1
2
3
4
5
6
7
8#include <config.h>
9#include <common.h>
10#include <dm.h>
11#include <env.h>
12#include <fastboot.h>
13#include <init.h>
14#include <asm/global_data.h>
15#include <linux/ctype.h>
16#include <linux/usb/musb.h>
17#include <asm/omap_musb.h>
18#include <asm/arch/mmc_host_def.h>
19#include <asm/arch/sys_proto.h>
20#include <asm/arch/mem.h>
21#include <asm/io.h>
22#include <ns16550.h>
23#include <twl4030.h>
24#include "sniper.h"
25
26DECLARE_GLOBAL_DATA_PTR;
27
28const omap3_sysinfo sysinfo = {
29 .mtype = DDR_STACKED,
30 .board_string = "sniper",
31 .nand_string = "MMC"
32};
33
34static const struct ns16550_plat serial_omap_plat = {
35 .base = OMAP34XX_UART3,
36 .reg_shift = 2,
37 .clock = V_NS16550_CLK,
38 .fcr = UART_FCR_DEFVAL,
39};
40
41U_BOOT_DRVINFO(sniper_serial) = {
42 .name = "ns16550_serial",
43 .plat = &serial_omap_plat
44};
45
46#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET)
47static struct musb_hdrc_config musb_config = {
48 .multipoint = 1,
49 .dyn_fifo = 1,
50 .num_eps = 16,
51 .ram_bits = 12
52};
53
54static struct omap_musb_board_data musb_board_data = {
55 .interface_type = MUSB_INTERFACE_ULPI,
56};
57
58static struct musb_hdrc_platform_data musb_platform_data = {
59 .mode = MUSB_PERIPHERAL,
60 .config = &musb_config,
61 .power = 100,
62 .platform_ops = &omap2430_ops,
63 .board_data = &musb_board_data,
64};
65#endif
66
67void set_muxconf_regs(void)
68{
69 MUX_SNIPER();
70}
71
72#ifdef CONFIG_SPL_BUILD
73void get_board_mem_timings(struct board_sdrc_timings *timings)
74{
75 timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
76 timings->ctrla = HYNIX_V_ACTIMA_200;
77 timings->ctrlb = HYNIX_V_ACTIMB_200;
78 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
79 timings->mr = MICRON_V_MR_165;
80}
81#endif
82
83int board_init(void)
84{
85
86 gpmc_init();
87
88
89 gd->bd->bi_arch_number = 3000;
90
91
92 gd->bd->bi_boot_params = OMAP34XX_SDRC_CS0 + 0x100;
93
94 return 0;
95}
96
97int misc_init_r(void)
98{
99 unsigned char keypad_matrix[64] = { 0 };
100 char reboot_mode[2] = { 0 };
101 unsigned char keys[3];
102 unsigned char data = 0;
103 int rc;
104
105
106
107 twl4030_power_reset_init();
108
109
110
111 twl4030_keypad_scan((unsigned char *)&keypad_matrix);
112
113 keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
114 keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
115 keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
116
117
118
119 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
120
121 if (keys[0])
122 reboot_mode[0] = 'r';
123 else if (keys[1])
124 reboot_mode[0] = 'b';
125
126 if (rc < 0 || reboot_mode[0] == 'o') {
127
128
129
130
131
132 data |= twl4030_input_power_button();
133 data |= twl4030_input_charger();
134 data |= twl4030_input_usb();
135
136 if (!data)
137 twl4030_power_off();
138 }
139
140 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
141 if (!env_get("reboot-mode"))
142 env_set("reboot-mode", (char *)reboot_mode);
143 }
144
145 omap_reboot_mode_clear();
146
147
148
149 omap_die_id_serial();
150
151
152#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET)
153 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
154#endif
155
156 return 0;
157}
158
159#ifdef CONFIG_REVISION_TAG
160u32 get_board_rev(void)
161{
162
163 return 6;
164}
165#endif
166
167void get_board_serial(struct tag_serialnr *serialnr)
168{
169 omap_die_id_get_board_serial(serialnr);
170}
171
172void reset_misc(void)
173{
174 char reboot_mode[2] = { 0 };
175
176
177
178
179
180
181 omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
182 omap_reboot_mode_store(reboot_mode);
183}
184
185int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
186{
187 if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
188 return -ENOTSUPP;
189
190 return omap_reboot_mode_store("b");
191}
192
193int board_mmc_init(struct bd_info *bis)
194{
195 return omap_mmc_init(1, 0, 0, -1, -1);
196}
197
198void board_mmc_power_init(void)
199{
200 twl4030_power_mmc_init(1);
201}
202