From patchwork Fri Feb 5 07:11:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: qiujiang X-Patchwork-Id: 8232041 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F0C60BEEE5 for ; Fri, 5 Feb 2016 07:05:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 137132039C for ; Fri, 5 Feb 2016 07:05:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C1E2201FA for ; Fri, 5 Feb 2016 07:05:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750997AbcBEHF3 (ORCPT ); Fri, 5 Feb 2016 02:05:29 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:44251 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbcBEHF2 (ORCPT ); Fri, 5 Feb 2016 02:05:28 -0500 Received: from 172.24.1.49 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DAZ25523; Fri, 05 Feb 2016 15:05:23 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Fri, 5 Feb 2016 15:05:13 +0800 From: qiujiang To: CC: , , , , , , qiujiang Subject: [RFC PATCH] SPI/ACPI: DesignWare: Add ACPI support for Designware SPI driver Date: Fri, 5 Feb 2016 15:11:20 +0800 Message-ID: <1454656280-130658-1-git-send-email-qiujiang@huawei.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.56B449B4.0113, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f6ca718fbcbffc35f33885f63e08b664 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This patch added ACPI support for DesignWare SPI mmio driver. It was based the corresponding DT driver and compatible for this two way. This patch has been tested on Hisilicon D02 board. It relies on the GPIO patchset. Signed-off-by: qiujiang --- drivers/spi/spi-dw-mmio.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index a6d7029..de542f0 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -8,6 +8,7 @@ * version 2, as published by the Free Software Foundation. */ +#include #include #include #include @@ -36,7 +37,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) struct dw_spi *dws; struct resource *mem; int ret; - int num_cs; + int num_cs, i; + struct gpio_desc *gpiod; + char propname[32]; dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), GFP_KERNEL); @@ -84,8 +87,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) dws->num_cs = num_cs; if (pdev->dev.of_node) { - int i; - for (i = 0; i < dws->num_cs; i++) { int cs_gpio = of_get_named_gpio(pdev->dev.of_node, "cs-gpios", i); @@ -104,6 +105,18 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) } } + if (ACPI_COMPANION(&pdev->dev)) { + for (i = 0; i < dws->num_cs; i++) { + snprintf(propname, sizeof(propname), "cs%d", i); + gpiod = devm_gpiod_get(&pdev->dev, + propname, GPIOD_ASIS); + if (IS_ERR(gpiod)) { + dev_err(&pdev->dev, "Get gpio desc failed!\n"); + return PTR_ERR(gpiod); + } + } + } + ret = dw_spi_add_host(&pdev->dev, dws); if (ret) goto out; @@ -132,12 +145,19 @@ static const struct of_device_id dw_spi_mmio_of_match[] = { }; MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match); +static const struct acpi_device_id dw_spi_mmio_acpi_match[] = { + {"HISI0171", 0}, + { } +}; +MODULE_DEVICE_TABLE(acpi, dw_spi_mmio_acpi_match); + static struct platform_driver dw_spi_mmio_driver = { .probe = dw_spi_mmio_probe, .remove = dw_spi_mmio_remove, .driver = { .name = DRIVER_NAME, .of_match_table = dw_spi_mmio_of_match, + .acpi_match_table = ACPI_PTR(dw_spi_mmio_acpi_match), }, }; module_platform_driver(dw_spi_mmio_driver);