blob: c37288b23e0cf4cb1bb37fa4a0516efcd0cd4d5f [file] [log] [blame]
Adrian McMenamin17be2d22007-09-21 15:55:55 +09001#ifndef __LINUX_MAPLE_H
2#define __LINUX_MAPLE_H
3
Adrian McMenamin1795cf42008-07-29 22:10:56 +09004#include <mach/maple.h>
Adrian McMenamin17be2d22007-09-21 15:55:55 +09005
Paul Gortmaker313162d2012-01-30 11:46:54 -05006struct device;
Adrian McMenamin17be2d22007-09-21 15:55:55 +09007extern struct bus_type maple_bus_type;
8
9/* Maple Bus command and response codes */
10enum maple_code {
Adrian McMenaminb233b282009-02-27 16:07:32 +090011 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
33enum 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
42struct maple_buffer {
43 char bufx[0x400];
44 void *buf;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090045};
46
47struct mapleq {
Adrian McMenaminb9482372008-02-06 22:46:21 +000048 struct list_head list;
49 struct maple_device *dev;
Adrian McMenaminb233b282009-02-27 16:07:32 +090050 struct maple_buffer *recvbuf;
51 void *sendbuf, *recvbuf_p2;
Adrian McMenaminb9482372008-02-06 22:46:21 +000052 unsigned char length;
53 enum maple_code command;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090054};
55
56struct maple_devinfo {
Adrian McMenaminb9482372008-02-06 22:46:21 +000057 unsigned long function;
58 unsigned long function_data[3];
59 unsigned char area_code;
Paul Mundt5c8f82c2008-02-13 19:44:53 +090060 unsigned char connector_direction;
Adrian McMenaminb9482372008-02-06 22:46:21 +000061 char product_name[31];
62 char product_licence[61];
63 unsigned short standby_power;
64 unsigned short max_power;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090065};
66
67struct maple_device {
Adrian McMenaminb9482372008-02-06 22:46:21 +000068 struct maple_driver *driver;
69 struct mapleq *mq;
Adrian McMenaminb9482372008-02-06 22:46:21 +000070 void (*callback) (struct mapleq * mq);
Adrian McMenaminb233b282009-02-27 16:07:32 +090071 void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf);
72 int (*can_unload)(struct maple_device *mdev);
Adrian McMenaminb9482372008-02-06 22:46:21 +000073 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 McMenaminb233b282009-02-27 16:07:32 +090078 atomic_t busy;
79 wait_queue_head_t maple_wait;
Adrian McMenaminb9482372008-02-06 22:46:21 +000080 struct device dev;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090081};
82
83struct maple_driver {
Adrian McMenaminb9482372008-02-06 22:46:21 +000084 unsigned long function;
Adrian McMenaminb9482372008-02-06 22:46:21 +000085 struct device_driver drv;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090086};
87
88void maple_getcond_callback(struct maple_device *dev,
Adrian McMenaminb9482372008-02-06 22:46:21 +000089 void (*callback) (struct mapleq * mq),
90 unsigned long interval,
91 unsigned long function);
Paul Mundt63870292008-08-04 10:39:46 +090092int maple_driver_register(struct maple_driver *);
93void maple_driver_unregister(struct maple_driver *);
94
Adrian McMenaminb233b282009-02-27 16:07:32 +090095int maple_add_packet(struct maple_device *mdev, u32 function,
Adrian McMenamin1795cf42008-07-29 22:10:56 +090096 u32 command, u32 length, void *data);
97void maple_clear_dev(struct maple_device *mdev);
Adrian McMenamin17be2d22007-09-21 15:55:55 +090098
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 Mundt61787062008-08-04 10:58:24 +0900102#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 McMenaminb9482372008-02-06 22:46:21 +0000105#endif /* __LINUX_MAPLE_H */