From patchwork Sun Jan 26 08:14:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 3539571 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 61A98C02DC for ; Sun, 26 Jan 2014 08:15:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97E79201BB for ; Sun, 26 Jan 2014 08:15:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C150520131 for ; Sun, 26 Jan 2014 08:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752465AbaAZIO7 (ORCPT ); Sun, 26 Jan 2014 03:14:59 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:39207 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751456AbaAZIO6 (ORCPT ); Sun, 26 Jan 2014 03:14:58 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) by mx.tkos.co.il (Postfix) with ESMTPSA id 1F9C9440AB3; Sun, 26 Jan 2014 10:14:56 +0200 (IST) From: Baruch Siach To: Mark Brown Cc: linux-spi@vger.kernel.org, Baruch Siach , Jean-Hugues Deschenes Subject: [PATCH v2 2/5] spi: dw-mmio: add device tree support Date: Sun, 26 Jan 2014 10:14:33 +0200 Message-Id: <4898c1f4dc88caa2b19fd04a57b7d20b53494644.1390723880.git.baruch@tkos.co.il> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: References: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Cc: Jean-Hugues Deschenes Signed-off-by: Baruch Siach --- drivers/spi/spi-dw-mmio.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 1492f5ee9aaa..b694f3f9b901 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "spi-dw.h" @@ -32,6 +33,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) struct dw_spi *dws; struct resource *mem; int ret; + u32 tmp; dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), GFP_KERNEL); @@ -67,7 +69,11 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) return ret; dws->bus_num = pdev->id; - dws->num_cs = 4; + ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &tmp); + if (ret == 0) + dws->num_cs = tmp; + else + dws->num_cs = 4; dws->max_freq = clk_get_rate(dwsmmio->clk); ret = dw_spi_add_host(&pdev->dev, dws); @@ -92,12 +98,21 @@ static int dw_spi_mmio_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static struct of_device_id dw_spi_dt_ids[] = { + { .compatible = "snps,designware-spi" }, + {} +}; +MODULE_DEVICE_TABLE(of, dw_spi_dt_ids); +#endif + static struct platform_driver dw_spi_mmio_driver = { .probe = dw_spi_mmio_probe, .remove = dw_spi_mmio_remove, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(dw_spi_dt_ids), }, }; module_platform_driver(dw_spi_mmio_driver);