1 /* 2 * LG Optimus Black codename sniper board 3 * 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> 12 #include <linux/ctype.h> 13 #include <linux/usb/musb.h> 14 #include <asm/omap_musb.h> 15 #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 23 DECLARE_GLOBAL_DATA_PTR; 24 25 const omap3_sysinfo sysinfo = { 26 .mtype = DDR_STACKED, 27 .board_string = "sniper", 28 .nand_string = "MMC" 29 }; 30 31 static const struct ns16550_platdata serial_omap_platdata = { 32 .base = OMAP34XX_UART3, 33 .reg_shift = 2, 34 .clock = V_NS16550_CLK 35 }; 36 37 U_BOOT_DEVICE(sniper_serial) = { 38 .name = "ns16550_serial", 39 .platdata = &serial_omap_platdata 40 }; 41 42 static struct musb_hdrc_config musb_config = { 43 .multipoint = 1, 44 .dyn_fifo = 1, 45 .num_eps = 16, 46 .ram_bits = 12 47 }; 48 49 static struct omap_musb_board_data musb_board_data = { 50 .interface_type = MUSB_INTERFACE_ULPI, 51 }; 52 53 static 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 61 void set_muxconf_regs(void) 62 { 63 MUX_SNIPER(); 64 } 65 66 #ifdef CONFIG_SPL_BUILD 67 void 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 77 int 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 91 int misc_init_r(void) 92 { 93 unsigned char keypad_matrix[64] = { 0 }; 94 char reboot_mode[2] = { 0 }; 95 unsigned char keys[3]; 96 unsigned char data = 0; 97 int rc; 98 99 /* Power button reset init */ 100 101 twl4030_power_reset_init(); 102 103 /* 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 111 /* Reboot mode */ 112 113 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode)); 114 115 if (keys[0]) 116 reboot_mode[0] = 'r'; 117 else if (keys[1]) 118 reboot_mode[0] = 'b'; 119 120 if (rc < 0 || reboot_mode[0] == 'o') { 121 /* 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(); 132 } 133 134 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) { 135 if (!getenv("reboot-mode")) 136 setenv("reboot-mode", (char *)reboot_mode); 137 } 138 139 omap_reboot_mode_clear(); 140 141 /* Serial number */ 142 143 omap_die_id_serial(); 144 145 /* MUSB */ 146 147 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE); 148 149 return 0; 150 } 151 152 u32 get_board_rev(void) 153 { 154 /* Sold devices are expected to be at least revision F. */ 155 return 6; 156 } 157 158 void get_board_serial(struct tag_serialnr *serialnr) 159 { 160 omap_die_id_get_board_serial(serialnr); 161 } 162 163 void 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 176 int fb_set_reboot_flag(void) 177 { 178 return omap_reboot_mode_store("b"); 179 } 180 181 #ifndef CONFIG_SPL_BUILD 182 int board_mmc_init(bd_t *bis) 183 { 184 return omap_mmc_init(1, 0, 0, -1, -1); 185 } 186 #endif 187 188 void board_mmc_power_init(void) 189 { 190 twl4030_power_mmc_init(1); 191 } 192