From patchwork Tue Nov 17 09:40:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7634511 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 70426BF90C for ; Tue, 17 Nov 2015 09:50:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39ED02047D for ; Tue, 17 Nov 2015 09:50:31 +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 4D60520454 for ; Tue, 17 Nov 2015 09:50:30 +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 1Zycs6-0003FP-F5; Tue, 17 Nov 2015 09:48:18 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zycou-0007Oc-CU for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 09:45:08 +0000 Received: by wmww144 with SMTP id w144so145613672wmw.1 for ; Tue, 17 Nov 2015 01:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KKaluU8GV5uO6AL97dSpwfFLHvfEBX6PNrJQIFd8jm4=; b=jKVHMfuNoaqw4mW+XFsYE2NoQYkM6X3tzHvTf8A/ez6VkXS0iHC+rzCinDYvvbEgEC YCDKmOCPFP6FrycMnT2YnaMPoWN7MssUA5Nbeq1JisG8DryYPejkuI/SYmCPEJJMgM26 N0iZ7NDSIYklOcxbW4CzkBGZEQzLMKaf6s8yXmNjWYiLgX36w3L0Cs205NSOkEJvcByK 6ZHBVHvhSzel0UcaFVg6NNKdGow7fi3XCfyOiIePIKtxhPv9svRih4X7uMvw11AAhWW5 iILEVmbo936g9VaP0o3sQL1RR1SYdt/tG5SBHoV++BaUnBgo4QaSQYAsTD0OADbuqJuq 25IQ== 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=KKaluU8GV5uO6AL97dSpwfFLHvfEBX6PNrJQIFd8jm4=; b=d8c5x6Rl5drb3mmzSnsUYfka7bjXobjTDDbrBIOsUzx5R4BUyCDDZNNHP6Gb/svHt8 GkYwhRAeoZLWKOE5CMHAdfuOKQnPyQoKCIbguj4ZGZvA8g+oEXZHG9gjPMog/8/VDTYl 1XctcS/zJ19ZDBR/B3Ykups7qHXvb9f9QVjsLpFRRlmqtUXBcuMwdS/peF7m43n9e5Z5 LHY063Cm2As5YH7lk8KLLByg+0fmsSLcDJTBoAIMN4kpvb/hLzknOaTgcGiusCS1qo8T OlUkocyMSHt3sYiRm6xjhYMvKMplnu9BKfrcoQMeC39KEuklCtSQK+ckhw8dsmfGcZHw jlOQ== X-Gm-Message-State: ALoCoQkteZI0T+B9lhU/4lRdoTh/9SStoCEDYXGaq1ZoKl4mnSQUWQR0lW7YhTzIMMTl/AbpWz7/ X-Received: by 10.194.87.39 with SMTP id u7mr41974926wjz.11.1447753478916; Tue, 17 Nov 2015 01:44:38 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id h67sm22939291wmf.17.2015.11.17.01.44.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:44:37 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Subject: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi Date: Tue, 17 Nov 2015 17:40:23 +0800 Message-Id: <1447753261-7552-25-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_014500_964530_866B5E8D X-CRM114-Status: GOOD ( 14.21 ) X-Spam-Score: -2.6 (--) 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: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com 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.7 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: Parth Dixit Add generic way to use device from acpi similar to the way it is supported in device tree. Signed-off-by: Parth Dixit Signed-off-by: Shannon Zhao --- xen/arch/arm/device.c | 19 +++++++++++++++++++ xen/arch/arm/xen.lds.S | 7 +++++++ xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 0b53f6a..5494de0 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -22,6 +22,7 @@ #include extern const struct device_desc _sdevice[], _edevice[]; +extern const struct acpi_device_desc _asdevice[], _aedevice[]; int __init device_init(struct dt_device_node *dev, enum device_class class, const void *data) @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class, return -EBADF; } +int __init acpi_device_init(enum device_class class, const void *data, int class_type) +{ + const struct acpi_device_desc *desc; + + for ( desc = _asdevice; desc != _aedevice; desc++ ) + { + if ( ( desc->class != class ) && ( desc->class_type != class_type ) ) + continue; + + + ASSERT(desc->init != NULL); + + return desc->init(data); + } + + return -EBADF; +} + enum device_class device_get_class(const struct dt_device_node *dev) { const struct device_desc *desc; diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 0488f37..60802f6 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -100,6 +100,13 @@ SECTIONS _edevice = .; } :text + . = ALIGN(8); + .adev.info : { + _asdevice = .; + *(.adev.info) + _aedevice = .; + } :text + . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : { diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h index 5d0a4cd..085f221 100644 --- a/xen/include/asm-arm/device.h +++ b/xen/include/asm-arm/device.h @@ -50,6 +50,27 @@ struct device_desc { int (*init)(struct dt_device_node *dev, const void *data); }; +struct acpi_device_desc { + /* Device name */ + const char *name; + /* Device class */ + enum device_class class; + /* type of device supported by the driver */ + const int class_type; + /* Device initialization */ + int (*init)(const void *data); +}; + +/** + * acpi_device_init - Initialize a device + * @class: class of the device (serial, network...) + * @data: specific data for initializing the device + * + * Return 0 on success. + */ +int __init acpi_device_init(enum device_class class, + const void *data, int class_type); + /** * device_init - Initialize a device * @dev: device to initialize @@ -78,6 +99,15 @@ __section(".dev.info") = { \ #define DT_DEVICE_END \ }; +#define ACPI_DEVICE_START(_name, _namestr, _class) \ +static const struct acpi_device_desc __dev_desc_##_name __used \ +__attribute__((__section__(".adev.info"))) = { \ + .name = _namestr, \ + .class = _class, \ + +#define ACPI_DEVICE_END \ +}; + #endif /* __ASM_ARM_DEVICE_H */ /*