tps6105x.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2011 ST-Ericsson SA
  3. * Written on behalf of Linaro for ST-Ericsson
  4. *
  5. * Author: Linus Walleij <linus.walleij@linaro.org>
  6. *
  7. * License terms: GNU General Public License (GPL) version 2
  8. */
  9. #ifndef MFD_TPS6105X_H
  10. #define MFD_TPS6105X_H
  11. #include <linux/i2c.h>
  12. /*
  13. * Register definitions to all subdrivers
  14. */
  15. #define TPS6105X_REG_0 0x00
  16. #define TPS6105X_REG0_MODE_SHIFT 6
  17. #define TPS6105X_REG0_MODE_MASK (0x03<<6)
  18. /* These defines for both reg0 and reg1 */
  19. #define TPS6105X_REG0_MODE_SHUTDOWN 0x00
  20. #define TPS6105X_REG0_MODE_TORCH 0x01
  21. #define TPS6105X_REG0_MODE_TORCH_FLASH 0x02
  22. #define TPS6105X_REG0_MODE_VOLTAGE 0x03
  23. #define TPS6105X_REG0_VOLTAGE_SHIFT 4
  24. #define TPS6105X_REG0_VOLTAGE_MASK (3<<4)
  25. #define TPS6105X_REG0_VOLTAGE_450 0
  26. #define TPS6105X_REG0_VOLTAGE_500 1
  27. #define TPS6105X_REG0_VOLTAGE_525 2
  28. #define TPS6105X_REG0_VOLTAGE_500_2 3
  29. #define TPS6105X_REG0_DIMMING_SHIFT 3
  30. #define TPS6105X_REG0_TORCHC_SHIFT 0
  31. #define TPS6105X_REG0_TORCHC_MASK (7<<0)
  32. #define TPS6105X_REG0_TORCHC_0 0x00
  33. #define TPS6105X_REG0_TORCHC_50 0x01
  34. #define TPS6105X_REG0_TORCHC_75 0x02
  35. #define TPS6105X_REG0_TORCHC_100 0x03
  36. #define TPS6105X_REG0_TORCHC_150 0x04
  37. #define TPS6105X_REG0_TORCHC_200 0x05
  38. #define TPS6105X_REG0_TORCHC_250_400 0x06
  39. #define TPS6105X_REG0_TORCHC_250_500 0x07
  40. #define TPS6105X_REG_1 0x01
  41. #define TPS6105X_REG1_MODE_SHIFT 6
  42. #define TPS6105X_REG1_MODE_MASK (0x03<<6)
  43. #define TPS6105X_REG1_MODE_SHUTDOWN 0x00
  44. #define TPS6105X_REG1_MODE_TORCH 0x01
  45. #define TPS6105X_REG1_MODE_TORCH_FLASH 0x02
  46. #define TPS6105X_REG1_MODE_VOLTAGE 0x03
  47. #define TPS6105X_REG_2 0x02
  48. #define TPS6105X_REG_3 0x03
  49. /**
  50. * enum tps6105x_mode - desired mode for the TPS6105x
  51. * @TPS6105X_MODE_SHUTDOWN: this instance is inactive, not used for anything
  52. * @TPS61905X_MODE_TORCH: this instance is used as a LED, usually a while
  53. * LED, for example as backlight or flashlight. If this is set, the
  54. * TPS6105X will register to the LED framework
  55. * @TPS6105X_MODE_TORCH_FLASH: this instance is used as a flashgun, usually
  56. * in a camera
  57. * @TPS6105X_MODE_VOLTAGE: this instance is used as a voltage regulator and
  58. * will register to the regulator framework
  59. */
  60. enum tps6105x_mode {
  61. TPS6105X_MODE_SHUTDOWN,
  62. TPS6105X_MODE_TORCH,
  63. TPS6105X_MODE_TORCH_FLASH,
  64. TPS6105X_MODE_VOLTAGE,
  65. };
  66. /**
  67. * struct tps6105x_platform_data - TPS61905x platform data
  68. * @mode: what mode this instance shall be operated in,
  69. * this is not selectable at runtime
  70. */
  71. struct tps6105x_platform_data {
  72. enum tps6105x_mode mode;
  73. };
  74. /**
  75. * struct tps6105x - state holder for the TPS6105x drivers
  76. * @mutex: mutex to serialize I2C accesses
  77. * @i2c_client: corresponding I2C client
  78. */
  79. struct tps6105x {
  80. struct tps6105x_platform_data *pdata;
  81. struct mutex lock;
  82. struct i2c_client *client;
  83. };
  84. extern int tps6105x_set(struct tps6105x *tps6105x, u8 reg, u8 value);
  85. extern int tps6105x_get(struct tps6105x *tps6105x, u8 reg, u8 *buf);
  86. extern int tps6105x_mask_and_set(struct tps6105x *tps6105x, u8 reg,
  87. u8 bitmask, u8 bitvalues);
  88. #endif