Skip to contentSkip to conversation

SPI fixes for S3C24XX SPI driver

PATCH In review Ben Dooks 2 participants 5 messages Apr 11, 2008 – Apr 15, 2008 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 SPI fixes for S3C24XX SPI driver

These are fixes for the spi_s3c24xx driver, which could be possibly applied before the 2.6.25 release.

Signature · 9 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
author
#1 lore raw

PATCH 1/1 SPI: spi_s3c24xx driver needs to pass num_chipselect.

The SPI core now expects num_chipselect to be set correctly as due to added checks on the chip being selected before an transfer is allowed. This patch adds a num_cs field to the platform data which needs to be set correctly before adding the SPI platform device.

drivers/spi/spi_s3c24xx.c +4 -0
Index: linux-2.6.25-rc8-spi/drivers/spi/spi_s3c24xx.c
===================================================================
@@ -265,6 +265,10 @@ static int __init s3c24xx_spi_probe(stru
 	platform_set_drvdata(pdev, hw);
 	init_completion(&hw->done);
 
+	/* setup the master state. */
+
+	master->num_chipselect = hw->pdata->num_cs;
+
 	/* setup the state for the bitbang driver */
 
 	hw->bitbang.master         = hw->master;
include/asm-arm/arch-s3c2410/spi.h +1 -0
Index: linux-2.6.25-rc8-spi/include/asm-arm/arch-s3c2410/spi.h
===================================================================
@@ -18,6 +18,7 @@ struct spi_board_info;
 
 struct s3c2410_spi_info {
 	unsigned long		 pin_cs;	/* simple gpio cs */
+	unsigned int		 num_cs;	/* total chipselects */
 
 	unsigned long		 board_size;
 	struct spi_board_info	*board_info;
Signature · 9 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
author
#2 lore raw

PATCH 1/1 SPI: spi_s3c24xx driver bus_num field.

In reply to Ben Dooks

Pass the bus number we expect the S3C24XX SPI driver to attach to via the platform data.

include/asm-arm/arch-s3c2410/spi.h +1 -0
Index: linux-2.6.25-rc8-spi/include/asm-arm/arch-s3c2410/spi.h
===================================================================
@@ -19,6 +19,7 @@ struct spi_board_info;
 struct s3c2410_spi_info {
 	unsigned long		 pin_cs;	/* simple gpio cs */
 	unsigned int		 num_cs;	/* total chipselects */
+	int			 bus_num;       /* bus number to use. */
 
 	unsigned long		 board_size;
 	struct spi_board_info	*board_info;
drivers/spi/spi_s3c24xx.c +9 -7
Index: linux-2.6.25-rc8-spi/drivers/spi/spi_s3c24xx.c
===================================================================
@@ -235,6 +235,7 @@ static irqreturn_t s3c24xx_spi_irq(int i
 
 static int __init s3c24xx_spi_probe(struct platform_device *pdev)
 {
+	struct s3c2410_spi_info *pdata;
 	struct s3c24xx_spi *hw;
 	struct spi_master *master;
 	struct spi_board_info *bi;
@@ -253,10 +254,10 @@ static int __init s3c24xx_spi_probe(stru
 	memset(hw, 0, sizeof(struct s3c24xx_spi));
 
 	hw->master = spi_master_get(master);
-	hw->pdata = pdev->dev.platform_data;
+	hw->pdata = pdata = pdev->dev.platform_data;
 	hw->dev = &pdev->dev;
 
-	if (hw->pdata == NULL) {
+	if (pdata == NULL) {
 		dev_err(&pdev->dev, "No platform data supplied\n");
 		err = -ENOENT;
 		goto err_no_pdata;
@@ -268,7 +269,8 @@ static int __init s3c24xx_spi_probe(stru
 	/* setup the master state. */
 
 	master->num_chipselect = hw->pdata->num_cs;
-
+	master->bus_num = pdata->bus_num;
+	
 	/* setup the state for the bitbang driver */
 
 	hw->bitbang.master         = hw->master;
@@ -336,13 +338,13 @@ static int __init s3c24xx_spi_probe(stru
 
 	/* setup any gpio we can */
 
-	if (!hw->pdata->set_cs) {
+	if (!pdata->set_cs) {
 		hw->set_cs = s3c24xx_spi_gpiocs;
 
-		s3c2410_gpio_setpin(hw->pdata->pin_cs, 1);
-		s3c2410_gpio_cfgpin(hw->pdata->pin_cs, S3C2410_GPIO_OUTPUT);
+		s3c2410_gpio_setpin(pdata->pin_cs, 1);
+		s3c2410_gpio_cfgpin(pdata->pin_cs, S3C2410_GPIO_OUTPUT);
 	} else
-		hw->set_cs = hw->pdata->set_cs;
+		hw->set_cs = pdata->set_cs;
 
 	/* register our spi controller */
 
Signature · 9 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
author
#3 lore raw

PATCH 1/1 SPI: spi_s3c24xx driver should initialise completion before using it.

In reply to Ben Dooks

The s3c24xx_spi_txrx() function should initialise the completion each time before using it, otherwise we end up with the possibility of returning success before the interrupt handler has processed all the data.

drivers/spi/spi_s3c24xx.c +3 -0
Index: linux-2.6.24-quilt16/drivers/spi/spi_s3c24xx.c
===================================================================
@@ -192,8 +192,11 @@ static int s3c24xx_spi_txrx(struct spi_d
 	hw->len = t->len;
 	hw->count = 0;
 
+	init_completion(&hw->done);
+
 	/* send the first byte */
 	writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT);
+
 	wait_for_completion(&hw->done);
 
 	return hw->count;
Signature · 9 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 2 lines · Ben Dooks

These are fixes for the spi_s3c24xx driver, which could be possibly applied before the 2.6.25 release.

Most of them seem to need additional patches to the board-specific init logic too ... so applying them won't eliminate the need for any SPI patches with a 2.6.25-based release.

- Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone