gpio.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * gpio.h -- GPIO Driver for Wolfson WM8350 PMIC
  4. *
  5. * Copyright 2007 Wolfson Microelectronics PLC
  6. */
  7. #ifndef __LINUX_MFD_WM8350_GPIO_H_
  8. #define __LINUX_MFD_WM8350_GPIO_H_
  9. #include <linux/platform_device.h>
  10. /*
  11. * GPIO Registers.
  12. */
  13. #define WM8350_GPIO_DEBOUNCE 0x80
  14. #define WM8350_GPIO_PIN_PULL_UP_CONTROL 0x81
  15. #define WM8350_GPIO_PULL_DOWN_CONTROL 0x82
  16. #define WM8350_GPIO_INT_MODE 0x83
  17. #define WM8350_GPIO_CONTROL 0x85
  18. #define WM8350_GPIO_CONFIGURATION_I_O 0x86
  19. #define WM8350_GPIO_PIN_POLARITY_TYPE 0x87
  20. #define WM8350_GPIO_FUNCTION_SELECT_1 0x8C
  21. #define WM8350_GPIO_FUNCTION_SELECT_2 0x8D
  22. #define WM8350_GPIO_FUNCTION_SELECT_3 0x8E
  23. #define WM8350_GPIO_FUNCTION_SELECT_4 0x8F
  24. #define WM8350_GPIO_LEVEL 0xE6
  25. /*
  26. * GPIO Functions
  27. */
  28. #define WM8350_GPIO0_GPIO_IN 0x0
  29. #define WM8350_GPIO0_GPIO_OUT 0x0
  30. #define WM8350_GPIO0_PWR_ON_IN 0x1
  31. #define WM8350_GPIO0_PWR_ON_OUT 0x1
  32. #define WM8350_GPIO0_LDO_EN_IN 0x2
  33. #define WM8350_GPIO0_VRTC_OUT 0x2
  34. #define WM8350_GPIO0_LPWR1_IN 0x3
  35. #define WM8350_GPIO0_POR_B_OUT 0x3
  36. #define WM8350_GPIO1_GPIO_IN 0x0
  37. #define WM8350_GPIO1_GPIO_OUT 0x0
  38. #define WM8350_GPIO1_PWR_ON_IN 0x1
  39. #define WM8350_GPIO1_DO_CONF_OUT 0x1
  40. #define WM8350_GPIO1_LDO_EN_IN 0x2
  41. #define WM8350_GPIO1_RESET_OUT 0x2
  42. #define WM8350_GPIO1_LPWR2_IN 0x3
  43. #define WM8350_GPIO1_MEMRST_OUT 0x3
  44. #define WM8350_GPIO2_GPIO_IN 0x0
  45. #define WM8350_GPIO2_GPIO_OUT 0x0
  46. #define WM8350_GPIO2_PWR_ON_IN 0x1
  47. #define WM8350_GPIO2_PWR_ON_OUT 0x1
  48. #define WM8350_GPIO2_WAKE_UP_IN 0x2
  49. #define WM8350_GPIO2_VRTC_OUT 0x2
  50. #define WM8350_GPIO2_32KHZ_IN 0x3
  51. #define WM8350_GPIO2_32KHZ_OUT 0x3
  52. #define WM8350_GPIO3_GPIO_IN 0x0
  53. #define WM8350_GPIO3_GPIO_OUT 0x0
  54. #define WM8350_GPIO3_PWR_ON_IN 0x1
  55. #define WM8350_GPIO3_P_CLK_OUT 0x1
  56. #define WM8350_GPIO3_LDO_EN_IN 0x2
  57. #define WM8350_GPIO3_VRTC_OUT 0x2
  58. #define WM8350_GPIO3_PWR_OFF_IN 0x3
  59. #define WM8350_GPIO3_32KHZ_OUT 0x3
  60. #define WM8350_GPIO4_GPIO_IN 0x0
  61. #define WM8350_GPIO4_GPIO_OUT 0x0
  62. #define WM8350_GPIO4_MR_IN 0x1
  63. #define WM8350_GPIO4_MEM_RST_OUT 0x1
  64. #define WM8350_GPIO4_FLASH_IN 0x2
  65. #define WM8350_GPIO4_ADA_OUT 0x2
  66. #define WM8350_GPIO4_HIBERNATE_IN 0x3
  67. #define WM8350_GPIO4_FLASH_OUT 0x3
  68. #define WM8350_GPIO4_MICDET_OUT 0x4
  69. #define WM8350_GPIO4_MICSHT_OUT 0x5
  70. #define WM8350_GPIO5_GPIO_IN 0x0
  71. #define WM8350_GPIO5_GPIO_OUT 0x0
  72. #define WM8350_GPIO5_LPWR1_IN 0x1
  73. #define WM8350_GPIO5_P_CLK_OUT 0x1
  74. #define WM8350_GPIO5_ADCLRCLK_IN 0x2
  75. #define WM8350_GPIO5_ADCLRCLK_OUT 0x2
  76. #define WM8350_GPIO5_HIBERNATE_IN 0x3
  77. #define WM8350_GPIO5_32KHZ_OUT 0x3
  78. #define WM8350_GPIO5_MICDET_OUT 0x4
  79. #define WM8350_GPIO5_MICSHT_OUT 0x5
  80. #define WM8350_GPIO5_ADA_OUT 0x6
  81. #define WM8350_GPIO5_OPCLK_OUT 0x7
  82. #define WM8350_GPIO6_GPIO_IN 0x0
  83. #define WM8350_GPIO6_GPIO_OUT 0x0
  84. #define WM8350_GPIO6_LPWR2_IN 0x1
  85. #define WM8350_GPIO6_MEMRST_OUT 0x1
  86. #define WM8350_GPIO6_FLASH_IN 0x2
  87. #define WM8350_GPIO6_ADA_OUT 0x2
  88. #define WM8350_GPIO6_HIBERNATE_IN 0x3
  89. #define WM8350_GPIO6_RTC_OUT 0x3
  90. #define WM8350_GPIO6_MICDET_OUT 0x4
  91. #define WM8350_GPIO6_MICSHT_OUT 0x5
  92. #define WM8350_GPIO6_ADCLRCLKB_OUT 0x6
  93. #define WM8350_GPIO6_SDOUT_OUT 0x7
  94. #define WM8350_GPIO7_GPIO_IN 0x0
  95. #define WM8350_GPIO7_GPIO_OUT 0x0
  96. #define WM8350_GPIO7_LPWR3_IN 0x1
  97. #define WM8350_GPIO7_P_CLK_OUT 0x1
  98. #define WM8350_GPIO7_MASK_IN 0x2
  99. #define WM8350_GPIO7_VCC_FAULT_OUT 0x2
  100. #define WM8350_GPIO7_HIBERNATE_IN 0x3
  101. #define WM8350_GPIO7_BATT_FAULT_OUT 0x3
  102. #define WM8350_GPIO7_MICDET_OUT 0x4
  103. #define WM8350_GPIO7_MICSHT_OUT 0x5
  104. #define WM8350_GPIO7_ADA_OUT 0x6
  105. #define WM8350_GPIO7_CSB_IN 0x7
  106. #define WM8350_GPIO8_GPIO_IN 0x0
  107. #define WM8350_GPIO8_GPIO_OUT 0x0
  108. #define WM8350_GPIO8_MR_IN 0x1
  109. #define WM8350_GPIO8_VCC_FAULT_OUT 0x1
  110. #define WM8350_GPIO8_ADCBCLK_IN 0x2
  111. #define WM8350_GPIO8_ADCBCLK_OUT 0x2
  112. #define WM8350_GPIO8_PWR_OFF_IN 0x3
  113. #define WM8350_GPIO8_BATT_FAULT_OUT 0x3
  114. #define WM8350_GPIO8_ALTSCL_IN 0xf
  115. #define WM8350_GPIO9_GPIO_IN 0x0
  116. #define WM8350_GPIO9_GPIO_OUT 0x0
  117. #define WM8350_GPIO9_HEARTBEAT_IN 0x1
  118. #define WM8350_GPIO9_VCC_FAULT_OUT 0x1
  119. #define WM8350_GPIO9_MASK_IN 0x2
  120. #define WM8350_GPIO9_LINE_GT_BATT_OUT 0x2
  121. #define WM8350_GPIO9_PWR_OFF_IN 0x3
  122. #define WM8350_GPIO9_BATT_FAULT_OUT 0x3
  123. #define WM8350_GPIO9_ALTSDA_OUT 0xf
  124. #define WM8350_GPIO10_GPIO_IN 0x0
  125. #define WM8350_GPIO10_GPIO_OUT 0x0
  126. #define WM8350_GPIO10_ISINKC_OUT 0x1
  127. #define WM8350_GPIO10_PWR_OFF_IN 0x2
  128. #define WM8350_GPIO10_LINE_GT_BATT_OUT 0x2
  129. #define WM8350_GPIO10_CHD_IND_IN 0x3
  130. #define WM8350_GPIO11_GPIO_IN 0x0
  131. #define WM8350_GPIO11_GPIO_OUT 0x0
  132. #define WM8350_GPIO11_ISINKD_OUT 0x1
  133. #define WM8350_GPIO11_WAKEUP_IN 0x2
  134. #define WM8350_GPIO11_LINE_GT_BATT_OUT 0x2
  135. #define WM8350_GPIO11_CHD_IND_IN 0x3
  136. #define WM8350_GPIO12_GPIO_IN 0x0
  137. #define WM8350_GPIO12_GPIO_OUT 0x0
  138. #define WM8350_GPIO12_ISINKE_OUT 0x1
  139. #define WM8350_GPIO12_LINE_GT_BATT_OUT 0x2
  140. #define WM8350_GPIO12_LINE_EN_OUT 0x3
  141. #define WM8350_GPIO12_32KHZ_OUT 0x4
  142. #define WM8350_GPIO_DIR_IN 0
  143. #define WM8350_GPIO_DIR_OUT 1
  144. #define WM8350_GPIO_ACTIVE_LOW 0
  145. #define WM8350_GPIO_ACTIVE_HIGH 1
  146. #define WM8350_GPIO_PULL_NONE 0
  147. #define WM8350_GPIO_PULL_UP 1
  148. #define WM8350_GPIO_PULL_DOWN 2
  149. #define WM8350_GPIO_INVERT_OFF 0
  150. #define WM8350_GPIO_INVERT_ON 1
  151. #define WM8350_GPIO_DEBOUNCE_OFF 0
  152. #define WM8350_GPIO_DEBOUNCE_ON 1
  153. /*
  154. * R30 (0x1E) - GPIO Interrupt Status
  155. */
  156. #define WM8350_GP12_EINT 0x1000
  157. #define WM8350_GP11_EINT 0x0800
  158. #define WM8350_GP10_EINT 0x0400
  159. #define WM8350_GP9_EINT 0x0200
  160. #define WM8350_GP8_EINT 0x0100
  161. #define WM8350_GP7_EINT 0x0080
  162. #define WM8350_GP6_EINT 0x0040
  163. #define WM8350_GP5_EINT 0x0020
  164. #define WM8350_GP4_EINT 0x0010
  165. #define WM8350_GP3_EINT 0x0008
  166. #define WM8350_GP2_EINT 0x0004
  167. #define WM8350_GP1_EINT 0x0002
  168. #define WM8350_GP0_EINT 0x0001
  169. /*
  170. * R128 (0x80) - GPIO Debounce
  171. */
  172. #define WM8350_GP12_DB 0x1000
  173. #define WM8350_GP11_DB 0x0800
  174. #define WM8350_GP10_DB 0x0400
  175. #define WM8350_GP9_DB 0x0200
  176. #define WM8350_GP8_DB 0x0100
  177. #define WM8350_GP7_DB 0x0080
  178. #define WM8350_GP6_DB 0x0040
  179. #define WM8350_GP5_DB 0x0020
  180. #define WM8350_GP4_DB 0x0010
  181. #define WM8350_GP3_DB 0x0008
  182. #define WM8350_GP2_DB 0x0004
  183. #define WM8350_GP1_DB 0x0002
  184. #define WM8350_GP0_DB 0x0001
  185. /*
  186. * R129 (0x81) - GPIO Pin pull up Control
  187. */
  188. #define WM8350_GP12_PU 0x1000
  189. #define WM8350_GP11_PU 0x0800
  190. #define WM8350_GP10_PU 0x0400
  191. #define WM8350_GP9_PU 0x0200
  192. #define WM8350_GP8_PU 0x0100
  193. #define WM8350_GP7_PU 0x0080
  194. #define WM8350_GP6_PU 0x0040
  195. #define WM8350_GP5_PU 0x0020
  196. #define WM8350_GP4_PU 0x0010
  197. #define WM8350_GP3_PU 0x0008
  198. #define WM8350_GP2_PU 0x0004
  199. #define WM8350_GP1_PU 0x0002
  200. #define WM8350_GP0_PU 0x0001
  201. /*
  202. * R130 (0x82) - GPIO Pull down Control
  203. */
  204. #define WM8350_GP12_PD 0x1000
  205. #define WM8350_GP11_PD 0x0800
  206. #define WM8350_GP10_PD 0x0400
  207. #define WM8350_GP9_PD 0x0200
  208. #define WM8350_GP8_PD 0x0100
  209. #define WM8350_GP7_PD 0x0080
  210. #define WM8350_GP6_PD 0x0040
  211. #define WM8350_GP5_PD 0x0020
  212. #define WM8350_GP4_PD 0x0010
  213. #define WM8350_GP3_PD 0x0008
  214. #define WM8350_GP2_PD 0x0004
  215. #define WM8350_GP1_PD 0x0002
  216. #define WM8350_GP0_PD 0x0001
  217. /*
  218. * R131 (0x83) - GPIO Interrupt Mode
  219. */
  220. #define WM8350_GP12_INTMODE 0x1000
  221. #define WM8350_GP11_INTMODE 0x0800
  222. #define WM8350_GP10_INTMODE 0x0400
  223. #define WM8350_GP9_INTMODE 0x0200
  224. #define WM8350_GP8_INTMODE 0x0100
  225. #define WM8350_GP7_INTMODE 0x0080
  226. #define WM8350_GP6_INTMODE 0x0040
  227. #define WM8350_GP5_INTMODE 0x0020
  228. #define WM8350_GP4_INTMODE 0x0010
  229. #define WM8350_GP3_INTMODE 0x0008
  230. #define WM8350_GP2_INTMODE 0x0004
  231. #define WM8350_GP1_INTMODE 0x0002
  232. #define WM8350_GP0_INTMODE 0x0001
  233. /*
  234. * R133 (0x85) - GPIO Control
  235. */
  236. #define WM8350_GP_DBTIME_MASK 0x00C0
  237. /*
  238. * R134 (0x86) - GPIO Configuration (i/o)
  239. */
  240. #define WM8350_GP12_DIR 0x1000
  241. #define WM8350_GP11_DIR 0x0800
  242. #define WM8350_GP10_DIR 0x0400
  243. #define WM8350_GP9_DIR 0x0200
  244. #define WM8350_GP8_DIR 0x0100
  245. #define WM8350_GP7_DIR 0x0080
  246. #define WM8350_GP6_DIR 0x0040
  247. #define WM8350_GP5_DIR 0x0020
  248. #define WM8350_GP4_DIR 0x0010
  249. #define WM8350_GP3_DIR 0x0008
  250. #define WM8350_GP2_DIR 0x0004
  251. #define WM8350_GP1_DIR 0x0002
  252. #define WM8350_GP0_DIR 0x0001
  253. /*
  254. * R135 (0x87) - GPIO Pin Polarity / Type
  255. */
  256. #define WM8350_GP12_CFG 0x1000
  257. #define WM8350_GP11_CFG 0x0800
  258. #define WM8350_GP10_CFG 0x0400
  259. #define WM8350_GP9_CFG 0x0200
  260. #define WM8350_GP8_CFG 0x0100
  261. #define WM8350_GP7_CFG 0x0080
  262. #define WM8350_GP6_CFG 0x0040
  263. #define WM8350_GP5_CFG 0x0020
  264. #define WM8350_GP4_CFG 0x0010
  265. #define WM8350_GP3_CFG 0x0008
  266. #define WM8350_GP2_CFG 0x0004
  267. #define WM8350_GP1_CFG 0x0002
  268. #define WM8350_GP0_CFG 0x0001
  269. /*
  270. * R140 (0x8C) - GPIO Function Select 1
  271. */
  272. #define WM8350_GP3_FN_MASK 0xF000
  273. #define WM8350_GP2_FN_MASK 0x0F00
  274. #define WM8350_GP1_FN_MASK 0x00F0
  275. #define WM8350_GP0_FN_MASK 0x000F
  276. /*
  277. * R141 (0x8D) - GPIO Function Select 2
  278. */
  279. #define WM8350_GP7_FN_MASK 0xF000
  280. #define WM8350_GP6_FN_MASK 0x0F00
  281. #define WM8350_GP5_FN_MASK 0x00F0
  282. #define WM8350_GP4_FN_MASK 0x000F
  283. /*
  284. * R142 (0x8E) - GPIO Function Select 3
  285. */
  286. #define WM8350_GP11_FN_MASK 0xF000
  287. #define WM8350_GP10_FN_MASK 0x0F00
  288. #define WM8350_GP9_FN_MASK 0x00F0
  289. #define WM8350_GP8_FN_MASK 0x000F
  290. /*
  291. * R143 (0x8F) - GPIO Function Select 4
  292. */
  293. #define WM8350_GP12_FN_MASK 0x000F
  294. /*
  295. * R230 (0xE6) - GPIO Pin Status
  296. */
  297. #define WM8350_GP12_LVL 0x1000
  298. #define WM8350_GP11_LVL 0x0800
  299. #define WM8350_GP10_LVL 0x0400
  300. #define WM8350_GP9_LVL 0x0200
  301. #define WM8350_GP8_LVL 0x0100
  302. #define WM8350_GP7_LVL 0x0080
  303. #define WM8350_GP6_LVL 0x0040
  304. #define WM8350_GP5_LVL 0x0020
  305. #define WM8350_GP4_LVL 0x0010
  306. #define WM8350_GP3_LVL 0x0008
  307. #define WM8350_GP2_LVL 0x0004
  308. #define WM8350_GP1_LVL 0x0002
  309. #define WM8350_GP0_LVL 0x0001
  310. struct wm8350;
  311. int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
  312. int pol, int pull, int invert, int debounce);
  313. struct wm8350_gpio {
  314. struct platform_device *pdev;
  315. };
  316. /*
  317. * GPIO Interrupts
  318. */
  319. #define WM8350_IRQ_GPIO(x) (50 + x)
  320. #endif