blob: 9b140272ee165b314744271ca90cf28008f8ddf9 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Adrian McMenamin17be2d22007-09-21 15:55:55 +09002#ifndef __LINUX_MAPLE_H
3#define __LINUX_MAPLE_H
4
Adrian McMenamin1795cf42008-07-29 22:10:56 +09005#include <mach/maple.h>
Adrian McMenamin17be2d22007-09-21 15:55:55 +09006
Paul Gortmaker313162d2012-01-30 11:46:54 -05007struct device;
Adrian McMenamin17be2d22007-09-21 15:55:55 +09008extern struct bus_type maple_bus_type;
9
10/* Maple Bus command and response codes */
11enum maple_code {
Adrian McMenaminb233b282009-02-27 16:07:32 +090012 MAPLE_RESPONSE_FILEERR = -5,
13 MAPLE_RESPONSE_AGAIN, /* retransmit */
14 MAPLE_RESPONSE_BADCMD,
15 MAPLE_RESPONSE_BADFUNC,
16 MAPLE_RESPONSE_NONE, /* unit didn't respond*/
17 MAPLE_COMMAND_DEVINFO = 1,
18 MAPLE_COMMAND_ALLINFO,
19 MAPLE_COMMAND_RESET,
20 MAPLE_COMMAND_KILL,
21 MAPLE_RESPONSE_DEVINFO,
22 MAPLE_RESPONSE_ALLINFO,
23 MAPLE_RESPONSE_OK,
24 MAPLE_RESPONSE_DATATRF,
25 MAPLE_COMMAND_GETCOND,
26 MAPLE_COMMAND_GETMINFO,
27 MAPLE_COMMAND_BREAD,
28 MAPLE_COMMAND_BWRITE,
29 MAPLE_COMMAND_BSYNC,
30 MAPLE_COMMAND_SETCOND,
31 MAPLE_COMMAND_MICCONTROL
32};
33
34enum maple_file_errors {
35 MAPLE_FILEERR_INVALID_PARTITION = 0x01000000,
36 MAPLE_FILEERR_PHASE_ERROR = 0x02000000,
37 MAPLE_FILEERR_INVALID_BLOCK = 0x04000000,
38 MAPLE_FILEERR_WRITE_ERROR = 0x08000000,
39 MAPLE_FILEERR_INVALID_WRITE_LENGTH = 0x10000000,
40 MAPLE_FILEERR_BAD_CRC = 0x20000000
41};
42
43struct maple_buffer {
44 char bufx[0x400];
45 void *buf;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090046};
47
48struct mapleq {
Adrian McMenaminb9482372008-02-06 22:46:21 +000049 struct list_head list;
50 struct maple_device *dev;
Adrian McMenaminb233b282009-02-27 16:07:32 +090051 struct maple_buffer *recvbuf;
52 void *sendbuf, *recvbuf_p2;
Adrian McMenaminb9482372008-02-06 22:46:21 +000053 unsigned char length;
54 enum maple_code command;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090055};
56
57struct maple_devinfo {
Adrian McMenaminb9482372008-02-06 22:46:21 +000058 unsigned long function;
59 unsigned long function_data[3];
60 unsigned char area_code;
Paul Mundt5c8f82c2008-02-13 19:44:53 +090061 unsigned char connector_direction;
Adrian McMenaminb9482372008-02-06 22:46:21 +000062 char product_name[31];
63 char product_licence[61];
64 unsigned short standby_power;
65 unsigned short max_power;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090066};
67
68struct maple_device {
Adrian McMenaminb9482372008-02-06 22:46:21 +000069 struct maple_driver *driver;
70 struct mapleq *mq;
Adrian McMenaminb9482372008-02-06 22:46:21 +000071 void (*callback) (struct mapleq * mq);
Adrian McMenaminb233b282009-02-27 16:07:32 +090072 void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf);
73 int (*can_unload)(struct maple_device *mdev);
Adrian McMenaminb9482372008-02-06 22:46:21 +000074 unsigned long when, interval, function;
75 struct maple_devinfo devinfo;
76 unsigned char port, unit;
77 char product_name[32];
78 char product_licence[64];
Adrian McMenaminb233b282009-02-27 16:07:32 +090079 atomic_t busy;
80 wait_queue_head_t maple_wait;
Adrian McMenaminb9482372008-02-06 22:46:21 +000081 struct device dev;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090082};
83
84struct maple_driver {
Adrian McMenaminb9482372008-02-06 22:46:21 +000085 unsigned long function;
Adrian McMenaminb9482372008-02-06 22:46:21 +000086 struct device_driver drv;
Adrian McMenamin17be2d22007-09-21 15:55:55 +090087};
88
89void maple_getcond_callback(struct maple_device *dev,
Adrian McMenaminb9482372008-02-06 22:46:21 +000090 void (*callback) (struct mapleq * mq),
91 unsigned long interval,
92 unsigned long function);
Paul Mundt63870292008-08-04 10:39:46 +090093int maple_driver_register(struct maple_driver *);
94void maple_driver_unregister(struct maple_driver *);
95
Adrian McMenaminb233b282009-02-27 16:07:32 +090096int maple_add_packet(struct maple_device *mdev, u32 function,
Adrian McMenamin1795cf42008-07-29 22:10:56 +090097 u32 command, u32 length, void *data);
98void maple_clear_dev(struct maple_device *mdev);
Adrian McMenamin17be2d22007-09-21 15:55:55 +090099
100#define to_maple_dev(n) container_of(n, struct maple_device, dev)
101#define to_maple_driver(n) container_of(n, struct maple_driver, drv)
102
Paul Mundt61787062008-08-04 10:58:24 +0900103#define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev)
104#define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
105
Adrian McMenaminb9482372008-02-06 22:46:21 +0000106#endif /* __LINUX_MAPLE_H */