tps6105x.h 3.0 KB

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