Commit ce620fa9 authored by Sandrine Bailleux's avatar Sandrine Bailleux Committed by TrustedFirmware Code Review
Browse files

Merge changes from topic "uniphier" into integration

* changes:
  uniphier: extend boot device detection for future SoCs
  uniphier: change block_addressing flag to bool
  uniphier: change the return value type of .is_usb_boot() to bool
parents 51d72d3a 2cb26005
......@@ -25,7 +25,8 @@ unsigned int uniphier_get_boot_device(unsigned int soc);
#define UNIPHIER_BOOT_DEVICE_EMMC 0
#define UNIPHIER_BOOT_DEVICE_NAND 1
#define UNIPHIER_BOOT_DEVICE_NOR 2
#define UNIPHIER_BOOT_DEVICE_USB 3
#define UNIPHIER_BOOT_DEVICE_SD 3
#define UNIPHIER_BOOT_DEVICE_USB 4
#define UNIPHIER_BOOT_DEVICE_RSV 0xffffffff
unsigned int uniphier_get_boot_master(unsigned int soc);
......
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
......@@ -16,17 +16,17 @@
#define UNIPHIER_PINMON0 0x5f900100
#define UNIPHIER_PINMON2 0x5f900108
static int uniphier_ld11_is_usb_boot(uint32_t pinmon)
static bool uniphier_ld11_is_usb_boot(uint32_t pinmon)
{
return !!(~pinmon & 0x00000080);
}
static int uniphier_ld20_is_usb_boot(uint32_t pinmon)
static bool uniphier_ld20_is_usb_boot(uint32_t pinmon)
{
return !!(~pinmon & 0x00000780);
}
static int uniphier_pxs3_is_usb_boot(uint32_t pinmon)
static bool uniphier_pxs3_is_usb_boot(uint32_t pinmon)
{
uint32_t pinmon2 = mmio_read_32(UNIPHIER_PINMON2);
......@@ -106,20 +106,25 @@ static unsigned int uniphier_pxs3_get_boot_device(uint32_t pinmon)
}
struct uniphier_boot_device_info {
int (*is_usb_boot)(uint32_t pinmon);
bool have_boot_swap;
bool (*is_sd_boot)(uint32_t pinmon);
bool (*is_usb_boot)(uint32_t pinmon);
unsigned int (*get_boot_device)(uint32_t pinmon);
};
static const struct uniphier_boot_device_info uniphier_boot_device_info[] = {
[UNIPHIER_SOC_LD11] = {
.have_boot_swap = true,
.is_usb_boot = uniphier_ld11_is_usb_boot,
.get_boot_device = uniphier_ld11_get_boot_device,
},
[UNIPHIER_SOC_LD20] = {
.have_boot_swap = true,
.is_usb_boot = uniphier_ld20_is_usb_boot,
.get_boot_device = uniphier_ld11_get_boot_device,
},
[UNIPHIER_SOC_PXS3] = {
.have_boot_swap = true,
.is_usb_boot = uniphier_pxs3_is_usb_boot,
.get_boot_device = uniphier_pxs3_get_boot_device,
},
......@@ -135,10 +140,13 @@ unsigned int uniphier_get_boot_device(unsigned int soc)
pinmon = mmio_read_32(UNIPHIER_PINMON0);
if (!(pinmon & BIT(29)))
if (info->have_boot_swap && !(pinmon & BIT(29)))
return UNIPHIER_BOOT_DEVICE_NOR;
if (info->is_usb_boot(pinmon))
if (info->is_sd_boot && info->is_sd_boot(pinmon))
return UNIPHIER_BOOT_DEVICE_SD;
if (info->is_usb_boot && info->is_usb_boot(pinmon))
return UNIPHIER_BOOT_DEVICE_USB;
return info->get_boot_device(pinmon);
......
......@@ -87,7 +87,7 @@ struct uniphier_mmc_cmd {
unsigned int is_data;
};
static int uniphier_emmc_block_addressing;
static bool uniphier_emmc_block_addressing;
static int uniphier_emmc_send_cmd(uintptr_t host_base,
struct uniphier_mmc_cmd *cmd)
......@@ -157,7 +157,8 @@ static int uniphier_emmc_switch_part(uintptr_t host_base, int part_num)
return uniphier_emmc_send_cmd(host_base, &cmd);
}
static int uniphier_emmc_is_over_2gb(uintptr_t host_base)
static int uniphier_emmc_check_device_size(uintptr_t host_base,
bool *is_block_addressing)
{
struct uniphier_mmc_cmd cmd = {0};
uint32_t csd40, csd72; /* CSD[71:40], CSD[103:72] */
......@@ -174,7 +175,10 @@ static int uniphier_emmc_is_over_2gb(uintptr_t host_base)
csd40 = mmio_read_32(host_base + SDHCI_RESPONSE + 4);
csd72 = mmio_read_32(host_base + SDHCI_RESPONSE + 8);
return !(~csd40 & 0xffc00380) && !(~csd72 & 0x3);
/* C_SIZE == 0xfff && C_SIZE_MULT == 0x7 ? */
*is_block_addressing = !(~csd40 & 0xffc00380) && !(~csd72 & 0x3);
return 0;
}
static int uniphier_emmc_load_image(uintptr_t host_base,
......@@ -253,12 +257,11 @@ static int uniphier_emmc_hw_init(void)
while (mmio_read_8(host_base + SDHCI_SOFTWARE_RESET))
;
ret = uniphier_emmc_is_over_2gb(host_base);
if (ret < 0)
ret = uniphier_emmc_check_device_size(host_base,
&uniphier_emmc_block_addressing);
if (ret)
return ret;
uniphier_emmc_block_addressing = ret;
cmd.cmdarg = UNIPHIER_EMMC_RCA << 16;
/* select card again */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment