blob: a7de4c21674c4eaa114aa5d096ac418df55d6879 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Paul Kocialkowski02579302015-07-20 15:17:11 +02002/*
Paul Kocialkowski39af3d82016-02-07 16:50:50 +01003 * LG Optimus Black codename sniper board
Paul Kocialkowski02579302015-07-20 15:17:11 +02004 *
5 * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
Paul Kocialkowski02579302015-07-20 15:17:11 +02006 */
7
8#include <config.h>
9#include <common.h>
10#include <dm.h>
Paul Kocialkowski957efd42015-07-20 15:17:12 +020011#include <linux/ctype.h>
Paul Kocialkowskifbdd3292015-07-20 15:17:15 +020012#include <linux/usb/musb.h>
13#include <asm/omap_musb.h>
Paul Kocialkowski02579302015-07-20 15:17:11 +020014#include <asm/arch/mmc_host_def.h>
15#include <asm/arch/sys_proto.h>
16#include <asm/arch/mem.h>
17#include <asm/io.h>
18#include <ns16550.h>
19#include <twl4030.h>
20#include "sniper.h"
21
22DECLARE_GLOBAL_DATA_PTR;
23
24const omap3_sysinfo sysinfo = {
25 .mtype = DDR_STACKED,
Paul Kocialkowski23a004a2016-02-26 13:18:47 +010026 .board_string = "sniper",
Paul Kocialkowski02579302015-07-20 15:17:11 +020027 .nand_string = "MMC"
28};
29
30static const struct ns16550_platdata serial_omap_platdata = {
31 .base = OMAP34XX_UART3,
32 .reg_shift = 2,
Heiko Schocher17fa0322017-01-18 08:05:49 +010033 .clock = V_NS16550_CLK,
34 .fcr = UART_FCR_DEFVAL,
Paul Kocialkowski02579302015-07-20 15:17:11 +020035};
36
37U_BOOT_DEVICE(sniper_serial) = {
Thomas Chouc7b96862015-11-19 21:48:12 +080038 .name = "ns16550_serial",
Paul Kocialkowski02579302015-07-20 15:17:11 +020039 .platdata = &serial_omap_platdata
40};
41
Paul Kocialkowskifbdd3292015-07-20 15:17:15 +020042static struct musb_hdrc_config musb_config = {
43 .multipoint = 1,
44 .dyn_fifo = 1,
45 .num_eps = 16,
46 .ram_bits = 12
47};
48
49static struct omap_musb_board_data musb_board_data = {
50 .interface_type = MUSB_INTERFACE_ULPI,
51};
52
53static struct musb_hdrc_platform_data musb_platform_data = {
54 .mode = MUSB_PERIPHERAL,
55 .config = &musb_config,
56 .power = 100,
57 .platform_ops = &omap2430_ops,
58 .board_data = &musb_board_data,
59};
60
Paul Kocialkowski23a004a2016-02-26 13:18:47 +010061void set_muxconf_regs(void)
62{
63 MUX_SNIPER();
64}
65
Paul Kocialkowski02579302015-07-20 15:17:11 +020066#ifdef CONFIG_SPL_BUILD
67void get_board_mem_timings(struct board_sdrc_timings *timings)
68{
69 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
70 timings->ctrla = HYNIX_V_ACTIMA_200;
71 timings->ctrlb = HYNIX_V_ACTIMB_200;
72 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
73 timings->mr = MICRON_V_MR_165;
74}
75#endif
76
Paul Kocialkowski02579302015-07-20 15:17:11 +020077int board_init(void)
78{
79 /* GPMC init */
80 gpmc_init();
81
82 /* MACH number */
83 gd->bd->bi_arch_number = 3000;
84
85 /* ATAGs location */
86 gd->bd->bi_boot_params = OMAP34XX_SDRC_CS0 + 0x100;
87
88 return 0;
89}
90
Paul Kocialkowski957efd42015-07-20 15:17:12 +020091int misc_init_r(void)
92{
Paul Kocialkowski5c2cff82015-07-20 15:17:18 +020093 unsigned char keypad_matrix[64] = { 0 };
Paul Kocialkowski957efd42015-07-20 15:17:12 +020094 char reboot_mode[2] = { 0 };
Paul Kocialkowski5c2cff82015-07-20 15:17:18 +020095 unsigned char keys[3];
Paul Kocialkowski0e14f882015-07-20 15:17:17 +020096 unsigned char data = 0;
Paul Kocialkowskic15ab5b2016-03-29 14:16:25 +020097 int rc;
Paul Kocialkowski957efd42015-07-20 15:17:12 +020098
Paul Kocialkowski69f25412015-07-20 15:17:16 +020099 /* Power button reset init */
100
101 twl4030_power_reset_init();
102
Paul Kocialkowski5c2cff82015-07-20 15:17:18 +0200103 /* Keypad */
104
105 twl4030_keypad_scan((unsigned char *)&keypad_matrix);
106
107 keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
108 keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
109 keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
110
Paul Kocialkowski957efd42015-07-20 15:17:12 +0200111 /* Reboot mode */
112
Paul Kocialkowskic15ab5b2016-03-29 14:16:25 +0200113 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
Paul Kocialkowski5c2cff82015-07-20 15:17:18 +0200114
115 if (keys[0])
116 reboot_mode[0] = 'r';
117 else if (keys[1])
118 reboot_mode[0] = 'b';
119
Paul Kocialkowskic15ab5b2016-03-29 14:16:25 +0200120 if (rc < 0 || reboot_mode[0] == 'o') {
Paul Kocialkowski0e14f882015-07-20 15:17:17 +0200121 /*
122 * When not rebooting, valid power on reasons are either the
123 * power button, charger plug or USB plug.
124 */
125
126 data |= twl4030_input_power_button();
127 data |= twl4030_input_charger();
128 data |= twl4030_input_usb();
129
130 if (!data)
131 twl4030_power_off();
Paul Kocialkowski957efd42015-07-20 15:17:12 +0200132 }
133
Paul Kocialkowskic15ab5b2016-03-29 14:16:25 +0200134 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
Simon Glass00caae62017-08-03 12:22:12 -0600135 if (!env_get("reboot-mode"))
Simon Glass382bee52017-08-03 12:22:09 -0600136 env_set("reboot-mode", (char *)reboot_mode);
Paul Kocialkowskic15ab5b2016-03-29 14:16:25 +0200137 }
138
139 omap_reboot_mode_clear();
140
Paul Kocialkowski169ecb42015-07-20 15:17:13 +0200141 /* Serial number */
142
Paul Kocialkowski07815eb2015-08-27 19:37:12 +0200143 omap_die_id_serial();
Paul Kocialkowski169ecb42015-07-20 15:17:13 +0200144
Paul Kocialkowskifbdd3292015-07-20 15:17:15 +0200145 /* MUSB */
146
147 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
148
Paul Kocialkowski957efd42015-07-20 15:17:12 +0200149 return 0;
150}
151
Paul Kocialkowski23a004a2016-02-26 13:18:47 +0100152u32 get_board_rev(void)
153{
154 /* Sold devices are expected to be at least revision F. */
155 return 6;
156}
157
Paul Kocialkowski9f4e1e92015-07-20 15:17:14 +0200158void get_board_serial(struct tag_serialnr *serialnr)
159{
Paul Kocialkowski2da87ab2015-08-27 19:37:14 +0200160 omap_die_id_get_board_serial(serialnr);
Paul Kocialkowski9f4e1e92015-07-20 15:17:14 +0200161}
162
Paul Kocialkowskic15ab5b2016-03-29 14:16:25 +0200163void reset_misc(void)
164{
165 char reboot_mode[2] = { 0 };
166
167 /*
168 * Valid resets must contain the reboot mode magic, but we must not
169 * override it when set previously (e.g. reboot to bootloader).
170 */
171
172 omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
173 omap_reboot_mode_store(reboot_mode);
174}
175
Alex Kiernan8a65bd62018-05-29 15:30:46 +0000176int fastboot_set_reboot_flag(void)
Paul Kocialkowskifbdd3292015-07-20 15:17:15 +0200177{
Paul Kocialkowskic5412b02016-02-27 19:26:41 +0100178 return omap_reboot_mode_store("b");
Paul Kocialkowskifbdd3292015-07-20 15:17:15 +0200179}
180
Paul Kocialkowski02579302015-07-20 15:17:11 +0200181int board_mmc_init(bd_t *bis)
182{
183 return omap_mmc_init(1, 0, 0, -1, -1);
184}
Paul Kocialkowski02579302015-07-20 15:17:11 +0200185
186void board_mmc_power_init(void)
187{
188 twl4030_power_mmc_init(1);
189}