blob: f093f97e2bc299545be82ef7bf318d9410c7693c [file] [log] [blame]
Paul Kocialkowski3dee0002015-07-20 15:17:11 +02001/*
Paul Kocialkowski4db92762016-02-07 16:50:50 +01002 * LG Optimus Black codename sniper board
Paul Kocialkowski3dee0002015-07-20 15:17:11 +02003 *
4 * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <config.h>
10#include <common.h>
11#include <dm.h>
Paul Kocialkowski248b7912015-07-20 15:17:12 +020012#include <linux/ctype.h>
Paul Kocialkowski46f99102015-07-20 15:17:15 +020013#include <linux/usb/musb.h>
14#include <asm/omap_musb.h>
Paul Kocialkowski3dee0002015-07-20 15:17:11 +020015#include <asm/arch/mmc_host_def.h>
16#include <asm/arch/sys_proto.h>
17#include <asm/arch/mem.h>
18#include <asm/io.h>
19#include <ns16550.h>
20#include <twl4030.h>
21#include "sniper.h"
22
23DECLARE_GLOBAL_DATA_PTR;
24
25const omap3_sysinfo sysinfo = {
26 .mtype = DDR_STACKED,
Paul Kocialkowskid90f8832016-02-26 13:18:47 +010027 .board_string = "sniper",
Paul Kocialkowski3dee0002015-07-20 15:17:11 +020028 .nand_string = "MMC"
29};
30
31static const struct ns16550_platdata serial_omap_platdata = {
32 .base = OMAP34XX_UART3,
33 .reg_shift = 2,
34 .clock = V_NS16550_CLK
35};
36
37U_BOOT_DEVICE(sniper_serial) = {
Thomas Chou52ac4432015-11-19 21:48:12 +080038 .name = "ns16550_serial",
Paul Kocialkowski3dee0002015-07-20 15:17:11 +020039 .platdata = &serial_omap_platdata
40};
41
Paul Kocialkowski46f99102015-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 Kocialkowskid90f8832016-02-26 13:18:47 +010061void set_muxconf_regs(void)
62{
63 MUX_SNIPER();
64}
65
Paul Kocialkowski3dee0002015-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 Kocialkowski3dee0002015-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 Kocialkowski248b7912015-07-20 15:17:12 +020091int misc_init_r(void)
92{
Paul Kocialkowski76844b92015-07-20 15:17:18 +020093 unsigned char keypad_matrix[64] = { 0 };
Paul Kocialkowski248b7912015-07-20 15:17:12 +020094 char reboot_mode[2] = { 0 };
Paul Kocialkowski76844b92015-07-20 15:17:18 +020095 unsigned char keys[3];
Paul Kocialkowski361b98b2015-07-20 15:17:17 +020096 unsigned char data = 0;
Paul Kocialkowski248b7912015-07-20 15:17:12 +020097
Paul Kocialkowskie3ff29e2015-07-20 15:17:16 +020098 /* Power button reset init */
99
100 twl4030_power_reset_init();
101
Paul Kocialkowski76844b92015-07-20 15:17:18 +0200102 /* Keypad */
103
104 twl4030_keypad_scan((unsigned char *)&keypad_matrix);
105
106 keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
107 keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
108 keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
109
Paul Kocialkowski248b7912015-07-20 15:17:12 +0200110 /* Reboot mode */
111
112 reboot_mode[0] = omap_reboot_mode();
Paul Kocialkowski76844b92015-07-20 15:17:18 +0200113
114 if (keys[0])
115 reboot_mode[0] = 'r';
116 else if (keys[1])
117 reboot_mode[0] = 'b';
118
Paul Kocialkowski248b7912015-07-20 15:17:12 +0200119 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
120 if (!getenv("reboot-mode"))
121 setenv("reboot-mode", (char *)reboot_mode);
122
123 omap_reboot_mode_clear();
Paul Kocialkowski361b98b2015-07-20 15:17:17 +0200124 } else {
125 /*
126 * When not rebooting, valid power on reasons are either the
127 * power button, charger plug or USB plug.
128 */
129
130 data |= twl4030_input_power_button();
131 data |= twl4030_input_charger();
132 data |= twl4030_input_usb();
133
134 if (!data)
135 twl4030_power_off();
Paul Kocialkowski248b7912015-07-20 15:17:12 +0200136 }
137
Paul Kocialkowskie3820442015-07-20 15:17:13 +0200138 /* Serial number */
139
Paul Kocialkowski2edadee2015-08-27 19:37:12 +0200140 omap_die_id_serial();
Paul Kocialkowskie3820442015-07-20 15:17:13 +0200141
Paul Kocialkowski46f99102015-07-20 15:17:15 +0200142 /* MUSB */
143
144 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
145
Paul Kocialkowski248b7912015-07-20 15:17:12 +0200146 return 0;
147}
148
Paul Kocialkowskid90f8832016-02-26 13:18:47 +0100149u32 get_board_rev(void)
150{
151 /* Sold devices are expected to be at least revision F. */
152 return 6;
153}
154
Paul Kocialkowskic29a72f2015-07-20 15:17:14 +0200155void get_board_serial(struct tag_serialnr *serialnr)
156{
Paul Kocialkowskia7267d22015-08-27 19:37:14 +0200157 omap_die_id_get_board_serial(serialnr);
Paul Kocialkowskic29a72f2015-07-20 15:17:14 +0200158}
159
Paul Kocialkowski361b98b2015-07-20 15:17:17 +0200160void reset_misc(void)
161{
162 omap_reboot_mode_store('u');
163}
164
Paul Kocialkowski46f99102015-07-20 15:17:15 +0200165int fb_set_reboot_flag(void)
166{
167 return omap_reboot_mode_store('b');
168}
169
Paul Kocialkowski3dee0002015-07-20 15:17:11 +0200170#ifndef CONFIG_SPL_BUILD
171int board_mmc_init(bd_t *bis)
172{
173 return omap_mmc_init(1, 0, 0, -1, -1);
174}
175#endif
176
177void board_mmc_power_init(void)
178{
179 twl4030_power_mmc_init(1);
180}