162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Driver for the NVIDIA Tegra pinmux 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef __PINMUX_TEGRA_H__ 962306a36Sopenharmony_ci#define __PINMUX_TEGRA_H__ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_cistruct tegra_pmx { 1262306a36Sopenharmony_ci struct device *dev; 1362306a36Sopenharmony_ci struct pinctrl_dev *pctl; 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci const struct tegra_pinctrl_soc_data *soc; 1662306a36Sopenharmony_ci struct tegra_function *functions; 1762306a36Sopenharmony_ci const char **group_pins; 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci struct pinctrl_gpio_range gpio_range; 2062306a36Sopenharmony_ci struct pinctrl_desc desc; 2162306a36Sopenharmony_ci int nbanks; 2262306a36Sopenharmony_ci void __iomem **regs; 2362306a36Sopenharmony_ci u32 *backup_regs; 2462306a36Sopenharmony_ci}; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cienum tegra_pinconf_param { 2762306a36Sopenharmony_ci /* argument: tegra_pinconf_pull */ 2862306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_PULL, 2962306a36Sopenharmony_ci /* argument: tegra_pinconf_tristate */ 3062306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_TRISTATE, 3162306a36Sopenharmony_ci /* argument: Boolean */ 3262306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_ENABLE_INPUT, 3362306a36Sopenharmony_ci /* argument: Boolean */ 3462306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_OPEN_DRAIN, 3562306a36Sopenharmony_ci /* argument: Boolean */ 3662306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_LOCK, 3762306a36Sopenharmony_ci /* argument: Boolean */ 3862306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_IORESET, 3962306a36Sopenharmony_ci /* argument: Boolean */ 4062306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_RCV_SEL, 4162306a36Sopenharmony_ci /* argument: Boolean */ 4262306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_HIGH_SPEED_MODE, 4362306a36Sopenharmony_ci /* argument: Boolean */ 4462306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_SCHMITT, 4562306a36Sopenharmony_ci /* argument: Boolean */ 4662306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_LOW_POWER_MODE, 4762306a36Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 4862306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH, 4962306a36Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 5062306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH, 5162306a36Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 5262306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING, 5362306a36Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 5462306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_SLEW_RATE_RISING, 5562306a36Sopenharmony_ci /* argument: Integer, range is HW-dependant */ 5662306a36Sopenharmony_ci TEGRA_PINCONF_PARAM_DRIVE_TYPE, 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_cienum tegra_pinconf_pull { 6062306a36Sopenharmony_ci TEGRA_PINCONFIG_PULL_NONE, 6162306a36Sopenharmony_ci TEGRA_PINCONFIG_PULL_DOWN, 6262306a36Sopenharmony_ci TEGRA_PINCONFIG_PULL_UP, 6362306a36Sopenharmony_ci}; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_cienum tegra_pinconf_tristate { 6662306a36Sopenharmony_ci TEGRA_PINCONFIG_DRIVEN, 6762306a36Sopenharmony_ci TEGRA_PINCONFIG_TRISTATE, 6862306a36Sopenharmony_ci}; 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define TEGRA_PINCONF_PACK(_param_, _arg_) ((_param_) << 16 | (_arg_)) 7162306a36Sopenharmony_ci#define TEGRA_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16) 7262306a36Sopenharmony_ci#define TEGRA_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff) 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/** 7562306a36Sopenharmony_ci * struct tegra_function - Tegra pinctrl mux function 7662306a36Sopenharmony_ci * @name: The name of the function, exported to pinctrl core. 7762306a36Sopenharmony_ci * @groups: An array of pin groups that may select this function. 7862306a36Sopenharmony_ci * @ngroups: The number of entries in @groups. 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_cistruct tegra_function { 8162306a36Sopenharmony_ci const char *name; 8262306a36Sopenharmony_ci const char **groups; 8362306a36Sopenharmony_ci unsigned ngroups; 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/** 8762306a36Sopenharmony_ci * struct tegra_pingroup - Tegra pin group 8862306a36Sopenharmony_ci * @name The name of the pin group. 8962306a36Sopenharmony_ci * @pins An array of pin IDs included in this pin group. 9062306a36Sopenharmony_ci * @npins The number of entries in @pins. 9162306a36Sopenharmony_ci * @funcs The mux functions which can be muxed onto this group. 9262306a36Sopenharmony_ci * @mux_reg: Mux register offset. 9362306a36Sopenharmony_ci * This register contains the mux, einput, odrain, lock, 9462306a36Sopenharmony_ci * ioreset, rcv_sel parameters. 9562306a36Sopenharmony_ci * @mux_bank: Mux register bank. 9662306a36Sopenharmony_ci * @mux_bit: Mux register bit. 9762306a36Sopenharmony_ci * @pupd_reg: Pull-up/down register offset. 9862306a36Sopenharmony_ci * @pupd_bank: Pull-up/down register bank. 9962306a36Sopenharmony_ci * @pupd_bit: Pull-up/down register bit. 10062306a36Sopenharmony_ci * @tri_reg: Tri-state register offset. 10162306a36Sopenharmony_ci * @tri_bank: Tri-state register bank. 10262306a36Sopenharmony_ci * @tri_bit: Tri-state register bit. 10362306a36Sopenharmony_ci * @einput_bit: Enable-input register bit. 10462306a36Sopenharmony_ci * @odrain_bit: Open-drain register bit. 10562306a36Sopenharmony_ci * @lock_bit: Lock register bit. 10662306a36Sopenharmony_ci * @ioreset_bit: IO reset register bit. 10762306a36Sopenharmony_ci * @rcv_sel_bit: Receiver select bit. 10862306a36Sopenharmony_ci * @drv_reg: Drive fields register offset. 10962306a36Sopenharmony_ci * This register contains hsm, schmitt, lpmd, drvdn, 11062306a36Sopenharmony_ci * drvup, slwr, slwf, and drvtype parameters. 11162306a36Sopenharmony_ci * @drv_bank: Drive fields register bank. 11262306a36Sopenharmony_ci * @hsm_bit: High Speed Mode register bit. 11362306a36Sopenharmony_ci * @sfsel_bit: GPIO/SFIO selection register bit. 11462306a36Sopenharmony_ci * @schmitt_bit: Schmitt register bit. 11562306a36Sopenharmony_ci * @lpmd_bit: Low Power Mode register bit. 11662306a36Sopenharmony_ci * @drvdn_bit: Drive Down register bit. 11762306a36Sopenharmony_ci * @drvdn_width: Drive Down field width. 11862306a36Sopenharmony_ci * @drvup_bit: Drive Up register bit. 11962306a36Sopenharmony_ci * @drvup_width: Drive Up field width. 12062306a36Sopenharmony_ci * @slwr_bit: Slew Rising register bit. 12162306a36Sopenharmony_ci * @slwr_width: Slew Rising field width. 12262306a36Sopenharmony_ci * @slwf_bit: Slew Falling register bit. 12362306a36Sopenharmony_ci * @slwf_width: Slew Falling field width. 12462306a36Sopenharmony_ci * @lpdr_bit: Base driver enabling bit. 12562306a36Sopenharmony_ci * @drvtype_bit: Drive type register bit. 12662306a36Sopenharmony_ci * @parked_bitmask: Parked register mask. 0 if unsupported. 12762306a36Sopenharmony_ci * 12862306a36Sopenharmony_ci * -1 in a *_reg field means that feature is unsupported for this group. 12962306a36Sopenharmony_ci * *_bank and *_reg values are irrelevant when *_reg is -1. 13062306a36Sopenharmony_ci * When *_reg is valid, *_bit may be -1 to indicate an unsupported feature. 13162306a36Sopenharmony_ci * 13262306a36Sopenharmony_ci * A representation of a group of pins (possibly just one pin) in the Tegra 13362306a36Sopenharmony_ci * pin controller. Each group allows some parameter or parameters to be 13462306a36Sopenharmony_ci * configured. The most common is mux function selection. Many others exist 13562306a36Sopenharmony_ci * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex; 13662306a36Sopenharmony_ci * certain groups may only support configuring certain parameters, hence 13762306a36Sopenharmony_ci * each parameter is optional. 13862306a36Sopenharmony_ci */ 13962306a36Sopenharmony_cistruct tegra_pingroup { 14062306a36Sopenharmony_ci const char *name; 14162306a36Sopenharmony_ci const unsigned *pins; 14262306a36Sopenharmony_ci u8 npins; 14362306a36Sopenharmony_ci u8 funcs[4]; 14462306a36Sopenharmony_ci s32 mux_reg; 14562306a36Sopenharmony_ci s32 pupd_reg; 14662306a36Sopenharmony_ci s32 tri_reg; 14762306a36Sopenharmony_ci s32 drv_reg; 14862306a36Sopenharmony_ci u32 mux_bank:2; 14962306a36Sopenharmony_ci u32 pupd_bank:2; 15062306a36Sopenharmony_ci u32 tri_bank:2; 15162306a36Sopenharmony_ci u32 drv_bank:2; 15262306a36Sopenharmony_ci s32 mux_bit:6; 15362306a36Sopenharmony_ci s32 pupd_bit:6; 15462306a36Sopenharmony_ci s32 tri_bit:6; 15562306a36Sopenharmony_ci s32 einput_bit:6; 15662306a36Sopenharmony_ci s32 odrain_bit:6; 15762306a36Sopenharmony_ci s32 lock_bit:6; 15862306a36Sopenharmony_ci s32 ioreset_bit:6; 15962306a36Sopenharmony_ci s32 rcv_sel_bit:6; 16062306a36Sopenharmony_ci s32 hsm_bit:6; 16162306a36Sopenharmony_ci s32 sfsel_bit:6; 16262306a36Sopenharmony_ci s32 schmitt_bit:6; 16362306a36Sopenharmony_ci s32 lpmd_bit:6; 16462306a36Sopenharmony_ci s32 drvdn_bit:6; 16562306a36Sopenharmony_ci s32 drvup_bit:6; 16662306a36Sopenharmony_ci s32 slwr_bit:6; 16762306a36Sopenharmony_ci s32 slwf_bit:6; 16862306a36Sopenharmony_ci s32 lpdr_bit:6; 16962306a36Sopenharmony_ci s32 drvtype_bit:6; 17062306a36Sopenharmony_ci s32 drvdn_width:6; 17162306a36Sopenharmony_ci s32 drvup_width:6; 17262306a36Sopenharmony_ci s32 slwr_width:6; 17362306a36Sopenharmony_ci s32 slwf_width:6; 17462306a36Sopenharmony_ci u32 parked_bitmask; 17562306a36Sopenharmony_ci}; 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci/** 17862306a36Sopenharmony_ci * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration 17962306a36Sopenharmony_ci * @ngpios: The number of GPIO pins the pin controller HW affects. 18062306a36Sopenharmony_ci * @pins: An array describing all pins the pin controller affects. 18162306a36Sopenharmony_ci * All pins which are also GPIOs must be listed first within the 18262306a36Sopenharmony_ci * array, and be numbered identically to the GPIO controller's 18362306a36Sopenharmony_ci * numbering. 18462306a36Sopenharmony_ci * @npins: The numbmer of entries in @pins. 18562306a36Sopenharmony_ci * @functions: An array describing all mux functions the SoC supports. 18662306a36Sopenharmony_ci * @nfunctions: The numbmer of entries in @functions. 18762306a36Sopenharmony_ci * @groups: An array describing all pin groups the pin SoC supports. 18862306a36Sopenharmony_ci * @ngroups: The numbmer of entries in @groups. 18962306a36Sopenharmony_ci */ 19062306a36Sopenharmony_cistruct tegra_pinctrl_soc_data { 19162306a36Sopenharmony_ci unsigned ngpios; 19262306a36Sopenharmony_ci const char *gpio_compatible; 19362306a36Sopenharmony_ci const struct pinctrl_pin_desc *pins; 19462306a36Sopenharmony_ci unsigned npins; 19562306a36Sopenharmony_ci const char * const *functions; 19662306a36Sopenharmony_ci unsigned nfunctions; 19762306a36Sopenharmony_ci const struct tegra_pingroup *groups; 19862306a36Sopenharmony_ci unsigned ngroups; 19962306a36Sopenharmony_ci bool hsm_in_mux; 20062306a36Sopenharmony_ci bool schmitt_in_mux; 20162306a36Sopenharmony_ci bool drvtype_in_mux; 20262306a36Sopenharmony_ci bool sfsel_in_mux; 20362306a36Sopenharmony_ci}; 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ciextern const struct dev_pm_ops tegra_pinctrl_pm; 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ciint tegra_pinctrl_probe(struct platform_device *pdev, 20862306a36Sopenharmony_ci const struct tegra_pinctrl_soc_data *soc_data); 20962306a36Sopenharmony_ci#endif 210