From patchwork Sun May 17 20:03:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 48639 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E61621411 for ; Sun, 17 May 2015 20:06:24 +0000 (UTC) Received: by wivs14 with SMTP id s14sf15382095wiv.1 for ; Sun, 17 May 2015 13:06:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=cekl02ChKu17do04C5+fg1vW/ilwszQ5KYgqtqxZhVY=; b=irPWPVlFA5XTolp6JA0QckjHWhbh76gzOTf12hAzAqhdt1naRgCgTUPeeJI+vWiY5x KigMKvXquZFD6FbCtHY/7G6010voGnUUZvwQ44oBoXDiO0U9t/vGgAp+Cp0WiWiZagEk rOQdQ1B1xemg5+9m6npxR8wI1wQzn+owfFkLtL6YawiJx2/Hk398xufx6hbC3vTbh+D0 UVbSu+r5BMEhF35rhkOIIyOCS3V60sTmbxJ375wRK731sE5JGI0JzAFRRjHcTkk4Ut43 KbZSLS+C/Bzd1mx06Mq0t1OvjMSddu5cBOapnjjxxD1yMvaGNYRiySfmIy+7NNYfqe+0 aI7Q== X-Gm-Message-State: ALoCoQmmLxtqU/bRj8R5nX4ZpTHrRBvsCy9UVJM1Juwh9e6dOP+MAmwQcMCjyuseCVijCbor1nh0 X-Received: by 10.180.73.137 with SMTP id l9mr7264533wiv.5.1431893183471; Sun, 17 May 2015 13:06:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.227 with SMTP id kt3ls574361lac.18.gmail; Sun, 17 May 2015 13:06:23 -0700 (PDT) X-Received: by 10.152.5.98 with SMTP id r2mr3158462lar.101.1431893183306; Sun, 17 May 2015 13:06:23 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id h19si5325986lbo.102.2015.05.17.13.06.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 13:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labbd9 with SMTP id bd9so191521325lab.2 for ; Sun, 17 May 2015 13:06:23 -0700 (PDT) X-Received: by 10.112.161.226 with SMTP id xv2mr15126192lbb.106.1431893183019; Sun, 17 May 2015 13:06:23 -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.108.230 with SMTP id hn6csp3507864lbb; Sun, 17 May 2015 13:06:22 -0700 (PDT) X-Received: by 10.52.32.34 with SMTP id f2mr17724790vdi.11.1431893181577; Sun, 17 May 2015 13:06:21 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id w7si4318495vdg.95.2015.05.17.13.06.20 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 13:06:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4of-0002Fs-FE; Sun, 17 May 2015 20:05:41 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yu4od-0002DF-SU for xen-devel@lists.xen.org; Sun, 17 May 2015 20:05:40 +0000 Received: from [193.109.254.147] by server-3.bemta-14.messagelabs.com id 38/00-03032-294F8555; Sun, 17 May 2015 20:05:38 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-14.tower-27.messagelabs.com!1431893135!18254038!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30218 invoked from network); 17 May 2015 20:05:36 -0000 Received: from mail-pd0-f179.google.com (HELO mail-pd0-f179.google.com) (209.85.192.179) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 May 2015 20:05:36 -0000 Received: by pdbqa5 with SMTP id qa5so117367860pdb.0 for ; Sun, 17 May 2015 13:05:35 -0700 (PDT) X-Received: by 10.68.65.43 with SMTP id u11mr33748474pbs.41.1431893135269; Sun, 17 May 2015 13:05:35 -0700 (PDT) Received: from localhost.localdomain ([117.247.24.139]) by mx.google.com with ESMTPSA id j9sm7838401pdm.53.2015.05.17.13.05.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 May 2015 13:05:34 -0700 (PDT) From: Parth Dixit To: xen-devel@lists.xen.org Date: Mon, 18 May 2015 01:33:45 +0530 Message-Id: <1431893048-5214-19-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> References: <1431893048-5214-1-git-send-email-parth.dixit@linaro.org> Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, tim@xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, jbeulich@suse.com, parth.dixit@linaro.org, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH v2 18/41] arm: Introduce a generic way to use a device from acpi X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@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.215.44 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-Archive: add generic way to use device from acpi similar to the way it is supported in device tree. Signed-off-by: Parth Dixit --- 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 a72f7c9..09fcfc3 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 @@ __attribute__((__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 */ /*