Merge branch '2022-05-23-regression-fixes'

- Fix PowerPC NOR booting, important SPI uclass fixes/updates, gic_v2
  fix when CPU is not in EL3, fsl_esdhc_spl fix, and squashfs fix for
  linking on some architectures, and fix phy_string_for_interface
This commit is contained in:
Tom Rini 2022-05-23 13:52:53 -04:00
commit c04a418d52
19 changed files with 149 additions and 80 deletions

View file

@ -1263,7 +1263,7 @@ spl/u-boot-spl.srec: spl/u-boot-spl FORCE
OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
$(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec) \
$(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR),-R .bootpg -R .resetvec)
$(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR),$(if $(CONFIG_OF_EMBED),,-R .bootpg -R .resetvec))
binary_size_check: u-boot-nodtb.bin FORCE
@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \

View file

@ -40,6 +40,8 @@ ENTRY(gic_init_secure)
sub w10, w10, #0x1
cbnz w10, 0b
#elif defined(CONFIG_GICV2)
switch_el x1, 2f, 1f, 1f
2:
mov w9, #0x3 /* EnableGrp0 | EnableGrp1 */
str w9, [x0, GICD_CTLR] /* Secure GICD_CTLR */
ldr w9, [x0, GICD_TYPER]
@ -141,6 +143,8 @@ ENTRY(gic_init_secure_percpu)
* x0: Distributor Base
* x1: Cpu Interface Base
*/
switch_el x2, 4f, 5f, 5f
4:
mov w9, #~0 /* Config SGIs and PPIs as Grp1 */
str w9, [x0, GICD_IGROUPRn] /* GICD_IGROUPR0 */
mov w9, #0x1 /* Enable SGI 0 */
@ -155,6 +159,7 @@ ENTRY(gic_init_secure_percpu)
mov w9, #0x1 << 7 /* Non-Secure access to GICC_PMR */
str w9, [x1, GICC_PMR]
#endif
5:
ret
ENDPROC(gic_init_secure_percpu)

View file

@ -20,7 +20,7 @@
u-boot-dtb-with-ucode {
#ifdef CONFIG_MPC85xx
align = <256>;
align = <4>;
#endif
};
#ifdef CONFIG_MPC85XX_HAVE_RESET_VECTOR

View file

@ -149,9 +149,9 @@ static int mox_do_spi(u8 *in, u8 *out, size_t size)
struct udevice *dev;
int ret;
ret = spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL,
"spi_generic_drv", "moxtet@1", &dev,
&slave);
ret = _spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL,
"spi_generic_drv", "moxtet@1", &dev,
&slave);
if (ret)
goto fail;

View file

