diff options
Diffstat (limited to 'drivers/pinctrl/pinconf-generic.c')
-rw-r--r-- | drivers/pinctrl/pinconf-generic.c | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c index 29ff77f90fcb..f78b416d7984 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c | |||
@@ -32,30 +32,32 @@ struct pin_config_item { | |||
32 | const enum pin_config_param param; | 32 | const enum pin_config_param param; |
33 | const char * const display; | 33 | const char * const display; |
34 | const char * const format; | 34 | const char * const format; |
35 | bool has_arg; | ||
35 | }; | 36 | }; |
36 | 37 | ||
37 | #define PCONFDUMP(a, b, c) { .param = a, .display = b, .format = c } | 38 | #define PCONFDUMP(a, b, c, d) { .param = a, .display = b, .format = c, \ |
39 | .has_arg = d } | ||
38 | 40 | ||
39 | static struct pin_config_item conf_items[] = { | 41 | static const struct pin_config_item conf_items[] = { |
40 | PCONFDUMP(PIN_CONFIG_BIAS_DISABLE, "input bias disabled", NULL), | 42 | PCONFDUMP(PIN_CONFIG_BIAS_DISABLE, "input bias disabled", NULL, false), |
41 | PCONFDUMP(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, "input bias high impedance", NULL), | 43 | PCONFDUMP(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, "input bias high impedance", NULL, false), |
42 | PCONFDUMP(PIN_CONFIG_BIAS_BUS_HOLD, "input bias bus hold", NULL), | 44 | PCONFDUMP(PIN_CONFIG_BIAS_BUS_HOLD, "input bias bus hold", NULL, false), |
43 | PCONFDUMP(PIN_CONFIG_BIAS_PULL_UP, "input bias pull up", NULL), | 45 | PCONFDUMP(PIN_CONFIG_BIAS_PULL_UP, "input bias pull up", NULL, false), |
44 | PCONFDUMP(PIN_CONFIG_BIAS_PULL_DOWN, "input bias pull down", NULL), | 46 | PCONFDUMP(PIN_CONFIG_BIAS_PULL_DOWN, "input bias pull down", NULL, false), |
45 | PCONFDUMP(PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, | 47 | PCONFDUMP(PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, |
46 | "input bias pull to pin specific state", NULL), | 48 | "input bias pull to pin specific state", NULL, false), |
47 | PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL), | 49 | PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL, false), |
48 | PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_DRAIN, "output drive open drain", NULL), | 50 | PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_DRAIN, "output drive open drain", NULL, false), |
49 | PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_SOURCE, "output drive open source", NULL), | 51 | PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_SOURCE, "output drive open source", NULL, false), |
50 | PCONFDUMP(PIN_CONFIG_DRIVE_STRENGTH, "output drive strength", "mA"), | 52 | PCONFDUMP(PIN_CONFIG_DRIVE_STRENGTH, "output drive strength", "mA", true), |
51 | PCONFDUMP(PIN_CONFIG_INPUT_ENABLE, "input enabled", NULL), | 53 | PCONFDUMP(PIN_CONFIG_INPUT_ENABLE, "input enabled", NULL, false), |
52 | PCONFDUMP(PIN_CONFIG_INPUT_SCHMITT_ENABLE, "input schmitt enabled", NULL), | 54 | PCONFDUMP(PIN_CONFIG_INPUT_SCHMITT_ENABLE, "input schmitt enabled", NULL, false), |
53 | PCONFDUMP(PIN_CONFIG_INPUT_SCHMITT, "input schmitt trigger", NULL), | 55 | PCONFDUMP(PIN_CONFIG_INPUT_SCHMITT, "input schmitt trigger", NULL, false), |
54 | PCONFDUMP(PIN_CONFIG_INPUT_DEBOUNCE, "input debounce", "usec"), | 56 | PCONFDUMP(PIN_CONFIG_INPUT_DEBOUNCE, "input debounce", "usec", true), |
55 | PCONFDUMP(PIN_CONFIG_POWER_SOURCE, "pin power source", "selector"), | 57 | PCONFDUMP(PIN_CONFIG_POWER_SOURCE, "pin power source", "selector", true), |
56 | PCONFDUMP(PIN_CONFIG_SLEW_RATE, "slew rate", NULL), | 58 | PCONFDUMP(PIN_CONFIG_SLEW_RATE, "slew rate", NULL, true), |
57 | PCONFDUMP(PIN_CONFIG_LOW_POWER_MODE, "pin low power", "mode"), | 59 | PCONFDUMP(PIN_CONFIG_LOW_POWER_MODE, "pin low power", "mode", true), |
58 | PCONFDUMP(PIN_CONFIG_OUTPUT, "pin output", "level"), | 60 | PCONFDUMP(PIN_CONFIG_OUTPUT, "pin output", "level", true), |
59 | }; | 61 | }; |
60 | 62 | ||
61 | void pinconf_generic_dump_pin(struct pinctrl_dev *pctldev, | 63 | void pinconf_generic_dump_pin(struct pinctrl_dev *pctldev, |
@@ -85,11 +87,14 @@ void pinconf_generic_dump_pin(struct pinctrl_dev *pctldev, | |||
85 | seq_puts(s, " "); | 87 | seq_puts(s, " "); |
86 | seq_puts(s, conf_items[i].display); | 88 | seq_puts(s, conf_items[i].display); |
87 | /* Print unit if available */ | 89 | /* Print unit if available */ |
88 | if (conf_items[i].format && | 90 | if (conf_items[i].has_arg) { |
89 | pinconf_to_config_argument(config) != 0) | 91 | seq_printf(s, " (%u", |
90 | seq_printf(s, " (%u %s)", | 92 | pinconf_to_config_argument(config)); |
91 | pinconf_to_config_argument(config), | 93 | if (conf_items[i].format) |
92 | conf_items[i].format); | 94 | seq_printf(s, " %s)", conf_items[i].format); |
95 | else | ||
96 | seq_puts(s, ")"); | ||
97 | } | ||
93 | } | 98 | } |
94 | } | 99 | } |
95 | 100 | ||
@@ -121,10 +126,14 @@ void pinconf_generic_dump_group(struct pinctrl_dev *pctldev, | |||
121 | seq_puts(s, " "); | 126 | seq_puts(s, " "); |
122 | seq_puts(s, conf_items[i].display); | 127 | seq_puts(s, conf_items[i].display); |
123 | /* Print unit if available */ | 128 | /* Print unit if available */ |
124 | if (conf_items[i].format && config != 0) | 129 | if (conf_items[i].has_arg) { |
125 | seq_printf(s, " (%u %s)", | 130 | seq_printf(s, " (%u", |
126 | pinconf_to_config_argument(config), | 131 | pinconf_to_config_argument(config)); |
127 | conf_items[i].format); | 132 | if (conf_items[i].format) |
133 | seq_printf(s, " %s)", conf_items[i].format); | ||
134 | else | ||
135 | seq_puts(s, ")"); | ||
136 | } | ||
128 | } | 137 | } |
129 | } | 138 | } |
130 | 139 | ||
@@ -150,7 +159,7 @@ struct pinconf_generic_dt_params { | |||
150 | u32 default_value; | 159 | u32 default_value; |
151 | }; | 160 | }; |
152 | 161 | ||
153 | static struct pinconf_generic_dt_params dt_params[] = { | 162 | static const struct pinconf_generic_dt_params dt_params[] = { |
154 | { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 }, | 163 | { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 }, |
155 | { "bias-high-impedance", PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0 }, | 164 | { "bias-high-impedance", PIN_CONFIG_BIAS_HIGH_IMPEDANCE, 0 }, |
156 | { "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD, 0 }, | 165 | { "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD, 0 }, |
@@ -200,7 +209,7 @@ int pinconf_generic_parse_dt_config(struct device_node *np, | |||
200 | return -ENOMEM; | 209 | return -ENOMEM; |
201 | 210 | ||
202 | for (i = 0; i < ARRAY_SIZE(dt_params); i++) { | 211 | for (i = 0; i < ARRAY_SIZE(dt_params); i++) { |
203 | struct pinconf_generic_dt_params *par = &dt_params[i]; | 212 | const struct pinconf_generic_dt_params *par = &dt_params[i]; |
204 | ret = of_property_read_u32(np, par->property, &val); | 213 | ret = of_property_read_u32(np, par->property, &val); |
205 | 214 | ||
206 | /* property not found */ | 215 | /* property not found */ |