Skip to content

Commit 368b62f

Browse files
thierryredinglinusw
authored andcommitted
pinctrl: tegra: Add SFIO/GPIO programming on Tegra194
Prior to Tegra186, the selection of SFIO vs. GPIO modes was done as part of the GPIO controller's register programming. Starting with Tegra186, a pin is configured as GPIO or SFIO with a bit in a configuration register of the pin controller. Signed-off-by: Thierry Reding <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: Vidya Sagar <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 103afc8 commit 368b62f

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

drivers/pinctrl/tegra/pinctrl-tegra.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,57 @@ static int tegra_pinctrl_set_mux(struct pinctrl_dev *pctldev,
275275
return 0;
276276
}
277277

278+
static int tegra_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev,
279+
struct pinctrl_gpio_range *range,
280+
unsigned int offset)
281+
{
282+
struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
283+
const struct tegra_pingroup *group;
284+
u32 value;
285+
286+
if (!pmx->soc->sfsel_in_mux)
287+
return 0;
288+
289+
group = &pmx->soc->groups[offset];
290+
291+
if (group->mux_reg < 0 || group->sfsel_bit < 0)
292+
return -EINVAL;
293+
294+
value = pmx_readl(pmx, group->mux_bank, group->mux_reg);
295+
value &= ~BIT(group->sfsel_bit);
296+
pmx_writel(pmx, value, group->mux_bank, group->mux_reg);
297+
298+
return 0;
299+
}
300+
301+
static void tegra_pinctrl_gpio_disable_free(struct pinctrl_dev *pctldev,
302+
struct pinctrl_gpio_range *range,
303+
unsigned int offset)
304+
{
305+
struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
306+
const struct tegra_pingroup *group;
307+
u32 value;
308+
309+
if (!pmx->soc->sfsel_in_mux)
310+
return;
311+
312+
group = &pmx->soc->groups[offset];
313+
314+
if (group->mux_reg < 0 || group->sfsel_bit < 0)
315+
return;
316+
317+
value = pmx_readl(pmx, group->mux_bank, group->mux_reg);
318+
value |= BIT(group->sfsel_bit);
319+
pmx_writel(pmx, value, group->mux_bank, group->mux_reg);
320+
}
321+
278322
static const struct pinmux_ops tegra_pinmux_ops = {
279323
.get_functions_count = tegra_pinctrl_get_funcs_count,
280324
.get_function_name = tegra_pinctrl_get_func_name,
281325
.get_function_groups = tegra_pinctrl_get_func_groups,
282326
.set_mux = tegra_pinctrl_set_mux,
327+
.gpio_request_enable = tegra_pinctrl_gpio_request_enable,
328+
.gpio_disable_free = tegra_pinctrl_gpio_disable_free,
283329
};
284330

285331
static int tegra_pinconf_reg(struct tegra_pmx *pmx,

drivers/pinctrl/tegra/pinctrl-tegra.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ struct tegra_function {
107107
* drvup, slwr, slwf, and drvtype parameters.
108108
* @drv_bank: Drive fields register bank.
109109
* @hsm_bit: High Speed Mode register bit.
110+
* @sfsel_bit: GPIO/SFIO selection register bit.
110111
* @schmitt_bit: Schmitt register bit.
111112
* @lpmd_bit: Low Power Mode register bit.
112113
* @drvdn_bit: Drive Down register bit.
@@ -153,6 +154,7 @@ struct tegra_pingroup {
153154
s32 ioreset_bit:6;
154155
s32 rcv_sel_bit:6;
155156
s32 hsm_bit:6;
157+
s32 sfsel_bit:6;
156158
s32 schmitt_bit:6;
157159
s32 lpmd_bit:6;
158160
s32 drvdn_bit:6;
@@ -192,6 +194,7 @@ struct tegra_pinctrl_soc_data {
192194
bool hsm_in_mux;
193195
bool schmitt_in_mux;
194196
bool drvtype_in_mux;
197+
bool sfsel_in_mux;
195198
};
196199

197200
extern const struct dev_pm_ops tegra_pinctrl_pm;

drivers/pinctrl/tegra/pinctrl-tegra194.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ static struct tegra_function tegra194_functions[] = {
9595
.tri_bit = 4, \
9696
.einput_bit = e_input, \
9797
.odrain_bit = e_od, \
98+
.sfsel_bit = 10, \
9899
.schmitt_bit = schmitt_b, \
99100
.drvtype_bit = 13, \
100101
.drv_reg = -1, \
@@ -140,6 +141,7 @@ static const struct tegra_pinctrl_soc_data tegra194_pinctrl = {
140141
.hsm_in_mux = true,
141142
.schmitt_in_mux = true,
142143
.drvtype_in_mux = true,
144+
.sfsel_in_mux = true,
143145
};
144146

145147
static int tegra194_pinctrl_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)