stmpe.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (C) ST-Ericsson SA 2010
  3. *
  4. * License Terms: GNU General Public License, version 2
  5. * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
  6. */
  7. #ifndef __LINUX_MFD_STMPE_H
  8. #define __LINUX_MFD_STMPE_H
  9. #include <linux/mutex.h>
  10. struct device;
  11. struct regulator;
  12. enum stmpe_block {
  13. STMPE_BLOCK_GPIO = 1 << 0,
  14. STMPE_BLOCK_KEYPAD = 1 << 1,
  15. STMPE_BLOCK_TOUCHSCREEN = 1 << 2,
  16. STMPE_BLOCK_ADC = 1 << 3,
  17. STMPE_BLOCK_PWM = 1 << 4,
  18. STMPE_BLOCK_ROTATOR = 1 << 5,
  19. };
  20. enum stmpe_partnum {
  21. STMPE610,
  22. STMPE801,
  23. STMPE811,
  24. STMPE1601,
  25. STMPE1801,
  26. STMPE2401,
  27. STMPE2403,
  28. STMPE_NBR_PARTS
  29. };
  30. /*
  31. * For registers whose locations differ on variants, the correct address is
  32. * obtained by indexing stmpe->regs with one of the following.
  33. */
  34. enum {
  35. STMPE_IDX_CHIP_ID,
  36. STMPE_IDX_ICR_LSB,
  37. STMPE_IDX_IER_LSB,
  38. STMPE_IDX_ISR_LSB,
  39. STMPE_IDX_ISR_MSB,
  40. STMPE_IDX_GPMR_LSB,
  41. STMPE_IDX_GPSR_LSB,
  42. STMPE_IDX_GPCR_LSB,
  43. STMPE_IDX_GPDR_LSB,
  44. STMPE_IDX_GPEDR_MSB,
  45. STMPE_IDX_GPRER_LSB,
  46. STMPE_IDX_GPFER_LSB,
  47. STMPE_IDX_GPPUR_LSB,
  48. STMPE_IDX_GPPDR_LSB,
  49. STMPE_IDX_GPAFR_U_MSB,
  50. STMPE_IDX_IEGPIOR_LSB,
  51. STMPE_IDX_ISGPIOR_LSB,
  52. STMPE_IDX_ISGPIOR_MSB,
  53. STMPE_IDX_MAX,
  54. };
  55. struct stmpe_variant_info;
  56. struct stmpe_client_info;
  57. /**
  58. * struct stmpe - STMPE MFD structure
  59. * @vcc: optional VCC regulator
  60. * @vio: optional VIO regulator
  61. * @lock: lock protecting I/O operations
  62. * @irq_lock: IRQ bus lock
  63. * @dev: device, mostly for dev_dbg()
  64. * @irq_domain: IRQ domain
  65. * @client: client - i2c or spi
  66. * @ci: client specific information
  67. * @partnum: part number
  68. * @variant: the detected STMPE model number
  69. * @regs: list of addresses of registers which are at different addresses on
  70. * different variants. Indexed by one of STMPE_IDX_*.
  71. * @irq: irq number for stmpe
  72. * @num_gpios: number of gpios, differs for variants
  73. * @ier: cache of IER registers for bus_lock
  74. * @oldier: cache of IER registers for bus_lock
  75. * @pdata: platform data
  76. */
  77. struct stmpe {
  78. struct regulator *vcc;
  79. struct regulator *vio;
  80. struct mutex lock;
  81. struct mutex irq_lock;
  82. struct device *dev;
  83. struct irq_domain *domain;
  84. void *client;
  85. struct stmpe_client_info *ci;
  86. enum stmpe_partnum partnum;
  87. struct stmpe_variant_info *variant;
  88. const u8 *regs;
  89. int irq;
  90. int num_gpios;
  91. u8 ier[2];
  92. u8 oldier[2];
  93. struct stmpe_platform_data *pdata;
  94. };
  95. extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data);
  96. extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg);
  97. extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length,
  98. u8 *values);
  99. extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
  100. const u8 *values);
  101. extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val);
  102. extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins,
  103. enum stmpe_block block);
  104. extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks);
  105. extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
  106. #define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
  107. /**
  108. * struct stmpe_platform_data - STMPE platform data
  109. * @id: device id to distinguish between multiple STMPEs on the same board
  110. * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*)
  111. * @irq_trigger: IRQ trigger to use for the interrupt to the host
  112. * @autosleep: bool to enable/disable stmpe autosleep
  113. * @autosleep_timeout: inactivity timeout in milliseconds for autosleep
  114. * @irq_over_gpio: true if gpio is used to get irq
  115. * @irq_gpio: gpio number over which irq will be requested (significant only if
  116. * irq_over_gpio is true)
  117. */
  118. struct stmpe_platform_data {
  119. int id;
  120. unsigned int blocks;
  121. unsigned int irq_trigger;
  122. bool autosleep;
  123. bool irq_over_gpio;
  124. int irq_gpio;
  125. int autosleep_timeout;
  126. };
  127. #endif