mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
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:
commit
c04a418d52
19 changed files with 149 additions and 80 deletions
2
Makefile
2
Makefile
|
@ -1263,7 +1263,7 @@ spl/u-boot-spl.srec: spl/u-boot-spl FORCE
|
||||||
|
|
||||||
OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
|
OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
|
||||||
$(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec) \
|
$(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
|
binary_size_check: u-boot-nodtb.bin FORCE
|
||||||
@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \
|
@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print $$1}') ; \
|
||||||
|
|
|
@ -40,6 +40,8 @@ ENTRY(gic_init_secure)
|
||||||
sub w10, w10, #0x1
|
sub w10, w10, #0x1
|
||||||
cbnz w10, 0b
|
cbnz w10, 0b
|
||||||
#elif defined(CONFIG_GICV2)
|
#elif defined(CONFIG_GICV2)
|
||||||
|
switch_el x1, 2f, 1f, 1f
|
||||||
|
2:
|
||||||
mov w9, #0x3 /* EnableGrp0 | EnableGrp1 */
|
mov w9, #0x3 /* EnableGrp0 | EnableGrp1 */
|
||||||
str w9, [x0, GICD_CTLR] /* Secure GICD_CTLR */
|
str w9, [x0, GICD_CTLR] /* Secure GICD_CTLR */
|
||||||
ldr w9, [x0, GICD_TYPER]
|
ldr w9, [x0, GICD_TYPER]
|
||||||
|
@ -141,6 +143,8 @@ ENTRY(gic_init_secure_percpu)
|
||||||
* x0: Distributor Base
|
* x0: Distributor Base
|
||||||
* x1: Cpu Interface Base
|
* x1: Cpu Interface Base
|
||||||
*/
|
*/
|
||||||
|
switch_el x2, 4f, 5f, 5f
|
||||||
|
4:
|
||||||
mov w9, #~0 /* Config SGIs and PPIs as Grp1 */
|
mov w9, #~0 /* Config SGIs and PPIs as Grp1 */
|
||||||
str w9, [x0, GICD_IGROUPRn] /* GICD_IGROUPR0 */
|
str w9, [x0, GICD_IGROUPRn] /* GICD_IGROUPR0 */
|
||||||
mov w9, #0x1 /* Enable SGI 0 */
|
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 */
|
mov w9, #0x1 << 7 /* Non-Secure access to GICC_PMR */
|
||||||
str w9, [x1, GICC_PMR]
|
str w9, [x1, GICC_PMR]
|
||||||
#endif
|
#endif
|
||||||
|
5:
|
||||||
ret
|
ret
|
||||||
ENDPROC(gic_init_secure_percpu)
|
ENDPROC(gic_init_secure_percpu)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
u-boot-dtb-with-ucode {
|
u-boot-dtb-with-ucode {
|
||||||
#ifdef CONFIG_MPC85xx
|
#ifdef CONFIG_MPC85xx
|
||||||
align = <256>;
|
align = <4>;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#ifdef CONFIG_MPC85XX_HAVE_RESET_VECTOR
|
#ifdef CONFIG_MPC85XX_HAVE_RESET_VECTOR
|
||||||
|
|
|
@ -149,7 +149,7 @@ static int mox_do_spi(u8 *in, u8 *out, size_t size)
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL,
|
ret = _spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL,
|
||||||
"spi_generic_drv", "moxtet@1", &dev,
|
"spi_generic_drv", "moxtet@1", &dev,
|
||||||
&slave);
|
&slave);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
15
cmd/sf.c
15
cmd/sf.c
|
@ -91,6 +91,7 @@ static int do_spi_flash_probe(int argc, char *const argv[])
|
||||||
unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
|
unsigned int speed = CONFIG_SF_DEFAULT_SPEED;
|
||||||
unsigned int mode = CONFIG_SF_DEFAULT_MODE;
|
unsigned int mode = CONFIG_SF_DEFAULT_MODE;
|
||||||
char *endp;
|
char *endp;
|
||||||
|
bool use_dt = true;
|
||||||
#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
|
#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
|
||||||
struct udevice *new, *bus_dev;
|
struct udevice *new, *bus_dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -117,11 +118,13 @@ static int do_spi_flash_probe(int argc, char *const argv[])
|
||||||
speed = simple_strtoul(argv[2], &endp, 0);
|
speed = simple_strtoul(argv[2], &endp, 0);
|
||||||
if (*argv[2] == 0 || *endp != 0)
|
if (*argv[2] == 0 || *endp != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
use_dt = false;
|
||||||
}
|
}
|
||||||
if (argc >= 4) {
|
if (argc >= 4) {
|
||||||
mode = hextoul(argv[3], &endp);
|
mode = hextoul(argv[3], &endp);
|
||||||
if (*argv[3] == 0 || *endp != 0)
|
if (*argv[3] == 0 || *endp != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
use_dt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(DM_SPI_FLASH)
|
#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);
|
device_remove(new, DM_REMOVE_NORMAL);
|
||||||
}
|
}
|
||||||
flash = NULL;
|
flash = NULL;
|
||||||
ret = spi_flash_probe_bus_cs(bus, cs, speed, mode, &new);
|
if (use_dt) {
|
||||||
if (ret) {
|
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",
|
printf("Failed to initialize SPI flash at %u:%u (error %d)\n",
|
||||||
bus, cs, ret);
|
bus, cs, ret);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flash = dev_get_uclass_priv(new);
|
|
||||||
#else
|
#else
|
||||||
if (flash)
|
if (flash)
|
||||||
spi_flash_free(flash);
|
spi_flash_free(flash);
|
||||||
|
|
|
@ -46,7 +46,7 @@ static int do_spi_xfer(int bus, int cs)
|
||||||
str = strdup(name);
|
str = strdup(name);
|
||||||
if (!str)
|
if (!str)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
ret = spi_get_bus_and_cs(bus, cs, freq, mode, "spi_generic_drv",
|
ret = _spi_get_bus_and_cs(bus, cs, freq, mode, "spi_generic_drv",
|
||||||
str, &dev, &slave);
|
str, &dev, &slave);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -106,7 +106,7 @@ again:
|
||||||
blk_off = (sector * 512) % mmc->read_bl_len;
|
blk_off = (sector * 512) % mmc->read_bl_len;
|
||||||
blk_cnt = DIV_ROUND_UP(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);
|
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");
|
puts("spl: mmc read failed!!\n");
|
||||||
hang();
|
hang();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* TODO(sjg@chromium.org): This is an old-style function. We should remove
|
||||||
* it when all SPI flash drivers use dm
|
* 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)
|
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 spi_slave *slave;
|
||||||
struct udevice *bus;
|
struct udevice *bus;
|
||||||
char *str;
|
char *str;
|
||||||
int ret;
|
|
||||||
|
|
||||||
#if defined(CONFIG_SPL_BUILD) && CONFIG_IS_ENABLED(USE_TINY_PRINTF)
|
#if defined(CONFIG_SPL_BUILD) && CONFIG_IS_ENABLED(USE_TINY_PRINTF)
|
||||||
str = "spi_flash";
|
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);
|
snprintf(name, sizeof(name), "spi_flash@%d:%d", busnum, cs);
|
||||||
str = strdup(name);
|
str = strdup(name);
|
||||||
#endif
|
#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)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
|
||||||
|
|
||||||
/* speed and mode will be read from DT */
|
/* speed and mode will be read from DT */
|
||||||
ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS,
|
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);
|
ucode_flash = dev_get_uclass_priv(new);
|
||||||
#else
|
#else
|
||||||
|
@ -475,7 +475,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
|
||||||
|
|
||||||
/* speed and mode will be read from DT */
|
/* speed and mode will be read from DT */
|
||||||
ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
|
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);
|
ucode_flash = dev_get_uclass_priv(new);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -172,31 +172,20 @@ static int pfe_fit_check(void)
|
||||||
int pfe_spi_flash_init(void)
|
int pfe_spi_flash_init(void)
|
||||||
{
|
{
|
||||||
struct spi_flash *pfe_flash;
|
struct spi_flash *pfe_flash;
|
||||||
struct udevice *new;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
void *addr = malloc(CONFIG_SYS_LS_PFE_FW_LENGTH);
|
void *addr = malloc(CONFIG_SYS_LS_PFE_FW_LENGTH);
|
||||||
|
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = spi_flash_probe_bus_cs(CONFIG_SYS_FSL_PFE_SPI_BUS,
|
pfe_flash = spi_flash_probe(CONFIG_SYS_FSL_PFE_SPI_BUS,
|
||||||
CONFIG_SYS_FSL_PFE_SPI_CS,
|
CONFIG_SYS_FSL_PFE_SPI_CS,
|
||||||
CONFIG_SYS_FSL_PFE_SPI_MAX_HZ,
|
CONFIG_SYS_FSL_PFE_SPI_MAX_HZ,
|
||||||
CONFIG_SYS_FSL_PFE_SPI_MODE,
|
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 = dev_get_uclass_priv(new);
|
|
||||||
if (!pfe_flash) {
|
if (!pfe_flash) {
|
||||||
printf("SF: probe for pfe failed\n");
|
printf("SF: probe for pfe failed\n");
|
||||||
free(addr);
|
free(addr);
|
||||||
device_remove(new, DM_REMOVE_NORMAL);
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
static void netsec_spi_read(char *buf, loff_t len, loff_t offset)
|
||||||
{
|
{
|
||||||
struct udevice *new;
|
|
||||||
struct spi_flash *flash;
|
struct spi_flash *flash;
|
||||||
|
|
||||||
spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
|
flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS,
|
||||||
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE, &new);
|
CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE);
|
||||||
flash = dev_get_uclass_priv(new);
|
|
||||||
|
|
||||||
spi_flash_read(flash, offset, len, buf);
|
spi_flash_read(flash, offset, len, buf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,7 +340,63 @@ int spi_find_bus_and_cs(int busnum, int cs, struct udevice **busp,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
|
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,
|
const char *drv_name, const char *dev_name,
|
||||||
struct udevice **busp, struct spi_slave **devp)
|
struct udevice **busp, struct spi_slave **devp)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +509,7 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs,
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = spi_get_bus_and_cs(busnum, cs, speed, mode, NULL, 0, &dev,
|
ret = _spi_get_bus_and_cs(busnum, cs, speed, mode, NULL, 0, &dev,
|
||||||
&slave);
|
&slave);
|
||||||
if (ret)
|
if (ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -830,7 +830,7 @@ static int max3420_udc_probe(struct udevice *dev)
|
||||||
cs = slave_pdata->cs;
|
cs = slave_pdata->cs;
|
||||||
speed = slave_pdata->max_hz;
|
speed = slave_pdata->max_hz;
|
||||||
mode = slave_pdata->mode;
|
mode = slave_pdata->mode;
|
||||||
spi_get_bus_and_cs(busnum, cs, speed, mode, "spi_generic_drv",
|
_spi_get_bus_and_cs(busnum, cs, speed, mode, false, "spi_generic_drv",
|
||||||
NULL, &spid, &udc->slave);
|
NULL, &spid, &udc->slave);
|
||||||
|
|
||||||
udc->dev = dev;
|
udc->dev = dev;
|
||||||
|
|
1
env/sf.c
vendored
1
env/sf.c
vendored
|
@ -48,7 +48,6 @@ static int setup_flash_device(struct spi_flash **env_flash)
|
||||||
|
|
||||||
/* speed and mode will be read from DT */
|
/* speed and mode will be read from DT */
|
||||||
ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
|
ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS,
|
||||||
CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE,
|
|
||||||
&new);
|
&new);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
env_set_default("spi_flash_probe_bus_cs() failed", 0);
|
env_set_default("spi_flash_probe_bus_cs() failed", 0);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
|
#include <div64.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fs.h>
|
#include <fs.h>
|
||||||
#include <linux/types.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++) {
|
for (j = 0; j < datablk_count; j++) {
|
||||||
char *data_buffer;
|
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_size = SQFS_BLOCK_SIZE(finfo.blk_sizes[j]);
|
||||||
table_offset = data_offset - (start * ctxt.cur_dev->blksz);
|
table_offset = data_offset - (start * ctxt.cur_dev->blksz);
|
||||||
n_blks = DIV_ROUND_UP(table_size + table_offset,
|
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;
|
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_size = SQFS_BLOCK_SIZE(frag_entry.size);
|
||||||
table_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);
|
table_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);
|
||||||
n_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);
|
n_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);
|
||||||
|
|
|
@ -85,7 +85,7 @@ static const char * const backplane_mode_strings[] = {
|
||||||
static inline const char *phy_string_for_interface(phy_interface_t i)
|
static inline const char *phy_string_for_interface(phy_interface_t i)
|
||||||
{
|
{
|
||||||
/* Default to unknown */
|
/* Default to unknown */
|
||||||
if (i > PHY_INTERFACE_MODE_NA)
|
if (i >= PHY_INTERFACE_MODE_MAX)
|
||||||
i = PHY_INTERFACE_MODE_NA;
|
i = PHY_INTERFACE_MODE_NA;
|
||||||
|
|
||||||
return phy_interface_strings[i];
|
return phy_interface_strings[i];
|
||||||
|
|
|
@ -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
|
* Given a bus number and chip select, this finds the corresponding bus
|
||||||
* device and slave device.
|
* 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
|
* 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.
|
* 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
|
* @devp: Return slave device
|
||||||
* Return: 0 if found, -ve on error
|
* 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,
|
const char *drv_name, const char *dev_name,
|
||||||
struct udevice **busp, struct spi_slave **devp);
|
struct udevice **busp, struct spi_slave **devp);
|
||||||
|
|
||||||
|
|
|
@ -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_std_probe(struct udevice *dev);
|
||||||
|
|
||||||
int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
|
int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
|
||||||
unsigned int max_hz, unsigned int spi_mode,
|
|
||||||
struct udevice **devp);
|
struct udevice **devp);
|
||||||
|
|
||||||
/* Compatibility function - this is the old U-Boot API */
|
/* Compatibility function - this is the old U-Boot API */
|
||||||
|
|
|
@ -46,17 +46,16 @@ static int dm_test_spi_find(struct unit_test_state *uts)
|
||||||
|
|
||||||
/* This finds nothing because we removed the device */
|
/* This finds nothing because we removed the device */
|
||||||
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
|
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
|
||||||
ut_asserteq(-ENODEV, spi_get_bus_and_cs(busnum, cs, speed, mode,
|
ut_asserteq(-ENODEV, spi_get_bus_and_cs(busnum, cs, &bus, &slave));
|
||||||
NULL, 0, &bus, &slave));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This forces the device to be re-added, but there is no emulation
|
* 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
|
* 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.
|
* a 'partially-inited' device.
|
||||||
*/
|
*/
|
||||||
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
|
ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev));
|
||||||
ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode,
|
ut_asserteq(-ENOENT, _spi_get_bus_and_cs(busnum, cs, speed, mode,
|
||||||
"jedec_spi_nor", "name", &bus,
|
"jedec_spi_nor", "name", &bus,
|
||||||
&slave));
|
&slave));
|
||||||
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
|
sandbox_sf_unbind_emul(state_get_current(), busnum, cs);
|
||||||
|
@ -67,7 +66,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
|
||||||
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, node,
|
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs, bus, node,
|
||||||
"name"));
|
"name"));
|
||||||
ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
|
ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev));
|
||||||
ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode,
|
ut_assertok(_spi_get_bus_and_cs(busnum, cs, speed, mode,
|
||||||
"jedec_spi_nor", "name", &bus, &slave));
|
"jedec_spi_nor", "name", &bus, &slave));
|
||||||
|
|
||||||
ut_assertok(spi_cs_info(bus, cs, &info));
|
ut_assertok(spi_cs_info(bus, cs, &info));
|
||||||
|
@ -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 */
|
/* We should be able to add something to another chip select */
|
||||||
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node,
|
ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node,
|
||||||
"name"));
|
"name"));
|
||||||
ut_asserteq(-EINVAL, spi_get_bus_and_cs(busnum, cs_b, speed, mode,
|
ut_asserteq(-EINVAL, _spi_get_bus_and_cs(busnum, cs_b, speed, mode,
|
||||||
"jedec_spi_nor", "name", &bus, &slave));
|
"jedec_spi_nor", "name", &bus,
|
||||||
|
&slave));
|
||||||
ut_asserteq(-EINVAL, spi_cs_info(bus, cs_b, &info));
|
ut_asserteq(-EINVAL, spi_cs_info(bus, cs_b, &info));
|
||||||
ut_asserteq_ptr(NULL, info.dev);
|
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 udevice *bus;
|
||||||
struct spi_slave *slave_a, *slave_b;
|
struct spi_slave *slave_a, *slave_b;
|
||||||
struct dm_spi_slave_plat *slave_plat;
|
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 */
|
/* Get spi slave on CS0 */
|
||||||
ut_assertok(spi_get_bus_and_cs(busnum, cs_a, 1000000, mode, NULL, 0,
|
ut_assertok(spi_get_bus_and_cs(busnum, cs_a, &bus, &slave_a));
|
||||||
&bus, &slave_a));
|
|
||||||
/* Get spi slave on CS1 */
|
/* Get spi slave on CS1 */
|
||||||
ut_assertok(spi_get_bus_and_cs(busnum, cs_b, 1000000, mode, NULL, 0,
|
ut_assertok(spi_get_bus_and_cs(busnum, cs_b, &bus, &slave_b));
|
||||||
&bus, &slave_b));
|
|
||||||
|
|
||||||
/* Different max_hz, different mode. */
|
/* Different max_hz, different mode. */
|
||||||
ut_assert(slave_a->max_hz != slave_b->max_hz);
|
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 spi_slave *slave;
|
||||||
struct udevice *bus;
|
struct udevice *bus;
|
||||||
const int busnum = 0, cs = 0, mode = 0;
|
const int busnum = 0, cs = 0;
|
||||||
const char dout[5] = {0x9f};
|
const char dout[5] = {0x9f};
|
||||||
unsigned char din[5];
|
unsigned char din[5];
|
||||||
|
|
||||||
ut_assertok(spi_get_bus_and_cs(busnum, cs, 1000000, mode, NULL, 0,
|
ut_assertok(spi_get_bus_and_cs(busnum, cs, &bus, &slave));
|
||||||
&bus, &slave));
|
|
||||||
ut_assertok(spi_claim_bus(slave));
|
ut_assertok(spi_claim_bus(slave));
|
||||||
ut_assertok(spi_xfer(slave, 40, dout, din,
|
ut_assertok(spi_xfer(slave, 40, dout, din,
|
||||||
SPI_XFER_BEGIN | SPI_XFER_END));
|
SPI_XFER_BEGIN | SPI_XFER_END));
|
||||||
|
|
Loading…
Reference in a new issue