From patchwork Mon Apr 27 03:44:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Welling X-Patchwork-Id: 6277511 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 184799F1C4 for ; Mon, 27 Apr 2015 03:44:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 431B1203F4 for ; Mon, 27 Apr 2015 03:44:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64D1B203EC for ; Mon, 27 Apr 2015 03:44:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752063AbbD0Dop (ORCPT ); Sun, 26 Apr 2015 23:44:45 -0400 Received: from mail-ie0-f182.google.com ([209.85.223.182]:34221 "EHLO mail-ie0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbbD0Dop (ORCPT ); Sun, 26 Apr 2015 23:44:45 -0400 Received: by iedfl3 with SMTP id fl3so133557605ied.1; Sun, 26 Apr 2015 20:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=NxM3qZIUtRAuLQc6AR4WsSB3DOcR1Zt+UKvs9WMq+iE=; b=k7FJqhdKV9vP+j47X56tvK6KDS0s2myF2eAHz4tIaUFYj4+nEJbn2iuuNwxN3P7UV7 uKWyDAxEo1r6GxVb99GclBta9ltqyTHfca4B11Iftqs/WnBDmnN2fK/ZyuT8r/9HVxG7 HQNT0fiVJMNV/tCIF1RacLKLxCJnJEzg1347bt1Zs4mIJIcDbe48evhPc50OevvrXe4v 5B9QxKbGO8K/UM5m6uOpFdYp4ThWL+VhmKB/s5e7KgNgMp8O62OKFGXFkNcQuqvUWWPL 1ydIc9xwKa9WWXHUG+NtikP1EDq1AfkXfM+ViHodT9uVFREjjxBBwqyAPsROAHhjrXka zlBQ== X-Received: by 10.50.18.113 with SMTP id v17mr10813111igd.8.1430106284318; Sun, 26 Apr 2015 20:44:44 -0700 (PDT) Received: from deathray.hitronhub.home (173-22-240-38.client.mchsi.com. [173.22.240.38]) by mx.google.com with ESMTPSA id i185sm3786235ioi.24.2015.04.26.20.44.42 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 Apr 2015 20:44:43 -0700 (PDT) From: Michael Welling To: broonie@kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Welling Subject: [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects Date: Sun, 26 Apr 2015 22:44:30 -0500 Message-Id: <1430106270-17142-1-git-send-email-mwelling@ieee.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allows for GPIOs specified in the devicetree to be used as SPI chipselects on TI OMAP2 SoCs. Tested on the AM3354. Signed-off-by: Michael Welling --- v2: Considers the possible use of SPI_CS_HIGH during chip select activation. drivers/spi/spi-omap2-mcspi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index d1a5b9f..5e388a8 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -35,6 +35,7 @@ #include #include +#include #include @@ -246,6 +247,12 @@ static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active) { u32 l; + if (gpio_is_valid(spi->cs_gpio)) { + gpio_set_value(spi->cs_gpio, (cs_active) ? + !!(spi->mode & SPI_CS_HIGH) : + !(spi->mode & SPI_CS_HIGH)); + } + l = mcspi_cached_chconf0(spi); if (cs_active) l |= OMAP2_MCSPI_CHCONF_FORCE; @@ -1015,6 +1022,12 @@ static int omap2_mcspi_setup(struct spi_device *spi) if (ret < 0) return ret; + if (gpio_is_valid(spi->cs_gpio)) { + if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0) + gpio_direction_output(spi->cs_gpio, + !(spi->mode & SPI_CS_HIGH)); + } + ret = omap2_mcspi_setup_transfer(spi, NULL); pm_runtime_mark_last_busy(mcspi->dev); pm_runtime_put_autosuspend(mcspi->dev);