18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2013, Sony Mobile Communications AB.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#ifndef __PINCTRL_MSM_H__
68c2ecf20Sopenharmony_ci#define __PINCTRL_MSM_H__
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistruct pinctrl_pin_desc;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/**
118c2ecf20Sopenharmony_ci * struct msm_function - a pinmux function
128c2ecf20Sopenharmony_ci * @name:    Name of the pinmux function.
138c2ecf20Sopenharmony_ci * @groups:  List of pingroups for this function.
148c2ecf20Sopenharmony_ci * @ngroups: Number of entries in @groups.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_cistruct msm_function {
178c2ecf20Sopenharmony_ci	const char *name;
188c2ecf20Sopenharmony_ci	const char * const *groups;
198c2ecf20Sopenharmony_ci	unsigned ngroups;
208c2ecf20Sopenharmony_ci};
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/**
238c2ecf20Sopenharmony_ci * struct msm_pingroup - Qualcomm pingroup definition
248c2ecf20Sopenharmony_ci * @name:                 Name of the pingroup.
258c2ecf20Sopenharmony_ci * @pins:	          A list of pins assigned to this pingroup.
268c2ecf20Sopenharmony_ci * @npins:	          Number of entries in @pins.
278c2ecf20Sopenharmony_ci * @funcs:                A list of pinmux functions that can be selected for
288c2ecf20Sopenharmony_ci *                        this group. The index of the selected function is used
298c2ecf20Sopenharmony_ci *                        for programming the function selector.
308c2ecf20Sopenharmony_ci *                        Entries should be indices into the groups list of the
318c2ecf20Sopenharmony_ci *                        struct msm_pinctrl_soc_data.
328c2ecf20Sopenharmony_ci * @ctl_reg:              Offset of the register holding control bits for this group.
338c2ecf20Sopenharmony_ci * @io_reg:               Offset of the register holding input/output bits for this group.
348c2ecf20Sopenharmony_ci * @intr_cfg_reg:         Offset of the register holding interrupt configuration bits.
358c2ecf20Sopenharmony_ci * @intr_status_reg:      Offset of the register holding the status bits for this group.
368c2ecf20Sopenharmony_ci * @intr_target_reg:      Offset of the register specifying routing of the interrupts
378c2ecf20Sopenharmony_ci *                        from this group.
388c2ecf20Sopenharmony_ci * @mux_bit:              Offset in @ctl_reg for the pinmux function selection.
398c2ecf20Sopenharmony_ci * @pull_bit:             Offset in @ctl_reg for the bias configuration.
408c2ecf20Sopenharmony_ci * @drv_bit:              Offset in @ctl_reg for the drive strength configuration.
418c2ecf20Sopenharmony_ci * @od_bit:               Offset in @ctl_reg for controlling open drain.
428c2ecf20Sopenharmony_ci * @oe_bit:               Offset in @ctl_reg for controlling output enable.
438c2ecf20Sopenharmony_ci * @in_bit:               Offset in @io_reg for the input bit value.
448c2ecf20Sopenharmony_ci * @out_bit:              Offset in @io_reg for the output bit value.
458c2ecf20Sopenharmony_ci * @intr_enable_bit:      Offset in @intr_cfg_reg for enabling the interrupt for this group.
468c2ecf20Sopenharmony_ci * @intr_status_bit:      Offset in @intr_status_reg for reading and acking the interrupt
478c2ecf20Sopenharmony_ci *                        status.
488c2ecf20Sopenharmony_ci * @intr_target_bit:      Offset in @intr_target_reg for configuring the interrupt routing.
498c2ecf20Sopenharmony_ci * @intr_target_kpss_val: Value in @intr_target_bit for specifying that the interrupt from
508c2ecf20Sopenharmony_ci *                        this gpio should get routed to the KPSS processor.
518c2ecf20Sopenharmony_ci * @intr_raw_status_bit:  Offset in @intr_cfg_reg for the raw status bit.
528c2ecf20Sopenharmony_ci * @intr_polarity_bit:    Offset in @intr_cfg_reg for specifying polarity of the interrupt.
538c2ecf20Sopenharmony_ci * @intr_detection_bit:   Offset in @intr_cfg_reg for specifying interrupt type.
548c2ecf20Sopenharmony_ci * @intr_detection_width: Number of bits used for specifying interrupt type,
558c2ecf20Sopenharmony_ci *                        Should be 2 for SoCs that can detect both edges in hardware,
568c2ecf20Sopenharmony_ci *                        otherwise 1.
578c2ecf20Sopenharmony_ci */
588c2ecf20Sopenharmony_cistruct msm_pingroup {
598c2ecf20Sopenharmony_ci	const char *name;
608c2ecf20Sopenharmony_ci	const unsigned *pins;
618c2ecf20Sopenharmony_ci	unsigned npins;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	unsigned *funcs;
648c2ecf20Sopenharmony_ci	unsigned nfuncs;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	u32 ctl_reg;
678c2ecf20Sopenharmony_ci	u32 io_reg;
688c2ecf20Sopenharmony_ci	u32 intr_cfg_reg;
698c2ecf20Sopenharmony_ci	u32 intr_status_reg;
708c2ecf20Sopenharmony_ci	u32 intr_target_reg;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	unsigned int tile:2;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	unsigned mux_bit:5;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	unsigned pull_bit:5;
778c2ecf20Sopenharmony_ci	unsigned drv_bit:5;
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	unsigned od_bit:5;
808c2ecf20Sopenharmony_ci	unsigned oe_bit:5;
818c2ecf20Sopenharmony_ci	unsigned in_bit:5;
828c2ecf20Sopenharmony_ci	unsigned out_bit:5;
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci	unsigned intr_enable_bit:5;
858c2ecf20Sopenharmony_ci	unsigned intr_status_bit:5;
868c2ecf20Sopenharmony_ci	unsigned intr_ack_high:1;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	unsigned intr_target_bit:5;
898c2ecf20Sopenharmony_ci	unsigned intr_target_kpss_val:5;
908c2ecf20Sopenharmony_ci	unsigned intr_raw_status_bit:5;
918c2ecf20Sopenharmony_ci	unsigned intr_polarity_bit:5;
928c2ecf20Sopenharmony_ci	unsigned intr_detection_bit:5;
938c2ecf20Sopenharmony_ci	unsigned intr_detection_width:5;
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/**
978c2ecf20Sopenharmony_ci * struct msm_gpio_wakeirq_map - Map of GPIOs and their wakeup pins
988c2ecf20Sopenharmony_ci * @gpio:          The GPIOs that are wakeup capable
998c2ecf20Sopenharmony_ci * @wakeirq:       The interrupt at the always-on interrupt controller
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_cistruct msm_gpio_wakeirq_map {
1028c2ecf20Sopenharmony_ci	unsigned int gpio;
1038c2ecf20Sopenharmony_ci	unsigned int wakeirq;
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/**
1078c2ecf20Sopenharmony_ci * struct msm_pinctrl_soc_data - Qualcomm pin controller driver configuration
1088c2ecf20Sopenharmony_ci * @pins:	    An array describing all pins the pin controller affects.
1098c2ecf20Sopenharmony_ci * @npins:	    The number of entries in @pins.
1108c2ecf20Sopenharmony_ci * @functions:	    An array describing all mux functions the SoC supports.
1118c2ecf20Sopenharmony_ci * @nfunctions:	    The number of entries in @functions.
1128c2ecf20Sopenharmony_ci * @groups:	    An array describing all pin groups the pin SoC supports.
1138c2ecf20Sopenharmony_ci * @ngroups:	    The numbmer of entries in @groups.
1148c2ecf20Sopenharmony_ci * @ngpio:	    The number of pingroups the driver should expose as GPIOs.
1158c2ecf20Sopenharmony_ci * @pull_no_keeper: The SoC does not support keeper bias.
1168c2ecf20Sopenharmony_ci * @wakeirq_map:    The map of wakeup capable GPIOs and the pin at PDC/MPM
1178c2ecf20Sopenharmony_ci * @nwakeirq_map:   The number of entries in @wakeirq_map
1188c2ecf20Sopenharmony_ci * @wakeirq_dual_edge_errata: If true then GPIOs using the wakeirq_map need
1198c2ecf20Sopenharmony_ci *                            to be aware that their parent can't handle dual
1208c2ecf20Sopenharmony_ci *                            edge interrupts.
1218c2ecf20Sopenharmony_ci * @gpio_func: Which function number is GPIO (usually 0).
1228c2ecf20Sopenharmony_ci */
1238c2ecf20Sopenharmony_cistruct msm_pinctrl_soc_data {
1248c2ecf20Sopenharmony_ci	const struct pinctrl_pin_desc *pins;
1258c2ecf20Sopenharmony_ci	unsigned npins;
1268c2ecf20Sopenharmony_ci	const struct msm_function *functions;
1278c2ecf20Sopenharmony_ci	unsigned nfunctions;
1288c2ecf20Sopenharmony_ci	const struct msm_pingroup *groups;
1298c2ecf20Sopenharmony_ci	unsigned ngroups;
1308c2ecf20Sopenharmony_ci	unsigned ngpios;
1318c2ecf20Sopenharmony_ci	bool pull_no_keeper;
1328c2ecf20Sopenharmony_ci	const char *const *tiles;
1338c2ecf20Sopenharmony_ci	unsigned int ntiles;
1348c2ecf20Sopenharmony_ci	const int *reserved_gpios;
1358c2ecf20Sopenharmony_ci	const struct msm_gpio_wakeirq_map *wakeirq_map;
1368c2ecf20Sopenharmony_ci	unsigned int nwakeirq_map;
1378c2ecf20Sopenharmony_ci	bool wakeirq_dual_edge_errata;
1388c2ecf20Sopenharmony_ci	unsigned int gpio_func;
1398c2ecf20Sopenharmony_ci};
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ciextern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ciint msm_pinctrl_probe(struct platform_device *pdev,
1448c2ecf20Sopenharmony_ci		      const struct msm_pinctrl_soc_data *soc_data);
1458c2ecf20Sopenharmony_ciint msm_pinctrl_remove(struct platform_device *pdev);
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#endif
148