[U-Boot] [PATCH 3/9] i.MX31: support GPIO as a chip-select in the mxc_spi driver

Guennadi Liakhovetski lg at denx.de
Thu Feb 5 11:03:53 CET 2009


On Wed, 4 Feb 2009, Jean-Christophe PLAGNIOL-VILLARD wrote:

> On 17:59 Wed 04 Feb     , Guennadi Liakhovetski wrote:
> >  
> > +	/*
> > +	 * Some SPI devices require active chip-select over multiple
> > +	 * transactions, we achieve this using a GPIO. Still, the SPI
> > +	 * controller has to be configured to use one of its own chipselects.
> > +	 * To use this feature you have to call spi_setup_slave() with
> > +	 * cs = internal_cs | (gpio << 8), and you have to use some unused
> > +	 * on this SPI controller cs between 0 and 3.
> > +	 */
> > +	if (cs > 3) {
> > +		mxcs->gpio = cs >> 8;
> > +		cs &= 3;
> > +		mx31_gpio_direction(mxcs->gpio, MX31_GPIO_DIRECTION_OUT);
> > +	} else
> > +		mxcs->gpio = -1;
> > +
> why not add a callback for the chipselect instead
> as example if you have to use a gpio extender it will simplest to implent
> instead of hack the SPI driver

and how shall I pass this callback to

struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
			unsigned int max_hz, unsigned int mode)

?

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.

DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de


More information about the U-Boot mailing list