@ -91,6 +91,7 @@ static int do_spi_flash_probe(int argc, char *const argv[])
unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
unsigned int mode = CONFIG_SF_DEFAULT_MODE;
char *endp;
bool use_dt = true;
#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
struct udevice *new, *bus_dev;
int ret;
@ -117,11 +118,13 @@ static int do_spi_flash_probe(int argc, char *const argv[])
speed = simple_strtoul(argv[2], &endp, 0);
if (*argv[2] == 0 || *endp != 0)
return -1;
use_dt = false;
}
if (argc >= 4) {
mode = hextoul(argv[3], &endp);
if (*argv[3] == 0 || *endp != 0)
return -1;
use_dt = false;
}
#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
@ -131,14 +134,18 @@ static int do_spi_flash_probe(int argc, char *const argv[])
device_remove(new, DM_REMOVE_NORMAL);
}
flash = NULL;
ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &new);
if (ret) {
if (use_dt) {
spi_flash_probe_bus_cs(bus, cs, &new);
flash = dev_get_uclass_priv(new);
} else {
flash = spi_flash_probe(bus, cs, speed, mode);
}
if (!flash) {
printf("Failed to initialize SPI flash at %u:%u (error %d)\n",
bus, cs, ret);
return 1;
}
flash = dev_get_uclass_priv(new);
#else
if (flash)
spi_flash_free(flash);

View file

@ -46,8 +46,8 @@ static int do_spi_xfer(int bus, int cs)
str = strdup(name);
if (!str)
return -ENOMEM;
ret = spi_get_bus_and_cs(bus, cs, freq, mode, "spi_generic_drv",
str, &dev, &slave);
ret = _spi_get_bus_and_cs(bus, cs, freq, mode, "spi_generic_drv",
str, &dev, &slave);
if (ret)
return ret;
#else

View file

@ -106,7 +106,7 @@ again:
blk_off = (sector * 512) % mmc->read_bl_len;
blk_cnt = DIV_ROUND_UP(512, mmc->read_bl_len);
err = mmc->block_dev.block_read(&mmc->block_dev, blk_start, blk_cnt, tmp_buf);
if (err != 1) {
if (err != blk_cnt) {
puts("spl: mmc read failed!!\n");
hang();
}

View file

@ -46,25 +46,12 @@ int spl_flash_get_sw_write_prot(struct udevice *dev)
* TODO(sjg@chromium.org): This is an old-style function. We should remove
* it when all SPI flash drivers use dm
*/
struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs,
struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
unsigned int max_hz, unsigned int spi_mode)
{
struct udevice *dev;
if (spi_flash_probe_bus_cs(bus, cs, max_hz, spi_mode, &dev))
return NULL;
return dev_get_uclass_priv(dev);
}
int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
unsigned int max_hz, unsigned int spi_mode,
struct udevice **devp)
{
struct spi_slave *slave;
struct udevice *bus;
char *str;
int ret;
#if defined(CONFIG_SPL_BUILD) && CONFIG_IS_ENABLED(USE_TINY_PRINTF)
str = "spi_flash";
@ -74,8 +61,22 @@ int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
snprintf(name, sizeof(name), "spi_flash@%d:%d", busnum, cs);
str = strdup(name);
#endif
ret = spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode,
"jedec_spi_nor", str, &bus, &slave);
if (_spi_get_bus_and_cs(busnum, cs, max_hz, spi_mode,
"jedec_spi_nor", str, &bus, &slave))
return NULL;
return dev_get_uclass_priv(slave->dev);
}
int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
struct udevice **devp)
{
struct spi_slave *slave;
struct udevice *bus;
int ret;
ret = spi_get_bus_and_cs(busnum, cs, &bus, &slave);
if (ret)
return ret;

View file

@ -388,7 +388,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
/* speed and mode will be read from DT */
ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS,
CONFIG_SF_DEFAULT_CS, 0, 0, &new);
CONFIG_SF_DEFAULT_CS, &new);
ucode_flash = dev_get_uclass_priv(new);
#else
@ -475,7 +475,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
/* speed and mode will be read from DT */
ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
0, 0, &new);
&new);
ucode_flash = dev_get_uclass_priv(new);
#else

View file

@ -172,31 +172,20 @@ static int pfe_fit_check(void)
int pfe_spi_flash_init(void)
{
struct spi_flash *pfe_flash;
struct udevice *new;
int ret = 0;
void *addr = malloc(CONFIG_SYS_LS_PFE_FW_LENGTH);
if (!addr)
return -ENOMEM;
ret = spi_flash_probe_bus_cs(CONFIG_SYS_FSL_PFE_SPI_BUS,
CONFIG_SYS_FSL_PFE_SPI_CS,
CONFIG_SYS_FSL_PFE_SPI_MAX_HZ,
CONFIG_SYS_FSL_PFE_SPI_MODE,
&new);
if (ret) {
printf("SF: failed to probe spi\n");
free(addr);
device_remove(new, DM_REMOVE_NORMAL);
return ret;
}
pfe_flash = spi_flash_probe(CONFIG_SYS_FSL_PFE_SPI_BUS,
CONFIG_SYS_FSL_PFE_SPI_CS,
CONFIG_SYS_FSL_PFE_SPI_MAX_HZ,
CONFIG_SYS_FSL_PFE_SPI_MODE);
pfe_flash = dev_get_uclass_priv(new);
if (!pfe_flash) {
printf("SF: probe for pfe failed\n");
free(addr);
device_remove(new, DM_REMOVE_NORMAL);
return -ENODEV;
}

View file

@ -621,12 +621,10 @@ static int netsec_stop_gmac(struct netsec_priv *priv)
static void netsec_spi_read(char *buf, loff_t len, loff_t offset)
{
struct udevice *new;
struct spi_flash *flash;
spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE, &new);
flash = dev_get_uclass_priv(new);
flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
spi_flash_read(flash, offset, len, buf);
}

View file

