2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-05-05 10:52:26 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2012-2013 Henrik Nordstrom <henrik@henriknordstrom.net>
|
|
|
|
* (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
|
|
|
|
*
|
|
|
|
* (C) Copyright 2007-2011
|
|
|
|
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
|
|
|
|
* Tom Cubie <tangliang@allwinnertech.com>
|
|
|
|
*
|
|
|
|
* Some board init for the Allwinner A10-evb board.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2021-12-14 18:36:40 +00:00
|
|
|
#include <clock_legacy.h>
|
2018-05-07 07:33:36 +00:00
|
|
|
#include <dm.h>
|
2019-08-01 15:46:46 +00:00
|
|
|
#include <env.h>
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2020-05-10 17:40:01 +00:00
|
|
|
#include <image.h>
|
2019-12-28 17:45:05 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2014-10-02 19:13:54 +00:00
|
|
|
#include <mmc.h>
|
2015-10-03 13:18:33 +00:00
|
|
|
#include <axp_pmic.h>
|
2018-05-07 07:33:36 +00:00
|
|
|
#include <generic-phy.h>
|
|
|
|
#include <phy-sun4i-usb.h>
|
2014-05-05 10:52:26 +00:00
|
|
|
#include <asm/arch/clock.h>
|
2014-06-14 06:59:09 +00:00
|
|
|
#include <asm/arch/cpu.h>
|
2014-08-13 05:55:07 +00:00
|
|
|
#include <asm/arch/display.h>
|
2014-05-05 10:52:26 +00:00
|
|
|
#include <asm/arch/dram.h>
|
2014-05-05 13:42:31 +00:00
|
|
|
#include <asm/arch/mmc.h>
|
2020-10-24 15:21:52 +00:00
|
|
|
#include <asm/arch/prcm.h>
|
2022-01-21 13:37:32 +00:00
|
|
|
#include <asm/arch/pmic_bus.h>
|
2016-07-09 07:56:56 +00:00
|
|
|
#include <asm/arch/spl.h>
|
2022-03-15 00:00:53 +00:00
|
|
|
#include <asm/arch/sys_proto.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2019-11-14 19:57:16 +00:00
|
|
|
#include <u-boot/crc.h>
|
2016-03-29 15:29:10 +00:00
|
|
|
#ifndef CONFIG_ARM64
|
|
|
|
#include <asm/armv7.h>
|
|
|
|
#endif
|
2015-04-23 21:23:50 +00:00
|
|
|
#include <asm/gpio.h>
|
2014-06-14 06:59:09 +00:00
|
|
|
#include <asm/io.h>
|
2018-11-25 18:22:18 +00:00
|
|
|
#include <u-boot/crc.h>
|
2019-08-02 15:44:25 +00:00
|
|
|
#include <env_internal.h>
|
2018-03-04 16:20:11 +00:00
|
|
|
#include <linux/libfdt.h>
|
2021-10-01 18:29:00 +00:00
|
|
|
#include <fdt_support.h>
|
2015-08-15 09:55:26 +00:00
|
|
|
#include <nand.h>
|
2014-06-14 06:59:09 +00:00
|
|
|
#include <net.h>
|
2017-08-23 08:08:29 +00:00
|
|
|
#include <spl.h>
|
2016-02-23 17:47:19 +00:00
|
|
|
#include <sy8106a.h>
|
2017-05-17 14:23:00 +00:00
|
|
|
#include <asm/setup.h>
|
2021-09-08 19:14:19 +00:00
|
|
|
#include <status_led.h>
|
2014-05-05 10:52:26 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2017-04-26 22:03:35 +00:00
|
|
|
void i2c_init_board(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_I2C0_ENABLE
|
|
|
|
#if defined(CONFIG_MACH_SUN4I) || \
|
|
|
|
defined(CONFIG_MACH_SUN5I) || \
|
|
|
|
defined(CONFIG_MACH_SUN7I) || \
|
|
|
|
defined(CONFIG_MACH_SUN8I_R40)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUN4I_GPB_TWI0);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUN4I_GPB_TWI0);
|
|
|
|
clock_twi_onoff(0, 1);
|
|
|
|
#elif defined(CONFIG_MACH_SUN6I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(14), SUN6I_GPH_TWI0);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(15), SUN6I_GPH_TWI0);
|
|
|
|
clock_twi_onoff(0, 1);
|
2020-10-26 14:19:34 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN8I_V3S)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(6), SUN8I_V3S_GPB_TWI0);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(7), SUN8I_V3S_GPB_TWI0);
|
|
|
|
clock_twi_onoff(0, 1);
|
2017-04-26 22:03:35 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN8I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(2), SUN8I_GPH_TWI0);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(3), SUN8I_GPH_TWI0);
|
|
|
|
clock_twi_onoff(0, 1);
|
2019-01-08 10:04:30 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN50I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(0), SUN50I_GPH_TWI0);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(1), SUN50I_GPH_TWI0);
|
|
|
|
clock_twi_onoff(0, 1);
|
2017-04-26 22:03:35 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_I2C1_ENABLE
|
|
|
|
#if defined(CONFIG_MACH_SUN4I) || \
|
|
|
|
defined(CONFIG_MACH_SUN7I) || \
|
|
|
|
defined(CONFIG_MACH_SUN8I_R40)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(18), SUN4I_GPB_TWI1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(19), SUN4I_GPB_TWI1);
|
|
|
|
clock_twi_onoff(1, 1);
|
|
|
|
#elif defined(CONFIG_MACH_SUN5I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(15), SUN5I_GPB_TWI1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPB(16), SUN5I_GPB_TWI1);
|
|
|
|
clock_twi_onoff(1, 1);
|
|
|
|
#elif defined(CONFIG_MACH_SUN6I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(16), SUN6I_GPH_TWI1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(17), SUN6I_GPH_TWI1);
|
|
|
|
clock_twi_onoff(1, 1);
|
|
|
|
#elif defined(CONFIG_MACH_SUN8I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(4), SUN8I_GPH_TWI1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(5), SUN8I_GPH_TWI1);
|
|
|
|
clock_twi_onoff(1, 1);
|
2019-01-08 10:04:30 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN50I)
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(2), SUN50I_GPH_TWI1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPH(3), SUN50I_GPH_TWI1);
|
|
|
|
clock_twi_onoff(1, 1);
|
2017-04-26 22:03:35 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_R_I2C_ENABLE
|
2018-11-06 04:24:30 +00:00
|
|
|
#ifdef CONFIG_MACH_SUN50I
|
|
|
|
clock_twi_onoff(5, 1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(8), SUN50I_GPL_R_TWI);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(9), SUN50I_GPL_R_TWI);
|
2021-01-11 20:11:42 +00:00
|
|
|
#elif CONFIG_MACH_SUN50I_H616
|
|
|
|
clock_twi_onoff(5, 1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN50I_H616_GPL_R_TWI);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN50I_H616_GPL_R_TWI);
|
2018-11-06 04:24:30 +00:00
|
|
|
#else
|
2017-04-26 22:03:35 +00:00
|
|
|
clock_twi_onoff(5, 1);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUN8I_H3_GPL_R_TWI);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUN8I_H3_GPL_R_TWI);
|
|
|
|
#endif
|
2018-11-06 04:24:30 +00:00
|
|
|
#endif
|
2017-04-26 22:03:35 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 12:46:04 +00:00
|
|
|
/*
|
|
|
|
* Try to use the environment from the boot source first.
|
|
|
|
* For MMC, this means a FAT partition on the boot device (SD or eMMC).
|
|
|
|
* If the raw MMC environment is also enabled, this is tried next.
|
2022-04-20 22:15:39 +00:00
|
|
|
* When booting from NAND we try UBI first, then NAND directly.
|
2022-01-11 12:46:04 +00:00
|
|
|
* SPI flash falls back to FAT (on SD card).
|
|
|
|
*/
|
2018-01-23 20:17:03 +00:00
|
|
|
enum env_location env_get_location(enum env_operation op, int prio)
|
|
|
|
{
|
2022-04-20 22:15:39 +00:00
|
|
|
if (prio > 1)
|
|
|
|
return ENVL_UNKNOWN;
|
2022-01-11 12:46:04 +00:00
|
|
|
|
2022-04-20 22:15:39 +00:00
|
|
|
/* NOWHERE is exclusive, no other option can be defined. */
|
|
|
|
if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE))
|
|
|
|
return ENVL_NOWHERE;
|
2022-01-11 12:46:04 +00:00
|
|
|
|
|
|
|
switch (sunxi_get_boot_device()) {
|
|
|
|
case BOOT_DEVICE_MMC1:
|
|
|
|
case BOOT_DEVICE_MMC2:
|
2022-04-20 22:15:39 +00:00
|
|
|
if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
|
|
|
|
return ENVL_FAT;
|
|
|
|
if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC))
|
|
|
|
return ENVL_MMC;
|
2022-01-11 12:46:04 +00:00
|
|
|
break;
|
|
|
|
case BOOT_DEVICE_NAND:
|
2022-04-20 22:15:39 +00:00
|
|
|
if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
|
|
|
|
return ENVL_UBI;
|
2022-01-11 12:46:04 +00:00
|
|
|
if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND))
|
2022-04-20 22:15:39 +00:00
|
|
|
return ENVL_NAND;
|
2022-01-11 12:46:04 +00:00
|
|
|
break;
|
|
|
|
case BOOT_DEVICE_SPI:
|
2022-04-20 22:15:39 +00:00
|
|
|
if (prio == 0 && IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH))
|
|
|
|
return ENVL_SPI_FLASH;
|
|
|
|
if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
|
|
|
|
return ENVL_FAT;
|
2022-01-11 12:46:04 +00:00
|
|
|
break;
|
|
|
|
case BOOT_DEVICE_BOARD:
|
|
|
|
break;
|
2018-01-23 20:17:03 +00:00
|
|
|
default:
|
2022-01-11 12:46:04 +00:00
|
|
|
break;
|
2018-01-23 20:17:03 +00:00
|
|
|
}
|
2022-01-11 12:46:04 +00:00
|
|
|
|
2022-04-20 22:15:39 +00:00
|
|
|
/*
|
|
|
|
* If we come here for the first time, we *must* return a valid
|
|
|
|
* environment location other than ENVL_UNKNOWN, or the setup sequence
|
|
|
|
* in board_f() will silently hang. This is arguably a bug in
|
|
|
|
* env_init(), but for now pick one environment for which we know for
|
|
|
|
* sure to have a driver for. For all defconfigs this is either FAT
|
|
|
|
* or UBI, or NOWHERE, which is already handled above.
|
|
|
|
*/
|
|
|
|
if (prio == 0) {
|
|
|
|
if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT))
|
2022-01-11 12:46:04 +00:00
|
|
|
return ENVL_FAT;
|
2022-04-20 22:15:39 +00:00
|
|
|
if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI))
|
|
|
|
return ENVL_UBI;
|
2022-01-11 12:46:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ENVL_UNKNOWN;
|
2018-01-23 20:17:03 +00:00
|
|
|
}
|
|
|
|
|
2014-05-05 10:52:26 +00:00
|
|
|
/* add board specific code here */
|
|
|
|
int board_init(void)
|
|
|
|
{
|
2017-04-02 10:59:10 +00:00
|
|
|
__maybe_unused int id_pfr1, ret, satapwr_pin, macpwr_pin;
|
2014-05-05 10:52:26 +00:00
|
|
|
|
|
|
|
gd->bd->bi_boot_params = (PHYS_SDRAM_0 + 0x100);
|
|
|
|
|
2022-01-29 15:23:05 +00:00
|
|
|
#if !defined(CONFIG_ARM64) && !defined(CONFIG_MACH_SUNIV)
|
2014-05-05 10:52:26 +00:00
|
|
|
asm volatile("mrc p15, 0, %0, c0, c1, 1" : "=r"(id_pfr1));
|
|
|
|
debug("id_pfr1: 0x%08x\n", id_pfr1);
|
|
|
|
/* Generic Timer Extension available? */
|
2016-03-29 15:29:10 +00:00
|
|
|
if ((id_pfr1 >> CPUID_ARM_GENTIMER_SHIFT) & 0xf) {
|
|
|
|
uint32_t freq;
|
|
|
|
|
2014-05-05 10:52:26 +00:00
|
|
|
debug("Setting CNTFRQ\n");
|
2016-03-29 15:29:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CNTFRQ is a secure register, so we will crash if we try to
|
|
|
|
* write this from the non-secure world (read is OK, though).
|
|
|
|
* In case some bootcode has already set the correct value,
|
|
|
|
* we avoid the risk of writing to it.
|
|
|
|
*/
|
|
|
|
asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r"(freq));
|
2022-04-13 09:47:22 +00:00
|
|
|
if (freq != CONFIG_COUNTER_FREQUENCY) {
|
2016-03-29 15:29:10 +00:00
|
|
|
debug("arch timer frequency is %d Hz, should be %d, fixing ...\n",
|
2022-04-13 09:47:22 +00:00
|
|
|
freq, CONFIG_COUNTER_FREQUENCY);
|
2016-03-29 15:29:10 +00:00
|
|
|
#ifdef CONFIG_NON_SECURE
|
|
|
|
printf("arch timer frequency is wrong, but cannot adjust it\n");
|
|
|
|
#else
|
|
|
|
asm volatile("mcr p15, 0, %0, c14, c0, 0"
|
2022-04-13 09:47:22 +00:00
|
|
|
: : "r"(CONFIG_COUNTER_FREQUENCY));
|
2016-03-29 15:29:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
2014-05-05 10:52:26 +00:00
|
|
|
}
|
2022-01-29 15:23:05 +00:00
|
|
|
#endif /* !CONFIG_ARM64 && !CONFIG_MACH_SUNIV */
|
2014-05-05 10:52:26 +00:00
|
|
|
|
2015-04-25 15:25:14 +00:00
|
|
|
ret = axp_gpio_init();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2021-01-18 23:23:59 +00:00
|
|
|
/* strcmp() would look better, but doesn't get optimised away. */
|
|
|
|
if (CONFIG_SATAPWR[0]) {
|
|
|
|
satapwr_pin = sunxi_name_to_gpio(CONFIG_SATAPWR);
|
|
|
|
if (satapwr_pin >= 0) {
|
|
|
|
gpio_request(satapwr_pin, "satapwr");
|
|
|
|
gpio_direction_output(satapwr_pin, 1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Give the attached SATA device time to power-up
|
|
|
|
* to avoid link timeouts
|
|
|
|
*/
|
|
|
|
mdelay(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CONFIG_MACPWR[0]) {
|
|
|
|
macpwr_pin = sunxi_name_to_gpio(CONFIG_MACPWR);
|
|
|
|
if (macpwr_pin >= 0) {
|
|
|
|
gpio_request(macpwr_pin, "macpwr");
|
|
|
|
gpio_direction_output(macpwr_pin, 1);
|
|
|
|
}
|
|
|
|
}
|
2016-03-17 12:53:03 +00:00
|
|
|
|
2021-02-09 11:52:45 +00:00
|
|
|
#if CONFIG_IS_ENABLED(DM_I2C)
|
2017-04-26 22:03:36 +00:00
|
|
|
/*
|
|
|
|
* Temporary workaround for enabling I2C clocks until proper sunxi DM
|
|
|
|
* clk, reset and pinctrl drivers land.
|
|
|
|
*/
|
|
|
|
i2c_init_board();
|
|
|
|
#endif
|
|
|
|
|
2022-03-15 00:00:53 +00:00
|
|
|
eth_init_board();
|
|
|
|
|
2021-10-08 05:17:24 +00:00
|
|
|
return 0;
|
2014-05-05 10:52:26 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 09:23:04 +00:00
|
|
|
/*
|
|
|
|
* On older SoCs the SPL is actually at address zero, so using NULL as
|
|
|
|
* an error value does not work.
|
|
|
|
*/
|
|
|
|
#define INVALID_SPL_HEADER ((void *)~0UL)
|
|
|
|
|
|
|
|
static struct boot_file_head * get_spl_header(uint8_t req_version)
|
|
|
|
{
|
|
|
|
struct boot_file_head *spl = (void *)(ulong)SPL_ADDR;
|
|
|
|
uint8_t spl_header_version = spl->spl_signature[3];
|
|
|
|
|
|
|
|
/* Is there really the SPL header (still) there? */
|
|
|
|
if (memcmp(spl->spl_signature, SPL_SIGNATURE, 3) != 0)
|
|
|
|
return INVALID_SPL_HEADER;
|
|
|
|
|
|
|
|
if (spl_header_version < req_version) {
|
|
|
|
printf("sunxi SPL version mismatch: expected %u, got %u\n",
|
|
|
|
req_version, spl_header_version);
|
|
|
|
return INVALID_SPL_HEADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return spl;
|
|
|
|
}
|
|
|
|
|
2020-10-24 15:21:50 +00:00
|
|
|
static const char *get_spl_dt_name(void)
|
|
|
|
{
|
|
|
|
struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION);
|
|
|
|
|
|
|
|
/* Check if there is a DT name stored in the SPL header. */
|
|
|
|
if (spl != INVALID_SPL_HEADER && spl->dt_name_offset)
|
|
|
|
return (char *)spl + spl->dt_name_offset;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:52:26 +00:00
|
|
|
int dram_init(void)
|
|
|
|
{
|
sunxi: store DRAM size in SPL header
At the moment we rely on the infamous get_ram_size() function to learn
the actual DRAM size in U-Boot proper. This function has two issues:
1) It only works if the DRAM size is a power of two. We start to see
boards which have 3GB of (usable) DRAM, so this does not fit anymore.
2) As U-Boot has no notion of reserved memory so far, it will happily
ride through the DRAM, possibly stepping on secure-only memory. This
could be a region of DRAM reserved for OP-TEE or some other secure
payload, for instance. It will most likely crash in that case.
As the SPL DRAM init routine has very accurate knowledge of the actual
DRAM size, lets propagate this wisdom to U-Boot proper.
We re-purpose a currently reserved word in our SPL header for that.
The SPL itself stores the detected DRAM size there, and bumps the SPL
header version number in that case. U-Boot proper checks for a valid
SPL header and a high enough version number, then uses the DRAM size
from there. If the SPL header field is not sufficient, we fall back to
the old DRAM scanning routine.
Part of the DRAM might be present and probed by SPL, but not accessible
by the CPU. They're restricted in the main U-Boot binary, when accessing
the DRAM size from SPL header.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
2018-10-25 09:23:07 +00:00
|
|
|
struct boot_file_head *spl = get_spl_header(SPL_DRAM_HEADER_VERSION);
|
|
|
|
|
|
|
|
if (spl == INVALID_SPL_HEADER)
|
|
|
|
gd->ram_size = get_ram_size((long *)PHYS_SDRAM_0,
|
|
|
|
PHYS_SDRAM_0_SIZE);
|
|
|
|
else
|
|
|
|
gd->ram_size = (phys_addr_t)spl->dram_size << 20;
|
|
|
|
|
|
|
|
if (gd->ram_size > CONFIG_SUNXI_DRAM_MAX_SIZE)
|
|
|
|
gd->ram_size = CONFIG_SUNXI_DRAM_MAX_SIZE;
|
2014-05-05 10:52:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-15 19:09:23 +00:00
|
|
|
#if defined(CONFIG_NAND_SUNXI)
|
2015-07-23 12:33:01 +00:00
|
|
|
static void nand_pinmux_setup(void)
|
|
|
|
{
|
|
|
|
unsigned int pin;
|
|
|
|
|
2015-08-15 11:17:49 +00:00
|
|
|
for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(19); pin++)
|
2015-07-23 12:33:01 +00:00
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_NAND);
|
|
|
|
|
2015-08-15 11:17:49 +00:00
|
|
|
#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN7I
|
|
|
|
for (pin = SUNXI_GPC(20); pin <= SUNXI_GPC(22); pin++)
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_NAND);
|
|
|
|
#endif
|
|
|
|
/* sun4i / sun7i do have a PC23, but it is not used for nand,
|
|
|
|
* only sun7i has a PC24 */
|
|
|
|
#ifdef CONFIG_MACH_SUN7I
|
2015-07-23 12:33:01 +00:00
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_NAND);
|
2015-08-15 11:17:49 +00:00
|
|
|
#endif
|
2015-07-23 12:33:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void nand_clock_setup(void)
|
|
|
|
{
|
|
|
|
struct sunxi_ccm_reg *const ccm =
|
|
|
|
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
|
2015-08-15 09:58:03 +00:00
|
|
|
|
2015-07-23 12:33:01 +00:00
|
|
|
setbits_le32(&ccm->ahb_gate0, (CLK_GATE_OPEN << AHB_GATE_OFFSET_NAND0));
|
2018-02-28 19:51:53 +00:00
|
|
|
#if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I || \
|
|
|
|
defined CONFIG_MACH_SUN9I || defined CONFIG_MACH_SUN50I
|
|
|
|
setbits_le32(&ccm->ahb_reset0_cfg, (1 << AHB_GATE_OFFSET_NAND0));
|
2015-08-15 09:58:03 +00:00
|
|
|
#endif
|
2015-07-23 12:33:01 +00:00
|
|
|
setbits_le32(&ccm->nand0_clk_cfg, CCM_NAND_CTRL_ENABLE | AHB_DIV_1);
|
|
|
|
}
|
2015-08-15 09:55:26 +00:00
|
|
|
|
|
|
|
void board_nand_init(void)
|
|
|
|
{
|
|
|
|
nand_pinmux_setup();
|
|
|
|
nand_clock_setup();
|
2016-06-15 19:09:23 +00:00
|
|
|
#ifndef CONFIG_SPL_BUILD
|
|
|
|
sunxi_nand_init();
|
|
|
|
#endif
|
2015-08-15 09:55:26 +00:00
|
|
|
}
|
2022-11-28 00:02:56 +00:00
|
|
|
#endif /* CONFIG_NAND_SUNXI */
|
2015-07-23 12:33:01 +00:00
|
|
|
|
2017-05-09 11:31:39 +00:00
|
|
|
#ifdef CONFIG_MMC
|
2014-05-05 13:42:31 +00:00
|
|
|
static void mmc_pinmux_setup(int sdc)
|
|
|
|
{
|
|
|
|
unsigned int pin;
|
|
|
|
|
|
|
|
switch (sdc) {
|
|
|
|
case 0:
|
2015-03-22 17:12:23 +00:00
|
|
|
/* SDC0: PF0-PF5 */
|
2014-05-05 13:42:31 +00:00
|
|
|
for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
|
2015-03-22 17:12:22 +00:00
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPF_SDC0);
|
2014-05-05 13:42:31 +00:00
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2016-11-30 08:28:34 +00:00
|
|
|
#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I) || \
|
|
|
|
defined(CONFIG_MACH_SUN8I_R40)
|
2021-09-12 15:28:35 +00:00
|
|
|
if (IS_ENABLED(CONFIG_MMC1_PINS_PH)) {
|
2015-03-22 17:12:23 +00:00
|
|
|
/* SDC1: PH22-PH-27 */
|
|
|
|
for (pin = SUNXI_GPH(22); pin <= SUNXI_GPH(27); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUN4I_GPH_SDC1);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* SDC1: PG0-PG5 */
|
|
|
|
for (pin = SUNXI_GPG(0); pin <= SUNXI_GPG(5); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUN4I_GPG_SDC1);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(CONFIG_MACH_SUN5I)
|
|
|
|
/* SDC1: PG3-PG8 */
|
2014-10-03 14:44:57 +00:00
|
|
|
for (pin = SUNXI_GPG(3); pin <= SUNXI_GPG(8); pin++) {
|
2015-03-22 17:12:22 +00:00
|
|
|
sunxi_gpio_set_cfgpin(pin, SUN5I_GPG_SDC1);
|
2014-05-05 13:42:31 +00:00
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
2015-03-22 17:12:23 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN6I)
|
|
|
|
/* SDC1: PG0-PG5 */
|
|
|
|
for (pin = SUNXI_GPG(0); pin <= SUNXI_GPG(5); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUN6I_GPG_SDC1);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
|
|
|
#elif defined(CONFIG_MACH_SUN8I)
|
2021-09-12 15:28:35 +00:00
|
|
|
/* SDC1: PG0-PG5 */
|
|
|
|
for (pin = SUNXI_GPG(0); pin <= SUNXI_GPG(5); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUN8I_GPG_SDC1);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
2015-03-22 17:12:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
2014-05-05 13:42:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2015-03-22 17:12:23 +00:00
|
|
|
#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I)
|
|
|
|
/* SDC2: PC6-PC11 */
|
2014-05-05 13:42:31 +00:00
|
|
|
for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(11); pin++) {
|
2015-03-22 17:12:22 +00:00
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
2014-05-05 13:42:31 +00:00
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
2015-03-22 17:12:23 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN5I)
|
2021-09-12 15:28:35 +00:00
|
|
|
/* SDC2: PC6-PC15 */
|
|
|
|
for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
2015-03-22 17:12:23 +00:00
|
|
|
}
|
|
|
|
#elif defined(CONFIG_MACH_SUN6I)
|
2021-09-12 15:28:35 +00:00
|
|
|
/* SDC2: PC6-PC15, PC24 */
|
|
|
|
for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
2015-03-22 17:12:23 +00:00
|
|
|
}
|
2021-09-12 15:28:35 +00:00
|
|
|
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
|
2016-11-30 08:28:34 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN8I_R40)
|
|
|
|
/* SDC2: PC6-PC15, PC24 */
|
|
|
|
for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
|
2016-03-29 15:29:10 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN8I) || defined(CONFIG_MACH_SUN50I)
|
2015-03-22 17:12:23 +00:00
|
|
|
/* SDC2: PC5-PC6, PC8-PC16 */
|
|
|
|
for (pin = SUNXI_GPC(5); pin <= SUNXI_GPC(6); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pin = SUNXI_GPC(8); pin <= SUNXI_GPC(16); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
2018-07-21 08:20:29 +00:00
|
|
|
}
|
|
|
|
#elif defined(CONFIG_MACH_SUN50I_H6)
|
|
|
|
/* SDC2: PC4-PC14 */
|
|
|
|
for (pin = SUNXI_GPC(4); pin <= SUNXI_GPC(14); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
2015-03-22 17:12:23 +00:00
|
|
|
}
|
2021-04-25 23:38:04 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN50I_H616)
|
|
|
|
/* SDC2: PC0-PC1, PC5-PC6, PC8-PC11, PC13-PC16 */
|
|
|
|
for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(16); pin++) {
|
|
|
|
if (pin > SUNXI_GPC(1) && pin < SUNXI_GPC(5))
|
|
|
|
continue;
|
|
|
|
if (pin == SUNXI_GPC(7) || pin == SUNXI_GPC(12))
|
|
|
|
continue;
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 3);
|
|
|
|
}
|
2016-10-28 10:21:33 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN9I)
|
|
|
|
/* SDC2: PC6-PC16 */
|
|
|
|
for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(16); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPC_SDC2);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
2021-04-25 23:38:04 +00:00
|
|
|
#else
|
|
|
|
puts("ERROR: No pinmux setup defined for MMC2!\n");
|
2015-03-22 17:12:23 +00:00
|
|
|
#endif
|
2014-05-05 13:42:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2016-11-30 08:28:34 +00:00
|
|
|
#if defined(CONFIG_MACH_SUN4I) || defined(CONFIG_MACH_SUN7I) || \
|
|
|
|
defined(CONFIG_MACH_SUN8I_R40)
|
2015-03-22 17:12:23 +00:00
|
|
|
/* SDC3: PI4-PI9 */
|
2014-05-05 13:42:31 +00:00
|
|
|
for (pin = SUNXI_GPI(4); pin <= SUNXI_GPI(9); pin++) {
|
2015-03-22 17:12:23 +00:00
|
|
|
sunxi_gpio_set_cfgpin(pin, SUNXI_GPI_SDC3);
|
2014-05-05 13:42:31 +00:00
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
|
|
|
}
|
2015-03-22 17:12:23 +00:00
|
|
|
#elif defined(CONFIG_MACH_SUN6I)
|
2021-09-12 15:28:35 +00:00
|
|
|
/* SDC3: PC6-PC15, PC24 */
|
|
|
|
for (pin = SUNXI_GPC(6); pin <= SUNXI_GPC(15); pin++) {
|
|
|
|
sunxi_gpio_set_cfgpin(pin, SUN6I_GPC_SDC3);
|
|
|
|
sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(pin, 2);
|
2015-03-22 17:12:23 +00:00
|
|
|
}
|
2021-09-12 15:28:35 +00:00
|
|
|
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPC(24), SUN6I_GPC_SDC3);
|
|
|
|
sunxi_gpio_set_pull(SUNXI_GPC(24), SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_drv(SUNXI_GPC(24), 2);
|
2015-03-22 17:12:23 +00:00
|
|
|
#endif
|
2014-05-05 13:42:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("sunxi: invalid MMC slot %d for pinmux setup\n", sdc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int board_mmc_init(struct bd_info *bis)
|
2014-05-05 13:42:31 +00:00
|
|
|
{
|
2022-11-28 00:03:53 +00:00
|
|
|
/*
|
|
|
|
* The BROM always accesses MMC port 0 (typically an SD card), and
|
|
|
|
* most boards seem to have such a slot. The others haven't reported
|
|
|
|
* any problem with unconditionally enabling this in the SPL.
|
|
|
|
*/
|
2022-04-10 05:13:33 +00:00
|
|
|
if (!IS_ENABLED(CONFIG_UART0_PORT_F)) {
|
2022-11-28 00:03:53 +00:00
|
|
|
mmc_pinmux_setup(0);
|
|
|
|
if (!sunxi_mmc_init(0))
|
2022-04-10 05:13:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2014-10-02 19:13:54 +00:00
|
|
|
|
2022-04-10 05:13:33 +00:00
|
|
|
if (CONFIG_MMC_SUNXI_SLOT_EXTRA != -1) {
|
|
|
|
mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT_EXTRA);
|
|
|
|
if (!sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT_EXTRA))
|
|
|
|
return -1;
|
|
|
|
}
|
2014-10-02 19:13:54 +00:00
|
|
|
|
2014-05-05 13:42:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2021-04-19 03:16:21 +00:00
|
|
|
|
|
|
|
#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
|
|
|
|
int mmc_get_env_dev(void)
|
|
|
|
{
|
|
|
|
switch (sunxi_get_boot_device()) {
|
|
|
|
case BOOT_DEVICE_MMC1:
|
|
|
|
return 0;
|
|
|
|
case BOOT_DEVICE_MMC2:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return CONFIG_SYS_MMC_ENV_DEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2022-11-28 00:02:56 +00:00
|
|
|
#endif /* CONFIG_MMC */
|
2014-05-05 13:42:31 +00:00
|
|
|
|
2014-05-05 10:52:26 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
sunxi: store DRAM size in SPL header
At the moment we rely on the infamous get_ram_size() function to learn
the actual DRAM size in U-Boot proper. This function has two issues:
1) It only works if the DRAM size is a power of two. We start to see
boards which have 3GB of (usable) DRAM, so this does not fit anymore.
2) As U-Boot has no notion of reserved memory so far, it will happily
ride through the DRAM, possibly stepping on secure-only memory. This
could be a region of DRAM reserved for OP-TEE or some other secure
payload, for instance. It will most likely crash in that case.
As the SPL DRAM init routine has very accurate knowledge of the actual
DRAM size, lets propagate this wisdom to U-Boot proper.
We re-purpose a currently reserved word in our SPL header for that.
The SPL itself stores the detected DRAM size there, and bumps the SPL
header version number in that case. U-Boot proper checks for a valid
SPL header and a high enough version number, then uses the DRAM size
from there. If the SPL header field is not sufficient, we fall back to
the old DRAM scanning routine.
Part of the DRAM might be present and probed by SPL, but not accessible
by the CPU. They're restricted in the main U-Boot binary, when accessing
the DRAM size from SPL header.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
2018-10-25 09:23:07 +00:00
|
|
|
|
|
|
|
static void sunxi_spl_store_dram_size(phys_addr_t dram_size)
|
|
|
|
{
|
|
|
|
struct boot_file_head *spl = get_spl_header(SPL_DT_HEADER_VERSION);
|
|
|
|
|
|
|
|
if (spl == INVALID_SPL_HEADER)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Promote the header version for U-Boot proper, if needed. */
|
|
|
|
if (spl->spl_signature[3] < SPL_DRAM_HEADER_VERSION)
|
|
|
|
spl->spl_signature[3] = SPL_DRAM_HEADER_VERSION;
|
|
|
|
|
|
|
|
spl->dram_size = dram_size >> 20;
|
|
|
|
}
|
|
|
|
|
2014-05-05 10:52:26 +00:00
|
|
|
void sunxi_board_init(void)
|
|
|
|
{
|
2014-06-13 20:55:50 +00:00
|
|
|
int power_failed = 0;
|
2014-05-05 10:52:26 +00:00
|
|
|
|
2021-09-08 19:14:19 +00:00
|
|
|
#ifdef CONFIG_LED_STATUS
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_DRIVERS_MISC))
|
|
|
|
status_led_init();
|
|
|
|
#endif
|
|
|
|
|
2016-02-23 17:47:19 +00:00
|
|
|
#ifdef CONFIG_SY8106A_POWER
|
|
|
|
power_failed = sy8106a_set_vout1(CONFIG_SY8106A_VOUT1_VOLT);
|
|
|
|
#endif
|
|
|
|
|
2015-11-28 17:07:22 +00:00
|
|
|
#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
|
2021-01-11 20:11:33 +00:00
|
|
|
defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
|
|
|
|
defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed = axp_init();
|
|
|
|
|
2022-01-21 13:37:32 +00:00
|
|
|
if (IS_ENABLED(CONFIG_AXP_DISABLE_BOOT_ON_POWERON) && !power_failed) {
|
|
|
|
u8 boot_reason;
|
|
|
|
|
|
|
|
pmic_bus_read(AXP_POWER_STATUS, &boot_reason);
|
|
|
|
if (boot_reason & AXP_POWER_STATUS_ALDO_IN) {
|
|
|
|
printf("Power on by plug-in, shutting down.\n");
|
|
|
|
pmic_bus_write(0x32, BIT(7));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-02 02:28:15 +00:00
|
|
|
#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
|
|
|
|
defined CONFIG_AXP818_POWER
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
|
2014-06-13 20:55:51 +00:00
|
|
|
#endif
|
2021-01-11 20:11:33 +00:00
|
|
|
#if !defined(CONFIG_AXP305_POWER)
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
|
|
|
|
power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
|
2021-01-11 20:11:33 +00:00
|
|
|
#endif
|
2015-11-28 17:07:22 +00:00
|
|
|
#if !defined(CONFIG_AXP209_POWER) && !defined(CONFIG_AXP818_POWER)
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
|
2013-07-26 10:56:58 +00:00
|
|
|
#endif
|
2016-05-02 02:28:15 +00:00
|
|
|
#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
|
|
|
|
defined CONFIG_AXP818_POWER
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
|
2014-06-13 20:55:50 +00:00
|
|
|
#endif
|
|
|
|
|
2016-05-02 02:28:15 +00:00
|
|
|
#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || \
|
|
|
|
defined CONFIG_AXP818_POWER
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
|
|
|
|
#endif
|
2021-01-11 20:11:33 +00:00
|
|
|
#if !defined(CONFIG_AXP305_POWER)
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
|
2021-01-11 20:11:33 +00:00
|
|
|
#endif
|
|
|
|
#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP305_POWER)
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_AXP209_POWER
|
|
|
|
power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);
|
|
|
|
#endif
|
|
|
|
|
2016-05-02 02:28:15 +00:00
|
|
|
#if defined(CONFIG_AXP221_POWER) || defined(CONFIG_AXP809_POWER) || \
|
|
|
|
defined(CONFIG_AXP818_POWER)
|
2016-01-12 06:42:37 +00:00
|
|
|
power_failed |= axp_set_dldo(1, CONFIG_AXP_DLDO1_VOLT);
|
|
|
|
power_failed |= axp_set_dldo(2, CONFIG_AXP_DLDO2_VOLT);
|
2016-05-02 02:28:15 +00:00
|
|
|
#if !defined CONFIG_AXP809_POWER
|
2016-01-12 06:42:37 +00:00
|
|
|
power_failed |= axp_set_dldo(3, CONFIG_AXP_DLDO3_VOLT);
|
|
|
|
power_failed |= axp_set_dldo(4, CONFIG_AXP_DLDO4_VOLT);
|
2016-05-02 02:28:15 +00:00
|
|
|
#endif
|
2015-10-03 13:18:33 +00:00
|
|
|
power_failed |= axp_set_eldo(1, CONFIG_AXP_ELDO1_VOLT);
|
|
|
|
power_failed |= axp_set_eldo(2, CONFIG_AXP_ELDO2_VOLT);
|
|
|
|
power_failed |= axp_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);
|
|
|
|
#endif
|
2016-03-29 16:26:48 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_AXP818_POWER
|
|
|
|
power_failed |= axp_set_fldo(1, CONFIG_AXP_FLDO1_VOLT);
|
|
|
|
power_failed |= axp_set_fldo(2, CONFIG_AXP_FLDO2_VOLT);
|
|
|
|
power_failed |= axp_set_fldo(3, CONFIG_AXP_FLDO3_VOLT);
|
2016-05-02 02:28:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
|
2016-05-02 02:28:12 +00:00
|
|
|
power_failed |= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON));
|
2016-03-29 16:26:48 +00:00
|
|
|
#endif
|
2015-10-03 13:18:33 +00:00
|
|
|
#endif
|
2018-12-19 13:00:39 +00:00
|
|
|
printf("DRAM:");
|
|
|
|
gd->ram_size = sunxi_dram_init();
|
|
|
|
printf(" %d MiB\n", (int)(gd->ram_size >> 20));
|
|
|
|
if (!gd->ram_size)
|
|
|
|
hang();
|
|
|
|
|
|
|
|
sunxi_spl_store_dram_size(gd->ram_size);
|
sunxi: store DRAM size in SPL header
At the moment we rely on the infamous get_ram_size() function to learn
the actual DRAM size in U-Boot proper. This function has two issues:
1) It only works if the DRAM size is a power of two. We start to see
boards which have 3GB of (usable) DRAM, so this does not fit anymore.
2) As U-Boot has no notion of reserved memory so far, it will happily
ride through the DRAM, possibly stepping on secure-only memory. This
could be a region of DRAM reserved for OP-TEE or some other secure
payload, for instance. It will most likely crash in that case.
As the SPL DRAM init routine has very accurate knowledge of the actual
DRAM size, lets propagate this wisdom to U-Boot proper.
We re-purpose a currently reserved word in our SPL header for that.
The SPL itself stores the detected DRAM size there, and bumps the SPL
header version number in that case. U-Boot proper checks for a valid
SPL header and a high enough version number, then uses the DRAM size
from there. If the SPL header field is not sufficient, we fall back to
the old DRAM scanning routine.
Part of the DRAM might be present and probed by SPL, but not accessible
by the CPU. They're restricted in the main U-Boot binary, when accessing
the DRAM size from SPL header.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
2018-10-25 09:23:07 +00:00
|
|
|
|
2014-06-13 20:55:50 +00:00
|
|
|
/*
|
|
|
|
* Only clock up the CPU to full speed if we are reasonably
|
|
|
|
* assured it's being powered with suitable core voltage
|
|
|
|
*/
|
|
|
|
if (!power_failed)
|
2021-12-14 18:36:40 +00:00
|
|
|
clock_set_pll1(get_board_sys_clk());
|
2014-06-13 20:55:50 +00:00
|
|
|
else
|
2018-12-19 13:00:39 +00:00
|
|
|
printf("Failed to set core voltage! Can't set CPU frequency\n");
|
2014-05-05 10:52:26 +00:00
|
|
|
}
|
2022-11-28 00:02:56 +00:00
|
|
|
#endif /* CONFIG_SPL_BUILD */
|
2014-06-14 06:59:09 +00:00
|
|
|
|
2015-03-22 17:07:13 +00:00
|
|
|
#ifdef CONFIG_USB_GADGET
|
|
|
|
int g_dnl_board_usb_cable_connected(void)
|
|
|
|
{
|
2018-05-07 07:33:36 +00:00
|
|
|
struct udevice *dev;
|
|
|
|
struct phy phy;
|
|
|
|
int ret;
|
|
|
|
|
2018-11-29 09:52:46 +00:00
|
|
|
ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev);
|
2018-05-07 07:33:36 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Cannot find USB device\n", __func__);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = generic_phy_get_by_name(dev, "usb", &phy);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("failed to get %s USB PHY\n", dev->name);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = generic_phy_init(&phy);
|
|
|
|
if (ret) {
|
2020-07-03 15:36:41 +00:00
|
|
|
pr_debug("failed to init %s USB PHY\n", dev->name);
|
2018-05-07 07:33:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
sunxi: Remove misleading USB-OTG charger message
The sunxi MUSB glue driver has some code to check for external VBUS
presence when it's going to use the MUSB host mode, and it warns if
there is VBUS provided through the cable (in sunxi_musb_enable()).
This code was apparently copied to the USB gadget detection code
(g_dnl_board_usb_cable_connected()), but here we actually *expect*
external VBUS power, so a warning is wrong and confusing.
So far this message rarely triggered, but a recent patch (6fa41cdd19b9)
changed this:
===========================
=> ums 0 mmc 2
UMS: LUN 0, dev mmc 2, hwpart 0, sector 0x0, count 0xe90000
A charger is plugged into the OTG
/A charger is plugged into the OTG
\A charger is plugged into the OTG
|A charger is plugged into the OTG
-A charger is plugged into the OTG
....
===========================
Remove the message for the gadget cable detection call, and just return
the status of the VBUS detection, as this is what the callers are after.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2021-11-02 19:45:47 +00:00
|
|
|
return sun4i_usb_phy_vbus_detect(&phy);
|
2015-03-22 17:07:13 +00:00
|
|
|
}
|
2022-11-28 00:02:56 +00:00
|
|
|
#endif /* CONFIG_USB_GADGET */
|
2015-03-22 17:07:13 +00:00
|
|
|
|
2015-03-28 17:35:36 +00:00
|
|
|
#ifdef CONFIG_SERIAL_TAG
|
|
|
|
void get_board_serial(struct tag_serialnr *serialnr)
|
|
|
|
{
|
|
|
|
char *serial_string;
|
|
|
|
unsigned long long serial;
|
|
|
|
|
2017-08-03 18:22:12 +00:00
|
|
|
serial_string = env_get("serial#");
|
2015-03-28 17:35:36 +00:00
|
|
|
|
|
|
|
if (serial_string) {
|
|
|
|
serial = simple_strtoull(serial_string, NULL, 16);
|
|
|
|
|
|
|
|
serialnr->high = (unsigned int) (serial >> 32);
|
|
|
|
serialnr->low = (unsigned int) (serial & 0xffffffff);
|
|
|
|
} else {
|
|
|
|
serialnr->high = 0;
|
|
|
|
serialnr->low = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-09-17 16:52:52 +00:00
|
|
|
/*
|
|
|
|
* Check the SPL header for the "sunxi" variant. If found: parse values
|
|
|
|
* that might have been passed by the loader ("fel" utility), and update
|
|
|
|
* the environment accordingly.
|
|
|
|
*/
|
|
|
|
static void parse_spl_header(const uint32_t spl_addr)
|
|
|
|
{
|
2018-10-25 09:23:04 +00:00
|
|
|
struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION);
|
2016-06-09 05:37:35 +00:00
|
|
|
|
2018-10-25 09:23:04 +00:00
|
|
|
if (spl == INVALID_SPL_HEADER)
|
2016-06-09 05:37:35 +00:00
|
|
|
return;
|
2018-10-25 09:23:04 +00:00
|
|
|
|
2016-06-09 05:37:35 +00:00
|
|
|
if (!spl->fel_script_address)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (spl->fel_uEnv_length != 0) {
|
|
|
|
/*
|
|
|
|
* data is expected in uEnv.txt compatible format, so "env
|
|
|
|
* import -t" the string(s) at fel_script_address right away.
|
|
|
|
*/
|
2016-09-05 00:32:41 +00:00
|
|
|
himport_r(&env_htab, (char *)(uintptr_t)spl->fel_script_address,
|
2016-06-09 05:37:35 +00:00
|
|
|
spl->fel_uEnv_length, '\n', H_NOCLEAR, 0, 0, NULL);
|
|
|
|
return;
|
2015-09-17 16:52:52 +00:00
|
|
|
}
|
2016-06-09 05:37:35 +00:00
|
|
|
/* otherwise assume .scr format (mkimage-type script) */
|
2017-08-03 18:22:10 +00:00
|
|
|
env_set_hex("fel_scriptaddr", spl->fel_script_address);
|
2015-09-17 16:52:52 +00:00
|
|
|
}
|
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
static bool get_unique_sid(unsigned int *sid)
|
|
|
|
{
|
|
|
|
if (sunxi_get_sid(sid) != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!sid[0])
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The single words 1 - 3 of the SID have quite a few bits
|
|
|
|
* which are the same on many models, so we take a crc32
|
|
|
|
* of all 3 words, to get a more unique value.
|
|
|
|
*
|
|
|
|
* Note we only do this on newer SoCs as we cannot change
|
|
|
|
* the algorithm on older SoCs since those have been using
|
|
|
|
* fixed mac-addresses based on only using word 3 for a
|
|
|
|
* long time and changing a fixed mac-address with an
|
|
|
|
* u-boot update is not good.
|
|
|
|
*/
|
|
|
|
#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \
|
|
|
|
!defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \
|
|
|
|
!defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)
|
|
|
|
sid[3] = crc32(0, (unsigned char *)&sid[1], 12);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Ensure the NIC specific bytes of the mac are not all 0 */
|
|
|
|
if ((sid[3] & 0xffffff) == 0)
|
|
|
|
sid[3] |= 0x800000;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-26 11:34:42 +00:00
|
|
|
/*
|
|
|
|
* Note this function gets called multiple times.
|
|
|
|
* It must not make any changes to env variables which already exist.
|
|
|
|
*/
|
|
|
|
static void setup_environment(const void *fdt)
|
2014-06-14 06:59:09 +00:00
|
|
|
{
|
2015-03-28 17:35:35 +00:00
|
|
|
char serial_string[17] = { 0 };
|
2014-11-25 23:04:24 +00:00
|
|
|
unsigned int sid[4];
|
2015-03-28 17:35:35 +00:00
|
|
|
uint8_t mac_addr[6];
|
2016-06-26 11:34:42 +00:00
|
|
|
char ethaddr[16];
|
2021-10-01 18:29:00 +00:00
|
|
|
int i;
|
2016-07-29 09:47:03 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
if (!get_unique_sid(sid))
|
|
|
|
return;
|
2016-07-27 15:58:06 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
sprintf(ethaddr, "ethernet%d", i);
|
|
|
|
if (!fdt_get_alias(fdt, ethaddr))
|
|
|
|
continue;
|
2016-06-26 11:34:42 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
if (i == 0)
|
|
|
|
strcpy(ethaddr, "ethaddr");
|
|
|
|
else
|
|
|
|
sprintf(ethaddr, "eth%daddr", i);
|
2016-06-26 11:34:42 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
if (env_get(ethaddr))
|
|
|
|
continue;
|
2016-06-26 11:34:42 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
/* Non OUI / registered MAC address */
|
|
|
|
mac_addr[0] = (i << 4) | 0x02;
|
|
|
|
mac_addr[1] = (sid[0] >> 0) & 0xff;
|
|
|
|
mac_addr[2] = (sid[3] >> 24) & 0xff;
|
|
|
|
mac_addr[3] = (sid[3] >> 16) & 0xff;
|
|
|
|
mac_addr[4] = (sid[3] >> 8) & 0xff;
|
|
|
|
mac_addr[5] = (sid[3] >> 0) & 0xff;
|
2015-03-28 17:35:35 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
eth_env_set_enetaddr(ethaddr, mac_addr);
|
|
|
|
}
|
2014-06-14 06:59:09 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
if (!env_get("serial#")) {
|
|
|
|
snprintf(serial_string, sizeof(serial_string),
|
|
|
|
"%08x%08x", sid[0], sid[3]);
|
2014-06-14 06:59:09 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
env_set("serial#", serial_string);
|
2014-06-14 06:59:09 +00:00
|
|
|
}
|
2016-06-26 11:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
2020-10-24 15:21:54 +00:00
|
|
|
const char *spl_dt_name;
|
2017-08-23 08:08:29 +00:00
|
|
|
uint boot;
|
2016-06-26 11:34:42 +00:00
|
|
|
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("fel_booted", NULL);
|
|
|
|
env_set("fel_scriptaddr", NULL);
|
sunxi: Remove the MMC index hack
The current code, if there's both an eMMC and an MMC slot available on the
board, will swap the MMC indices based on whether we booted from the eMMC
or the MMC. This way, the MMC we're supposed to boot on will always have
the index 0.
However, this causes various issues, for example when using other
components that base their behaviour on the MMC index, such as fastboot.
Let's remove that hack, and take the opposite approach. The MMC will always
have the same index, but the bootcmd will pick the same device than the one
we booted from. This is done through the introduction of the mmc_bootdev
environment variable that will be filled by the board code based on the
boot device informations we can get from the SoC.
In order to not introduce regressions, we also need to adjust the fastboot
MMC device and the environment device in order to set it to the eMMC, over
the MMC, like it used to be the case.
Tested-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-08-23 08:12:22 +00:00
|
|
|
env_set("mmc_bootdev", NULL);
|
2017-08-23 08:08:29 +00:00
|
|
|
|
|
|
|
boot = sunxi_get_boot_device();
|
2016-06-26 11:34:42 +00:00
|
|
|
/* determine if we are running in FEL mode */
|
2017-08-23 08:08:29 +00:00
|
|
|
if (boot == BOOT_DEVICE_BOARD) {
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("fel_booted", "1");
|
2016-06-26 11:34:42 +00:00
|
|
|
parse_spl_header(SPL_ADDR);
|
sunxi: Remove the MMC index hack
The current code, if there's both an eMMC and an MMC slot available on the
board, will swap the MMC indices based on whether we booted from the eMMC
or the MMC. This way, the MMC we're supposed to boot on will always have
the index 0.
However, this causes various issues, for example when using other
components that base their behaviour on the MMC index, such as fastboot.
Let's remove that hack, and take the opposite approach. The MMC will always
have the same index, but the bootcmd will pick the same device than the one
we booted from. This is done through the introduction of the mmc_bootdev
environment variable that will be filled by the board code based on the
boot device informations we can get from the SoC.
In order to not introduce regressions, we also need to adjust the fastboot
MMC device and the environment device in order to set it to the eMMC, over
the MMC, like it used to be the case.
Tested-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-08-23 08:12:22 +00:00
|
|
|
/* or if we booted from MMC, and which one */
|
|
|
|
} else if (boot == BOOT_DEVICE_MMC1) {
|
|
|
|
env_set("mmc_bootdev", "0");
|
|
|
|
} else if (boot == BOOT_DEVICE_MMC2) {
|
|
|
|
env_set("mmc_bootdev", "1");
|
2016-06-26 11:34:42 +00:00
|
|
|
}
|
|
|
|
|
2020-10-24 15:21:54 +00:00
|
|
|
/* Set fdtfile to match the FIT configuration chosen in SPL. */
|
|
|
|
spl_dt_name = get_spl_dt_name();
|
|
|
|
if (spl_dt_name) {
|
|
|
|
char *prefix = IS_ENABLED(CONFIG_ARM64) ? "allwinner/" : "";
|
|
|
|
char str[64];
|
|
|
|
|
|
|
|
snprintf(str, sizeof(str), "%s%s.dtb", prefix, spl_dt_name);
|
|
|
|
env_set("fdtfile", str);
|
|
|
|
}
|
|
|
|
|
2016-06-26 11:34:42 +00:00
|
|
|
setup_environment(gd->fdt_blob);
|
2014-06-14 06:59:09 +00:00
|
|
|
|
2020-12-08 15:45:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
2017-09-28 14:16:38 +00:00
|
|
|
#ifdef CONFIG_USB_ETHER
|
2017-09-06 20:25:03 +00:00
|
|
|
usb_ether_init();
|
2017-09-28 14:16:38 +00:00
|
|
|
#endif
|
2017-09-06 20:25:03 +00:00
|
|
|
|
2014-06-14 06:59:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-13 05:55:07 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
static void bluetooth_dt_fixup(void *blob)
|
|
|
|
{
|
|
|
|
/* Some devices ship with a Bluetooth controller default address.
|
|
|
|
* Set a valid address through the device tree.
|
|
|
|
*/
|
|
|
|
uchar tmp[ETH_ALEN], bdaddr[ETH_ALEN];
|
|
|
|
unsigned int sid[4];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!CONFIG_BLUETOOTH_DT_DEVICE_FIXUP[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (eth_env_get_enetaddr("bdaddr", tmp)) {
|
|
|
|
/* Convert between the binary formats of the corresponding stacks */
|
|
|
|
for (i = 0; i < ETH_ALEN; ++i)
|
|
|
|
bdaddr[i] = tmp[ETH_ALEN - i - 1];
|
|
|
|
} else {
|
|
|
|
if (!get_unique_sid(sid))
|
|
|
|
return;
|
|
|
|
|
|
|
|
bdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1;
|
|
|
|
bdaddr[1] = (sid[3] >> 8) & 0xff;
|
|
|
|
bdaddr[2] = (sid[3] >> 16) & 0xff;
|
|
|
|
bdaddr[3] = (sid[3] >> 24) & 0xff;
|
|
|
|
bdaddr[4] = (sid[0] >> 0) & 0xff;
|
|
|
|
bdaddr[5] = 0x02;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_fixup_by_compat(blob, CONFIG_BLUETOOTH_DT_DEVICE_FIXUP,
|
|
|
|
"local-bd-address", bdaddr, ETH_ALEN, 1);
|
|
|
|
}
|
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
int ft_board_setup(void *blob, struct bd_info *bd)
|
2014-08-13 05:55:07 +00:00
|
|
|
{
|
2016-03-22 21:51:52 +00:00
|
|
|
int __maybe_unused r;
|
|
|
|
|
2016-06-26 11:34:42 +00:00
|
|
|
/*
|
2021-09-11 17:39:16 +00:00
|
|
|
* Call setup_environment and fdt_fixup_ethernet again
|
|
|
|
* in case the boot fdt has ethernet aliases the u-boot
|
|
|
|
* copy does not have.
|
2016-06-26 11:34:42 +00:00
|
|
|
*/
|
|
|
|
setup_environment(blob);
|
2021-09-11 17:39:16 +00:00
|
|
|
fdt_fixup_ethernet(blob);
|
2016-06-26 11:34:42 +00:00
|
|
|
|
2021-10-01 18:29:00 +00:00
|
|
|
bluetooth_dt_fixup(blob);
|
|
|
|
|
2014-08-13 05:55:07 +00:00
|
|
|
#ifdef CONFIG_VIDEO_DT_SIMPLEFB
|
2016-03-22 21:51:52 +00:00
|
|
|
r = sunxi_simplefb_setup(blob);
|
|
|
|
if (r)
|
|
|
|
return r;
|
2014-08-13 05:55:07 +00:00
|
|
|
#endif
|
2016-03-22 21:51:52 +00:00
|
|
|
return 0;
|
2014-08-13 05:55:07 +00:00
|
|
|
}
|
2017-04-26 00:32:44 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_LOAD_FIT
|
2020-10-24 15:21:53 +00:00
|
|
|
static void set_spl_dt_name(const char *name)
|
|
|
|
{
|
|
|
|
struct boot_file_head *spl = get_spl_header(SPL_ENV_HEADER_VERSION);
|
|
|
|
|
|
|
|
if (spl == INVALID_SPL_HEADER)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Promote the header version for U-Boot proper, if needed. */
|
|
|
|
if (spl->spl_signature[3] < SPL_DT_HEADER_VERSION)
|
|
|
|
spl->spl_signature[3] = SPL_DT_HEADER_VERSION;
|
|
|
|
|
|
|
|
strcpy((char *)&spl->string_pool, name);
|
|
|
|
spl->dt_name_offset = offsetof(struct boot_file_head, string_pool);
|
|
|
|
}
|
|
|
|
|
2017-04-26 00:32:44 +00:00
|
|
|
int board_fit_config_name_match(const char *name)
|
|
|
|
{
|
2020-10-24 15:21:50 +00:00
|
|
|
const char *best_dt_name = get_spl_dt_name();
|
2020-10-24 15:21:53 +00:00
|
|
|
int ret;
|
2017-04-26 00:32:44 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEFAULT_DEVICE_TREE
|
2020-10-24 15:21:50 +00:00
|
|
|
if (best_dt_name == NULL)
|
2020-10-24 15:21:49 +00:00
|
|
|
best_dt_name = CONFIG_DEFAULT_DEVICE_TREE;
|
2017-04-26 00:32:44 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-24 15:21:50 +00:00
|
|
|
if (best_dt_name == NULL) {
|
|
|
|
/* No DT name was provided, so accept the first config. */
|
|
|
|
return 0;
|
|
|
|
}
|
2018-10-25 09:23:02 +00:00
|
|
|
#ifdef CONFIG_PINE64_DT_SELECTION
|
2020-10-24 15:21:51 +00:00
|
|
|
if (strstr(best_dt_name, "-pine64-plus")) {
|
|
|
|
/* Differentiate the Pine A64 boards by their DRAM size. */
|
|
|
|
if ((gd->ram_size == 512 * 1024 * 1024))
|
|
|
|
best_dt_name = "sun50i-a64-pine64";
|
2017-04-26 00:32:44 +00:00
|
|
|
}
|
2018-10-25 09:23:02 +00:00
|
|
|
#endif
|
2020-10-24 15:21:52 +00:00
|
|
|
#ifdef CONFIG_PINEPHONE_DT_SELECTION
|
|
|
|
if (strstr(best_dt_name, "-pinephone")) {
|
|
|
|
/* Differentiate the PinePhone revisions by GPIO inputs. */
|
|
|
|
prcm_apb0_enable(PRCM_APB0_GATE_PIO);
|
|
|
|
sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_UP);
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_INPUT);
|
|
|
|
udelay(100);
|
|
|
|
|
|
|
|
/* PL6 is pulled low by the modem on v1.2. */
|
|
|
|
if (gpio_get_value(SUNXI_GPL(6)) == 0)
|
|
|
|
best_dt_name = "sun50i-a64-pinephone-1.2";
|
|
|
|
else
|
|
|
|
best_dt_name = "sun50i-a64-pinephone-1.1";
|
|
|
|
|
|
|
|
sunxi_gpio_set_cfgpin(SUNXI_GPL(6), SUNXI_GPIO_DISABLE);
|
|
|
|
sunxi_gpio_set_pull(SUNXI_GPL(6), SUNXI_GPIO_PULL_DISABLE);
|
|
|
|
prcm_apb0_disable(PRCM_APB0_GATE_PIO);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-10-24 15:21:53 +00:00
|
|
|
ret = strcmp(name, best_dt_name);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If one of the FIT configurations matches the most accurate DT name,
|
|
|
|
* update the SPL header to provide that DT name to U-Boot proper.
|
|
|
|
*/
|
|
|
|
if (ret == 0)
|
|
|
|
set_spl_dt_name(best_dt_name);
|
|
|
|
|
|
|
|
return ret;
|
2017-04-26 00:32:44 +00:00
|
|
|
}
|
2022-11-28 00:02:56 +00:00
|
|
|
#endif /* CONFIG_SPL_LOAD_FIT */
|