From patchwork Thu Jan 23 13:05:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 3528671 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BF0339F1C3 for ; Thu, 23 Jan 2014 13:07:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B27F02017E for ; Thu, 23 Jan 2014 13:07:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A080120115 for ; Thu, 23 Jan 2014 13:07:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753957AbaAWNGj (ORCPT ); Thu, 23 Jan 2014 08:06:39 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:36973 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753961AbaAWNGg (ORCPT ); Thu, 23 Jan 2014 08:06:36 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) by mx.tkos.co.il (Postfix) with ESMTPSA id 5495D440AFA; Thu, 23 Jan 2014 15:06:33 +0200 (IST) From: Baruch Siach To: Mark Brown Cc: linux-spi@vger.kernel.org, Feng Tang , Baruch Siach , Jean-Hugues Deschenes Subject: [PATCH RFC 2/4] spi: dw-mmio: add device tree support Date: Thu, 23 Jan 2014 15:05:57 +0200 Message-Id: <4859e838c549175fbff8d5a6a70f5a02ce51008c.1390481413.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.5 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);