blob: eead98b24eb39aabf732f096fba3a44987007292 [file] [log] [blame]
Paul Kocialkowskiae51b572016-02-27 19:19:00 +01001/*
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 Kocialkowskie66782e2016-02-27 19:19:06 +010011#include <linux/ctype.h>
12#include <linux/usb/musb.h>
13#include <asm/omap_musb.h>
Paul Kocialkowskiae51b572016-02-27 19:19:00 +010014#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 Glassc62db352017-05-31 19:47:48 -060020#include <asm/mach-types.h>
Paul Kocialkowskiae51b572016-02-27 19:19:00 +010021
22DECLARE_GLOBAL_DATA_PTR;
23
24const struct omap_sysinfo sysinfo = {
25 .board_string = "kc1"
26};
27
Paul Kocialkowskie66782e2016-02-27 19:19:06 +010028static struct musb_hdrc_config musb_config = {
29 .multipoint = 1,
30 .dyn_fifo = 1,
31 .num_eps = 16,
32 .ram_bits = 12
33};
34
35static struct omap_musb_board_data musb_board_data = {
36 .interface_type = MUSB_INTERFACE_UTMI,
37};
38
39static 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 Kocialkowskiae51b572016-02-27 19:19:00 +010048void 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
54struct 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
65void 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
73int 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
87int misc_init_r(void)
88{
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +010089 char reboot_mode[2] = { 0 };
Paul Kocialkowskiee85a412016-02-27 19:19:14 +010090 u32 data = 0;
Paul Kocialkowskibd55eed2016-02-27 19:19:10 +010091 u32 value;
Paul Kocialkowski523849a2016-03-29 14:16:26 +020092 int rc;
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +010093
94 /* Reboot mode */
95
Paul Kocialkowski523849a2016-03-29 14:16:26 +020096 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +010097
Paul Kocialkowskibd55eed2016-02-27 19:19:10 +010098 /* 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 Kocialkowski523849a2016-03-29 14:16:26 +0200106 if (rc < 0 || reboot_mode[0] == 'o') {
Paul Kocialkowskiee85a412016-02-27 19:19:14 +0100107 /*
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 Kocialkowski7c0a4b72016-02-27 19:19:09 +0100118 }
119
Paul Kocialkowski523849a2016-03-29 14:16:26 +0200120 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
Simon Glass00caae62017-08-03 12:22:12 -0600121 if (!env_get("reboot-mode"))
Simon Glass382bee52017-08-03 12:22:09 -0600122 env_set("reboot-mode", (char *)reboot_mode);
Paul Kocialkowski523849a2016-03-29 14:16:26 +0200123 }
124
125 omap_reboot_mode_clear();
126
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100127 /* Serial number */
128
129 omap_die_id_serial();
130
Paul Kocialkowskie66782e2016-02-27 19:19:06 +0100131 /* MUSB */
132
133 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
134
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100135 return 0;
136}
137
138u32 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
160void get_board_serial(struct tag_serialnr *serialnr)
161{
162 omap_die_id_get_board_serial(serialnr);
163}
164
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +0100165int fb_set_reboot_flag(void)
166{
167 return omap_reboot_mode_store("b");
168}
169
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100170int board_mmc_init(bd_t *bis)
171{
172 return omap_mmc_init(1, 0, 0, -1, -1);
173}
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100174
175void board_mmc_power_init(void)
176{
177 twl6030_power_mmc_init(1);
178}