maple.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __LINUX_MAPLE_H
  3. #define __LINUX_MAPLE_H
  4. #include <mach/maple.h>
  5. struct device;
  6. extern struct bus_type maple_bus_type;
  7. /* Maple Bus command and response codes */
  8. enum maple_code {
  9. MAPLE_RESPONSE_FILEERR = -5,
  10. MAPLE_RESPONSE_AGAIN, /* retransmit */
  11. MAPLE_RESPONSE_BADCMD,
  12. MAPLE_RESPONSE_BADFUNC,
  13. MAPLE_RESPONSE_NONE, /* unit didn't respond*/
  14. MAPLE_COMMAND_DEVINFO = 1,
  15. MAPLE_COMMAND_ALLINFO,
  16. MAPLE_COMMAND_RESET,
  17. MAPLE_COMMAND_KILL,
  18. MAPLE_RESPONSE_DEVINFO,
  19. MAPLE_RESPONSE_ALLINFO,
  20. MAPLE_RESPONSE_OK,
  21. MAPLE_RESPONSE_DATATRF,
  22. MAPLE_COMMAND_GETCOND,
  23. MAPLE_COMMAND_GETMINFO,
  24. MAPLE_COMMAND_BREAD,
  25. MAPLE_COMMAND_BWRITE,
  26. MAPLE_COMMAND_BSYNC,
  27. MAPLE_COMMAND_SETCOND,
  28. MAPLE_COMMAND_MICCONTROL
  29. };
  30. enum maple_file_errors {
  31. MAPLE_FILEERR_INVALID_PARTITION = 0x01000000,
  32. MAPLE_FILEERR_PHASE_ERROR = 0x02000000,
  33. MAPLE_FILEERR_INVALID_BLOCK = 0x04000000,
  34. MAPLE_FILEERR_WRITE_ERROR = 0x08000000,
  35. MAPLE_FILEERR_INVALID_WRITE_LENGTH = 0x10000000,
  36. MAPLE_FILEERR_BAD_CRC = 0x20000000
  37. };
  38. struct maple_buffer {
  39. char bufx[0x400];
  40. void *buf;
  41. };
  42. struct mapleq {
  43. struct list_head list;
  44. struct maple_device *dev;
  45. struct maple_buffer *recvbuf;
  46. void *sendbuf, *recvbuf_p2;
  47. unsigned char length;
  48. enum maple_code command;
  49. };
  50. struct maple_devinfo {
  51. unsigned long function;
  52. unsigned long function_data[3];
  53. unsigned char area_code;
  54. unsigned char connector_direction;
  55. char product_name[31];
  56. char product_licence[61];
  57. unsigned short standby_power;
  58. unsigned short max_power;
  59. };
  60. struct maple_device {
  61. struct maple_driver *driver;
  62. struct mapleq *mq;
  63. void (*callback) (struct mapleq * mq);
  64. void (*fileerr_handler)(struct maple_device *mdev, void *recvbuf);
  65. int (*can_unload)(struct maple_device *mdev);
  66. unsigned long when, interval, function;
  67. struct maple_devinfo devinfo;
  68. unsigned char port, unit;
  69. char product_name[32];
  70. char product_licence[64];
  71. atomic_t busy;
  72. wait_queue_head_t maple_wait;
  73. struct device dev;
  74. };
  75. struct maple_driver {
  76. unsigned long function;
  77. struct device_driver drv;
  78. };
  79. void maple_getcond_callback(struct maple_device *dev,
  80. void (*callback) (struct mapleq * mq),
  81. unsigned long interval,
  82. unsigned long function);
  83. int maple_driver_register(struct maple_driver *);
  84. void maple_driver_unregister(struct maple_driver *);
  85. int maple_add_packet(struct maple_device *mdev, u32 function,
  86. u32 command, u32 length, void *data);
  87. void maple_clear_dev(struct maple_device *mdev);
  88. #define to_maple_dev(n) container_of(n, struct maple_device, dev)
  89. #define to_maple_driver(n) container_of(n, struct maple_driver, drv)
  90. #define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev)
  91. #define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
  92. #endif /* __LINUX_MAPLE_H */