Paul Kocialkowski | 3dee000 | 2015-07-20 15:17:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * LG Optimus Black (P970) 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> |
Paul Kocialkowski | 248b791 | 2015-07-20 15:17:12 +0200 | [diff] [blame] | 12 | #include <linux/ctype.h> |
Paul Kocialkowski | 46f9910 | 2015-07-20 15:17:15 +0200 | [diff] [blame] | 13 | #include <linux/usb/musb.h> |
| 14 | #include <asm/omap_musb.h> |
Paul Kocialkowski | 3dee000 | 2015-07-20 15:17:11 +0200 | [diff] [blame] | 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 = "serial_omap", |
| 39 | .platdata = &serial_omap_platdata |
| 40 | }; |
| 41 | |
Paul Kocialkowski | 46f9910 | 2015-07-20 15:17:15 +0200 | [diff] [blame] | 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 | |
Paul Kocialkowski | 3dee000 | 2015-07-20 15:17:11 +0200 | [diff] [blame] | 61 | #ifdef CONFIG_SPL_BUILD |
| 62 | void get_board_mem_timings(struct board_sdrc_timings *timings) |
| 63 | { |
| 64 | timings->mcfg = HYNIX_V_MCFG_200(256 << 20); |
| 65 | timings->ctrla = HYNIX_V_ACTIMA_200; |
| 66 | timings->ctrlb = HYNIX_V_ACTIMB_200; |
| 67 | timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; |
| 68 | timings->mr = MICRON_V_MR_165; |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | u32 get_board_rev(void) |
| 73 | { |
| 74 | /* Sold devices are expected to be at least revision F. */ |
| 75 | return 6; |
| 76 | } |
| 77 | |
| 78 | int board_init(void) |
| 79 | { |
| 80 | /* GPMC init */ |
| 81 | gpmc_init(); |
| 82 | |
| 83 | /* MACH number */ |
| 84 | gd->bd->bi_arch_number = 3000; |
| 85 | |
| 86 | /* ATAGs location */ |
| 87 | gd->bd->bi_boot_params = OMAP34XX_SDRC_CS0 + 0x100; |
| 88 | |
| 89 | return 0; |
| 90 | } |
| 91 | |
Paul Kocialkowski | 248b791 | 2015-07-20 15:17:12 +0200 | [diff] [blame] | 92 | int misc_init_r(void) |
| 93 | { |
Paul Kocialkowski | e382044 | 2015-07-20 15:17:13 +0200 | [diff] [blame] | 94 | char serial_string[17] = { 0 }; |
Paul Kocialkowski | 248b791 | 2015-07-20 15:17:12 +0200 | [diff] [blame] | 95 | char reboot_mode[2] = { 0 }; |
Paul Kocialkowski | e382044 | 2015-07-20 15:17:13 +0200 | [diff] [blame] | 96 | u32 dieid[4] = { 0 }; |
Paul Kocialkowski | 248b791 | 2015-07-20 15:17:12 +0200 | [diff] [blame] | 97 | |
Paul Kocialkowski | e3ff29e | 2015-07-20 15:17:16 +0200 | [diff] [blame^] | 98 | /* Power button reset init */ |
| 99 | |
| 100 | twl4030_power_reset_init(); |
| 101 | |
Paul Kocialkowski | 248b791 | 2015-07-20 15:17:12 +0200 | [diff] [blame] | 102 | /* Reboot mode */ |
| 103 | |
| 104 | reboot_mode[0] = omap_reboot_mode(); |
| 105 | if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) { |
| 106 | if (!getenv("reboot-mode")) |
| 107 | setenv("reboot-mode", (char *)reboot_mode); |
| 108 | |
| 109 | omap_reboot_mode_clear(); |
| 110 | } |
| 111 | |
Paul Kocialkowski | e382044 | 2015-07-20 15:17:13 +0200 | [diff] [blame] | 112 | /* Serial number */ |
| 113 | |
| 114 | get_dieid((u32 *)&dieid); |
| 115 | |
| 116 | if (!getenv("serial#")) { |
| 117 | snprintf(serial_string, sizeof(serial_string), |
| 118 | "%08x%08x", dieid[0], dieid[3]); |
| 119 | |
| 120 | setenv("serial#", serial_string); |
| 121 | } |
| 122 | |
Paul Kocialkowski | 46f9910 | 2015-07-20 15:17:15 +0200 | [diff] [blame] | 123 | /* MUSB */ |
| 124 | |
| 125 | musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE); |
| 126 | |
Paul Kocialkowski | 248b791 | 2015-07-20 15:17:12 +0200 | [diff] [blame] | 127 | return 0; |
| 128 | } |
| 129 | |
Paul Kocialkowski | c29a72f | 2015-07-20 15:17:14 +0200 | [diff] [blame] | 130 | void get_board_serial(struct tag_serialnr *serialnr) |
| 131 | { |
| 132 | char *serial_string; |
| 133 | unsigned long long serial; |
| 134 | |
| 135 | serial_string = getenv("serial#"); |
| 136 | |
| 137 | if (serial_string) { |
| 138 | serial = simple_strtoull(serial_string, NULL, 16); |
| 139 | |
| 140 | serialnr->high = (unsigned int) (serial >> 32); |
| 141 | serialnr->low = (unsigned int) (serial & 0xffffffff); |
| 142 | } else { |
| 143 | serialnr->high = 0; |
| 144 | serialnr->low = 0; |
| 145 | } |
| 146 | } |
| 147 | |
Paul Kocialkowski | 46f9910 | 2015-07-20 15:17:15 +0200 | [diff] [blame] | 148 | int fb_set_reboot_flag(void) |
| 149 | { |
| 150 | return omap_reboot_mode_store('b'); |
| 151 | } |
| 152 | |
Paul Kocialkowski | 3dee000 | 2015-07-20 15:17:11 +0200 | [diff] [blame] | 153 | void set_muxconf_regs(void) |
| 154 | { |
| 155 | MUX_SNIPER(); |
| 156 | } |
| 157 | |
| 158 | #ifndef CONFIG_SPL_BUILD |
| 159 | int board_mmc_init(bd_t *bis) |
| 160 | { |
| 161 | return omap_mmc_init(1, 0, 0, -1, -1); |
| 162 | } |
| 163 | #endif |
| 164 | |
| 165 | void board_mmc_power_init(void) |
| 166 | { |
| 167 | twl4030_power_mmc_init(1); |
| 168 | } |