1*25cbac77SMasahiro Yamada /* 2*25cbac77SMasahiro Yamada * Driver for the NVIDIA Tegra pinmux 3*25cbac77SMasahiro Yamada * 4*25cbac77SMasahiro Yamada * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. 5*25cbac77SMasahiro Yamada * 6*25cbac77SMasahiro Yamada * This program is free software; you can redistribute it and/or modify it 7*25cbac77SMasahiro Yamada * under the terms and conditions of the GNU General Public License, 8*25cbac77SMasahiro Yamada * version 2, as published by the Free Software Foundation. 9*25cbac77SMasahiro Yamada * 10*25cbac77SMasahiro Yamada * This program is distributed in the hope it will be useful, but WITHOUT 11*25cbac77SMasahiro Yamada * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12*25cbac77SMasahiro Yamada * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13*25cbac77SMasahiro Yamada * more details. 14*25cbac77SMasahiro Yamada */ 15*25cbac77SMasahiro Yamada 16*25cbac77SMasahiro Yamada #ifndef __PINMUX_TEGRA_H__ 17*25cbac77SMasahiro Yamada #define __PINMUX_TEGRA_H__ 18*25cbac77SMasahiro Yamada 19*25cbac77SMasahiro Yamada enum tegra_pinconf_param { 20*25cbac77SMasahiro Yamada /* argument: tegra_pinconf_pull */ 21*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_PULL, 22*25cbac77SMasahiro Yamada /* argument: tegra_pinconf_tristate */ 23*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_TRISTATE, 24*25cbac77SMasahiro Yamada /* argument: Boolean */ 25*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_ENABLE_INPUT, 26*25cbac77SMasahiro Yamada /* argument: Boolean */ 27*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_OPEN_DRAIN, 28*25cbac77SMasahiro Yamada /* argument: Boolean */ 29*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_LOCK, 30*25cbac77SMasahiro Yamada /* argument: Boolean */ 31*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_IORESET, 32*25cbac77SMasahiro Yamada /* argument: Boolean */ 33*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_RCV_SEL, 34*25cbac77SMasahiro Yamada /* argument: Boolean */ 35*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_HIGH_SPEED_MODE, 36*25cbac77SMasahiro Yamada /* argument: Boolean */ 37*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_SCHMITT, 38*25cbac77SMasahiro Yamada /* argument: Boolean */ 39*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_LOW_POWER_MODE, 40*25cbac77SMasahiro Yamada /* argument: Integer, range is HW-dependant */ 41*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH, 42*25cbac77SMasahiro Yamada /* argument: Integer, range is HW-dependant */ 43*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH, 44*25cbac77SMasahiro Yamada /* argument: Integer, range is HW-dependant */ 45*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING, 46*25cbac77SMasahiro Yamada /* argument: Integer, range is HW-dependant */ 47*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_SLEW_RATE_RISING, 48*25cbac77SMasahiro Yamada /* argument: Integer, range is HW-dependant */ 49*25cbac77SMasahiro Yamada TEGRA_PINCONF_PARAM_DRIVE_TYPE, 50*25cbac77SMasahiro Yamada }; 51*25cbac77SMasahiro Yamada 52*25cbac77SMasahiro Yamada enum tegra_pinconf_pull { 53*25cbac77SMasahiro Yamada TEGRA_PINCONFIG_PULL_NONE, 54*25cbac77SMasahiro Yamada TEGRA_PINCONFIG_PULL_DOWN, 55*25cbac77SMasahiro Yamada TEGRA_PINCONFIG_PULL_UP, 56*25cbac77SMasahiro Yamada }; 57*25cbac77SMasahiro Yamada 58*25cbac77SMasahiro Yamada enum tegra_pinconf_tristate { 59*25cbac77SMasahiro Yamada TEGRA_PINCONFIG_DRIVEN, 60*25cbac77SMasahiro Yamada TEGRA_PINCONFIG_TRISTATE, 61*25cbac77SMasahiro Yamada }; 62*25cbac77SMasahiro Yamada 63*25cbac77SMasahiro Yamada #define TEGRA_PINCONF_PACK(_param_, _arg_) ((_param_) << 16 | (_arg_)) 64*25cbac77SMasahiro Yamada #define TEGRA_PINCONF_UNPACK_PARAM(_conf_) ((_conf_) >> 16) 65*25cbac77SMasahiro Yamada #define TEGRA_PINCONF_UNPACK_ARG(_conf_) ((_conf_) & 0xffff) 66*25cbac77SMasahiro Yamada 67*25cbac77SMasahiro Yamada /** 68*25cbac77SMasahiro Yamada * struct tegra_function - Tegra pinctrl mux function 69*25cbac77SMasahiro Yamada * @name: The name of the function, exported to pinctrl core. 70*25cbac77SMasahiro Yamada * @groups: An array of pin groups that may select this function. 71*25cbac77SMasahiro Yamada * @ngroups: The number of entries in @groups. 72*25cbac77SMasahiro Yamada */ 73*25cbac77SMasahiro Yamada struct tegra_function { 74*25cbac77SMasahiro Yamada const char *name; 75*25cbac77SMasahiro Yamada const char **groups; 76*25cbac77SMasahiro Yamada unsigned ngroups; 77*25cbac77SMasahiro Yamada }; 78*25cbac77SMasahiro Yamada 79*25cbac77SMasahiro Yamada /** 80*25cbac77SMasahiro Yamada * struct tegra_pingroup - Tegra pin group 81*25cbac77SMasahiro Yamada * @name The name of the pin group. 82*25cbac77SMasahiro Yamada * @pins An array of pin IDs included in this pin group. 83*25cbac77SMasahiro Yamada * @npins The number of entries in @pins. 84*25cbac77SMasahiro Yamada * @funcs The mux functions which can be muxed onto this group. 85*25cbac77SMasahiro Yamada * @mux_reg: Mux register offset. 86*25cbac77SMasahiro Yamada * This register contains the mux, einput, odrain, lock, 87*25cbac77SMasahiro Yamada * ioreset, rcv_sel parameters. 88*25cbac77SMasahiro Yamada * @mux_bank: Mux register bank. 89*25cbac77SMasahiro Yamada * @mux_bit: Mux register bit. 90*25cbac77SMasahiro Yamada * @pupd_reg: Pull-up/down register offset. 91*25cbac77SMasahiro Yamada * @pupd_bank: Pull-up/down register bank. 92*25cbac77SMasahiro Yamada * @pupd_bit: Pull-up/down register bit. 93*25cbac77SMasahiro Yamada * @tri_reg: Tri-state register offset. 94*25cbac77SMasahiro Yamada * @tri_bank: Tri-state register bank. 95*25cbac77SMasahiro Yamada * @tri_bit: Tri-state register bit. 96*25cbac77SMasahiro Yamada * @einput_bit: Enable-input register bit. 97*25cbac77SMasahiro Yamada * @odrain_bit: Open-drain register bit. 98*25cbac77SMasahiro Yamada * @lock_bit: Lock register bit. 99*25cbac77SMasahiro Yamada * @ioreset_bit: IO reset register bit. 100*25cbac77SMasahiro Yamada * @rcv_sel_bit: Receiver select bit. 101*25cbac77SMasahiro Yamada * @drv_reg: Drive fields register offset. 102*25cbac77SMasahiro Yamada * This register contains hsm, schmitt, lpmd, drvdn, 103*25cbac77SMasahiro Yamada * drvup, slwr, slwf, and drvtype parameters. 104*25cbac77SMasahiro Yamada * @drv_bank: Drive fields register bank. 105*25cbac77SMasahiro Yamada * @hsm_bit: High Speed Mode register bit. 106*25cbac77SMasahiro Yamada * @schmitt_bit: Scmitt register bit. 107*25cbac77SMasahiro Yamada * @lpmd_bit: Low Power Mode register bit. 108*25cbac77SMasahiro Yamada * @drvdn_bit: Drive Down register bit. 109*25cbac77SMasahiro Yamada * @drvdn_width: Drive Down field width. 110*25cbac77SMasahiro Yamada * @drvup_bit: Drive Up register bit. 111*25cbac77SMasahiro Yamada * @drvup_width: Drive Up field width. 112*25cbac77SMasahiro Yamada * @slwr_bit: Slew Rising register bit. 113*25cbac77SMasahiro Yamada * @slwr_width: Slew Rising field width. 114*25cbac77SMasahiro Yamada * @slwf_bit: Slew Falling register bit. 115*25cbac77SMasahiro Yamada * @slwf_width: Slew Falling field width. 116*25cbac77SMasahiro Yamada * @drvtype_bit: Drive type register bit. 117*25cbac77SMasahiro Yamada * 118*25cbac77SMasahiro Yamada * -1 in a *_reg field means that feature is unsupported for this group. 119*25cbac77SMasahiro Yamada * *_bank and *_reg values are irrelevant when *_reg is -1. 120*25cbac77SMasahiro Yamada * When *_reg is valid, *_bit may be -1 to indicate an unsupported feature. 121*25cbac77SMasahiro Yamada * 122*25cbac77SMasahiro Yamada * A representation of a group of pins (possibly just one pin) in the Tegra 123*25cbac77SMasahiro Yamada * pin controller. Each group allows some parameter or parameters to be 124*25cbac77SMasahiro Yamada * configured. The most common is mux function selection. Many others exist 125*25cbac77SMasahiro Yamada * such as pull-up/down, tri-state, etc. Tegra's pin controller is complex; 126*25cbac77SMasahiro Yamada * certain groups may only support configuring certain parameters, hence 127*25cbac77SMasahiro Yamada * each parameter is optional. 128*25cbac77SMasahiro Yamada */ 129*25cbac77SMasahiro Yamada struct tegra_pingroup { 130*25cbac77SMasahiro Yamada const char *name; 131*25cbac77SMasahiro Yamada const unsigned *pins; 132*25cbac77SMasahiro Yamada u8 npins; 133*25cbac77SMasahiro Yamada u8 funcs[4]; 134*25cbac77SMasahiro Yamada s16 mux_reg; 135*25cbac77SMasahiro Yamada s16 pupd_reg; 136*25cbac77SMasahiro Yamada s16 tri_reg; 137*25cbac77SMasahiro Yamada s16 drv_reg; 138*25cbac77SMasahiro Yamada u32 mux_bank:2; 139*25cbac77SMasahiro Yamada u32 pupd_bank:2; 140*25cbac77SMasahiro Yamada u32 tri_bank:2; 141*25cbac77SMasahiro Yamada u32 drv_bank:2; 142*25cbac77SMasahiro Yamada s32 mux_bit:6; 143*25cbac77SMasahiro Yamada s32 pupd_bit:6; 144*25cbac77SMasahiro Yamada s32 tri_bit:6; 145*25cbac77SMasahiro Yamada s32 einput_bit:6; 146*25cbac77SMasahiro Yamada s32 odrain_bit:6; 147*25cbac77SMasahiro Yamada s32 lock_bit:6; 148*25cbac77SMasahiro Yamada s32 ioreset_bit:6; 149*25cbac77SMasahiro Yamada s32 rcv_sel_bit:6; 150*25cbac77SMasahiro Yamada s32 hsm_bit:6; 151*25cbac77SMasahiro Yamada s32 schmitt_bit:6; 152*25cbac77SMasahiro Yamada s32 lpmd_bit:6; 153*25cbac77SMasahiro Yamada s32 drvdn_bit:6; 154*25cbac77SMasahiro Yamada s32 drvup_bit:6; 155*25cbac77SMasahiro Yamada s32 slwr_bit:6; 156*25cbac77SMasahiro Yamada s32 slwf_bit:6; 157*25cbac77SMasahiro Yamada s32 drvtype_bit:6; 158*25cbac77SMasahiro Yamada s32 drvdn_width:6; 159*25cbac77SMasahiro Yamada s32 drvup_width:6; 160*25cbac77SMasahiro Yamada s32 slwr_width:6; 161*25cbac77SMasahiro Yamada s32 slwf_width:6; 162*25cbac77SMasahiro Yamada }; 163*25cbac77SMasahiro Yamada 164*25cbac77SMasahiro Yamada /** 165*25cbac77SMasahiro Yamada * struct tegra_pinctrl_soc_data - Tegra pin controller driver configuration 166*25cbac77SMasahiro Yamada * @ngpios: The number of GPIO pins the pin controller HW affects. 167*25cbac77SMasahiro Yamada * @pins: An array describing all pins the pin controller affects. 168*25cbac77SMasahiro Yamada * All pins which are also GPIOs must be listed first within the 169*25cbac77SMasahiro Yamada * array, and be numbered identically to the GPIO controller's 170*25cbac77SMasahiro Yamada * numbering. 171*25cbac77SMasahiro Yamada * @npins: The numbmer of entries in @pins. 172*25cbac77SMasahiro Yamada * @functions: An array describing all mux functions the SoC supports. 173*25cbac77SMasahiro Yamada * @nfunctions: The numbmer of entries in @functions. 174*25cbac77SMasahiro Yamada * @groups: An array describing all pin groups the pin SoC supports. 175*25cbac77SMasahiro Yamada * @ngroups: The numbmer of entries in @groups. 176*25cbac77SMasahiro Yamada */ 177*25cbac77SMasahiro Yamada struct tegra_pinctrl_soc_data { 178*25cbac77SMasahiro Yamada unsigned ngpios; 179*25cbac77SMasahiro Yamada const struct pinctrl_pin_desc *pins; 180*25cbac77SMasahiro Yamada unsigned npins; 181*25cbac77SMasahiro Yamada struct tegra_function *functions; 182*25cbac77SMasahiro Yamada unsigned nfunctions; 183*25cbac77SMasahiro Yamada const struct tegra_pingroup *groups; 184*25cbac77SMasahiro Yamada unsigned ngroups; 185*25cbac77SMasahiro Yamada bool hsm_in_mux; 186*25cbac77SMasahiro Yamada bool schmitt_in_mux; 187*25cbac77SMasahiro Yamada bool drvtype_in_mux; 188*25cbac77SMasahiro Yamada }; 189*25cbac77SMasahiro Yamada 190*25cbac77SMasahiro Yamada int tegra_pinctrl_probe(struct platform_device *pdev, 191*25cbac77SMasahiro Yamada const struct tegra_pinctrl_soc_data *soc_data); 192*25cbac77SMasahiro Yamada int tegra_pinctrl_remove(struct platform_device *pdev); 193*25cbac77SMasahiro Yamada 194*25cbac77SMasahiro Yamada #endif 195