Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * gpio.h  --  GPIO Driver for Wolfson WM8350 PMIC
0004  *
0005  * Copyright 2007 Wolfson Microelectronics PLC
0006  */
0007 
0008 #ifndef __LINUX_MFD_WM8350_GPIO_H_
0009 #define __LINUX_MFD_WM8350_GPIO_H_
0010 
0011 #include <linux/platform_device.h>
0012 
0013 /*
0014  * GPIO Registers.
0015  */
0016 #define WM8350_GPIO_DEBOUNCE                    0x80
0017 #define WM8350_GPIO_PIN_PULL_UP_CONTROL         0x81
0018 #define WM8350_GPIO_PULL_DOWN_CONTROL           0x82
0019 #define WM8350_GPIO_INT_MODE                    0x83
0020 #define WM8350_GPIO_CONTROL                     0x85
0021 #define WM8350_GPIO_CONFIGURATION_I_O           0x86
0022 #define WM8350_GPIO_PIN_POLARITY_TYPE           0x87
0023 #define WM8350_GPIO_FUNCTION_SELECT_1           0x8C
0024 #define WM8350_GPIO_FUNCTION_SELECT_2           0x8D
0025 #define WM8350_GPIO_FUNCTION_SELECT_3           0x8E
0026 #define WM8350_GPIO_FUNCTION_SELECT_4           0x8F
0027 #define WM8350_GPIO_LEVEL           0xE6
0028 
0029 /*
0030  * GPIO Functions
0031  */
0032 #define WM8350_GPIO0_GPIO_IN            0x0
0033 #define WM8350_GPIO0_GPIO_OUT           0x0
0034 #define WM8350_GPIO0_PWR_ON_IN          0x1
0035 #define WM8350_GPIO0_PWR_ON_OUT         0x1
0036 #define WM8350_GPIO0_LDO_EN_IN          0x2
0037 #define WM8350_GPIO0_VRTC_OUT           0x2
0038 #define WM8350_GPIO0_LPWR1_IN           0x3
0039 #define WM8350_GPIO0_POR_B_OUT          0x3
0040 
0041 #define WM8350_GPIO1_GPIO_IN            0x0
0042 #define WM8350_GPIO1_GPIO_OUT           0x0
0043 #define WM8350_GPIO1_PWR_ON_IN          0x1
0044 #define WM8350_GPIO1_DO_CONF_OUT        0x1
0045 #define WM8350_GPIO1_LDO_EN_IN          0x2
0046 #define WM8350_GPIO1_RESET_OUT          0x2
0047 #define WM8350_GPIO1_LPWR2_IN           0x3
0048 #define WM8350_GPIO1_MEMRST_OUT         0x3
0049 
0050 #define WM8350_GPIO2_GPIO_IN            0x0
0051 #define WM8350_GPIO2_GPIO_OUT           0x0
0052 #define WM8350_GPIO2_PWR_ON_IN          0x1
0053 #define WM8350_GPIO2_PWR_ON_OUT         0x1
0054 #define WM8350_GPIO2_WAKE_UP_IN         0x2
0055 #define WM8350_GPIO2_VRTC_OUT           0x2
0056 #define WM8350_GPIO2_32KHZ_IN           0x3
0057 #define WM8350_GPIO2_32KHZ_OUT          0x3
0058 
0059 #define WM8350_GPIO3_GPIO_IN            0x0
0060 #define WM8350_GPIO3_GPIO_OUT           0x0
0061 #define WM8350_GPIO3_PWR_ON_IN          0x1
0062 #define WM8350_GPIO3_P_CLK_OUT          0x1
0063 #define WM8350_GPIO3_LDO_EN_IN          0x2
0064 #define WM8350_GPIO3_VRTC_OUT           0x2
0065 #define WM8350_GPIO3_PWR_OFF_IN         0x3
0066 #define WM8350_GPIO3_32KHZ_OUT          0x3
0067 
0068 #define WM8350_GPIO4_GPIO_IN            0x0
0069 #define WM8350_GPIO4_GPIO_OUT           0x0
0070 #define WM8350_GPIO4_MR_IN          0x1
0071 #define WM8350_GPIO4_MEM_RST_OUT        0x1
0072 #define WM8350_GPIO4_FLASH_IN           0x2
0073 #define WM8350_GPIO4_ADA_OUT            0x2
0074 #define WM8350_GPIO4_HIBERNATE_IN       0x3
0075 #define WM8350_GPIO4_FLASH_OUT          0x3
0076 #define WM8350_GPIO4_MICDET_OUT         0x4
0077 #define WM8350_GPIO4_MICSHT_OUT         0x5
0078 
0079 #define WM8350_GPIO5_GPIO_IN            0x0
0080 #define WM8350_GPIO5_GPIO_OUT           0x0
0081 #define WM8350_GPIO5_LPWR1_IN           0x1
0082 #define WM8350_GPIO5_P_CLK_OUT          0x1
0083 #define WM8350_GPIO5_ADCLRCLK_IN        0x2
0084 #define WM8350_GPIO5_ADCLRCLK_OUT       0x2
0085 #define WM8350_GPIO5_HIBERNATE_IN       0x3
0086 #define WM8350_GPIO5_32KHZ_OUT          0x3
0087 #define WM8350_GPIO5_MICDET_OUT         0x4
0088 #define WM8350_GPIO5_MICSHT_OUT         0x5
0089 #define WM8350_GPIO5_ADA_OUT            0x6
0090 #define WM8350_GPIO5_OPCLK_OUT          0x7
0091 
0092 #define WM8350_GPIO6_GPIO_IN            0x0
0093 #define WM8350_GPIO6_GPIO_OUT           0x0
0094 #define WM8350_GPIO6_LPWR2_IN           0x1
0095 #define WM8350_GPIO6_MEMRST_OUT         0x1
0096 #define WM8350_GPIO6_FLASH_IN           0x2
0097 #define WM8350_GPIO6_ADA_OUT            0x2
0098 #define WM8350_GPIO6_HIBERNATE_IN       0x3
0099 #define WM8350_GPIO6_RTC_OUT            0x3
0100 #define WM8350_GPIO6_MICDET_OUT         0x4
0101 #define WM8350_GPIO6_MICSHT_OUT         0x5
0102 #define WM8350_GPIO6_ADCLRCLKB_OUT      0x6
0103 #define WM8350_GPIO6_SDOUT_OUT          0x7
0104 
0105 #define WM8350_GPIO7_GPIO_IN            0x0
0106 #define WM8350_GPIO7_GPIO_OUT           0x0
0107 #define WM8350_GPIO7_LPWR3_IN           0x1
0108 #define WM8350_GPIO7_P_CLK_OUT          0x1
0109 #define WM8350_GPIO7_MASK_IN            0x2
0110 #define WM8350_GPIO7_VCC_FAULT_OUT      0x2
0111 #define WM8350_GPIO7_HIBERNATE_IN       0x3
0112 #define WM8350_GPIO7_BATT_FAULT_OUT     0x3
0113 #define WM8350_GPIO7_MICDET_OUT         0x4
0114 #define WM8350_GPIO7_MICSHT_OUT         0x5
0115 #define WM8350_GPIO7_ADA_OUT            0x6
0116 #define WM8350_GPIO7_CSB_IN         0x7
0117 
0118 #define WM8350_GPIO8_GPIO_IN            0x0
0119 #define WM8350_GPIO8_GPIO_OUT           0x0
0120 #define WM8350_GPIO8_MR_IN          0x1
0121 #define WM8350_GPIO8_VCC_FAULT_OUT      0x1
0122 #define WM8350_GPIO8_ADCBCLK_IN         0x2
0123 #define WM8350_GPIO8_ADCBCLK_OUT        0x2
0124 #define WM8350_GPIO8_PWR_OFF_IN         0x3
0125 #define WM8350_GPIO8_BATT_FAULT_OUT     0x3
0126 #define WM8350_GPIO8_ALTSCL_IN          0xf
0127 
0128 #define WM8350_GPIO9_GPIO_IN            0x0
0129 #define WM8350_GPIO9_GPIO_OUT           0x0
0130 #define WM8350_GPIO9_HEARTBEAT_IN       0x1
0131 #define WM8350_GPIO9_VCC_FAULT_OUT      0x1
0132 #define WM8350_GPIO9_MASK_IN            0x2
0133 #define WM8350_GPIO9_LINE_GT_BATT_OUT       0x2
0134 #define WM8350_GPIO9_PWR_OFF_IN         0x3
0135 #define WM8350_GPIO9_BATT_FAULT_OUT     0x3
0136 #define WM8350_GPIO9_ALTSDA_OUT         0xf
0137 
0138 #define WM8350_GPIO10_GPIO_IN           0x0
0139 #define WM8350_GPIO10_GPIO_OUT          0x0
0140 #define WM8350_GPIO10_ISINKC_OUT        0x1
0141 #define WM8350_GPIO10_PWR_OFF_IN        0x2
0142 #define WM8350_GPIO10_LINE_GT_BATT_OUT      0x2
0143 #define WM8350_GPIO10_CHD_IND_IN        0x3
0144 
0145 #define WM8350_GPIO11_GPIO_IN           0x0
0146 #define WM8350_GPIO11_GPIO_OUT          0x0
0147 #define WM8350_GPIO11_ISINKD_OUT        0x1
0148 #define WM8350_GPIO11_WAKEUP_IN         0x2
0149 #define WM8350_GPIO11_LINE_GT_BATT_OUT      0x2
0150 #define WM8350_GPIO11_CHD_IND_IN        0x3
0151 
0152 #define WM8350_GPIO12_GPIO_IN           0x0
0153 #define WM8350_GPIO12_GPIO_OUT          0x0
0154 #define WM8350_GPIO12_ISINKE_OUT        0x1
0155 #define WM8350_GPIO12_LINE_GT_BATT_OUT      0x2
0156 #define WM8350_GPIO12_LINE_EN_OUT       0x3
0157 #define WM8350_GPIO12_32KHZ_OUT         0x4
0158 
0159 #define WM8350_GPIO_DIR_IN          0
0160 #define WM8350_GPIO_DIR_OUT         1
0161 #define WM8350_GPIO_ACTIVE_LOW          0
0162 #define WM8350_GPIO_ACTIVE_HIGH         1
0163 #define WM8350_GPIO_PULL_NONE           0
0164 #define WM8350_GPIO_PULL_UP         1
0165 #define WM8350_GPIO_PULL_DOWN           2
0166 #define WM8350_GPIO_INVERT_OFF          0
0167 #define WM8350_GPIO_INVERT_ON           1
0168 #define WM8350_GPIO_DEBOUNCE_OFF        0
0169 #define WM8350_GPIO_DEBOUNCE_ON         1
0170 
0171 /*
0172  * R30 (0x1E) - GPIO Interrupt Status
0173  */
0174 #define WM8350_GP12_EINT                        0x1000
0175 #define WM8350_GP11_EINT                        0x0800
0176 #define WM8350_GP10_EINT                        0x0400
0177 #define WM8350_GP9_EINT                         0x0200
0178 #define WM8350_GP8_EINT                         0x0100
0179 #define WM8350_GP7_EINT                         0x0080
0180 #define WM8350_GP6_EINT                         0x0040
0181 #define WM8350_GP5_EINT                         0x0020
0182 #define WM8350_GP4_EINT                         0x0010
0183 #define WM8350_GP3_EINT                         0x0008
0184 #define WM8350_GP2_EINT                         0x0004
0185 #define WM8350_GP1_EINT                         0x0002
0186 #define WM8350_GP0_EINT                         0x0001
0187 
0188 
0189 /*
0190  * R128 (0x80) - GPIO Debounce
0191  */
0192 #define WM8350_GP12_DB                          0x1000
0193 #define WM8350_GP11_DB                          0x0800
0194 #define WM8350_GP10_DB                          0x0400
0195 #define WM8350_GP9_DB                           0x0200
0196 #define WM8350_GP8_DB                           0x0100
0197 #define WM8350_GP7_DB                           0x0080
0198 #define WM8350_GP6_DB                           0x0040
0199 #define WM8350_GP5_DB                           0x0020
0200 #define WM8350_GP4_DB                           0x0010
0201 #define WM8350_GP3_DB                           0x0008
0202 #define WM8350_GP2_DB                           0x0004
0203 #define WM8350_GP1_DB                           0x0002
0204 #define WM8350_GP0_DB                           0x0001
0205 
0206 /*
0207  * R129 (0x81) - GPIO Pin pull up Control
0208  */
0209 #define WM8350_GP12_PU                          0x1000
0210 #define WM8350_GP11_PU                          0x0800
0211 #define WM8350_GP10_PU                          0x0400
0212 #define WM8350_GP9_PU                           0x0200
0213 #define WM8350_GP8_PU                           0x0100
0214 #define WM8350_GP7_PU                           0x0080
0215 #define WM8350_GP6_PU                           0x0040
0216 #define WM8350_GP5_PU                           0x0020
0217 #define WM8350_GP4_PU                           0x0010
0218 #define WM8350_GP3_PU                           0x0008
0219 #define WM8350_GP2_PU                           0x0004
0220 #define WM8350_GP1_PU                           0x0002
0221 #define WM8350_GP0_PU                           0x0001
0222 
0223 /*
0224  * R130 (0x82) - GPIO Pull down Control
0225  */
0226 #define WM8350_GP12_PD                          0x1000
0227 #define WM8350_GP11_PD                          0x0800
0228 #define WM8350_GP10_PD                          0x0400
0229 #define WM8350_GP9_PD                           0x0200
0230 #define WM8350_GP8_PD                           0x0100
0231 #define WM8350_GP7_PD                           0x0080
0232 #define WM8350_GP6_PD                           0x0040
0233 #define WM8350_GP5_PD                           0x0020
0234 #define WM8350_GP4_PD                           0x0010
0235 #define WM8350_GP3_PD                           0x0008
0236 #define WM8350_GP2_PD                           0x0004
0237 #define WM8350_GP1_PD                           0x0002
0238 #define WM8350_GP0_PD                           0x0001
0239 
0240 /*
0241  * R131 (0x83) - GPIO Interrupt Mode
0242  */
0243 #define WM8350_GP12_INTMODE                     0x1000
0244 #define WM8350_GP11_INTMODE                     0x0800
0245 #define WM8350_GP10_INTMODE                     0x0400
0246 #define WM8350_GP9_INTMODE                      0x0200
0247 #define WM8350_GP8_INTMODE                      0x0100
0248 #define WM8350_GP7_INTMODE                      0x0080
0249 #define WM8350_GP6_INTMODE                      0x0040
0250 #define WM8350_GP5_INTMODE                      0x0020
0251 #define WM8350_GP4_INTMODE                      0x0010
0252 #define WM8350_GP3_INTMODE                      0x0008
0253 #define WM8350_GP2_INTMODE                      0x0004
0254 #define WM8350_GP1_INTMODE                      0x0002
0255 #define WM8350_GP0_INTMODE                      0x0001
0256 
0257 /*
0258  * R133 (0x85) - GPIO Control
0259  */
0260 #define WM8350_GP_DBTIME_MASK                   0x00C0
0261 
0262 /*
0263  * R134 (0x86) - GPIO Configuration (i/o)
0264  */
0265 #define WM8350_GP12_DIR                         0x1000
0266 #define WM8350_GP11_DIR                         0x0800
0267 #define WM8350_GP10_DIR                         0x0400
0268 #define WM8350_GP9_DIR                          0x0200
0269 #define WM8350_GP8_DIR                          0x0100
0270 #define WM8350_GP7_DIR                          0x0080
0271 #define WM8350_GP6_DIR                          0x0040
0272 #define WM8350_GP5_DIR                          0x0020
0273 #define WM8350_GP4_DIR                          0x0010
0274 #define WM8350_GP3_DIR                          0x0008
0275 #define WM8350_GP2_DIR                          0x0004
0276 #define WM8350_GP1_DIR                          0x0002
0277 #define WM8350_GP0_DIR                          0x0001
0278 
0279 /*
0280  * R135 (0x87) - GPIO Pin Polarity / Type
0281  */
0282 #define WM8350_GP12_CFG                         0x1000
0283 #define WM8350_GP11_CFG                         0x0800
0284 #define WM8350_GP10_CFG                         0x0400
0285 #define WM8350_GP9_CFG                          0x0200
0286 #define WM8350_GP8_CFG                          0x0100
0287 #define WM8350_GP7_CFG                          0x0080
0288 #define WM8350_GP6_CFG                          0x0040
0289 #define WM8350_GP5_CFG                          0x0020
0290 #define WM8350_GP4_CFG                          0x0010
0291 #define WM8350_GP3_CFG                          0x0008
0292 #define WM8350_GP2_CFG                          0x0004
0293 #define WM8350_GP1_CFG                          0x0002
0294 #define WM8350_GP0_CFG                          0x0001
0295 
0296 /*
0297  * R140 (0x8C) - GPIO Function Select 1
0298  */
0299 #define WM8350_GP3_FN_MASK                      0xF000
0300 #define WM8350_GP2_FN_MASK                      0x0F00
0301 #define WM8350_GP1_FN_MASK                      0x00F0
0302 #define WM8350_GP0_FN_MASK                      0x000F
0303 
0304 /*
0305  * R141 (0x8D) - GPIO Function Select 2
0306  */
0307 #define WM8350_GP7_FN_MASK                      0xF000
0308 #define WM8350_GP6_FN_MASK                      0x0F00
0309 #define WM8350_GP5_FN_MASK                      0x00F0
0310 #define WM8350_GP4_FN_MASK                      0x000F
0311 
0312 /*
0313  * R142 (0x8E) - GPIO Function Select 3
0314  */
0315 #define WM8350_GP11_FN_MASK                     0xF000
0316 #define WM8350_GP10_FN_MASK                     0x0F00
0317 #define WM8350_GP9_FN_MASK                      0x00F0
0318 #define WM8350_GP8_FN_MASK                      0x000F
0319 
0320 /*
0321  * R143 (0x8F) - GPIO Function Select 4
0322  */
0323 #define WM8350_GP12_FN_MASK                     0x000F
0324 
0325 /*
0326  * R230 (0xE6) - GPIO Pin Status
0327  */
0328 #define WM8350_GP12_LVL                         0x1000
0329 #define WM8350_GP11_LVL                         0x0800
0330 #define WM8350_GP10_LVL                         0x0400
0331 #define WM8350_GP9_LVL                          0x0200
0332 #define WM8350_GP8_LVL                          0x0100
0333 #define WM8350_GP7_LVL                          0x0080
0334 #define WM8350_GP6_LVL                          0x0040
0335 #define WM8350_GP5_LVL                          0x0020
0336 #define WM8350_GP4_LVL                          0x0010
0337 #define WM8350_GP3_LVL                          0x0008
0338 #define WM8350_GP2_LVL                          0x0004
0339 #define WM8350_GP1_LVL                          0x0002
0340 #define WM8350_GP0_LVL                          0x0001
0341 
0342 struct wm8350;
0343 
0344 int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
0345                int pol, int pull, int invert, int debounce);
0346 
0347 struct wm8350_gpio {
0348     struct platform_device *pdev;
0349 };
0350 
0351 /*
0352  * GPIO Interrupts
0353  */
0354 #define WM8350_IRQ_GPIO(x)                      (50 + x)
0355 
0356 #endif