Patchwork [U-Boot,3/3] spi/kirkwood: add weak functions board_spi_claim/release_bus

login
register
mail settings
Submitter Valentin Longchamp
Date May 16, 2012, 10:53 a.m.
Message ID <1337165623-7118-4-git-send-email-valentin.longchamp@keymile.com>
Download mbox | patch
Permalink /patch/159585/
State Superseded
Headers show

Comments

Valentin Longchamp - May 16, 2012, 10:53 a.m.
This allows a final, board specific, step in the claim/relase_bus
function for the SPI controller, which may be needed for some hardware
designs.

Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
cc: Holger Brunck <holger.brunck@keymile.com>
cc: Prafulla Wadaskar <prafulla@marvell.com>
---
 drivers/spi/kirkwood_spi.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
Prafulla Wadaskar - May 24, 2012, 8:38 a.m.
> -----Original Message-----
> From: Valentin Longchamp [mailto:valentin.longchamp@keymile.com]
> Sent: 16 May 2012 16:24
> To: Prafulla Wadaskar; holger.brunck@keymile.com
> Cc: Valentin Longchamp; u-boot@lists.denx.de; Holger Brunck; Prafulla
> Wadaskar
> Subject: [PATCH 3/3] spi/kirkwood: add weak functions
> board_spi_claim/release_bus
> 
> This allows a final, board specific, step in the claim/relase_bus
> function for the SPI controller, which may be needed for some hardware
> designs.

NAK, this is not needed if earlier two patches in the patch series are in place.

Regards..
Prafulla . . .
Valentin Longchamp - May 29, 2012, 8:32 a.m.
On 05/24/2012 10:38 AM, Prafulla Wadaskar wrote:
>> -----Original Message-----
>> From: Valentin Longchamp [mailto:valentin.longchamp@keymile.com]
>> Sent: 16 May 2012 16:24
>> To: Prafulla Wadaskar; holger.brunck@keymile.com
>> Cc: Valentin Longchamp; u-boot@lists.denx.de; Holger Brunck; Prafulla
>> Wadaskar
>> Subject: [PATCH 3/3] spi/kirkwood: add weak functions
>> board_spi_claim/release_bus
>>
>> This allows a final, board specific, step in the claim/relase_bus
>> function for the SPI controller, which may be needed for some hardware
>> designs.
> 
> NAK, this is not needed if earlier two patches in the patch series are in place.
> 

In our case, this is still needed. As I had already explained you in the
previous discussion, even with the generic approach, our hardware design
requires one access to an additional signal (a GPIO) to configure an external HW
multiplexer which is present to electrically remove the Nand Flash device from
the signals used by the SPI bus and put it back when the accesses are over.

That's why my first implementation was only relying on these weak functions.
Prafulla Wadaskar - May 29, 2012, 12:13 p.m.
> -----Original Message-----
> From: Valentin Longchamp [mailto:valentin.longchamp@keymile.com]
> Sent: 29 May 2012 14:03
> To: Prafulla Wadaskar
> Cc: holger.brunck@keymile.com; u-boot@lists.denx.de
> Subject: Re: [PATCH 3/3] spi/kirkwood: add weak functions
> board_spi_claim/release_bus
> 
> On 05/24/2012 10:38 AM, Prafulla Wadaskar wrote:
> >> -----Original Message-----
> >> From: Valentin Longchamp [mailto:valentin.longchamp@keymile.com]
> >> Sent: 16 May 2012 16:24
> >> To: Prafulla Wadaskar; holger.brunck@keymile.com
> >> Cc: Valentin Longchamp; u-boot@lists.denx.de; Holger Brunck;
> Prafulla
> >> Wadaskar
> >> Subject: [PATCH 3/3] spi/kirkwood: add weak functions
> >> board_spi_claim/release_bus
> >>
> >> This allows a final, board specific, step in the claim/relase_bus
> >> function for the SPI controller, which may be needed for some
> hardware
> >> designs.
> >
> > NAK, this is not needed if earlier two patches in the patch series
> are in place.
> >
> 
> In our case, this is still needed. As I had already explained you in
> the
> previous discussion, even with the generic approach, our hardware
> design
> requires one access to an additional signal (a GPIO) to configure an
> external HW
> multiplexer which is present to electrically remove the Nand Flash
> device from
> the signals used by the SPI bus and put it back when the accesses are
> over.
> 
> That's why my first implementation was only relying on these weak
> functions.

Okay, got it, on your board, apart from MPPs, you need additional control.

BTW: if NF_CEn could have been used this additional GPIO would not have needed.
But any ways we cannot change your h/w now :-)
So in that case it makes sense to expose these weak functions.

Regards..
Prafulla . . .

Patch

diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
index 0877915..0e4db45 100644
--- a/drivers/spi/kirkwood_spi.c
+++ b/drivers/spi/kirkwood_spi.c
@@ -86,6 +86,11 @@  void spi_free_slave(struct spi_slave *slave)
 	free(slave);
 }
 
+__attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave)
+{
+	return 0;
+}
+
 int spi_claim_bus(struct spi_slave *slave)
 {
 	u32 config;
@@ -121,12 +126,18 @@  int spi_claim_bus(struct spi_slave *slave)
 	/* finally set chosen mpp spi configuration */
 	kirkwood_mpp_conf(spi_mpp_config);
 
-	return 0;
+	return board_spi_claim_bus(slave);
+}
+
+__attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave)
+{
 }
 
 void spi_release_bus(struct spi_slave *slave)
 {
 	kirkwood_mpp_restore();
+
+	board_spi_release_bus(slave);
 }
 
 #ifndef CONFIG_SPI_CS_IS_VALID