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