Updates for spi-imx
Subsystems (2)
cover Updates for spi-imx
Hello,
as a followup to this mail I'll send some updates for the spi-imx driver for review.
Overall diffstat and shortlog can be found below.
You can find the patches based on current Linus' master at
git://git.pengutronix.de/git/ukl/linux-2.6.git spi-imx
Sascha Hauer (3):
spi-imx: update state correctly
spi-imx: Fix initial chipselect settings
spi-imx: setup mode_bits we can handle
Uwe Kleine-König (4):
spi-imx: rename source file to spi_imx.c
spi-imx: no need to assert bits_per_word being initialized
spi-imx: initialize complete config struct
[RFC] spi-imx: strip down chipselect function to only drive the chipselect
drivers/spi/Makefile | 2 +-
drivers/spi/{mxc_spi.c => spi_imx.c} | 383 +++++++++++++++++-----------------
2 files changed, 190 insertions(+), 195 deletions(-)
rename drivers/spi/{mxc_spi.c => spi_imx.c} (55%)Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 1/7 spi-imx: rename source file to spi_imx.c
This makes the filename match the Kconfig symbol and the driver name.
---
drivers/spi/Makefile | 2 +-
drivers/spi/{mxc_spi.c => spi_imx.c} | 336 +++++++++++++++++-----------------
2 files changed, 169 insertions(+), 169 deletions(-)
rename drivers/spi/{mxc_spi.c => spi_imx.c} (57%)drivers/spi/Makefile +1 -1
@@ -17,7 +17,7 @@ obj-$(CONFIG_SPI_BITBANG) += spi_bitbang.o obj-$(CONFIG_SPI_AU1550) += au1550_spi.o obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o obj-$(CONFIG_SPI_GPIO) += spi_gpio.o -obj-$(CONFIG_SPI_IMX) += mxc_spi.o +obj-$(CONFIG_SPI_IMX) += spi_imx.o obj-$(CONFIG_SPI_LM70_LLP) += spi_lm70llp.o obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o
drivers/spi/spi_imx.c renamed from drivers/spi/mxc_spi.c +168 -168
671 lines not on this page · raw message
Signature · 13 lines
1.6.4.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
PATCH 2/7 spi-imx: update state correctly
From: Sascha Hauer <[email protected]>
--- drivers/spi/spi_imx.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/spi/spi_imx.c +7 -0
@@ -443,6 +443,13 @@ static int spi_imx_setupxfer(struct spi_device *spi, config.speed_hz = t ? t->speed_hz : spi->max_speed_hz; config.mode = spi->mode; +if (!config.speed_hz) + config.speed_hz = spi->max_speed_hz; +if (!config.bpw) + config.bpw = spi->bits_per_word; +if (!config.speed_hz) + config.speed_hz = spi->max_speed_hz; + spi_imx->config (spi_imx, &config);return 0 ;
Signature · 13 lines
1.6.4.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
PATCH 3/7 spi-imx: Fix initial chipselect settings
From: Sascha Hauer <[email protected]>
We can only setup the gpio pins in spi_setup time when we know the SPI_CS_HIGH setting.
--- drivers/spi/spi_imx.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/spi/spi_imx.c +6 -1
@@ -478,12 +478,18 @@ static int spi_imx_transfer(struct spi_device *spi,static int spi_imx_setup (struct spi_device *spi) { +struct spi_imx_data *spi_imx =spi_master_get_devdata (spi->master); +int gpio = spi_imx->chipselect[spi->chip_select]; +if (!spi->bits_per_word) spi->bits_per_word =8 ;pr_debug ("%s: mode %d, %u bpw, %d hz\n" , __func__, spi->mode, spi->bits_per_word, spi->max_speed_hz); +if (gpio >=0 ) +gpio_direction_output (gpio, spi->mode &SPI_CS_HIGH ?0 :1 ); +spi_imx_chipselect (spi,BITBANG_CS_INACTIVE );return 0 ;
@@ -532,7 +538,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)dev_err (&pdev->dev,"can't get cs gpios" ); goto out_master_put; } -gpio_direction_output (spi_imx->chipselect[i],1 ); } spi_imx->bitbang.chipselect = spi_imx_chipselect;
Signature · 1 line
1.6.4.3
PATCH 4/7 spi-imx: setup mode_bits we can handle
From: Sascha Hauer <[email protected]>
--- drivers/spi/spi_imx.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/spi/spi_imx.c +1 -0
@@ -545,6 +545,7 @@ static int __init spi_imx_probe(struct platform_device *pdev) spi_imx->bitbang.txrx_bufs = spi_imx_transfer; spi_imx->bitbang.master->setup = spi_imx_setup; spi_imx->bitbang.master->cleanup = spi_imx_cleanup; + spi_imx->bitbang.master->mode_bits =SPI_CPOL |SPI_CPHA |SPI_CS_HIGH ;init_completion (&spi_imx->xfer_done);
Signature · 13 lines
1.6.4.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
PATCH 5/7 spi-imx: no need to assert bits_per_word being initialized
spi_imx_setup() is only called by spi_setup(). The latter does the initialization already.
--- drivers/spi/spi_imx.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/spi/spi_imx.c +0 -3
@@ -481,9 +481,6 @@ static int spi_imx_setup(struct spi_device *spi)struct spi_imx_data *spi_imx =spi_master_get_devdata (spi->master);int gpio = spi_imx->chipselect[spi->chip_select]; -if (!spi->bits_per_word) - spi->bits_per_word =8 ; -pr_debug ("%s: mode %d, %u bpw, %d hz\n" , __func__, spi->mode, spi->bits_per_word, spi->max_speed_hz);
Signature · 1 line
1.6.4.3
PATCH 6/7 spi-imx: initialize complete config struct
Otherwise the config function uses random data from the stack. This didn't stick out because config is called once more in the chipselect function with correct parameters.
--- drivers/spi/spi_imx.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/spi/spi_imx.c +1 -0
@@ -442,6 +442,7 @@ static int spi_imx_setupxfer(struct spi_device *spi, config.bpw = t ? t->bits_per_word : spi->bits_per_word; config.speed_hz = t ? t->speed_hz : spi->max_speed_hz; config.mode = spi->mode; + config.cs = spi_imx->chipselect[spi->chip_select];if (!config.speed_hz) config.speed_hz = spi->max_speed_hz;
Signature · 13 lines
1.6.4.3 ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
RFC PATCH 7/7 spi-imx: strip down chipselect function to only drive the chipselect
spi_imx_chipselect() made things that should be (and mostly are) done by spi_imx_setupxfer. Only setting the tx and rx functions was missing.
--- drivers/spi/spi_imx.c | 50 ++++++++++++++++-------------------------------- 1 files changed, 17 insertions(+), 33 deletions(-)
drivers/spi/spi_imx.c +17 -33
@@ -354,43 +354,14 @@ static int mx1_rx_available(struct spi_imx_data *spi_imx)static void spi_imx_chipselect (struct spi_device *spi,int is_active) {struct spi_imx_data *spi_imx =spi_master_get_devdata (spi->master); -unsigned int cs =0 ;int gpio = spi_imx->chipselect[spi->chip_select]; -struct spi_imx_config config; - -if (spi->mode &SPI_CS_HIGH ) - cs =1 ; +int active = is_active !=BITBANG_CS_INACTIVE ; +int dev_is_lowactive = !(spi->mode &SPI_CS_HIGH ); -if (is_active ==BITBANG_CS_INACTIVE ) { -if (gpio >=0 ) -gpio_set_value (gpio, !cs); +if (gpio <0 )return ; - } - - config.bpw = spi->bits_per_word; - config.speed_hz = spi->max_speed_hz; - config.mode = spi->mode; - config.cs = spi_imx->chipselect[spi->chip_select]; - - spi_imx->config (spi_imx, &config); - -/* Initialize the functions for transfer */ -if (config.bpw <=8 ) { - spi_imx->rx = spi_imx_buf_rx_u8; - spi_imx->tx = spi_imx_buf_tx_u8; - }else if (config.bpw <=16 ) { - spi_imx->rx = spi_imx_buf_rx_u16; - spi_imx->tx = spi_imx_buf_tx_u16; - }else if (config.bpw <=32 ) { - spi_imx->rx = spi_imx_buf_rx_u32; - spi_imx->tx = spi_imx_buf_tx_u32; - }else -BUG (); - -if (gpio >=0 ) -gpio_set_value (gpio, cs); -return ; +gpio_set_value (gpio, dev_is_lowactive ^ active); }static void spi_imx_push (struct spi_imx_data *spi_imx)
@@ -451,6 +422,19 @@ static int spi_imx_setupxfer(struct spi_device *spi,if (!config.speed_hz) config.speed_hz = spi->max_speed_hz; +/* Initialize the functions for transfer */ +if (config.bpw <=8 ) { + spi_imx->rx = spi_imx_buf_rx_u8; + spi_imx->tx = spi_imx_buf_tx_u8; + }else if (config.bpw <=16 ) { + spi_imx->rx = spi_imx_buf_rx_u16; + spi_imx->tx = spi_imx_buf_tx_u16; + }else if (config.bpw <=32 ) { + spi_imx->rx = spi_imx_buf_rx_u32; + spi_imx->tx = spi_imx_buf_tx_u32; + }else +BUG (); + spi_imx->config (spi_imx, &config);return 0 ;
Signature · 1 line
1.6.4.3
Quoted 2 lines · On Wed, 30 Sep 2009 21:42:11 +0200 Uwe Kleine-K__nig…
as a followup to this mail I'll send some updates for the spi-imx driver for review.
Several of these patches were unchangelogged but afaict they all fix bugs and hence should be in 2.6.32, yes?
Renaming the entire source file after -rc1 was probably a bit naughty, but we'll survive.
Hi Andrew,
Quoted 8 lines · Andrew Morton
Quoted 2 lines · On Wed, 30 Sep 2009 21:42:11 +0200 Uwe Kleine-K__nig…
as a followup to this mail I'll send some updates for the spi-imx driver for review.
Several of these patches were unchangelogged but afaict they all fix bugs and hence should be in 2.6.32, yes?
I'm not sure about "strip down chipselect function to only drive the chipselect", that's why I marked it RFC. I see the driver working with it and using less register writes, but if someone would check it and consider it OK, I'd feel better.
"spi-imx: no need to assert bits_per_word being initialized" isn't a real bugfix, it just removes an if(...) that is never hit.
The other (non-naughty) patches are bugfixes, yes.
Quoted 2 lines
Renaming the entire source file after -rc1 was probably a bit naughty, but we'll survive.
I didn't target for 2.6.32, I just wanted to get rid of the patches. The earlier they get in the better for me.
To be honest I expected to get back some patches because of the missing changelog. I just wanted to get them out before going to bed.
Best regards and thanks for picking my patches up
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |