1 #ifndef __ASM_ARM_DEVICE_H
2 #define __ASM_ARM_DEVICE_H
3 
4 #include <xen/init.h>
5 
6 enum device_type
7 {
8     DEV_DT,
9 };
10 
11 struct dev_archdata {
12     void *iommu;    /* IOMMU private data */
13 };
14 
15 /* struct device - The basic device structure */
16 struct device
17 {
18     enum device_type type;
19 #ifdef CONFIG_HAS_DEVICE_TREE
20     struct dt_device_node *of_node; /* Used by drivers imported from Linux */
21 #endif
22     struct dev_archdata archdata;
23 };
24 
25 typedef struct device device_t;
26 
27 #include <xen/device_tree.h>
28 
29 /* TODO: Correctly implement dev_is_pci when PCI is supported on ARM */
30 #define dev_is_pci(dev) ((void)(dev), 0)
31 #define dev_is_dt(dev)  ((dev->type == DEV_DT)
32 
33 enum device_class
34 {
35     DEVICE_SERIAL,
36     DEVICE_IOMMU,
37     DEVICE_GIC,
38     /* Use for error */
39     DEVICE_UNKNOWN,
40 };
41 
42 struct device_desc {
43     /* Device name */
44     const char *name;
45     /* Device class */
46     enum device_class class;
47     /* List of devices supported by this driver */
48     const struct dt_device_match *dt_match;
49     /* Device initialization */
50     int (*init)(struct dt_device_node *dev, const void *data);
51 };
52 
53 struct acpi_device_desc {
54     /* Device name */
55     const char *name;
56     /* Device class */
57     enum device_class class;
58     /* type of device supported by the driver */
59     const int class_type;
60     /* Device initialization */
61     int (*init)(const void *data);
62 };
63 
64 /**
65  *  acpi_device_init - Initialize a device
66  *  @class: class of the device (serial, network...)
67  *  @data: specific data for initializing the device
68  *
69  *  Return 0 on success.
70  */
71 int __init acpi_device_init(enum device_class class,
72                             const void *data, int class_type);
73 
74 /**
75  *  device_init - Initialize a device
76  *  @dev: device to initialize
77  *  @class: class of the device (serial, network...)
78  *  @data: specific data for initializing the device
79  *
80  *  Return 0 on success.
81  */
82 int __init device_init(struct dt_device_node *dev, enum device_class class,
83                        const void *data);
84 
85 /**
86  * device_get_type - Get the type of the device
87  * @dev: device to match
88  *
89  * Return the device type on success or DEVICE_ANY on failure
90  */
91 enum device_class device_get_class(const struct dt_device_node *dev);
92 
93 #define DT_DEVICE_START(_name, _namestr, _class)                    \
94 static const struct device_desc __dev_desc_##_name __used           \
95 __section(".dev.info") = {                                          \
96     .name = _namestr,                                               \
97     .class = _class,                                                \
98 
99 #define DT_DEVICE_END                                               \
100 };
101 
102 #define ACPI_DEVICE_START(_name, _namestr, _class)                    \
103 static const struct acpi_device_desc __dev_desc_##_name __used           \
104 __section(".adev.info") = {                       \
105     .name = _namestr,                                               \
106     .class = _class,                                                \
107 
108 #define ACPI_DEVICE_END                                               \
109 };
110 
111 #endif /* __ASM_ARM_DEVICE_H */
112 
113 /*
114  * Local variables:
115  * mode: C
116  * c-file-style: "BSD"
117  * c-basic-offset: 4
118  * indent-tabs-mode: nil
119  * End:
120  */
121