Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2010 |
| 4 | * Texas Instruments Incorporated, <www.ti.com> |
| 5 | * Steve Sakoman <steve@sakoman.com> |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include <common.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 10 | #include <net.h> |
Tero Kristo | 0a45375 | 2020-06-16 11:03:06 +0300 | [diff] [blame^] | 11 | #include <serial.h> |
Simon Glass | c62db35 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 12 | #include <asm/mach-types.h> |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
Sukumar Ghorai | 7e982c9 | 2010-09-18 20:56:18 -0700 | [diff] [blame] | 14 | #include <asm/arch/mmc_host_def.h> |
Lokesh Vutla | af1d002 | 2013-05-30 02:54:32 +0000 | [diff] [blame] | 15 | #include <asm/arch/clock.h> |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 16 | #include <asm/arch/gpio.h> |
Govindraj.R | 43b6239 | 2012-02-06 03:55:34 +0000 | [diff] [blame] | 17 | #include <asm/gpio.h> |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 18 | #include <env.h> |
Paul Kocialkowski | fbf1b08 | 2016-02-27 19:18:52 +0100 | [diff] [blame] | 19 | #include <twl6030.h> |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 20 | |
Aneesh V | 469ec1e | 2011-07-21 09:10:01 -0400 | [diff] [blame] | 21 | #include "panda_mux_data.h" |
Steve Sakoman | 2ad853c | 2010-07-15 13:43:10 -0700 | [diff] [blame] | 22 | |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 23 | #define PANDA_ULPI_PHY_TYPE_GPIO 182 |
Dan Murphy | 7d47d1c | 2013-06-13 11:21:13 -0500 | [diff] [blame] | 24 | #define PANDA_BOARD_ID_1_GPIO 101 |
| 25 | #define PANDA_ES_BOARD_ID_1_GPIO 48 |
| 26 | #define PANDA_BOARD_ID_2_GPIO 171 |
| 27 | #define PANDA_ES_BOARD_ID_3_GPIO 3 |
| 28 | #define PANDA_ES_BOARD_ID_4_GPIO 2 |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 29 | |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 30 | DECLARE_GLOBAL_DATA_PTR; |
| 31 | |
| 32 | const struct omap_sysinfo sysinfo = { |
| 33 | "Board: OMAP4 Panda\n" |
| 34 | }; |
| 35 | |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 36 | struct omap4_scrm_regs *const scrm = (struct omap4_scrm_regs *)0x4a30a000; |
| 37 | |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 38 | /** |
| 39 | * @brief board_init |
| 40 | * |
| 41 | * @return 0 |
| 42 | */ |
| 43 | int board_init(void) |
| 44 | { |
Steve Sakoman | 2795201 | 2010-07-15 16:19:16 -0400 | [diff] [blame] | 45 | gpmc_init(); |
| 46 | |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 47 | gd->bd->bi_arch_number = MACH_TYPE_OMAP4_PANDA; |
| 48 | gd->bd->bi_boot_params = (0x80000000 + 0x100); /* boot param addr */ |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
Tero Kristo | 0a45375 | 2020-06-16 11:03:06 +0300 | [diff] [blame^] | 53 | #if defined(CONFIG_SPL_OS_BOOT) |
| 54 | int spl_start_uboot(void) |
| 55 | { |
| 56 | /* break into full u-boot on 'c' */ |
| 57 | if (serial_tstc() && serial_getc() == 'c') |
| 58 | return 1; |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | #endif /* CONFIG_SPL_OS_BOOT */ |
| 63 | |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 64 | int board_eth_init(bd_t *bis) |
| 65 | { |
| 66 | return 0; |
| 67 | } |
| 68 | |
Dan Murphy | 7d47d1c | 2013-06-13 11:21:13 -0500 | [diff] [blame] | 69 | /* |
| 70 | * Routine: get_board_revision |
| 71 | * Description: Detect if we are running on a panda revision A1-A6, |
| 72 | * or an ES panda board. This can be done by reading |
| 73 | * the level of GPIOs and checking the processor revisions. |
| 74 | * This should result in: |
| 75 | * Panda 4430: |
| 76 | * GPIO171, GPIO101, GPIO182: 0 1 1 => A1-A5 |
| 77 | * GPIO171, GPIO101, GPIO182: 1 0 1 => A6 |
| 78 | * Panda ES: |
| 79 | * GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 0 1 1 => B1/B2 |
| 80 | * GPIO2, GPIO3, GPIO171, GPIO48, GPIO182: 0 0 1 1 1 => B3 |
| 81 | */ |
| 82 | int get_board_revision(void) |
| 83 | { |
| 84 | int board_id0, board_id1, board_id2; |
| 85 | int board_id3, board_id4; |
| 86 | int board_id; |
| 87 | |
| 88 | int processor_rev = omap_revision(); |
| 89 | |
| 90 | /* Setup the mux for the common board ID pins (gpio 171 and 182) */ |
| 91 | writew((IEN | M3), (*ctrl)->control_padconf_core_base + UNIPRO_TX0); |
| 92 | writew((IEN | M3), (*ctrl)->control_padconf_core_base + FREF_CLK2_OUT); |
| 93 | |
| 94 | board_id0 = gpio_get_value(PANDA_ULPI_PHY_TYPE_GPIO); |
| 95 | board_id2 = gpio_get_value(PANDA_BOARD_ID_2_GPIO); |
| 96 | |
| 97 | if ((processor_rev >= OMAP4460_ES1_0 && |
| 98 | processor_rev <= OMAP4460_ES1_1)) { |
| 99 | /* |
| 100 | * Setup the mux for the ES specific board ID pins (gpio 101, |
| 101 | * 2 and 3. |
| 102 | */ |
| 103 | writew((IEN | M3), (*ctrl)->control_padconf_core_base + |
| 104 | GPMC_A24); |
| 105 | writew((IEN | M3), (*ctrl)->control_padconf_core_base + |
| 106 | UNIPRO_RY0); |
| 107 | writew((IEN | M3), (*ctrl)->control_padconf_core_base + |
| 108 | UNIPRO_RX1); |
| 109 | |
| 110 | board_id1 = gpio_get_value(PANDA_ES_BOARD_ID_1_GPIO); |
| 111 | board_id3 = gpio_get_value(PANDA_ES_BOARD_ID_3_GPIO); |
| 112 | board_id4 = gpio_get_value(PANDA_ES_BOARD_ID_4_GPIO); |
| 113 | |
| 114 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 115 | env_set("board_name", "panda-es"); |
Dan Murphy | 7d47d1c | 2013-06-13 11:21:13 -0500 | [diff] [blame] | 116 | #endif |
| 117 | board_id = ((board_id4 << 4) | (board_id3 << 3) | |
| 118 | (board_id2 << 2) | (board_id1 << 1) | (board_id0)); |
| 119 | } else { |
| 120 | /* Setup the mux for the Ax specific board ID pins (gpio 101) */ |
| 121 | writew((IEN | M3), (*ctrl)->control_padconf_core_base + |
| 122 | FREF_CLK2_OUT); |
| 123 | |
| 124 | board_id1 = gpio_get_value(PANDA_BOARD_ID_1_GPIO); |
| 125 | board_id = ((board_id2 << 2) | (board_id1 << 1) | (board_id0)); |
| 126 | |
| 127 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 128 | if ((board_id >= 0x3) && (processor_rev == OMAP4430_ES2_3)) |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 129 | env_set("board_name", "panda-a4"); |
Dan Murphy | 7d47d1c | 2013-06-13 11:21:13 -0500 | [diff] [blame] | 130 | #endif |
| 131 | } |
| 132 | |
| 133 | return board_id; |
| 134 | } |
| 135 | |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 136 | /** |
Hardik Patel | 675cc77 | 2013-11-27 21:16:21 +0530 | [diff] [blame] | 137 | * is_panda_es_rev_b3() - Detect if we are running on rev B3 of panda board ES |
| 138 | * |
| 139 | * |
| 140 | * Detect if we are running on B3 version of ES panda board, |
| 141 | * This can be done by reading the level of GPIO 171 and checking the |
| 142 | * processor revisions. |
| 143 | * GPIO171: 1 => Panda ES Rev B3 |
| 144 | * |
| 145 | * Return : return 1 if Panda ES Rev B3 , else return 0 |
| 146 | */ |
| 147 | u8 is_panda_es_rev_b3(void) |
| 148 | { |
| 149 | int processor_rev = omap_revision(); |
| 150 | int ret = 0; |
| 151 | |
| 152 | if ((processor_rev >= OMAP4460_ES1_0 && |
| 153 | processor_rev <= OMAP4460_ES1_1)) { |
| 154 | |
| 155 | /* Setup the mux for the common board ID pins (gpio 171) */ |
| 156 | writew((IEN | M3), |
| 157 | (*ctrl)->control_padconf_core_base + UNIPRO_TX0); |
| 158 | |
| 159 | /* if processor_rev is panda ES and GPIO171 is 1,it is rev b3 */ |
| 160 | ret = gpio_get_value(PANDA_BOARD_ID_2_GPIO); |
| 161 | } |
| 162 | return ret; |
| 163 | } |
| 164 | |
| 165 | #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS |
| 166 | /* |
| 167 | * emif_get_reg_dump() - emif_get_reg_dump strong function |
| 168 | * |
| 169 | * @emif_nr - emif base |
| 170 | * @regs - reg dump of timing values |
| 171 | * |
| 172 | * Strong function to override emif_get_reg_dump weak function in sdram_elpida.c |
| 173 | */ |
| 174 | void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs) |
| 175 | { |
| 176 | u32 omap4_rev = omap_revision(); |
| 177 | |
| 178 | /* Same devices and geometry on both EMIFs */ |
| 179 | if (omap4_rev == OMAP4430_ES1_0) |
| 180 | *regs = &emif_regs_elpida_380_mhz_1cs; |
| 181 | else if (omap4_rev == OMAP4430_ES2_0) |
| 182 | *regs = &emif_regs_elpida_200_mhz_2cs; |
| 183 | else if (omap4_rev == OMAP4430_ES2_3) |
| 184 | *regs = &emif_regs_elpida_400_mhz_1cs; |
| 185 | else if (omap4_rev < OMAP4470_ES1_0) { |
| 186 | if(is_panda_es_rev_b3()) |
| 187 | *regs = &emif_regs_elpida_400_mhz_1cs; |
| 188 | else |
| 189 | *regs = &emif_regs_elpida_400_mhz_2cs; |
| 190 | } |
| 191 | else |
| 192 | *regs = &emif_regs_elpida_400_mhz_1cs; |
| 193 | } |
Nishanth Menon | 38e5a5a | 2014-12-18 15:28:35 -0600 | [diff] [blame] | 194 | |
| 195 | void emif_get_dmm_regs(const struct dmm_lisa_map_regs |
| 196 | **dmm_lisa_regs) |
| 197 | { |
| 198 | u32 omap_rev = omap_revision(); |
| 199 | |
| 200 | if (omap_rev == OMAP4430_ES1_0) |
| 201 | *dmm_lisa_regs = &lisa_map_2G_x_1_x_2; |
| 202 | else if (omap_rev == OMAP4430_ES2_3) |
| 203 | *dmm_lisa_regs = &lisa_map_2G_x_2_x_2; |
| 204 | else if (omap_rev < OMAP4460_ES1_0) |
| 205 | *dmm_lisa_regs = &lisa_map_2G_x_2_x_2; |
| 206 | else |
| 207 | *dmm_lisa_regs = &ma_lisa_map_2G_x_2_x_2; |
| 208 | } |
| 209 | |
Hardik Patel | 675cc77 | 2013-11-27 21:16:21 +0530 | [diff] [blame] | 210 | #endif |
| 211 | |
| 212 | /** |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 213 | * @brief misc_init_r - Configure Panda board specific configurations |
| 214 | * such as power configurations, ethernet initialization as phase2 of |
| 215 | * boot sequence |
| 216 | * |
| 217 | * @return 0 |
| 218 | */ |
| 219 | int misc_init_r(void) |
| 220 | { |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 221 | int phy_type; |
| 222 | u32 auxclk, altclksrc; |
| 223 | |
| 224 | /* EHCI is not supported on ES1.0 */ |
| 225 | if (omap_revision() == OMAP4430_ES1_0) |
| 226 | return 0; |
| 227 | |
Dan Murphy | 7d47d1c | 2013-06-13 11:21:13 -0500 | [diff] [blame] | 228 | get_board_revision(); |
Dan Murphy | 34f667b | 2013-04-18 06:29:53 +0000 | [diff] [blame] | 229 | |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 230 | gpio_direction_input(PANDA_ULPI_PHY_TYPE_GPIO); |
| 231 | phy_type = gpio_get_value(PANDA_ULPI_PHY_TYPE_GPIO); |
| 232 | |
| 233 | if (phy_type == 1) { |
| 234 | /* ULPI PHY supplied by auxclk3 derived from sys_clk */ |
| 235 | debug("ULPI PHY supplied by auxclk3\n"); |
| 236 | |
| 237 | auxclk = readl(&scrm->auxclk3); |
| 238 | /* Select sys_clk */ |
| 239 | auxclk &= ~AUXCLK_SRCSELECT_MASK; |
| 240 | auxclk |= AUXCLK_SRCSELECT_SYS_CLK << AUXCLK_SRCSELECT_SHIFT; |
| 241 | /* Set the divisor to 2 */ |
| 242 | auxclk &= ~AUXCLK_CLKDIV_MASK; |
| 243 | auxclk |= AUXCLK_CLKDIV_2 << AUXCLK_CLKDIV_SHIFT; |
| 244 | /* Request auxilary clock #3 */ |
| 245 | auxclk |= AUXCLK_ENABLE_MASK; |
| 246 | |
| 247 | writel(auxclk, &scrm->auxclk3); |
Dan Murphy | bf3b98a | 2013-06-13 11:21:26 -0500 | [diff] [blame] | 248 | } else { |
Chris Lalancette | df65a3f | 2011-12-13 09:41:12 +0000 | [diff] [blame] | 249 | /* ULPI PHY supplied by auxclk1 derived from PER dpll */ |
| 250 | debug("ULPI PHY supplied by auxclk1\n"); |
| 251 | |
| 252 | auxclk = readl(&scrm->auxclk1); |
| 253 | /* Select per DPLL */ |
| 254 | auxclk &= ~AUXCLK_SRCSELECT_MASK; |
| 255 | auxclk |= AUXCLK_SRCSELECT_PER_DPLL << AUXCLK_SRCSELECT_SHIFT; |
| 256 | /* Set the divisor to 16 */ |
| 257 | auxclk &= ~AUXCLK_CLKDIV_MASK; |
| 258 | auxclk |= AUXCLK_CLKDIV_16 << AUXCLK_CLKDIV_SHIFT; |
| 259 | /* Request auxilary clock #3 */ |
| 260 | auxclk |= AUXCLK_ENABLE_MASK; |
| 261 | |
| 262 | writel(auxclk, &scrm->auxclk1); |
| 263 | } |
| 264 | |
| 265 | altclksrc = readl(&scrm->altclksrc); |
| 266 | |
| 267 | /* Activate alternate system clock supplier */ |
| 268 | altclksrc &= ~ALTCLKSRC_MODE_MASK; |
| 269 | altclksrc |= ALTCLKSRC_MODE_ACTIVE; |
| 270 | |
| 271 | /* enable clocks */ |
| 272 | altclksrc |= ALTCLKSRC_ENABLE_INT_MASK | ALTCLKSRC_ENABLE_EXT_MASK; |
| 273 | |
| 274 | writel(altclksrc, &scrm->altclksrc); |
| 275 | |
Paul Kocialkowski | 07815eb | 2015-08-27 19:37:12 +0200 | [diff] [blame] | 276 | omap_die_id_usbethaddr(); |
Dan Murphy | e84b8f6 | 2013-10-10 08:54:23 -0500 | [diff] [blame] | 277 | |
Steve Sakoman | c57cca2 | 2010-06-11 20:35:26 -0700 | [diff] [blame] | 278 | return 0; |
| 279 | } |
Steve Sakoman | 2ad853c | 2010-07-15 13:43:10 -0700 | [diff] [blame] | 280 | |
Paul Kocialkowski | 3ef56e6 | 2016-02-27 19:18:56 +0100 | [diff] [blame] | 281 | void set_muxconf_regs(void) |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 282 | { |
Lokesh Vutla | 9239f5b | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 283 | do_set_mux((*ctrl)->control_padconf_core_base, |
| 284 | core_padconf_array_essential, |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 285 | sizeof(core_padconf_array_essential) / |
| 286 | sizeof(struct pad_conf_entry)); |
| 287 | |
Lokesh Vutla | 9239f5b | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 288 | do_set_mux((*ctrl)->control_padconf_wkup_base, |
| 289 | wkup_padconf_array_essential, |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 290 | sizeof(wkup_padconf_array_essential) / |
| 291 | sizeof(struct pad_conf_entry)); |
| 292 | |
| 293 | if (omap_revision() >= OMAP4460_ES1_0) |
Lokesh Vutla | 9239f5b | 2013-05-30 02:54:30 +0000 | [diff] [blame] | 294 | do_set_mux((*ctrl)->control_padconf_wkup_base, |
Dan Murphy | bf3b98a | 2013-06-13 11:21:26 -0500 | [diff] [blame] | 295 | wkup_padconf_array_essential_4460, |
| 296 | sizeof(wkup_padconf_array_essential_4460) / |
| 297 | sizeof(struct pad_conf_entry)); |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 298 | } |
| 299 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 300 | #if defined(CONFIG_MMC) |
Sukumar Ghorai | 7e982c9 | 2010-09-18 20:56:18 -0700 | [diff] [blame] | 301 | int board_mmc_init(bd_t *bis) |
| 302 | { |
Nikita Kiryanov | e3913f5 | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 303 | return omap_mmc_init(0, 0, 0, -1, -1); |
Sukumar Ghorai | 7e982c9 | 2010-09-18 20:56:18 -0700 | [diff] [blame] | 304 | } |
Paul Kocialkowski | fbf1b08 | 2016-02-27 19:18:52 +0100 | [diff] [blame] | 305 | |
Jean-Jacques Hiblot | d5abcf9 | 2017-02-01 11:39:14 +0100 | [diff] [blame] | 306 | #if !defined(CONFIG_SPL_BUILD) |
Paul Kocialkowski | fbf1b08 | 2016-02-27 19:18:52 +0100 | [diff] [blame] | 307 | void board_mmc_power_init(void) |
| 308 | { |
| 309 | twl6030_power_mmc_init(0); |
| 310 | } |
Sukumar Ghorai | 7e982c9 | 2010-09-18 20:56:18 -0700 | [diff] [blame] | 311 | #endif |
Jean-Jacques Hiblot | d5abcf9 | 2017-02-01 11:39:14 +0100 | [diff] [blame] | 312 | #endif |
Sricharan | 508a58f | 2011-11-15 09:49:55 -0500 | [diff] [blame] | 313 | |
| 314 | /* |
| 315 | * get_board_rev() - get board revision |
| 316 | */ |
| 317 | u32 get_board_rev(void) |
| 318 | { |
| 319 | return 0x20; |
| 320 | } |