From patchwork Wed Jan 20 14:29: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: 60036 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3206985lbb; Wed, 20 Jan 2016 06:30:00 -0800 (PST) X-Received: by 10.98.80.135 with SMTP id g7mr53003949pfj.132.1453300200181; Wed, 20 Jan 2016 06:30:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q140si55491686pfq.49.2016.01.20.06.29.59; Wed, 20 Jan 2016 06:30:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934236AbcATO35 (ORCPT + 29 others); Wed, 20 Jan 2016 09:29:57 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:35085 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934183AbcATO3t (ORCPT ); Wed, 20 Jan 2016 09:29:49 -0500 Received: by mail-lf0-f48.google.com with SMTP id c192so6956178lfe.2 for ; Wed, 20 Jan 2016 06:29:48 -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=1y0NZxwf0DN5smw1OFzD7gmHi7/2dnpoDSpIIIo3uzY=; b=T1204ijm0Kbn48mSt7+bOpVvhXa4qynpRf+cC7wkaYvck66rt3B0VAN4m7Ki+Pvdt0 dCtlx7fgoyw+vgUWt8ISIsq28l1hS/DZ9MztQmRkJjLJE+UaYhJIKrbLQjxrhrYSj1ug Wnm5b3IsRZIX3KHxMLsyDuh+2taS7eUrk7/zY= 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=1y0NZxwf0DN5smw1OFzD7gmHi7/2dnpoDSpIIIo3uzY=; b=gBlPqTSmMeK9FbYAGHXrdR6phd52GniSs2APtazFOAsJlnXluTVU+ZieY1967yUtj9 3kYdtcvU3xXIHBKLF/4M9I5M1Jc6CnlQNKN/P7+8oZrkiKJwAGvhidxw61z2medi7Q1u 17uypaFmQSNAPf0jRB6g4xbPVJPj3xa8nJZUxk1KsFEy0Am2OmK1HTVnJBjt2nFcMwVU svFHLpAav9iAMxQn5aoC89/fa+D7d4gJ0gduxmOVCnHiYHbhXi9SZqvZLOdAD2CT8pqI iclg5bCFYzKMX07eT440eBem3XjfmFjRMo00AAPNCwWXpoMO3d/x4U9KfHNC73qtTZ/M RElQ== X-Gm-Message-State: ALoCoQlS9v+K67w9x+ZNUjxbaJdvTyUlz5jBhLRjo7xTI7YwAWjbU9NFj/q7VoXeNz/MDWYTjCdF2RO38i5fmh1mDMdNyhFNWA== X-Received: by 10.25.168.133 with SMTP id r127mr10939819lfe.134.1453300187740; Wed, 20 Jan 2016 06:29:47 -0800 (PST) Received: from lemon.localdomain (host-2-60-44-52.pppoe.omsknet.ru. [2.60.44.52]) by smtp.gmail.com with ESMTPSA id q8sm4683121lbf.24.2016.01.20.06.29.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 06:29:46 -0800 (PST) From: Aleksey Makarov To: linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Aleksey Makarov , Graeme Gregory , Russell King , Greg Kroah-Hartman , "Rafael J . Wysocki" , Shannon Zhao , Andy Shevchenko , Vladimir Zapolskiy , Len Brown Subject: [PATCH v6 2/2] ACPI: amba bus probing support Date: Wed, 20 Jan 2016 20:29:27 +0600 Message-Id: <1453300171-25473-3-git-send-email-aleksey.makarov@linaro.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453300171-25473-1-git-send-email-aleksey.makarov@linaro.org> References: <1453300171-25473-1-git-send-email-aleksey.makarov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Acked-by: Russell King Signed-off-by: Graeme Gregory Signed-off-by: Aleksey Makarov --- 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 -- 2.7.0 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 265eb90..f632ef1 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);