From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Wed, 28 Oct 2015 17:39:20 +0100 Subject: [U-Boot] [PATCH v0 5/5] spi: Add support for Armada 38x second controller In-Reply-To: References: <1446047056-16801-1-git-send-email-dirk.eibach@gdsys.cc> <1446047056-16801-6-git-send-email-dirk.eibach@gdsys.cc> Message-ID: <5630FA38.5090000@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Dirk, On 28.10.2015 17:29, Jagan Teki wrote: > On 28 October 2015 at 21:14, wrote: >> From: Dirk Eibach >> >> Armada 38x has two spi controllers. >> >> Signed-off-by: Dirk Eibach >> --- >> >> drivers/spi/kirkwood_spi.c | 52 +++++++++++++++++++++++++++++++++++++++------- >> 1 file changed, 45 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c >> index e7b0982..200c391 100644 >> --- a/drivers/spi/kirkwood_spi.c >> +++ b/drivers/spi/kirkwood_spi.c >> @@ -18,17 +18,25 @@ >> #endif >> #include >> >> -static struct kwspi_registers *spireg = >> - (struct kwspi_registers *)MVEBU_SPI_BASE; >> - >> #ifdef CONFIG_KIRKWOOD >> static u32 cs_spi_mpp_back[2]; >> #endif >> >> +struct kwspi_slave { >> + struct spi_slave slave; >> + struct kwspi_registers *spireg; >> +}; >> + >> +static inline struct kwspi_slave *to_kwspi(struct spi_slave *slave) >> +{ >> + return container_of(slave, struct kwspi_slave, slave); >> +} >> + >> struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, >> unsigned int max_hz, unsigned int mode) >> { >> - struct spi_slave *slave; >> + struct kwspi_slave *kwspi_slave; >> + struct kwspi_registers *spireg; >> u32 data; >> #ifdef CONFIG_KIRKWOOD >> static const u32 kwspi_mpp_config[2][2] = { >> @@ -40,10 +48,27 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, >> if (!spi_cs_is_valid(bus, cs)) >> return NULL; >> >> - slave = spi_alloc_slave_base(bus, cs); >> - if (!slave) >> + kwspi_slave = spi_alloc_slave(struct kwspi_slave, bus, cs); >> + if (!kwspi_slave) >> return NULL; >> >> + switch (bus) { >> + case 0: >> + kwspi_slave->spireg = (struct kwspi_registers *)MVEBU_SPI_BASE; >> + break; >> +#ifdef CONFIG_ARMADA_38X >> + /* Armada 38x has two SPI controllers */ > > Can you please add this through driver-model, I understand it's bit > big task but I can help you at any moment. Yes, please do. I know this is additional work. But we really need to get there at some time. And please note that you can use the runtime SoC detection for this: if (mvebu_soc_family() == MVEBU_SOC_A38X) So no new #idefs are needed in such places. Thanks, Stefan