1 // SPDX-License-Identifier: GPL-2.0+
3 * LG Optimus Black codename sniper board
5 * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
13 #include <linux/ctype.h>
14 #include <linux/usb/musb.h>
15 #include <asm/omap_musb.h>
16 #include <asm/arch/mmc_host_def.h>
17 #include <asm/arch/sys_proto.h>
18 #include <asm/arch/mem.h>
24 DECLARE_GLOBAL_DATA_PTR;
26 const omap3_sysinfo sysinfo = {
28 .board_string = "sniper",
32 static const struct ns16550_platdata serial_omap_platdata = {
33 .base = OMAP34XX_UART3,
35 .clock = V_NS16550_CLK,
36 .fcr = UART_FCR_DEFVAL,
39 U_BOOT_DEVICE(sniper_serial) = {
40 .name = "ns16550_serial",
41 .platdata = &serial_omap_platdata
44 static struct musb_hdrc_config musb_config = {
51 static struct omap_musb_board_data musb_board_data = {
52 .interface_type = MUSB_INTERFACE_ULPI,
55 static struct musb_hdrc_platform_data musb_platform_data = {
56 .mode = MUSB_PERIPHERAL,
57 .config = &musb_config,
59 .platform_ops = &omap2430_ops,
60 .board_data = &musb_board_data,
63 void set_muxconf_regs(void)
68 #ifdef CONFIG_SPL_BUILD
69 void get_board_mem_timings(struct board_sdrc_timings *timings)
71 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
72 timings->ctrla = HYNIX_V_ACTIMA_200;
73 timings->ctrlb = HYNIX_V_ACTIMB_200;
74 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
75 timings->mr = MICRON_V_MR_165;
85 gd->bd->bi_arch_number = 3000;
88 gd->bd->bi_boot_params = OMAP34XX_SDRC_CS0 + 0x100;
95 unsigned char keypad_matrix[64] = { 0 };
96 char reboot_mode[2] = { 0 };
97 unsigned char keys[3];
98 unsigned char data = 0;
101 /* Power button reset init */
103 twl4030_power_reset_init();
107 twl4030_keypad_scan((unsigned char *)&keypad_matrix);
109 keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
110 keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
111 keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
115 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
118 reboot_mode[0] = 'r';
120 reboot_mode[0] = 'b';
122 if (rc < 0 || reboot_mode[0] == 'o') {
124 * When not rebooting, valid power on reasons are either the
125 * power button, charger plug or USB plug.
128 data |= twl4030_input_power_button();
129 data |= twl4030_input_charger();
130 data |= twl4030_input_usb();
136 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
137 if (!env_get("reboot-mode"))
138 env_set("reboot-mode", (char *)reboot_mode);
141 omap_reboot_mode_clear();
145 omap_die_id_serial();
149 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
154 u32 get_board_rev(void)
156 /* Sold devices are expected to be at least revision F. */
160 void get_board_serial(struct tag_serialnr *serialnr)
162 omap_die_id_get_board_serial(serialnr);
165 void reset_misc(void)
167 char reboot_mode[2] = { 0 };
170 * Valid resets must contain the reboot mode magic, but we must not
171 * override it when set previously (e.g. reboot to bootloader).
174 omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
175 omap_reboot_mode_store(reboot_mode);
178 int fastboot_set_reboot_flag(void)
180 return omap_reboot_mode_store("b");
183 int board_mmc_init(bd_t *bis)
185 return omap_mmc_init(1, 0, 0, -1, -1);
188 void board_mmc_power_init(void)
190 twl4030_power_mmc_init(1);