@ -340,9 +340,65 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp,
return ret;
}
int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
const char *drv_name, const char *dev_name,
struct udevice **busp, struct spi_slave **devp)
int spi_get_bus_and_cs(int busnum, int cs, struct udevice **busp,
struct spi_slave **devp)
{
struct udevice *bus, *dev;
struct dm_spi_bus *bus_data;
struct spi_slave *slave;
int ret;
#if CONFIG_IS_ENABLED(OF_PLATDATA)
ret = uclass_first_device_err(UCLASS_SPI, &bus);
#else
ret = uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus);
#endif
if (ret) {
log_err("Invalid bus %d (err=%d)\n", busnum, ret);
return ret;
}
ret = spi_find_chip_select(bus, cs, &dev);
if (ret) {
dev_err(bus, "Invalid chip select %d:%d (err=%d)\n", busnum, cs, ret);
return ret;
}
if (!device_active(dev)) {
struct spi_slave *slave;
ret = device_probe(dev);
if (ret)
goto err;
slave = dev_get_parent_priv(dev);
slave->dev = dev;
}
slave = dev_get_parent_priv(dev);
bus_data = dev_get_uclass_priv(bus);
/*
* In case the operation speed is not yet established by
* dm_spi_claim_bus() ensure the bus is configured properly.
*/
if (!bus_data->speed) {
ret = spi_claim_bus(slave);
if (ret)
goto err;
}
*busp = bus;
*devp = slave;
return 0;
err:
log_debug("%s: Error path, device '%s'\n", __func__, dev->name);
return ret;
}
int _spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
const char *drv_name, const char *dev_name,
struct udevice **busp, struct spi_slave **devp)
{
struct udevice *bus, *dev;
struct dm_spi_slave_plat *plat;
@ -453,8 +509,8 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs,
struct udevice *dev;
int ret;
ret = spi_get_bus_and_cs(busnum, cs, speed, mode, NULL, 0, &dev,
&slave);
ret = _spi_get_bus_and_cs(busnum, cs, speed, mode, NULL, 0, &dev,
&slave);
if (ret)
return NULL;

View file

@ -830,8 +830,8 @@ static int max3420_udc_probe(struct udevice *dev)
cs = slave_pdata->cs;
speed = slave_pdata->max_hz;
mode = slave_pdata->mode;
spi_get_bus_and_cs(busnum, cs, speed, mode, "spi_generic_drv",
NULL, &spid, &udc->slave);
_spi_get_bus_and_cs(busnum, cs, speed, mode, false, "spi_generic_drv",
NULL, &spid, &udc->slave);
udc->dev = dev;
udc->gadget.ep0 = &udc->ep[0].ep_usb;

1
env/sf.c vendored
View file

@ -48,7 +48,6 @@ static int setup_flash_device(struct spi_flash **env_flash)
/* speed and mode will be read from DT */
ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE,
&new);
if (ret) {
env_set_default("spi_flash_probe_bus_cs() failed", 0);

View file

@ -8,6 +8,7 @@
*/
#include <asm/unaligned.h>
#include <div64.h>
#include <errno.h>
#include <fs.h>
#include <linux/types.h>
@ -1442,7 +1443,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
for (j = 0; j < datablk_count; j++) {
char *data_buffer;
start = data_offset / ctxt.cur_dev->blksz;
start = lldiv(data_offset, ctxt.cur_dev->blksz);
table_size = SQFS_BLOCK_SIZE(finfo.blk_sizes[j]);
table_offset = data_offset - (start * ctxt.cur_dev->blksz);
n_blks = DIV_ROUND_UP(table_size + table_offset,
@ -1516,7 +1517,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
goto out;
}
start = frag_entry.start / ctxt.cur_dev->blksz;
start = lldiv(frag_entry.start, ctxt.cur_dev->blksz);
table_size = SQFS_BLOCK_SIZE(frag_entry.size);
table_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);
n_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);

View file

@ -85,7 +85,7 @@ static const char * const backplane_mode_strings[] = {
static inline const char *phy_string_for_interface(phy_interface_t i)
{
/* Default to unknown */
if (i > PHY_INTERFACE_MODE_NA)
if (i >= PHY_INTERFACE_MODE_MAX)
i = PHY_INTERFACE_MODE_NA;
return phy_interface_strings[i];

View file

@ -572,6 +572,23 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp,
* Given a bus number and chip select, this finds the corresponding bus
* device and slave device.
*
* @busnum: SPI bus number
* @cs: Chip select to look for
* @busp: Returns bus device
* @devp: Return slave device
* @return 0 if found, -ve on error
*/
int spi_get_bus_and_cs(int busnum, int cs,
struct udevice **busp, struct spi_slave **devp);
/**
* _spi_get_bus_and_cs() - Find and activate bus and slave devices by number
* As spi_flash_probe(), This is an old-style function. We should remove
* it when all SPI flash drivers use dm
*
* Given a bus number and chip select, this finds the corresponding bus
* device and slave device.
*
* If no such slave exists, and drv_name is not NULL, then a new slave device
* is automatically bound on this chip select with requested speed and mode.
*
@ -588,7 +605,7 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp,
* @devp: Return slave device
* Return: 0 if found, -ve on error
*/
int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
int _spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
const char *drv_name, const char *dev_name,
struct udevice **busp, struct spi_slave **devp);

View file

@ -102,7 +102,6 @@ int spl_flash_get_sw_write_prot(struct udevice *dev);
int spi_flash_std_probe(struct udevice *dev);
int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
unsigned int max_hz, unsigned int spi_mode,
struct udevice **devp);
/* Compatibility function - this is the old U-Boot API */

