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