1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2009
4  * Marvell Semiconductor <www.marvell.com>
5  * Prafulla Wadaskar <prafulla@marvell.com>
6  *
7  * (C) Copyright 2009
8  * Stefan Roese, DENX Software Engineering, sr@denx.de.
9  *
10  * (C) Copyright 2010-2011
11  * Heiko Schocher, DENX Software Engineering, hs@denx.de.
12  */
13 
14 /*
15  * for linking errors see
16  * http://lists.denx.de/pipermail/u-boot/2009-July/057350.html
17  */
18 
19 #ifndef _CONFIG_KM_ARM_H
20 #define _CONFIG_KM_ARM_H
21 
22 /*
23  * High Level Configuration Options (easy to change)
24  */
25 #define CONFIG_FEROCEON_88FR131		/* CPU Core subversion */
26 #define CONFIG_KW88F6281		/* SOC Name */
27 
28 #define CONFIG_MACH_TYPE	MACH_TYPE_KM_KIRKWOOD
29 
30 #define CONFIG_NAND_ECC_BCH
31 
32 /* include common defines/options for all Keymile boards */
33 #include "keymile-common.h"
34 
35 /* Reserve 4 MB for malloc */
36 #define CONFIG_SYS_MALLOC_LEN		(4 * 1024 * 1024)
37 
38 /* Increase max size of compressed kernel */
39 #define CONFIG_SYS_BOOTM_LEN		(32 << 20)
40 
41 #include "asm/arch/config.h"
42 
43 #define CONFIG_SYS_LOAD_ADDR	0x00800000	/* default load adr- 8M */
44 
45 /* architecture specific default bootargs */
46 #define CONFIG_KM_DEF_BOOT_ARGS_CPU					\
47 		"bootcountaddr=${bootcountaddr} ${mtdparts}"		\
48 		" boardid=0x${IVM_BoardId} hwkey=0x${IVM_HWKey}"
49 
50 #define CONFIG_KM_DEF_ENV_CPU						\
51 	"u-boot=" CONFIG_HOSTNAME "/u-boot.kwb\0"		\
52 	CONFIG_KM_UPDATE_UBOOT						\
53 	"set_fdthigh=setenv fdt_high ${kernelmem}\0"			\
54 	"checkfdt="							\
55 		"if cramfsls fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb; "	\
56 		"then true; else setenv cramfsloadfdt true; "		\
57 		"setenv boot bootm ${load_addr_r}; "			\
58 		"echo No FDT found, booting with the kernel "		\
59 		"appended one; fi\0"					\
60 	""
61 
62 #define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
63 
64 /*
65  * For booting Linux, the board info and command line data
66  * have to be in the first 8 MB of memory, since this is
67  * the maximum mapped by the Linux kernel during initialization.
68  */
69 #define CONFIG_CMDLINE_TAG		/* enable passing of ATAGs  */
70 #define CONFIG_INITRD_TAG		/* enable INITRD tag */
71 #define CONFIG_SETUP_MEMORY_TAGS	/* enable memory tag */
72 
73 /*
74  * NAND Flash configuration
75  */
76 #define CONFIG_SYS_MAX_NAND_DEVICE	1
77 
78 /*
79  * Other required minimal configurations
80  */
81 
82 /*
83  * Ethernet Driver configuration
84  */
85 #define PHY_ANEG_TIMEOUT	8000	/* PHY needs a longer autoneg timeout */
86 #define CONFIG_MVGBE_PORTS	{1, 0}	/* enable port 0 only */
87 #define CONFIG_PHY_BASE_ADR	0
88 
89 /*
90  * I2C related stuff
91  */
92 #undef CONFIG_I2C_MVTWSI
93 #define CONFIG_SYS_I2C
94 #define	CONFIG_SYS_I2C_SOFT	/* I2C bit-banged	*/
95 #define CONFIG_SYS_I2C_INIT_BOARD
96 
97 #define	CONFIG_KIRKWOOD_GPIO		/* Enable GPIO Support */
98 #define CONFIG_SYS_NUM_I2C_BUSES	6
99 #define CONFIG_SYS_I2C_MAX_HOPS		1
100 #define CONFIG_SYS_I2C_BUSES	{	{0, {I2C_NULL_HOP} }, \
101 					{0, {{I2C_MUX_PCA9547, 0x70, 1} } }, \
102 					{0, {{I2C_MUX_PCA9547, 0x70, 2} } }, \
103 					{0, {{I2C_MUX_PCA9547, 0x70, 3} } }, \
104 					{0, {{I2C_MUX_PCA9547, 0x70, 4} } }, \
105 					{0, {{I2C_MUX_PCA9547, 0x70, 5} } }, \
106 				}
107 
108 #ifndef __ASSEMBLY__
109 #include <asm/arch/gpio.h>
110 #include <linux/delay.h>
111 #include <linux/stringify.h>
112 extern void __set_direction(unsigned pin, int high);
113 #define KM_KIRKWOOD_SDA_PIN	8
114 #define KM_KIRKWOOD_SCL_PIN	9
115 #define KM_KIRKWOOD_SOFT_I2C_GPIOS	0x0300
116 #define KM_KIRKWOOD_ENV_WP	38
117 
118 #define I2C_ACTIVE	__set_direction(KM_KIRKWOOD_SDA_PIN, 0)
119 #define I2C_TRISTATE	__set_direction(KM_KIRKWOOD_SDA_PIN, 1)
120 #define I2C_READ	(kw_gpio_get_value(KM_KIRKWOOD_SDA_PIN) ? 1 : 0)
121 #define I2C_SDA(bit)	kw_gpio_set_value(KM_KIRKWOOD_SDA_PIN, bit)
122 #define I2C_SCL(bit)	kw_gpio_set_value(KM_KIRKWOOD_SCL_PIN, bit)
123 #endif
124 
125 #define I2C_DELAY	udelay(1)
126 #define I2C_SOFT_DECLARATIONS
127 
128 #define	CONFIG_SYS_I2C_SOFT_SLAVE	0x0
129 #define	CONFIG_SYS_I2C_SOFT_SPEED	100000
130 
131 /* EEprom support 24C128, 24C256 valid for environment eeprom */
132 #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
133 #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	6 /* 64 Byte write page */
134 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
135 
136 #define CONFIG_SYS_I2C_EEPROM_ADDR	0x50
137 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN	2
138 
139 /*
140  *  Environment variables configurations
141  */
142 #if defined CONFIG_KM_ENV_IS_IN_SPI_NOR
143 #define CONFIG_ENV_TOTAL_SIZE		0x20000     /* no bracets! */
144 #else
145 #define CONFIG_SYS_DEF_EEPROM_ADDR	0x50
146 #define CONFIG_ENV_EEPROM_IS_ON_I2C
147 #define CONFIG_SYS_EEPROM_WREN
148 #define CONFIG_I2C_ENV_EEPROM_BUS 5 /* I2C2 (Mux-Port 5) */
149 #endif
150 
151 #define KM_FLASH_GPIO_PIN	16
152 
153 #define	CONFIG_KM_UPDATE_UBOOT						\
154 	"update="							\
155 		"sf probe 0;sf erase 0 +${filesize};"			\
156 		"sf write ${load_addr_r} 0 ${filesize};\0"
157 
158 #if defined CONFIG_KM_ENV_IS_IN_SPI_NOR
159 #define CONFIG_KM_NEW_ENV						\
160 	"newenv=sf probe 0;"						\
161 		"sf erase " __stringify(CONFIG_ENV_OFFSET) " "		\
162 		__stringify(CONFIG_ENV_TOTAL_SIZE)"\0"
163 #else
164 #define CONFIG_KM_NEW_ENV						\
165 	"newenv=setenv addr 0x100000 && "				\
166 		"i2c dev " __stringify(CONFIG_I2C_ENV_EEPROM_BUS) "; "  \
167 		"mw.b ${addr} 0 4 && "					\
168 		"eeprom write " __stringify(CONFIG_SYS_DEF_EEPROM_ADDR)	\
169 		" ${addr} " __stringify(CONFIG_ENV_OFFSET) " 4 && "	\
170 		"eeprom write " __stringify(CONFIG_SYS_DEF_EEPROM_ADDR)	\
171 		" ${addr} " __stringify(CONFIG_ENV_OFFSET_REDUND) " 4\0"
172 #endif
173 
174 #ifndef CONFIG_KM_BOARD_EXTRA_ENV
175 #define CONFIG_KM_BOARD_EXTRA_ENV       ""
176 #endif
177 
178 /*
179  * Default environment variables
180  */
181 #define CONFIG_EXTRA_ENV_SETTINGS					\
182 	CONFIG_KM_BOARD_EXTRA_ENV					\
183 	CONFIG_KM_DEF_ENV						\
184 	CONFIG_KM_NEW_ENV						\
185 	"arch=arm\0"							\
186 	""
187 
188 /* additions for new relocation code, must be added to all boards */
189 #define CONFIG_SYS_SDRAM_BASE		0x00000000
190 
191 /* address for the bootcount (taken from end of RAM) */
192 #define BOOTCOUNT_ADDR          (CONFIG_KM_RESERVED_PRAM)
193 
194 /* enable POST tests */
195 #define CONFIG_POST	(CONFIG_SYS_POST_MEM_REGIONS)
196 #define CONFIG_POST_SKIP_ENV_FLAGS
197 #define CONFIG_POST_EXTERNAL_WORD_FUNCS
198 
199 #endif /* _CONFIG_KM_ARM_H */
200