From patchwork Fri Jun 11 10:19:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raffaele Recalcati X-Patchwork-Id: 105547 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5BALli9017795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 11 Jun 2010 10:22:23 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o5BAK78U012714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 11 Jun 2010 05:20:07 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5BAK6UU020108; Fri, 11 Jun 2010 05:20:06 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id B178F80628; Fri, 11 Jun 2010 05:20:05 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id DA34380626 for ; Fri, 11 Jun 2010 05:20:03 -0500 (CDT) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5BAK3xr016109 for ; Fri, 11 Jun 2010 05:20:03 -0500 (CDT) Received: from psmtp.com (na3sys009amx160.postini.com [74.125.149.86]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id o5BAK200026554 for ; Fri, 11 Jun 2010 05:20:02 -0500 Received: from source ([74.125.82.173]) by na3sys009amx160.postini.com ([74.125.148.10]) with SMTP; Fri, 11 Jun 2010 03:20:02 PDT Received: by wyb36 with SMTP id 36so682492wyb.4 for ; Fri, 11 Jun 2010 03:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=jkHqwN57+Zx674c1a3iXI+LOpD1oXqSvLy0WJRwA+6g=; b=vkCvCFFhjDhs5fl/etjXOuJTF0mtPAyPOzHemoyu9tTGvXszZFJKNBmezlDS0J+9cn HNUR0LfrvTYZLm89IzfkTV7fLWf0Z+xrHQc2doA4Vkb6vE4B8eUdhiEFhyNqmIuTKHaQ Qj4XNF7phemHsUtCBWMjwpASgdbKDoiKaN7Kk= 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=t0I2EOi3x26lusAq3T6mqKGnrcfNlmMlsPDfBaMvhj0AoMotyLI6jOYSObppuvGiOI 575sPBQMlwErNgJ1HUMwTSXlc4Yv0gt3go90nusJBoeb8/vR4kr5QDZD1C8nLCUrCj49 /uqT7ol29dgB4m8I3HbDbMyrmatvurnsWfxgQ= Received: by 10.227.69.17 with SMTP id x17mr1585386wbi.171.1276251601361; Fri, 11 Jun 2010 03:20:01 -0700 (PDT) Received: from localhost.localdomain (host81-90-static.72-81-b.business.telecomitalia.it [81.72.90.81]) by mx.google.com with ESMTPS id p17sm530613wbe.14.2010.06.11.03.19.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 11 Jun 2010 03:20:00 -0700 (PDT) From: Raffaele Recalcati To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 02/14] spi: davinci: Added support for chip select using gpio Date: Fri, 11 Jun 2010 12:19:42 +0200 Message-Id: <1276251594-5936-2-git-send-email-lamiaposta71@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1276251594-5936-1-git-send-email-lamiaposta71@gmail.com> References: <1276251594-5936-1-git-send-email-lamiaposta71@gmail.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:20.20518/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: Raffaele Recalcati X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 11 Jun 2010 10:22:23 +0000 (UTC) diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index a146849..42fd4a4 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -677,10 +677,12 @@ void __init dm365_init_spi0(unsigned chipselect_mask, davinci_cfg_reg(DM365_SPI0_SDO); /* not all slaves will be wired up */ - if (chipselect_mask & BIT(0)) - davinci_cfg_reg(DM365_SPI0_SDENA0); - if (chipselect_mask & BIT(1)) - davinci_cfg_reg(DM365_SPI0_SDENA1); + if (!((unsigned long) info->controller_data)) { + if (chipselect_mask & BIT(0)) + davinci_cfg_reg(DM365_SPI0_SDENA0); + if (chipselect_mask & BIT(1)) + davinci_cfg_reg(DM365_SPI0_SDENA1); + } spi_register_board_info(info, len); diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 95afb6b..621ae46 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -270,18 +271,26 @@ static void davinci_spi_chipselect(struct spi_device *spi, int value) pdata = davinci_spi->pdata; /* - * Board specific chip select logic decides the polarity and cs - * line for the controller - */ + * Board specific chip select logic decides the polarity and cs + * line for the controller + */ if (value == BITBANG_CS_INACTIVE) { - set_io_bits(davinci_spi->base + SPIDEF, CS_DEFAULT); - - data1_reg_val |= CS_DEFAULT << SPIDAT1_CSNR_SHIFT; - iowrite32(data1_reg_val, davinci_spi->base + SPIDAT1); - + if ((unsigned long) spi->controller_data) { + gpio_set_value(spi->controller_data, \ + !(spi->mode & SPI_CS_HIGH)); + } else { + set_io_bits(davinci_spi->base + SPIDEF, CS_DEFAULT); + + data1_reg_val |= CS_DEFAULT << SPIDAT1_CSNR_SHIFT; + iowrite32(data1_reg_val, davinci_spi->base + SPIDAT1); + } while ((ioread32(davinci_spi->base + SPIBUF) - & SPIBUF_RXEMPTY_MASK) == 0) + & SPIBUF_RXEMPTY_MASK) == 0) cpu_relax(); + } else { + if ((unsigned long) spi->controller_data) + gpio_set_value(spi->controller_data, \ + (spi->mode & SPI_CS_HIGH)); } }