3 * Logic Product Development <www.logicpd.com>
6 * Peter Barada <peter.barada@logicpd.com>
8 * Derived from Beagle Board and 3430 SDP code by
9 * Richard Woodruff <r-woodruff2@ti.com>
10 * Syed Mohammed Khasim <khasim@ti.com>
12 * SPDX-License-Identifier: GPL-2.0+
23 #include <asm/arch/mmc_host_def.h>
24 #include <asm/arch/mux.h>
25 #include <asm/arch/mem.h>
26 #include <asm/arch/sys_proto.h>
28 #include <asm/mach-types.h>
29 #include <linux/mtd/nand.h>
30 #include <asm/omap_musb.h>
31 #include <linux/errno.h>
32 #include <linux/usb/ch9.h>
33 #include <linux/usb/gadget.h>
34 #include <linux/usb/musb.h>
35 #include "omap3logic.h"
36 #ifdef CONFIG_USB_EHCI_HCD
38 #include <asm/ehci-omap.h>
41 DECLARE_GLOBAL_DATA_PTR;
43 /* This is only needed until SPL gets OF support */
44 #ifdef CONFIG_SPL_BUILD
45 static const struct ns16550_platdata omap3logic_serial = {
46 .base = OMAP34XX_UART1,
48 .clock = V_NS16550_CLK,
49 .fcr = UART_FCR_DEFVAL,
52 U_BOOT_DEVICE(omap3logic_uart) = {
59 * two dimensional array of strucures containining board name and Linux
60 * machine IDs; row it selected based on CPU column is slected based
61 * on hsusb0_data5 pin having a pulldown resistor
63 static struct board_id {
70 .name = "OMAP35xx SOM LV",
71 .machine_id = MACH_TYPE_OMAP3530_LV_SOM,
72 .fdtfile = "logicpd-som-lv-35xx-devkit.dtb",
75 .name = "OMAP35xx Torpedo",
76 .machine_id = MACH_TYPE_OMAP3_TORPEDO,
77 .fdtfile = "logicpd-torpedo-35xx-devkit.dtb",
82 .name = "DM37xx SOM LV",
83 .fdtfile = "logicpd-som-lv-37xx-devkit.dtb",
86 .name = "DM37xx Torpedo",
87 .fdtfile = "logicpd-torpedo-37xx-devkit.dtb",
92 #ifdef CONFIG_SPL_OS_BOOT
93 int spl_start_uboot(void)
95 /* break into full u-boot on 'c' */
96 return serial_tstc() && serial_getc() == 'c';
100 #if defined(CONFIG_SPL_BUILD)
102 * Routine: get_board_mem_timings
103 * Description: If we use SPL then there is no x-loader nor config header
104 * so we have to setup the DDR timings ourself on the first bank. This
105 * provides the timing values back to the function that configures
108 void get_board_mem_timings(struct board_sdrc_timings *timings)
110 timings->mr = MICRON_V_MR_165;
112 timings->mcfg = MICRON_V_MCFG_200(256 << 20);
113 timings->ctrla = MICRON_V_ACTIMA_200;
114 timings->ctrlb = MICRON_V_ACTIMB_200;
115 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
119 #ifdef CONFIG_USB_MUSB_OMAP2PLUS
120 static struct musb_hdrc_config musb_config = {
127 static struct omap_musb_board_data musb_board_data = {
128 .interface_type = MUSB_INTERFACE_ULPI,
131 static struct musb_hdrc_platform_data musb_plat = {
132 #if defined(CONFIG_USB_MUSB_HOST)
134 #elif defined(CONFIG_USB_MUSB_GADGET)
135 .mode = MUSB_PERIPHERAL,
137 #error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
139 .config = &musb_config,
141 .platform_ops = &omap2430_ops,
142 .board_data = &musb_board_data,
146 #if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
147 /* Call usb_stop() before starting the kernel */
148 void show_boot_progress(int val)
150 if (val == BOOTSTAGE_ID_RUN_OS)
154 static struct omap_usbhs_board_data usbhs_bdata = {
155 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
156 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
157 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
160 int ehci_hcd_init(int index, enum usb_init_type init,
161 struct ehci_hccr **hccr, struct ehci_hcor **hcor)
163 return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
166 int ehci_hcd_stop(int index)
168 return omap_ehci_hcd_stop();
171 #endif /* CONFIG_USB_EHCI_HCD */
175 * Routine: misc_init_r
176 * Description: Configure board specific parts
178 int misc_init_r(void)
180 twl4030_power_init();
181 omap_die_id_display();
183 #ifdef CONFIG_USB_MUSB_OMAP2PLUS
184 musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
191 * BOARD_ID_GPIO - GPIO of pin with optional pulldown resistor on SOM LV
193 #define BOARD_ID_GPIO 189 /* hsusb0_data5 pin */
196 * Routine: board_init
197 * Description: Early hardware init.
201 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
203 /* boot param addr */
204 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
209 #ifdef CONFIG_BOARD_LATE_INIT
210 int board_late_init(void)
212 struct board_id *board;
216 * To identify between a SOM LV and Torpedo module,
217 * a pulldown resistor is on hsusb0_data5 for the SOM LV module.
218 * Drive the pin (and let it soak), then read it back.
219 * If the pin is still high its a Torpedo. If low its a SOM LV
222 /* Mux hsusb0_data5 as a GPIO */
223 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M4));
225 if (gpio_request(BOARD_ID_GPIO, "husb0_data5.gpio_189") == 0) {
228 * Drive BOARD_ID_GPIO - the pulldown resistor on the SOM LV
229 * will drain the voltage.
231 gpio_direction_output(BOARD_ID_GPIO, 0);
232 gpio_set_value(BOARD_ID_GPIO, 1);
234 /* Let it soak for a bit */
238 * Read state of BOARD_ID_GPIO as an input and if its set.
239 * If so the board is a Torpedo
241 gpio_direction_input(BOARD_ID_GPIO);
242 val = gpio_get_value(BOARD_ID_GPIO);
243 gpio_free(BOARD_ID_GPIO);
245 board = &boards[!!(get_cpu_family() == CPU_OMAP36XX)][!!val];
246 printf("Board: %s\n", board->name);
248 /* Set the machine_id passed to Linux */
249 if (board->machine_id)
250 gd->bd->bi_arch_number = board->machine_id;
252 /* If the user has not set fdtimage, set the default */
253 if (!env_get("fdtimage"))
254 env_set("fdtimage", board->fdtfile);
257 /* restore hsusb0_data5 pin as hsusb0_data5 */
258 MUX_VAL(CP(HSUSB0_DATA5), (IEN | PTD | DIS | M0));
263 #if defined(CONFIG_MMC)
264 int board_mmc_init(bd_t *bis)
266 return omap_mmc_init(0, 0, 0, -1, -1);
270 #if defined(CONFIG_MMC)
271 void board_mmc_power_init(void)
273 twl4030_power_mmc_init(0);
277 #ifdef CONFIG_SMC911X
278 /* GPMC CS1 settings for Logic SOM LV/Torpedo LAN92xx Ethernet chip */
279 static const u32 gpmc_lan92xx_config[] = {
280 NET_LAN92XX_GPMC_CONFIG1,
281 NET_LAN92XX_GPMC_CONFIG2,
282 NET_LAN92XX_GPMC_CONFIG3,
283 NET_LAN92XX_GPMC_CONFIG4,
284 NET_LAN92XX_GPMC_CONFIG5,
285 NET_LAN92XX_GPMC_CONFIG6,
288 int board_eth_init(bd_t *bis)
290 enable_gpmc_cs_config(gpmc_lan92xx_config, &gpmc_cfg->cs[1],
291 CONFIG_SMC911X_BASE, GPMC_SIZE_16M);
293 return smc911x_initialize(0, CONFIG_SMC911X_BASE);