Commit 2a5c6cdc48fb68615fecc6c2cbe8016d7980f590
1 parent
0cea25608d
Exists in
v2015.07-smarct33-emmc
and in
1 other branch
Optimize DDR3L parameter for Samsung and Micron DDR3L
Showing 3 changed files with 112 additions and 36 deletions Inline Diff
arch/arm/cpu/armv7/am33xx/board.c
1 | /* | 1 | /* |
2 | * board.c | 2 | * board.c |
3 | * | 3 | * |
4 | * Common board functions for AM33XX based boards | 4 | * Common board functions for AM33XX based boards |
5 | * | 5 | * |
6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ | 6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
7 | * | 7 | * |
8 | * SPDX-License-Identifier: GPL-2.0+ | 8 | * SPDX-License-Identifier: GPL-2.0+ |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <common.h> | 11 | #include <common.h> |
12 | #include <dm.h> | 12 | #include <dm.h> |
13 | #include <errno.h> | 13 | #include <errno.h> |
14 | #include <ns16550.h> | 14 | #include <ns16550.h> |
15 | #include <spl.h> | 15 | #include <spl.h> |
16 | #include <asm/arch/cpu.h> | 16 | #include <asm/arch/cpu.h> |
17 | #include <asm/arch/hardware.h> | 17 | #include <asm/arch/hardware.h> |
18 | #include <asm/arch/omap.h> | 18 | #include <asm/arch/omap.h> |
19 | #include <asm/arch/ddr_defs.h> | 19 | #include <asm/arch/ddr_defs.h> |
20 | #include <asm/arch/clock.h> | 20 | #include <asm/arch/clock.h> |
21 | #include <asm/arch/gpio.h> | 21 | #include <asm/arch/gpio.h> |
22 | #include <asm/arch/mem.h> | 22 | #include <asm/arch/mem.h> |
23 | #include <asm/arch/mmc_host_def.h> | 23 | #include <asm/arch/mmc_host_def.h> |
24 | #include <asm/arch/sys_proto.h> | 24 | #include <asm/arch/sys_proto.h> |
25 | #include <asm/io.h> | 25 | #include <asm/io.h> |
26 | #include <asm/emif.h> | 26 | #include <asm/emif.h> |
27 | #include <asm/gpio.h> | 27 | #include <asm/gpio.h> |
28 | #include <i2c.h> | 28 | #include <i2c.h> |
29 | #include <miiphy.h> | 29 | #include <miiphy.h> |
30 | #include <cpsw.h> | 30 | #include <cpsw.h> |
31 | #include <asm/errno.h> | 31 | #include <asm/errno.h> |
32 | #include <linux/compiler.h> | 32 | #include <linux/compiler.h> |
33 | #include <linux/usb/ch9.h> | 33 | #include <linux/usb/ch9.h> |
34 | #include <linux/usb/gadget.h> | 34 | #include <linux/usb/gadget.h> |
35 | #include <linux/usb/musb.h> | 35 | #include <linux/usb/musb.h> |
36 | #include <asm/omap_musb.h> | 36 | #include <asm/omap_musb.h> |
37 | #include <asm/davinci_rtc.h> | 37 | #include <asm/davinci_rtc.h> |
38 | 38 | ||
39 | DECLARE_GLOBAL_DATA_PTR; | 39 | DECLARE_GLOBAL_DATA_PTR; |
40 | 40 | ||
41 | #ifdef CONFIG_DM_GPIO | 41 | #ifdef CONFIG_DM_GPIO |
42 | static const struct omap_gpio_platdata am33xx_gpio[] = { | 42 | static const struct omap_gpio_platdata am33xx_gpio[] = { |
43 | { 0, AM33XX_GPIO0_BASE, METHOD_GPIO_24XX }, | 43 | { 0, AM33XX_GPIO0_BASE, METHOD_GPIO_24XX }, |
44 | { 1, AM33XX_GPIO1_BASE, METHOD_GPIO_24XX }, | 44 | { 1, AM33XX_GPIO1_BASE, METHOD_GPIO_24XX }, |
45 | { 2, AM33XX_GPIO2_BASE, METHOD_GPIO_24XX }, | 45 | { 2, AM33XX_GPIO2_BASE, METHOD_GPIO_24XX }, |
46 | { 3, AM33XX_GPIO3_BASE, METHOD_GPIO_24XX }, | 46 | { 3, AM33XX_GPIO3_BASE, METHOD_GPIO_24XX }, |
47 | #ifdef CONFIG_AM43XX | 47 | #ifdef CONFIG_AM43XX |
48 | { 4, AM33XX_GPIO4_BASE, METHOD_GPIO_24XX }, | 48 | { 4, AM33XX_GPIO4_BASE, METHOD_GPIO_24XX }, |
49 | { 5, AM33XX_GPIO5_BASE, METHOD_GPIO_24XX }, | 49 | { 5, AM33XX_GPIO5_BASE, METHOD_GPIO_24XX }, |
50 | #endif | 50 | #endif |
51 | }; | 51 | }; |
52 | 52 | ||
53 | U_BOOT_DEVICES(am33xx_gpios) = { | 53 | U_BOOT_DEVICES(am33xx_gpios) = { |
54 | { "gpio_omap", &am33xx_gpio[0] }, | 54 | { "gpio_omap", &am33xx_gpio[0] }, |
55 | { "gpio_omap", &am33xx_gpio[1] }, | 55 | { "gpio_omap", &am33xx_gpio[1] }, |
56 | { "gpio_omap", &am33xx_gpio[2] }, | 56 | { "gpio_omap", &am33xx_gpio[2] }, |
57 | { "gpio_omap", &am33xx_gpio[3] }, | 57 | { "gpio_omap", &am33xx_gpio[3] }, |
58 | #ifdef CONFIG_AM43XX | 58 | #ifdef CONFIG_AM43XX |
59 | { "gpio_omap", &am33xx_gpio[4] }, | 59 | { "gpio_omap", &am33xx_gpio[4] }, |
60 | { "gpio_omap", &am33xx_gpio[5] }, | 60 | { "gpio_omap", &am33xx_gpio[5] }, |
61 | #endif | 61 | #endif |
62 | }; | 62 | }; |
63 | 63 | ||
64 | # ifndef CONFIG_OF_CONTROL | 64 | # ifndef CONFIG_OF_CONTROL |
65 | /* | 65 | /* |
66 | * TODO(sjg@chromium.org): When we can move SPL serial to DM, we can remove | 66 | * TODO(sjg@chromium.org): When we can move SPL serial to DM, we can remove |
67 | * the CONFIGs. At the same time, we should move this to the board files. | 67 | * the CONFIGs. At the same time, we should move this to the board files. |
68 | */ | 68 | */ |
69 | static const struct ns16550_platdata am33xx_serial[] = { | 69 | static const struct ns16550_platdata am33xx_serial[] = { |
70 | { CONFIG_SYS_NS16550_COM1, 2, CONFIG_SYS_NS16550_CLK }, | 70 | { CONFIG_SYS_NS16550_COM1, 2, CONFIG_SYS_NS16550_CLK }, |
71 | # ifdef CONFIG_SYS_NS16550_COM2 | 71 | # ifdef CONFIG_SYS_NS16550_COM2 |
72 | { CONFIG_SYS_NS16550_COM2, 2, CONFIG_SYS_NS16550_CLK }, | 72 | { CONFIG_SYS_NS16550_COM2, 2, CONFIG_SYS_NS16550_CLK }, |
73 | # ifdef CONFIG_SYS_NS16550_COM3 | 73 | # ifdef CONFIG_SYS_NS16550_COM3 |
74 | { CONFIG_SYS_NS16550_COM3, 2, CONFIG_SYS_NS16550_CLK }, | 74 | { CONFIG_SYS_NS16550_COM3, 2, CONFIG_SYS_NS16550_CLK }, |
75 | { CONFIG_SYS_NS16550_COM4, 2, CONFIG_SYS_NS16550_CLK }, | 75 | { CONFIG_SYS_NS16550_COM4, 2, CONFIG_SYS_NS16550_CLK }, |
76 | { CONFIG_SYS_NS16550_COM5, 2, CONFIG_SYS_NS16550_CLK }, | 76 | { CONFIG_SYS_NS16550_COM5, 2, CONFIG_SYS_NS16550_CLK }, |
77 | { CONFIG_SYS_NS16550_COM6, 2, CONFIG_SYS_NS16550_CLK }, | 77 | { CONFIG_SYS_NS16550_COM6, 2, CONFIG_SYS_NS16550_CLK }, |
78 | # endif | 78 | # endif |
79 | # endif | 79 | # endif |
80 | }; | 80 | }; |
81 | 81 | ||
82 | U_BOOT_DEVICES(am33xx_uarts) = { | 82 | U_BOOT_DEVICES(am33xx_uarts) = { |
83 | { "serial_omap", &am33xx_serial[0] }, | 83 | { "serial_omap", &am33xx_serial[0] }, |
84 | # ifdef CONFIG_SYS_NS16550_COM2 | 84 | # ifdef CONFIG_SYS_NS16550_COM2 |
85 | { "serial_omap", &am33xx_serial[1] }, | 85 | { "serial_omap", &am33xx_serial[1] }, |
86 | # ifdef CONFIG_SYS_NS16550_COM3 | 86 | # ifdef CONFIG_SYS_NS16550_COM3 |
87 | { "serial_omap", &am33xx_serial[2] }, | 87 | { "serial_omap", &am33xx_serial[2] }, |
88 | { "serial_omap", &am33xx_serial[3] }, | 88 | { "serial_omap", &am33xx_serial[3] }, |
89 | { "serial_omap", &am33xx_serial[4] }, | 89 | { "serial_omap", &am33xx_serial[4] }, |
90 | { "serial_omap", &am33xx_serial[5] }, | 90 | { "serial_omap", &am33xx_serial[5] }, |
91 | # endif | 91 | # endif |
92 | # endif | 92 | # endif |
93 | }; | 93 | }; |
94 | # endif | 94 | # endif |
95 | 95 | ||
96 | #else | 96 | #else |
97 | 97 | ||
98 | static const struct gpio_bank gpio_bank_am33xx[] = { | 98 | static const struct gpio_bank gpio_bank_am33xx[] = { |
99 | { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX }, | 99 | { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX }, |
100 | { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX }, | 100 | { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX }, |
101 | { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX }, | 101 | { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX }, |
102 | { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX }, | 102 | { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX }, |
103 | #ifdef CONFIG_AM43XX | 103 | #ifdef CONFIG_AM43XX |
104 | { (void *)AM33XX_GPIO4_BASE, METHOD_GPIO_24XX }, | 104 | { (void *)AM33XX_GPIO4_BASE, METHOD_GPIO_24XX }, |
105 | { (void *)AM33XX_GPIO5_BASE, METHOD_GPIO_24XX }, | 105 | { (void *)AM33XX_GPIO5_BASE, METHOD_GPIO_24XX }, |
106 | #endif | 106 | #endif |
107 | }; | 107 | }; |
108 | 108 | ||
109 | const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx; | 109 | const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx; |
110 | 110 | ||
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD) | 113 | #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD) |
114 | int cpu_mmc_init(bd_t *bis) | 114 | int cpu_mmc_init(bd_t *bis) |
115 | { | 115 | { |
116 | int ret; | 116 | int ret; |
117 | 117 | ||
118 | ret = omap_mmc_init(0, 0, 0, -1, -1); | 118 | ret = omap_mmc_init(0, 0, 0, -1, -1); |
119 | if (ret) | 119 | if (ret) |
120 | return ret; | 120 | return ret; |
121 | 121 | ||
122 | return omap_mmc_init(1, 0, 0, -1, -1); | 122 | return omap_mmc_init(1, 0, 0, -1, -1); |
123 | } | 123 | } |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | /* | 126 | /* |
127 | * RTC only mode magic value, checked against during boot to see if we have | 127 | * RTC only mode magic value, checked against during boot to see if we have |
128 | * a valid config | 128 | * a valid config |
129 | */ | 129 | */ |
130 | #define RTC_MAGIC_VAL 0x8cd0 | 130 | #define RTC_MAGIC_VAL 0x8cd0 |
131 | 131 | ||
132 | /* Board type field bit shift for RTC only mode */ | 132 | /* Board type field bit shift for RTC only mode */ |
133 | #define RTC_BOARD_TYPE_SHIFT 16 | 133 | #define RTC_BOARD_TYPE_SHIFT 16 |
134 | 134 | ||
135 | /* AM33XX has two MUSB controllers which can be host or gadget */ | 135 | /* AM33XX has two MUSB controllers which can be host or gadget */ |
136 | #if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) && \ | 136 | #if (defined(CONFIG_MUSB_GADGET) || defined(CONFIG_MUSB_HOST)) && \ |
137 | (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) | 137 | (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) |
138 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; | 138 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
139 | 139 | ||
140 | /* USB 2.0 PHY Control */ | 140 | /* USB 2.0 PHY Control */ |
141 | #define CM_PHY_PWRDN (1 << 0) | 141 | #define CM_PHY_PWRDN (1 << 0) |
142 | #define CM_PHY_OTG_PWRDN (1 << 1) | 142 | #define CM_PHY_OTG_PWRDN (1 << 1) |
143 | #define OTGVDET_EN (1 << 19) | 143 | #define OTGVDET_EN (1 << 19) |
144 | #define OTGSESSENDEN (1 << 20) | 144 | #define OTGSESSENDEN (1 << 20) |
145 | 145 | ||
146 | static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) | 146 | static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr) |
147 | { | 147 | { |
148 | if (on) { | 148 | if (on) { |
149 | clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, | 149 | clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN, |
150 | OTGVDET_EN | OTGSESSENDEN); | 150 | OTGVDET_EN | OTGSESSENDEN); |
151 | } else { | 151 | } else { |
152 | clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); | 152 | clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | static struct musb_hdrc_config musb_config = { | 156 | static struct musb_hdrc_config musb_config = { |
157 | .multipoint = 1, | 157 | .multipoint = 1, |
158 | .dyn_fifo = 1, | 158 | .dyn_fifo = 1, |
159 | .num_eps = 16, | 159 | .num_eps = 16, |
160 | .ram_bits = 12, | 160 | .ram_bits = 12, |
161 | }; | 161 | }; |
162 | 162 | ||
163 | #ifdef CONFIG_AM335X_USB0 | 163 | #ifdef CONFIG_AM335X_USB0 |
164 | static void am33xx_otg0_set_phy_power(u8 on) | 164 | static void am33xx_otg0_set_phy_power(u8 on) |
165 | { | 165 | { |
166 | am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0); | 166 | am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0); |
167 | } | 167 | } |
168 | 168 | ||
169 | struct omap_musb_board_data otg0_board_data = { | 169 | struct omap_musb_board_data otg0_board_data = { |
170 | .set_phy_power = am33xx_otg0_set_phy_power, | 170 | .set_phy_power = am33xx_otg0_set_phy_power, |
171 | }; | 171 | }; |
172 | 172 | ||
173 | static struct musb_hdrc_platform_data otg0_plat = { | 173 | static struct musb_hdrc_platform_data otg0_plat = { |
174 | .mode = CONFIG_AM335X_USB0_MODE, | 174 | .mode = CONFIG_AM335X_USB0_MODE, |
175 | .config = &musb_config, | 175 | .config = &musb_config, |
176 | .power = 50, | 176 | .power = 50, |
177 | .platform_ops = &musb_dsps_ops, | 177 | .platform_ops = &musb_dsps_ops, |
178 | .board_data = &otg0_board_data, | 178 | .board_data = &otg0_board_data, |
179 | }; | 179 | }; |
180 | #endif | 180 | #endif |
181 | 181 | ||
182 | #ifdef CONFIG_AM335X_USB1 | 182 | #ifdef CONFIG_AM335X_USB1 |
183 | static void am33xx_otg1_set_phy_power(u8 on) | 183 | static void am33xx_otg1_set_phy_power(u8 on) |
184 | { | 184 | { |
185 | am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1); | 185 | am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1); |
186 | } | 186 | } |
187 | 187 | ||
188 | struct omap_musb_board_data otg1_board_data = { | 188 | struct omap_musb_board_data otg1_board_data = { |
189 | .set_phy_power = am33xx_otg1_set_phy_power, | 189 | .set_phy_power = am33xx_otg1_set_phy_power, |
190 | }; | 190 | }; |
191 | 191 | ||
192 | static struct musb_hdrc_platform_data otg1_plat = { | 192 | static struct musb_hdrc_platform_data otg1_plat = { |
193 | .mode = CONFIG_AM335X_USB1_MODE, | 193 | .mode = CONFIG_AM335X_USB1_MODE, |
194 | .config = &musb_config, | 194 | .config = &musb_config, |
195 | .power = 50, | 195 | .power = 50, |
196 | .platform_ops = &musb_dsps_ops, | 196 | .platform_ops = &musb_dsps_ops, |
197 | .board_data = &otg1_board_data, | 197 | .board_data = &otg1_board_data, |
198 | }; | 198 | }; |
199 | #endif | 199 | #endif |
200 | #endif | 200 | #endif |
201 | 201 | ||
202 | int arch_misc_init(void) | 202 | int arch_misc_init(void) |
203 | { | 203 | { |
204 | #ifdef CONFIG_AM335X_USB0 | 204 | #ifdef CONFIG_AM335X_USB0 |
205 | musb_register(&otg0_plat, &otg0_board_data, | 205 | musb_register(&otg0_plat, &otg0_board_data, |
206 | (void *)USB0_OTG_BASE); | 206 | (void *)USB0_OTG_BASE); |
207 | #endif | 207 | #endif |
208 | #ifdef CONFIG_AM335X_USB1 | 208 | #ifdef CONFIG_AM335X_USB1 |
209 | musb_register(&otg1_plat, &otg1_board_data, | 209 | musb_register(&otg1_plat, &otg1_board_data, |
210 | (void *)USB1_OTG_BASE); | 210 | (void *)USB1_OTG_BASE); |
211 | #endif | 211 | #endif |
212 | return 0; | 212 | return 0; |
213 | } | 213 | } |
214 | 214 | ||
215 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT | 215 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
216 | 216 | ||
217 | #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) || \ | 217 | #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) || \ |
218 | (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT)) | 218 | (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT)) |
219 | static void rtc32k_unlock(struct davinci_rtc *rtc) | 219 | static void rtc32k_unlock(struct davinci_rtc *rtc) |
220 | { | 220 | { |
221 | /* | 221 | /* |
222 | * Unlock the RTC's registers. For more details please see the | 222 | * Unlock the RTC's registers. For more details please see the |
223 | * RTC_SS section of the TRM. In order to unlock we need to | 223 | * RTC_SS section of the TRM. In order to unlock we need to |
224 | * write these specific values (keys) in this order. | 224 | * write these specific values (keys) in this order. |
225 | */ | 225 | */ |
226 | writel(RTC_KICK0R_WE, &rtc->kick0r); | 226 | writel(RTC_KICK0R_WE, &rtc->kick0r); |
227 | writel(RTC_KICK1R_WE, &rtc->kick1r); | 227 | writel(RTC_KICK1R_WE, &rtc->kick1r); |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | 230 | ||
231 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) | 231 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) |
232 | /* | 232 | /* |
233 | * Write contents of the RTC_SCRATCH1 register based on board type | 233 | * Write contents of the RTC_SCRATCH1 register based on board type |
234 | * Two things are passed | 234 | * Two things are passed |
235 | * on. First 16 bits (0:15) are written with RTC_MAGIC value. Once the | 235 | * on. First 16 bits (0:15) are written with RTC_MAGIC value. Once the |
236 | * control gets to kernel, kernel reads the scratchpad register and gets to | 236 | * control gets to kernel, kernel reads the scratchpad register and gets to |
237 | * know that bootloader has rtc_only support. | 237 | * know that bootloader has rtc_only support. |
238 | * | 238 | * |
239 | * Second important thing is the board type (16:31). This is needed in the | 239 | * Second important thing is the board type (16:31). This is needed in the |
240 | * rtc_only boot where in we want to avoid costly i2c reads to eeprom to | 240 | * rtc_only boot where in we want to avoid costly i2c reads to eeprom to |
241 | * identify the board type and we go ahead and copy the board strings to | 241 | * identify the board type and we go ahead and copy the board strings to |
242 | * am43xx_board_name. | 242 | * am43xx_board_name. |
243 | */ | 243 | */ |
244 | void update_rtc_magic(void) | 244 | void update_rtc_magic(void) |
245 | { | 245 | { |
246 | struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE; | 246 | struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE; |
247 | u32 magic = RTC_MAGIC_VAL; | 247 | u32 magic = RTC_MAGIC_VAL; |
248 | magic |= (rtc_only_get_board_type() << RTC_BOARD_TYPE_SHIFT); | 248 | magic |= (rtc_only_get_board_type() << RTC_BOARD_TYPE_SHIFT); |
249 | 249 | ||
250 | rtc32k_unlock(rtc); | 250 | rtc32k_unlock(rtc); |
251 | 251 | ||
252 | /* write magic */ | 252 | /* write magic */ |
253 | writel(magic, &rtc->scratch1); | 253 | writel(magic, &rtc->scratch1); |
254 | } | 254 | } |
255 | #endif | 255 | #endif |
256 | 256 | ||
257 | /* | 257 | /* |
258 | * In the case of non-SPL based booting we'll want to call these | 258 | * In the case of non-SPL based booting we'll want to call these |
259 | * functions a tiny bit later as it will require gd to be set and cleared | 259 | * functions a tiny bit later as it will require gd to be set and cleared |
260 | * and that's not true in s_init in this case so we cannot do it there. | 260 | * and that's not true in s_init in this case so we cannot do it there. |
261 | */ | 261 | */ |
262 | int board_early_init_f(void) | 262 | int board_early_init_f(void) |
263 | { | 263 | { |
264 | #ifdef CONFIG_NOR_BOOT | ||
265 | gd->baudrate = CONFIG_BAUDRATE; | ||
266 | serial_init(); | ||
267 | gd->have_console = 1; | ||
268 | #elif defined(CONFIG_SPL_BUILD) | ||
269 | preloader_console_init(); | ||
270 | #endif | ||
271 | prcm_init(); | 264 | prcm_init(); |
272 | set_mux_conf_regs(); | 265 | set_mux_conf_regs(); |
273 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) | 266 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) |
274 | update_rtc_magic(); | 267 | update_rtc_magic(); |
275 | #endif | 268 | #endif |
276 | return 0; | 269 | return 0; |
277 | } | 270 | } |
278 | 271 | ||
279 | /* | 272 | /* |
280 | * This function is the place to do per-board things such as ramp up the | 273 | * This function is the place to do per-board things such as ramp up the |
281 | * MPU clock frequency. | 274 | * MPU clock frequency. |
282 | */ | 275 | */ |
283 | __weak void am33xx_spl_board_init(void) | 276 | __weak void am33xx_spl_board_init(void) |
284 | { | 277 | { |
285 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); | 278 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); |
286 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); | 279 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); |
287 | } | 280 | } |
288 | 281 | ||
289 | #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) | 282 | #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) |
290 | static void rtc32k_enable(void) | 283 | static void rtc32k_enable(void) |
291 | { | 284 | { |
292 | struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE; | 285 | struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE; |
293 | 286 | ||
294 | rtc32k_unlock(rtc); | 287 | rtc32k_unlock(rtc); |
295 | 288 | ||
296 | /* Enable the RTC 32K OSC by setting bits 3 and 6. */ | 289 | /* Enable the RTC 32K OSC by setting bits 3 and 6. */ |
297 | writel((1 << 3) | (1 << 6), &rtc->osc); | 290 | writel((1 << 3) | (1 << 6), &rtc->osc); |
298 | } | 291 | } |
299 | #endif | 292 | #endif |
300 | 293 | ||
301 | static void uart_soft_reset(void) | 294 | static void uart_soft_reset(void) |
302 | { | 295 | { |
303 | struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE; | 296 | struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE; |
304 | u32 regval; | 297 | u32 regval; |
305 | 298 | ||
306 | regval = readl(&uart_base->uartsyscfg); | 299 | regval = readl(&uart_base->uartsyscfg); |
307 | regval |= UART_RESET; | 300 | regval |= UART_RESET; |
308 | writel(regval, &uart_base->uartsyscfg); | 301 | writel(regval, &uart_base->uartsyscfg); |
309 | while ((readl(&uart_base->uartsyssts) & | 302 | while ((readl(&uart_base->uartsyssts) & |
310 | UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK) | 303 | UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK) |
311 | ; | 304 | ; |
312 | 305 | ||
313 | /* Disable smart idle */ | 306 | /* Disable smart idle */ |
314 | regval = readl(&uart_base->uartsyscfg); | 307 | regval = readl(&uart_base->uartsyscfg); |
315 | regval |= UART_SMART_IDLE_EN; | 308 | regval |= UART_SMART_IDLE_EN; |
316 | writel(regval, &uart_base->uartsyscfg); | 309 | writel(regval, &uart_base->uartsyscfg); |
317 | } | 310 | } |
318 | 311 | ||
319 | static void watchdog_disable(void) | 312 | static void watchdog_disable(void) |
320 | { | 313 | { |
321 | struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE; | 314 | struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE; |
322 | 315 | ||
323 | writel(0xAAAA, &wdtimer->wdtwspr); | 316 | writel(0xAAAA, &wdtimer->wdtwspr); |
324 | while (readl(&wdtimer->wdtwwps) != 0x0) | 317 | while (readl(&wdtimer->wdtwwps) != 0x0) |
325 | ; | 318 | ; |
326 | writel(0x5555, &wdtimer->wdtwspr); | 319 | writel(0x5555, &wdtimer->wdtwspr); |
327 | while (readl(&wdtimer->wdtwwps) != 0x0) | 320 | while (readl(&wdtimer->wdtwwps) != 0x0) |
328 | ; | 321 | ; |
329 | } | 322 | } |
330 | 323 | ||
331 | #ifdef CONFIG_SPL_BUILD | 324 | #ifdef CONFIG_SPL_BUILD |
332 | void board_init_f(ulong dummy) | 325 | void board_init_f(ulong dummy) |
333 | { | 326 | { |
334 | board_early_init_f(); | 327 | board_early_init_f(); |
335 | sdram_init(); | 328 | sdram_init(); |
336 | } | 329 | } |
337 | #endif | 330 | #endif |
338 | 331 | ||
339 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) | 332 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) |
340 | /* | 333 | /* |
341 | * Check if we are executing rtc-only mode, and resume from it if needed | 334 | * Check if we are executing rtc-only mode, and resume from it if needed |
342 | */ | 335 | */ |
343 | static void rtc_only(void) | 336 | static void rtc_only(void) |
344 | { | 337 | { |
345 | struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE; | 338 | struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE; |
346 | u32 scratch1; | 339 | u32 scratch1; |
347 | void (*resume_func)(void); | 340 | void (*resume_func)(void); |
348 | 341 | ||
349 | scratch1 = readl(&rtc->scratch1); | 342 | scratch1 = readl(&rtc->scratch1); |
350 | 343 | ||
351 | /* | 344 | /* |
352 | * Check RTC scratch against RTC_MAGIC_VAL, RTC_MAGIC_VAL is only | 345 | * Check RTC scratch against RTC_MAGIC_VAL, RTC_MAGIC_VAL is only |
353 | * written to this register when we want to wake up from RTC only | 346 | * written to this register when we want to wake up from RTC only |
354 | * mode. Contents of the RTC_SCRATCH1: | 347 | * mode. Contents of the RTC_SCRATCH1: |
355 | * bits 0-15: RTC_MAGIC_VAL | 348 | * bits 0-15: RTC_MAGIC_VAL |
356 | * bits 16-31: board type (needed for sdram_init) | 349 | * bits 16-31: board type (needed for sdram_init) |
357 | */ | 350 | */ |
358 | if ((scratch1 & 0xffff) != RTC_MAGIC_VAL) | 351 | if ((scratch1 & 0xffff) != RTC_MAGIC_VAL) |
359 | return; | 352 | return; |
360 | 353 | ||
361 | rtc32k_unlock(rtc); | 354 | rtc32k_unlock(rtc); |
362 | 355 | ||
363 | /* Clear RTC magic */ | 356 | /* Clear RTC magic */ |
364 | writel(0, &rtc->scratch1); | 357 | writel(0, &rtc->scratch1); |
365 | 358 | ||
366 | /* | 359 | /* |
367 | * Update board type based on value stored on RTC_SCRATCH1, this | 360 | * Update board type based on value stored on RTC_SCRATCH1, this |
368 | * is done so that we don't need to read the board type from eeprom | 361 | * is done so that we don't need to read the board type from eeprom |
369 | * over i2c bus which is expensive | 362 | * over i2c bus which is expensive |
370 | */ | 363 | */ |
371 | rtc_only_update_board_type(scratch1 >> RTC_BOARD_TYPE_SHIFT); | 364 | rtc_only_update_board_type(scratch1 >> RTC_BOARD_TYPE_SHIFT); |
372 | 365 | ||
373 | rtc_only_prcm_init(); | 366 | rtc_only_prcm_init(); |
374 | sdram_init(); | 367 | sdram_init(); |
375 | 368 | ||
376 | resume_func = (void *)readl(&rtc->scratch0); | 369 | resume_func = (void *)readl(&rtc->scratch0); |
377 | if (resume_func) | 370 | if (resume_func) |
378 | resume_func(); | 371 | resume_func(); |
379 | } | 372 | } |
380 | #endif | 373 | #endif |
381 | 374 | ||
382 | void s_init(void) | 375 | void s_init(void) |
383 | { | 376 | { |
384 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) | 377 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT) |
385 | rtc_only(); | 378 | rtc_only(); |
386 | #endif | 379 | #endif |
387 | /* | 380 | /* |
388 | * The ROM will only have set up sufficient pinmux to allow for the | 381 | * The ROM will only have set up sufficient pinmux to allow for the |
389 | * first 4KiB NOR to be read, we must finish doing what we know of | 382 | * first 4KiB NOR to be read, we must finish doing what we know of |
390 | * the NOR mux in this space in order to continue. | 383 | * the NOR mux in this space in order to continue. |
391 | */ | 384 | */ |
392 | #ifdef CONFIG_NOR_BOOT | 385 | #ifdef CONFIG_NOR_BOOT |
393 | enable_norboot_pin_mux(); | 386 | enable_norboot_pin_mux(); |
394 | #endif | 387 | #endif |
395 | watchdog_disable(); | 388 | watchdog_disable(); |
396 | set_uart_mux_conf(); | 389 | set_uart_mux_conf(); |
397 | setup_clocks_for_console(); | 390 | setup_clocks_for_console(); |
398 | uart_soft_reset(); | 391 | uart_soft_reset(); |
399 | #if defined(CONFIG_NOR_BOOT) || defined(CONFIG_QSPI_BOOT) | 392 | #if defined(CONFIG_NOR_BOOT) || defined(CONFIG_QSPI_BOOT) |
400 | /* TODO: This does not work, gd is not available yet */ | 393 | /* TODO: This does not work, gd is not available yet */ |
401 | gd->baudrate = CONFIG_BAUDRATE; | 394 | gd->baudrate = CONFIG_BAUDRATE; |
402 | serial_init(); | 395 | serial_init(); |
403 | gd->have_console = 1; | 396 | gd->have_console = 1; |
404 | #endif | 397 | #endif |
405 | #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) | 398 | #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) |
406 | /* Enable RTC32K clock */ | 399 | /* Enable RTC32K clock */ |
407 | rtc32k_enable(); | 400 | rtc32k_enable(); |
408 | #endif | 401 | #endif |
409 | } | 402 | } |
410 | #endif | 403 | #endif |
411 | 404 |
arch/arm/include/asm/arch-am33xx/ddr_defs.h
1 | /* | 1 | /* |
2 | * ddr_defs.h | 2 | * ddr_defs.h |
3 | * | 3 | * |
4 | * ddr specific header | 4 | * ddr specific header |
5 | * | 5 | * |
6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ | 6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
7 | * | 7 | * |
8 | * SPDX-License-Identifier: GPL-2.0+ | 8 | * SPDX-License-Identifier: GPL-2.0+ |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #ifndef _DDR_DEFS_H | 11 | #ifndef _DDR_DEFS_H |
12 | #define _DDR_DEFS_H | 12 | #define _DDR_DEFS_H |
13 | 13 | ||
14 | #include <asm/arch/hardware.h> | 14 | #include <asm/arch/hardware.h> |
15 | #include <asm/emif.h> | 15 | #include <asm/emif.h> |
16 | 16 | ||
17 | /* AM335X EMIF Register values */ | 17 | /* AM335X EMIF Register values */ |
18 | #define VTP_CTRL_READY (0x1 << 5) | 18 | #define VTP_CTRL_READY (0x1 << 5) |
19 | #define VTP_CTRL_ENABLE (0x1 << 6) | 19 | #define VTP_CTRL_ENABLE (0x1 << 6) |
20 | #define VTP_CTRL_START_EN (0x1) | 20 | #define VTP_CTRL_START_EN (0x1) |
21 | #ifdef CONFIG_AM43XX | 21 | #ifdef CONFIG_AM43XX |
22 | #define DDR_CKE_CTRL_NORMAL 0x3 | 22 | #define DDR_CKE_CTRL_NORMAL 0x3 |
23 | #else | 23 | #else |
24 | #define DDR_CKE_CTRL_NORMAL 0x1 | 24 | #define DDR_CKE_CTRL_NORMAL 0x1 |
25 | #endif | 25 | #endif |
26 | #define PHY_EN_DYN_PWRDN (0x1 << 20) | 26 | #define PHY_EN_DYN_PWRDN (0x1 << 20) |
27 | 27 | ||
28 | /* Micron MT47H128M16RT-25E */ | 28 | /* Micron MT47H128M16RT-25E */ |
29 | #define MT47H128M16RT25E_EMIF_READ_LATENCY 0x100005 | 29 | #define MT47H128M16RT25E_EMIF_READ_LATENCY 0x100005 |
30 | #define MT47H128M16RT25E_EMIF_TIM1 0x0666B3C9 | 30 | #define MT47H128M16RT25E_EMIF_TIM1 0x0666B3C9 |
31 | #define MT47H128M16RT25E_EMIF_TIM2 0x243631CA | 31 | #define MT47H128M16RT25E_EMIF_TIM2 0x243631CA |
32 | #define MT47H128M16RT25E_EMIF_TIM3 0x0000033F | 32 | #define MT47H128M16RT25E_EMIF_TIM3 0x0000033F |
33 | #define MT47H128M16RT25E_EMIF_SDCFG 0x41805332 | 33 | #define MT47H128M16RT25E_EMIF_SDCFG 0x41805332 |
34 | #define MT47H128M16RT25E_EMIF_SDREF 0x0000081a | 34 | #define MT47H128M16RT25E_EMIF_SDREF 0x0000081a |
35 | #define MT47H128M16RT25E_RATIO 0x80 | 35 | #define MT47H128M16RT25E_RATIO 0x80 |
36 | #define MT47H128M16RT25E_RD_DQS 0x12 | 36 | #define MT47H128M16RT25E_RD_DQS 0x12 |
37 | #define MT47H128M16RT25E_PHY_WR_DATA 0x40 | 37 | #define MT47H128M16RT25E_PHY_WR_DATA 0x40 |
38 | #define MT47H128M16RT25E_PHY_FIFO_WE 0x80 | 38 | #define MT47H128M16RT25E_PHY_FIFO_WE 0x80 |
39 | #define MT47H128M16RT25E_IOCTRL_VALUE 0x18B | 39 | #define MT47H128M16RT25E_IOCTRL_VALUE 0x18B |
40 | 40 | ||
41 | /* Micron MT41J128M16JT-125 */ | 41 | /* Micron MT41J128M16JT-125 */ |
42 | #define MT41J128MJT125_EMIF_READ_LATENCY 0x100006 | 42 | #define MT41J128MJT125_EMIF_READ_LATENCY 0x100006 |
43 | #define MT41J128MJT125_EMIF_TIM1 0x0888A39B | 43 | #define MT41J128MJT125_EMIF_TIM1 0x0888A39B |
44 | #define MT41J128MJT125_EMIF_TIM2 0x26337FDA | 44 | #define MT41J128MJT125_EMIF_TIM2 0x26337FDA |
45 | #define MT41J128MJT125_EMIF_TIM3 0x501F830F | 45 | #define MT41J128MJT125_EMIF_TIM3 0x501F830F |
46 | #define MT41J128MJT125_EMIF_SDCFG 0x61C04AB2 | 46 | #define MT41J128MJT125_EMIF_SDCFG 0x61C04AB2 |
47 | #define MT41J128MJT125_EMIF_SDREF 0x0000093B | 47 | #define MT41J128MJT125_EMIF_SDREF 0x0000093B |
48 | #define MT41J128MJT125_ZQ_CFG 0x50074BE4 | 48 | #define MT41J128MJT125_ZQ_CFG 0x50074BE4 |
49 | #define MT41J128MJT125_RATIO 0x40 | 49 | #define MT41J128MJT125_RATIO 0x40 |
50 | #define MT41J128MJT125_INVERT_CLKOUT 0x1 | 50 | #define MT41J128MJT125_INVERT_CLKOUT 0x1 |
51 | #define MT41J128MJT125_RD_DQS 0x3B | 51 | #define MT41J128MJT125_RD_DQS 0x3B |
52 | #define MT41J128MJT125_WR_DQS 0x85 | 52 | #define MT41J128MJT125_WR_DQS 0x85 |
53 | #define MT41J128MJT125_PHY_WR_DATA 0xC1 | 53 | #define MT41J128MJT125_PHY_WR_DATA 0xC1 |
54 | #define MT41J128MJT125_PHY_FIFO_WE 0x100 | 54 | #define MT41J128MJT125_PHY_FIFO_WE 0x100 |
55 | #define MT41J128MJT125_IOCTRL_VALUE 0x18B | 55 | #define MT41J128MJT125_IOCTRL_VALUE 0x18B |
56 | 56 | ||
57 | /* Micron MT41K128M16JT-187E */ | 57 | /* Micron MT41K128M16JT-187E */ |
58 | #define MT41K128MJT187E_EMIF_READ_LATENCY 0x06 | 58 | #define MT41K128MJT187E_EMIF_READ_LATENCY 0x06 |
59 | #define MT41K128MJT187E_EMIF_TIM1 0x0888B3DB | 59 | #define MT41K128MJT187E_EMIF_TIM1 0x0888B3DB |
60 | #define MT41K128MJT187E_EMIF_TIM2 0x36337FDA | 60 | #define MT41K128MJT187E_EMIF_TIM2 0x36337FDA |
61 | #define MT41K128MJT187E_EMIF_TIM3 0x501F830F | 61 | #define MT41K128MJT187E_EMIF_TIM3 0x501F830F |
62 | #define MT41K128MJT187E_EMIF_SDCFG 0x61C04AB2 | 62 | #define MT41K128MJT187E_EMIF_SDCFG 0x61C04AB2 |
63 | #define MT41K128MJT187E_EMIF_SDREF 0x0000093B | 63 | #define MT41K128MJT187E_EMIF_SDREF 0x0000093B |
64 | #define MT41K128MJT187E_ZQ_CFG 0x50074BE4 | 64 | #define MT41K128MJT187E_ZQ_CFG 0x50074BE4 |
65 | #define MT41K128MJT187E_RATIO 0x40 | 65 | #define MT41K128MJT187E_RATIO 0x40 |
66 | #define MT41K128MJT187E_INVERT_CLKOUT 0x1 | 66 | #define MT41K128MJT187E_INVERT_CLKOUT 0x1 |
67 | #define MT41K128MJT187E_RD_DQS 0x3B | 67 | #define MT41K128MJT187E_RD_DQS 0x3B |
68 | #define MT41K128MJT187E_WR_DQS 0x85 | 68 | #define MT41K128MJT187E_WR_DQS 0x85 |
69 | #define MT41K128MJT187E_PHY_WR_DATA 0xC1 | 69 | #define MT41K128MJT187E_PHY_WR_DATA 0xC1 |
70 | #define MT41K128MJT187E_PHY_FIFO_WE 0x100 | 70 | #define MT41K128MJT187E_PHY_FIFO_WE 0x100 |
71 | #define MT41K128MJT187E_IOCTRL_VALUE 0x18B | 71 | #define MT41K128MJT187E_IOCTRL_VALUE 0x18B |
72 | 72 | ||
73 | /* Micron MT41J64M16JT-125 */ | 73 | /* Micron MT41J64M16JT-125 */ |
74 | #define MT41J64MJT125_EMIF_SDCFG 0x61C04A32 | 74 | #define MT41J64MJT125_EMIF_SDCFG 0x61C04A32 |
75 | 75 | ||
76 | /* Micron MT41J256M16JT-125 */ | 76 | /* Micron MT41J256M16JT-125 */ |
77 | #define MT41J256MJT125_EMIF_SDCFG 0x61C04B32 | 77 | #define MT41J256MJT125_EMIF_SDCFG 0x61C04B32 |
78 | 78 | ||
79 | /* Micron MT41J256M8HX-15E */ | 79 | /* Micron MT41J256M8HX-15E */ |
80 | #define MT41J256M8HX15E_EMIF_READ_LATENCY 0x100006 | 80 | #define MT41J256M8HX15E_EMIF_READ_LATENCY 0x100006 |
81 | #define MT41J256M8HX15E_EMIF_TIM1 0x0888A39B | 81 | #define MT41J256M8HX15E_EMIF_TIM1 0x0888A39B |
82 | #define MT41J256M8HX15E_EMIF_TIM2 0x26337FDA | 82 | #define MT41J256M8HX15E_EMIF_TIM2 0x26337FDA |
83 | #define MT41J256M8HX15E_EMIF_TIM3 0x501F830F | 83 | #define MT41J256M8HX15E_EMIF_TIM3 0x501F830F |
84 | #define MT41J256M8HX15E_EMIF_SDCFG 0x61C04B32 | 84 | #define MT41J256M8HX15E_EMIF_SDCFG 0x61C04B32 |
85 | #define MT41J256M8HX15E_EMIF_SDREF 0x0000093B | 85 | #define MT41J256M8HX15E_EMIF_SDREF 0x0000093B |
86 | #define MT41J256M8HX15E_ZQ_CFG 0x50074BE4 | 86 | #define MT41J256M8HX15E_ZQ_CFG 0x50074BE4 |
87 | #define MT41J256M8HX15E_RATIO 0x40 | 87 | #define MT41J256M8HX15E_RATIO 0x40 |
88 | #define MT41J256M8HX15E_INVERT_CLKOUT 0x1 | 88 | #define MT41J256M8HX15E_INVERT_CLKOUT 0x1 |
89 | #define MT41J256M8HX15E_RD_DQS 0x3B | 89 | #define MT41J256M8HX15E_RD_DQS 0x3B |
90 | #define MT41J256M8HX15E_WR_DQS 0x85 | 90 | #define MT41J256M8HX15E_WR_DQS 0x85 |
91 | #define MT41J256M8HX15E_PHY_WR_DATA 0xC1 | 91 | #define MT41J256M8HX15E_PHY_WR_DATA 0xC1 |
92 | #define MT41J256M8HX15E_PHY_FIFO_WE 0x100 | 92 | #define MT41J256M8HX15E_PHY_FIFO_WE 0x100 |
93 | #define MT41J256M8HX15E_IOCTRL_VALUE 0x18B | 93 | #define MT41J256M8HX15E_IOCTRL_VALUE 0x18B |
94 | 94 | ||
95 | /* Micron MT41K256M16HA-125E */ | 95 | /* Micron MT41K256M16HA-125E */ |
96 | #define MT41K256M16HA125E_EMIF_READ_LATENCY 0x100007 | 96 | #define MT41K256M16HA125E_EMIF_READ_LATENCY 0x100007 |
97 | #define MT41K256M16HA125E_EMIF_TIM1 0x0AAAD4DB | 97 | #define MT41K256M16HA125E_EMIF_TIM1 0x0AAAD4DB |
98 | #define MT41K256M16HA125E_EMIF_TIM2 0x266B7FDA | 98 | #define MT41K256M16HA125E_EMIF_TIM2 0x266B7FDA |
99 | #define MT41K256M16HA125E_EMIF_TIM3 0x501F867F | 99 | #define MT41K256M16HA125E_EMIF_TIM3 0x501F867F |
100 | #define MT41K256M16HA125E_EMIF_SDCFG 0x61C05332 | 100 | #define MT41K256M16HA125E_EMIF_SDCFG 0x61C05332 |
101 | #define MT41K256M16HA125E_EMIF_SDREF 0xC30 | 101 | #define MT41K256M16HA125E_EMIF_SDREF 0xC30 |
102 | #define MT41K256M16HA125E_ZQ_CFG 0x50074BE4 | 102 | #define MT41K256M16HA125E_ZQ_CFG 0x50074BE4 |
103 | #define MT41K256M16HA125E_RATIO 0x80 | 103 | #define MT41K256M16HA125E_RATIO 0x80 |
104 | #define MT41K256M16HA125E_INVERT_CLKOUT 0x0 | 104 | #define MT41K256M16HA125E_INVERT_CLKOUT 0x0 |
105 | #define MT41K256M16HA125E_RD_DQS 0x38 | 105 | #define MT41K256M16HA125E_RD_DQS 0x38 |
106 | #define MT41K256M16HA125E_WR_DQS 0x44 | 106 | #define MT41K256M16HA125E_WR_DQS 0x44 |
107 | #define MT41K256M16HA125E_PHY_WR_DATA 0x7D | 107 | #define MT41K256M16HA125E_PHY_WR_DATA 0x7D |
108 | #define MT41K256M16HA125E_PHY_FIFO_WE 0x94 | 108 | #define MT41K256M16HA125E_PHY_FIFO_WE 0x94 |
109 | #define MT41K256M16HA125E_IOCTRL_VALUE 0x18B | 109 | #define MT41K256M16HA125E_IOCTRL_VALUE 0x18B |
110 | 110 | ||
111 | /* Samsung K4B4G1646E-BYK0 */ | ||
112 | #define K4B4G1646EBYK0_EMIF_READ_LATENCY 0x100007 | ||
113 | #define K4B4G1646EBYK0_EMIF_TIM1 0x0AAAE51B | ||
114 | #define K4B4G1646EBYK0_EMIF_TIM2 0x267B7FDA | ||
115 | #define K4B4G1646EBYK0_EMIF_TIM3 0x501F877F | ||
116 | #define K4B4G1646EBYK0_EMIF_SDCFG 0x61C05332 | ||
117 | #define K4B4G1646EBYK0_EMIF_SDREF 0xC30 | ||
118 | #define K4B4G1646EBYK0_ZQ_CFG 0x50074BE4 | ||
119 | #define K4B4G1646EBYK0_RATIO 0x80 | ||
120 | #define K4B4G1646EBYK0_INVERT_CLKOUT 0x0 | ||
121 | #define K4B4G1646EBYK0_RD_DQS 0x3B | ||
122 | #define K4B4G1646EBYK0_WR_DQS 0x4A | ||
123 | #define K4B4G1646EBYK0_PHY_WR_DATA 0x83 | ||
124 | #define K4B4G1646EBYK0_PHY_FIFO_WE 0xA4 | ||
125 | #define K4B4G1646EBYK0_IOCTRL_VALUE 0x18B | ||
126 | |||
127 | /* Micron MT41K256M16HA-125ITE */ | ||
128 | #define MT41K256M16HA125ITE_EMIF_READ_LATENCY 0x100007 | ||
129 | #define MT41K256M16HA125ITE_EMIF_TIM1 0x0AAAE51B | ||
130 | #define MT41K256M16HA125ITE_EMIF_TIM2 0x267B7FDA | ||
131 | #define MT41K256M16HA125ITE_EMIF_TIM3 0x501F877F | ||
132 | #define MT41K256M16HA125ITE_EMIF_SDCFG 0x61C05332 | ||
133 | #define MT41K256M16HA125ITE_EMIF_SDREF 0xC30 | ||
134 | #define MT41K256M16HA125ITE_ZQ_CFG 0x50074BE4 | ||
135 | #define MT41K256M16HA125ITE_RATIO 0x80 | ||
136 | #define MT41K256M16HA125ITE_INVERT_CLKOUT 0x0 | ||
137 | #define MT41K256M16HA125ITE_RD_DQS 0x3D | ||
138 | #define MT41K256M16HA125ITE_WR_DQS 0x4B | ||
139 | #define MT41K256M16HA125ITE_PHY_WR_DATA 0x7F | ||
140 | #define MT41K256M16HA125ITE_PHY_FIFO_WE 0x9D | ||
141 | #define MT41K256M16HA125ITE_IOCTRL_VALUE 0x18B | ||
142 | |||
111 | /* Micron MT41J512M8RH-125 on EVM v1.5 */ | 143 | /* Micron MT41J512M8RH-125 on EVM v1.5 */ |
112 | #define MT41J512M8RH125_EMIF_READ_LATENCY 0x100006 | 144 | #define MT41J512M8RH125_EMIF_READ_LATENCY 0x100006 |
113 | #define MT41J512M8RH125_EMIF_TIM1 0x0888A39B | 145 | #define MT41J512M8RH125_EMIF_TIM1 0x0888A39B |
114 | #define MT41J512M8RH125_EMIF_TIM2 0x26517FDA | 146 | #define MT41J512M8RH125_EMIF_TIM2 0x26517FDA |
115 | #define MT41J512M8RH125_EMIF_TIM3 0x501F84EF | 147 | #define MT41J512M8RH125_EMIF_TIM3 0x501F84EF |
116 | #define MT41J512M8RH125_EMIF_SDCFG 0x61C04BB2 | 148 | #define MT41J512M8RH125_EMIF_SDCFG 0x61C04BB2 |
117 | #define MT41J512M8RH125_EMIF_SDREF 0x0000093B | 149 | #define MT41J512M8RH125_EMIF_SDREF 0x0000093B |
118 | #define MT41J512M8RH125_ZQ_CFG 0x50074BE4 | 150 | #define MT41J512M8RH125_ZQ_CFG 0x50074BE4 |
119 | #define MT41J512M8RH125_RATIO 0x80 | 151 | #define MT41J512M8RH125_RATIO 0x80 |
120 | #define MT41J512M8RH125_INVERT_CLKOUT 0x0 | 152 | #define MT41J512M8RH125_INVERT_CLKOUT 0x0 |
121 | #define MT41J512M8RH125_RD_DQS 0x3B | 153 | #define MT41J512M8RH125_RD_DQS 0x3B |
122 | #define MT41J512M8RH125_WR_DQS 0x3C | 154 | #define MT41J512M8RH125_WR_DQS 0x3C |
123 | #define MT41J512M8RH125_PHY_FIFO_WE 0xA5 | 155 | #define MT41J512M8RH125_PHY_FIFO_WE 0xA5 |
124 | #define MT41J512M8RH125_PHY_WR_DATA 0x74 | 156 | #define MT41J512M8RH125_PHY_WR_DATA 0x74 |
125 | #define MT41J512M8RH125_IOCTRL_VALUE 0x18B | 157 | #define MT41J512M8RH125_IOCTRL_VALUE 0x18B |
126 | 158 | ||
127 | /* Samsung K4B2G1646E-BIH9 */ | 159 | /* Samsung K4B2G1646E-BIH9 */ |
128 | #define K4B2G1646EBIH9_EMIF_READ_LATENCY 0x100007 | 160 | #define K4B2G1646EBIH9_EMIF_READ_LATENCY 0x100007 |
129 | #define K4B2G1646EBIH9_EMIF_TIM1 0x0AAAE51B | 161 | #define K4B2G1646EBIH9_EMIF_TIM1 0x0AAAE51B |
130 | #define K4B2G1646EBIH9_EMIF_TIM2 0x2A1D7FDA | 162 | #define K4B2G1646EBIH9_EMIF_TIM2 0x2A1D7FDA |
131 | #define K4B2G1646EBIH9_EMIF_TIM3 0x501F83FF | 163 | #define K4B2G1646EBIH9_EMIF_TIM3 0x501F83FF |
132 | #define K4B2G1646EBIH9_EMIF_SDCFG 0x61C052B2 | 164 | #define K4B2G1646EBIH9_EMIF_SDCFG 0x61C052B2 |
133 | #define K4B2G1646EBIH9_EMIF_SDREF 0x00000C30 | 165 | #define K4B2G1646EBIH9_EMIF_SDREF 0x00000C30 |
134 | #define K4B2G1646EBIH9_ZQ_CFG 0x50074BE4 | 166 | #define K4B2G1646EBIH9_ZQ_CFG 0x50074BE4 |
135 | #define K4B2G1646EBIH9_RATIO 0x80 | 167 | #define K4B2G1646EBIH9_RATIO 0x80 |
136 | #define K4B2G1646EBIH9_INVERT_CLKOUT 0x0 | 168 | #define K4B2G1646EBIH9_INVERT_CLKOUT 0x0 |
137 | #define K4B2G1646EBIH9_RD_DQS 0x35 | 169 | #define K4B2G1646EBIH9_RD_DQS 0x35 |
138 | #define K4B2G1646EBIH9_WR_DQS 0x3A | 170 | #define K4B2G1646EBIH9_WR_DQS 0x3A |
139 | #define K4B2G1646EBIH9_PHY_FIFO_WE 0x97 | 171 | #define K4B2G1646EBIH9_PHY_FIFO_WE 0x97 |
140 | #define K4B2G1646EBIH9_PHY_WR_DATA 0x76 | 172 | #define K4B2G1646EBIH9_PHY_WR_DATA 0x76 |
141 | #define K4B2G1646EBIH9_IOCTRL_VALUE 0x18B | 173 | #define K4B2G1646EBIH9_IOCTRL_VALUE 0x18B |
142 | 174 | ||
143 | #define LPDDR2_ADDRCTRL_IOCTRL_VALUE 0x294 | 175 | #define LPDDR2_ADDRCTRL_IOCTRL_VALUE 0x294 |
144 | #define LPDDR2_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000 | 176 | #define LPDDR2_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000 |
145 | #define LPDDR2_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000 | 177 | #define LPDDR2_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000 |
146 | #define LPDDR2_DATA0_IOCTRL_VALUE 0x20000294 | 178 | #define LPDDR2_DATA0_IOCTRL_VALUE 0x20000294 |
147 | #define LPDDR2_DATA1_IOCTRL_VALUE 0x20000294 | 179 | #define LPDDR2_DATA1_IOCTRL_VALUE 0x20000294 |
148 | #define LPDDR2_DATA2_IOCTRL_VALUE 0x20000294 | 180 | #define LPDDR2_DATA2_IOCTRL_VALUE 0x20000294 |
149 | #define LPDDR2_DATA3_IOCTRL_VALUE 0x20000294 | 181 | #define LPDDR2_DATA3_IOCTRL_VALUE 0x20000294 |
150 | 182 | ||
151 | #define DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000 | 183 | #define DDR3_ADDRCTRL_WD0_IOCTRL_VALUE 0x00000000 |
152 | #define DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000 | 184 | #define DDR3_ADDRCTRL_WD1_IOCTRL_VALUE 0x00000000 |
153 | #define DDR3_ADDRCTRL_IOCTRL_VALUE 0x84 | 185 | #define DDR3_ADDRCTRL_IOCTRL_VALUE 0x84 |
154 | #define DDR3_DATA0_IOCTRL_VALUE 0x84 | 186 | #define DDR3_DATA0_IOCTRL_VALUE 0x84 |
155 | #define DDR3_DATA1_IOCTRL_VALUE 0x84 | 187 | #define DDR3_DATA1_IOCTRL_VALUE 0x84 |
156 | #define DDR3_DATA2_IOCTRL_VALUE 0x84 | 188 | #define DDR3_DATA2_IOCTRL_VALUE 0x84 |
157 | #define DDR3_DATA3_IOCTRL_VALUE 0x84 | 189 | #define DDR3_DATA3_IOCTRL_VALUE 0x84 |
158 | 190 | ||
159 | /** | 191 | /** |
160 | * Configure DMM | 192 | * Configure DMM |
161 | */ | 193 | */ |
162 | void config_dmm(const struct dmm_lisa_map_regs *regs); | 194 | void config_dmm(const struct dmm_lisa_map_regs *regs); |
163 | 195 | ||
164 | /** | 196 | /** |
165 | * Configure SDRAM | 197 | * Configure SDRAM |
166 | */ | 198 | */ |
167 | void config_sdram(const struct emif_regs *regs, int nr); | 199 | void config_sdram(const struct emif_regs *regs, int nr); |
168 | void config_sdram_emif4d5(const struct emif_regs *regs, int nr); | 200 | void config_sdram_emif4d5(const struct emif_regs *regs, int nr); |
169 | 201 | ||
170 | /** | 202 | /** |
171 | * Set SDRAM timings | 203 | * Set SDRAM timings |
172 | */ | 204 | */ |
173 | void set_sdram_timings(const struct emif_regs *regs, int nr); | 205 | void set_sdram_timings(const struct emif_regs *regs, int nr); |
174 | 206 | ||
175 | /** | 207 | /** |
176 | * Configure DDR PHY | 208 | * Configure DDR PHY |
177 | */ | 209 | */ |
178 | void config_ddr_phy(const struct emif_regs *regs, int nr); | 210 | void config_ddr_phy(const struct emif_regs *regs, int nr); |
179 | 211 | ||
180 | struct ddr_cmd_regs { | 212 | struct ddr_cmd_regs { |
181 | unsigned int resv0[7]; | 213 | unsigned int resv0[7]; |
182 | unsigned int cm0csratio; /* offset 0x01C */ | 214 | unsigned int cm0csratio; /* offset 0x01C */ |
183 | unsigned int resv1[3]; | 215 | unsigned int resv1[3]; |
184 | unsigned int cm0iclkout; /* offset 0x02C */ | 216 | unsigned int cm0iclkout; /* offset 0x02C */ |
185 | unsigned int resv2[8]; | 217 | unsigned int resv2[8]; |
186 | unsigned int cm1csratio; /* offset 0x050 */ | 218 | unsigned int cm1csratio; /* offset 0x050 */ |
187 | unsigned int resv3[3]; | 219 | unsigned int resv3[3]; |
188 | unsigned int cm1iclkout; /* offset 0x060 */ | 220 | unsigned int cm1iclkout; /* offset 0x060 */ |
189 | unsigned int resv4[8]; | 221 | unsigned int resv4[8]; |
190 | unsigned int cm2csratio; /* offset 0x084 */ | 222 | unsigned int cm2csratio; /* offset 0x084 */ |
191 | unsigned int resv5[3]; | 223 | unsigned int resv5[3]; |
192 | unsigned int cm2iclkout; /* offset 0x094 */ | 224 | unsigned int cm2iclkout; /* offset 0x094 */ |
193 | unsigned int resv6[3]; | 225 | unsigned int resv6[3]; |
194 | }; | 226 | }; |
195 | 227 | ||
196 | struct ddr_data_regs { | 228 | struct ddr_data_regs { |
197 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ | 229 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ |
198 | unsigned int resv1[4]; | 230 | unsigned int resv1[4]; |
199 | unsigned int dt0wdsratio0; /* offset 0x0DC */ | 231 | unsigned int dt0wdsratio0; /* offset 0x0DC */ |
200 | unsigned int resv2[4]; | 232 | unsigned int resv2[4]; |
201 | unsigned int dt0wiratio0; /* offset 0x0F0 */ | 233 | unsigned int dt0wiratio0; /* offset 0x0F0 */ |
202 | unsigned int resv3; | 234 | unsigned int resv3; |
203 | unsigned int dt0wimode0; /* offset 0x0F8 */ | 235 | unsigned int dt0wimode0; /* offset 0x0F8 */ |
204 | unsigned int dt0giratio0; /* offset 0x0FC */ | 236 | unsigned int dt0giratio0; /* offset 0x0FC */ |
205 | unsigned int resv4; | 237 | unsigned int resv4; |
206 | unsigned int dt0gimode0; /* offset 0x104 */ | 238 | unsigned int dt0gimode0; /* offset 0x104 */ |
207 | unsigned int dt0fwsratio0; /* offset 0x108 */ | 239 | unsigned int dt0fwsratio0; /* offset 0x108 */ |
208 | unsigned int resv5[4]; | 240 | unsigned int resv5[4]; |
209 | unsigned int dt0dqoffset; /* offset 0x11C */ | 241 | unsigned int dt0dqoffset; /* offset 0x11C */ |
210 | unsigned int dt0wrsratio0; /* offset 0x120 */ | 242 | unsigned int dt0wrsratio0; /* offset 0x120 */ |
211 | unsigned int resv6[4]; | 243 | unsigned int resv6[4]; |
212 | unsigned int dt0rdelays0; /* offset 0x134 */ | 244 | unsigned int dt0rdelays0; /* offset 0x134 */ |
213 | unsigned int dt0dldiff0; /* offset 0x138 */ | 245 | unsigned int dt0dldiff0; /* offset 0x138 */ |
214 | unsigned int resv7[12]; | 246 | unsigned int resv7[12]; |
215 | }; | 247 | }; |
216 | 248 | ||
217 | /** | 249 | /** |
218 | * This structure represents the DDR registers on AM33XX devices. | 250 | * This structure represents the DDR registers on AM33XX devices. |
219 | * We make use of DDR_PHY_BASE_ADDR2 to address the DATA1 registers that | 251 | * We make use of DDR_PHY_BASE_ADDR2 to address the DATA1 registers that |
220 | * correspond to DATA1 registers defined here. | 252 | * correspond to DATA1 registers defined here. |
221 | */ | 253 | */ |
222 | struct ddr_regs { | 254 | struct ddr_regs { |
223 | unsigned int resv0[3]; | 255 | unsigned int resv0[3]; |
224 | unsigned int cm0config; /* offset 0x00C */ | 256 | unsigned int cm0config; /* offset 0x00C */ |
225 | unsigned int cm0configclk; /* offset 0x010 */ | 257 | unsigned int cm0configclk; /* offset 0x010 */ |
226 | unsigned int resv1[2]; | 258 | unsigned int resv1[2]; |
227 | unsigned int cm0csratio; /* offset 0x01C */ | 259 | unsigned int cm0csratio; /* offset 0x01C */ |
228 | unsigned int resv2[3]; | 260 | unsigned int resv2[3]; |
229 | unsigned int cm0iclkout; /* offset 0x02C */ | 261 | unsigned int cm0iclkout; /* offset 0x02C */ |
230 | unsigned int resv3[4]; | 262 | unsigned int resv3[4]; |
231 | unsigned int cm1config; /* offset 0x040 */ | 263 | unsigned int cm1config; /* offset 0x040 */ |
232 | unsigned int cm1configclk; /* offset 0x044 */ | 264 | unsigned int cm1configclk; /* offset 0x044 */ |
233 | unsigned int resv4[2]; | 265 | unsigned int resv4[2]; |
234 | unsigned int cm1csratio; /* offset 0x050 */ | 266 | unsigned int cm1csratio; /* offset 0x050 */ |
235 | unsigned int resv5[3]; | 267 | unsigned int resv5[3]; |
236 | unsigned int cm1iclkout; /* offset 0x060 */ | 268 | unsigned int cm1iclkout; /* offset 0x060 */ |
237 | unsigned int resv6[4]; | 269 | unsigned int resv6[4]; |
238 | unsigned int cm2config; /* offset 0x074 */ | 270 | unsigned int cm2config; /* offset 0x074 */ |
239 | unsigned int cm2configclk; /* offset 0x078 */ | 271 | unsigned int cm2configclk; /* offset 0x078 */ |
240 | unsigned int resv7[2]; | 272 | unsigned int resv7[2]; |
241 | unsigned int cm2csratio; /* offset 0x084 */ | 273 | unsigned int cm2csratio; /* offset 0x084 */ |
242 | unsigned int resv8[3]; | 274 | unsigned int resv8[3]; |
243 | unsigned int cm2iclkout; /* offset 0x094 */ | 275 | unsigned int cm2iclkout; /* offset 0x094 */ |
244 | unsigned int resv9[12]; | 276 | unsigned int resv9[12]; |
245 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ | 277 | unsigned int dt0rdsratio0; /* offset 0x0C8 */ |
246 | unsigned int resv10[4]; | 278 | unsigned int resv10[4]; |
247 | unsigned int dt0wdsratio0; /* offset 0x0DC */ | 279 | unsigned int dt0wdsratio0; /* offset 0x0DC */ |
248 | unsigned int resv11[4]; | 280 | unsigned int resv11[4]; |
249 | unsigned int dt0wiratio0; /* offset 0x0F0 */ | 281 | unsigned int dt0wiratio0; /* offset 0x0F0 */ |
250 | unsigned int resv12; | 282 | unsigned int resv12; |
251 | unsigned int dt0wimode0; /* offset 0x0F8 */ | 283 | unsigned int dt0wimode0; /* offset 0x0F8 */ |
252 | unsigned int dt0giratio0; /* offset 0x0FC */ | 284 | unsigned int dt0giratio0; /* offset 0x0FC */ |
253 | unsigned int resv13; | 285 | unsigned int resv13; |
254 | unsigned int dt0gimode0; /* offset 0x104 */ | 286 | unsigned int dt0gimode0; /* offset 0x104 */ |
255 | unsigned int dt0fwsratio0; /* offset 0x108 */ | 287 | unsigned int dt0fwsratio0; /* offset 0x108 */ |
256 | unsigned int resv14[4]; | 288 | unsigned int resv14[4]; |
257 | unsigned int dt0dqoffset; /* offset 0x11C */ | 289 | unsigned int dt0dqoffset; /* offset 0x11C */ |
258 | unsigned int dt0wrsratio0; /* offset 0x120 */ | 290 | unsigned int dt0wrsratio0; /* offset 0x120 */ |
259 | unsigned int resv15[4]; | 291 | unsigned int resv15[4]; |
260 | unsigned int dt0rdelays0; /* offset 0x134 */ | 292 | unsigned int dt0rdelays0; /* offset 0x134 */ |
261 | unsigned int dt0dldiff0; /* offset 0x138 */ | 293 | unsigned int dt0dldiff0; /* offset 0x138 */ |
262 | }; | 294 | }; |
263 | 295 | ||
264 | /** | 296 | /** |
265 | * Encapsulates DDR CMD control registers. | 297 | * Encapsulates DDR CMD control registers. |
266 | */ | 298 | */ |
267 | struct cmd_control { | 299 | struct cmd_control { |
268 | unsigned long cmd0csratio; | 300 | unsigned long cmd0csratio; |
269 | unsigned long cmd0csforce; | 301 | unsigned long cmd0csforce; |
270 | unsigned long cmd0csdelay; | 302 | unsigned long cmd0csdelay; |
271 | unsigned long cmd0iclkout; | 303 | unsigned long cmd0iclkout; |
272 | unsigned long cmd1csratio; | 304 | unsigned long cmd1csratio; |
273 | unsigned long cmd1csforce; | 305 | unsigned long cmd1csforce; |
274 | unsigned long cmd1csdelay; | 306 | unsigned long cmd1csdelay; |
275 | unsigned long cmd1iclkout; | 307 | unsigned long cmd1iclkout; |
276 | unsigned long cmd2csratio; | 308 | unsigned long cmd2csratio; |
277 | unsigned long cmd2csforce; | 309 | unsigned long cmd2csforce; |
278 | unsigned long cmd2csdelay; | 310 | unsigned long cmd2csdelay; |
279 | unsigned long cmd2iclkout; | 311 | unsigned long cmd2iclkout; |
280 | }; | 312 | }; |
281 | 313 | ||
282 | /** | 314 | /** |
283 | * Encapsulates DDR DATA registers. | 315 | * Encapsulates DDR DATA registers. |
284 | */ | 316 | */ |
285 | struct ddr_data { | 317 | struct ddr_data { |
286 | unsigned long datardsratio0; | 318 | unsigned long datardsratio0; |
287 | unsigned long datawdsratio0; | 319 | unsigned long datawdsratio0; |
288 | unsigned long datawiratio0; | 320 | unsigned long datawiratio0; |
289 | unsigned long datagiratio0; | 321 | unsigned long datagiratio0; |
290 | unsigned long datafwsratio0; | 322 | unsigned long datafwsratio0; |
291 | unsigned long datawrsratio0; | 323 | unsigned long datawrsratio0; |
292 | }; | 324 | }; |
293 | 325 | ||
294 | /** | 326 | /** |
295 | * Configure DDR CMD control registers | 327 | * Configure DDR CMD control registers |
296 | */ | 328 | */ |
297 | void config_cmd_ctrl(const struct cmd_control *cmd, int nr); | 329 | void config_cmd_ctrl(const struct cmd_control *cmd, int nr); |
298 | 330 | ||
299 | /** | 331 | /** |
300 | * Configure DDR DATA registers | 332 | * Configure DDR DATA registers |
301 | */ | 333 | */ |
302 | void config_ddr_data(const struct ddr_data *data, int nr); | 334 | void config_ddr_data(const struct ddr_data *data, int nr); |
303 | 335 | ||
304 | /** | 336 | /** |
305 | * This structure represents the DDR io control on AM33XX devices. | 337 | * This structure represents the DDR io control on AM33XX devices. |
306 | */ | 338 | */ |
307 | struct ddr_cmdtctrl { | 339 | struct ddr_cmdtctrl { |
308 | unsigned int cm0ioctl; | 340 | unsigned int cm0ioctl; |
309 | unsigned int cm1ioctl; | 341 | unsigned int cm1ioctl; |
310 | unsigned int cm2ioctl; | 342 | unsigned int cm2ioctl; |
311 | unsigned int resv2[12]; | 343 | unsigned int resv2[12]; |
312 | unsigned int dt0ioctl; | 344 | unsigned int dt0ioctl; |
313 | unsigned int dt1ioctl; | 345 | unsigned int dt1ioctl; |
314 | unsigned int dt2ioctrl; | 346 | unsigned int dt2ioctrl; |
315 | unsigned int dt3ioctrl; | 347 | unsigned int dt3ioctrl; |
316 | unsigned int resv3[4]; | 348 | unsigned int resv3[4]; |
317 | unsigned int emif_sdram_config_ext; | 349 | unsigned int emif_sdram_config_ext; |
318 | }; | 350 | }; |
319 | 351 | ||
320 | struct ctrl_ioregs { | 352 | struct ctrl_ioregs { |
321 | unsigned int cm0ioctl; | 353 | unsigned int cm0ioctl; |
322 | unsigned int cm1ioctl; | 354 | unsigned int cm1ioctl; |
323 | unsigned int cm2ioctl; | 355 | unsigned int cm2ioctl; |
324 | unsigned int dt0ioctl; | 356 | unsigned int dt0ioctl; |
325 | unsigned int dt1ioctl; | 357 | unsigned int dt1ioctl; |
326 | unsigned int dt2ioctrl; | 358 | unsigned int dt2ioctrl; |
327 | unsigned int dt3ioctrl; | 359 | unsigned int dt3ioctrl; |
328 | unsigned int emif_sdram_config_ext; | 360 | unsigned int emif_sdram_config_ext; |
329 | }; | 361 | }; |
330 | 362 | ||
331 | /** | 363 | /** |
332 | * Configure DDR io control registers | 364 | * Configure DDR io control registers |
333 | */ | 365 | */ |
334 | void config_io_ctrl(const struct ctrl_ioregs *ioregs); | 366 | void config_io_ctrl(const struct ctrl_ioregs *ioregs); |
335 | 367 | ||
336 | struct ddr_ctrl { | 368 | struct ddr_ctrl { |
337 | unsigned int ddrioctrl; | 369 | unsigned int ddrioctrl; |
338 | unsigned int resv1[325]; | 370 | unsigned int resv1[325]; |
339 | unsigned int ddrckectrl; | 371 | unsigned int ddrckectrl; |
340 | }; | 372 | }; |
341 | 373 | ||
342 | void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs, | 374 | void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs, |
343 | const struct ddr_data *data, const struct cmd_control *ctrl, | 375 | const struct ddr_data *data, const struct cmd_control *ctrl, |
344 | const struct emif_regs *regs, int nr); | 376 | const struct emif_regs *regs, int nr); |
345 | void emif_get_ext_phy_ctrl_const_regs(const u32 **regs, u32 *size); | 377 | void emif_get_ext_phy_ctrl_const_regs(const u32 **regs, u32 *size); |
346 | 378 | ||
347 | #endif /* _DDR_DEFS_H */ | 379 | #endif /* _DDR_DEFS_H */ |
348 | 380 |
board/embedian/smarct335x/board.c
1 | /* | 1 | /* |
2 | * board.c | 2 | * board.c |
3 | * | 3 | * |
4 | * Board functions for TI AM335X based boards | 4 | * Board functions for TI AM335X based boards |
5 | * | 5 | * |
6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ | 6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
7 | * | 7 | * |
8 | * SPDX-License-Identifier: GPL-2.0+ | 8 | * SPDX-License-Identifier: GPL-2.0+ |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <common.h> | 11 | #include <common.h> |
12 | #include <errno.h> | 12 | #include <errno.h> |
13 | #include <spl.h> | 13 | #include <spl.h> |
14 | #include <asm/arch/cpu.h> | 14 | #include <asm/arch/cpu.h> |
15 | #include <asm/arch/hardware.h> | 15 | #include <asm/arch/hardware.h> |
16 | #include <asm/arch/omap.h> | 16 | #include <asm/arch/omap.h> |
17 | #include <asm/arch/ddr_defs.h> | 17 | #include <asm/arch/ddr_defs.h> |
18 | #include <asm/arch/clock.h> | 18 | #include <asm/arch/clock.h> |
19 | #include <asm/arch/gpio.h> | 19 | #include <asm/arch/gpio.h> |
20 | #include <asm/arch/mmc_host_def.h> | 20 | #include <asm/arch/mmc_host_def.h> |
21 | #include <asm/arch/sys_proto.h> | 21 | #include <asm/arch/sys_proto.h> |
22 | #include <asm/arch/mem.h> | 22 | #include <asm/arch/mem.h> |
23 | #include <asm/io.h> | 23 | #include <asm/io.h> |
24 | #include <asm/emif.h> | 24 | #include <asm/emif.h> |
25 | #include <asm/gpio.h> | 25 | #include <asm/gpio.h> |
26 | #include <i2c.h> | 26 | #include <i2c.h> |
27 | #include <miiphy.h> | 27 | #include <miiphy.h> |
28 | #include <cpsw.h> | 28 | #include <cpsw.h> |
29 | #include <power/tps65217.h> | 29 | #include <power/tps65217.h> |
30 | #include <power/tps65910.h> | 30 | #include <power/tps65910.h> |
31 | #include <environment.h> | 31 | #include <environment.h> |
32 | #include <watchdog.h> | 32 | #include <watchdog.h> |
33 | #include "board.h" | 33 | #include "board.h" |
34 | 34 | ||
35 | DECLARE_GLOBAL_DATA_PTR; | 35 | DECLARE_GLOBAL_DATA_PTR; |
36 | 36 | ||
37 | /* GPIO that controls power to DDR on EVM-SK */ | 37 | /* GPIO that controls power to DDR on EVM-SK */ |
38 | #define GPIO_DDR_VTT_EN 7 | 38 | #define GPIO_DDR_VTT_EN 7 |
39 | 39 | ||
40 | /* GPIO that controls power of LCD backlight */ | 40 | /* GPIO that controls power of LCD backlight */ |
41 | #define GPIO_LCD_BKLT_EN 54 | 41 | #define GPIO_LCD_BKLT_EN 54 |
42 | 42 | ||
43 | /* GPIO that controls LCD backlight PWM */ | 43 | /* GPIO that controls LCD backlight PWM */ |
44 | #define GPIO_LCD_PWM_EN 7 | 44 | #define GPIO_LCD_PWM_EN 7 |
45 | 45 | ||
46 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; | 46 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Read header information from EEPROM into global structure. | 49 | * Read header information from EEPROM into global structure. |
50 | */ | 50 | */ |
51 | static int read_eeprom(struct am335x_baseboard_id *header) | 51 | static int read_eeprom(struct am335x_baseboard_id *header) |
52 | { | 52 | { |
53 | /* Check if baseboard eeprom is available */ | 53 | /* Check if baseboard eeprom is available */ |
54 | if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { | 54 | if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { |
55 | puts("Could not probe the EEPROM; something fundamentally " | 55 | puts("Could not probe the EEPROM; something fundamentally " |
56 | "wrong on the I2C bus.\n"); | 56 | "wrong on the I2C bus.\n"); |
57 | return -ENODEV; | 57 | return -ENODEV; |
58 | } | 58 | } |
59 | 59 | ||
60 | /* read the eeprom using i2c */ | 60 | /* read the eeprom using i2c */ |
61 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, | 61 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, |
62 | sizeof(struct am335x_baseboard_id))) { | 62 | sizeof(struct am335x_baseboard_id))) { |
63 | puts("Could not read the EEPROM; something fundamentally" | 63 | puts("Could not read the EEPROM; something fundamentally" |
64 | " wrong on the I2C bus.\n"); | 64 | " wrong on the I2C bus.\n"); |
65 | return -EIO; | 65 | return -EIO; |
66 | } | 66 | } |
67 | 67 | ||
68 | if (header->magic != 0xEE3355AA) { | 68 | if (header->magic != 0xEE3355AA) { |
69 | /* | 69 | /* |
70 | * read the eeprom using i2c again, | 70 | * read the eeprom using i2c again, |
71 | * but use only a 1 byte address | 71 | * but use only a 1 byte address |
72 | */ | 72 | */ |
73 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, | 73 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, |
74 | sizeof(struct am335x_baseboard_id))) { | 74 | sizeof(struct am335x_baseboard_id))) { |
75 | puts("Could not read the EEPROM; something " | 75 | puts("Could not read the EEPROM; something " |
76 | "fundamentally wrong on the I2C bus.\n"); | 76 | "fundamentally wrong on the I2C bus.\n"); |
77 | return -EIO; | 77 | return -EIO; |
78 | } | 78 | } |
79 | 79 | ||
80 | if (header->magic != 0xEE3355AA) { | 80 | if (header->magic != 0xEE3355AA) { |
81 | printf("Incorrect magic number (0x%x) in EEPROM\n", | 81 | printf("Incorrect magic number (0x%x) in EEPROM\n", |
82 | header->magic); | 82 | header->magic); |
83 | return -EINVAL; | 83 | return -EINVAL; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | return 0; | 87 | return 0; |
88 | } | 88 | } |
89 | 89 | ||
90 | /*#ifndef CONFIG_SKIP_LOWLEVEL_INIT*/ | 90 | /*#ifndef CONFIG_SKIP_LOWLEVEL_INIT*/ |
91 | #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT) | 91 | #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT) |
92 | static const struct ddr_data ddr2_data = { | 92 | static const struct ddr_data ddr2_data = { |
93 | .datardsratio0 = MT47H128M16RT25E_RD_DQS, | 93 | .datardsratio0 = MT47H128M16RT25E_RD_DQS, |
94 | .datafwsratio0 = MT47H128M16RT25E_PHY_FIFO_WE, | 94 | .datafwsratio0 = MT47H128M16RT25E_PHY_FIFO_WE, |
95 | .datawrsratio0 = MT47H128M16RT25E_PHY_WR_DATA, | 95 | .datawrsratio0 = MT47H128M16RT25E_PHY_WR_DATA, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static const struct cmd_control ddr2_cmd_ctrl_data = { | 98 | static const struct cmd_control ddr2_cmd_ctrl_data = { |
99 | .cmd0csratio = MT47H128M16RT25E_RATIO, | 99 | .cmd0csratio = MT47H128M16RT25E_RATIO, |
100 | 100 | ||
101 | .cmd1csratio = MT47H128M16RT25E_RATIO, | 101 | .cmd1csratio = MT47H128M16RT25E_RATIO, |
102 | 102 | ||
103 | .cmd2csratio = MT47H128M16RT25E_RATIO, | 103 | .cmd2csratio = MT47H128M16RT25E_RATIO, |
104 | }; | 104 | }; |
105 | 105 | ||
106 | static const struct emif_regs ddr2_emif_reg_data = { | 106 | static const struct emif_regs ddr2_emif_reg_data = { |
107 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, | 107 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, |
108 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, | 108 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, |
109 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, | 109 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, |
110 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, | 110 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, |
111 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, | 111 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, |
112 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, | 112 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, |
113 | }; | 113 | }; |
114 | 114 | ||
115 | static const struct ddr_data ddr3_data = { | 115 | static const struct ddr_data ddr3_data = { |
116 | .datardsratio0 = MT41J128MJT125_RD_DQS, | 116 | .datardsratio0 = MT41J128MJT125_RD_DQS, |
117 | .datawdsratio0 = MT41J128MJT125_WR_DQS, | 117 | .datawdsratio0 = MT41J128MJT125_WR_DQS, |
118 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE, | 118 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE, |
119 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA, | 119 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static const struct ddr_data ddr3_beagleblack_data = { | 122 | static const struct ddr_data ddr3_beagleblack_data = { |
123 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, | 123 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, |
124 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, | 124 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, |
125 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, | 125 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, |
126 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, | 126 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, |
127 | }; | 127 | }; |
128 | 128 | ||
129 | static const struct ddr_data ddr3_smarct335x_data = { | 129 | static const struct ddr_data ddr3_smarct335x_data = { |
130 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, | 130 | .datardsratio0 = K4B4G1646EBYK0_RD_DQS, |
131 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, | 131 | .datawdsratio0 = K4B4G1646EBYK0_WR_DQS, |
132 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, | 132 | .datafwsratio0 = K4B4G1646EBYK0_PHY_FIFO_WE, |
133 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, | 133 | .datawrsratio0 = K4B4G1646EBYK0_PHY_WR_DATA, |
134 | }; | 134 | }; |
135 | 135 | ||
136 | static const struct ddr_data ddr3_smarct335x80_data = { | ||
137 | .datardsratio0 = MT41K256M16HA125ITE_RD_DQS, | ||
138 | .datawdsratio0 = MT41K256M16HA125ITE_WR_DQS, | ||
139 | .datafwsratio0 = MT41K256M16HA125ITE_PHY_FIFO_WE, | ||
140 | .datawrsratio0 = MT41K256M16HA125ITE_PHY_WR_DATA, | ||
141 | }; | ||
142 | |||
136 | static const struct ddr_data ddr3_evm_data = { | 143 | static const struct ddr_data ddr3_evm_data = { |
137 | .datardsratio0 = MT41J512M8RH125_RD_DQS, | 144 | .datardsratio0 = MT41J512M8RH125_RD_DQS, |
138 | .datawdsratio0 = MT41J512M8RH125_WR_DQS, | 145 | .datawdsratio0 = MT41J512M8RH125_WR_DQS, |
139 | .datafwsratio0 = MT41J512M8RH125_PHY_FIFO_WE, | 146 | .datafwsratio0 = MT41J512M8RH125_PHY_FIFO_WE, |
140 | .datawrsratio0 = MT41J512M8RH125_PHY_WR_DATA, | 147 | .datawrsratio0 = MT41J512M8RH125_PHY_WR_DATA, |
141 | }; | 148 | }; |
142 | 149 | ||
143 | static const struct cmd_control ddr3_cmd_ctrl_data = { | 150 | static const struct cmd_control ddr3_cmd_ctrl_data = { |
144 | .cmd0csratio = MT41J128MJT125_RATIO, | 151 | .cmd0csratio = MT41J128MJT125_RATIO, |
145 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT, | 152 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT, |
146 | 153 | ||
147 | .cmd1csratio = MT41J128MJT125_RATIO, | 154 | .cmd1csratio = MT41J128MJT125_RATIO, |
148 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT, | 155 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT, |
149 | 156 | ||
150 | .cmd2csratio = MT41J128MJT125_RATIO, | 157 | .cmd2csratio = MT41J128MJT125_RATIO, |
151 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT, | 158 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT, |
152 | }; | 159 | }; |
153 | 160 | ||
154 | static const struct cmd_control ddr3_beagleblack_cmd_ctrl_data = { | 161 | static const struct cmd_control ddr3_beagleblack_cmd_ctrl_data = { |
155 | .cmd0csratio = MT41K256M16HA125E_RATIO, | 162 | .cmd0csratio = MT41K256M16HA125E_RATIO, |
156 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 163 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
157 | 164 | ||
158 | .cmd1csratio = MT41K256M16HA125E_RATIO, | 165 | .cmd1csratio = MT41K256M16HA125E_RATIO, |
159 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 166 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
160 | 167 | ||
161 | .cmd2csratio = MT41K256M16HA125E_RATIO, | 168 | .cmd2csratio = MT41K256M16HA125E_RATIO, |
162 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 169 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
163 | }; | 170 | }; |
164 | 171 | ||
165 | static const struct cmd_control ddr3_smarct335x_cmd_ctrl_data = { | 172 | static const struct cmd_control ddr3_smarct335x_cmd_ctrl_data = { |
166 | .cmd0csratio = MT41K256M16HA125E_RATIO, | 173 | .cmd0csratio = K4B4G1646EBYK0_RATIO, |
167 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 174 | .cmd0iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, |
168 | 175 | ||
169 | .cmd1csratio = MT41K256M16HA125E_RATIO, | 176 | .cmd1csratio = K4B4G1646EBYK0_RATIO, |
170 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 177 | .cmd1iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, |
171 | 178 | ||
172 | .cmd2csratio = MT41K256M16HA125E_RATIO, | 179 | .cmd2csratio = K4B4G1646EBYK0_RATIO, |
173 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 180 | .cmd2iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, |
174 | }; | 181 | }; |
175 | 182 | ||
183 | static const struct cmd_control ddr3_smarct335x80_cmd_ctrl_data = { | ||
184 | .cmd0csratio = MT41K256M16HA125ITE_RATIO, | ||
185 | .cmd0iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, | ||
186 | |||
187 | .cmd1csratio = MT41K256M16HA125ITE_RATIO, | ||
188 | .cmd1iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, | ||
189 | |||
190 | .cmd2csratio = MT41K256M16HA125ITE_RATIO, | ||
191 | .cmd2iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, | ||
192 | }; | ||
193 | |||
176 | static const struct cmd_control ddr3_evm_cmd_ctrl_data = { | 194 | static const struct cmd_control ddr3_evm_cmd_ctrl_data = { |
177 | .cmd0csratio = MT41J512M8RH125_RATIO, | 195 | .cmd0csratio = MT41J512M8RH125_RATIO, |
178 | .cmd0iclkout = MT41J512M8RH125_INVERT_CLKOUT, | 196 | .cmd0iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
179 | 197 | ||
180 | .cmd1csratio = MT41J512M8RH125_RATIO, | 198 | .cmd1csratio = MT41J512M8RH125_RATIO, |
181 | .cmd1iclkout = MT41J512M8RH125_INVERT_CLKOUT, | 199 | .cmd1iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
182 | 200 | ||
183 | .cmd2csratio = MT41J512M8RH125_RATIO, | 201 | .cmd2csratio = MT41J512M8RH125_RATIO, |
184 | .cmd2iclkout = MT41J512M8RH125_INVERT_CLKOUT, | 202 | .cmd2iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
185 | }; | 203 | }; |
186 | 204 | ||
187 | static struct emif_regs ddr3_emif_reg_data = { | 205 | static struct emif_regs ddr3_emif_reg_data = { |
188 | .sdram_config = MT41J128MJT125_EMIF_SDCFG, | 206 | .sdram_config = MT41J128MJT125_EMIF_SDCFG, |
189 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF, | 207 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF, |
190 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1, | 208 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1, |
191 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2, | 209 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2, |
192 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3, | 210 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3, |
193 | .zq_config = MT41J128MJT125_ZQ_CFG, | 211 | .zq_config = MT41J128MJT125_ZQ_CFG, |
194 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY | | 212 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY | |
195 | PHY_EN_DYN_PWRDN, | 213 | PHY_EN_DYN_PWRDN, |
196 | }; | 214 | }; |
197 | 215 | ||
198 | static struct emif_regs ddr3_beagleblack_emif_reg_data = { | 216 | static struct emif_regs ddr3_beagleblack_emif_reg_data = { |
199 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, | 217 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, |
200 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, | 218 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, |
201 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, | 219 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, |
202 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, | 220 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, |
203 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, | 221 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, |
204 | .zq_config = MT41K256M16HA125E_ZQ_CFG, | 222 | .zq_config = MT41K256M16HA125E_ZQ_CFG, |
205 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, | 223 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, |
206 | }; | 224 | }; |
207 | 225 | ||
208 | static struct emif_regs ddr3_smarct335x_emif_reg_data = { | 226 | static struct emif_regs ddr3_smarct335x_emif_reg_data = { |
209 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, | 227 | .sdram_config = K4B4G1646EBYK0_EMIF_SDCFG, |
210 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, | 228 | .ref_ctrl = K4B4G1646EBYK0_EMIF_SDREF, |
211 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, | 229 | .sdram_tim1 = K4B4G1646EBYK0_EMIF_TIM1, |
212 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, | 230 | .sdram_tim2 = K4B4G1646EBYK0_EMIF_TIM2, |
213 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, | 231 | .sdram_tim3 = K4B4G1646EBYK0_EMIF_TIM3, |
214 | .zq_config = MT41K256M16HA125E_ZQ_CFG, | 232 | .zq_config = K4B4G1646EBYK0_ZQ_CFG, |
215 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, | 233 | .emif_ddr_phy_ctlr_1 = K4B4G1646EBYK0_EMIF_READ_LATENCY, |
216 | }; | 234 | }; |
217 | 235 | ||
236 | static struct emif_regs ddr3_smarct335x80_emif_reg_data = { | ||
237 | .sdram_config = MT41K256M16HA125ITE_EMIF_SDCFG, | ||
238 | .ref_ctrl = MT41K256M16HA125ITE_EMIF_SDREF, | ||
239 | .sdram_tim1 = MT41K256M16HA125ITE_EMIF_TIM1, | ||
240 | .sdram_tim2 = MT41K256M16HA125ITE_EMIF_TIM2, | ||
241 | .sdram_tim3 = MT41K256M16HA125ITE_EMIF_TIM3, | ||
242 | .zq_config = MT41K256M16HA125ITE_ZQ_CFG, | ||
243 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125ITE_EMIF_READ_LATENCY, | ||
244 | }; | ||
245 | |||
218 | static struct emif_regs ddr3_evm_emif_reg_data = { | 246 | static struct emif_regs ddr3_evm_emif_reg_data = { |
219 | .sdram_config = MT41J512M8RH125_EMIF_SDCFG, | 247 | .sdram_config = MT41J512M8RH125_EMIF_SDCFG, |
220 | .ref_ctrl = MT41J512M8RH125_EMIF_SDREF, | 248 | .ref_ctrl = MT41J512M8RH125_EMIF_SDREF, |
221 | .sdram_tim1 = MT41J512M8RH125_EMIF_TIM1, | 249 | .sdram_tim1 = MT41J512M8RH125_EMIF_TIM1, |
222 | .sdram_tim2 = MT41J512M8RH125_EMIF_TIM2, | 250 | .sdram_tim2 = MT41J512M8RH125_EMIF_TIM2, |
223 | .sdram_tim3 = MT41J512M8RH125_EMIF_TIM3, | 251 | .sdram_tim3 = MT41J512M8RH125_EMIF_TIM3, |
224 | .zq_config = MT41J512M8RH125_ZQ_CFG, | 252 | .zq_config = MT41J512M8RH125_ZQ_CFG, |
225 | .emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY | | 253 | .emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY | |
226 | PHY_EN_DYN_PWRDN, | 254 | PHY_EN_DYN_PWRDN, |
227 | }; | 255 | }; |
228 | 256 | ||
229 | #ifdef CONFIG_SPL_OS_BOOT | 257 | #ifdef CONFIG_SPL_OS_BOOT |
230 | int spl_start_uboot(void) | 258 | int spl_start_uboot(void) |
231 | { | 259 | { |
232 | /* break into full u-boot on 'c' */ | 260 | /* break into full u-boot on 'c' */ |
233 | if (serial_tstc() && serial_getc() == 'c') | 261 | if (serial_tstc() && serial_getc() == 'c') |
234 | return 1; | 262 | return 1; |
235 | 263 | ||
236 | #ifdef CONFIG_SPL_ENV_SUPPORT | 264 | #ifdef CONFIG_SPL_ENV_SUPPORT |
237 | env_init(); | 265 | env_init(); |
238 | env_relocate_spec(); | 266 | env_relocate_spec(); |
239 | if (getenv_yesno("boot_os") != 1) | 267 | if (getenv_yesno("boot_os") != 1) |
240 | return 1; | 268 | return 1; |
241 | #endif | 269 | #endif |
242 | 270 | ||
243 | return 0; | 271 | return 0; |
244 | } | 272 | } |
245 | #endif | 273 | #endif |
246 | 274 | ||
247 | #define OSC (V_OSCK/1000000) | 275 | #define OSC (V_OSCK/1000000) |
248 | const struct dpll_params dpll_ddr = { | 276 | const struct dpll_params dpll_ddr = { |
249 | 266, OSC-1, 1, -1, -1, -1, -1}; | 277 | 266, OSC-1, 1, -1, -1, -1, -1}; |
250 | const struct dpll_params dpll_ddr_evm_sk = { | 278 | const struct dpll_params dpll_ddr_evm_sk = { |
251 | 303, OSC-1, 1, -1, -1, -1, -1}; | 279 | 303, OSC-1, 1, -1, -1, -1, -1}; |
252 | const struct dpll_params dpll_ddr_bone_black = { | 280 | const struct dpll_params dpll_ddr_bone_black = { |
253 | 400, OSC-1, 1, -1, -1, -1, -1}; | 281 | 400, OSC-1, 1, -1, -1, -1, -1}; |
254 | const struct dpll_params dpll_ddr_smarc_t335x = { | 282 | const struct dpll_params dpll_ddr_smarc_t335x = { |
255 | 400, OSC-1, 1, -1, -1, -1, -1}; | 283 | 400, OSC-1, 1, -1, -1, -1, -1}; |
256 | 284 | ||
257 | void am33xx_spl_board_init(void) | 285 | void am33xx_spl_board_init(void) |
258 | { | 286 | { |
259 | struct am335x_baseboard_id header; | 287 | struct am335x_baseboard_id header; |
260 | int mpu_vdd; | 288 | int mpu_vdd; |
261 | 289 | ||
262 | if (read_eeprom(&header) < 0) | 290 | if (read_eeprom(&header) < 0) |
263 | puts("Could not get board ID.\n"); | 291 | puts("Could not get board ID.\n"); |
264 | 292 | ||
265 | /* Get the frequency */ | 293 | /* Get the frequency */ |
266 | dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev); | 294 | dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev); |
267 | 295 | ||
268 | if (board_is_bone(&header) || board_is_bone_lt(&header) || board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { | 296 | if (board_is_bone(&header) || board_is_bone_lt(&header) || board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { |
269 | /* BeagleBone PMIC Code */ | 297 | /* BeagleBone PMIC Code */ |
270 | int usb_cur_lim; | 298 | int usb_cur_lim; |
271 | 299 | ||
272 | /* | 300 | /* |
273 | * Only perform PMIC configurations if board rev > A1 | 301 | * Only perform PMIC configurations if board rev > A1 |
274 | * on Beaglebone White | 302 | * on Beaglebone White |
275 | */ | 303 | */ |
276 | if (board_is_bone(&header) && !strncmp(header.version, | 304 | if (board_is_bone(&header) && !strncmp(header.version, |
277 | "00A1", 4)) | 305 | "00A1", 4)) |
278 | return; | 306 | return; |
279 | 307 | ||
280 | if (i2c_probe(TPS65217_CHIP_PM)) | 308 | if (i2c_probe(TPS65217_CHIP_PM)) |
281 | return; | 309 | return; |
282 | 310 | ||
283 | /* | 311 | /* |
284 | * On Beaglebone White we need to ensure we have AC power | 312 | * On Beaglebone White we need to ensure we have AC power |
285 | * before increasing the frequency. | 313 | * before increasing the frequency. |
286 | */ | 314 | */ |
287 | if (board_is_bone(&header)) { | 315 | if (board_is_bone(&header)) { |
288 | uchar pmic_status_reg; | 316 | uchar pmic_status_reg; |
289 | if (tps65217_reg_read(TPS65217_STATUS, | 317 | if (tps65217_reg_read(TPS65217_STATUS, |
290 | &pmic_status_reg)) | 318 | &pmic_status_reg)) |
291 | return; | 319 | return; |
292 | if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) { | 320 | if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) { |
293 | puts("No AC power, disabling frequency switch\n"); | 321 | puts("No AC power, disabling frequency switch\n"); |
294 | return; | 322 | return; |
295 | } | 323 | } |
296 | } | 324 | } |
297 | 325 | ||
298 | /* | 326 | /* |
299 | * Override what we have detected since we know if we have | 327 | * Override what we have detected since we know if we have |
300 | * a Beaglebone Black it supports 1GHz. | 328 | * a Beaglebone Black it supports 1GHz. |
301 | */ | 329 | */ |
302 | if ((board_is_bone_lt(&header) || board_is_smarc_t335x_1g(&header))) | 330 | if ((board_is_bone_lt(&header) || board_is_smarc_t335x_1g(&header))) |
303 | dpll_mpu_opp100.m = MPUPLL_M_1000; | 331 | dpll_mpu_opp100.m = MPUPLL_M_1000; |
304 | 332 | ||
305 | /* | 333 | /* |
306 | * Increase USB current limit to 1300mA or 1800mA and set | 334 | * Increase USB current limit to 1300mA or 1800mA and set |
307 | * the MPU voltage controller as needed. | 335 | * the MPU voltage controller as needed. |
308 | */ | 336 | */ |
309 | if (dpll_mpu_opp100.m == MPUPLL_M_1000) { | 337 | if (dpll_mpu_opp100.m == MPUPLL_M_1000) { |
310 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; | 338 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; |
311 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; | 339 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; |
312 | } else { | 340 | } else { |
313 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; | 341 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
314 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; | 342 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; |
315 | } | 343 | } |
316 | 344 | ||
317 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, | 345 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
318 | TPS65217_POWER_PATH, | 346 | TPS65217_POWER_PATH, |
319 | usb_cur_lim, | 347 | usb_cur_lim, |
320 | TPS65217_USB_INPUT_CUR_LIMIT_MASK)) | 348 | TPS65217_USB_INPUT_CUR_LIMIT_MASK)) |
321 | puts("tps65217_reg_write failure\n"); | 349 | puts("tps65217_reg_write failure\n"); |
322 | 350 | ||
323 | /* Set DCDC3 (CORE) voltage to 1.125V */ | 351 | /* Set DCDC3 (CORE) voltage to 1.125V */ |
324 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, | 352 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, |
325 | TPS65217_DCDC_VOLT_SEL_1125MV)) { | 353 | TPS65217_DCDC_VOLT_SEL_1125MV)) { |
326 | puts("tps65217_voltage_update failure\n"); | 354 | puts("tps65217_voltage_update failure\n"); |
327 | return; | 355 | return; |
328 | } | 356 | } |
329 | 357 | ||
330 | /* Set CORE Frequencies to OPP100 */ | 358 | /* Set CORE Frequencies to OPP100 */ |
331 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); | 359 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); |
332 | 360 | ||
333 | /* Set DCDC2 (MPU) voltage */ | 361 | /* Set DCDC2 (MPU) voltage */ |
334 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { | 362 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { |
335 | puts("tps65217_voltage_update failure\n"); | 363 | puts("tps65217_voltage_update failure\n"); |
336 | return; | 364 | return; |
337 | } | 365 | } |
338 | 366 | ||
339 | /* | 367 | /* |
340 | * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. | 368 | * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. |
341 | * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. | 369 | * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. |
342 | */ | 370 | */ |
343 | if (board_is_bone(&header)) { | 371 | if (board_is_bone(&header)) { |
344 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, | 372 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
345 | TPS65217_DEFLS1, | 373 | TPS65217_DEFLS1, |
346 | TPS65217_LDO_VOLTAGE_OUT_3_3, | 374 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
347 | TPS65217_LDO_MASK)) | 375 | TPS65217_LDO_MASK)) |
348 | puts("tps65217_reg_write failure\n"); | 376 | puts("tps65217_reg_write failure\n"); |
349 | } else { | 377 | } else { |
350 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, | 378 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
351 | TPS65217_DEFLS1, | 379 | TPS65217_DEFLS1, |
352 | TPS65217_LDO_VOLTAGE_OUT_1_8, | 380 | TPS65217_LDO_VOLTAGE_OUT_1_8, |
353 | TPS65217_LDO_MASK)) | 381 | TPS65217_LDO_MASK)) |
354 | puts("tps65217_reg_write failure\n"); | 382 | puts("tps65217_reg_write failure\n"); |
355 | } | 383 | } |
356 | 384 | ||
357 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, | 385 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
358 | TPS65217_DEFLS2, | 386 | TPS65217_DEFLS2, |
359 | TPS65217_LDO_VOLTAGE_OUT_3_3, | 387 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
360 | TPS65217_LDO_MASK)) | 388 | TPS65217_LDO_MASK)) |
361 | puts("tps65217_reg_write failure\n"); | 389 | puts("tps65217_reg_write failure\n"); |
362 | } else { | 390 | } else { |
363 | int sil_rev; | 391 | int sil_rev; |
364 | 392 | ||
365 | /* | 393 | /* |
366 | * The GP EVM, IDK and EVM SK use a TPS65910 PMIC. For all | 394 | * The GP EVM, IDK and EVM SK use a TPS65910 PMIC. For all |
367 | * MPU frequencies we support we use a CORE voltage of | 395 | * MPU frequencies we support we use a CORE voltage of |
368 | * 1.1375V. For MPU voltage we need to switch based on | 396 | * 1.1375V. For MPU voltage we need to switch based on |
369 | * the frequency we are running at. | 397 | * the frequency we are running at. |
370 | */ | 398 | */ |
371 | if (i2c_probe(TPS65910_CTRL_I2C_ADDR)) | 399 | if (i2c_probe(TPS65910_CTRL_I2C_ADDR)) |
372 | return; | 400 | return; |
373 | 401 | ||
374 | /* | 402 | /* |
375 | * Depending on MPU clock and PG we will need a different | 403 | * Depending on MPU clock and PG we will need a different |
376 | * VDD to drive at that speed. | 404 | * VDD to drive at that speed. |
377 | */ | 405 | */ |
378 | sil_rev = readl(&cdev->deviceid) >> 28; | 406 | sil_rev = readl(&cdev->deviceid) >> 28; |
379 | mpu_vdd = am335x_get_tps65910_mpu_vdd(sil_rev, | 407 | mpu_vdd = am335x_get_tps65910_mpu_vdd(sil_rev, |
380 | dpll_mpu_opp100.m); | 408 | dpll_mpu_opp100.m); |
381 | 409 | ||
382 | /* Tell the TPS65910 to use i2c */ | 410 | /* Tell the TPS65910 to use i2c */ |
383 | tps65910_set_i2c_control(); | 411 | tps65910_set_i2c_control(); |
384 | 412 | ||
385 | /* First update MPU voltage. */ | 413 | /* First update MPU voltage. */ |
386 | if (tps65910_voltage_update(MPU, mpu_vdd)) | 414 | if (tps65910_voltage_update(MPU, mpu_vdd)) |
387 | return; | 415 | return; |
388 | 416 | ||
389 | /* Second, update the CORE voltage. */ | 417 | /* Second, update the CORE voltage. */ |
390 | if (tps65910_voltage_update(CORE, TPS65910_OP_REG_SEL_1_1_3)) | 418 | if (tps65910_voltage_update(CORE, TPS65910_OP_REG_SEL_1_1_3)) |
391 | return; | 419 | return; |
392 | 420 | ||
393 | /* Set CORE Frequencies to OPP100 */ | 421 | /* Set CORE Frequencies to OPP100 */ |
394 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); | 422 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); |
395 | } | 423 | } |
396 | 424 | ||
397 | /* Set MPU Frequency to what we detected now that voltages are set */ | 425 | /* Set MPU Frequency to what we detected now that voltages are set */ |
398 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); | 426 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); |
399 | } | 427 | } |
400 | 428 | ||
401 | const struct dpll_params *get_dpll_ddr_params(void) | 429 | const struct dpll_params *get_dpll_ddr_params(void) |
402 | { | 430 | { |
403 | struct am335x_baseboard_id header; | 431 | struct am335x_baseboard_id header; |
404 | 432 | ||
405 | enable_i2c0_pin_mux(); | 433 | enable_i2c0_pin_mux(); |
406 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); | 434 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); |
407 | if (read_eeprom(&header) < 0) | 435 | if (read_eeprom(&header) < 0) |
408 | puts("Could not get board ID.\n"); | 436 | puts("Could not get board ID.\n"); |
409 | 437 | ||
410 | if (board_is_evm_sk(&header)) | 438 | if (board_is_evm_sk(&header)) |
411 | return &dpll_ddr_evm_sk; | 439 | return &dpll_ddr_evm_sk; |
412 | else if (board_is_bone_lt(&header)) | 440 | else if (board_is_bone_lt(&header)) |
413 | return &dpll_ddr_bone_black; | 441 | return &dpll_ddr_bone_black; |
414 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) | 442 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) |
415 | return &dpll_ddr_smarc_t335x; | 443 | return &dpll_ddr_smarc_t335x; |
416 | else if (board_is_evm_15_or_later(&header)) | 444 | else if (board_is_evm_15_or_later(&header)) |
417 | return &dpll_ddr_evm_sk; | 445 | return &dpll_ddr_evm_sk; |
418 | else | 446 | else |
419 | return &dpll_ddr; | 447 | return &dpll_ddr; |
420 | } | 448 | } |
421 | 449 | ||
422 | void set_uart_mux_conf(void) | 450 | void set_uart_mux_conf(void) |
423 | { | 451 | { |
424 | #if CONFIG_CONS_INDEX == 1 | 452 | #if CONFIG_CONS_INDEX == 1 |
425 | enable_uart0_pin_mux(); | 453 | enable_uart0_pin_mux(); |
426 | #elif CONFIG_CONS_INDEX == 2 | 454 | #elif CONFIG_CONS_INDEX == 2 |
427 | enable_uart1_pin_mux(); | 455 | enable_uart1_pin_mux(); |
428 | #elif CONFIG_CONS_INDEX == 3 | 456 | #elif CONFIG_CONS_INDEX == 3 |
429 | enable_uart2_pin_mux(); | 457 | enable_uart2_pin_mux(); |
430 | #elif CONFIG_CONS_INDEX == 4 | 458 | #elif CONFIG_CONS_INDEX == 4 |
431 | enable_uart3_pin_mux(); | 459 | enable_uart3_pin_mux(); |
432 | #elif CONFIG_CONS_INDEX == 5 | 460 | #elif CONFIG_CONS_INDEX == 5 |
433 | enable_uart4_pin_mux(); | 461 | enable_uart4_pin_mux(); |
434 | #elif CONFIG_CONS_INDEX == 6 | 462 | #elif CONFIG_CONS_INDEX == 6 |
435 | enable_uart5_pin_mux(); | 463 | enable_uart5_pin_mux(); |
436 | #endif | 464 | #endif |
437 | } | 465 | } |
438 | 466 | ||
439 | void set_mux_conf_regs(void) | 467 | void set_mux_conf_regs(void) |
440 | { | 468 | { |
441 | __maybe_unused struct am335x_baseboard_id header; | 469 | __maybe_unused struct am335x_baseboard_id header; |
442 | 470 | ||
443 | if (read_eeprom(&header) < 0) | 471 | if (read_eeprom(&header) < 0) |
444 | puts("Could not get board ID.\n"); | 472 | puts("Could not get board ID.\n"); |
445 | 473 | ||
446 | enable_board_pin_mux(&header); | 474 | enable_board_pin_mux(&header); |
447 | } | 475 | } |
448 | 476 | ||
449 | const struct ctrl_ioregs ioregs_evmsk = { | 477 | const struct ctrl_ioregs ioregs_evmsk = { |
450 | .cm0ioctl = MT41J128MJT125_IOCTRL_VALUE, | 478 | .cm0ioctl = MT41J128MJT125_IOCTRL_VALUE, |
451 | .cm1ioctl = MT41J128MJT125_IOCTRL_VALUE, | 479 | .cm1ioctl = MT41J128MJT125_IOCTRL_VALUE, |
452 | .cm2ioctl = MT41J128MJT125_IOCTRL_VALUE, | 480 | .cm2ioctl = MT41J128MJT125_IOCTRL_VALUE, |
453 | .dt0ioctl = MT41J128MJT125_IOCTRL_VALUE, | 481 | .dt0ioctl = MT41J128MJT125_IOCTRL_VALUE, |
454 | .dt1ioctl = MT41J128MJT125_IOCTRL_VALUE, | 482 | .dt1ioctl = MT41J128MJT125_IOCTRL_VALUE, |
455 | }; | 483 | }; |
456 | 484 | ||
457 | const struct ctrl_ioregs ioregs_bonelt = { | 485 | const struct ctrl_ioregs ioregs_bonelt = { |
458 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 486 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
459 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 487 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
460 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 488 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
461 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 489 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
462 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 490 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
463 | }; | 491 | }; |
464 | 492 | ||
465 | const struct ctrl_ioregs ioregs_smarct335x = { | 493 | const struct ctrl_ioregs ioregs_smarct335x = { |
466 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 494 | .cm0ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
467 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 495 | .cm1ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
468 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 496 | .cm2ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
469 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 497 | .dt0ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
470 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 498 | .dt1ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
471 | }; | 499 | }; |
472 | 500 | ||
501 | const struct ctrl_ioregs ioregs_smarct335x80 = { | ||
502 | .cm0ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | ||
503 | .cm1ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | ||
504 | .cm2ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | ||
505 | .dt0ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | ||
506 | .dt1ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | ||
507 | }; | ||
508 | |||
473 | const struct ctrl_ioregs ioregs_evm15 = { | 509 | const struct ctrl_ioregs ioregs_evm15 = { |
474 | .cm0ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 510 | .cm0ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
475 | .cm1ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 511 | .cm1ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
476 | .cm2ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 512 | .cm2ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
477 | .dt0ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 513 | .dt0ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
478 | .dt1ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 514 | .dt1ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
479 | }; | 515 | }; |
480 | 516 | ||
481 | const struct ctrl_ioregs ioregs = { | 517 | const struct ctrl_ioregs ioregs = { |
482 | .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 518 | .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
483 | .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 519 | .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
484 | .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 520 | .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
485 | .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 521 | .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
486 | .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 522 | .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
487 | }; | 523 | }; |
488 | 524 | ||
489 | void sdram_init(void) | 525 | void sdram_init(void) |
490 | { | 526 | { |
491 | __maybe_unused struct am335x_baseboard_id header; | 527 | __maybe_unused struct am335x_baseboard_id header; |
492 | 528 | ||
493 | if (read_eeprom(&header) < 0) | 529 | if (read_eeprom(&header) < 0) |
494 | puts("Could not get board ID.\n"); | 530 | puts("Could not get board ID.\n"); |
495 | 531 | ||
496 | if (board_is_evm_sk(&header)) { | 532 | if (board_is_evm_sk(&header)) { |
497 | /* | 533 | /* |
498 | * EVM SK 1.2A and later use gpio0_7 to enable DDR3. | 534 | * EVM SK 1.2A and later use gpio0_7 to enable DDR3. |
499 | * This is safe enough to do on older revs. | 535 | * This is safe enough to do on older revs. |
500 | */ | 536 | */ |
501 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); | 537 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); |
502 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); | 538 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); |
503 | } | 539 | } |
504 | 540 | ||
505 | if (board_is_evm_sk(&header)) | 541 | if (board_is_evm_sk(&header)) |
506 | config_ddr(303, &ioregs_evmsk, &ddr3_data, | 542 | config_ddr(303, &ioregs_evmsk, &ddr3_data, |
507 | &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); | 543 | &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); |
508 | else if (board_is_bone_lt(&header)) | 544 | else if (board_is_bone_lt(&header)) |
509 | config_ddr(400, &ioregs_bonelt, | 545 | config_ddr(400, &ioregs_bonelt, |
510 | &ddr3_beagleblack_data, | 546 | &ddr3_beagleblack_data, |
511 | &ddr3_beagleblack_cmd_ctrl_data, | 547 | &ddr3_beagleblack_cmd_ctrl_data, |
512 | &ddr3_beagleblack_emif_reg_data, 0); | 548 | &ddr3_beagleblack_emif_reg_data, 0); |
513 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { | 549 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_1g(&header)) { |
514 | /* | 550 | /* |
515 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. | 551 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. |
516 | * This is safe enough to do on older revs. | 552 | * This is safe enough to do on older revs. |
517 | */ | 553 | */ |
518 | gpio_request(GPIO_LCD_BKLT_EN, "lcd_bklt_en"); | 554 | gpio_request(GPIO_LCD_BKLT_EN, "lcd_bklt_en"); |
519 | gpio_direction_output(GPIO_LCD_BKLT_EN, 1); | 555 | gpio_direction_output(GPIO_LCD_BKLT_EN, 1); |
520 | gpio_request(GPIO_LCD_PWM_EN, "lcd_pwm_en"); | 556 | gpio_request(GPIO_LCD_PWM_EN, "lcd_pwm_en"); |
521 | gpio_direction_output(GPIO_LCD_PWM_EN, 1); | 557 | gpio_direction_output(GPIO_LCD_PWM_EN, 1); |
522 | config_ddr(400, &ioregs_smarct335x, | 558 | config_ddr(400, &ioregs_smarct335x, |
523 | &ddr3_smarct335x_data, | 559 | &ddr3_smarct335x_data, |
524 | &ddr3_smarct335x_cmd_ctrl_data, | 560 | &ddr3_smarct335x_cmd_ctrl_data, |
525 | &ddr3_smarct335x_emif_reg_data, 0); | 561 | &ddr3_smarct335x_emif_reg_data, 0); |
526 | puts("Set DDR3 to 800MHz.\n"); | 562 | udelay(1600); |
563 | } | ||
564 | else if (board_is_smarc_t335x_80(&header)) { | ||
565 | /* | ||
566 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. | ||
567 | * This is safe enough to do on older revs. | ||
568 | */ | ||
569 | gpio_request(GPIO_LCD_BKLT_EN, "lcd_bklt_en"); | ||
570 | gpio_direction_output(GPIO_LCD_BKLT_EN, 1); | ||
571 | gpio_request(GPIO_LCD_PWM_EN, "lcd_pwm_en"); | ||
572 | gpio_direction_output(GPIO_LCD_PWM_EN, 1); | ||
573 | config_ddr(400, &ioregs_smarct335x80, | ||
574 | &ddr3_smarct335x80_data, | ||
575 | &ddr3_smarct335x80_cmd_ctrl_data, | ||
576 | &ddr3_smarct335x80_emif_reg_data, 0); | ||
577 | udelay(1600); | ||
527 | } | 578 | } |
528 | else if (board_is_evm_15_or_later(&header)) | 579 | else if (board_is_evm_15_or_later(&header)) |
529 | config_ddr(400, &ioregs_evm15, &ddr3_evm_data, | 580 | config_ddr(400, &ioregs_evm15, &ddr3_evm_data, |
530 | &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); | 581 | &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); |
531 | else | 582 | else |
532 | config_ddr(266, &ioregs, &ddr2_data, | 583 | config_ddr(266, &ioregs, &ddr2_data, |
533 | &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0); | 584 | &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0); |
534 | } | 585 | } |
535 | #endif | 586 | #endif |
536 | 587 | ||
537 | /* | 588 | /* |
538 | * Basic board specific setup. Pinmux has been handled already. | 589 | * Basic board specific setup. Pinmux has been handled already. |
539 | */ | 590 | */ |
540 | int board_init(void) | 591 | int board_init(void) |
541 | { | 592 | { |
542 | u32 sys_reboot; | 593 | u32 sys_reboot; |
543 | 594 | ||
544 | sys_reboot = readl(PRM_RSTST); | 595 | sys_reboot = readl(PRM_RSTST); |
545 | if (sys_reboot & (1 << 9)) | 596 | if (sys_reboot & (1 << 9)) |
546 | puts("Reset Source: IcePick reset has occurred.\n"); | 597 | puts("Reset Source: IcePick reset has occurred.\n"); |
547 | 598 | ||
548 | if (sys_reboot & (1 << 5)) | 599 | if (sys_reboot & (1 << 5)) |
549 | puts("Reset Source: Global external warm reset has occurred.\n"); | 600 | puts("Reset Source: Global external warm reset has occurred.\n"); |
550 | 601 | ||
551 | if (sys_reboot & (1 << 4)) | 602 | if (sys_reboot & (1 << 4)) |
552 | puts("Reset Source: watchdog reset has occurred.\n"); | 603 | puts("Reset Source: watchdog reset has occurred.\n"); |
553 | 604 | ||
554 | if (sys_reboot & (1 << 1)) | 605 | if (sys_reboot & (1 << 1)) |
555 | puts("Reset Source: Global warm SW reset has occurred.\n"); | 606 | puts("Reset Source: Global warm SW reset has occurred.\n"); |
556 | 607 | ||
557 | if (sys_reboot & (1 << 0)) | 608 | if (sys_reboot & (1 << 0)) |
558 | puts("Reset Source: Power-on reset has occurred.\n"); | 609 | puts("Reset Source: Power-on reset has occurred.\n"); |
559 | 610 | ||
560 | #if defined(CONFIG_HW_WATCHDOG) | 611 | #if defined(CONFIG_HW_WATCHDOG) |
561 | hw_watchdog_init(); | 612 | hw_watchdog_init(); |
562 | #endif | 613 | #endif |
563 | 614 | ||
564 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; | 615 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
565 | #if defined(CONFIG_NOR) || defined(CONFIG_NAND) | 616 | #if defined(CONFIG_NOR) || defined(CONFIG_NAND) |
566 | gpmc_init(); | 617 | gpmc_init(); |
567 | #endif | 618 | #endif |
568 | return 0; | 619 | return 0; |
569 | } | 620 | } |
570 | 621 | ||
571 | #ifdef CONFIG_BOARD_LATE_INIT | 622 | #ifdef CONFIG_BOARD_LATE_INIT |
572 | int board_late_init(void) | 623 | int board_late_init(void) |
573 | { | 624 | { |
574 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | 625 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
575 | char safe_string[HDR_NAME_LEN + 1]; | 626 | char safe_string[HDR_NAME_LEN + 1]; |
576 | struct am335x_baseboard_id header; | 627 | struct am335x_baseboard_id header; |
577 | 628 | ||
578 | if (read_eeprom(&header) < 0) | 629 | if (read_eeprom(&header) < 0) |
579 | puts("Could not get board ID.\n"); | 630 | puts("Could not get board ID.\n"); |
580 | 631 | ||
581 | /* Now set variables based on the header. */ | 632 | /* Now set variables based on the header. */ |
582 | strncpy(safe_string, (char *)header.name, sizeof(header.name)); | 633 | strncpy(safe_string, (char *)header.name, sizeof(header.name)); |
583 | safe_string[sizeof(header.name)] = 0; | 634 | safe_string[sizeof(header.name)] = 0; |
584 | setenv("board_name", safe_string); | 635 | setenv("board_name", safe_string); |
585 | 636 | ||
586 | /* BeagleBone Green has 0x1a at [0], they are free to increment 'a' */ | 637 | /* BeagleBone Green has 0x1a at [0], they are free to increment 'a' */ |
587 | if ( (header.version[0] != 0x30) && (header.version[0] & (1 << 4)) ) { | 638 | if ( (header.version[0] != 0x30) && (header.version[0] & (1 << 4)) ) { |
588 | setenv("board_rev", "BBG1"); | 639 | setenv("board_rev", "BBG1"); |
589 | } else { | 640 | } else { |
590 | strncpy(safe_string, (char *)header.version, sizeof(header.version)); | 641 | strncpy(safe_string, (char *)header.version, sizeof(header.version)); |
591 | safe_string[sizeof(header.version)] = 0; | 642 | safe_string[sizeof(header.version)] = 0; |
592 | setenv("board_rev", safe_string); | 643 | setenv("board_rev", safe_string); |
593 | } | 644 | } |
594 | #endif | 645 | #endif |
595 | 646 | ||
596 | return 0; | 647 | return 0; |
597 | } | 648 | } |
598 | #endif | 649 | #endif |
599 | 650 | ||
600 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ | 651 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ |
601 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) | 652 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
602 | static void cpsw_control(int enabled) | 653 | static void cpsw_control(int enabled) |
603 | { | 654 | { |
604 | /* VTP can be added here */ | 655 | /* VTP can be added here */ |
605 | 656 | ||
606 | return; | 657 | return; |
607 | } | 658 | } |
608 | 659 | ||
609 | static struct cpsw_slave_data cpsw_slaves[] = { | 660 | static struct cpsw_slave_data cpsw_slaves[] = { |
610 | { | 661 | { |
611 | .slave_reg_ofs = 0x208, | 662 | .slave_reg_ofs = 0x208, |
612 | .sliver_reg_ofs = 0xd80, | 663 | .sliver_reg_ofs = 0xd80, |
613 | .phy_addr = 0, | 664 | .phy_addr = 0, |
614 | }, | 665 | }, |
615 | { | 666 | { |
616 | .slave_reg_ofs = 0x308, | 667 | .slave_reg_ofs = 0x308, |
617 | .sliver_reg_ofs = 0xdc0, | 668 | .sliver_reg_ofs = 0xdc0, |
618 | .phy_addr = 1, | 669 | .phy_addr = 1, |
619 | }, | 670 | }, |
620 | }; | 671 | }; |
621 | 672 | ||
622 | static struct cpsw_platform_data cpsw_data = { | 673 | static struct cpsw_platform_data cpsw_data = { |
623 | .mdio_base = CPSW_MDIO_BASE, | 674 | .mdio_base = CPSW_MDIO_BASE, |
624 | .cpsw_base = CPSW_BASE, | 675 | .cpsw_base = CPSW_BASE, |
625 | .mdio_div = 0xff, | 676 | .mdio_div = 0xff, |
626 | .channels = 8, | 677 | .channels = 8, |
627 | .cpdma_reg_ofs = 0x800, | 678 | .cpdma_reg_ofs = 0x800, |
628 | .slaves = 1, | 679 | .slaves = 1, |
629 | .slave_data = cpsw_slaves, | 680 | .slave_data = cpsw_slaves, |
630 | .ale_reg_ofs = 0xd00, | 681 | .ale_reg_ofs = 0xd00, |
631 | .ale_entries = 1024, | 682 | .ale_entries = 1024, |
632 | .host_port_reg_ofs = 0x108, | 683 | .host_port_reg_ofs = 0x108, |
633 | .hw_stats_reg_ofs = 0x900, | 684 | .hw_stats_reg_ofs = 0x900, |
634 | .bd_ram_ofs = 0x2000, | 685 | .bd_ram_ofs = 0x2000, |
635 | .mac_control = (1 << 5), | 686 | .mac_control = (1 << 5), |
636 | .control = cpsw_control, | 687 | .control = cpsw_control, |
637 | .host_port_num = 0, | 688 | .host_port_num = 0, |
638 | .version = CPSW_CTRL_VERSION_2, | 689 | .version = CPSW_CTRL_VERSION_2, |
639 | }; | 690 | }; |
640 | #endif | 691 | #endif |
641 | 692 | ||
642 | /* | 693 | /* |
643 | * This function will: | 694 | * This function will: |
644 | * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr | 695 | * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr |
645 | * in the environment | 696 | * in the environment |
646 | * Perform fixups to the PHY present on certain boards. We only need this | 697 | * Perform fixups to the PHY present on certain boards. We only need this |
647 | * function in: | 698 | * function in: |
648 | * - SPL with either CPSW or USB ethernet support | 699 | * - SPL with either CPSW or USB ethernet support |
649 | * - Full U-Boot, with either CPSW or USB ethernet | 700 | * - Full U-Boot, with either CPSW or USB ethernet |
650 | * Build in only these cases to avoid warnings about unused variables | 701 | * Build in only these cases to avoid warnings about unused variables |
651 | * when we build an SPL that has neither option but full U-Boot will. | 702 | * when we build an SPL that has neither option but full U-Boot will. |
652 | */ | 703 | */ |
653 | #if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) \ | 704 | #if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) \ |
654 | && defined(CONFIG_SPL_BUILD)) || \ | 705 | && defined(CONFIG_SPL_BUILD)) || \ |
655 | ((defined(CONFIG_DRIVER_TI_CPSW) || \ | 706 | ((defined(CONFIG_DRIVER_TI_CPSW) || \ |
656 | defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \ | 707 | defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \ |
657 | !defined(CONFIG_SPL_BUILD)) | 708 | !defined(CONFIG_SPL_BUILD)) |
658 | int board_eth_init(bd_t *bis) | 709 | int board_eth_init(bd_t *bis) |
659 | { | 710 | { |
660 | int rv, n = 0; | 711 | int rv, n = 0; |
661 | uint8_t mac_addr[6]; | 712 | uint8_t mac_addr[6]; |
662 | uint32_t mac_hi, mac_lo; | 713 | uint32_t mac_hi, mac_lo; |
663 | __maybe_unused struct am335x_baseboard_id header; | 714 | __maybe_unused struct am335x_baseboard_id header; |
664 | 715 | ||
665 | /* try reading mac address from efuse */ | 716 | /* try reading mac address from efuse */ |
666 | mac_lo = readl(&cdev->macid0l); | 717 | mac_lo = readl(&cdev->macid0l); |
667 | mac_hi = readl(&cdev->macid0h); | 718 | mac_hi = readl(&cdev->macid0h); |
668 | mac_addr[0] = mac_hi & 0xFF; | 719 | mac_addr[0] = mac_hi & 0xFF; |
669 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; | 720 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
670 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; | 721 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
671 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; | 722 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
672 | mac_addr[4] = mac_lo & 0xFF; | 723 | mac_addr[4] = mac_lo & 0xFF; |
673 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; | 724 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
674 | 725 | ||
675 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ | 726 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ |
676 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) | 727 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
677 | if (!getenv("ethaddr")) { | 728 | if (!getenv("ethaddr")) { |
678 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); | 729 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); |
679 | 730 | ||
680 | if (is_valid_ethaddr(mac_addr)) | 731 | if (is_valid_ethaddr(mac_addr)) |
681 | eth_setenv_enetaddr("ethaddr", mac_addr); | 732 | eth_setenv_enetaddr("ethaddr", mac_addr); |
682 | } | 733 | } |
683 | 734 | ||
684 | #ifdef CONFIG_DRIVER_TI_CPSW | 735 | #ifdef CONFIG_DRIVER_TI_CPSW |
685 | 736 | ||
686 | mac_lo = readl(&cdev->macid1l); | 737 | mac_lo = readl(&cdev->macid1l); |
687 | mac_hi = readl(&cdev->macid1h); | 738 | mac_hi = readl(&cdev->macid1h); |
688 | mac_addr[0] = mac_hi & 0xFF; | 739 | mac_addr[0] = mac_hi & 0xFF; |
689 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; | 740 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
690 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; | 741 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
691 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; | 742 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
692 | mac_addr[4] = mac_lo & 0xFF; | 743 | mac_addr[4] = mac_lo & 0xFF; |
693 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; | 744 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
694 | 745 | ||
695 | if (!getenv("eth1addr")) { | 746 | if (!getenv("eth1addr")) { |
696 | if (is_valid_ethaddr(mac_addr)) | 747 | if (is_valid_ethaddr(mac_addr)) |
697 | eth_setenv_enetaddr("eth1addr", mac_addr); | 748 | eth_setenv_enetaddr("eth1addr", mac_addr); |
698 | } | 749 | } |
699 | 750 | ||
700 | if (read_eeprom(&header) < 0) | 751 | if (read_eeprom(&header) < 0) |
701 | puts("Could not get board ID.\n"); | 752 | puts("Could not get board ID.\n"); |
702 | 753 | ||
703 | if (board_is_bone(&header) || board_is_bone_lt(&header) || | 754 | if (board_is_bone(&header) || board_is_bone_lt(&header) || |
704 | board_is_idk(&header)) { | 755 | board_is_idk(&header)) { |
705 | writel(MII_MODE_ENABLE, &cdev->miisel); | 756 | writel(MII_MODE_ENABLE, &cdev->miisel); |
706 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = | 757 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = |
707 | PHY_INTERFACE_MODE_MII; | 758 | PHY_INTERFACE_MODE_MII; |
708 | } else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { | 759 | } else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { |
709 | writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel); | 760 | writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel); |
710 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = | 761 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = |
711 | PHY_INTERFACE_MODE_RMII; | 762 | PHY_INTERFACE_MODE_RMII; |
712 | } else { | 763 | } else { |
713 | writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel); | 764 | writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel); |
714 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = | 765 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = |
715 | PHY_INTERFACE_MODE_RGMII; | 766 | PHY_INTERFACE_MODE_RGMII; |
716 | } | 767 | } |
717 | 768 | ||
718 | rv = cpsw_register(&cpsw_data); | 769 | rv = cpsw_register(&cpsw_data); |
719 | if (rv < 0) | 770 | if (rv < 0) |
720 | printf("Error %d registering CPSW switch\n", rv); | 771 | printf("Error %d registering CPSW switch\n", rv); |
721 | else | 772 | else |
722 | n += rv; | 773 | n += rv; |
723 | #endif | 774 | #endif |
724 | 775 | ||
725 | /* | 776 | /* |
726 | * | 777 | * |
727 | * CPSW RGMII Internal Delay Mode is not supported in all PVT | 778 | * CPSW RGMII Internal Delay Mode is not supported in all PVT |
728 | * operating points. So we must set the TX clock delay feature | 779 | * operating points. So we must set the TX clock delay feature |
729 | * in the AR8051 PHY. Since we only support a single ethernet | 780 | * in the AR8051 PHY. Since we only support a single ethernet |
730 | * device in U-Boot, we only do this for the first instance. | 781 | * device in U-Boot, we only do this for the first instance. |
731 | */ | 782 | */ |
732 | #define AR8051_PHY_DEBUG_ADDR_REG 0x1d | 783 | #define AR8051_PHY_DEBUG_ADDR_REG 0x1d |
733 | #define AR8051_PHY_DEBUG_DATA_REG 0x1e | 784 | #define AR8051_PHY_DEBUG_DATA_REG 0x1e |
734 | #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5 | 785 | #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5 |
735 | #define AR8051_RGMII_TX_CLK_DLY 0x100 | 786 | #define AR8051_RGMII_TX_CLK_DLY 0x100 |
736 | 787 | ||
737 | if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) { | 788 | if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) { |
738 | const char *devname; | 789 | const char *devname; |
739 | devname = miiphy_get_current_dev(); | 790 | devname = miiphy_get_current_dev(); |
740 | 791 | ||
741 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_ADDR_REG, | 792 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_ADDR_REG, |
742 | AR8051_DEBUG_RGMII_CLK_DLY_REG); | 793 | AR8051_DEBUG_RGMII_CLK_DLY_REG); |
743 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_DATA_REG, | 794 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_DATA_REG, |
744 | AR8051_RGMII_TX_CLK_DLY); | 795 | AR8051_RGMII_TX_CLK_DLY); |
745 | } | 796 | } |
746 | #endif | 797 | #endif |
747 | #if defined(CONFIG_USB_ETHER) && \ | 798 | #if defined(CONFIG_USB_ETHER) && \ |
748 | (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT)) | 799 | (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT)) |
749 | if (is_valid_ethaddr(mac_addr)) | 800 | if (is_valid_ethaddr(mac_addr)) |
750 | eth_setenv_enetaddr("usbnet_devaddr", mac_addr); | 801 | eth_setenv_enetaddr("usbnet_devaddr", mac_addr); |
751 | 802 | ||
752 | rv = usb_eth_initialize(bis); | 803 | rv = usb_eth_initialize(bis); |
753 | if (rv < 0) | 804 | if (rv < 0) |
754 | printf("Error %d registering USB_ETHER\n", rv); | 805 | printf("Error %d registering USB_ETHER\n", rv); |
755 | else | 806 | else |
756 | n += rv; | 807 | n += rv; |
757 | #endif | 808 | #endif |
758 | return n; | 809 | return n; |
759 | } | 810 | } |
760 | #endif | 811 | #endif |
761 | 812 |