Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 1 | #ifndef __LINUX_MAPLE_H |
| 2 | #define __LINUX_MAPLE_H |
| 3 | |
| 4 | #include <linux/device.h> |
| 5 | |
| 6 | extern struct bus_type maple_bus_type; |
| 7 | |
| 8 | /* Maple Bus command and response codes */ |
| 9 | enum maple_code { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 10 | MAPLE_RESPONSE_FILEERR = -5, |
| 11 | MAPLE_RESPONSE_AGAIN = -4, /* request should be retransmitted */ |
| 12 | MAPLE_RESPONSE_BADCMD = -3, |
| 13 | MAPLE_RESPONSE_BADFUNC = -2, |
| 14 | MAPLE_RESPONSE_NONE = -1, /* unit didn't respond at all */ |
| 15 | MAPLE_COMMAND_DEVINFO = 1, |
| 16 | MAPLE_COMMAND_ALLINFO = 2, |
| 17 | MAPLE_COMMAND_RESET = 3, |
| 18 | MAPLE_COMMAND_KILL = 4, |
| 19 | MAPLE_RESPONSE_DEVINFO = 5, |
| 20 | MAPLE_RESPONSE_ALLINFO = 6, |
| 21 | MAPLE_RESPONSE_OK = 7, |
| 22 | MAPLE_RESPONSE_DATATRF = 8, |
| 23 | MAPLE_COMMAND_GETCOND = 9, |
| 24 | MAPLE_COMMAND_GETMINFO = 10, |
| 25 | MAPLE_COMMAND_BREAD = 11, |
| 26 | MAPLE_COMMAND_BWRITE = 12, |
| 27 | MAPLE_COMMAND_SETCOND = 14 |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | struct mapleq { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 31 | struct list_head list; |
| 32 | struct maple_device *dev; |
| 33 | void *sendbuf, *recvbuf, *recvbufdcsp; |
| 34 | unsigned char length; |
| 35 | enum maple_code command; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | struct maple_devinfo { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 39 | unsigned long function; |
| 40 | unsigned long function_data[3]; |
| 41 | unsigned char area_code; |
Paul Mundt | 5c8f82c | 2008-02-13 19:44:53 +0900 | [diff] [blame] | 42 | unsigned char connector_direction; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 43 | char product_name[31]; |
| 44 | char product_licence[61]; |
| 45 | unsigned short standby_power; |
| 46 | unsigned short max_power; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct maple_device { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 50 | struct maple_driver *driver; |
| 51 | struct mapleq *mq; |
| 52 | void *private_data; |
| 53 | void (*callback) (struct mapleq * mq); |
| 54 | unsigned long when, interval, function; |
| 55 | struct maple_devinfo devinfo; |
| 56 | unsigned char port, unit; |
| 57 | char product_name[32]; |
| 58 | char product_licence[64]; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 59 | struct device dev; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | struct maple_driver { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 63 | unsigned long function; |
| 64 | int (*connect) (struct maple_device * dev); |
| 65 | void (*disconnect) (struct maple_device * dev); |
| 66 | struct device_driver drv; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | void maple_getcond_callback(struct maple_device *dev, |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 70 | void (*callback) (struct mapleq * mq), |
| 71 | unsigned long interval, |
| 72 | unsigned long function); |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 73 | int maple_driver_register(struct device_driver *drv); |
| 74 | void maple_add_packet(struct mapleq *mq); |
| 75 | |
| 76 | #define to_maple_dev(n) container_of(n, struct maple_device, dev) |
| 77 | #define to_maple_driver(n) container_of(n, struct maple_driver, drv) |
| 78 | |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 79 | #endif /* __LINUX_MAPLE_H */ |