Paul Kocialkowski | ae51b57 | 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 | e66782e | 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 | ae51b57 | 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" |
| 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
| 23 | const struct omap_sysinfo sysinfo = { |
| 24 | .board_string = "kc1" |
| 25 | }; |
| 26 | |
Paul Kocialkowski | e66782e | 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 | ae51b57 | 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 | 7c0a4b7 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 88 | char reboot_mode[2] = { 0 }; |
Paul Kocialkowski | bd55eed | 2016-02-27 19:19:10 +0100 | [diff] [blame^] | 89 | u32 value; |
Paul Kocialkowski | 7c0a4b7 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 90 | |
| 91 | /* Reboot mode */ |
| 92 | |
| 93 | omap_reboot_mode(reboot_mode, sizeof(reboot_mode)); |
| 94 | |
Paul Kocialkowski | bd55eed | 2016-02-27 19:19:10 +0100 | [diff] [blame^] | 95 | /* USB ID pin pull-up indicates factory (fastboot) cable detection. */ |
| 96 | gpio_request(KC1_GPIO_USB_ID, "USB_ID"); |
| 97 | gpio_direction_input(KC1_GPIO_USB_ID); |
| 98 | value = gpio_get_value(KC1_GPIO_USB_ID); |
| 99 | |
| 100 | if (value) |
| 101 | reboot_mode[0] = 'b'; |
| 102 | |
Paul Kocialkowski | 7c0a4b7 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 103 | if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) { |
| 104 | if (!getenv("reboot-mode")) |
| 105 | setenv("reboot-mode", (char *)reboot_mode); |
| 106 | |
| 107 | omap_reboot_mode_clear(); |
| 108 | } |
| 109 | |
Paul Kocialkowski | ae51b57 | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 110 | /* Serial number */ |
| 111 | |
| 112 | omap_die_id_serial(); |
| 113 | |
Paul Kocialkowski | e66782e | 2016-02-27 19:19:06 +0100 | [diff] [blame] | 114 | /* MUSB */ |
| 115 | |
| 116 | musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE); |
| 117 | |
Paul Kocialkowski | ae51b57 | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | u32 get_board_rev(void) |
| 122 | { |
| 123 | u32 value = 0; |
| 124 | |
| 125 | gpio_request(KC1_GPIO_MBID0, "MBID0"); |
| 126 | gpio_request(KC1_GPIO_MBID1, "MBID1"); |
| 127 | gpio_request(KC1_GPIO_MBID2, "MBID2"); |
| 128 | gpio_request(KC1_GPIO_MBID3, "MBID3"); |
| 129 | |
| 130 | gpio_direction_input(KC1_GPIO_MBID0); |
| 131 | gpio_direction_input(KC1_GPIO_MBID1); |
| 132 | gpio_direction_input(KC1_GPIO_MBID2); |
| 133 | gpio_direction_input(KC1_GPIO_MBID3); |
| 134 | |
| 135 | value |= (gpio_get_value(KC1_GPIO_MBID0) << 0); |
| 136 | value |= (gpio_get_value(KC1_GPIO_MBID1) << 1); |
| 137 | value |= (gpio_get_value(KC1_GPIO_MBID2) << 2); |
| 138 | value |= (gpio_get_value(KC1_GPIO_MBID3) << 3); |
| 139 | |
| 140 | return value; |
| 141 | } |
| 142 | |
| 143 | void get_board_serial(struct tag_serialnr *serialnr) |
| 144 | { |
| 145 | omap_die_id_get_board_serial(serialnr); |
| 146 | } |
| 147 | |
Paul Kocialkowski | 7c0a4b7 | 2016-02-27 19:19:09 +0100 | [diff] [blame] | 148 | int fb_set_reboot_flag(void) |
| 149 | { |
| 150 | return omap_reboot_mode_store("b"); |
| 151 | } |
| 152 | |
Paul Kocialkowski | ae51b57 | 2016-02-27 19:19:00 +0100 | [diff] [blame] | 153 | #ifndef CONFIG_SPL_BUILD |
| 154 | int board_mmc_init(bd_t *bis) |
| 155 | { |
| 156 | return omap_mmc_init(1, 0, 0, -1, -1); |
| 157 | } |
| 158 | #endif |
| 159 | |
| 160 | void board_mmc_power_init(void) |
| 161 | { |
| 162 | twl6030_power_mmc_init(1); |
| 163 | } |