18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Driver for the NVIDIA Tegra pinmux 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __PINMUX_TEGRA_H__ 98c2ecf20Sopenharmony_ci#define __PINMUX_TEGRA_H__ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct tegra_pmx { 128c2ecf20Sopenharmony_ci struct device *dev; 138c2ecf20Sopenharmony_ci struct pinctrl_dev *pctl; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci const struct tegra_pinctrl_soc_data *soc; 168c2ecf20Sopenharmony_ci const char **group_pins; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci int nbanks; 198c2ecf20Sopenharmony_ci void __iomem **regs; 208c2ecf20Sopenharmony_ci u32 *backup_regs; 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cienum tegra_pinconf_param { 248c2ecf20Sopenharmony_ci /* argument: tegra_pinconf_pull */ 258c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_PULL, 268c2ecf20Sopenharmony_ci /* argument: tegra_pinconf_tristate */ 278c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_TRISTATE, 288c2ecf20Sopenharmony_ci /* argument: Boolean */ 298c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_ENABLE_INPUT, 308c2ecf20Sopenharmony_ci /* argument: Boolean */ 318c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_OPEN_DRAIN, 328c2ecf20Sopenharmony_ci /* argument: Boolean */ 338c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_LOCK, 348c2ecf20Sopenharmony_ci /* argument: Boolean */ 358c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_IORESET, 368c2ecf20Sopenharmony_ci /* argument: Boolean */ 378c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_RCV_SEL, 388c2ecf20Sopenharmony_ci /* argument: Boolean */ 398c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_HIGH_SPEED_MODE, 408c2ecf20Sopenharmony_ci /* argument: Boolean */ 418c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_SCHMITT, 428c2ecf20Sopenharmony_ci /* argument: Boolean */ 438c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_LOW_POWER_MODE, 448c2ecf20Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 458c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH, 468c2ecf20Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 478c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH, 488c2ecf20Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 498c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING, 508c2ecf20Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 518c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_SLEW_RATE_RISING, 528c2ecf20Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 538c2ecf20Sopenharmony_ci TEGRA_PINCONF_PARAM_DRIVE_TYPE, 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cienum tegra_pinconf_pull { 578c2ecf20Sopenharmony_ci TEGRA_PINCONFIG_PULL_NONE, 588c2ecf20Sopenharmony_ci TEGRA_PINCONFIG_PULL_DOWN, 598c2ecf20Sopenharmony_ci TEGRA_PINCONFIG_PULL_UP, 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cienum tegra_pinconf_tristate { 638c2ecf20Sopenharmony_ci TEGRA_PINCONFIG_DRIVEN, 648c2ecf20Sopenharmony_ci TEGRA_PINCONFIG_TRISTATE, 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define TEGRA_PINCONF_PACK(_param_, _arg_) ((_param_) << 16 | (_arg_)) 688c2ecf20Sopenharmony_ci#define TEGRA_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16) 698c2ecf20Sopenharmony_ci#define TEGRA_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff) 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/** 728c2ecf20Sopenharmony_ci * struct tegra_function - Tegra pinctrl mux function 738c2ecf20Sopenharmony_ci * @name: The name of the function, exported to pinctrl core. 748c2ecf20Sopenharmony_ci * @groups: An array of pin groups that may select this function. 758c2ecf20Sopenharmony_ci * @ngroups: The number of entries in @groups. 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_cistruct tegra_function { 788c2ecf20Sopenharmony_ci const char *name; 798c2ecf20Sopenharmony_ci const char **groups; 808c2ecf20Sopenharmony_ci unsigned ngroups; 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/** 848c2ecf20Sopenharmony_ci * struct tegra_pingroup - Tegra pin group 858c2ecf20Sopenharmony_ci * @name The name of the pin group. 868c2ecf20Sopenharmony_ci * @pins An array of pin IDs included in this pin group. 878c2ecf20Sopenharmony_ci * @npins The number of entries in @pins. 888c2ecf20Sopenharmony_ci * @funcs The mux functions which can be muxed onto this group. 898c2ecf20Sopenharmony_ci * @mux_reg: Mux register offset. 908c2ecf20Sopenharmony_ci * This register contains the mux, einput, odrain, lock, 918c2ecf20Sopenharmony_ci * ioreset, rcv_sel parameters. 928c2ecf20Sopenharmony_ci * @mux_bank: Mux register bank. 938c2ecf20Sopenharmony_ci * @mux_bit: Mux register bit. 948c2ecf20Sopenharmony_ci * @pupd_reg: Pull-up/down register offset. 958c2ecf20Sopenharmony_ci * @pupd_bank: Pull-up/down register bank. 968c2ecf20Sopenharmony_ci * @pupd_bit: Pull-up/down register bit. 978c2ecf20Sopenharmony_ci * @tri_reg: Tri-state register offset. 988c2ecf20Sopenharmony_ci * @tri_bank: Tri-state register bank. 998c2ecf20Sopenharmony_ci * @tri_bit: Tri-state register bit. 1008c2ecf20Sopenharmony_ci * @einput_bit: Enable-input register bit. 1018c2ecf20Sopenharmony_ci * @odrain_bit: Open-drain register bit. 1028c2ecf20Sopenharmony_ci * @lock_bit: Lock register bit. 1038c2ecf20Sopenharmony_ci * @ioreset_bit: IO reset register bit. 1048c2ecf20Sopenharmony_ci * @rcv_sel_bit: Receiver select bit. 1058c2ecf20Sopenharmony_ci * @drv_reg: Drive fields register offset. 1068c2ecf20Sopenharmony_ci * This register contains hsm, schmitt, lpmd, drvdn, 1078c2ecf20Sopenharmony_ci * drvup, slwr, slwf, and drvtype parameters. 1088c2ecf20Sopenharmony_ci * @drv_bank: Drive fields register bank. 1098c2ecf20Sopenharmony_ci * @hsm_bit: High Speed Mode register bit. 1108c2ecf20Sopenharmony_ci * @sfsel_bit: GPIO/SFIO selection register bit. 1118c2ecf20Sopenharmony_ci * @schmitt_bit: Schmitt register bit. 1128c2ecf20Sopenharmony_ci * @lpmd_bit: Low Power Mode register bit. 1138c2ecf20Sopenharmony_ci * @drvdn_bit: Drive Down register bit. 1148c2ecf20Sopenharmony_ci * @drvdn_width: Drive Down field width. 1158c2ecf20Sopenharmony_ci * @drvup_bit: Drive Up register bit. 1168c2ecf20Sopenharmony_ci * @drvup_width: Drive Up field width. 1178c2ecf20Sopenharmony_ci * @slwr_bit: Slew Rising register bit. 1188c2ecf20Sopenharmony_ci * @slwr_width: Slew Rising field width. 1198c2ecf20Sopenharmony_ci * @slwf_bit: Slew Falling register bit. 1208c2ecf20Sopenharmony_ci * @slwf_width: Slew Falling field width. 1218c2ecf20Sopenharmony_ci * @drvtype_bit: Drive type register bit. 1228c2ecf20Sopenharmony_ci * @parked_bitmask: Parked register mask. 0 if unsupported. 1238c2ecf20Sopenharmony_ci * 1248c2ecf20Sopenharmony_ci * -1 in a *_reg field means that feature is unsupported for this group. 1258c2ecf20Sopenharmony_ci * *_bank and *_reg values are irrelevant when *_reg is -1. 1268c2ecf20Sopenharmony_ci * When *_reg is valid, *_bit may be -1 to indicate an unsupported feature. 1278c2ecf20Sopenharmony_ci * 1288c2ecf20Sopenharmony_ci * A representation of a group of pins (possibly just one pin) in the Tegra 1298c2ecf20Sopenharmony_ci * pin controller. Each group allows some parameter or parameters to be 1308c2ecf20Sopenharmony_ci * configured. The most common is mux function selection. Many others exist 1318c2ecf20Sopenharmony_ci * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex; 1328c2ecf20Sopenharmony_ci * certain groups may only support configuring certain parameters, hence 1338c2ecf20Sopenharmony_ci * each parameter is optional. 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_cistruct tegra_pingroup { 1368c2ecf20Sopenharmony_ci const char *name; 1378c2ecf20Sopenharmony_ci const unsigned *pins; 1388c2ecf20Sopenharmony_ci u8 npins; 1398c2ecf20Sopenharmony_ci u8 funcs[4]; 1408c2ecf20Sopenharmony_ci s32 mux_reg; 1418c2ecf20Sopenharmony_ci s32 pupd_reg; 1428c2ecf20Sopenharmony_ci s32 tri_reg; 1438c2ecf20Sopenharmony_ci s32 drv_reg; 1448c2ecf20Sopenharmony_ci u32 mux_bank:2; 1458c2ecf20Sopenharmony_ci u32 pupd_bank:2; 1468c2ecf20Sopenharmony_ci u32 tri_bank:2; 1478c2ecf20Sopenharmony_ci u32 drv_bank:2; 1488c2ecf20Sopenharmony_ci s32 mux_bit:6; 1498c2ecf20Sopenharmony_ci s32 pupd_bit:6; 1508c2ecf20Sopenharmony_ci s32 tri_bit:6; 1518c2ecf20Sopenharmony_ci s32 einput_bit:6; 1528c2ecf20Sopenharmony_ci s32 odrain_bit:6; 1538c2ecf20Sopenharmony_ci s32 lock_bit:6; 1548c2ecf20Sopenharmony_ci s32 ioreset_bit:6; 1558c2ecf20Sopenharmony_ci s32 rcv_sel_bit:6; 1568c2ecf20Sopenharmony_ci s32 hsm_bit:6; 1578c2ecf20Sopenharmony_ci s32 sfsel_bit:6; 1588c2ecf20Sopenharmony_ci s32 schmitt_bit:6; 1598c2ecf20Sopenharmony_ci s32 lpmd_bit:6; 1608c2ecf20Sopenharmony_ci s32 drvdn_bit:6; 1618c2ecf20Sopenharmony_ci s32 drvup_bit:6; 1628c2ecf20Sopenharmony_ci s32 slwr_bit:6; 1638c2ecf20Sopenharmony_ci s32 slwf_bit:6; 1648c2ecf20Sopenharmony_ci s32 drvtype_bit:6; 1658c2ecf20Sopenharmony_ci s32 drvdn_width:6; 1668c2ecf20Sopenharmony_ci s32 drvup_width:6; 1678c2ecf20Sopenharmony_ci s32 slwr_width:6; 1688c2ecf20Sopenharmony_ci s32 slwf_width:6; 1698c2ecf20Sopenharmony_ci u32 parked_bitmask; 1708c2ecf20Sopenharmony_ci}; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci/** 1738c2ecf20Sopenharmony_ci * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration 1748c2ecf20Sopenharmony_ci * @ngpios: The number of GPIO pins the pin controller HW affects. 1758c2ecf20Sopenharmony_ci * @pins: An array describing all pins the pin controller affects. 1768c2ecf20Sopenharmony_ci * All pins which are also GPIOs must be listed first within the 1778c2ecf20Sopenharmony_ci * array, and be numbered identically to the GPIO controller's 1788c2ecf20Sopenharmony_ci * numbering. 1798c2ecf20Sopenharmony_ci * @npins: The numbmer of entries in @pins. 1808c2ecf20Sopenharmony_ci * @functions: An array describing all mux functions the SoC supports. 1818c2ecf20Sopenharmony_ci * @nfunctions: The numbmer of entries in @functions. 1828c2ecf20Sopenharmony_ci * @groups: An array describing all pin groups the pin SoC supports. 1838c2ecf20Sopenharmony_ci * @ngroups: The numbmer of entries in @groups. 1848c2ecf20Sopenharmony_ci */ 1858c2ecf20Sopenharmony_cistruct tegra_pinctrl_soc_data { 1868c2ecf20Sopenharmony_ci unsigned ngpios; 1878c2ecf20Sopenharmony_ci const char *gpio_compatible; 1888c2ecf20Sopenharmony_ci const struct pinctrl_pin_desc *pins; 1898c2ecf20Sopenharmony_ci unsigned npins; 1908c2ecf20Sopenharmony_ci struct tegra_function *functions; 1918c2ecf20Sopenharmony_ci unsigned nfunctions; 1928c2ecf20Sopenharmony_ci const struct tegra_pingroup *groups; 1938c2ecf20Sopenharmony_ci unsigned ngroups; 1948c2ecf20Sopenharmony_ci bool hsm_in_mux; 1958c2ecf20Sopenharmony_ci bool schmitt_in_mux; 1968c2ecf20Sopenharmony_ci bool drvtype_in_mux; 1978c2ecf20Sopenharmony_ci bool sfsel_in_mux; 1988c2ecf20Sopenharmony_ci}; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ciextern const struct dev_pm_ops tegra_pinctrl_pm; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ciint tegra_pinctrl_probe(struct platform_device *pdev, 2038c2ecf20Sopenharmony_ci const struct tegra_pinctrl_soc_data *soc_data); 2048c2ecf20Sopenharmony_ci#endif 205