The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | **************************************************************************** |
| 11 | ****************************************************************************/ |
| 12 | #ifndef _DEVICE_H_ |
| 13 | #define _DEVICE_H_ |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 14 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 15 | #include <linux/ioport.h> |
| 16 | #include <linux/kobject.h> |
| 17 | #include <linux/klist.h> |
| 18 | #include <linux/list.h> |
| 19 | #include <linux/types.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/pm.h> |
| 22 | #include <asm/semaphore.h> |
| 23 | #include <asm/atomic.h> |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 24 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 25 | #define DEVICE_NAME_SIZE 50 |
| 26 | #define DEVICE_NAME_HALF __stringify(20) |
| 27 | #define DEVICE_ID_SIZE 32 |
| 28 | #define BUS_ID_SIZE KOBJ_NAME_LEN |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 29 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 30 | struct device; |
| 31 | struct device_driver; |
| 32 | struct class; |
| 33 | struct class_device; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 34 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 35 | struct bus_type { |
| 36 | const char * name; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 37 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 38 | struct subsystem subsys; |
| 39 | struct kset drivers; |
| 40 | struct kset devices; |
| 41 | struct klist klist_devices; |
| 42 | struct klist klist_drivers; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 43 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 44 | struct bus_attribute * bus_attrs; |
| 45 | struct device_attribute * dev_attrs; |
| 46 | struct driver_attribute * drv_attrs; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 47 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 48 | int (*match)(struct device * dev, struct device_driver * drv); |
| 49 | int (*uevent)(struct device *dev, char **envp, |
| 50 | int num_envp, char *buffer, int buffer_size); |
| 51 | int (*probe)(struct device * dev); |
| 52 | int (*remove)(struct device * dev); |
| 53 | void (*shutdown)(struct device * dev); |
| 54 | int (*suspend)(struct device * dev, pm_message_t state); |
| 55 | int (*resume)(struct device * dev); |
| 56 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 57 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 58 | struct device * bus_find_device(struct bus_type *bus, struct device *start, |
| 59 | void *data, int (*match)(struct device *, void *)); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 60 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 61 | struct bus_attribute { |
| 62 | struct attribute attr; |
| 63 | ssize_t (*show)(struct bus_type *, char * buf); |
| 64 | ssize_t (*store)(struct bus_type *, const char * buf, size_t count); |
| 65 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 66 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 67 | #define BUS_ATTR(_name,_mode,_show,_store) struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 68 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 69 | struct device_driver { |
| 70 | const char * name; |
| 71 | struct bus_type * bus; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 72 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 73 | struct completion unloaded; |
| 74 | struct kobject kobj; |
| 75 | struct klist klist_devices; |
| 76 | struct klist_node knode_bus; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 77 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 78 | struct module * owner; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 79 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 80 | int (*probe) (struct device * dev); |
| 81 | int (*remove) (struct device * dev); |
| 82 | void (*shutdown) (struct device * dev); |
| 83 | int (*suspend) (struct device * dev, pm_message_t state); |
| 84 | int (*resume) (struct device * dev); |
| 85 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 86 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 87 | struct driver_attribute { |
| 88 | struct attribute attr; |
| 89 | ssize_t (*show)(struct device_driver *, char * buf); |
| 90 | ssize_t (*store)(struct device_driver *, const char * buf, size_t count); |
| 91 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 92 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 93 | #define DRIVER_ATTR(_name,_mode,_show,_store) struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 94 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 95 | struct device * driver_find_device(struct device_driver *drv, |
| 96 | struct device *start, void *data, |
| 97 | int (*match)(struct device *, void *)); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 98 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 99 | struct class { |
| 100 | const char * name; |
| 101 | struct module * owner; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 102 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 103 | struct subsystem subsys; |
| 104 | struct list_head children; |
| 105 | struct list_head devices; |
| 106 | struct list_head interfaces; |
| 107 | struct semaphore sem; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 108 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 109 | struct class_attribute * class_attrs; |
| 110 | struct class_device_attribute * class_dev_attrs; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 111 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 112 | int (*uevent)(struct class_device *dev, char **envp, |
| 113 | int num_envp, char *buffer, int buffer_size); |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 114 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 115 | void (*release)(struct class_device *dev); |
| 116 | void (*class_release)(struct class *class); |
| 117 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 118 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 119 | struct class_attribute { |
| 120 | struct attribute attr; |
| 121 | ssize_t (*show)(struct class *, char * buf); |
| 122 | ssize_t (*store)(struct class *, const char * buf, size_t count); |
| 123 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 124 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 125 | #define CLASS_ATTR(_name,_mode,_show,_store) struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 126 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 127 | struct class_device_attribute { |
| 128 | struct attribute attr; |
| 129 | ssize_t (*show)(struct class_device *, char * buf); |
| 130 | ssize_t (*store)(struct class_device *, const char * buf, size_t count); |
| 131 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 132 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 133 | #define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) struct class_device_attribute class_device_attr_##_name = __ATTR(_name,_mode,_show,_store) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 134 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 135 | struct class_device { |
| 136 | struct list_head node; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 137 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 138 | struct kobject kobj; |
| 139 | struct class * class; |
| 140 | dev_t devt; |
| 141 | struct class_device_attribute *devt_attr; |
| 142 | struct class_device_attribute uevent_attr; |
| 143 | struct device * dev; |
| 144 | void * class_data; |
| 145 | struct class_device *parent; |
| 146 | struct attribute_group ** groups; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 147 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 148 | void (*release)(struct class_device *dev); |
| 149 | int (*uevent)(struct class_device *dev, char **envp, |
| 150 | int num_envp, char *buffer, int buffer_size); |
| 151 | char class_id[BUS_ID_SIZE]; |
| 152 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 153 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 154 | struct class_interface { |
| 155 | struct list_head node; |
| 156 | struct class *class; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 157 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 158 | int (*add) (struct class_device *, struct class_interface *); |
| 159 | void (*remove) (struct class_device *, struct class_interface *); |
| 160 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 161 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 162 | struct device_attribute { |
| 163 | struct attribute attr; |
| 164 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, |
| 165 | char *buf); |
| 166 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, |
| 167 | const char *buf, size_t count); |
| 168 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 169 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 170 | #define DEVICE_ATTR(_name,_mode,_show,_store) struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 171 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 172 | struct device { |
| 173 | struct klist klist_children; |
| 174 | struct klist_node knode_parent; |
| 175 | struct klist_node knode_driver; |
| 176 | struct klist_node knode_bus; |
| 177 | struct device * parent; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 178 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 179 | struct kobject kobj; |
| 180 | char bus_id[BUS_ID_SIZE]; |
| 181 | struct device_attribute uevent_attr; |
| 182 | struct device_attribute *devt_attr; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 183 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 184 | struct semaphore sem; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 185 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 186 | struct bus_type * bus; |
| 187 | struct device_driver *driver; |
| 188 | void *driver_data; |
| 189 | void *platform_data; |
| 190 | void *firmware_data; |
| 191 | struct dev_pm_info power; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 192 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 193 | u64 *dma_mask; |
| 194 | u64 coherent_dma_mask; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 195 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 196 | struct list_head dma_pools; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 197 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 198 | struct dma_coherent_mem *dma_mem; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 199 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 200 | struct list_head node; |
| 201 | struct class *class; |
| 202 | dev_t devt; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 203 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 204 | void (*release)(struct device * dev); |
| 205 | }; |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 206 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 207 | #define dev_printk(level, dev, format, arg...) printk(level "%s %s: " format , dev_driver_string(dev) , (dev)->bus_id , ## arg) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 208 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 209 | #ifdef DEBUG |
| 210 | #define dev_dbg(dev, format, arg...) dev_printk(KERN_DEBUG , dev , format , ## arg) |
| 211 | #else |
| 212 | #define dev_dbg(dev, format, arg...) do { (void)(dev); } while (0) |
| 213 | #endif |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 214 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 215 | #define dev_err(dev, format, arg...) dev_printk(KERN_ERR , dev , format , ## arg) |
| 216 | #define dev_info(dev, format, arg...) dev_printk(KERN_INFO , dev , format , ## arg) |
| 217 | #define dev_warn(dev, format, arg...) dev_printk(KERN_WARNING , dev , format , ## arg) |
| 218 | #define dev_notice(dev, format, arg...) dev_printk(KERN_NOTICE , dev , format , ## arg) |
Ben Cheng | 4b29af0 | 2012-03-07 16:14:53 -0800 | [diff] [blame] | 219 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 220 | #define MODULE_ALIAS_CHARDEV(major,minor) MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) |
| 221 | #define MODULE_ALIAS_CHARDEV_MAJOR(major) MODULE_ALIAS("char-major-" __stringify(major) "-*") |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 222 | #endif |