1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_MAPLE_H
3 #define __LINUX_MAPLE_H
5 #include <mach/maple.h>
8 extern struct bus_type maple_bus_type;
10 /* Maple Bus command and response codes */
12 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,
21 MAPLE_RESPONSE_DEVINFO,
22 MAPLE_RESPONSE_ALLINFO,
24 MAPLE_RESPONSE_DATATRF,
25 MAPLE_COMMAND_GETCOND,
26 MAPLE_COMMAND_GETMINFO,
30 MAPLE_COMMAND_SETCOND,
31 MAPLE_COMMAND_MICCONTROL
34 enum 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
49 struct list_head list;
50 struct maple_device *dev;
51 struct maple_buffer *recvbuf;
52 void *sendbuf, *recvbuf_p2;
54 enum maple_code command;
57 struct maple_devinfo {
58 unsigned long function;
59 unsigned long function_data[3];
60 unsigned char area_code;
61 unsigned char connector_direction;
62 char product_name[31];
63 char product_licence[61];
64 unsigned short standby_power;
65 unsigned short max_power;
69 struct maple_driver *driver;
71 void (*callback) (struct mapleq * mq);
72 void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf);
73 int (*can_unload)(struct maple_device *mdev);
74 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];
80 wait_queue_head_t maple_wait;
85 unsigned long function;
86 struct device_driver drv;
89 void maple_getcond_callback(struct maple_device *dev,
90 void (*callback) (struct mapleq * mq),
91 unsigned long interval,
92 unsigned long function);
93 int maple_driver_register(struct maple_driver *);
94 void maple_driver_unregister(struct maple_driver *);
96 int maple_add_packet(struct maple_device *mdev, u32 function,
97 u32 command, u32 length, void *data);
98 void maple_clear_dev(struct maple_device *mdev);
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)
103 #define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev)
104 #define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
106 #endif /* __LINUX_MAPLE_H */