lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 11 Nov 2009 10:48:38 +0100
From:	Wolfram Sang <w.sang@...gutronix.de>
To:	Luotao Fu <l.fu@...gutronix.de>
Cc:	Grant Likely <grant.likely@...retlab.ca>,
	spi-devel-general@...ts.sourceforge.net,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	linux-kernel@...r.kernel.org, linuxppc-dev@...abs.org
Subject: Re: [PATCH 1/3] mpc52xx_spi: fix clearing status register

On Tue, Nov 10, 2009 at 10:12:07AM +0100, Luotao Fu wrote:
> Before reading status register to check MODF failure, we have to clear it
> first since the MODF flag will be set after initializing the spi master,
> if the hardware comes up with a low SS. The processor datasheet reads:
> Mode Fault flag -- bit sets if SS input goes low while SPI is configured as a
> master. Flag is cleared automatically by an SPI status register read (with MODF
> set) followed by a SPI control register 1 write.
> Hence simply rereading the register is not sufficient to clear the flag. We
> redo the write also to make sure to clear the flag.
> 
> Signed-off-by: Luotao Fu <l.fu@...gutronix.de>

Nit below, otherwise:

Acked-by: Wolfram Sang <w.sang@...gutronix.de>

> ---
>  drivers/spi/mpc52xx_spi.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
> index ef8379b..5b036f2 100644
> --- a/drivers/spi/mpc52xx_spi.c
> +++ b/drivers/spi/mpc52xx_spi.c
> @@ -391,6 +391,7 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
>  	struct mpc52xx_spi *ms;
>  	void __iomem *regs;
>  	int rc;
> +	int ctrl1;

u8?

>  
>  	/* MMIO registers */
>  	dev_dbg(&op->dev, "probing mpc5200 SPI device\n");
> @@ -399,7 +400,8 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
>  		return -ENODEV;
>  

Sidenote to all: It was tested that simply moving the read here will not suffice.

>  	/* initialize the device */
> -	out_8(regs+SPI_CTRL1, SPI_CTRL1_SPIE | SPI_CTRL1_SPE | SPI_CTRL1_MSTR);
> +	ctrl1 = SPI_CTRL1_SPIE | SPI_CTRL1_SPE | SPI_CTRL1_MSTR;
> +	out_8(regs + SPI_CTRL1, ctrl1);
>  	out_8(regs + SPI_CTRL2, 0x0);
>  	out_8(regs + SPI_DATADIR, 0xe);	/* Set output pins */
>  	out_8(regs + SPI_PORTDATA, 0x8);	/* Deassert /SS signal */
> @@ -409,6 +411,8 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
>  	 * on the SPI bus.  This fault will also occur if the SPI signals
>  	 * are not connected to any pins (port_config setting) */
>  	in_8(regs + SPI_STATUS);
> +	out_8(regs + SPI_CTRL1, ctrl1);
> +
>  	in_8(regs + SPI_DATA);
>  	if (in_8(regs + SPI_STATUS) & SPI_STATUS_MODF) {
>  		dev_err(&op->dev, "mode fault; is port_config correct?\n");
> -- 
> 1.6.5.2
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@...ts.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Download attachment "signature.asc" of type "application/pgp-signature" (198 bytes)

Powered by blists - more mailing lists