From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Stabellini Subject: Re: [PATCH v4 11/21] arm: Introduce a generic way to use a device from acpi Date: Thu, 28 Jan 2016 12:45:42 +0000 Message-ID: References: <1453540813-15764-1-git-send-email-zhaoshenglong@huawei.com> <1453540813-15764-12-git-send-email-zhaoshenglong@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1453540813-15764-12-git-send-email-zhaoshenglong@huawei.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Shannon Zhao Cc: ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, peter.huangpeng@huawei.com, xen-devel@lists.xen.org, julien.grall@citrix.com, stefano.stabellini@citrix.com, shannon.zhao@linaro.org List-Id: xen-devel@lists.xenproject.org On Sat, 23 Jan 2016, Shannon Zhao wrote: > 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 Acked-by: Stefano Stabellini > V4: drop __attribute__ > --- > xen/arch/arm/device.c | 18 ++++++++++++++++++ > xen/arch/arm/xen.lds.S | 7 +++++++ > xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 55 insertions(+) > > diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c > index 0b53f6a..a0072c1 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,23 @@ 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 b455bdf..6734ae8 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 \ > +__section(".adev.info") = { \ > + .name = _namestr, \ > + .class = _class, \ > + > +#define ACPI_DEVICE_END \ > +}; > + > #endif /* __ASM_ARM_DEVICE_H */ > > /* > -- > 2.0.4 > >