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