blob: 973bc5a927295ee7c89cf46af3335fe4bbdcd0ce [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +01002/*
3 * Amazon Kindle Fire (first generation) codename kc1 config
4 *
5 * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +01006 */
7
8#include <config.h>
9#include <common.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060010#include <env.h>
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +030011#include <fastboot.h>
Simon Glass97589732020-05-10 11:40:02 -060012#include <init.h>
Paul Kocialkowski75089e52016-02-27 19:19:06 +010013#include <linux/ctype.h>
14#include <linux/usb/musb.h>
15#include <asm/omap_musb.h>
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +010016#include <asm/arch/sys_proto.h>
17#include <asm/arch/mmc_host_def.h>
18#include <asm/gpio.h>
19#include <asm/emif.h>
20#include <twl6030.h>
21#include "kc1.h"
Simon Glass0ffb9d62017-05-31 19:47:48 -060022#include <asm/mach-types.h>
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +010023
24DECLARE_GLOBAL_DATA_PTR;
25
26const struct omap_sysinfo sysinfo = {
27 .board_string = "kc1"
28};
29
Paul Kocialkowski75089e52016-02-27 19:19:06 +010030static struct musb_hdrc_config musb_config = {
31 .multipoint = 1,
32 .dyn_fifo = 1,
33 .num_eps = 16,
34 .ram_bits = 12
35};
36
37static struct omap_musb_board_data musb_board_data = {
38 .interface_type = MUSB_INTERFACE_UTMI,
39};
40
41static struct musb_hdrc_platform_data musb_platform_data = {
42 .mode = MUSB_PERIPHERAL,
43 .config = &musb_config,
44 .power = 100,
45 .platform_ops = &omap2430_ops,
46 .board_data = &musb_board_data,
47};
48
49
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +010050void set_muxconf_regs(void)
51{
52 do_set_mux((*ctrl)->control_padconf_core_base, core_padconf_array,
53 sizeof(core_padconf_array) / sizeof(struct pad_conf_entry));
54}
55
56struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
57 struct lpddr2_device_details *lpddr2_dev_details)
58{
59 if (cs == CS1)
60 return NULL;
61
62 *lpddr2_dev_details = elpida_2G_S4_details;
63
64 return lpddr2_dev_details;
65}
66
67void emif_get_device_timings(u32 emif_nr,
68 const struct lpddr2_device_timings **cs0_device_timings,
69 const struct lpddr2_device_timings **cs1_device_timings)
70{
71 *cs0_device_timings = &elpida_2G_S4_timings;
72 *cs1_device_timings = NULL;
73}
74
75int board_init(void)
76{
77 /* GPMC init */
78 gpmc_init();
79
80 /* MACH number */
81 gd->bd->bi_arch_number = MACH_TYPE_OMAP_4430SDP;
82
83 /* ATAGs location */
84 gd->bd->bi_boot_params = OMAP44XX_DRAM_ADDR_SPACE_START + 0x100;
85
86 return 0;
87}
88
89int misc_init_r(void)
90{
Paul Kocialkowskifc453922016-02-27 19:19:09 +010091 char reboot_mode[2] = { 0 };
Paul Kocialkowski31d8ef82016-02-27 19:19:14 +010092 u32 data = 0;
Paul Kocialkowskibdcbdcf2016-02-27 19:19:10 +010093 u32 value;
Paul Kocialkowski050f9332016-03-29 14:16:26 +020094 int rc;
Paul Kocialkowskifc453922016-02-27 19:19:09 +010095
96 /* Reboot mode */
97
Paul Kocialkowski050f9332016-03-29 14:16:26 +020098 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
Paul Kocialkowskifc453922016-02-27 19:19:09 +010099
Paul Kocialkowskibdcbdcf2016-02-27 19:19:10 +0100100 /* USB ID pin pull-up indicates factory (fastboot) cable detection. */
101 gpio_request(KC1_GPIO_USB_ID, "USB_ID");
102 gpio_direction_input(KC1_GPIO_USB_ID);
103 value = gpio_get_value(KC1_GPIO_USB_ID);
104
105 if (value)
106 reboot_mode[0] = 'b';
107
Paul Kocialkowski050f9332016-03-29 14:16:26 +0200108 if (rc < 0 || reboot_mode[0] == 'o') {
Paul Kocialkowski31d8ef82016-02-27 19:19:14 +0100109 /*
110 * When not rebooting, valid power on reasons are either the
111 * power button, charger plug or USB plug.
112 */
113
114 data |= twl6030_input_power_button();
115 data |= twl6030_input_charger();
116 data |= twl6030_input_usb();
117
118 if (!data)
119 twl6030_power_off();
Paul Kocialkowskifc453922016-02-27 19:19:09 +0100120 }
121
Paul Kocialkowski050f9332016-03-29 14:16:26 +0200122 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
Simon Glass64b723f2017-08-03 12:22:12 -0600123 if (!env_get("reboot-mode"))
Simon Glass6a38e412017-08-03 12:22:09 -0600124 env_set("reboot-mode", (char *)reboot_mode);
Paul Kocialkowski050f9332016-03-29 14:16:26 +0200125 }
126
127 omap_reboot_mode_clear();
128
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +0100129 /* Serial number */
130
131 omap_die_id_serial();
132
Paul Kocialkowski75089e52016-02-27 19:19:06 +0100133 /* MUSB */
134
135 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
136
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +0100137 return 0;
138}
139
140u32 get_board_rev(void)
141{
142 u32 value = 0;
143
144 gpio_request(KC1_GPIO_MBID0, "MBID0");
145 gpio_request(KC1_GPIO_MBID1, "MBID1");
146 gpio_request(KC1_GPIO_MBID2, "MBID2");
147 gpio_request(KC1_GPIO_MBID3, "MBID3");
148
149 gpio_direction_input(KC1_GPIO_MBID0);
150 gpio_direction_input(KC1_GPIO_MBID1);
151 gpio_direction_input(KC1_GPIO_MBID2);
152 gpio_direction_input(KC1_GPIO_MBID3);
153
154 value |= (gpio_get_value(KC1_GPIO_MBID0) << 0);
155 value |= (gpio_get_value(KC1_GPIO_MBID1) << 1);
156 value |= (gpio_get_value(KC1_GPIO_MBID2) << 2);
157 value |= (gpio_get_value(KC1_GPIO_MBID3) << 3);
158
159 return value;
160}
161
162void get_board_serial(struct tag_serialnr *serialnr)
163{
164 omap_die_id_get_board_serial(serialnr);
165}
166
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +0300167int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
Paul Kocialkowskifc453922016-02-27 19:19:09 +0100168{
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +0300169 if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
170 return -ENOTSUPP;
171
Paul Kocialkowskifc453922016-02-27 19:19:09 +0100172 return omap_reboot_mode_store("b");
173}
174
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900175int board_mmc_init(struct bd_info *bis)
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +0100176{
177 return omap_mmc_init(1, 0, 0, -1, -1);
178}
Paul Kocialkowski3e3b8bc2016-02-27 19:19:00 +0100179
180void board_mmc_power_init(void)
181{
182 twl6030_power_mmc_init(1);
183}