Blame view

arch/arm/mach-omap2/am33xx/board.c 11.4 KB
5289e83a8   Chandan Nath   ARM:AM33XX: Add s...
1
2
3
4
5
6
7
  /*
   * board.c
   *
   * Common board functions for AM33XX based boards
   *
   * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
   *
1a4596601   Wolfgang Denk   Add GPL-2.0+ SPDX...
8
   * SPDX-License-Identifier:	GPL-2.0+
5289e83a8   Chandan Nath   ARM:AM33XX: Add s...
9
10
11
   */
  
  #include <common.h>
d12010b09   Simon Glass   dm: am33xx: Provi...
12
  #include <dm.h>
973b66382   Tom Rini   am33xx: Remove bo...
13
  #include <errno.h>
4119e06dd   Simon Glass   dm: am33xx: Provi...
14
  #include <ns16550.h>
47f7bcae8   Tom Rini   SPL: Move the oma...
15
  #include <spl.h>
5289e83a8   Chandan Nath   ARM:AM33XX: Add s...
16
17
  #include <asm/arch/cpu.h>
  #include <asm/arch/hardware.h>
8a8f084e4   Chandan Nath   ARM:AM33XX: Add S...
18
  #include <asm/arch/omap.h>
5289e83a8   Chandan Nath   ARM:AM33XX: Add s...
19
20
  #include <asm/arch/ddr_defs.h>
  #include <asm/arch/clock.h>
3b97152b6   Steve Sakoman   omap: am33xx: ena...
21
  #include <asm/arch/gpio.h>
8eb16b7f7   Ilya Yanok   am33xx: NAND support
22
  #include <asm/arch/mem.h>
8a8f084e4   Chandan Nath   ARM:AM33XX: Add S...
23
  #include <asm/arch/mmc_host_def.h>
db7dd8109   Tom Rini   am33xx: Rework pi...
24
  #include <asm/arch/sys_proto.h>
5289e83a8   Chandan Nath   ARM:AM33XX: Add s...
25
  #include <asm/io.h>
fda35eb98   Tom Rini   am33xx: Pass to c...
26
  #include <asm/emif.h>
65d750be5   Tom Rini   am33xx: Add suppo...
27
  #include <asm/gpio.h>
973b66382   Tom Rini   am33xx: Remove bo...
28
29
30
  #include <i2c.h>
  #include <miiphy.h>
  #include <cpsw.h>
1221ce459   Masahiro Yamada   treewide: replace...
31
  #include <linux/errno.h>
6a0d803c7   Tom Rini   am33xx: Add am33x...
32
  #include <linux/compiler.h>
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
33
34
35
36
  #include <linux/usb/ch9.h>
  #include <linux/usb/gadget.h>
  #include <linux/usb/musb.h>
  #include <asm/omap_musb.h>
155d424a9   Tom Rini   am33xx, davinci: ...
37
  #include <asm/davinci_rtc.h>
5289e83a8   Chandan Nath   ARM:AM33XX: Add s...
38
39
  
  DECLARE_GLOBAL_DATA_PTR;
75507d5d5   Tom Rini   am33xx: Update se...
40
  #if !CONFIG_IS_ENABLED(OF_CONTROL)
