1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright (c) 2013, Sony Mobile Communications AB. 4*4882a593Smuzhiyun */ 5*4882a593Smuzhiyun #ifndef __PINCTRL_MSM_H__ 6*4882a593Smuzhiyun #define __PINCTRL_MSM_H__ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun struct pinctrl_pin_desc; 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun /** 11*4882a593Smuzhiyun * struct msm_function - a pinmux function 12*4882a593Smuzhiyun * @name: Name of the pinmux function. 13*4882a593Smuzhiyun * @groups: List of pingroups for this function. 14*4882a593Smuzhiyun * @ngroups: Number of entries in @groups. 15*4882a593Smuzhiyun */ 16*4882a593Smuzhiyun struct msm_function { 17*4882a593Smuzhiyun const char *name; 18*4882a593Smuzhiyun const char * const *groups; 19*4882a593Smuzhiyun unsigned ngroups; 20*4882a593Smuzhiyun }; 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /** 23*4882a593Smuzhiyun * struct msm_pingroup - Qualcomm pingroup definition 24*4882a593Smuzhiyun * @name: Name of the pingroup. 25*4882a593Smuzhiyun * @pins: A list of pins assigned to this pingroup. 26*4882a593Smuzhiyun * @npins: Number of entries in @pins. 27*4882a593Smuzhiyun * @funcs: A list of pinmux functions that can be selected for 28*4882a593Smuzhiyun * this group. The index of the selected function is used 29*4882a593Smuzhiyun * for programming the function selector. 30*4882a593Smuzhiyun * Entries should be indices into the groups list of the 31*4882a593Smuzhiyun * struct msm_pinctrl_soc_data. 32*4882a593Smuzhiyun * @ctl_reg: Offset of the register holding control bits for this group. 33*4882a593Smuzhiyun * @io_reg: Offset of the register holding input/output bits for this group. 34*4882a593Smuzhiyun * @intr_cfg_reg: Offset of the register holding interrupt configuration bits. 35*4882a593Smuzhiyun * @intr_status_reg: Offset of the register holding the status bits for this group. 36*4882a593Smuzhiyun * @intr_target_reg: Offset of the register specifying routing of the interrupts 37*4882a593Smuzhiyun * from this group. 38*4882a593Smuzhiyun * @mux_bit: Offset in @ctl_reg for the pinmux function selection. 39*4882a593Smuzhiyun * @pull_bit: Offset in @ctl_reg for the bias configuration. 40*4882a593Smuzhiyun * @drv_bit: Offset in @ctl_reg for the drive strength configuration. 41*4882a593Smuzhiyun * @od_bit: Offset in @ctl_reg for controlling open drain. 42*4882a593Smuzhiyun * @oe_bit: Offset in @ctl_reg for controlling output enable. 43*4882a593Smuzhiyun * @in_bit: Offset in @io_reg for the input bit value. 44*4882a593Smuzhiyun * @out_bit: Offset in @io_reg for the output bit value. 45*4882a593Smuzhiyun * @intr_enable_bit: Offset in @intr_cfg_reg for enabling the interrupt for this group. 46*4882a593Smuzhiyun * @intr_status_bit: Offset in @intr_status_reg for reading and acking the interrupt 47*4882a593Smuzhiyun * status. 48*4882a593Smuzhiyun * @intr_target_bit: Offset in @intr_target_reg for configuring the interrupt routing. 49*4882a593Smuzhiyun * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from 50*4882a593Smuzhiyun * this gpio should get routed to the KPSS processor. 51*4882a593Smuzhiyun * @intr_raw_status_bit: Offset in @intr_cfg_reg for the raw status bit. 52*4882a593Smuzhiyun * @intr_polarity_bit: Offset in @intr_cfg_reg for specifying polarity of the interrupt. 53*4882a593Smuzhiyun * @intr_detection_bit: Offset in @intr_cfg_reg for specifying interrupt type. 54*4882a593Smuzhiyun * @intr_detection_width: Number of bits used for specifying interrupt type, 55*4882a593Smuzhiyun * Should be 2 for SoCs that can detect both edges in hardware, 56*4882a593Smuzhiyun * otherwise 1. 57*4882a593Smuzhiyun */ 58*4882a593Smuzhiyun struct msm_pingroup { 59*4882a593Smuzhiyun const char *name; 60*4882a593Smuzhiyun const unsigned *pins; 61*4882a593Smuzhiyun unsigned npins; 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun unsigned *funcs; 64*4882a593Smuzhiyun unsigned nfuncs; 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun u32 ctl_reg; 67*4882a593Smuzhiyun u32 io_reg; 68*4882a593Smuzhiyun u32 intr_cfg_reg; 69*4882a593Smuzhiyun u32 intr_status_reg; 70*4882a593Smuzhiyun u32 intr_target_reg; 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun unsigned int tile:2; 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun unsigned mux_bit:5; 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun unsigned pull_bit:5; 77*4882a593Smuzhiyun unsigned drv_bit:5; 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun unsigned od_bit:5; 80*4882a593Smuzhiyun unsigned oe_bit:5; 81*4882a593Smuzhiyun unsigned in_bit:5; 82*4882a593Smuzhiyun unsigned out_bit:5; 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun unsigned intr_enable_bit:5; 85*4882a593Smuzhiyun unsigned intr_status_bit:5; 86*4882a593Smuzhiyun unsigned intr_ack_high:1; 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun unsigned intr_target_bit:5; 89*4882a593Smuzhiyun unsigned intr_target_kpss_val:5; 90*4882a593Smuzhiyun unsigned intr_raw_status_bit:5; 91*4882a593Smuzhiyun unsigned intr_polarity_bit:5; 92*4882a593Smuzhiyun unsigned intr_detection_bit:5; 93*4882a593Smuzhiyun unsigned intr_detection_width:5; 94*4882a593Smuzhiyun }; 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun /** 97*4882a593Smuzhiyun * struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins 98*4882a593Smuzhiyun * @gpio: The GPIOs that are wakeup capable 99*4882a593Smuzhiyun * @wakeirq: The interrupt at the always-on interrupt controller 100*4882a593Smuzhiyun */ 101*4882a593Smuzhiyun struct msm_gpio_wakeirq_map { 102*4882a593Smuzhiyun unsigned int gpio; 103*4882a593Smuzhiyun unsigned int wakeirq; 104*4882a593Smuzhiyun }; 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun /** 107*4882a593Smuzhiyun * struct msm_pinctrl_soc_data - Qualcomm pin controller driver configuration 108*4882a593Smuzhiyun * @pins: An array describing all pins the pin controller affects. 109*4882a593Smuzhiyun * @npins: The number of entries in @pins. 110*4882a593Smuzhiyun * @functions: An array describing all mux functions the SoC supports. 111*4882a593Smuzhiyun * @nfunctions: The number of entries in @functions. 112*4882a593Smuzhiyun * @groups: An array describing all pin groups the pin SoC supports. 113*4882a593Smuzhiyun * @ngroups: The numbmer of entries in @groups. 114*4882a593Smuzhiyun * @ngpio: The number of pingroups the driver should expose as GPIOs. 115*4882a593Smuzhiyun * @pull_no_keeper: The SoC does not support keeper bias. 116*4882a593Smuzhiyun * @wakeirq_map: The map of wakeup capable GPIOs and the pin at PDC/MPM 117*4882a593Smuzhiyun * @nwakeirq_map: The number of entries in @wakeirq_map 118*4882a593Smuzhiyun * @wakeirq_dual_edge_errata: If true then GPIOs using the wakeirq_map need 119*4882a593Smuzhiyun * to be aware that their parent can't handle dual 120*4882a593Smuzhiyun * edge interrupts. 121*4882a593Smuzhiyun * @gpio_func: Which function number is GPIO (usually 0). 122*4882a593Smuzhiyun */ 123*4882a593Smuzhiyun struct msm_pinctrl_soc_data { 124*4882a593Smuzhiyun const struct pinctrl_pin_desc *pins; 125*4882a593Smuzhiyun unsigned npins; 126*4882a593Smuzhiyun const struct msm_function *functions; 127*4882a593Smuzhiyun unsigned nfunctions; 128*4882a593Smuzhiyun const struct msm_pingroup *groups; 129*4882a593Smuzhiyun unsigned ngroups; 130*4882a593Smuzhiyun unsigned ngpios; 131*4882a593Smuzhiyun bool pull_no_keeper; 132*4882a593Smuzhiyun const char *const *tiles; 133*4882a593Smuzhiyun unsigned int ntiles; 134*4882a593Smuzhiyun const int *reserved_gpios; 135*4882a593Smuzhiyun const struct msm_gpio_wakeirq_map *wakeirq_map; 136*4882a593Smuzhiyun unsigned int nwakeirq_map; 137*4882a593Smuzhiyun bool wakeirq_dual_edge_errata; 138*4882a593Smuzhiyun unsigned int gpio_func; 139*4882a593Smuzhiyun }; 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops; 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun int msm_pinctrl_probe(struct platform_device *pdev, 144*4882a593Smuzhiyun const struct msm_pinctrl_soc_data *soc_data); 145*4882a593Smuzhiyun int msm_pinctrl_remove(struct platform_device *pdev); 146*4882a593Smuzhiyun 147*4882a593Smuzhiyun #endif 148