From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radu Pirea Subject: Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi Date: Thu, 24 May 2018 19:04:11 +0300 Message-ID: <0e6e71e2-f8ac-7889-0d81-8d8a4c15223d@microchip.com> References: <20180511103822.31698-1-radu.pirea@microchip.com> <20180511103822.31698-6-radu.pirea@microchip.com> <5a3930b867cf8c279953d08c5d5dd1d93113a43b.camel@microchip.com> <20180517045437.GE20254@sirena.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180517045437.GE20254@sirena.org.uk> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Mark Brown Cc: Andy Shevchenko , devicetree , "open list:SERIAL DRIVERS" , Linux Kernel Mailing List , linux-arm Mailing List , linux-spi , Mark Rutland , Rob Herring , Lee Jones , Greg Kroah-Hartman , Jiri Slaby , Richard Genoud , alexandre.belloni@bootlin.com, Nicolas Ferre List-Id: linux-serial@vger.kernel.org On 05/17/2018 07:54 AM, Mark Brown wrote: > On Tue, May 15, 2018 at 12:22:24PM +0300, Radu Pirea wrote: >> On Mon, 2018-05-14 at 20:38 +0300, Andy Shevchenko wrote: > >>> So, what is not going as expected in "SPI core takes care of CSs" >>> case? >>> Did you use oscilloscope for that? > >> Yes, I used and CSs was not asserted. Anyway, I will will try again. > > If the core chip select handling is not working properly for some reason > then the core chip select handling should be fixed rather than just open > coding in your driver - probably it's also broken for other users. > Hi Mark, I found the fix for cs-gpios. If I change spi_add_device function like this(see below) everything is ok. int spi_add_device(struct spi_device *spi) ... if (ctlr->cs_gpios){ spi->cs_gpio = ctlr->cs_gpios[spi->chip_select]; if(gpio_is_valid(spi->cs_gpio)) gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); } ... return status; } In the subsystem gpio direction of pins is never set and gpio_set_value() don't set the direction. In my opinion gpio_direction_output() set direction should be called in spi_add_device. What do you think? Is ok?