Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LINUX_MAPLE_H
0003 #define __LINUX_MAPLE_H
0004 
0005 #include <mach/maple.h>
0006 
0007 struct device;
0008 extern struct bus_type maple_bus_type;
0009 
0010 /* Maple Bus command and response codes */
0011 enum maple_code {
0012     MAPLE_RESPONSE_FILEERR =    -5,
0013     MAPLE_RESPONSE_AGAIN,   /* retransmit */
0014     MAPLE_RESPONSE_BADCMD,
0015     MAPLE_RESPONSE_BADFUNC,
0016     MAPLE_RESPONSE_NONE,    /* unit didn't respond*/
0017     MAPLE_COMMAND_DEVINFO =     1,
0018     MAPLE_COMMAND_ALLINFO,
0019     MAPLE_COMMAND_RESET,
0020     MAPLE_COMMAND_KILL,
0021     MAPLE_RESPONSE_DEVINFO,
0022     MAPLE_RESPONSE_ALLINFO,
0023     MAPLE_RESPONSE_OK,
0024     MAPLE_RESPONSE_DATATRF,
0025     MAPLE_COMMAND_GETCOND,
0026     MAPLE_COMMAND_GETMINFO,
0027     MAPLE_COMMAND_BREAD,
0028     MAPLE_COMMAND_BWRITE,
0029     MAPLE_COMMAND_BSYNC,
0030     MAPLE_COMMAND_SETCOND,
0031     MAPLE_COMMAND_MICCONTROL
0032 };
0033 
0034 enum maple_file_errors {
0035     MAPLE_FILEERR_INVALID_PARTITION =   0x01000000,
0036     MAPLE_FILEERR_PHASE_ERROR =     0x02000000,
0037     MAPLE_FILEERR_INVALID_BLOCK =       0x04000000,
0038     MAPLE_FILEERR_WRITE_ERROR =     0x08000000,
0039     MAPLE_FILEERR_INVALID_WRITE_LENGTH =    0x10000000,
0040     MAPLE_FILEERR_BAD_CRC =         0x20000000
0041 };
0042 
0043 struct maple_buffer {
0044     char bufx[0x400];
0045     void *buf;
0046 };
0047 
0048 struct mapleq {
0049     struct list_head list;
0050     struct maple_device *dev;
0051     struct maple_buffer *recvbuf;
0052     void *sendbuf, *recvbuf_p2;
0053     unsigned char length;
0054     enum maple_code command;
0055 };
0056 
0057 struct maple_devinfo {
0058     unsigned long function;
0059     unsigned long function_data[3];
0060     unsigned char area_code;
0061     unsigned char connector_direction;
0062     char product_name[31];
0063     char product_licence[61];
0064     unsigned short standby_power;
0065     unsigned short max_power;
0066 };
0067 
0068 struct maple_device {
0069     struct maple_driver *driver;
0070     struct mapleq *mq;
0071     void (*callback) (struct mapleq * mq);
0072     void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf);
0073     int (*can_unload)(struct maple_device *mdev);
0074     unsigned long when, interval, function;
0075     struct maple_devinfo devinfo;
0076     unsigned char port, unit;
0077     char product_name[32];
0078     char product_licence[64];
0079     atomic_t busy;
0080     wait_queue_head_t maple_wait;
0081     struct device dev;
0082 };
0083 
0084 struct maple_driver {
0085     unsigned long function;
0086     struct device_driver drv;
0087 };
0088 
0089 void maple_getcond_callback(struct maple_device *dev,
0090                 void (*callback) (struct mapleq * mq),
0091                 unsigned long interval,
0092                 unsigned long function);
0093 int maple_driver_register(struct maple_driver *);
0094 void maple_driver_unregister(struct maple_driver *);
0095 
0096 int maple_add_packet(struct maple_device *mdev, u32 function,
0097     u32 command, u32 length, void *data);
0098 void maple_clear_dev(struct maple_device *mdev);
0099 
0100 #define to_maple_dev(n) container_of(n, struct maple_device, dev)
0101 #define to_maple_driver(n) container_of(n, struct maple_driver, drv)
0102 
0103 #define maple_get_drvdata(d)        dev_get_drvdata(&(d)->dev)
0104 #define maple_set_drvdata(d,p)      dev_set_drvdata(&(d)->dev, (p))
0105 
0106 #endif              /* __LINUX_MAPLE_H */