maple.h 2.7 KB

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