4119e06dd   Simon Glass   dm: am33xx: Provi...
41
  static const struct ns16550_platdata am33xx_serial[] = {
aa1ac9d52   Heiko Schocher   serial, ns16550: ...
42
43
  	{ .base = CONFIG_SYS_NS16550_COM1, .reg_shift = 2,
  	  .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
1480fdf8a   Tom Rini   am33xx: Update DT...
44
  # ifdef CONFIG_SYS_NS16550_COM2
aa1ac9d52   Heiko Schocher   serial, ns16550: ...
45
46
  	{ .base = CONFIG_SYS_NS16550_COM2, .reg_shift = 2,
  	  .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
1480fdf8a   Tom Rini   am33xx: Update DT...
47
  #  ifdef CONFIG_SYS_NS16550_COM3
aa1ac9d52   Heiko Schocher   serial, ns16550: ...
48
49
50
51
52
53
54
55
  	{ .base = CONFIG_SYS_NS16550_COM3, .reg_shift = 2,
  	  .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  	{ .base = CONFIG_SYS_NS16550_COM4, .reg_shift = 2,
  	  .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  	{ .base = CONFIG_SYS_NS16550_COM5, .reg_shift = 2,
  	  .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
  	{ .base = CONFIG_SYS_NS16550_COM6, .reg_shift = 2,
  	  .clock = CONFIG_SYS_NS16550_CLK, .fcr = UART_FCR_DEFVAL, },
4119e06dd   Simon Glass   dm: am33xx: Provi...
56
  #  endif
1480fdf8a   Tom Rini   am33xx: Update DT...
57
  # endif
4119e06dd   Simon Glass   dm: am33xx: Provi...
58
59
60
  };
  
  U_BOOT_DEVICES(am33xx_uarts) = {
75507d5d5   Tom Rini   am33xx: Update se...
61
  	{ "ns16550_serial", &am33xx_serial[0] },
4119e06dd   Simon Glass   dm: am33xx: Provi...
62
  #  ifdef CONFIG_SYS_NS16550_COM2
75507d5d5   Tom Rini   am33xx: Update se...
63
  	{ "ns16550_serial", &am33xx_serial[1] },
4119e06dd   Simon Glass   dm: am33xx: Provi...
64
  #   ifdef CONFIG_SYS_NS16550_COM3
75507d5d5   Tom Rini   am33xx: Update se...
65
66
67
68
  	{ "ns16550_serial", &am33xx_serial[2] },
  	{ "ns16550_serial", &am33xx_serial[3] },
  	{ "ns16550_serial", &am33xx_serial[4] },
  	{ "ns16550_serial", &am33xx_serial[5] },
4119e06dd   Simon Glass   dm: am33xx: Provi...
69
70
71
  #   endif
  #  endif
  };
90345c92a   Tom Rini   am33xx/am43xx: Ad...
72
73
74
75
76
77
78
79
80
81
  
  #ifdef CONFIG_DM_GPIO
  static const struct omap_gpio_platdata am33xx_gpio[] = {
  	{ 0, AM33XX_GPIO0_BASE },
  	{ 1, AM33XX_GPIO1_BASE },
  	{ 2, AM33XX_GPIO2_BASE },
  	{ 3, AM33XX_GPIO3_BASE },
  #ifdef CONFIG_AM43XX
  	{ 4, AM33XX_GPIO4_BASE },
  	{ 5, AM33XX_GPIO5_BASE },
1480fdf8a   Tom Rini   am33xx: Update DT...
82
  #endif
90345c92a   Tom Rini   am33xx/am43xx: Ad...
83
  };
4119e06dd   Simon Glass   dm: am33xx: Provi...
84

90345c92a   Tom Rini   am33xx/am43xx: Ad...
85
86
87
88
89
90
91
92
93
94
95
96
  U_BOOT_DEVICES(am33xx_gpios) = {
  	{ "gpio_omap", &am33xx_gpio[0] },
  	{ "gpio_omap", &am33xx_gpio[1] },
  	{ "gpio_omap", &am33xx_gpio[2] },
  	{ "gpio_omap", &am33xx_gpio[3] },
  #ifdef CONFIG_AM43XX
  	{ "gpio_omap", &am33xx_gpio[4] },
  	{ "gpio_omap", &am33xx_gpio[5] },
  #endif
  };
  #endif
  #endif
d12010b09   Simon Glass   dm: am33xx: Provi...
97

1480fdf8a   Tom Rini   am33xx: Update DT...
98
  #ifndef CONFIG_DM_GPIO
cd8341b7e   Dave Gerlach   ARM: AM43xx: GP-E...
99
  static const struct gpio_bank gpio_bank_am33xx[] = {
0a9e34056   Tom Rini   gpio: omap: Drop ...
100
101
102
103
  	{ (void *)AM33XX_GPIO0_BASE },
  	{ (void *)AM33XX_GPIO1_BASE },
  	{ (void *)AM33XX_GPIO2_BASE },
  	{ (void *)AM33XX_GPIO3_BASE },
cd8341b7e   Dave Gerlach   ARM: AM43xx: GP-E...
104
  #ifdef CONFIG_AM43XX
0a9e34056   Tom Rini   gpio: omap: Drop ...
105
106
  	{ (void *)AM33XX_GPIO4_BASE },
  	{ (void *)AM33XX_GPIO5_BASE },
cd8341b7e   Dave Gerlach   ARM: AM43xx: GP-E...
107
  #endif
3b97152b6   Steve Sakoman   omap: am33xx: ena...
108
109
110
  };
  
  const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
d12010b09   Simon Glass   dm: am33xx: Provi...
111
  #endif
3eb68c53e   Jean-Jacques Hiblot   ti: boot: Registe...
112
  #if defined(CONFIG_OMAP_HSMMC)
75a23880a   Peter Korsgaard   am33xx/board: use...
113
  int cpu_mmc_init(bd_t *bis)
876bdd6d4   Chandan Nath   ARM:AM33XX: Add m...
114
  {
0689a2ef1   Tom Rini   am33xx: Correct M...
115
  	int ret;
75a23880a   Peter Korsgaard   am33xx/board: use...
116

e3913f56a   Nikita Kiryanov   omap_hsmmc: add d...
117
  	ret = omap_mmc_init(0, 0, 0, -1, -1);
0689a2ef1   Tom Rini   am33xx: Correct M...
118
119
  	if (ret)
  		return ret;
c3c6fd417   Eric Lee   Initial Release o...
120
  	return omap_mmc_init(2, 0, 0, -1, -1);
876bdd6d4   Chandan Nath   ARM:AM33XX: Add m...
121
122
  }
  #endif
8a8f084e4   Chandan Nath   ARM:AM33XX: Add S...
123

adb395df0   Tero Kristo   ARM: AM43xx: Add ...
124
125
126
127
128
129
130
131
  /*
   * RTC only mode magic value, checked against during boot to see if we have
   * a valid config
   */
  #define RTC_MAGIC_VAL		0x8cd0
  
  /* Board type field bit shift for RTC only mode */
  #define RTC_BOARD_TYPE_SHIFT	16
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
132
  /* AM33XX has two MUSB controllers which can be host or gadget */
95de1e2f2   Paul Kocialkowski   usb: musb-new: CO...
133
  #if (defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)) && \
195702217   Mugunthan V N   am33xx: board: do...
134
135
  	(defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) && \
  	(!defined(CONFIG_DM_USB))
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
  
  /* USB 2.0 PHY Control */
  #define CM_PHY_PWRDN			(1 << 0)
  #define CM_PHY_OTG_PWRDN		(1 << 1)
  #define OTGVDET_EN			(1 << 19)
  #define OTGSESSENDEN			(1 << 20)
  
  static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr)
  {
  	if (on) {
  		clrsetbits_le32(reg_addr, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN,
  				OTGVDET_EN | OTGSESSENDEN);
  	} else {
  		clrsetbits_le32(reg_addr, 0, CM_PHY_PWRDN | CM_PHY_OTG_PWRDN);
  	}
  }
  
  static struct musb_hdrc_config musb_config = {
  	.multipoint     = 1,
  	.dyn_fifo       = 1,
  	.num_eps        = 16,
  	.ram_bits       = 12,
  };
  
  #ifdef CONFIG_AM335X_USB0
1cac34ce1   Mugunthan V N   drivers: usb: mus...
162
  static void am33xx_otg0_set_phy_power(struct udevice *dev, u8 on)
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  {
  	am33xx_usb_set_phy_power(on, &cdev->usb_ctrl0);
  }
  
  struct omap_musb_board_data otg0_board_data = {
  	.set_phy_power = am33xx_otg0_set_phy_power,
  };
  
  static struct musb_hdrc_platform_data otg0_plat = {
  	.mode           = CONFIG_AM335X_USB0_MODE,
  	.config         = &musb_config,
  	.power          = 50,
  	.platform_ops	= &musb_dsps_ops,
  	.board_data	= &otg0_board_data,
  };
  #endif
  
  #ifdef CONFIG_AM335X_USB1
1cac34ce1   Mugunthan V N   drivers: usb: mus...
181
  static void am33xx_otg1_set_phy_power(struct udevice *dev, u8 on)
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
  {
  	am33xx_usb_set_phy_power(on, &cdev->usb_ctrl1);
  }
  
  struct omap_musb_board_data otg1_board_data = {
  	.set_phy_power = am33xx_otg1_set_phy_power,
  };
  
  static struct musb_hdrc_platform_data otg1_plat = {
  	.mode           = CONFIG_AM335X_USB1_MODE,
  	.config         = &musb_config,
  	.power          = 50,
  	.platform_ops	= &musb_dsps_ops,
  	.board_data	= &otg1_board_data,
  };
  #endif
  #endif
  
  int arch_misc_init(void)
  {
195702217   Mugunthan V N   am33xx: board: do...
202
  #ifndef CONFIG_DM_USB
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
203
204
  #ifdef CONFIG_AM335X_USB0
  	musb_register(&otg0_plat, &otg0_board_data,
81df2bab4   Matt Porter   am33xx: convert d...
205
  		(void *)USB0_OTG_BASE);
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
206
207
208
  #endif
  #ifdef CONFIG_AM335X_USB1
  	musb_register(&otg1_plat, &otg1_board_data,
81df2bab4   Matt Porter   am33xx: convert d...
209
  		(void *)USB1_OTG_BASE);
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
210
  #endif
3aec26486   Mugunthan V N   am33xx: board: pr...
211
212
213
214
215
216
217
  #else
  	struct udevice *dev;
  	int ret;
  
  	ret = uclass_first_device(UCLASS_MISC, &dev);
  	if (ret || !dev)
  		return ret;
c9b65c9a3   Mugunthan V N   am33xx: board: in...
218

dcc773a44   Vignesh R   am33xx: board: pr...
219
220
221
  	ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
  	if (ret)
  		return ret;
c9b65c9a3   Mugunthan V N   am33xx: board: in...
222
223
224
225
226
227
228
229
  #if defined(CONFIG_DM_ETH) && defined(CONFIG_USB_ETHER)
  	ret = usb_ether_init();
  	if (ret) {
  		error("USB ether init failed
  ");
  		return ret;
  	}
  #endif
195702217   Mugunthan V N   am33xx: board: do...
230
  #endif
7df5cf35d   Ilya Yanok   am33xx: init OTG ...
231
232
  	return 0;
  }
49f783650   Heiko Schocher   arm, am33xx: move...
233

d0e6d34d7   Tom Rini   am335x: Switch to...
234
  #ifndef CONFIG_SKIP_LOWLEVEL_INIT
adb395df0   Tero Kristo   ARM: AM43xx: Add ...
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
  
  #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) || \
  	(defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT))
  static void rtc32k_unlock(struct davinci_rtc *rtc)
  {
  	/*
  	 * Unlock the RTC's registers.  For more details please see the
  	 * RTC_SS section of the TRM.  In order to unlock we need to
  	 * write these specific values (keys) in this order.
  	 */
  	writel(RTC_KICK0R_WE, &rtc->kick0r);
  	writel(RTC_KICK1R_WE, &rtc->kick1r);
  }
  #endif
  
  #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT)
  /*
   * Write contents of the RTC_SCRATCH1 register based on board type
   * Two things are passed
   * on. First 16 bits (0:15) are written with RTC_MAGIC value. Once the
   * control gets to kernel, kernel reads the scratchpad register and gets to
   * know that bootloader has rtc_only support.
   *
   * Second important thing is the board type  (16:31). This is needed in the
   * rtc_only boot where in we want to avoid costly i2c reads to eeprom to
   * identify the board type and we go ahead and copy the board strings to
   * am43xx_board_name.
   */
  void update_rtc_magic(void)
  {
  	struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE;
  	u32 magic = RTC_MAGIC_VAL;
  
  	magic |= (rtc_only_get_board_type() << RTC_BOARD_TYPE_SHIFT);
  
  	rtc32k_unlock(rtc);
  
  	/* write magic */
  	writel(magic, &rtc->scratch1);
  }
  #endif
6a0d803c7   Tom Rini   am33xx: Add am33x...
276
  /*
196311dc7   Tom Rini   arm:am33xx: Rewor...
277
278
279
280
281
282
283
284
   * In the case of non-SPL based booting we'll want to call these
   * functions a tiny bit later as it will require gd to be set and cleared
   * and that's not true in s_init in this case so we cannot do it there.
   */
  int board_early_init_f(void)
  {
  	prcm_init();
  	set_mux_conf_regs();
adb395df0   Tero Kristo   ARM: AM43xx: Add ...
285
286
287
  #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT)
  	update_rtc_magic();
  #endif
196311dc7   Tom Rini   arm:am33xx: Rewor...
288
289
290
291
  	return 0;
  }
  
  /*
6a0d803c7   Tom Rini   am33xx: Add am33x...
292
293
294
295
296
297
   * This function is the place to do per-board things such as ramp up the
   * MPU clock frequency.
   */
  __weak void am33xx_spl_board_init(void)
  {
  }
16678eb40   Heiko Schocher   arm, am33x: make ...
298
  #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
299
  static void rtc32k_enable(void)
49f783650   Heiko Schocher   arm, am33xx: move...
300
  {
155d424a9   Tom Rini   am33xx, davinci: ...
301
  	struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE;
49f783650   Heiko Schocher   arm, am33xx: move...
302

adb395df0   Tero Kristo   ARM: AM43xx: Add ...
303
  	rtc32k_unlock(rtc);
49f783650   Heiko Schocher   arm, am33xx: move...
304
305
306
307
  
  	/* Enable the RTC 32K OSC by setting bits 3 and 6. */
  	writel((1 << 3) | (1 << 6), &rtc->osc);
  }
16678eb40   Heiko Schocher   arm, am33x: make ...
308
  #endif
7ea7f689c   Heiko Schocher   arm, am33xx: move...
309

0660481a5   Heiko Schocher   ARM: AM33xx: Move...
310
  static void uart_soft_reset(void)
7ea7f689c   Heiko Schocher   arm, am33xx: move...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
  {
  	struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
  	u32 regval;
  
  	regval = readl(&uart_base->uartsyscfg);
  	regval |= UART_RESET;
  	writel(regval, &uart_base->uartsyscfg);
  	while ((readl(&uart_base->uartsyssts) &
  		UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
  		;
  
  	/* Disable smart idle */
  	regval = readl(&uart_base->uartsyscfg);
  	regval |= UART_SMART_IDLE_EN;
  	writel(regval, &uart_base->uartsyscfg);
  }
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
327
328
329
330
331
332
333
334
335
336
337
338
  
  static void watchdog_disable(void)
  {
  	struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
  
  	writel(0xAAAA, &wdtimer->wdtwspr);
  	while (readl(&wdtimer->wdtwwps) != 0x0)
  		;
  	writel(0x5555, &wdtimer->wdtwspr);
  	while (readl(&wdtimer->wdtwwps) != 0x0)
  		;
  }
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
339

adb395df0   Tero Kristo   ARM: AM43xx: Add ...
340
341
342
343
344
345
346
  #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT)
  /*
   * Check if we are executing rtc-only mode, and resume from it if needed
   */
  static void rtc_only(void)
  {
  	struct davinci_rtc *rtc = (struct davinci_rtc *)RTC_BASE;
5c3d4a3a6   Russ Dill   ARM: am33xx: Inhi...
347
348
  	struct prm_device_inst *prm_device =
  				(struct prm_device_inst *)PRM_DEVICE_INST;
adb395df0   Tero Kristo   ARM: AM43xx: Add ...
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
  	u32 scratch1;
  	void (*resume_func)(void);
  
  	scratch1 = readl(&rtc->scratch1);
  
  	/*
  	 * Check RTC scratch against RTC_MAGIC_VAL, RTC_MAGIC_VAL is only
  	 * written to this register when we want to wake up from RTC only
  	 * mode. Contents of the RTC_SCRATCH1:
  	 * bits 0-15:  RTC_MAGIC_VAL
  	 * bits 16-31: board type (needed for sdram_init)
  	 */
  	if ((scratch1 & 0xffff) != RTC_MAGIC_VAL)
  		return;
  
  	rtc32k_unlock(rtc);
  
  	/* Clear RTC magic */
  	writel(0, &rtc->scratch1);
  
  	/*
  	 * Update board type based on value stored on RTC_SCRATCH1, this
  	 * is done so that we don't need to read the board type from eeprom
  	 * over i2c bus which is expensive
  	 */
  	rtc_only_update_board_type(scratch1 >> RTC_BOARD_TYPE_SHIFT);
5c3d4a3a6   Russ Dill   ARM: am33xx: Inhi...
375
376
377
378
379
380
381
  	/*
  	 * Enable EMIF_DEVOFF in PRCM_PRM_EMIF_CTRL to indicate to EMIF we
  	 * are resuming from self-refresh. This avoids an unnecessary re-init
  	 * of the DDR. The re-init takes time and we would need to wait for
  	 * it to complete before accessing DDR to avoid L3 NOC errors.
  	 */
  	writel(EMIF_CTRL_DEVOFF, &prm_device->emif_ctrl);
adb395df0   Tero Kristo   ARM: AM43xx: Add ...
382
383
  	rtc_only_prcm_init();
  	sdram_init();
5c3d4a3a6   Russ Dill   ARM: am33xx: Inhi...
384
385
  	/* Disable EMIF_DEVOFF for normal operation and to exit self-refresh */
  	writel(0, &prm_device->emif_ctrl);
adb395df0   Tero Kristo   ARM: AM43xx: Add ...
386
387
388
389
390
  	resume_func = (void *)readl(&rtc->scratch0);
  	if (resume_func)
  		resume_func();
  }
  #endif
c704a99df   Lokesh Vutla   ARM: AMx3xx: Allo...
391
  void s_init(void)
7ae8350f6   Simon Glass   ti: armv7: Move S...
392
  {
adb395df0   Tero Kristo   ARM: AM43xx: Add ...
393
394
395
  #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_RTC_ONLY_SUPPORT)
  	rtc_only();
  #endif
7ae8350f6   Simon Glass   ti: armv7: Move S...
396
  }
7ae8350f6   Simon Glass   ti: armv7: Move S...
397

c704a99df   Lokesh Vutla   ARM: AMx3xx: Allo...
398
  void early_system_init(void)
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
399
400
401
402
403
404
405
406
407
  {
  	/*
  	 * The ROM will only have set up sufficient pinmux to allow for the
  	 * first 4KiB NOR to be read, we must finish doing what we know of
  	 * the NOR mux in this space in order to continue.
  	 */
  #ifdef CONFIG_NOR_BOOT
  	enable_norboot_pin_mux();
  #endif
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
408
  	watchdog_disable();
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
409
  	set_uart_mux_conf();
b64a7cb92   Lokesh Vutla   ARM: AMx3xx: Cent...
410
  	setup_early_clocks();
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
411
  	uart_soft_reset();
f320970d2   Lokesh Vutla   arm: omap: Detect...
412
413
414
415
416
417
418
419
  #ifdef CONFIG_SPL_BUILD
  	/*
  	 * Save the boot parameters passed from romcode.
  	 * We cannot delay the saving further than this,
  	 * to prevent overwrites.
  	 */
  	save_omap_boot_params();
  #endif
140d76a9e   Lokesh Vutla   board: ti: amx3xx...
420
421
422
  #ifdef CONFIG_TI_I2C_BOARD_DETECT
  	do_board_detect();
  #endif
16678eb40   Heiko Schocher   arm, am33x: make ...
423
  #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
424
425
  	/* Enable RTC32K clock */
  	rtc32k_enable();
16678eb40   Heiko Schocher   arm, am33x: make ...
426
  #endif
0660481a5   Heiko Schocher   ARM: AM33xx: Move...
427
  }
c704a99df   Lokesh Vutla   ARM: AMx3xx: Allo...
428
429
430
431
432
433
434
  
  #ifdef CONFIG_SPL_BUILD
  void board_init_f(ulong dummy)
  {
  	early_system_init();
  	board_early_init_f();
  	sdram_init();
837d8234c   Lokesh Vutla   arch: arm: omap: ...
435
436
437
438
  	/* dram_init must store complete ramsize in gd->ram_size */
  	gd->ram_size = get_ram_size(
  			(void *)CONFIG_SYS_SDRAM_BASE,
  			CONFIG_MAX_RAM_BANK_SIZE);
c704a99df   Lokesh Vutla   ARM: AMx3xx: Allo...
439
  }
d73f38f7b   Tom Rini   am33xx: Rework #i...
440
  #endif
c704a99df   Lokesh Vutla   ARM: AMx3xx: Allo...
441
442
443
444
445
446
447
448
449
450
  
  #endif
  
  int arch_cpu_init_dm(void)
  {
  #ifndef CONFIG_SKIP_LOWLEVEL_INIT
  	early_system_init();
  #endif
  	return 0;
  }