From patchwork Fri Jan 31 10:07:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 3560911 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 0D7819F2E9 for ; Fri, 31 Jan 2014 10:08:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FFFA2021A for ; Fri, 31 Jan 2014 10:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32B992021C for ; Fri, 31 Jan 2014 10:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085AbaAaKIg (ORCPT ); Fri, 31 Jan 2014 05:08:36 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:44422 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754086AbaAaKIe (ORCPT ); Fri, 31 Jan 2014 05:08:34 -0500 Received: from tarshish.tkos.co.il (unknown [10.0.8.6]) by mx.tkos.co.il (Postfix) with ESMTPSA id 21824440B3A; Fri, 31 Jan 2014 12:08:32 +0200 (IST) From: Baruch Siach To: Mark Brown Cc: linux-spi@vger.kernel.org, Feng Tang , Baruch Siach , Jean-Hugues Deschenes Subject: [PATCH v3 3/5] spi: dw-mmio: add device tree support Date: Fri, 31 Jan 2014 12:07:46 +0200 Message-Id: X-Mailer: git-send-email 1.8.5.3 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 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 1492f5ee9aaa..86d247ecd2d2 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,15 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) return ret; dws->bus_num = pdev->id; - dws->num_cs = 4; + if (pdev->dev.of_node == NULL) + dws->num_cs = 4; + ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &tmp); + if (ret == 0) + dws->num_cs = tmp; + if (dws->num_cs == 0) { + dev_err(&pdev->dev, "missing or wrong num-cs property\n"); + goto out; + } dws->max_freq = clk_get_rate(dwsmmio->clk); ret = dw_spi_add_host(&pdev->dev, dws); @@ -92,12 +102,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);