tps65912.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. /*
  2. * tps65912.h -- TI TPS6591x
  3. *
  4. * Copyright 2011 Texas Instruments Inc.
  5. *
  6. * Author: Margarita Olaya <magi@slimlogic.co.uk>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. */
  14. #ifndef __LINUX_MFD_TPS65912_H
  15. #define __LINUX_MFD_TPS65912_H
  16. /* TPS regulator type list */
  17. #define REGULATOR_LDO 0
  18. #define REGULATOR_DCDC 1
  19. /*
  20. * List of registers for TPS65912
  21. */
  22. #define TPS65912_DCDC1_CTRL 0x00
  23. #define TPS65912_DCDC2_CTRL 0x01
  24. #define TPS65912_DCDC3_CTRL 0x02
  25. #define TPS65912_DCDC4_CTRL 0x03
  26. #define TPS65912_DCDC1_OP 0x04
  27. #define TPS65912_DCDC1_AVS 0x05
  28. #define TPS65912_DCDC1_LIMIT 0x06
  29. #define TPS65912_DCDC2_OP 0x07
  30. #define TPS65912_DCDC2_AVS 0x08
  31. #define TPS65912_DCDC2_LIMIT 0x09
  32. #define TPS65912_DCDC3_OP 0x0A
  33. #define TPS65912_DCDC3_AVS 0x0B
  34. #define TPS65912_DCDC3_LIMIT 0x0C
  35. #define TPS65912_DCDC4_OP 0x0D
  36. #define TPS65912_DCDC4_AVS 0x0E
  37. #define TPS65912_DCDC4_LIMIT 0x0F
  38. #define TPS65912_LDO1_OP 0x10
  39. #define TPS65912_LDO1_AVS 0x11
  40. #define TPS65912_LDO1_LIMIT 0x12
  41. #define TPS65912_LDO2_OP 0x13
  42. #define TPS65912_LDO2_AVS 0x14
  43. #define TPS65912_LDO2_LIMIT 0x15
  44. #define TPS65912_LDO3_OP 0x16
  45. #define TPS65912_LDO3_AVS 0x17
  46. #define TPS65912_LDO3_LIMIT 0x18
  47. #define TPS65912_LDO4_OP 0x19
  48. #define TPS65912_LDO4_AVS 0x1A
  49. #define TPS65912_LDO4_LIMIT 0x1B
  50. #define TPS65912_LDO5 0x1C
  51. #define TPS65912_LDO6 0x1D
  52. #define TPS65912_LDO7 0x1E
  53. #define TPS65912_LDO8 0x1F
  54. #define TPS65912_LDO9 0x20
  55. #define TPS65912_LDO10 0x21
  56. #define TPS65912_THRM 0x22
  57. #define TPS65912_CLK32OUT 0x23
  58. #define TPS65912_DEVCTRL 0x24
  59. #define TPS65912_DEVCTRL2 0x25
  60. #define TPS65912_I2C_SPI_CFG 0x26
  61. #define TPS65912_KEEP_ON 0x27
  62. #define TPS65912_KEEP_ON2 0x28
  63. #define TPS65912_SET_OFF1 0x29
  64. #define TPS65912_SET_OFF2 0x2A
  65. #define TPS65912_DEF_VOLT 0x2B
  66. #define TPS65912_DEF_VOLT_MAPPING 0x2C
  67. #define TPS65912_DISCHARGE 0x2D
  68. #define TPS65912_DISCHARGE2 0x2E
  69. #define TPS65912_EN1_SET1 0x2F
  70. #define TPS65912_EN1_SET2 0x30
  71. #define TPS65912_EN2_SET1 0x31
  72. #define TPS65912_EN2_SET2 0x32
  73. #define TPS65912_EN3_SET1 0x33
  74. #define TPS65912_EN3_SET2 0x34
  75. #define TPS65912_EN4_SET1 0x35
  76. #define TPS65912_EN4_SET2 0x36
  77. #define TPS65912_PGOOD 0x37
  78. #define TPS65912_PGOOD2 0x38
  79. #define TPS65912_INT_STS 0x39
  80. #define TPS65912_INT_MSK 0x3A
  81. #define TPS65912_INT_STS2 0x3B
  82. #define TPS65912_INT_MSK2 0x3C
  83. #define TPS65912_INT_STS3 0x3D
  84. #define TPS65912_INT_MSK3 0x3E
  85. #define TPS65912_INT_STS4 0x3F
  86. #define TPS65912_INT_MSK4 0x40
  87. #define TPS65912_GPIO1 0x41
  88. #define TPS65912_GPIO2 0x42
  89. #define TPS65912_GPIO3 0x43
  90. #define TPS65912_GPIO4 0x44
  91. #define TPS65912_GPIO5 0x45
  92. #define TPS65912_VMON 0x46
  93. #define TPS65912_LEDA_CTRL1 0x47
  94. #define TPS65912_LEDA_CTRL2 0x48
  95. #define TPS65912_LEDA_CTRL3 0x49
  96. #define TPS65912_LEDA_CTRL4 0x4A
  97. #define TPS65912_LEDA_CTRL5 0x4B
  98. #define TPS65912_LEDA_CTRL6 0x4C
  99. #define TPS65912_LEDA_CTRL7 0x4D
  100. #define TPS65912_LEDA_CTRL8 0x4E
  101. #define TPS65912_LEDB_CTRL1 0x4F
  102. #define TPS65912_LEDB_CTRL2 0x50
  103. #define TPS65912_LEDB_CTRL3 0x51
  104. #define TPS65912_LEDB_CTRL4 0x52
  105. #define TPS65912_LEDB_CTRL5 0x53
  106. #define TPS65912_LEDB_CTRL6 0x54
  107. #define TPS65912_LEDB_CTRL7 0x55
  108. #define TPS65912_LEDB_CTRL8 0x56
  109. #define TPS65912_LEDC_CTRL1 0x57
  110. #define TPS65912_LEDC_CTRL2 0x58
  111. #define TPS65912_LEDC_CTRL3 0x59
  112. #define TPS65912_LEDC_CTRL4 0x5A
  113. #define TPS65912_LEDC_CTRL5 0x5B
  114. #define TPS65912_LEDC_CTRL6 0x5C
  115. #define TPS65912_LEDC_CTRL7 0x5D
  116. #define TPS65912_LEDC_CTRL8 0x5E
  117. #define TPS65912_LED_RAMP_UP_TIME 0x5F
  118. #define TPS65912_LED_RAMP_DOWN_TIME 0x60
  119. #define TPS65912_LED_SEQ_EN 0x61
  120. #define TPS65912_LOADSWITCH 0x62
  121. #define TPS65912_SPARE 0x63
  122. #define TPS65912_VERNUM 0x64
  123. #define TPS6591X_MAX_REGISTER 0x64
  124. /* IRQ Definitions */
  125. #define TPS65912_IRQ_PWRHOLD_F 0
  126. #define TPS65912_IRQ_VMON 1
  127. #define TPS65912_IRQ_PWRON 2
  128. #define TPS65912_IRQ_PWRON_LP 3
  129. #define TPS65912_IRQ_PWRHOLD_R 4
  130. #define TPS65912_IRQ_HOTDIE 5
  131. #define TPS65912_IRQ_GPIO1_R 6
  132. #define TPS65912_IRQ_GPIO1_F 7
  133. #define TPS65912_IRQ_GPIO2_R 8
  134. #define TPS65912_IRQ_GPIO2_F 9
  135. #define TPS65912_IRQ_GPIO3_R 10
  136. #define TPS65912_IRQ_GPIO3_F 11
  137. #define TPS65912_IRQ_GPIO4_R 12
  138. #define TPS65912_IRQ_GPIO4_F 13
  139. #define TPS65912_IRQ_GPIO5_R 14
  140. #define TPS65912_IRQ_GPIO5_F 15
  141. #define TPS65912_IRQ_PGOOD_DCDC1 16
  142. #define TPS65912_IRQ_PGOOD_DCDC2 17
  143. #define TPS65912_IRQ_PGOOD_DCDC3 18
  144. #define TPS65912_IRQ_PGOOD_DCDC4 19
  145. #define TPS65912_IRQ_PGOOD_LDO1 20
  146. #define TPS65912_IRQ_PGOOD_LDO2 21
  147. #define TPS65912_IRQ_PGOOD_LDO3 22
  148. #define TPS65912_IRQ_PGOOD_LDO4 23
  149. #define TPS65912_IRQ_PGOOD_LDO5 24
  150. #define TPS65912_IRQ_PGOOD_LDO6 25
  151. #define TPS65912_IRQ_PGOOD_LDO7 26
  152. #define TPS65912_IRQ_PGOOD_LD08 27
  153. #define TPS65912_IRQ_PGOOD_LDO9 28
  154. #define TPS65912_IRQ_PGOOD_LDO10 29
  155. #define TPS65912_NUM_IRQ 30
  156. /* GPIO 1 and 2 Register Definitions */
  157. #define GPIO_SLEEP_MASK 0x80
  158. #define GPIO_SLEEP_SHIFT 7
  159. #define GPIO_DEB_MASK 0x10
  160. #define GPIO_DEB_SHIFT 4
  161. #define GPIO_CFG_MASK 0x04
  162. #define GPIO_CFG_SHIFT 2
  163. #define GPIO_STS_MASK 0x02
  164. #define GPIO_STS_SHIFT 1
  165. #define GPIO_SET_MASK 0x01
  166. #define GPIO_SET_SHIFT 0
  167. /* GPIO 3 Register Definitions */
  168. #define GPIO3_SLEEP_MASK 0x80
  169. #define GPIO3_SLEEP_SHIFT 7
  170. #define GPIO3_SEL_MASK 0x40
  171. #define GPIO3_SEL_SHIFT 6
  172. #define GPIO3_ODEN_MASK 0x20
  173. #define GPIO3_ODEN_SHIFT 5
  174. #define GPIO3_DEB_MASK 0x10
  175. #define GPIO3_DEB_SHIFT 4
  176. #define GPIO3_PDEN_MASK 0x08
  177. #define GPIO3_PDEN_SHIFT 3
  178. #define GPIO3_CFG_MASK 0x04
  179. #define GPIO3_CFG_SHIFT 2
  180. #define GPIO3_STS_MASK 0x02
  181. #define GPIO3_STS_SHIFT 1
  182. #define GPIO3_SET_MASK 0x01
  183. #define GPIO3_SET_SHIFT 0
  184. /* GPIO 4 Register Definitions */
  185. #define GPIO4_SLEEP_MASK 0x80
  186. #define GPIO4_SLEEP_SHIFT 7
  187. #define GPIO4_SEL_MASK 0x40
  188. #define GPIO4_SEL_SHIFT 6
  189. #define GPIO4_ODEN_MASK 0x20
  190. #define GPIO4_ODEN_SHIFT 5
  191. #define GPIO4_DEB_MASK 0x10
  192. #define GPIO4_DEB_SHIFT 4
  193. #define GPIO4_PDEN_MASK 0x08
  194. #define GPIO4_PDEN_SHIFT 3
  195. #define GPIO4_CFG_MASK 0x04
  196. #define GPIO4_CFG_SHIFT 2
  197. #define GPIO4_STS_MASK 0x02
  198. #define GPIO4_STS_SHIFT 1
  199. #define GPIO4_SET_MASK 0x01
  200. #define GPIO4_SET_SHIFT 0
  201. /* Register THERM (0x80) register.RegisterDescription */
  202. #define THERM_THERM_HD_MASK 0x20
  203. #define THERM_THERM_HD_SHIFT 5
  204. #define THERM_THERM_TS_MASK 0x10
  205. #define THERM_THERM_TS_SHIFT 4
  206. #define THERM_THERM_HDSEL_MASK 0x0C
  207. #define THERM_THERM_HDSEL_SHIFT 2
  208. #define THERM_RSVD1_MASK 0x02
  209. #define THERM_RSVD1_SHIFT 1
  210. #define THERM_THERM_STATE_MASK 0x01
  211. #define THERM_THERM_STATE_SHIFT 0
  212. /* Register DCDCCTRL1 register.RegisterDescription */
  213. #define DCDCCTRL_VCON_ENABLE_MASK 0x80
  214. #define DCDCCTRL_VCON_ENABLE_SHIFT 7
  215. #define DCDCCTRL_VCON_RANGE1_MASK 0x40
  216. #define DCDCCTRL_VCON_RANGE1_SHIFT 6
  217. #define DCDCCTRL_VCON_RANGE0_MASK 0x20
  218. #define DCDCCTRL_VCON_RANGE0_SHIFT 5
  219. #define DCDCCTRL_TSTEP2_MASK 0x10
  220. #define DCDCCTRL_TSTEP2_SHIFT 4
  221. #define DCDCCTRL_TSTEP1_MASK 0x08
  222. #define DCDCCTRL_TSTEP1_SHIFT 3
  223. #define DCDCCTRL_TSTEP0_MASK 0x04
  224. #define DCDCCTRL_TSTEP0_SHIFT 2
  225. #define DCDCCTRL_DCDC1_MODE_MASK 0x02
  226. #define DCDCCTRL_DCDC1_MODE_SHIFT 1
  227. /* Register DCDCCTRL2 and DCDCCTRL3 register.RegisterDescription */
  228. #define DCDCCTRL_TSTEP2_MASK 0x10
  229. #define DCDCCTRL_TSTEP2_SHIFT 4
  230. #define DCDCCTRL_TSTEP1_MASK 0x08
  231. #define DCDCCTRL_TSTEP1_SHIFT 3
  232. #define DCDCCTRL_TSTEP0_MASK 0x04
  233. #define DCDCCTRL_TSTEP0_SHIFT 2
  234. #define DCDCCTRL_DCDC_MODE_MASK 0x02
  235. #define DCDCCTRL_DCDC_MODE_SHIFT 1
  236. #define DCDCCTRL_RSVD0_MASK 0x01
  237. #define DCDCCTRL_RSVD0_SHIFT 0
  238. /* Register DCDCCTRL4 register.RegisterDescription */
  239. #define DCDCCTRL_RAMP_TIME_MASK 0x01
  240. #define DCDCCTRL_RAMP_TIME_SHIFT 0
  241. /* Register DCDCx_AVS */
  242. #define DCDC_AVS_ENABLE_MASK 0x80
  243. #define DCDC_AVS_ENABLE_SHIFT 7
  244. #define DCDC_AVS_ECO_MASK 0x40
  245. #define DCDC_AVS_ECO_SHIFT 6
  246. /* Register DCDCx_LIMIT */
  247. #define DCDC_LIMIT_RANGE_MASK 0xC0
  248. #define DCDC_LIMIT_RANGE_SHIFT 6
  249. #define DCDC_LIMIT_MAX_SEL_MASK 0x3F
  250. #define DCDC_LIMIT_MAX_SEL_SHIFT 0
  251. /**
  252. * struct tps65912_board
  253. * Board platform dat may be used to initialize regulators.
  254. */
  255. struct tps65912_board {
  256. int is_dcdc1_avs;
  257. int is_dcdc2_avs;
  258. int is_dcdc3_avs;
  259. int is_dcdc4_avs;
  260. int irq;
  261. int irq_base;
  262. int gpio_base;
  263. struct regulator_init_data *tps65912_pmic_init_data;
  264. };
  265. /**
  266. * struct tps65912 - tps65912 sub-driver chip access routines
  267. */
  268. struct tps65912 {
  269. struct device *dev;
  270. /* for read/write acces */
  271. struct mutex io_mutex;
  272. /* For device IO interfaces: I2C or SPI */
  273. void *control_data;
  274. int (*read)(struct tps65912 *tps65912, u8 reg, int size, void *dest);
  275. int (*write)(struct tps65912 *tps65912, u8 reg, int size, void *src);
  276. /* Client devices */
  277. struct tps65912_pmic *pmic;
  278. /* GPIO Handling */
  279. struct gpio_chip gpio;
  280. /* IRQ Handling */
  281. struct mutex irq_lock;
  282. int chip_irq;
  283. int irq_base;
  284. int irq_num;
  285. u32 irq_mask;
  286. };
  287. struct tps65912_platform_data {
  288. int irq;
  289. int irq_base;
  290. };
  291. unsigned int tps_chip(void);
  292. int tps65912_set_bits(struct tps65912 *tps65912, u8 reg, u8 mask);
  293. int tps65912_clear_bits(struct tps65912 *tps65912, u8 reg, u8 mask);
  294. int tps65912_reg_read(struct tps65912 *tps65912, u8 reg);
  295. int tps65912_reg_write(struct tps65912 *tps65912, u8 reg, u8 val);
  296. int tps65912_device_init(struct tps65912 *tps65912);
  297. void tps65912_device_exit(struct tps65912 *tps65912);
  298. int tps65912_irq_init(struct tps65912 *tps65912, int irq,
  299. struct tps65912_platform_data *pdata);
  300. int tps65912_irq_exit(struct tps65912 *tps65912);
  301. #endif /* __LINUX_MFD_TPS65912_H */