UPSTREAM: spi: Pass pointer to spi_slave structure in spi_setup_slave
For spi_setup_slave, instead of making the platform driver return a pointer to spi_slave structure, pass in a structure pointer that can be filled in by the driver as required. This removes the need for platform drivers to maintain a slave structure in data/CAR section. CQ-DEPEND=CL:417081,CL:417087,CL:417958 BUG=chrome-os-partner:59832 BRANCH=None TEST=Compiles successfully Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17683 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Change-Id: Ia15a4f88ef4dcfdf616bb1c22261e7cb642a7573 Reviewed-on: https://chromium-review.googlesource.com/417080 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
15797fb67c
commit
737d4e09fe
30 changed files with 201 additions and 235 deletions
|
|
@ -344,7 +344,6 @@ static int nuclear_spi_status(const struct spi_flash *flash, uint8_t *reg)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static struct spi_slave boot_spi CAR_GLOBAL;
|
||||
static struct spi_flash boot_flash CAR_GLOBAL;
|
||||
|
||||
/*
|
||||
|
|
@ -391,20 +390,18 @@ struct spi_flash *spi_flash_programmer_probe(struct spi_slave *spi, int force)
|
|||
return flash;
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
|
||||
{
|
||||
BOILERPLATE_CREATE_CTX(ctx);
|
||||
|
||||
/* This is special hardware. We expect bus 0 and CS line 0 here. */
|
||||
if ((bus != 0) || (cs != 0))
|
||||
return NULL;
|
||||
|
||||
struct spi_slave *slave = car_get_var_ptr(&boot_spi);
|
||||
return -1;
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spi_read_status(uint8_t *status)
|
||||
|
|
|
|||
|
|
@ -260,20 +260,11 @@ static void ich_set_bbar(uint32_t minaddr)
|
|||
writel_(ichspi_bbar, cntlr.bbar);
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
|
||||
{
|
||||
ich_spi_slave *slave = malloc(sizeof(*slave));
|
||||
|
||||
if (!slave) {
|
||||
printk(BIOS_DEBUG, "ICH SPI: Bad allocation\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(slave, 0, sizeof(*slave));
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ich9_spi_regs *spi_regs(void)
|
||||
|
|
|
|||
|
|
@ -229,20 +229,11 @@ static void read_reg(void *src, void *value, uint32_t size)
|
|||
}
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
|
||||
{
|
||||
ich_spi_slave *slave = malloc(sizeof(*slave));
|
||||
|
||||
if (!slave) {
|
||||
printk(BIOS_ERR, "ICH SPI: Bad allocation\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(slave, 0, sizeof(*slave));
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ich9_spi_regs *spi_regs(void)
|
||||
|
|
|
|||
|
|
@ -259,20 +259,11 @@ static void ich_set_bbar(uint32_t minaddr)
|
|||
writel_(ichspi_bbar, cntlr.bbar);
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
|
||||
{
|
||||
ich_spi_slave *slave = malloc(sizeof(*slave));
|
||||
|
||||
if (!slave) {
|
||||
printk(BIOS_DEBUG, "ICH SPI: Bad allocation\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(slave, 0, sizeof(*slave));
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_init(void)
|
||||
|
|
|
|||
|
|
@ -249,20 +249,11 @@ static void read_reg(const void *src, void *value, uint32_t size)
|
|||
}
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
|
||||
{
|
||||
ich_spi_slave *slave = malloc(sizeof(*slave));
|
||||
|
||||
if (!slave) {
|
||||
printk(BIOS_DEBUG, "ICH SPI: Bad allocation\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(slave, 0, sizeof(*slave));
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ich9_spi_regs *spi_regs(void)
|
||||
|
|
|
|||
|
|
@ -259,20 +259,11 @@ static void ich_set_bbar(uint32_t minaddr)
|
|||
writel_(ichspi_bbar, cntlr.bbar);
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave * slave)
|
||||
{
|
||||
ich_spi_slave *slave = malloc(sizeof(*slave));
|
||||
|
||||
if (!slave) {
|
||||
printk(BIOS_DEBUG, "ICH SPI: Bad allocation\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(slave, 0, sizeof(*slave));
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void spi_init(void)
|
||||
|
|
|
|||
|
|
@ -342,7 +342,6 @@ int pch_hwseq_read_status(const struct spi_flash *flash, u8 *reg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct spi_slave boot_spi CAR_GLOBAL;
|
||||
static struct spi_flash boot_flash CAR_GLOBAL;
|
||||
|
||||
struct spi_flash *spi_flash_programmer_probe(struct spi_slave *spi, int force)
|
||||
|
|
@ -370,18 +369,16 @@ struct spi_flash *spi_flash_programmer_probe(struct spi_slave *spi, int force)
|
|||
return flash;
|
||||
}
|
||||
|
||||
struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs)
|
||||
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
|
||||
{
|
||||
/* This is special hardware. We expect bus 0 and CS line 0 here. */
|
||||
if ((bus != 0) || (cs != 0))
|
||||
return NULL;
|
||||
|
||||
struct spi_slave *slave = car_get_var_ptr(&boot_spi);
|
||||
return -1;
|
||||
|
||||
slave->bus = bus;
|
||||
slave->cs = cs;
|
||||
|
||||
return slave;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spi_flash_get_fpr_info(struct fpr_info *info)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue