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