aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@baylibre.com>2019-06-04 11:04:54 +0200
committerNeil Armstrong <narmstrong@baylibre.com>2019-06-12 11:50:02 +0200
commitb9308f2c05906b41dabb1941a384a70dbabdc40f (patch)
treeb18dc752f47a116764bece4137364588fabbde67 /drivers
parent239228947703c670c92e7204dcd875b87f45b716 (diff)
downloadu-boot-b9308f2c05906b41dabb1941a384a70dbabdc40f.zip
u-boot-b9308f2c05906b41dabb1941a384a70dbabdc40f.tar.gz
u-boot-b9308f2c05906b41dabb1941a384a70dbabdc40f.tar.bz2
pinctrl: meson-axg: add support for getting pinmux status
In order to support the "pinmux status" command, use the common functions to get the pins count and names, and add the AXG specific function to get the current function from registers. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c b/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c
index f23b188..10b070e 100644
--- a/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c
+++ b/drivers/pinctrl/meson/pinctrl-meson-axg-pmx.c
@@ -93,6 +93,51 @@ static int meson_axg_pinmux_group_set(struct udevice *dev,
return 0;
}
+static int meson_axg_pinmux_get(struct udevice *dev, unsigned int selector,
+ char *buf, int size)
+{
+ struct meson_pinctrl *priv = dev_get_priv(dev);
+ struct meson_pmx_axg_data *pmx_data;
+ struct meson_pmx_group *group;
+ struct meson_pmx_bank *bank;
+ unsigned int offset;
+ unsigned int func;
+ unsigned int reg;
+ int ret, i, j;
+
+ selector += priv->data->pin_base;
+
+ ret = meson_axg_pmx_get_bank(dev, selector, &bank);
+ if (ret) {
+ snprintf(buf, size, "Unhandled");
+ return 0;
+ }
+
+ meson_axg_pmx_calc_reg_and_offset(bank, selector, &reg, &offset);
+
+ func = (readl(priv->reg_mux + (reg << 2)) >> offset) & 0xf;
+
+ for (i = 0; i < priv->data->num_groups; i++) {
+ group = &priv->data->groups[i];
+ pmx_data = (struct meson_pmx_axg_data *)group->data;
+
+ if (pmx_data->func != func)
+ continue;
+
+ for (j = 0; j < group->num_pins; j++) {
+ if (group->pins[j] == selector) {
+ snprintf(buf, size, "%s (%x)",
+ group->name, func);
+ return 0;
+ }
+ }
+ }
+
+ snprintf(buf, size, "Unknown (%x)", func);
+
+ return 0;
+}
+
const struct pinconf_param meson_axg_pinconf_params[] = {
{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
{ "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
@@ -110,6 +155,9 @@ const struct pinctrl_ops meson_axg_pinctrl_ops = {
.pinconf_num_params = ARRAY_SIZE(meson_axg_pinconf_params),
.pinconf_set = meson_pinconf_set,
.pinconf_group_set = meson_pinconf_group_set,
+ .get_pin_name = meson_pinctrl_get_pin_name,
+ .get_pins_count = meson_pinctrl_get_pins_count,
+ .get_pin_muxing = meson_axg_pinmux_get,
};
static int meson_axg_gpio_request(struct udevice *dev,