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