SPDX: Convert all of our single license tags to Linux Kernel style
[platform/kernel/u-boot.git] / include / configs / tqma6.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2013, 2014, 2017 Markus Niebel <Markus.Niebel@tq-group.com>
4  *
5  * Configuration settings for the TQ Systems TQMa6<Q,D,DL,S> module.
6  */
7
8 #ifndef __CONFIG_H
9 #define __CONFIG_H
10
11 #include <linux/kconfig.h>
12 /* SPL */
13 /* #if defined(CONFIG_SPL_BUILD) */
14 /* common IMX6 SPL configuration */
15 #include "imx6_spl.h"
16
17 /* #endif */
18
19 /* place code in last 4 MiB of RAM */
20
21 #include "mx6_common.h"
22
23 #if defined(CONFIG_TQMA6S)
24 #define PHYS_SDRAM_SIZE                 (512u * SZ_1M)
25 #elif defined(CONFIG_TQMA6DL)
26 #define PHYS_SDRAM_SIZE                 (SZ_1G)
27 #elif defined(CONFIG_TQMA6Q)
28 #define PHYS_SDRAM_SIZE                 (SZ_1G)
29 #endif
30
31 #define CONFIG_MXC_UART
32
33 /* SPI Flash */
34
35 #define TQMA6_SPI_FLASH_SECTOR_SIZE     SZ_64K
36
37 #define CONFIG_SF_DEFAULT_BUS   0
38 #define CONFIG_SF_DEFAULT_CS    0
39 #define CONFIG_SF_DEFAULT_SPEED 50000000
40 #define CONFIG_SF_DEFAULT_MODE  (SPI_MODE_0)
41
42 /* I2C Configs */
43 #define CONFIG_SYS_I2C
44 #define CONFIG_SYS_I2C_MXC
45 #define CONFIG_SYS_I2C_MXC_I2C1         /* enable I2C bus 1 */
46 #define CONFIG_SYS_I2C_MXC_I2C2         /* enable I2C bus 2 */
47 #define CONFIG_SYS_I2C_MXC_I2C3         /* enable I2C bus 3 */
48 #define CONFIG_I2C_MULTI_BUS
49 #define CONFIG_SYS_I2C_SPEED            100000
50
51 /* I2C EEPROM (M24C64) */
52 #define CONFIG_SYS_I2C_EEPROM_ADDR                      0x50
53 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN                  2
54 #define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_BITS           5 /* 32 Bytes */
55 #define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_DELAY_MS       20
56
57 #define CONFIG_POWER
58 #define CONFIG_POWER_I2C
59 #define CONFIG_POWER_PFUZE100
60 #define CONFIG_POWER_PFUZE100_I2C_ADDR  0x08
61 #define TQMA6_PFUZE100_I2C_BUS          2
62
63 /* MMC Configs */
64 #define CONFIG_SYS_FSL_ESDHC_ADDR       0
65
66 /* USB Configs */
67 #define CONFIG_MXC_USB_PORTSC   (PORT_PTS_UTMI | PORT_PTS_PTW)
68 #define CONFIG_USB_MAX_CONTROLLER_COUNT 2
69 #define CONFIG_EHCI_HCD_INIT_AFTER_RESET        /* For OTG port */
70
71 #define CONFIG_FEC_MXC
72 #define IMX_FEC_BASE                    ENET_BASE_ADDR
73 #define CONFIG_MII
74
75 #define CONFIG_ARP_TIMEOUT              200UL
76
77 #define CONFIG_ENV_SIZE                 (SZ_8K)
78 /* Size of malloc() pool */
79 #define CONFIG_SYS_MALLOC_LEN           (CONFIG_ENV_SIZE + 2 * SZ_1M)
80
81 #if defined(CONFIG_TQMA6X_MMC_BOOT)
82
83 #define TQMA6_UBOOT_OFFSET              SZ_1K
84 #define TQMA6_UBOOT_SECTOR_START        0x2
85 #define TQMA6_UBOOT_SECTOR_COUNT        0x7fe
86
87 #define CONFIG_ENV_OFFSET               SZ_1M
88 #define CONFIG_SYS_MMC_ENV_DEV          0
89
90 #define TQMA6_FDT_OFFSET                (2 * SZ_1M)
91 #define TQMA6_FDT_SECTOR_START          0x1000
92 #define TQMA6_FDT_SECTOR_COUNT          0x800
93
94 #define TQMA6_KERNEL_SECTOR_START       0x2000
95 #define TQMA6_KERNEL_SECTOR_COUNT       0x2000
96
97 #define TQMA6_EXTRA_BOOTDEV_ENV_SETTINGS                                       \
98         "uboot_start="__stringify(TQMA6_UBOOT_SECTOR_START)"\0"                \
99         "uboot_size="__stringify(TQMA6_UBOOT_SECTOR_COUNT)"\0"                 \
100         "fdt_start="__stringify(TQMA6_FDT_SECTOR_START)"\0"                    \
101         "fdt_size="__stringify(TQMA6_FDT_SECTOR_COUNT)"\0"                     \
102         "kernel_start="__stringify(TQMA6_KERNEL_SECTOR_START)"\0"              \
103         "kernel_size="__stringify(TQMA6_KERNEL_SECTOR_COUNT)"\0"               \
104         "mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0"                       \
105         "loadimage=mmc dev ${mmcdev}; "                                        \
106                 "mmc read ${loadaddr} ${kernel_start} ${kernel_size};\0"       \
107         "loadfdt=mmc dev ${mmcdev}; "                                          \
108                 "mmc read ${fdt_addr} ${fdt_start} ${fdt_size};\0"             \
109         "update_uboot=if tftp ${uboot}; then "                                 \
110                 "if itest ${filesize} > 0; then "                              \
111                         "mmc dev ${mmcdev}; mmc rescan; "                      \
112                         "setexpr blkc ${filesize} + 0x1ff; "                   \
113                         "setexpr blkc ${blkc} / 0x200; "                       \
114                         "if itest ${blkc} <= ${uboot_size}; then "             \
115                                 "mmc write ${loadaddr} ${uboot_start} "        \
116                                         "${blkc}; "                            \
117                         "fi; "                                                 \
118                 "fi; fi; "                                                     \
119                 "setenv filesize; setenv blkc \0"                              \
120         "update_kernel=run kernel_name; "                                      \
121                 "if tftp ${kernel}; then "                                     \
122                         "if itest ${filesize} > 0; then "                      \
123                                 "mmc dev ${mmcdev}; mmc rescan; "              \
124                                 "setexpr blkc ${filesize} + 0x1ff; "           \
125                                 "setexpr blkc ${blkc} / 0x200; "               \
126                                 "if itest ${blkc} <= ${kernel_size}; then "    \
127                                         "mmc write ${loadaddr} "               \
128                                                 "${kernel_start} ${blkc}; "    \
129                                 "fi; "                                         \
130                         "fi; "                                                 \
131                 "fi; "                                                         \
132                 "setenv filesize; setenv blkc \0"                              \
133         "update_fdt=if tftp ${fdt_file}; then "                                \
134                 "if itest ${filesize} > 0; then "                              \
135                         "mmc dev ${mmcdev}; mmc rescan; "                      \
136                         "setexpr blkc ${filesize} + 0x1ff; "                   \
137                         "setexpr blkc ${blkc} / 0x200; "                       \
138                         "if itest ${blkc} <= ${fdt_size}; then "               \
139                                 "mmc write ${loadaddr} ${fdt_start} ${blkc}; " \
140                         "fi; "                                                 \
141                 "fi; fi; "                                                     \
142                 "setenv filesize; setenv blkc \0"                              \
143
144 #define CONFIG_BOOTCOMMAND \
145         "run mmcboot; run netboot; run panicboot"
146
147 #elif defined(CONFIG_TQMA6X_SPI_BOOT)
148
149 #define TQMA6_UBOOT_OFFSET              0x400
150 #define TQMA6_UBOOT_SECTOR_START        0x0
151 /* max u-boot size: 512k */
152 #define TQMA6_UBOOT_SECTOR_SIZE         TQMA6_SPI_FLASH_SECTOR_SIZE
153 #define TQMA6_UBOOT_SECTOR_COUNT        0x8
154 #define TQMA6_UBOOT_SIZE                (TQMA6_UBOOT_SECTOR_SIZE * \
155                                          TQMA6_UBOOT_SECTOR_COUNT)
156
157 #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
158 #define CONFIG_ENV_OFFSET               (TQMA6_UBOOT_SIZE)
159 #define CONFIG_ENV_SECT_SIZE            TQMA6_SPI_FLASH_SECTOR_SIZE
160 #define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + \
161                                          CONFIG_ENV_SECT_SIZE)
162
163 #define CONFIG_ENV_SPI_BUS              (CONFIG_SF_DEFAULT_BUS)
164 #define CONFIG_ENV_SPI_CS               (CONFIG_SF_DEFAULT_CS)
165 #define CONFIG_ENV_SPI_MAX_HZ           (CONFIG_SF_DEFAULT_SPEED)
166 #define CONFIG_ENV_SPI_MODE             (CONFIG_SF_DEFAULT_MODE)
167
168 #define TQMA6_FDT_OFFSET                (CONFIG_ENV_OFFSET_REDUND + \
169                                          CONFIG_ENV_SECT_SIZE)
170 #define TQMA6_FDT_SECT_SIZE             (TQMA6_SPI_FLASH_SECTOR_SIZE)
171
172 #define TQMA6_FDT_SECTOR_START          0x0a /* 8 Sector u-boot, 2 Sector env */
173 #define TQMA6_FDT_SECTOR_COUNT          0x01
174
175 #define TQMA6_KERNEL_SECTOR_START       0x10
176 #define TQMA6_KERNEL_SECTOR_COUNT       0x60
177
178 #define TQMA6_EXTRA_BOOTDEV_ENV_SETTINGS                                       \
179         "mmcblkdev=0\0"                                                        \
180         "uboot_offset="__stringify(TQMA6_UBOOT_OFFSET)"\0"                     \
181         "uboot_sectors="__stringify(TQMA6_UBOOT_SECTOR_COUNT)"\0"              \
182         "fdt_start="__stringify(TQMA6_FDT_SECTOR_START)"\0"                    \
183         "fdt_sectors="__stringify(TQMA6_FDT_SECTOR_COUNT)"\0"                  \
184         "kernel_start="__stringify(TQMA6_KERNEL_SECTOR_START)"\0"              \
185         "kernel_sectors="__stringify(TQMA6_KERNEL_SECTOR_COUNT)"\0"            \
186         "update_uboot=if tftp ${uboot}; then "                                 \
187                 "if itest ${filesize} > 0; then "                              \
188                         "setexpr blkc ${filesize} + "                          \
189                                 __stringify(TQMA6_UBOOT_OFFSET) "; "           \
190                         "setexpr size ${uboot_sectors} * "                     \
191                                 __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
192                         "if itest ${blkc} <= ${size}; then "                   \
193                                 "sf probe; "                                   \
194                                 "sf erase 0 ${size}; "                         \
195                                 "sf write ${loadaddr} ${uboot_offset} "        \
196                                         "${filesize}; "                        \
197                         "fi; "                                                 \
198                 "fi; fi; "                                                     \
199                 "setenv filesize 0; setenv blkc; setenv size \0"               \
200         "update_kernel=run kernel_name; if tftp ${kernel}; then "              \
201                 "if itest ${filesize} > 0; then "                              \
202                         "setexpr size ${kernel_sectors} * "                    \
203                                 __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
204                         "setexpr offset ${kernel_start} * "                    \
205                                 __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
206                         "if itest ${filesize} <= ${size}; then "               \
207                                 "sf probe; "                                   \
208                                 "sf erase ${offset} ${size}; "                 \
209                                 "sf write ${loadaddr} ${offset} "              \
210                                         "${filesize}; "                        \
211                         "fi; "                                                 \
212                 "fi; fi; "                                                     \
213                 "setenv filesize 0; setenv size ; setenv offset\0"             \
214         "update_fdt=if tftp ${fdt_file}; then "                                \
215                 "if itest ${filesize} > 0; then "                              \
216                         "setexpr size ${fdt_sectors} * "                       \
217                                 __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
218                         "setexpr offset ${fdt_start} * "                       \
219                                 __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "   \
220                         "if itest ${filesize} <= ${size}; then "               \
221                                 "sf probe; "                                   \
222                                 "sf erase ${offset} ${size}; "                 \
223                                 "sf write ${loadaddr} ${offset} "              \
224                                         "${filesize}; "                        \
225                         "fi; "                                                 \
226                 "fi; fi; "                                                     \
227                 "setenv filesize 0; setenv size ; setenv offset\0"             \
228         "loadimage=sf probe; "                                                 \
229                 "setexpr size ${kernel_sectors} * "                            \
230                         __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
231                 "setexpr offset ${kernel_start} * "                            \
232                         __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
233                 "sf read ${loadaddr} ${offset} ${size}; "                      \
234                 "setenv size ; setenv offset\0"                                \
235         "loadfdt=sf probe; "                                                   \
236                 "setexpr size ${fdt_sectors} * "                               \
237                         __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
238                 "setexpr offset ${fdt_start} * "                               \
239                         __stringify(TQMA6_SPI_FLASH_SECTOR_SIZE)"; "           \
240                 "sf read ${fdt_addr} ${offset} ${size}; "                      \
241                 "setenv size ; setenv offset\0"                                \
242
243 #define CONFIG_BOOTCOMMAND                                                     \
244         "sf probe; run mmcboot; run netboot; run panicboot"                    \
245
246 #else
247
248 #error "need to define boot source"
249
250 #endif
251
252 /* 128 MiB offset as in ARM related docu for linux suggested */
253 #define TQMA6_FDT_ADDRESS               0x18000000
254
255 /* set to a resonable value, changeable by user */
256 #define TQMA6_CMA_SIZE                 160M
257
258 #define CONFIG_EXTRA_ENV_SETTINGS                                              \
259         "board=tqma6\0"                                                        \
260         "uimage=uImage\0"                                                      \
261         "zimage=zImage\0"                                                      \
262         "boot_type=bootz\0"                                                    \
263         "kernel_name=if test \"${boot_type}\" != bootz; then "                 \
264                 "setenv kernel ${uimage}; "                                    \
265                 "else setenv kernel ${zimage}; fi\0"                           \
266         "uboot=u-boot.imx\0"                                                   \
267         "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0"                               \
268         "fdt_addr="__stringify(TQMA6_FDT_ADDRESS)"\0"                          \
269         "console=" CONSOLE_DEV "\0"                                            \
270         "cma_size="__stringify(TQMA6_CMA_SIZE)"\0"                             \
271         "fdt_high=0xffffffff\0"                                                \
272         "initrd_high=0xffffffff\0"                                             \
273         "rootfsmode=ro\0"                                                      \
274         "addcma=setenv bootargs ${bootargs} cma=${cma_size}\0"                 \
275         "addtty=setenv bootargs ${bootargs} console=${console},${baudrate}\0"  \
276         "addfb=setenv bootargs ${bootargs} "                                   \
277                 "imx-fbdev.legacyfb_depth=32 consoleblank=0\0"                 \
278         "mmcpart=2\0"                                                          \
279         "mmcblkdev=0\0"                                                        \
280         "mmcargs=run addmmc addtty addfb addcma\0"                             \
281         "addmmc=setenv bootargs ${bootargs} "                                  \
282                 "root=/dev/mmcblk${mmcblkdev}p${mmcpart} ${rootfsmode} "       \
283                 "rootwait\0"                                                   \
284         "mmcboot=echo Booting from mmc ...; "                                  \
285                 "setenv bootargs; "                                            \
286                 "run mmcargs; "                                                \
287                 "run loadimage; "                                              \
288                 "if run loadfdt; then "                                        \
289                         "echo boot device tree kernel ...; "                   \
290                         "${boot_type} ${loadaddr} - ${fdt_addr}; "             \
291                 "else "                                                        \
292                         "${boot_type}; "                                       \
293                 "fi;\0"                                                        \
294                 "setenv bootargs \0"                                           \
295         "netdev=eth0\0"                                                        \
296         "rootpath=/srv/nfs/tqma6\0"                                            \
297         "ipmode=static\0"                                                      \
298         "netargs=run addnfs addip addtty addfb addcma\0"                       \
299         "addnfs=setenv bootargs ${bootargs} "                                  \
300                 "root=/dev/nfs rw "                                            \
301                 "nfsroot=${serverip}:${rootpath},v3,tcp;\0"                    \
302         "addip_static=setenv bootargs ${bootargs} "                            \
303                 "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:"            \
304                 "${hostname}:${netdev}:off\0"                                  \
305         "addip_dynamic=setenv bootargs ${bootargs} ip=dhcp\0"                  \
306         "addip=if test \"${ipmode}\" != static; then "                         \
307                 "run addip_dynamic; else run addip_static; fi\0"               \
308         "set_getcmd=if test \"${ipmode}\" != static; then "                    \
309                 "setenv getcmd dhcp; setenv autoload yes; "                    \
310                 "else setenv getcmd tftp; setenv autoload no; fi\0"            \
311         "netboot=echo Booting from net ...; "                                  \
312                 "run kernel_name; "                                            \
313                 "run set_getcmd; "                                             \
314                 "setenv bootargs; "                                            \
315                 "run netargs; "                                                \
316                 "if ${getcmd} ${kernel}; then "                                \
317                         "if ${getcmd} ${fdt_addr} ${fdt_file}; then "          \
318                                 "${boot_type} ${loadaddr} - ${fdt_addr}; "     \
319                         "fi; "                                                 \
320                 "fi; "                                                         \
321                 "echo ... failed\0"                                            \
322         "panicboot=echo No boot device !!! reset\0"                            \
323         TQMA6_EXTRA_BOOTDEV_ENV_SETTINGS                                      \
324
325 /* Physical Memory Map */
326 #define CONFIG_NR_DRAM_BANKS            1
327 #define PHYS_SDRAM                      MMDC0_ARB_BASE_ADDR
328
329 #define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM
330 #define CONFIG_SYS_INIT_RAM_ADDR        IRAM_BASE_ADDR
331 #define CONFIG_SYS_INIT_RAM_SIZE        IRAM_SIZE
332
333 #define CONFIG_SYS_INIT_SP_OFFSET \
334         (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
335 #define CONFIG_SYS_INIT_SP_ADDR \
336         (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
337
338 /*
339  * All the defines above are for the TQMa6 SoM
340  *
341  * Now include the baseboard specific configuration
342  */
343 #ifdef CONFIG_MBA6
344 #include "tqma6_mba6.h"
345 #elif CONFIG_WRU4
346 #include "tqma6_wru4.h"
347 #else
348 #error "No baseboard for the TQMa6 defined!"
349 #endif
350
351 /* Support at least the sensor on TQMa6 SOM */
352
353 #endif /* __CONFIG_H */