lp3943.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * TI/National Semiconductor LP3943 Device
  3. *
  4. * Copyright 2013 Texas Instruments
  5. *
  6. * Author: Milo Kim <milo.kim@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #ifndef __MFD_LP3943_H__
  14. #define __MFD_LP3943_H__
  15. #include <linux/gpio.h>
  16. #include <linux/pwm.h>
  17. #include <linux/regmap.h>
  18. /* Registers */
  19. #define LP3943_REG_GPIO_A 0x00
  20. #define LP3943_REG_GPIO_B 0x01
  21. #define LP3943_REG_PRESCALE0 0x02
  22. #define LP3943_REG_PWM0 0x03
  23. #define LP3943_REG_PRESCALE1 0x04
  24. #define LP3943_REG_PWM1 0x05
  25. #define LP3943_REG_MUX0 0x06
  26. #define LP3943_REG_MUX1 0x07
  27. #define LP3943_REG_MUX2 0x08
  28. #define LP3943_REG_MUX3 0x09
  29. /* Bit description for LP3943_REG_MUX0 ~ 3 */
  30. #define LP3943_GPIO_IN 0x00
  31. #define LP3943_GPIO_OUT_HIGH 0x00
  32. #define LP3943_GPIO_OUT_LOW 0x01
  33. #define LP3943_DIM_PWM0 0x02
  34. #define LP3943_DIM_PWM1 0x03
  35. #define LP3943_NUM_PWMS 2
  36. enum lp3943_pwm_output {
  37. LP3943_PWM_OUT0,
  38. LP3943_PWM_OUT1,
  39. LP3943_PWM_OUT2,
  40. LP3943_PWM_OUT3,
  41. LP3943_PWM_OUT4,
  42. LP3943_PWM_OUT5,
  43. LP3943_PWM_OUT6,
  44. LP3943_PWM_OUT7,
  45. LP3943_PWM_OUT8,
  46. LP3943_PWM_OUT9,
  47. LP3943_PWM_OUT10,
  48. LP3943_PWM_OUT11,
  49. LP3943_PWM_OUT12,
  50. LP3943_PWM_OUT13,
  51. LP3943_PWM_OUT14,
  52. LP3943_PWM_OUT15,
  53. };
  54. /*
  55. * struct lp3943_pwm_map
  56. * @output: Output pins which are mapped to each PWM channel
  57. * @num_outputs: Number of outputs
  58. */
  59. struct lp3943_pwm_map {
  60. enum lp3943_pwm_output *output;
  61. int num_outputs;
  62. };
  63. /*
  64. * struct lp3943_platform_data
  65. * @pwms: Output channel definitions for PWM channel 0 and 1
  66. */
  67. struct lp3943_platform_data {
  68. struct lp3943_pwm_map *pwms[LP3943_NUM_PWMS];
  69. };
  70. /*
  71. * struct lp3943_reg_cfg
  72. * @reg: Register address
  73. * @mask: Register bit mask to be updated
  74. * @shift: Register bit shift
  75. */
  76. struct lp3943_reg_cfg {
  77. u8 reg;
  78. u8 mask;
  79. u8 shift;
  80. };
  81. /*
  82. * struct lp3943
  83. * @dev: Parent device pointer
  84. * @regmap: Used for I2C communication on accessing registers
  85. * @pdata: LP3943 platform specific data
  86. * @mux_cfg: Register configuration for pin MUX
  87. * @pin_used: Bit mask for output pin used.
  88. * This bitmask is used for pin assignment management.
  89. * 1 = pin used, 0 = available.
  90. * Only LSB 16 bits are used, but it is unsigned long type
  91. * for atomic bitwise operations.
  92. */
  93. struct lp3943 {
  94. struct device *dev;
  95. struct regmap *regmap;
  96. struct lp3943_platform_data *pdata;
  97. const struct lp3943_reg_cfg *mux_cfg;
  98. unsigned long pin_used;
  99. };
  100. int lp3943_read_byte(struct lp3943 *lp3943, u8 reg, u8 *read);
  101. int lp3943_write_byte(struct lp3943 *lp3943, u8 reg, u8 data);
  102. int lp3943_update_bits(struct lp3943 *lp3943, u8 reg, u8 mask, u8 data);
  103. #endif