Skip to content

Commit b5badba

Browse files
author
Stephen Warren
committed
pinctrl: tegra: debugfs enhancements
* Only provide debugfs-relates ops when CONFIG_DEBUG_FS is enabled. * Implement pin_config_group_dbg_show op. * Implement pin_config_config_dbg_show op. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 52f48fe commit b5badba

1 file changed

Lines changed: 69 additions & 6 deletions

File tree

‎drivers/pinctrl/pinctrl-tegra.c‎

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ static int tegra_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
8383
return 0;
8484
}
8585

86+
#ifdef CONFIG_DEBUG_FS
8687
static void tegra_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev,
8788
struct seq_file *s,
8889
unsigned offset)
8990
{
9091
seq_printf(s, " %s", dev_name(pctldev->dev));
9192
}
93+
#endif
9294

9395
static int reserve_map(struct pinctrl_map **map, unsigned *reserved_maps,
9496
unsigned *num_maps, unsigned reserve)
@@ -295,7 +297,9 @@ static struct pinctrl_ops tegra_pinctrl_ops = {
295297
.get_groups_count = tegra_pinctrl_get_groups_count,
296298
.get_group_name = tegra_pinctrl_get_group_name,
297299
.get_group_pins = tegra_pinctrl_get_group_pins,
300+
#ifdef CONFIG_DEBUG_FS
298301
.pin_dbg_show = tegra_pinctrl_pin_dbg_show,
302+
#endif
299303
.dt_node_to_map = tegra_pinctrl_dt_node_to_map,
300304
.dt_free_map = tegra_pinctrl_dt_free_map,
301305
};
@@ -385,6 +389,7 @@ static struct pinmux_ops tegra_pinmux_ops = {
385389
static int tegra_pinconf_reg(struct tegra_pmx *pmx,
386390
const struct tegra_pingroup *g,
387391
enum tegra_pinconf_param param,
392+
bool report_err,
388393
s8 *bank, s16 *reg, s8 *bit, s8 *width)
389394
{
390395
switch (param) {
@@ -472,9 +477,10 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx,
472477
}
473478

474479
if (*reg < 0) {
475-
dev_err(pmx->dev,
476-
"Config param %04x not supported on group %s\n",
477-
param, g->name);
480+
if (report_err)
481+
dev_err(pmx->dev,
482+
"Config param %04x not supported on group %s\n",
483+
param, g->name);
478484
return -ENOTSUPP;
479485
}
480486

@@ -507,7 +513,8 @@ static int tegra_pinconf_group_get(struct pinctrl_dev *pctldev,
507513

508514
g = &pmx->soc->groups[group];
509515

510-
ret = tegra_pinconf_reg(pmx, g, param, &bank, &reg, &bit, &width);
516+
ret = tegra_pinconf_reg(pmx, g, param, true, &bank, &reg, &bit,
517+
&width);
511518
if (ret < 0)
512519
return ret;
513520

@@ -534,7 +541,8 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev,
534541

535542
g = &pmx->soc->groups[group];
536543

537-
ret = tegra_pinconf_reg(pmx, g, param, &bank, &reg, &bit, &width);
544+
ret = tegra_pinconf_reg(pmx, g, param, true, &bank, &reg, &bit,
545+
&width);
538546
if (ret < 0)
539547
return ret;
540548

@@ -563,23 +571,78 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev,
563571
return 0;
564572
}
565573

574+
#ifdef CONFIG_DEBUG_FS
566575
static void tegra_pinconf_dbg_show(struct pinctrl_dev *pctldev,
567576
struct seq_file *s, unsigned offset)
568577
{
569578
}
570579

580+
static const char *strip_prefix(const char *s)
581+
{
582+
const char *comma = strchr(s, ',');
583+
if (!comma)
584+
return s;
585+
586+
return comma + 1;
587+
}
588+
571589
static void tegra_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,
572-
struct seq_file *s, unsigned selector)
590+
struct seq_file *s, unsigned group)
591+
{
592+
struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
593+
const struct tegra_pingroup *g;
594+
int i, ret;
595+
s8 bank, bit, width;
596+
s16 reg;
597+
u32 val;
598+
599+
g = &pmx->soc->groups[group];
600+
601+
for (i = 0; i < ARRAY_SIZE(cfg_params); i++) {
602+
ret = tegra_pinconf_reg(pmx, g, cfg_params[i].param, false,
603+
&bank, &reg, &bit, &width);
604+
if (ret < 0)
605+
continue;
606+
607+
val = pmx_readl(pmx, bank, reg);
608+
val >>= bit;
609+
val &= (1 << width) - 1;
610+
611+
seq_printf(s, "\n\t%s=%u",
612+
strip_prefix(cfg_params[i].property), val);
613+
}
614+
}
615+
616+
static void tegra_pinconf_config_dbg_show(struct pinctrl_dev *pctldev,
617+
struct seq_file *s,
618+
unsigned long config)
573619
{
620+
enum tegra_pinconf_param param = TEGRA_PINCONF_UNPACK_PARAM(config);
621+
u16 arg = TEGRA_PINCONF_UNPACK_ARG(config);
622+
const char *pname = "unknown";
623+
int i;
624+
625+
for (i = 0; i < ARRAY_SIZE(cfg_params); i++) {
626+
if (cfg_params[i].param == param) {
627+
pname = cfg_params[i].property;
628+
break;
629+
}
630+
}
631+
632+
seq_printf(s, "%s=%d", strip_prefix(pname), arg);
574633
}
634+
#endif
575635

576636
struct pinconf_ops tegra_pinconf_ops = {
577637
.pin_config_get = tegra_pinconf_get,
578638
.pin_config_set = tegra_pinconf_set,
579639
.pin_config_group_get = tegra_pinconf_group_get,
580640
.pin_config_group_set = tegra_pinconf_group_set,
641+
#ifdef CONFIG_DEBUG_FS
581642
.pin_config_dbg_show = tegra_pinconf_dbg_show,
582643
.pin_config_group_dbg_show = tegra_pinconf_group_dbg_show,
644+
.pin_config_config_dbg_show = tegra_pinconf_config_dbg_show,
645+
#endif
583646
};
584647

585648
static struct pinctrl_gpio_range tegra_pinctrl_gpio_range = {

0 commit comments

Comments
 (0)