2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2010-02-05 14:13:58 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2009 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2010-02-05 14:13:58 +00:00
|
|
|
#include <asm/io.h>
|
2011-08-21 21:29:52 +00:00
|
|
|
#include <asm/gpio.h>
|
2010-02-05 14:13:58 +00:00
|
|
|
#include <asm/arch/imx-regs.h>
|
2013-05-03 10:32:27 +00:00
|
|
|
#include <asm/arch/iomux-mx51.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2016-09-21 02:28:55 +00:00
|
|
|
#include <linux/errno.h>
|
2010-03-05 16:54:37 +00:00
|
|
|
#include <asm/arch/sys_proto.h>
|
2010-03-16 16:22:21 +00:00
|
|
|
#include <asm/arch/crm_regs.h>
|
2012-10-01 08:36:25 +00:00
|
|
|
#include <asm/arch/clock.h>
|
2017-06-29 08:16:06 +00:00
|
|
|
#include <asm/mach-imx/mx5_video.h>
|
2010-02-05 14:13:58 +00:00
|
|
|
#include <i2c.h>
|
2017-09-22 15:12:18 +00:00
|
|
|
#include <input.h>
|
2010-02-05 14:13:58 +00:00
|
|
|
#include <mmc.h>
|
2019-06-21 03:42:28 +00:00
|
|
|
#include <fsl_esdhc_imx.h>
|
2012-11-13 03:21:55 +00:00
|
|
|
#include <power/pmic.h>
|
2010-03-16 16:22:21 +00:00
|
|
|
#include <fsl_pmic.h>
|
|
|
|
#include <mc13892.h>
|
2016-03-31 21:12:23 +00:00
|
|
|
#include <usb/ehci-ci.h>
|
2010-02-05 14:13:58 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
int dram_init(void)
|
|
|
|
{
|
2010-10-28 02:13:15 +00:00
|
|
|
/* dram_init must store complete ramsize in gd->ram_size */
|
2011-07-03 05:55:33 +00:00
|
|
|
gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
|
2010-10-28 02:13:15 +00:00
|
|
|
PHYS_SDRAM_1_SIZE);
|
2010-02-05 14:13:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
arm: Disable ATAGs support
With the exceptions of ds109, ds414, icnova-a20-swac, nokia_rx51 and
stemmy, disable ATAG support. A large number of platforms had enabled
support but never supported a kernel so old as to require it. Further,
some platforms are old enough to support both, but are well supported by
devicetree booting, and have been for a number of years. This is
because some of the ATAGs related functions have been re-used to provide
the same kind of information, but for devicetree or just generally to
inform the user. When needed still, rename these functions to
get_board_revision() instead, to avoid conflicts. In other cases, these
functions were simply unused, so drop them.
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Phil Sutter <phil@nwl.cc>
Cc: Stefan Bosch <stefan_b@posteo.net>
Signed-off-by: Tom Rini <trini@konsulko.com>
2021-08-30 13:16:30 +00:00
|
|
|
#ifdef CONFIG_REVISION_TAG
|
2012-09-18 04:48:42 +00:00
|
|
|
u32 get_board_rev(void)
|
|
|
|
{
|
|
|
|
u32 rev = get_cpu_rev();
|
|
|
|
if (!gpio_get_value(IMX_GPIO_NR(1, 22)))
|
|
|
|
rev |= BOARD_REV_2_0 << BOARD_VER_OFFSET;
|
|
|
|
return rev;
|
|
|
|
}
|
arm: Disable ATAGs support
With the exceptions of ds109, ds414, icnova-a20-swac, nokia_rx51 and
stemmy, disable ATAG support. A large number of platforms had enabled
support but never supported a kernel so old as to require it. Further,
some platforms are old enough to support both, but are well supported by
devicetree booting, and have been for a number of years. This is
because some of the ATAGs related functions have been re-used to provide
the same kind of information, but for devicetree or just generally to
inform the user. When needed still, rename these functions to
get_board_revision() instead, to avoid conflicts. In other cases, these
functions were simply unused, so drop them.
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Jagan Teki <jagan@amarulasolutions.com>
Cc: Phil Sutter <phil@nwl.cc>
Cc: Stefan Bosch <stefan_b@posteo.net>
Signed-off-by: Tom Rini <trini@konsulko.com>
2021-08-30 13:16:30 +00:00
|
|
|
#endif
|
2012-09-18 04:48:42 +00:00
|
|
|
|
2013-05-03 10:32:27 +00:00
|
|
|
#define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_DSE_HIGH)
|
|
|
|
|
2010-02-05 14:13:58 +00:00
|
|
|
static void setup_iomux_uart(void)
|
|
|
|
{
|
2013-05-03 10:32:27 +00:00
|
|
|
static const iomux_v3_cfg_t uart_pads[] = {
|
|
|
|
MX51_PAD_UART1_RXD__UART1_RXD,
|
|
|
|
MX51_PAD_UART1_TXD__UART1_TXD,
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_UART1_RTS__UART1_RTS, UART_PAD_CTRL),
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_UART1_CTS__UART1_CTS, UART_PAD_CTRL),
|
|
|
|
};
|
|
|
|
|
|
|
|
imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
|
2010-02-05 14:13:58 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 16:22:21 +00:00
|
|
|
#ifdef CONFIG_MXC_SPI
|
|
|
|
static void setup_iomux_spi(void)
|
|
|
|
{
|
2013-05-03 10:32:27 +00:00
|
|
|
static const iomux_v3_cfg_t spi_pads[] = {
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, PAD_CTL_HYS |
|
|
|
|
PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_CSPI1_MISO__ECSPI1_MISO, PAD_CTL_HYS |
|
|
|
|
PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_CSPI1_SS1__ECSPI1_SS1,
|
|
|
|
MX51_GPIO_PAD_CTRL),
|
|
|
|
MX51_PAD_CSPI1_SS0__ECSPI1_SS0,
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_CSPI1_RDY__ECSPI1_RDY, MX51_PAD_CTRL_2),
|
|
|
|
NEW_PAD_CTRL(MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, PAD_CTL_HYS |
|
|
|
|
PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
|
|
|
|
};
|
|
|
|
|
|
|
|
imx_iomux_v3_setup_multiple_pads(spi_pads, ARRAY_SIZE(spi_pads));
|
2010-03-16 16:22:21 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void power_init(void)
|
|
|
|
{
|
|
|
|
unsigned int val;
|
|
|
|
struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
|
2011-10-08 08:59:20 +00:00
|
|
|
struct pmic *p;
|
2012-11-13 03:21:55 +00:00
|
|
|
int ret;
|
2011-10-08 08:59:20 +00:00
|
|
|
|
2013-11-20 22:26:03 +00:00
|
|
|
ret = pmic_init(CONFIG_FSL_PMIC_BUS);
|
2012-11-13 03:21:55 +00:00
|
|
|
if (ret)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p = pmic_get("FSL_PMIC");
|
|
|
|
if (!p)
|
|
|
|
return;
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Write needed to Power Gate 2 register */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_POWER_MISC, &val);
|
2010-03-16 16:22:21 +00:00
|
|
|
val &= ~PWGT2SPIEN;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_POWER_MISC, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
2010-10-27 15:36:04 +00:00
|
|
|
/* Externally powered */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_CHARGE, &val);
|
2010-10-27 15:36:04 +00:00
|
|
|
val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_CHARGE, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* power up the system first */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_POWER_MISC, PWUP);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Set core voltage to 1.1V */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SW_0, &val);
|
2011-01-19 04:40:36 +00:00
|
|
|
val = (val & ~SWx_VOLT_MASK) | SWx_1_100V;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SW_0, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Setup VCC (SW2) to 1.25 */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SW_1, &val);
|
2011-01-19 04:40:36 +00:00
|
|
|
val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SW_1, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Setup 1V2_DIG1 (SW3) to 1.25 */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SW_2, &val);
|
2011-01-19 04:40:36 +00:00
|
|
|
val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SW_2, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
udelay(50);
|
|
|
|
|
|
|
|
/* Raise the core frequency to 800MHz */
|
|
|
|
writel(0x0, &mxc_ccm->cacrr);
|
|
|
|
|
|
|
|
/* Set switchers in Auto in NORMAL mode & STANDBY mode */
|
|
|
|
/* Setup the switcher mode for SW1 & SW2*/
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SW_4, &val);
|
2010-03-16 16:22:21 +00:00
|
|
|
val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
|
|
|
|
(SWMODE_MASK << SWMODE2_SHIFT)));
|
|
|
|
val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
|
|
|
|
(SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SW_4, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Setup the switcher mode for SW3 & SW4 */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SW_5, &val);
|
2010-03-16 16:22:21 +00:00
|
|
|
val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) |
|
|
|
|
(SWMODE_MASK << SWMODE4_SHIFT)));
|
|
|
|
val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) |
|
|
|
|
(SWMODE_AUTO_AUTO << SWMODE4_SHIFT);
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SW_5, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SETTING_0, &val);
|
2010-03-16 16:22:21 +00:00
|
|
|
val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK);
|
|
|
|
val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SETTING_0, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_read(p, REG_SETTING_1, &val);
|
2010-03-16 16:22:21 +00:00
|
|
|
val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
|
|
|
|
val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_SETTING_1, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
|
|
|
/* Configure VGEN3 and VCAM regulators to use external PNP */
|
|
|
|
val = VGEN3CONFIG | VCAMCONFIG;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_MODE_1, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
udelay(200);
|
|
|
|
|
|
|
|
/* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
|
|
|
|
val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
|
|
|
|
VVIDEOEN | VAUDIOEN | VSDEN;
|
2011-10-08 08:59:20 +00:00
|
|
|
pmic_reg_write(p, REG_MODE_1, val);
|
2010-03-16 16:22:21 +00:00
|
|
|
|
2013-05-03 10:32:27 +00:00
|
|
|
imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_EIM_A20__GPIO2_14,
|
|
|
|
NO_PAD_CTRL));
|
2021-02-15 11:58:17 +00:00
|
|
|
gpio_request(IMX_GPIO_NR(2, 14), "gpio2_14");
|
2012-08-28 02:09:38 +00:00
|
|
|
gpio_direction_output(IMX_GPIO_NR(2, 14), 0);
|
2011-10-25 03:14:00 +00:00
|
|
|
|
2010-03-16 16:22:21 +00:00
|
|
|
udelay(500);
|
|
|
|
|
2012-08-28 02:09:38 +00:00
|
|
|
gpio_set_value(IMX_GPIO_NR(2, 14), 1);
|
2010-03-16 16:22:21 +00:00
|
|
|
}
|
|
|
|
|
2010-12-23 01:13:17 +00:00
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
|
|
|
setup_iomux_uart();
|
2012-11-10 02:28:52 +00:00
|
|
|
setup_iomux_lcd();
|
2010-12-23 01:13:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-05 14:13:58 +00:00
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
/* address of boot parameters */
|
|
|
|
gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-10-20 04:19:47 +00:00
|
|
|
#ifdef CONFIG_BOARD_LATE_INIT
|
2010-03-16 16:22:21 +00:00
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_MXC_SPI
|
|
|
|
setup_iomux_spi();
|
|
|
|
power_init();
|
|
|
|
#endif
|
2012-05-09 06:39:41 +00:00
|
|
|
|
2010-03-16 16:22:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-05 07:31:33 +00:00
|
|
|
/*
|
|
|
|
* Do not overwrite the console
|
|
|
|
* Use always serial for U-Boot console
|
|
|
|
*/
|
|
|
|
int overwrite_console(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-05 14:13:58 +00:00
|
|
|
int checkboard(void)
|
|
|
|
{
|
2011-04-22 02:55:42 +00:00
|
|
|
puts("Board: MX51EVK\n");
|
2010-02-05 14:13:58 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|