From patchwork Tue May 5 13:50:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 48031 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 469C120553 for ; Tue, 5 May 2015 13:52:41 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf53520788wgt.1 for ; Tue, 05 May 2015 06:52:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=lrp/kUXwNqbTtZ53N7XpDPg7PJbHZ071EyRWoqjP3ok=; b=lxwPXpUusL1ZBWu8WyqsgcWZlrccsARHdaSpyCBwoDPS8NkTw9HkgMyVzR2yBWqp8q DHnzKxxOSzWFY40AhkLNk0yjZyyY28+bsypSeH0Up4xVuAr2NKzOON0ykxgWyNGvwSoU YbdHB+m11qZe/hmQcfrfLOJOkaecN/7oq+tttl1pB4BZH1KH/WSnf2eT/ZK9yUoMGEuG R8S5R2wwH5WAzDjCBs/ib1v8TpgJQdnKBGAu0EroRTC+xFMSincMTAYnDcWdh+znbZ1B l97BszOaSu00cFNzu5ENblM5kW1lX33ThKqy36ptK9/ei1XDP+kdgKXiZVRXnkxeMcqr lxcA== X-Gm-Message-State: ALoCoQkdheFVvbeqefKQDDgn+xVhhF2DFoUH3lY5r6UP0xJDsrHYfaRLoDa3qc4NOCTJmCzMXtFq X-Received: by 10.152.26.134 with SMTP id l6mr22271664lag.10.1430833960562; Tue, 05 May 2015 06:52:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.194 with SMTP id v2ls1005412lag.59.gmail; Tue, 05 May 2015 06:52:40 -0700 (PDT) X-Received: by 10.152.45.97 with SMTP id l1mr24524075lam.55.1430833960389; Tue, 05 May 2015 06:52:40 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id w2si12487454laz.126.2015.05.05.06.52.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2015 06:52:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbcga7 with SMTP id ga7so129004587lbc.1 for ; Tue, 05 May 2015 06:52:40 -0700 (PDT) X-Received: by 10.152.36.2 with SMTP id m2mr23743878laj.72.1430833960260; Tue, 05 May 2015 06:52:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp2262179lbt; Tue, 5 May 2015 06:52:39 -0700 (PDT) X-Received: by 10.68.139.103 with SMTP id qx7mr51816638pbb.133.1430833958045; Tue, 05 May 2015 06:52:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk4si24355739pbb.219.2015.05.05.06.52.37; Tue, 05 May 2015 06:52:38 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992725AbbEENwc (ORCPT + 29 others); Tue, 5 May 2015 09:52:32 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35063 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992688AbbEENwP (ORCPT ); Tue, 5 May 2015 09:52:15 -0400 Received: by pabtp1 with SMTP id tp1so193943199pab.2 for ; Tue, 05 May 2015 06:52:15 -0700 (PDT) X-Received: by 10.70.38.33 with SMTP id d1mr50675108pdk.99.1430833935231; Tue, 05 May 2015 06:52:15 -0700 (PDT) Received: from localhost ([180.150.157.4]) by mx.google.com with ESMTPSA id f1sm16081521pds.62.2015.05.05.06.52.09 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 05 May 2015 06:52:10 -0700 (PDT) From: Hanjun Guo To: Marc Zyngier , Jason Cooper , Will Deacon , Catalin Marinas , "Rafael J. Wysocki" Cc: Jiang Liu , Lorenzo Pieralisi , Arnd Bergmann , Tomasz Nowicki , Grant Likely , Thomas Gleixner , Olof Johansson , linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, Hanjun Guo Subject: [RFC PATCH 2/9] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Date: Tue, 5 May 2015 21:50:50 +0800 Message-Id: <1430833857-30736-3-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430833857-30736-1-git-send-email-hanjun.guo@linaro.org> References: <1430833857-30736-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tomasz Nowicki This self-probe infrastructure works in the similar way as OF, but there is some different in the mechanism: For OF, the init fn will be called once it finds comptiable strings in DT, but for ACPI, we init irqchips by static tables, and in static ACPI tables, there are no comptiable strings to indicate irqchips, so every init function with IRQCHIP_ACPI_DECLARE in the same table will be called, but thanks to the GIC version presented in ACPI table, we can init different GIC irqchips with this framework. This mechanism can also be used for clock declare and may also works on x86 for some table parsing too. Signed-off-by: Tomasz Nowicki [hj: introduce struct acpi_table_id instead of acpi_device_id] [hj: rework it more generic to all ACPI tables and fix some issues] Signed-off-by: Hanjun Guo --- drivers/acpi/Makefile | 1 + drivers/acpi/irq.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/irqchip/irqchip.h | 12 ++++++++++++ include/asm-generic/vmlinux.lds.h | 13 +++++++++++++ include/linux/acpi.h | 14 ++++++++++++++ include/linux/mod_devicetable.h | 7 +++++++ 6 files changed, 84 insertions(+) create mode 100644 drivers/acpi/irq.c diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 431e587..0b34d99 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_ACPI_HED) += hed.o obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o +obj-$(CONFIG_IRQCHIP) += irq.o obj-$(CONFIG_ACPI_SPCR) += acpi_spcr.o # processor has its own "processor." module_param namespace diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c new file mode 100644 index 0000000..65d6b93 --- /dev/null +++ b/drivers/acpi/irq.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, Linaro Ltd. + * Author: Tomasz Nowicki + * Hanjun Guo + * + * Inspired by drivers/irqchip/irqchip.c + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + */ + +#include +#include + +/* + * This special acpi_table_id is the sentinel at the end of the + * acpi_table_id[] array of all irqchips. It is automatically placed at + * the end of the array by the linker, thanks to being part of a + * special section. + */ +static const struct acpi_table_id +irqchip_acpi_match_end __used __section(__irqchip_acpi_table_end); + +extern struct acpi_table_id __irqchip_acpi_table[]; + +void __init acpi_irqchip_init(void) +{ + struct acpi_table_id *id; + + if (acpi_disabled) + return; + + for (id = __irqchip_acpi_table; id->id[0]; id++) + acpi_table_parse(id->id, (acpi_tbl_table_handler)id->data); +} diff --git a/drivers/irqchip/irqchip.h b/drivers/irqchip/irqchip.h index 0f6486d..1949546 100644 --- a/drivers/irqchip/irqchip.h +++ b/drivers/irqchip/irqchip.h @@ -11,6 +11,7 @@ #ifndef _IRQCHIP_H #define _IRQCHIP_H +#include #include /* @@ -25,4 +26,15 @@ */ #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) +/* + * This macro must be used by the different irqchip drivers to declare + * the association between their ACPI table and their initialization function. + * + * @name: name that must be unique accross all IRQCHIP_ACPI_DECLARE of the + * same file. + * @table_id: name of the ACPI table signature + * @fn: initialization function + */ +#define IRQCHIP_ACPI_DECLARE(name, table_id, fn) \ + ACPI_DECLARE(irqchip, name, table_id, fn) #endif diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 8bd374d..625776c 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -181,6 +181,18 @@ #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) +#ifdef CONFIG_ACPI +#define ACPI_TABLE(name) \ + . = ALIGN(8); \ + VMLINUX_SYMBOL(__##name##_acpi_table) = .; \ + *(__##name##_acpi_table) \ + *(__##name##_acpi_table_end) + +#define IRQCHIP_ACPI_MATCH_TABLE() ACPI_TABLE(irqchip) +#else +#define IRQCHIP_ACPI_MATCH_TABLE() +#endif + #define KERNEL_DTB() \ STRUCT_ALIGN(); \ VMLINUX_SYMBOL(__dtb_start) = .; \ @@ -516,6 +528,7 @@ CPUIDLE_METHOD_OF_TABLES() \ KERNEL_DTB() \ IRQCHIP_OF_MATCH_TABLE() \ + IRQCHIP_ACPI_MATCH_TABLE() \ EARLYCON_TABLE() \ EARLYCON_OF_TABLES() diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4f2dfe6..c6cdbaf 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -820,6 +820,20 @@ static inline struct acpi_device *acpi_get_next_child(struct device *dev, #endif +#ifdef CONFIG_ACPI +#define ACPI_DECLARE(table, name, table_id, fn) \ + static const struct acpi_table_id __acpi_table_##name \ + __used __section(__##table##_acpi_table) \ + = { .id = table_id, \ + .data = (void *)fn } +#else +#define ACPI_DECLARE(table, name, table_id, fn) \ + static const struct acpi_table_id __acpi_table_##name \ + __attribute__((unused)) \ + = { .id = table_id, \ + .data = (void*)fn } +#endif + /* Provide support for using the SPCR table to define the console */ #ifdef CONFIG_ACPI_SPCR extern u64 spcr_serial_addr; diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 3bfd567..47c1ea1 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -199,6 +199,13 @@ struct pnp_device_id { kernel_ulong_t driver_data; }; +#define ACPI_TABLE_ID_LEN 5 + +struct acpi_table_id { + __u8 id[ACPI_TABLE_ID_LEN]; + const void *data; +}; + struct pnp_card_device_id { __u8 id[PNP_ID_LEN]; kernel_ulong_t driver_data;