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 | b233b28 | 2009-02-27 16:07:32 +0900 | [diff] [blame^] | 11 | MAPLE_RESPONSE_FILEERR = -5, |
| 12 | MAPLE_RESPONSE_AGAIN, /* retransmit */ |
| 13 | MAPLE_RESPONSE_BADCMD, |
| 14 | MAPLE_RESPONSE_BADFUNC, |
| 15 | MAPLE_RESPONSE_NONE, /* unit didn't respond*/ |
| 16 | MAPLE_COMMAND_DEVINFO = 1, |
| 17 | MAPLE_COMMAND_ALLINFO, |
| 18 | MAPLE_COMMAND_RESET, |
| 19 | MAPLE_COMMAND_KILL, |
| 20 | MAPLE_RESPONSE_DEVINFO, |
| 21 | MAPLE_RESPONSE_ALLINFO, |
| 22 | MAPLE_RESPONSE_OK, |
| 23 | MAPLE_RESPONSE_DATATRF, |
| 24 | MAPLE_COMMAND_GETCOND, |
| 25 | MAPLE_COMMAND_GETMINFO, |
| 26 | MAPLE_COMMAND_BREAD, |
| 27 | MAPLE_COMMAND_BWRITE, |
| 28 | MAPLE_COMMAND_BSYNC, |
| 29 | MAPLE_COMMAND_SETCOND, |
| 30 | MAPLE_COMMAND_MICCONTROL |
| 31 | }; |
| 32 | |
| 33 | enum maple_file_errors { |
| 34 | MAPLE_FILEERR_INVALID_PARTITION = 0x01000000, |
| 35 | MAPLE_FILEERR_PHASE_ERROR = 0x02000000, |
| 36 | MAPLE_FILEERR_INVALID_BLOCK = 0x04000000, |
| 37 | MAPLE_FILEERR_WRITE_ERROR = 0x08000000, |
| 38 | MAPLE_FILEERR_INVALID_WRITE_LENGTH = 0x10000000, |
| 39 | MAPLE_FILEERR_BAD_CRC = 0x20000000 |
| 40 | }; |
| 41 | |
| 42 | struct maple_buffer { |
| 43 | char bufx[0x400]; |
| 44 | void *buf; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | struct mapleq { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 48 | struct list_head list; |
| 49 | struct maple_device *dev; |
Adrian McMenamin | b233b28 | 2009-02-27 16:07:32 +0900 | [diff] [blame^] | 50 | struct maple_buffer *recvbuf; |
| 51 | void *sendbuf, *recvbuf_p2; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 52 | unsigned char length; |
| 53 | enum maple_code command; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct maple_devinfo { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 57 | unsigned long function; |
| 58 | unsigned long function_data[3]; |
| 59 | unsigned char area_code; |
Paul Mundt | 5c8f82c | 2008-02-13 19:44:53 +0900 | [diff] [blame] | 60 | unsigned char connector_direction; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 61 | char product_name[31]; |
| 62 | char product_licence[61]; |
| 63 | unsigned short standby_power; |
| 64 | unsigned short max_power; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | struct maple_device { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 68 | struct maple_driver *driver; |
| 69 | struct mapleq *mq; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 70 | void (*callback) (struct mapleq * mq); |
Adrian McMenamin | b233b28 | 2009-02-27 16:07:32 +0900 | [diff] [blame^] | 71 | void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf); |
| 72 | int (*can_unload)(struct maple_device *mdev); |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 73 | unsigned long when, interval, function; |
| 74 | struct maple_devinfo devinfo; |
| 75 | unsigned char port, unit; |
| 76 | char product_name[32]; |
| 77 | char product_licence[64]; |
Adrian McMenamin | b233b28 | 2009-02-27 16:07:32 +0900 | [diff] [blame^] | 78 | atomic_t busy; |
| 79 | wait_queue_head_t maple_wait; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 80 | struct device dev; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | struct maple_driver { |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 84 | unsigned long function; |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 85 | struct device_driver drv; |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | void maple_getcond_callback(struct maple_device *dev, |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 89 | void (*callback) (struct mapleq * mq), |
| 90 | unsigned long interval, |
| 91 | unsigned long function); |
Paul Mundt | 6387029 | 2008-08-04 10:39:46 +0900 | [diff] [blame] | 92 | int maple_driver_register(struct maple_driver *); |
| 93 | void maple_driver_unregister(struct maple_driver *); |
| 94 | |
Adrian McMenamin | b233b28 | 2009-02-27 16:07:32 +0900 | [diff] [blame^] | 95 | int maple_add_packet(struct maple_device *mdev, u32 function, |
Adrian McMenamin | 1795cf4 | 2008-07-29 22:10:56 +0900 | [diff] [blame] | 96 | u32 command, u32 length, void *data); |
| 97 | void maple_clear_dev(struct maple_device *mdev); |
Adrian McMenamin | 17be2d2 | 2007-09-21 15:55:55 +0900 | [diff] [blame] | 98 | |
| 99 | #define to_maple_dev(n) container_of(n, struct maple_device, dev) |
| 100 | #define to_maple_driver(n) container_of(n, struct maple_driver, drv) |
| 101 | |
Paul Mundt | 6178706 | 2008-08-04 10:58:24 +0900 | [diff] [blame] | 102 | #define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev) |
| 103 | #define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p)) |
| 104 | |
Adrian McMenamin | b948237 | 2008-02-06 22:46:21 +0000 | [diff] [blame] | 105 | #endif /* __LINUX_MAPLE_H */ |