Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2944219imm; Thu, 24 May 2018 19:36:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrXifOFhwxjziG3ioFNytfepxBu4EthQvSPnXoPB0mhmKUpflQJWtAk0+z5g5BuEyK/oW4G X-Received: by 2002:a62:f24a:: with SMTP id y10-v6mr567078pfl.75.1527215768946; Thu, 24 May 2018 19:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527215768; cv=none; d=google.com; s=arc-20160816; b=RZhBmYT1xWBsY+a42sCAx+YpDgf49LFK0cXaoyWEqySqCmUf4wd9BtroCP3Z3igmAJ v/Pli0eZlo8r3CUzZGikWugW8W70ao9M3xZ85A04PtpEij9yNynpQGcog/7Bp9hK0cIl VPs9bvJa+ESPKMHKtqUkjAWKRiRYPtcNuPTFaQitQDAmy53L83vN2CnWDY2sDBBxI61m QTUvIxCVeS9KROS+SEXfWi/sbofXnCyiysFtfE1nTPIUoPXevTvX1dlBuVvicRXMwLy6 CUoKi3M4yJewGvxiQfUJmOu/LZM4+VlS2IB5ahobYfE0o4E2QH/A3suCSGStIagRSx10 n8JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=drQ97kY1layNw8uzDcuOyTmHhHtxFRuK5bB8Uyw89CA=; b=qhl/y78zzPe/4kavtqn4Vw0d/tsZKONGm2qg+So8sAF/tB4Zw/VAmm1fkP/Cw3voG0 WignAqOjGB8AOPryjKWO7ltDd/lNP62NqZP96Qs3zUDAZkHbm9vs4mxJNEis9HMWiZHl f3ior8xEvM6OeYKpfXe9hgd+4LNmsXY1SLqFH/yByUXSsJJszvu4KsOKjjvenN6c0PAL 3eBOwyrW/8rsjgeVFn1gdsE9ovm4bhNVx4bdfCmLFtPdPUk8Pb+iaKZnUS3j/ZOuEhGQ 0TmgRmRpz1+B2EO6ipAyEmyw3Hi7g5WZfsga2/avLWLhqDcHeXgv84bSeydrAUJwyyPM kINQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13-v6si21925827plp.128.2018.05.24.19.35.54; Thu, 24 May 2018 19:36:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032175AbeEXR4Z (ORCPT + 99 others); Thu, 24 May 2018 13:56:25 -0400 Received: from mail.bootlin.com ([62.4.15.54]:40855 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030366AbeEXR4X (ORCPT ); Thu, 24 May 2018 13:56:23 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 2D76020714; Thu, 24 May 2018 19:56:21 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (unknown [88.191.26.124]) by mail.bootlin.com (Postfix) with ESMTPSA id 0470D203B4; Thu, 24 May 2018 19:56:21 +0200 (CEST) Date: Thu, 24 May 2018 19:56:20 +0200 From: Alexandre Belloni To: Radu Pirea Cc: Mark Brown , 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 , Nicolas Ferre Subject: Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi Message-ID: <20180524175620.GB12093@piout.net> References: <20180511103822.31698-1-radu.pirea@microchip.com> <20180511103822.31698-6-radu.pirea@microchip.com> <5a3930b867cf8c279953d08c5d5dd1d93113a43b.camel@microchip.com> <20180517045437.GE20254@sirena.org.uk> <0e6e71e2-f8ac-7889-0d81-8d8a4c15223d@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0e6e71e2-f8ac-7889-0d81-8d8a4c15223d@microchip.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 24/05/2018 19:04:11+0300, Radu Pirea wrote: > > > 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? Back in 2014, I was suggesting using devm_gpio_request_one() in of_spi_register_master(). That would take care of setting the direction of the GPIO: https://www.spinics.net/lists/arm-kernel/msg351251.html I never took the time to create the patch and test though. -- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com