From patchwork Tue Sep 18 12:49:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland Stigge X-Patchwork-Id: 1472721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id AB83EDF24C for ; Tue, 18 Sep 2012 12:52:19 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TDxEu-00046G-32; Tue, 18 Sep 2012 12:49:20 +0000 Received: from mail.work-microwave.de ([62.245.205.51] helo=work-microwave.de) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TDxEp-00045M-P2 for linux-arm-kernel@lists.infradead.org; Tue, 18 Sep 2012 12:49:17 +0000 Received: from rst-pc1.lan.work-microwave.de ([192.168.11.78]) (authenticated bits=0) by mail.work-microwave.de with ESMTP id q8ICn3SU019578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 18 Sep 2012 13:49:04 +0100 Received: by rst-pc1.lan.work-microwave.de (Postfix, from userid 1000) id 4BF0DAE06B; Tue, 18 Sep 2012 14:49:02 +0200 (CEST) From: Roland Stigge To: broonie@opensource.wolfsonmicro.com, grant.likely@secretlab.ca, linus.walleij@linaro.org, lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, STEricsson_nomadik_linux@list.st.com, arnd@arndb.de, devicetree-discuss@lists.ozlabs.org, aletes.xgr@gmail.com, kevin.wells@nxp.com, srinivas.bakki@nxp.com Subject: [PATCH] spi/pl022: Devicetree support w/o platform data Date: Tue, 18 Sep 2012 14:49:00 +0200 Message-Id: <1347972540-29667-1-git-send-email-stigge@antcom.de> X-Mailer: git-send-email 1.7.10.4 X-FEAS-SYSTEM-WL: rst@work-microwave.de, 192.168.11.78 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Roland Stigge X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Even with devicetree support, we needed platform data to provide some data like bus_id and enable_dma, leading to mixed device tree and platform data. This patch makes it possible to provide all that information via device tree. Now, the data must be provided via platform data _or_ device tree completely. Only in case of callback specification (dma_filter()), platform data is necessary. Signed-off-by: Roland Stigge Acked-by: Linus Walleij Acked-by: Alexandre Pereira da Silva --- Documentation/devicetree/bindings/spi/spi_pl022.txt | 9 ++++ drivers/spi/spi-pl022.c | 41 +++++++++++++++++--- 2 files changed, 45 insertions(+), 5 deletions(-) --- linux-2.6.orig/Documentation/devicetree/bindings/spi/spi_pl022.txt +++ linux-2.6/Documentation/devicetree/bindings/spi/spi_pl022.txt @@ -10,6 +10,15 @@ Optional properties: - cs-gpios : should specify GPIOs used for chipselects. The gpios will be referred to as reg = in the SPI child nodes. If unspecified, a single SPI device without a chip select can be used. +- pl022,bus-id : Bus ID (0, 1, ...) +- pl022,enable-dma : enables DMA driven transfers (boolean) +- pl022,autosuspend-delay : delay in ms following transfer completion before + the runtime power management system suspends the + device. A setting of 0 indicates no delay and the + device will be suspended immediately +- pl022,rt : indicates the controller should run the message pump with realtime + priority to minimise the transfer latency on the bus (boolean) + SPI slave nodes must be children of the SPI master node and can contain the following properties. --- linux-2.6.orig/drivers/spi/spi-pl022.c +++ linux-2.6/drivers/spi/spi-pl022.c @@ -2024,6 +2024,36 @@ static void pl022_cleanup(struct spi_dev kfree(chip); } +static struct pl022_ssp_controller * +pl022_platform_data_dt_get(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct pl022_ssp_controller *pd; + u32 tmp; + + if (!np) { + dev_err(dev, "no dt node defined\n"); + return NULL; + } + + pd = devm_kzalloc(dev, sizeof(struct pl022_ssp_controller), GFP_KERNEL); + if (!pd) { + dev_err(dev, "cannot allocate platform data memory\n"); + return NULL; + } + + of_property_read_u32(np, "pl022,bus-id", &tmp); + pd->bus_id = tmp; + of_property_read_u32(np, "num-cs", &tmp); + pd->num_chipselect = tmp; + pd->enable_dma = of_property_read_bool(np, "pl022,enable-dma") ? 1 : 0; + of_property_read_u32(np, "pl022,autosuspend-delay", + &pd->autosuspend_delay); + pd->rt = of_property_read_bool(np, "pl022,rt"); + + return pd; +} + static int __devinit pl022_probe(struct amba_device *adev, const struct amba_id *id) { @@ -2036,18 +2066,19 @@ pl022_probe(struct amba_device *adev, co dev_info(&adev->dev, "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid); - if (platform_info == NULL) { - dev_err(&adev->dev, "probe - no platform data supplied\n"); + if (!platform_info && IS_ENABLED(CONFIG_OF)) + platform_info = pl022_platform_data_dt_get(dev); + + if (!platform_info) { + dev_err(dev, "probe: no platform data defined\n"); status = -ENODEV; goto err_no_pdata; } if (platform_info->num_chipselect) { num_cs = platform_info->num_chipselect; - } else if (IS_ENABLED(CONFIG_OF)) { - of_property_read_u32(np, "num-cs", &num_cs); } else { - dev_err(&adev->dev, "probe: no chip select defined\n"); + dev_err(dev, "probe: no chip select defined\n"); status = -ENODEV; goto err_no_pdata; }