From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Subject: Re: [PATCH] spi/imx: Fix spi-imx when the hardware SPI chipselects are used Date: Thu, 15 Sep 2011 20:17:07 +0200 Message-ID: <20110915181707.GC29357@pengutronix.de> References: <1316103406-16401-1-git-send-email-fabio.estevam@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: grant.likely@secretlab.ca, spi-devel-general@lists.sourceforge.net, kernel@pengutronix.de, shawn.guo@freescale.com, linux-arm-kernel@lists.infradead.org To: Fabio Estevam Return-path: Content-Disposition: inline In-Reply-To: <1316103406-16401-1-git-send-email-fabio.estevam@freescale.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org List-Id: linux-spi.vger.kernel.org On Thu, Sep 15, 2011 at 01:16:46PM -0300, Fabio Estevam wrote: > commit 22a85e4cd51 (spi/imx: add device tree probe support) broke spi-imx= usage > when the SPI chipselect is the one internal to the controller. > = > On a mx31pdk board the following error is seen: > = > Registering mxc_nand as whole device > ------------[ cut here ]------------ > WARNING: at drivers/gpio/gpiolib.c:101 gpio_ensure_requested+0x4c/0xf4() > autorequest GPIO-0 > Modules linked in: > [] (unwind_backtrace+0x0/0xf4) from [] (warn_slowpath= _common+0x4c/0x64) > [] (warn_slowpath_common+0x4c/0x64) from [] (warn_slo= wpath_fmt+0x30/0x40) > [] (warn_slowpath_fmt+0x30/0x40) from [] (gpio_ensure= _requested+0x4c/0xf4) > [] (gpio_ensure_requested+0x4c/0xf4) from [] (gpio_di= rection_output+0xa0/0x138) > [] (gpio_direction_output+0xa0/0x138) from [] (spi_im= x_setup+0x38/0x4c) > [] (spi_imx_setup+0x38/0x4c) from [] (spi_setup+0x38/= 0x50) > [] (spi_setup+0x38/0x50) from [] (spi_add_device+0x94= /0x124) > [] (spi_add_device+0x94/0x124) from [] (spi_new_devic= e+0x74/0xac) > [] (spi_new_device+0x74/0xac) from [] (spi_match_mast= er_to_boardinfo+0x20/0x40) > [] (spi_match_master_to_boardinfo+0x20/0x40) from [] = (spi_register_master+0xb0/0x104) > [] (spi_register_master+0xb0/0x104) from [] (spi_bitb= ang_start+0x104/0x17c) > [] (spi_bitbang_start+0x104/0x17c) from [] (spi_imx_p= robe+0x2fc/0x404) > [] (spi_imx_probe+0x2fc/0x404) from [] (platform_drv_= probe+0x18/0x1c) > [] (platform_drv_probe+0x18/0x1c) from [] (driver_pro= be_device+0x78/0x174) > [] (driver_probe_device+0x78/0x174) from [] (__driver= _attach+0x8c/0x90) > [] (__driver_attach+0x8c/0x90) from [] (bus_for_each_= dev+0x60/0x8c) > [] (bus_for_each_dev+0x60/0x8c) from [] (bus_add_driv= er+0xa0/0x288) > [] (bus_add_driver+0xa0/0x288) from [] (driver_regist= er+0x78/0x18c) > [] (driver_register+0x78/0x18c) from [] (do_one_initc= all+0x34/0x178) > [] (do_one_initcall+0x34/0x178) from [] (kernel_init+= 0x74/0x118) > [] (kernel_init+0x74/0x118) from [] (kernel_thread_ex= it+0x0/0x8) > ---[ end trace 759f924b30fd5a44 ]--- > = > Fix this issue by using the original chip select logic and make spi-imx t= o work again. > = > Tested on a mx31pdk that uses the hardware SPI chipselect pins and also > on a mx27pdk that uses GPIO as SPI chipselect. > = > Signed-off-by: Fabio Estevam > --- > drivers/spi/spi-imx.c | 8 +++----- > 1 files changed, 3 insertions(+), 5 deletions(-) > = > diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c > index 8ac6542..7821c48 100644 > --- a/drivers/spi/spi-imx.c > +++ b/drivers/spi/spi-imx.c > @@ -783,12 +783,10 @@ static int __devinit spi_imx_probe(struct platform_= device *pdev) > spi_imx->bitbang.master =3D spi_master_get(master); > = > for (i =3D 0; i < master->num_chipselect; i++) { > - int cs_gpio =3D of_get_named_gpio(np, "cs-gpios", i); > - if (cs_gpio < 0) > - cs_gpio =3D mxc_platform_info->chipselect[i]; > - if (cs_gpio < 0) > + spi_imx->chipselect[i] =3D mxc_platform_info->chipselect[i]; > + if (spi_imx->chipselect[i] < 0) > continue; > - spi_imx->chipselect[i] =3D cs_gpio; > + > ret =3D gpio_request(spi_imx->chipselect[i], DRIVER_NAME); > if (ret) { > while (i > 0) { I think this is wrong. My first guess is you need to move spi_imx->chipselect[i] =3D cs_gpio; before if (cs_gpio < 0) continue; Does that make sense and works? Uwe -- = Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | http://www.pengutronix.de/ |