[U-Boot] [PATCH v2 2/4] kw_spi: backup and reset the MPP of the chosen CS pin
Valentin Longchamp
valentin.longchamp at keymile.com
Thu May 31 10:45:19 CEST 2012
On 05/31/2012 10:36 AM, Prafulla Wadaskar wrote:
>> -----Original Message-----
>> From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
>> Sent: 30 May 2012 21:12
>> To: Prafulla Wadaskar
>> Cc: Valentin Longchamp; holger.brunck at keymile.com; u-
>> boot at lists.denx.de; Prafulla Wadaskar
>> Subject: [PATCH v2 2/4] kw_spi: backup and reset the MPP of the chosen
>> CS pin
>>
>> This was not done before, and in the case of a shared pin (for MPP0
>> between NF_IO[2] and CSn) this could lead to problems.
>>
>> Signed-off-by: Valentin Longchamp <valentin.longchamp at keymile.com>
>> cc: Holger Brunck <holger.brunck at keymile.com>
>> cc: Prafulla Wadaskar <prafulla at marvell.com>
>> ---
>> drivers/spi/kirkwood_spi.c | 14 ++++++--------
>> 1 files changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
>> index db8ba8b..2fd89d2 100644
>> --- a/drivers/spi/kirkwood_spi.c
>> +++ b/drivers/spi/kirkwood_spi.c
>> @@ -34,16 +34,14 @@
>>
>> static struct kwspi_registers *spireg = (struct kwspi_registers
>> *)KW_SPI_BASE;
>>
>> +u32 cs_spi_mpp_back[2];
>> +
>> struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>> unsigned int max_hz, unsigned int mode)
>> {
>> struct spi_slave *slave;
>> u32 data;
>> - u32 kwspi_mpp_config[] = {
>> - MPP0_GPIO,
>> - MPP7_SPI_SCn,
>> - 0
>> - };
>> + u32 kwspi_mpp_config[] = { 0, 0 };
>>
>> if (!spi_cs_is_valid(bus, cs))
>> return NULL;
>> @@ -70,12 +68,11 @@ struct spi_slave *spi_setup_slave(unsigned int
>> bus, unsigned int cs,
>>
>> /* program mpp registers to select SPI_CSn */
>> if (cs) {
>> - kwspi_mpp_config[0] = MPP0_GPIO;
>> - kwspi_mpp_config[1] = MPP7_SPI_SCn;
>> + kwspi_mpp_config[0] = MPP7_SPI_SCn;
>> } else {
>> kwspi_mpp_config[0] = MPP0_SPI_SCn;
>> - kwspi_mpp_config[1] = MPP7_GPO;
>> }
>> + kirkwood_mpp_read(kwspi_mpp_config, cs_spi_mpp_back);
>> kirkwood_mpp_conf(kwspi_mpp_config);
>>
>> return slave;
>> @@ -83,6 +80,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
>> unsigned int cs,
>>
>> void spi_free_slave(struct spi_slave *slave)
>> {
>> + kirkwood_mpp_conf(cs_spi_mpp_back);
>> free(slave);
>> }
>>
>> --
>
> Acked-By: Prafulla Wadaskar <prafulla at maravell.com>
> But as you said functionality need to be verified, I hope you have verified it on any of Kirkwood variant.
>
Sure, it's always been tested successfully on our kirkwood boards.
More information about the U-Boot
mailing list