From patchwork Thu May 25 11:37:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriele Paoloni X-Patchwork-Id: 9748289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A37FA60388 for ; Thu, 25 May 2017 11:48:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E46426B41 for ; Thu, 25 May 2017 11:48:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8283827CF9; Thu, 25 May 2017 11:48:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 20B6E271BC for ; Thu, 25 May 2017 11:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9U+z0sVBKzoNnp+H5vJ7CzHW4o4tnaLFQtNpoV+lsN0=; b=Upc729SC15U2iz CqgQNruaI1OkPmgQRESG9kYnj7G+M4vsrA3vuY20pGDcJqFKeQPZWp8zG1mhQzf2BiTiBI78hNLU0 8NhN0DVyAkBu7T8HqMCWHjsnn15qV941P42L23jIeEWhlWuD/FFTFYMjUqMkNx3xFv1jkD9sw1L3U Z81/Y4KmQNVshTxu+sgxhVYvGz46w98jvWR4yNSQlGuPX+8Mdzl/kbJbraupMaqhgUwLHHrR1MPhg z9eY0oUzuSVO7qz1gdLIga9AInH/YgqMN1fjcukUUfWHKlgK+sXtDIHB0FcsrYp8QyNPm6QK28UGQ xf+Z92AcctGHkUPUXc1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dDrFd-0006dB-Pa; Thu, 25 May 2017 11:48:21 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dDrFa-0006bz-RM for linux-arm-kernel@lists.infradead.org; Thu, 25 May 2017 11:48:20 +0000 Received: from 172.30.72.57 (EHLO DGGEML401-HUB.china.huawei.com) ([172.30.72.57]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id APE94826; Thu, 25 May 2017 19:39:12 +0800 (CST) Received: from G00308965-DELL1.china.huawei.com (10.203.181.156) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Thu, 25 May 2017 19:39:03 +0800 From: Gabriele Paoloni To: , , , , , , , , Subject: [PATCH v9 6/7] LPC: Add the ACPI LPC support Date: Thu, 25 May 2017 12:37:27 +0100 Message-ID: <1495712248-5232-7-git-send-email-gabriele.paoloni@huawei.com> X-Mailer: git-send-email 2.7.1.windows.1 In-Reply-To: <1495712248-5232-1-git-send-email-gabriele.paoloni@huawei.com> References: <1495712248-5232-1-git-send-email-gabriele.paoloni@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.181.156] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.5926C261.0170, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5a95c541780afe83448bd7224a026c86 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170525_044819_221713_C58FFF91 X-CRM114-Status: GOOD ( 15.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, minyard@acm.org, gabriele.paoloni@huawei.com, benh@kernel.crashing.org, john.garry@huawei.com, linux-kernel@vger.kernel.org, xuwei5@hisilicon.com, linuxarm@huawei.com, linux-acpi@vger.kernel.org, "zhichang.yuan" , linux-pci@vger.kernel.org, olof@lixom.net, brian.starkey@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: "zhichang.yuan" Based on the provious patches, this patch supports the ACPI LPC host on Hip06/Hip07. Signed-off-by: zhichang.yuan Signed-off-by: John Garry Signed-off-by: Gabriele Paoloni Tested-by: dann frazier --- drivers/acpi/arm64/acpi_indirect_pio.c | 3 ++ drivers/bus/hisi_lpc.c | 71 ++++++++++++++++++++++++++++++++-- include/acpi/acpi_indirect_pio.h | 4 ++ 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/arm64/acpi_indirect_pio.c b/drivers/acpi/arm64/acpi_indirect_pio.c index 7813f73..3a5ba7a 100644 --- a/drivers/acpi/arm64/acpi_indirect_pio.c +++ b/drivers/acpi/arm64/acpi_indirect_pio.c @@ -261,6 +261,9 @@ int acpi_set_logic_pio_resource(struct device *child, /* All the host devices which apply indirect-PIO can be listed here. */ static const struct acpi_device_id acpi_indirect_host_id[] = { +#ifdef CONFIG_HISILICON_LPC + {"HISI0191", INDIRECT_PIO_INFO(lpc_host_desc)}, +#endif {""}, }; diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c index 4f3bf76..05a0a84 100644 --- a/drivers/bus/hisi_lpc.c +++ b/drivers/bus/hisi_lpc.c @@ -467,7 +467,9 @@ static int hisilpc_probe(struct platform_device *pdev) } /* register the LPC host PIO resources */ - if (!has_acpi_companion(dev)) { + if (has_acpi_companion(dev)) { + lpcdev->io_host = find_io_range_by_fwnode(dev->fwnode); + } else { struct logic_pio_hwaddr *range; range = kzalloc(sizeof(*range), GFP_KERNEL); @@ -481,13 +483,14 @@ static int hisilpc_probe(struct platform_device *pdev) ret = logic_pio_register_range(range); if (ret) { kfree(range); - dev_err(dev, "OF: register IO range FAIL!\n"); + dev_err(dev, "OF: logic_pio_register_range returned %d!\n", + ret); return -ret; } lpcdev->io_host = range; } if (!lpcdev->io_host) { - dev_err(dev, "Hisilpc IO hasn't registered!\n"); + dev_err(dev, "HiSi LPC IO hasn't been registered!\n"); return -EFAULT; } @@ -533,10 +536,72 @@ static const struct of_device_id hisilpc_of_match[] = { {}, }; +#ifdef CONFIG_ACPI +#include + +struct lpc_private_data { + resource_size_t io_size; + resource_size_t io_start; +}; + +static struct lpc_private_data lpc_data = { + .io_size = LPC_BUS_IO_SIZE, + .io_start = LPC_MIN_BUS_RANGE, +}; + +static int lpc_host_io_setup(struct acpi_device *adev, void *pdata) +{ + int ret = 0; + struct logic_pio_hwaddr *range; + struct lpc_private_data *lpc_private; + struct acpi_device *child; + + lpc_private = (struct lpc_private_data *)pdata; + range = kzalloc(sizeof(*range), GFP_KERNEL); + if (!range) + return -ENOMEM; + range->fwnode = &adev->fwnode; + range->flags = PIO_INDIRECT; + range->size = lpc_private->io_size; + range->hw_start = lpc_private->io_start; + + ret = logic_pio_register_range(range); + if (ret) { + kfree(range); + return ret; + } + + /* In HiSilicon lpc, only care about the children of the host. */ + list_for_each_entry(child, &adev->children, node) { + ret = acpi_set_logic_pio_resource(&child->dev, &adev->dev); + if (ret) { + dev_err(&child->dev, + "acpi_set_logic_pio_resource() returned %d\n", + ret); + return ret; + } + } + + return ret; +} + +static const struct acpi_device_id hisilpc_acpi_match[] = { + {"HISI0191", }, + {}, +}; + +const struct indirect_pio_device_desc lpc_host_desc = { + .pdata = &lpc_data, + .pre_setup = lpc_host_io_setup, +}; + +#endif + static struct platform_driver hisilpc_driver = { .driver = { .name = "hisi_lpc", .of_match_table = hisilpc_of_match, + .acpi_match_table = ACPI_PTR(hisilpc_acpi_match), }, .probe = hisilpc_probe, }; diff --git a/include/acpi/acpi_indirect_pio.h b/include/acpi/acpi_indirect_pio.h index efc5c43..7a8d26b 100644 --- a/include/acpi/acpi_indirect_pio.h +++ b/include/acpi/acpi_indirect_pio.h @@ -18,6 +18,10 @@ struct indirect_pio_device_desc { int (*pre_setup)(struct acpi_device *adev, void *pdata); }; +#ifdef CONFIG_HISILICON_LPC +extern const struct indirect_pio_device_desc lpc_host_desc; +#endif + int acpi_set_logic_pio_resource(struct device *child, struct device *hostdev);