From patchwork Sun Mar 13 19:05:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gamari X-Patchwork-Id: 631941 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2DJ4HOx024636 for ; Sun, 13 Mar 2011 19:05:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755391Ab1CMTF3 (ORCPT ); Sun, 13 Mar 2011 15:05:29 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:47661 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755979Ab1CMTF3 (ORCPT ); Sun, 13 Mar 2011 15:05:29 -0400 Received: by vxi39 with SMTP id 39so3818121vxi.19 for ; Sun, 13 Mar 2011 12:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=5iP2LdLP7Av9XGgajK0ilf6sW3ubyljZlJF48G7he7c=; b=XHNpsgSgyEx+vrLghG/Md0Ui+BSdSUOdXsXiGOCAGBGHIuA6KBtrAEkidgnGBgj0n9 WBq7F3pOxFI8m4rxdk0DChUAvlZ74W+TPGuPv27RKaZfdbGj8HSDADnUKnWVHSNgRrrt GVIPMXEgt68NtqpfB1YsOfGe6+/8DtGkOsZiQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=mHWrfcjf935u4TUwoN13xikuI0mZHyqlT41b0TkxxnuV69cmFEXvLgyC7KU2UlIda3 B63PtIKHFzLJSg2YicDaecaZ3kQIzDGcvDWyE7t8MImL0zpH6cw5iKV2OjWa2I0MOJWY 2coUdK+6njsURNw5dGx65H7S0YaFpY5BnV82g= Received: by 10.52.180.102 with SMTP id dn6mr9709462vdc.38.1300043128515; Sun, 13 Mar 2011 12:05:28 -0700 (PDT) Received: from ben-laptop (pool-96-233-177-109.spfdma.east.verizon.net [96.233.177.109]) by mx.google.com with ESMTPS id u6sm4554933vby.7.2011.03.13.12.05.26 (version=SSLv3 cipher=OTHER); Sun, 13 Mar 2011 12:05:26 -0700 (PDT) From: Ben Gamari To: grant.likely@secretlab.ca, linux-omap@vger.kernel.org Cc: Ben Gamari Subject: [PATCH] mcspi: Add support for GPIO chip select lines Date: Sun, 13 Mar 2011 15:05:19 -0400 Message-Id: <1300043119-11262-1-git-send-email-bgamari.foss@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <87ipvmx2ok.fsf@gmail.com> References: <87ipvmx2ok.fsf@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 13 Mar 2011 19:05:30 +0000 (UTC) diff --git a/arch/arm/plat-omap/include/plat/mcspi.h b/arch/arm/plat-omap/include/plat/mcspi.h index 1254e49..cac1d84 100644 --- a/arch/arm/plat-omap/include/plat/mcspi.h +++ b/arch/arm/plat-omap/include/plat/mcspi.h @@ -2,7 +2,8 @@ #define _OMAP2_MCSPI_H struct omap2_mcspi_platform_config { - unsigned short num_cs; + unsigned short num_cs; + int *cs_gpios; }; struct omap2_mcspi_device_config { diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index abb1ffb..59cbed4 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -235,11 +236,15 @@ static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable) static void omap2_mcspi_force_cs(struct spi_device *spi, int cs_active) { - u32 l; - - l = mcspi_cached_chconf0(spi); - MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active); - mcspi_write_chconf0(spi, l); + struct omap2_mcspi_platform_config *pconfig = spi->master->dev.platform_data; + if (pconfig->cs_gpios) { + int gpio = pconfig->cs_gpios[spi->chip_select]; + gpio_set_value(gpio, cs_active); + } else { + u32 l = mcspi_cached_chconf0(spi); + MOD_REG_BIT(l, OMAP2_MCSPI_CHCONF_FORCE, cs_active); + mcspi_write_chconf0(spi, l); + } } static void omap2_mcspi_set_master_mode(struct spi_master *master)