From patchwork Wed Sep 6 07:05:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9940021 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 77A63602CC for ; Wed, 6 Sep 2017 07:05:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6870328AFA for ; Wed, 6 Sep 2017 07:05:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D32028AFD; Wed, 6 Sep 2017 07:05:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CBBE28AFA for ; Wed, 6 Sep 2017 07:05:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751880AbdIFHFV (ORCPT ); Wed, 6 Sep 2017 03:05:21 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:57116 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751913AbdIFHFO (ORCPT ); Wed, 6 Sep 2017 03:05:14 -0400 Received: from vsmta11.fe.internet.bosch.com (unknown [10.4.98.51]) by imta24.fe.bosch.de (Postfix) with ESMTP id 2B159D80231; Wed, 6 Sep 2017 09:04:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1504681484; bh=JbLYvlyOc+H/3b2ur7aNFVMicCuJNJVOtVEm8wJtcNA=; l=10; h=From:From:Reply-To:Sender; b=mnHAO+XWa+qSWCvouk2CZlige3LLpQdW/vj6i8urIohHl5dLVXymplX6gC9KjfQIE bgnoThqcDU4R/zl3QyFHa/3+6y3mFFLj6zlRr6fj5lFLFQHoer6R5LYm9qnDAbQX4u 2mJzcuGGOo9vOACQQM4DYfJuWloGA+ggivqHXd14= Received: from SI-HUB1001.de.bosch.com (vsgw23.fe.internet.bosch.com [10.4.98.23]) by vsmta11.fe.internet.bosch.com (Postfix) with ESMTP id 1EE05238094E; Wed, 6 Sep 2017 09:05:13 +0200 (CEST) Received: from HI-Z0EVG.hi.de.bosch.com (10.34.218.219) by SI-HUB1001.de.bosch.com (10.4.103.108) with Microsoft SMTP Server id 14.3.319.2; Wed, 6 Sep 2017 09:05:11 +0200 Received: from HI-Z0EVG.hi.de.bosch.com (localhost [IPv6:::1]) by HI-Z0EVG.hi.de.bosch.com (Postfix) with ESMTP id E8F4D1B46B14; Wed, 6 Sep 2017 09:05:10 +0200 (CEST) From: Dirk Behme To: , , Geert Uytterhoeven CC: Hiromitsu Yamasaki , Dirk Behme Subject: [PATCH 7/8] spi: sh-msiof: Fix gpio function Date: Wed, 6 Sep 2017 09:05:06 +0200 Message-ID: <20170906070507.26223-8-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170906070507.26223-1-dirk.behme@de.bosch.com> References: <20170906070507.26223-1-dirk.behme@de.bosch.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-23304.006 X-TMASE-MatchedRID: SHd+RjLgi2NNlZ1zEcyAY3QEQEU5OIefCKSk3rI3m0akNS9uwltRRHyj hWAKC7w4CX5kPBDNbrTfsce4DE2TjG18DcO3+y6JxEwSTOeVUQ6+CP3vLx6KVgqiCYa6w8tvgo4 eB1LnWggOK8Rrgay3iuuLFZZYlisfHxPMjOKY7A8LbigRnpKlKSPzRlrdFGDwtloR5YwrijzVtB 9LBoO4PQFqzBy/JeNJ8s1SvxHmQYRi/louuqbMZw== Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hiromitsu Yamasaki This patch adds a function to control chip select by GPIO. In order to use this patch, it is necessary to define it to devicetree. &pfc { ... /* MSIOF_SYMC Pin delete. */ msiof1_pins: spi2 { /* The definition of sync, ss1 and ss2 are unnecessary because of using GPIO as chip select. */ groups = "msiof1_clk_c", "msiof1_rxd_c", "msiof1_txd_c"; function = "msiof1"; }; ... }; &msiof1 { pinctrl-0 = <&msiof1_pins>; pinctrl-names = "default"; cs-gpios = <&gpio6 21 GPIO_ACTIVE_LOW>, <&gpio6 27 GPIO_ACTIVE_LOW>; status = "okay"; spidev@0 { ... reg = <0>; ... }; spidev@1 { ... reg = <1>; ... }; }; Signed-off-by: Hiromitsu Yamasaki Signed-off-by: Dirk Behme --- drivers/spi/spi-sh-msiof.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c index 2c53fc3f73af..fdad8d852602 100644 --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -541,6 +541,7 @@ static int sh_msiof_spi_setup(struct spi_device *spi) { struct device_node *np = spi->master->dev.of_node; struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master); + int ret; pm_runtime_get_sync(&p->pdev->dev); @@ -559,8 +560,12 @@ static int sh_msiof_spi_setup(struct spi_device *spi) !!(spi->mode & SPI_LSB_FIRST), !!(spi->mode & SPI_CS_HIGH)); - if (spi->cs_gpio >= 0) - gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); + if (gpio_is_valid(spi->cs_gpio)) { + ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); + if (!ret) + gpio_direction_output(spi->cs_gpio, + !(spi->mode & SPI_CS_HIGH)); + } pm_runtime_put(&p->pdev->dev);