From patchwork Mon Jan 11 13:26:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Makarov X-Patchwork-Id: 8003811 Return-Path: X-Original-To: patchwork-linux-arm@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 C9656BEEE5 for ; Mon, 11 Jan 2016 13:36:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D784020279 for ; Mon, 11 Jan 2016 13:36:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB26F20220 for ; Mon, 11 Jan 2016 13:36:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIccX-0002jJ-8a; Mon, 11 Jan 2016 13:34:53 +0000 Received: from mail-lb0-x22e.google.com ([2a00:1450:4010:c04::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIcV3-0002fj-V0 for linux-arm-kernel@lists.infradead.org; Mon, 11 Jan 2016 13:27:38 +0000 Received: by mail-lb0-x22e.google.com with SMTP id cl12so36564461lbc.1 for ; Mon, 11 Jan 2016 05:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f03euiBDTlhM+0mrmJ/7MhSLfXWI2IxAPpyUqSXiqqE=; b=YJzI4XjFqrUIK5TAPlgTUF2FuxLsdHpUuxthqmXtnx/ITeig1usInynNdX2h1pKCGJ 2ApXq0o15U28Uw7/5S9b4Ax0w+TjwrrVNkelojVFEhjUef2kzWRe8KTwru0WC9WVg6+J ZuEogPsaT8c/V6blwUvLY6yrFHEvPMXVaLclI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f03euiBDTlhM+0mrmJ/7MhSLfXWI2IxAPpyUqSXiqqE=; b=lUipcvYYrpQo6TOypP61fuFWzwnyTNw0oM+BLXz6CRQp36tRLXIO5SzEoo6ykm8Ic5 9K69nqtibRg544hQAxYDXXdrzqoK9hYGU5eTlKnPcKagAa8uRFcLRl8v/DJEWF/V3UQz YMJ59skGgWONMahiBbUFkwk+/TJe18xFc2VARpcCvlAC8wI2hiElkc+MRL69Al22Xrva Pyj2iE8Xpi/H5ukMOEH9O4JlrIw+S99MQOGSApT1+xAGzo3HYMZ5/cQ1mYYKr1T84wz7 8uMI7Y+c2IZGmOJRyv0uUdbiACgw0DrJbeTWlxelEkhgVDAsel4TkoXABFWuh/dmaZ0F 138A== X-Gm-Message-State: ALoCoQlmRz8h2KTbEpFxRQfjyNs/lIBYrgL7TwGsJVcJRTqsSOD0IzYppeqUAWiadh/NOEqhGFALNG8Jwwm7le6Q7tJ3SfeELQ== X-Received: by 10.112.145.131 with SMTP id su3mr2738960lbb.19.1452518807986; Mon, 11 Jan 2016 05:26:47 -0800 (PST) Received: from lemon.localdomain (host-2-60-215-78.pppoe.omsknet.ru. [2.60.215.78]) by smtp.gmail.com with ESMTPSA id xf10sm2418277lbb.23.2016.01.11.05.26.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 05:26:47 -0800 (PST) From: Aleksey Makarov To: linux-acpi@vger.kernel.org Subject: [PATCH v5 2/2] ACPI: amba bus probing support Date: Mon, 11 Jan 2016 19:26:27 +0600 Message-Id: <1452518790-27053-3-git-send-email-aleksey.makarov@linaro.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1452518790-27053-1-git-send-email-aleksey.makarov@linaro.org> References: <1452518790-27053-1-git-send-email-aleksey.makarov@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160111_052711_282728_23FF0749 X-CRM114-Status: GOOD ( 21.63 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King , Graeme Gregory , Greg Kroah-Hartman , Andy Shevchenko , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Vladimir Zapolskiy , Aleksey Makarov , Shannon Zhao , linux-arm-kernel@lists.infradead.org, Len Brown MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Graeme Gregory On ARM64 some devices use the AMBA device and not the platform bus for probing so add support for this. Uses a dummy clock for apb_pclk as ACPI does not have a suitable clock representation and to keep the core AMBA bus code unchanged between probing methods. Signed-off-by: Graeme Gregory Signed-off-by: Aleksey Makarov Acked-by: Russell King --- drivers/acpi/Makefile | 1 + drivers/acpi/acpi_amba.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/internal.h | 5 ++ drivers/acpi/scan.c | 1 + 4 files changed, 129 insertions(+) create mode 100644 drivers/acpi/acpi_amba.c diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 675eaf3..3cf732f 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -43,6 +43,7 @@ acpi-y += pci_root.o pci_link.o pci_irq.o acpi-y += acpi_lpss.o acpi_apd.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o +acpi-$(CONFIG_ARM_AMBA) += acpi_amba.o acpi-y += int340x_thermal.o acpi-y += power.o acpi-y += event.o diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c new file mode 100644 index 0000000..2a61b54 --- /dev/null +++ b/drivers/acpi/acpi_amba.c @@ -0,0 +1,122 @@ + +/* + * ACPI support for platform bus type. + * + * Copyright (C) 2015, Linaro Ltd + * Author: Graeme Gregory + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "internal.h" + +static const struct acpi_device_id amba_id_list[] = { + {"ARMH0061", 0}, /* PL061 GPIO Device */ + {"", 0}, +}; + +static void amba_register_dummy_clk(void) +{ + static struct clk *amba_dummy_clk; + + /* If clock already registered */ + if (amba_dummy_clk) + return; + + amba_dummy_clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, + CLK_IS_ROOT, 0); + clk_register_clkdev(amba_dummy_clk, "apb_pclk", NULL); +} + +static int amba_handler_attach(struct acpi_device *adev, + const struct acpi_device_id *id) +{ + struct amba_device *dev; + struct resource_entry *rentry; + struct list_head resource_list; + bool address_found = false; + int irq_no = 0; + int ret; + + /* If the ACPI node already has a physical device attached, skip it. */ + if (adev->physical_node_count) + return 0; + + dev = amba_device_alloc(dev_name(&adev->dev), 0, 0); + if (!dev) { + dev_err(&adev->dev, "%s(): amba_device_alloc() failed\n", + __func__); + return -ENOMEM; + } + + INIT_LIST_HEAD(&resource_list); + ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); + if (ret < 0) + goto err_free; + + list_for_each_entry(rentry, &resource_list, node) { + switch (resource_type(rentry->res)) { + case IORESOURCE_MEM: + if (!address_found) { + dev->res = *rentry->res; + address_found = true; + } + break; + case IORESOURCE_IRQ: + if (irq_no < AMBA_NR_IRQS) + dev->irq[irq_no++] = rentry->res->start; + break; + default: + dev_warn(&adev->dev, "Invalid resource\n"); + break; + } + } + + acpi_dev_free_resource_list(&resource_list); + + /* + * If the ACPI node has a parent and that parent has a physical device + * attached to it, that physical device should be the parent of + * the amba device we are about to create. + */ + if (adev->parent) + dev->dev.parent = acpi_get_first_physical_node(adev->parent); + + ACPI_COMPANION_SET(&dev->dev, adev); + + ret = amba_device_add(dev, &iomem_resource); + if (ret) { + dev_err(&adev->dev, "%s(): amba_device_add() failed (%d)\n", + __func__, ret); + goto err_free; + } + + return 1; + +err_free: + amba_device_put(dev); + return ret; +} + +static struct acpi_scan_handler amba_handler = { + .ids = amba_id_list, + .attach = amba_handler_attach, +}; + +void __init acpi_amba_init(void) +{ + amba_register_dummy_clk(); + acpi_scan_add_handler(&amba_handler); +} diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index ee9312ba..6086f66 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -29,6 +29,11 @@ void acpi_processor_init(void); void acpi_platform_init(void); void acpi_pnp_init(void); void acpi_int340x_thermal_init(void); +#ifdef CONFIG_ARM_AMBA +void acpi_amba_init(void); +#else +static inline void acpi_amba_init(void) {} +#endif int acpi_sysfs_init(void); void acpi_container_init(void); void acpi_memory_hotplug_init(void); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 78d5f02..20c8cba 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1922,6 +1922,7 @@ int __init acpi_scan_init(void) acpi_memory_hotplug_init(); acpi_pnp_init(); acpi_int340x_thermal_init(); + acpi_amba_init(); acpi_scan_add_handler(&generic_device_handler);