maple.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __LINUX_MAPLE_H
  2. #define __LINUX_MAPLE_H
  3. #include <linux/device.h>
  4. #include <mach/maple.h>
  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 = -4, /* request should be retransmitted */
  10. MAPLE_RESPONSE_BADCMD = -3,
  11. MAPLE_RESPONSE_BADFUNC = -2,
  12. MAPLE_RESPONSE_NONE = -1, /* unit didn't respond at all */
  13. MAPLE_COMMAND_DEVINFO = 1,
  14. MAPLE_COMMAND_ALLINFO = 2,
  15. MAPLE_COMMAND_RESET = 3,
  16. MAPLE_COMMAND_KILL = 4,
  17. MAPLE_RESPONSE_DEVINFO = 5,
  18. MAPLE_RESPONSE_ALLINFO = 6,
  19. MAPLE_RESPONSE_OK = 7,
  20. MAPLE_RESPONSE_DATATRF = 8,
  21. MAPLE_COMMAND_GETCOND = 9,
  22. MAPLE_COMMAND_GETMINFO = 10,
  23. MAPLE_COMMAND_BREAD = 11,
  24. MAPLE_COMMAND_BWRITE = 12,
  25. MAPLE_COMMAND_SETCOND = 14
  26. };
  27. struct mapleq {
  28. struct list_head list;
  29. struct maple_device *dev;
  30. void *sendbuf, *recvbuf, *recvbufdcsp;
  31. unsigned char length;
  32. enum maple_code command;
  33. struct mutex mutex;
  34. };
  35. struct maple_devinfo {
  36. unsigned long function;
  37. unsigned long function_data[3];
  38. unsigned char area_code;
  39. unsigned char connector_direction;
  40. char product_name[31];
  41. char product_licence[61];
  42. unsigned short standby_power;
  43. unsigned short max_power;
  44. };
  45. struct maple_device {
  46. struct maple_driver *driver;
  47. struct mapleq *mq;
  48. void (*callback) (struct mapleq * mq);
  49. unsigned long when, interval, function;
  50. struct maple_devinfo devinfo;
  51. unsigned char port, unit;
  52. char product_name[32];
  53. char product_licence[64];
  54. struct device dev;
  55. };
  56. struct maple_driver {
  57. unsigned long function;
  58. struct device_driver drv;
  59. };
  60. void maple_getcond_callback(struct maple_device *dev,
  61. void (*callback) (struct mapleq * mq),
  62. unsigned long interval,
  63. unsigned long function);
  64. int maple_driver_register(struct maple_driver *);
  65. void maple_driver_unregister(struct maple_driver *);
  66. int maple_add_packet_sleeps(struct maple_device *mdev, u32 function,
  67. u32 command, u32 length, void *data);
  68. void maple_clear_dev(struct maple_device *mdev);
  69. #define to_maple_dev(n) container_of(n, struct maple_device, dev)
  70. #define to_maple_driver(n) container_of(n, struct maple_driver, drv)
  71. #define maple_get_drvdata(d) dev_get_drvdata(&(d)->dev)
  72. #define maple_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
  73. #endif /* __LINUX_MAPLE_H */