nvec.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef __LINUX_MFD_NVEC
  2. #define __LINUX_MFD_NVEC
  3. #include <linux/semaphore.h>
  4. typedef enum {
  5. NVEC_2BYTES,
  6. NVEC_3BYTES,
  7. NVEC_VAR_SIZE
  8. } nvec_size;
  9. typedef enum {
  10. NOT_REALLY,
  11. YES,
  12. NOT_AT_ALL,
  13. } how_care;
  14. typedef enum {
  15. NVEC_SYS=1,
  16. NVEC_BAT,
  17. NVEC_KBD = 5,
  18. NVEC_PS2,
  19. NVEC_CNTL,
  20. NVEC_KB_EVT = 0x80,
  21. NVEC_PS2_EVT
  22. } nvec_event;
  23. typedef enum {
  24. NVEC_WAIT,
  25. NVEC_READ,
  26. NVEC_WRITE
  27. } nvec_state;
  28. struct nvec_msg {
  29. unsigned char *data;
  30. unsigned short size;
  31. unsigned short pos;
  32. struct list_head node;
  33. };
  34. struct nvec_subdev {
  35. const char *name;
  36. void *platform_data;
  37. int id;
  38. };
  39. struct nvec_platform_data {
  40. int num_subdevs;
  41. int i2c_addr;
  42. int gpio;
  43. int irq;
  44. int base;
  45. int size;
  46. char clock[16];
  47. struct nvec_subdev *subdevs;
  48. };
  49. struct nvec_chip {
  50. struct device *dev;
  51. int gpio;
  52. int irq;
  53. unsigned char *i2c_regs;
  54. nvec_state state;
  55. struct atomic_notifier_head notifier_list;
  56. struct list_head rx_data, tx_data;
  57. struct notifier_block nvec_status_notifier;
  58. struct work_struct rx_work, tx_work;
  59. struct nvec_msg *rx, *tx;
  60. /* sync write stuff */
  61. struct semaphore sync_write_mutex;
  62. struct completion sync_write;
  63. u16 sync_write_pending;
  64. struct nvec_msg *last_sync_msg;
  65. };
  66. extern void nvec_write_async(struct nvec_chip *nvec, unsigned char *data, short size);
  67. extern int nvec_register_notifier(struct nvec_chip *nvec,
  68. struct notifier_block *nb, unsigned int events);
  69. extern int nvec_unregister_notifier(struct device *dev,
  70. struct notifier_block *nb, unsigned int events);
  71. const char *nvec_send_msg(unsigned char *src, unsigned char *dst_size, how_care care_resp, void (*rt_handler)(unsigned char *data));
  72. extern int nvec_ps2(struct nvec_chip *nvec);
  73. extern int nvec_kbd_init(struct nvec_chip *nvec);
  74. #define I2C_CNFG 0x00
  75. #define I2C_CNFG_PACKET_MODE_EN (1<<10)
  76. #define I2C_CNFG_NEW_MASTER_SFM (1<<11)
  77. #define I2C_CNFG_DEBOUNCE_CNT_SHIFT 12
  78. #define I2C_SL_CNFG 0x20
  79. #define I2C_SL_NEWL (1<<2)
  80. #define I2C_SL_NACK (1<<1)
  81. #define I2C_SL_RESP (1<<0)
  82. #define I2C_SL_IRQ (1<<3)
  83. #define END_TRANS (1<<4)
  84. #define RCVD (1<<2)
  85. #define RNW (1<<1)
  86. #define I2C_SL_RCVD 0x24
  87. #define I2C_SL_STATUS 0x28
  88. #define I2C_SL_ADDR1 0x2c
  89. #define I2C_SL_ADDR2 0x30
  90. #define I2C_SL_DELAY_COUNT 0x3c
  91. #endif