Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Amazon Kindle Fire (first generation) codename kc1 config |
| 4 | * |
| 5 | * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr> |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <config.h> |
| 9 | #include <common.h> |
Paul Kocialkowski | 75089e5 | 2016-02-27 19:19:06 +0100 | [diff] [blame] | 10 | #include <linux/ctype.h> |
| 11 | #include <linux/usb/musb.h> |
| 12 | #include <asm/omap_musb.h> |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
| 14 | #include <asm/arch/mmc_host_def.h> |
| 15 | #include <asm/gpio.h> |
| 16 | #include <asm/emif.h> |
| 17 | #include <twl6030.h> |
| 18 | #include "kc1.h" |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
| 23 | const struct omap_sysinfo sysinfo = { |
| 24 | .board_string = "kc1" |
| 25 | }; |
| 26 | |
Paul Kocialkowski | 75089e5 | 2016-02-27 19:19:06 +0100 | [diff] [blame] | 27 | static struct musb_hdrc_config musb_config = { |
| 28 | .multipoint = 1, |
| 29 | .dyn_fifo = 1, |
| 30 | .num_eps = 16, |
| 31 | .ram_bits = 12 |
| 32 | }; |
| 33 | |
| 34 | static struct omap_musb_board_data musb_board_data = { |
| 35 | .interface_type = MUSB_INTERFACE_UTMI, |
| 36 | }; |
| 37 | |
| 38 | static struct musb_hdrc_platform_data musb_platform_data = { |
| 39 | .mode = MUSB_PERIPHERAL, |
| 40 | .config = &musb_config, |
| 41 | .power = 100, |
| 42 | .platform_ops = &omap2430_ops, |
| 43 | .board_data = &musb_board_data, |
| 44 | }; |
| 45 | |
| 46 | |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 47 | void set_muxconf_regs(void) |
| 48 | { |
| 49 | do_set_mux((*ctrl)->control_padconf_core_base, core_padconf_array, |
| 50 | sizeof(core_padconf_array) / sizeof(struct pad_conf_entry)); |
| 51 | } |
| 52 | |
| 53 | struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, |
| 54 | struct lpddr2_device_details *lpddr2_dev_details) |
| 55 | { |
| 56 | if (cs == CS1) |
| 57 | return NULL; |
| 58 | |
| 59 | *lpddr2_dev_details = elpida_2G_S4_details; |
| 60 | |
| 61 | return lpddr2_dev_details; |
| 62 | } |
| 63 | |
| 64 | void emif_get_device_timings(u32 emif_nr, |
| 65 | const struct lpddr2_device_timings **cs0_device_timings, |
| 66 | const struct lpddr2_device_timings **cs1_device_timings) |
| 67 | { |
| 68 | *cs0_device_timings = &elpida_2G_S4_timings; |
| 69 | *cs1_device_timings = NULL; |
| 70 | } |
| 71 | |
| 72 | int board_init(void) |
| 73 | { |
| 74 | /* GPMC init */ |
| 75 | gpmc_init(); |
| 76 | |
| 77 | /* MACH number */ |
| 78 | gd->bd->bi_arch_number = MACH_TYPE_OMAP_4430SDP; |
| 79 | |
| 80 | /* ATAGs location */ |
| 81 | gd->bd->bi_boot_params = OMAP44XX_DRAM_ADDR_SPACE_START + 0x100; |
| 82 | |
| 83 | return 0; |
| 84 | } |
| 85 | |
| 86 | int misc_init_r(void) |
| 87 | { |
Paul Kocialkowski | fc45392 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 88 | char reboot_mode[2] = { 0 }; |
Paul Kocialkowski | 31d8ef8 | 2016-02-27 19:19:14 +0100 | [diff] [blame] | 89 | u32 data = 0; |
Paul Kocialkowski | bdcbdcf | 2016-02-27 19:19:10 +0100 | [diff] [blame] | 90 | u32 value; |
Paul Kocialkowski | 050f933 | 2016-03-29 14:16:26 +0200 | [diff] [blame] | 91 | int rc; |
Paul Kocialkowski | fc45392 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 92 | |
| 93 | /* Reboot mode */ |
| 94 | |
Paul Kocialkowski | 050f933 | 2016-03-29 14:16:26 +0200 | [diff] [blame] | 95 | rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode)); |
Paul Kocialkowski | fc45392 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 96 | |
Paul Kocialkowski | bdcbdcf | 2016-02-27 19:19:10 +0100 | [diff] [blame] | 97 | /* USB ID pin pull-up indicates factory (fastboot) cable detection. */ |
| 98 | gpio_request(KC1_GPIO_USB_ID, "USB_ID"); |
| 99 | gpio_direction_input(KC1_GPIO_USB_ID); |
| 100 | value = gpio_get_value(KC1_GPIO_USB_ID); |
| 101 | |
| 102 | if (value) |
| 103 | reboot_mode[0] = 'b'; |
| 104 | |
Paul Kocialkowski | 050f933 | 2016-03-29 14:16:26 +0200 | [diff] [blame] | 105 | if (rc < 0 || reboot_mode[0] == 'o') { |
Paul Kocialkowski | 31d8ef8 | 2016-02-27 19:19:14 +0100 | [diff] [blame] | 106 | /* |
| 107 | * When not rebooting, valid power on reasons are either the |
| 108 | * power button, charger plug or USB plug. |
| 109 | */ |
| 110 | |
| 111 | data |= twl6030_input_power_button(); |
| 112 | data |= twl6030_input_charger(); |
| 113 | data |= twl6030_input_usb(); |
| 114 | |
| 115 | if (!data) |
| 116 | twl6030_power_off(); |
Paul Kocialkowski | fc45392 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 117 | } |
| 118 | |
Paul Kocialkowski | 050f933 | 2016-03-29 14:16:26 +0200 | [diff] [blame] | 119 | if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 120 | if (!env_get("reboot-mode")) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 121 | env_set("reboot-mode", (char *)reboot_mode); |
Paul Kocialkowski | 050f933 | 2016-03-29 14:16:26 +0200 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | omap_reboot_mode_clear(); |
| 125 | |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 126 | /* Serial number */ |
| 127 | |
| 128 | omap_die_id_serial(); |
| 129 | |
Paul Kocialkowski | 75089e5 | 2016-02-27 19:19:06 +0100 | [diff] [blame] | 130 | /* MUSB */ |
| 131 | |
| 132 | musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE); |
| 133 | |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | u32 get_board_rev(void) |
| 138 | { |
| 139 | u32 value = 0; |
| 140 | |
| 141 | gpio_request(KC1_GPIO_MBID0, "MBID0"); |
| 142 | gpio_request(KC1_GPIO_MBID1, "MBID1"); |
| 143 | gpio_request(KC1_GPIO_MBID2, "MBID2"); |
| 144 | gpio_request(KC1_GPIO_MBID3, "MBID3"); |
| 145 | |
| 146 | gpio_direction_input(KC1_GPIO_MBID0); |
| 147 | gpio_direction_input(KC1_GPIO_MBID1); |
| 148 | gpio_direction_input(KC1_GPIO_MBID2); |
| 149 | gpio_direction_input(KC1_GPIO_MBID3); |
| 150 | |
| 151 | value |= (gpio_get_value(KC1_GPIO_MBID0) << 0); |
| 152 | value |= (gpio_get_value(KC1_GPIO_MBID1) << 1); |
| 153 | value |= (gpio_get_value(KC1_GPIO_MBID2) << 2); |
| 154 | value |= (gpio_get_value(KC1_GPIO_MBID3) << 3); |
| 155 | |
| 156 | return value; |
| 157 | } |
| 158 | |
| 159 | void get_board_serial(struct tag_serialnr *serialnr) |
| 160 | { |
| 161 | omap_die_id_get_board_serial(serialnr); |
| 162 | } |
| 163 | |
Alex Kiernan | 5512c43 | 2018-05-29 15:30:46 +0000 | [diff] [blame] | 164 | int fastboot_set_reboot_flag(void) |
Paul Kocialkowski | fc45392 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 165 | { |
| 166 | return omap_reboot_mode_store("b"); |
| 167 | } |
| 168 | |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 169 | int board_mmc_init(bd_t *bis) |
| 170 | { |
| 171 | return omap_mmc_init(1, 0, 0, -1, -1); |
| 172 | } |
Paul Kocialkowski | 3e3b8bc | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 173 | |
| 174 | void board_mmc_power_init(void) |
| 175 | { |
| 176 | twl6030_power_mmc_init(1); |
| 177 | } |