blob: 75fb14025c12884fc57dd6997c3007364f3d2802 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Paul Kocialkowskiae51b572016-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 Kocialkowskiae51b572016-02-27 19:19:00 +01006 */
7
8#include <config.h>
9#include <common.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060010#include <env.h>
Roman Kovalivskyi851737a2020-07-28 23:35:32 +030011#include <fastboot.h>
Simon Glass691d7192020-05-10 11:40:02 -060012#include <init.h>
Simon Glass401d1c42020-10-30 21:38:53 -060013#include <asm/global_data.h>
Paul Kocialkowskie66782e2016-02-27 19:19:06 +010014#include <linux/ctype.h>
15#include <linux/usb/musb.h>
16#include <asm/omap_musb.h>
Paul Kocialkowskiae51b572016-02-27 19:19:00 +010017#include <asm/arch/sys_proto.h>
18#include <asm/arch/mmc_host_def.h>
19#include <asm/gpio.h>
20#include <asm/emif.h>
21#include <twl6030.h>
22#include "kc1.h"
Simon Glassc62db352017-05-31 19:47:48 -060023#include <asm/mach-types.h>
Paul Kocialkowskiae51b572016-02-27 19:19:00 +010024
25DECLARE_GLOBAL_DATA_PTR;
26
27const struct omap_sysinfo sysinfo = {
28 .board_string = "kc1"
29};
30
Paul Kocialkowskie66782e2016-02-27 19:19:06 +010031static struct musb_hdrc_config musb_config = {
32 .multipoint = 1,
33 .dyn_fifo = 1,
34 .num_eps = 16,
35 .ram_bits = 12
36};
37
38static struct omap_musb_board_data musb_board_data = {
39 .interface_type = MUSB_INTERFACE_UTMI,
40};
41
42static struct musb_hdrc_platform_data musb_platform_data = {
43 .mode = MUSB_PERIPHERAL,
44 .config = &musb_config,
45 .power = 100,
46 .platform_ops = &omap2430_ops,
47 .board_data = &musb_board_data,
48};
49
50
Paul Kocialkowskiae51b572016-02-27 19:19:00 +010051void set_muxconf_regs(void)
52{
53 do_set_mux((*ctrl)->control_padconf_core_base, core_padconf_array,
54 sizeof(core_padconf_array) / sizeof(struct pad_conf_entry));
55}
56
57struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
58 struct lpddr2_device_details *lpddr2_dev_details)
59{
60 if (cs == CS1)
61 return NULL;
62
63 *lpddr2_dev_details = elpida_2G_S4_details;
64
65 return lpddr2_dev_details;
66}
67
68void emif_get_device_timings(u32 emif_nr,
69 const struct lpddr2_device_timings **cs0_device_timings,
70 const struct lpddr2_device_timings **cs1_device_timings)
71{
72 *cs0_device_timings = &elpida_2G_S4_timings;
73 *cs1_device_timings = NULL;
74}
75
76int board_init(void)
77{
78 /* GPMC init */
79 gpmc_init();
80
81 /* MACH number */
82 gd->bd->bi_arch_number = MACH_TYPE_OMAP_4430SDP;
83
84 /* ATAGs location */
85 gd->bd->bi_boot_params = OMAP44XX_DRAM_ADDR_SPACE_START + 0x100;
86
87 return 0;
88}
89
90int misc_init_r(void)
91{
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +010092 char reboot_mode[2] = { 0 };
Paul Kocialkowskiee85a412016-02-27 19:19:14 +010093 u32 data = 0;
Paul Kocialkowskibd55eed2016-02-27 19:19:10 +010094 u32 value;
Paul Kocialkowski523849a2016-03-29 14:16:26 +020095 int rc;
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +010096
97 /* Reboot mode */
98
Paul Kocialkowski523849a2016-03-29 14:16:26 +020099 rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +0100100
Paul Kocialkowskibd55eed2016-02-27 19:19:10 +0100101 /* USB ID pin pull-up indicates factory (fastboot) cable detection. */
102 gpio_request(KC1_GPIO_USB_ID, "USB_ID");
103 gpio_direction_input(KC1_GPIO_USB_ID);
104 value = gpio_get_value(KC1_GPIO_USB_ID);
105
106 if (value)
107 reboot_mode[0] = 'b';
108
Paul Kocialkowski523849a2016-03-29 14:16:26 +0200109 if (rc < 0 || reboot_mode[0] == 'o') {
Paul Kocialkowskiee85a412016-02-27 19:19:14 +0100110 /*
111 * When not rebooting, valid power on reasons are either the
112 * power button, charger plug or USB plug.
113 */
114
115 data |= twl6030_input_power_button();
116 data |= twl6030_input_charger();
117 data |= twl6030_input_usb();
118
119 if (!data)
120 twl6030_power_off();
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +0100121 }
122
Paul Kocialkowski523849a2016-03-29 14:16:26 +0200123 if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
Simon Glass00caae62017-08-03 12:22:12 -0600124 if (!env_get("reboot-mode"))
Simon Glass382bee52017-08-03 12:22:09 -0600125 env_set("reboot-mode", (char *)reboot_mode);
Paul Kocialkowski523849a2016-03-29 14:16:26 +0200126 }
127
128 omap_reboot_mode_clear();
129
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100130 /* Serial number */
131
132 omap_die_id_serial();
133
Paul Kocialkowskie66782e2016-02-27 19:19:06 +0100134 /* MUSB */
135
136 musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
137
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100138 return 0;
139}
140
141u32 get_board_rev(void)
142{
143 u32 value = 0;
144
145 gpio_request(KC1_GPIO_MBID0, "MBID0");
146 gpio_request(KC1_GPIO_MBID1, "MBID1");
147 gpio_request(KC1_GPIO_MBID2, "MBID2");
148 gpio_request(KC1_GPIO_MBID3, "MBID3");
149
150 gpio_direction_input(KC1_GPIO_MBID0);
151 gpio_direction_input(KC1_GPIO_MBID1);
152 gpio_direction_input(KC1_GPIO_MBID2);
153 gpio_direction_input(KC1_GPIO_MBID3);
154
155 value |= (gpio_get_value(KC1_GPIO_MBID0) << 0);
156 value |= (gpio_get_value(KC1_GPIO_MBID1) << 1);
157 value |= (gpio_get_value(KC1_GPIO_MBID2) << 2);
158 value |= (gpio_get_value(KC1_GPIO_MBID3) << 3);
159
160 return value;
161}
162
163void get_board_serial(struct tag_serialnr *serialnr)
164{
165 omap_die_id_get_board_serial(serialnr);
166}
167
Roman Kovalivskyi851737a2020-07-28 23:35:32 +0300168int fastboot_set_reboot_flag(enum fastboot_reboot_reason reason)
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +0100169{
Roman Kovalivskyi851737a2020-07-28 23:35:32 +0300170 if (reason != FASTBOOT_REBOOT_REASON_BOOTLOADER)
171 return -ENOTSUPP;
172
Paul Kocialkowski7c0a4b72016-02-27 19:19:09 +0100173 return omap_reboot_mode_store("b");
174}
175
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900176int board_mmc_init(struct bd_info *bis)
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100177{
178 return omap_mmc_init(1, 0, 0, -1, -1);
179}
Paul Kocialkowskiae51b572016-02-27 19:19:00 +0100180
181void board_mmc_power_init(void)
182{
183 twl6030_power_mmc_init(1);
184}