162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2013, Sony Mobile Communications AB. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci#ifndef __PINCTRL_MSM_H__ 662306a36Sopenharmony_ci#define __PINCTRL_MSM_H__ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <linux/pm.h> 962306a36Sopenharmony_ci#include <linux/types.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/pinctrl/pinctrl.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cistruct platform_device; 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cistruct pinctrl_pin_desc; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#define APQ_PIN_FUNCTION(fname) \ 1862306a36Sopenharmony_ci [APQ_MUX_##fname] = PINCTRL_PINFUNCTION(#fname, \ 1962306a36Sopenharmony_ci fname##_groups, \ 2062306a36Sopenharmony_ci ARRAY_SIZE(fname##_groups)) 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define IPQ_PIN_FUNCTION(fname) \ 2362306a36Sopenharmony_ci [IPQ_MUX_##fname] = PINCTRL_PINFUNCTION(#fname, \ 2462306a36Sopenharmony_ci fname##_groups, \ 2562306a36Sopenharmony_ci ARRAY_SIZE(fname##_groups)) 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define MSM_PIN_FUNCTION(fname) \ 2862306a36Sopenharmony_ci [msm_mux_##fname] = PINCTRL_PINFUNCTION(#fname, \ 2962306a36Sopenharmony_ci fname##_groups, \ 3062306a36Sopenharmony_ci ARRAY_SIZE(fname##_groups)) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define QCA_PIN_FUNCTION(fname) \ 3362306a36Sopenharmony_ci [qca_mux_##fname] = PINCTRL_PINFUNCTION(#fname, \ 3462306a36Sopenharmony_ci fname##_groups, \ 3562306a36Sopenharmony_ci ARRAY_SIZE(fname##_groups)) 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/** 3862306a36Sopenharmony_ci * struct msm_pingroup - Qualcomm pingroup definition 3962306a36Sopenharmony_ci * @grp: Generic data of the pin group (name and pins) 4062306a36Sopenharmony_ci * @funcs: A list of pinmux functions that can be selected for 4162306a36Sopenharmony_ci * this group. The index of the selected function is used 4262306a36Sopenharmony_ci * for programming the function selector. 4362306a36Sopenharmony_ci * Entries should be indices into the groups list of the 4462306a36Sopenharmony_ci * struct msm_pinctrl_soc_data. 4562306a36Sopenharmony_ci * @ctl_reg: Offset of the register holding control bits for this group. 4662306a36Sopenharmony_ci * @io_reg: Offset of the register holding input/output bits for this group. 4762306a36Sopenharmony_ci * @intr_cfg_reg: Offset of the register holding interrupt configuration bits. 4862306a36Sopenharmony_ci * @intr_status_reg: Offset of the register holding the status bits for this group. 4962306a36Sopenharmony_ci * @intr_target_reg: Offset of the register specifying routing of the interrupts 5062306a36Sopenharmony_ci * from this group. 5162306a36Sopenharmony_ci * @mux_bit: Offset in @ctl_reg for the pinmux function selection. 5262306a36Sopenharmony_ci * @pull_bit: Offset in @ctl_reg for the bias configuration. 5362306a36Sopenharmony_ci * @drv_bit: Offset in @ctl_reg for the drive strength configuration. 5462306a36Sopenharmony_ci * @od_bit: Offset in @ctl_reg for controlling open drain. 5562306a36Sopenharmony_ci * @oe_bit: Offset in @ctl_reg for controlling output enable. 5662306a36Sopenharmony_ci * @in_bit: Offset in @io_reg for the input bit value. 5762306a36Sopenharmony_ci * @out_bit: Offset in @io_reg for the output bit value. 5862306a36Sopenharmony_ci * @intr_enable_bit: Offset in @intr_cfg_reg for enabling the interrupt for this group. 5962306a36Sopenharmony_ci * @intr_status_bit: Offset in @intr_status_reg for reading and acking the interrupt 6062306a36Sopenharmony_ci * status. 6162306a36Sopenharmony_ci * @intr_target_bit: Offset in @intr_target_reg for configuring the interrupt routing. 6262306a36Sopenharmony_ci * @intr_target_width: Number of bits used for specifying interrupt routing target. 6362306a36Sopenharmony_ci * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from 6462306a36Sopenharmony_ci * this gpio should get routed to the KPSS processor. 6562306a36Sopenharmony_ci * @intr_raw_status_bit: Offset in @intr_cfg_reg for the raw status bit. 6662306a36Sopenharmony_ci * @intr_polarity_bit: Offset in @intr_cfg_reg for specifying polarity of the interrupt. 6762306a36Sopenharmony_ci * @intr_detection_bit: Offset in @intr_cfg_reg for specifying interrupt type. 6862306a36Sopenharmony_ci * @intr_detection_width: Number of bits used for specifying interrupt type, 6962306a36Sopenharmony_ci * Should be 2 for SoCs that can detect both edges in hardware, 7062306a36Sopenharmony_ci * otherwise 1. 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_cistruct msm_pingroup { 7362306a36Sopenharmony_ci struct pingroup grp; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci unsigned *funcs; 7662306a36Sopenharmony_ci unsigned nfuncs; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci u32 ctl_reg; 7962306a36Sopenharmony_ci u32 io_reg; 8062306a36Sopenharmony_ci u32 intr_cfg_reg; 8162306a36Sopenharmony_ci u32 intr_status_reg; 8262306a36Sopenharmony_ci u32 intr_target_reg; 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci unsigned int tile:2; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci unsigned mux_bit:5; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci unsigned pull_bit:5; 8962306a36Sopenharmony_ci unsigned drv_bit:5; 9062306a36Sopenharmony_ci unsigned i2c_pull_bit:5; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci unsigned od_bit:5; 9362306a36Sopenharmony_ci unsigned egpio_enable:5; 9462306a36Sopenharmony_ci unsigned egpio_present:5; 9562306a36Sopenharmony_ci unsigned oe_bit:5; 9662306a36Sopenharmony_ci unsigned in_bit:5; 9762306a36Sopenharmony_ci unsigned out_bit:5; 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci unsigned intr_enable_bit:5; 10062306a36Sopenharmony_ci unsigned intr_status_bit:5; 10162306a36Sopenharmony_ci unsigned intr_ack_high:1; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci unsigned intr_target_bit:5; 10462306a36Sopenharmony_ci unsigned intr_target_width:5; 10562306a36Sopenharmony_ci unsigned intr_target_kpss_val:5; 10662306a36Sopenharmony_ci unsigned intr_raw_status_bit:5; 10762306a36Sopenharmony_ci unsigned intr_polarity_bit:5; 10862306a36Sopenharmony_ci unsigned intr_detection_bit:5; 10962306a36Sopenharmony_ci unsigned intr_detection_width:5; 11062306a36Sopenharmony_ci}; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci/** 11362306a36Sopenharmony_ci * struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins 11462306a36Sopenharmony_ci * @gpio: The GPIOs that are wakeup capable 11562306a36Sopenharmony_ci * @wakeirq: The interrupt at the always-on interrupt controller 11662306a36Sopenharmony_ci */ 11762306a36Sopenharmony_cistruct msm_gpio_wakeirq_map { 11862306a36Sopenharmony_ci unsigned int gpio; 11962306a36Sopenharmony_ci unsigned int wakeirq; 12062306a36Sopenharmony_ci}; 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci/** 12362306a36Sopenharmony_ci * struct msm_pinctrl_soc_data - Qualcomm pin controller driver configuration 12462306a36Sopenharmony_ci * @pins: An array describing all pins the pin controller affects. 12562306a36Sopenharmony_ci * @npins: The number of entries in @pins. 12662306a36Sopenharmony_ci * @functions: An array describing all mux functions the SoC supports. 12762306a36Sopenharmony_ci * @nfunctions: The number of entries in @functions. 12862306a36Sopenharmony_ci * @groups: An array describing all pin groups the pin SoC supports. 12962306a36Sopenharmony_ci * @ngroups: The numbmer of entries in @groups. 13062306a36Sopenharmony_ci * @ngpio: The number of pingroups the driver should expose as GPIOs. 13162306a36Sopenharmony_ci * @pull_no_keeper: The SoC does not support keeper bias. 13262306a36Sopenharmony_ci * @wakeirq_map: The map of wakeup capable GPIOs and the pin at PDC/MPM 13362306a36Sopenharmony_ci * @nwakeirq_map: The number of entries in @wakeirq_map 13462306a36Sopenharmony_ci * @wakeirq_dual_edge_errata: If true then GPIOs using the wakeirq_map need 13562306a36Sopenharmony_ci * to be aware that their parent can't handle dual 13662306a36Sopenharmony_ci * edge interrupts. 13762306a36Sopenharmony_ci * @gpio_func: Which function number is GPIO (usually 0). 13862306a36Sopenharmony_ci * @egpio_func: If non-zero then this SoC supports eGPIO. Even though in 13962306a36Sopenharmony_ci * hardware this is a mux 1-level above the TLMM, we'll treat 14062306a36Sopenharmony_ci * it as if this is just another mux state of the TLMM. Since 14162306a36Sopenharmony_ci * it doesn't really map to hardware, we'll allocate a virtual 14262306a36Sopenharmony_ci * function number for eGPIO and any time we see that function 14362306a36Sopenharmony_ci * number used we'll treat it as a request to mux away from 14462306a36Sopenharmony_ci * our TLMM towards another owner. 14562306a36Sopenharmony_ci */ 14662306a36Sopenharmony_cistruct msm_pinctrl_soc_data { 14762306a36Sopenharmony_ci const struct pinctrl_pin_desc *pins; 14862306a36Sopenharmony_ci unsigned npins; 14962306a36Sopenharmony_ci const struct pinfunction *functions; 15062306a36Sopenharmony_ci unsigned nfunctions; 15162306a36Sopenharmony_ci const struct msm_pingroup *groups; 15262306a36Sopenharmony_ci unsigned ngroups; 15362306a36Sopenharmony_ci unsigned ngpios; 15462306a36Sopenharmony_ci bool pull_no_keeper; 15562306a36Sopenharmony_ci const char *const *tiles; 15662306a36Sopenharmony_ci unsigned int ntiles; 15762306a36Sopenharmony_ci const int *reserved_gpios; 15862306a36Sopenharmony_ci const struct msm_gpio_wakeirq_map *wakeirq_map; 15962306a36Sopenharmony_ci unsigned int nwakeirq_map; 16062306a36Sopenharmony_ci bool wakeirq_dual_edge_errata; 16162306a36Sopenharmony_ci unsigned int gpio_func; 16262306a36Sopenharmony_ci unsigned int egpio_func; 16362306a36Sopenharmony_ci}; 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ciextern const struct dev_pm_ops msm_pinctrl_dev_pm_ops; 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ciint msm_pinctrl_probe(struct platform_device *pdev, 16862306a36Sopenharmony_ci const struct msm_pinctrl_soc_data *soc_data); 16962306a36Sopenharmony_ciint msm_pinctrl_remove(struct platform_device *pdev); 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#endif 172