blob: a93848666fea3380a5b76cb36c8c9fe463bf0aa5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Behme7b84a7b2009-01-28 21:39:58 +01002/*
3 * (C) Copyright 2008
4 * Grazvydas Ignotas <notasas@gmail.com>
5 *
6 * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by
7 * Richard Woodruff <r-woodruff2@ti.com>
8 * Syed Mohammed Khasim <khasim@ti.com>
9 * Sunil Kumar <sunilsaini05@gmail.com>
10 * Shashi Ranjan <shashiranjanmca05@gmail.com>
11 *
12 * (C) Copyright 2004-2008
13 * Texas Instruments, <www.ti.com>
Dirk Behme7b84a7b2009-01-28 21:39:58 +010014 */
15#include <common.h>
Grazvydas Ignotasa5c5a552018-08-25 22:40:08 +030016#include <dm.h>
Simon Glass97589732020-05-10 11:40:02 -060017#include <init.h>
Grazvydas Ignotasa5c5a552018-08-25 22:40:08 +030018#include <ns16550.h>
Tom Rix0f2a8042009-06-28 12:52:30 -050019#include <twl4030.h>
Dirk Behme7b84a7b2009-01-28 21:39:58 +010020#include <asm/io.h>
Grazvydas Ignotas43d95382012-03-22 13:49:22 +000021#include <asm/gpio.h>
Tom Rini83922512011-09-03 21:51:25 -040022#include <asm/arch/mmc_host_def.h>
Dirk Behme7b84a7b2009-01-28 21:39:58 +010023#include <asm/arch/mux.h>
Aneesh V1843eca2011-07-31 20:30:53 +000024#include <asm/arch/gpio.h>
Dirk Behme7b84a7b2009-01-28 21:39:58 +010025#include <asm/arch/sys_proto.h>
26#include <asm/mach-types.h>
Simon Glassdbd79542020-05-10 11:40:11 -060027#include <linux/delay.h>
Dirk Behme7b84a7b2009-01-28 21:39:58 +010028#include "pandora.h"
29
John Rigby0d21ed02010-12-20 18:27:51 -070030DECLARE_GLOBAL_DATA_PTR;
31
Grazvydas Ignotas09a22512010-06-08 17:19:22 -040032#define TWL4030_BB_CFG_BBCHEN (1 << 4)
33#define TWL4030_BB_CFG_BBSEL_3200MV (3 << 2)
34#define TWL4030_BB_CFG_BBISEL_500UA 2
35
Grazvydas Ignotas43d95382012-03-22 13:49:22 +000036#define CONTROL_WKUP_CTRL 0x48002a5c
37#define GPIO_IO_PWRDNZ (1 << 6)
38#define PBIASLITEVMODE1 (1 << 8)
39
Grazvydas Ignotasa5c5a552018-08-25 22:40:08 +030040static const struct ns16550_platdata pandora_serial = {
41 .base = OMAP34XX_UART3,
42 .reg_shift = 2,
43 .clock = V_NS16550_CLK,
44 .fcr = UART_FCR_DEFVAL,
45};
46
47U_BOOT_DEVICE(pandora_uart) = {
48 "ns16550_serial",
49 &pandora_serial
50};
51
Tom Rix558bb832009-04-01 22:02:20 -050052/*
Dirk Behme7b84a7b2009-01-28 21:39:58 +010053 * Routine: board_init
54 * Description: Early hardware init.
Tom Rix558bb832009-04-01 22:02:20 -050055 */
Dirk Behme7b84a7b2009-01-28 21:39:58 +010056int board_init(void)
57{
Dirk Behme7b84a7b2009-01-28 21:39:58 +010058 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
59 /* board id for Linux */
60 gd->bd->bi_arch_number = MACH_TYPE_OMAP3_PANDORA;
61 /* boot param addr */
62 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
63
64 return 0;
65}
66
Grazvydas Ignotas43d95382012-03-22 13:49:22 +000067static void set_output_gpio(unsigned int gpio, int value)
68{
69 int ret;
70
71 ret = gpio_request(gpio, "");
72 if (ret != 0) {
73 printf("could not request GPIO %u\n", gpio);
74 return;
75 }
76 ret = gpio_direction_output(gpio, value);
77 if (ret != 0)
78 printf("could not set GPIO %u to %d\n", gpio, value);
79}
80
Tom Rix558bb832009-04-01 22:02:20 -050081/*
Dirk Behme7b84a7b2009-01-28 21:39:58 +010082 * Routine: misc_init_r
83 * Description: Configure board specific parts
Tom Rix558bb832009-04-01 22:02:20 -050084 */
Dirk Behme7b84a7b2009-01-28 21:39:58 +010085int misc_init_r(void)
86{
Grazvydas Ignotas43d95382012-03-22 13:49:22 +000087 t2_t *t2_base = (t2_t *)T2_BASE;
88 u32 pbias_lite;
Dirk Behme7b84a7b2009-01-28 21:39:58 +010089
Grazvydas Ignotas17887bf2009-12-10 17:10:21 +020090 twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
Dirk Behme7b84a7b2009-01-28 21:39:58 +010091
Grazvydas Ignotas43d95382012-03-22 13:49:22 +000092 /* set up dual-voltage GPIOs to 1.8V */
93 pbias_lite = readl(&t2_base->pbias_lite);
94 pbias_lite &= ~PBIASLITEVMODE1;
95 pbias_lite |= PBIASLITEPWRDNZ1;
96 writel(pbias_lite, &t2_base->pbias_lite);
97 if (get_cpu_family() == CPU_OMAP36XX)
98 writel(readl(CONTROL_WKUP_CTRL) | GPIO_IO_PWRDNZ,
99 CONTROL_WKUP_CTRL);
100
101 /* make sure audio and BT chips are in powerdown state */
102 set_output_gpio(14, 0);
103 set_output_gpio(15, 0);
104 set_output_gpio(118, 0);
105
106 /* enable USB supply */
107 set_output_gpio(164, 1);
Dirk Behme7b84a7b2009-01-28 21:39:58 +0100108
Grazvydas Ignotas43d95382012-03-22 13:49:22 +0000109 /* wifi needs a short pulse to enter powersave state */
110 set_output_gpio(23, 1);
111 udelay(5000);
112 gpio_direction_output(23, 0);
Dirk Behme7b84a7b2009-01-28 21:39:58 +0100113
Grazvydas Ignotas09a22512010-06-08 17:19:22 -0400114 /* Enable battery backup capacitor (3.2V, 0.5mA charge current) */
115 twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER,
Nishanth Menond26a1062013-03-26 05:20:49 +0000116 TWL4030_PM_RECEIVER_BB_CFG,
Grazvydas Ignotas09a22512010-06-08 17:19:22 -0400117 TWL4030_BB_CFG_BBCHEN | TWL4030_BB_CFG_BBSEL_3200MV |
Nishanth Menond26a1062013-03-26 05:20:49 +0000118 TWL4030_BB_CFG_BBISEL_500UA);
Grazvydas Ignotas09a22512010-06-08 17:19:22 -0400119
Paul Kocialkowski6bc318e2015-08-27 19:37:13 +0200120 omap_die_id_display();
Dirk Behme12dbcf62009-03-12 19:30:50 +0100121
Dirk Behme7b84a7b2009-01-28 21:39:58 +0100122 return 0;
123}
124
Tom Rix558bb832009-04-01 22:02:20 -0500125/*
Dirk Behme7b84a7b2009-01-28 21:39:58 +0100126 * Routine: set_muxconf_regs
127 * Description: Setting up the configuration Mux registers specific to the
128 * hardware. Many pins need to be moved from protect to primary
129 * mode.
Tom Rix558bb832009-04-01 22:02:20 -0500130 */
Dirk Behme7b84a7b2009-01-28 21:39:58 +0100131void set_muxconf_regs(void)
132{
133 MUX_PANDORA();
Grazvydas Ignotasb5f9c3f2012-03-22 13:49:21 +0000134 if (get_cpu_family() == CPU_OMAP36XX) {
135 MUX_PANDORA_3730();
136 }
Dirk Behme7b84a7b2009-01-28 21:39:58 +0100137}
Tom Rini83922512011-09-03 21:51:25 -0400138
Masahiro Yamada0a780172017-05-09 20:31:39 +0900139#ifdef CONFIG_MMC
Tom Rini83922512011-09-03 21:51:25 -0400140int board_mmc_init(bd_t *bis)
141{
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000142 return omap_mmc_init(0, 0, 0, -1, -1);
Tom Rini83922512011-09-03 21:51:25 -0400143}
Paul Kocialkowski69559892014-11-08 20:55:47 +0100144
145void board_mmc_power_init(void)
146{
147 twl4030_power_mmc_init(0);
148}
Tom Rini83922512011-09-03 21:51:25 -0400149#endif