View file

@ -46,19 +46,18 @@ static int dm_test_spi_find(struct unit_test_state *uts)
/* This finds nothing because we removed the device */
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_asserteq(-ENODEV, spi_get_bus_and_cs(busnum, cs, speed, mode,
NULL, 0, &bus, &slave));
ut_asserteq(-ENODEV, spi_get_bus_and_cs(busnum, cs, &bus, &slave));
/*
* This forces the device to be re-added, but there is no emulation
* connected so the probe will fail. We require that bus is left
* alone on failure, and that the spi_get_bus_and_cs() does not add
* alone on failure, and that the _spi_get_bus_and_cs() does not add
* a 'partially-inited' device.
*/
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode,
"jedec_spi_nor", "name", &bus,
&slave));
ut_asserteq(-ENOENT, _spi_get_bus_and_cs(busnum, cs, speed, mode,
"jedec_spi_nor", "name", &bus,
&slave));
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
ut_assertok(spi_cs_info(bus, cs, &info));
ut_asserteq_ptr(NULL, info.dev);
@ -67,8 +66,8 @@ static int dm_test_spi_find(struct unit_test_state *uts)
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, node,
"name"));
ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode,
"jedec_spi_nor", "name", &bus, &slave));
ut_assertok(_spi_get_bus_and_cs(busnum, cs, speed, mode,
"jedec_spi_nor", "name", &bus, &slave));
ut_assertok(spi_cs_info(bus, cs, &info));
ut_asserteq_ptr(info.dev, slave->dev);
@ -76,8 +75,9 @@ static int dm_test_spi_find(struct unit_test_state *uts)
/* We should be able to add something to another chip select */
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node,
"name"));
ut_asserteq(-EINVAL, spi_get_bus_and_cs(busnum, cs_b, speed, mode,
"jedec_spi_nor", "name", &bus, &slave));
ut_asserteq(-EINVAL, _spi_get_bus_and_cs(busnum, cs_b, speed, mode,
"jedec_spi_nor", "name", &bus,
&slave));
ut_asserteq(-EINVAL, spi_cs_info(bus, cs_b, &info));
ut_asserteq_ptr(NULL, info.dev);
@ -142,14 +142,12 @@ static int dm_test_spi_claim_bus(struct unit_test_state *uts)
struct udevice *bus;
struct spi_slave *slave_a, *slave_b;
struct dm_spi_slave_plat *slave_plat;
const int busnum = 0, cs_a = 0, cs_b = 1, mode = 0;
const int busnum = 0, cs_a = 0, cs_b = 1;
/* Get spi slave on CS0 */
ut_assertok(spi_get_bus_and_cs(busnum, cs_a, 1000000, mode, NULL, 0,
&bus, &slave_a));
ut_assertok(spi_get_bus_and_cs(busnum, cs_a, &bus, &slave_a));
/* Get spi slave on CS1 */
ut_assertok(spi_get_bus_and_cs(busnum, cs_b, 1000000, mode, NULL, 0,
&bus, &slave_b));
ut_assertok(spi_get_bus_and_cs(busnum, cs_b, &bus, &slave_b));
/* Different max_hz, different mode. */
ut_assert(slave_a->max_hz != slave_b->max_hz);
@ -178,12 +176,11 @@ static int dm_test_spi_xfer(struct unit_test_state *uts)
{
struct spi_slave *slave;
struct udevice *bus;
const int busnum = 0, cs = 0, mode = 0;
const int busnum = 0, cs = 0;
const char dout[5] = {0x9f};
unsigned char din[5];
ut_assertok(spi_get_bus_and_cs(busnum, cs, 1000000, mode, NULL, 0,
&bus, &slave));
ut_assertok(spi_get_bus_and_cs(busnum, cs, &bus, &slave));
ut_assertok(spi_claim_bus(slave));
ut_assertok(spi_xfer(slave, 40, dout, din,
SPI_XFER_BEGIN | SPI_XFER_END));