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