aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAdrian McMenamin <adrian@mcmen.demon.co.uk>2009-02-27 02:07:32 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-02-27 02:07:32 -0500
commitb233b28eac0cc37d07c2d007ea08c86c778c5af4 (patch)
tree636f91b57d675d1886d8b3ab4aca8d8488d65d90 /include
parent41480ae7a383dcffa497decdd97b3cb2caaa18ec (diff)
sh: maple: Support block reads and writes.
This patch updates the maple bus to support asynchronous block reads and writes as well as generally improving the quality of the code and supporting concurrency (all needed to support the Dreamcast visual memory unit - a driver will also be posted for that). Changes in the bus driver necessitate some changes in the two maple bus input drivers that are currently in mainline. As well as supporting block reads and writes this code clean up removes some poor handling of locks, uses an atomic status variable to serialise access to devices and more robusly handles the general performance problems of the bus. Signed-off-by: Adrian McMenamin <adrian@mcmen.demon.co.uk> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/maple.h62
1 files changed, 41 insertions, 21 deletions
diff --git a/include/linux/maple.h b/include/linux/maple.h
index c23d3f51ba40..d9a51b9b3300 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -8,33 +8,49 @@ extern struct bus_type maple_bus_type;
8 8
9/* Maple Bus command and response codes */ 9/* Maple Bus command and response codes */
10enum maple_code { 10enum maple_code {
11 MAPLE_RESPONSE_FILEERR = -5, 11 MAPLE_RESPONSE_FILEERR = -5,
12 MAPLE_RESPONSE_AGAIN = -4, /* request should be retransmitted */ 12 MAPLE_RESPONSE_AGAIN, /* retransmit */
13 MAPLE_RESPONSE_BADCMD = -3, 13 MAPLE_RESPONSE_BADCMD,
14 MAPLE_RESPONSE_BADFUNC = -2, 14 MAPLE_RESPONSE_BADFUNC,
15 MAPLE_RESPONSE_NONE = -1, /* unit didn't respond at all */ 15 MAPLE_RESPONSE_NONE, /* unit didn't respond*/
16 MAPLE_COMMAND_DEVINFO = 1, 16 MAPLE_COMMAND_DEVINFO = 1,
17 MAPLE_COMMAND_ALLINFO = 2, 17 MAPLE_COMMAND_ALLINFO,
18 MAPLE_COMMAND_RESET = 3, 18 MAPLE_COMMAND_RESET,
19 MAPLE_COMMAND_KILL = 4, 19 MAPLE_COMMAND_KILL,
20 MAPLE_RESPONSE_DEVINFO = 5, 20 MAPLE_RESPONSE_DEVINFO,
21 MAPLE_RESPONSE_ALLINFO = 6, 21 MAPLE_RESPONSE_ALLINFO,
22 MAPLE_RESPONSE_OK = 7, 22 MAPLE_RESPONSE_OK,
23 MAPLE_RESPONSE_DATATRF = 8, 23 MAPLE_RESPONSE_DATATRF,
24 MAPLE_COMMAND_GETCOND = 9, 24 MAPLE_COMMAND_GETCOND,
25 MAPLE_COMMAND_GETMINFO = 10, 25 MAPLE_COMMAND_GETMINFO,
26 MAPLE_COMMAND_BREAD = 11, 26 MAPLE_COMMAND_BREAD,
27 MAPLE_COMMAND_BWRITE = 12, 27 MAPLE_COMMAND_BWRITE,
28 MAPLE_COMMAND_SETCOND = 14 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;
29}; 45};
30 46
31struct mapleq { 47struct mapleq {
32 struct list_head list; 48 struct list_head list;
33 struct maple_device *dev; 49 struct maple_device *dev;
34 void *sendbuf, *recvbuf, *recvbufdcsp; 50 struct maple_buffer *recvbuf;
51 void *sendbuf, *recvbuf_p2;
35 unsigned char length; 52 unsigned char length;
36 enum maple_code command; 53 enum maple_code command;
37 struct mutex mutex;
38}; 54};
39 55
40struct maple_devinfo { 56struct maple_devinfo {
@@ -52,11 +68,15 @@ struct maple_device {
52 struct maple_driver *driver; 68 struct maple_driver *driver;
53 struct mapleq *mq; 69 struct mapleq *mq;
54 void (*callback) (struct mapleq * mq); 70 void (*callback) (struct mapleq * mq);
71 void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf);
72 int (*can_unload)(struct maple_device *mdev);
55 unsigned long when, interval, function; 73 unsigned long when, interval, function;
56 struct maple_devinfo devinfo; 74 struct maple_devinfo devinfo;
57 unsigned char port, unit; 75 unsigned char port, unit;
58 char product_name[32]; 76 char product_name[32];
59 char product_licence[64]; 77 char product_licence[64];
78 atomic_t busy;
79 wait_queue_head_t maple_wait;
60 struct device dev; 80 struct device dev;
61}; 81};
62 82
@@ -72,7 +92,7 @@ void maple_getcond_callback(struct maple_device *dev,
72int maple_driver_register(struct maple_driver *); 92int maple_driver_register(struct maple_driver *);
73void maple_driver_unregister(struct maple_driver *); 93void maple_driver_unregister(struct maple_driver *);
74 94
75int maple_add_packet_sleeps(struct maple_device *mdev, u32 function, 95int maple_add_packet(struct maple_device *mdev, u32 function,
76 u32 command, u32 length, void *data); 96 u32 command, u32 length, void *data);
77void maple_clear_dev(struct maple_device *mdev); 97void maple_clear_dev(struct maple_device *mdev);
78 98