Skip to contentSkip to conversation

Add generic pinctrl helpers for managing groups and function

PATCH In review Tony Lindgren 4 participants 25 messages Dec 27, 2016 – Jan 11, 2017

Subsystems (3)
lore
Share & tools
lore

Tony Lindgren

author maintainer
#0 lore raw

v2 cover Add generic pinctrl helpers for managing groups and function

Hi all,

Here are some changes to add generic helpers for managing pinctrl groups and functions.

Regards,

Tony

Changes since v1:

- Updates to the first patch in the series to use delayed work for pinctrl hogs based on what was discussed on the mailing list, mostly to pass pctldev to the parsers and add pinctrl_dt_has_hogs() check

Tony Lindgren (5):
pinctrl: core: Use delayed work for hogs
pinctrl: core: Add generic pinctrl functions for managing groups
pinctrl: core: Add generic pinctrl functions for managing groups
pinctrl: single: Use generic pinctrl helpers for managing groups
pinctrl: single: Use generic pinmux helpers for managing functions

 drivers/pinctrl/Kconfig          |  11 +-
 drivers/pinctrl/core.c           | 270 +++++++++++++++++++++++++++++++-----
 drivers/pinctrl/core.h           |  67 +++++++++
 drivers/pinctrl/devicetree.c     |  28 +++-
 drivers/pinctrl/devicetree.h     |  12 +-
 drivers/pinctrl/pinctrl-single.c | 290 ++++-----------------------------------
 drivers/pinctrl/pinmux.c         | 173 +++++++++++++++++++++++
 drivers/pinctrl/pinmux.h         |  42 ++++++
 8 files changed, 591 insertions(+), 302 deletions(-)
Signature · 5 lines
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#1 lore raw

PATCH v2 1/5 pinctrl: core: Use delayed work for hogs

Having the pin control framework call pin controller functions before it's probe has finished is not nice as the pin controller device driver does not yet have struct pinctrl_dev handle.

Let's fix this issue by adding deferred work for late init. This is needed to be able to add pinctrl generic helper functions that expect to know struct pinctrl_dev handle. Note that we now need to call create_pinctrl() directly as we don't want to add the pin controller to the list of controllers until the hogs are claimed. We also need to pass the pinctrl_dev to the device tree parser functions as they otherwise won't find the right controller at this point.

---
 drivers/pinctrl/core.c       | 90 ++++++++++++++++++++++++++++----------------
 drivers/pinctrl/core.h       |  2 +
 drivers/pinctrl/devicetree.c | 28 +++++++++++---
 drivers/pinctrl/devicetree.h | 12 +++++-
 4 files changed, 93 insertions(+), 39 deletions(-)
drivers/pinctrl/core.c +58 -32
@@ -720,7 +720,8 @@ static struct pinctrl_state *create_state(struct pinctrl *p,
 	return state;
 }
 
-static int add_setting(struct pinctrl *p, struct pinctrl_map const *map)
+static int add_setting(struct pinctrl *p, struct pinctrl_dev *pctldev,
+		       struct pinctrl_map const *map)
 {
 	struct pinctrl_state *state;
 	struct pinctrl_setting *setting;
@@ -744,7 +745,11 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map)
 
 	setting->type = map->type;
 
-	setting->pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name);
+	if (pctldev)
+		setting->pctldev = pctldev;
+	else
+		setting->pctldev =
+			get_pinctrl_dev_from_devname(map->ctrl_dev_name);
 	if (setting->pctldev == NULL) {
 		kfree(setting);
 		/* Do not defer probing of hogs (circular loop) */
@@ -800,7 +805,8 @@ static struct pinctrl *find_pinctrl(struct device *dev)
 
 static void pinctrl_free(struct pinctrl *p, bool inlist);
 
-static struct pinctrl *create_pinctrl(struct device *dev)
+static struct pinctrl *create_pinctrl(struct device *dev,
+				      struct pinctrl_dev *pctldev)
 {
 	struct pinctrl *p;
 	const char *devname;
@@ -823,7 +829,7 @@ static struct pinctrl *create_pinctrl(struct device *dev)
 	INIT_LIST_HEAD(&p->states);
 	INIT_LIST_HEAD(&p->dt_maps);
 
-	ret = pinctrl_dt_to_map(p);
+	ret = pinctrl_dt_to_map(p, pctldev);
 	if (ret < 0) {
 		kfree(p);
 		return ERR_PTR(ret);
@@ -838,7 +844,7 @@ static struct pinctrl *create_pinctrl(struct device *dev)
 		if (strcmp(map->dev_name, devname))
 			continue;
 
-		ret = add_setting(p, map);
+		ret = add_setting(p, pctldev, map);
 		/*
 		 * At this point the adding of a setting may:
 		 *
@@ -899,7 +905,7 @@ struct pinctrl *pinctrl_get(struct device *dev)
 		return p;
 	}
 
-	return create_pinctrl(dev);
+	return create_pinctrl(dev, NULL);
 }
 EXPORT_SYMBOL_GPL(pinctrl_get);
 
@@ -1738,6 +1744,46 @@ static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
 }
 
 /**
+ * pinctrl_late_init() - finish pin controller device registration
+ * @work: work struct
+ */
+static void pinctrl_late_init(struct work_struct *work)
+{
+	struct pinctrl_dev *pctldev;
+
+	pctldev = container_of(work, struct pinctrl_dev, late_init.work);
+
+	pctldev->p = create_pinctrl(pctldev->dev, pctldev);
+	if (!IS_ERR(pctldev->p)) {
+		kref_get(&pctldev->p->users);
+		pctldev->hog_default =
+			pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
+		if (IS_ERR(pctldev->hog_default)) {
+			dev_dbg(pctldev->dev,
+				"failed to lookup the default state\n");
+		} else {
+			if (pinctrl_select_state(pctldev->p,
+						 pctldev->hog_default))
+				dev_err(pctldev->dev,
+					"failed to select default state\n");
+		}
+
+		pctldev->hog_sleep =
+			pinctrl_lookup_state(pctldev->p,
+					     PINCTRL_STATE_SLEEP);
+		if (IS_ERR(pctldev->hog_sleep))
+			dev_dbg(pctldev->dev,
+				"failed to lookup the sleep state\n");
+	}
+
+	mutex_lock(&pinctrldev_list_mutex);
+	list_add_tail(&pctldev->node, &pinctrldev_list);
+	mutex_unlock(&pinctrldev_list_mutex);
+
+	pinctrl_init_device_debugfs(pctldev);
+}
+
+/**
  * pinctrl_register() - register a pin controller device
  * @pctldesc: descriptor for this pin controller
  * @dev: parent device for this pin controller
@@ -1766,6 +1812,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 	pctldev->driver_data = driver_data;
 	INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
 	INIT_LIST_HEAD(&pctldev->gpio_ranges);
+	INIT_DELAYED_WORK(&pctldev->late_init, pinctrl_late_init);
 	pctldev->dev = dev;
 	mutex_init(&pctldev->mutex);
 
@@ -1800,32 +1847,10 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 		goto out_err;
 	}
 
-	mutex_lock(&pinctrldev_list_mutex);
-	list_add_tail(&pctldev->node, &pinctrldev_list);
-	mutex_unlock(&pinctrldev_list_mutex);
-
-	pctldev->p = pinctrl_get(pctldev->dev);
-
-	if (!IS_ERR(pctldev->p)) {
-		pctldev->hog_default =
-			pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
-		if (IS_ERR(pctldev->hog_default)) {
-			dev_dbg(dev, "failed to lookup the default state\n");
-		} else {
-			if (pinctrl_select_state(pctldev->p,
-						pctldev->hog_default))
-				dev_err(dev,
-					"failed to select default state\n");
-		}
-
-		pctldev->hog_sleep =
-			pinctrl_lookup_state(pctldev->p,
-						    PINCTRL_STATE_SLEEP);
-		if (IS_ERR(pctldev->hog_sleep))
-			dev_dbg(dev, "failed to lookup the sleep state\n");
-	}
-
-	pinctrl_init_device_debugfs(pctldev);
+	if (pinctrl_dt_has_hogs(pctldev))
+		schedule_delayed_work(&pctldev->late_init, 0);
+	else
+		pinctrl_late_init(&pctldev->late_init.work);
 
 	return pctldev;
 
@@ -1848,6 +1873,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
 	if (pctldev == NULL)
 		return;
 
+	cancel_delayed_work_sync(&pctldev->late_init);
 	mutex_lock(&pctldev->mutex);
 	pinctrl_remove_device_debugfs(pctldev);
 	mutex_unlock(&pctldev->mutex);
drivers/pinctrl/core.h +2 -0
@@ -33,6 +33,7 @@ struct pinctrl_gpio_range;
  * @p: result of pinctrl_get() for this device
  * @hog_default: default state for pins hogged by this device
  * @hog_sleep: sleep state for pins hogged by this device
+ * @late_init: delayed work for pin controller to finish registration
  * @mutex: mutex taken on each pin controller specific action
  * @device_root: debugfs root for this device
  */
@@ -47,6 +48,7 @@ struct pinctrl_dev {
 	struct pinctrl *p;
 	struct pinctrl_state *hog_default;
 	struct pinctrl_state *hog_sleep;
+	struct delayed_work late_init;
 	struct mutex mutex;
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *device_root;
drivers/pinctrl/devicetree.c +23 -5
@@ -100,11 +100,12 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np)
 	return get_pinctrl_dev_from_of_node(np);
 }
 
-static int dt_to_map_one_config(struct pinctrl *p, const char *statename,
+static int dt_to_map_one_config(struct pinctrl *p,
+				struct pinctrl_dev *pctldev,
+				const char *statename,
 				struct device_node *np_config)
 {
 	struct device_node *np_pctldev;
-	struct pinctrl_dev *pctldev;
 	const struct pinctrl_ops *ops;
 	int ret;
 	struct pinctrl_map *map;
@@ -121,7 +122,8 @@ static int dt_to_map_one_config(struct pinctrl *p, const char *statename,
 			/* OK let's just assume this will appear later then */
 			return -EPROBE_DEFER;
 		}
-		pctldev = get_pinctrl_dev_from_of_node(np_pctldev);
+		if (!pctldev)
+			pctldev = get_pinctrl_dev_from_of_node(np_pctldev);
 		if (pctldev)
 			break;
 		/* Do not defer probing of hogs (circular loop) */
@@ -166,7 +168,22 @@ static int dt_remember_dummy_state(struct pinctrl *p, const char *statename)
 	return dt_remember_or_free_map(p, statename, NULL, map, 1);
 }
 
-int pinctrl_dt_to_map(struct pinctrl *p)
+bool pinctrl_dt_has_hogs(struct pinctrl_dev *pctldev)
+{
+	struct device_node *np;
+	struct property *prop;
+	int size;
+
+	np = pctldev->dev->of_node;
+	if (!np)
+		return false;
+
+	prop = of_find_property(np, "pinctrl-0", &size);
+
+	return prop ? true : false;
+}
+
+int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev)
 {
 	struct device_node *np = p->dev->of_node;
 	int state, ret;
@@ -233,7 +250,8 @@ int pinctrl_dt_to_map(struct pinctrl *p)
 			}
 
 			/* Parse the node */
-			ret = dt_to_map_one_config(p, statename, np_config);
+			ret = dt_to_map_one_config(p, pctldev, statename,
+						   np_config);
 			of_node_put(np_config);
 			if (ret < 0)
 				goto err;
drivers/pinctrl/devicetree.h +10 -2
@@ -20,8 +20,10 @@ struct of_phandle_args;
 
 #ifdef CONFIG_OF
 
+bool pinctrl_dt_has_hogs(struct pinctrl_dev *pctldev);
+
 void pinctrl_dt_free_maps(struct pinctrl *p);
-int pinctrl_dt_to_map(struct pinctrl *p);
+int pinctrl_dt_to_map(struct pinctrl *p, struct pinctrl_dev *pctldev);
 
 int pinctrl_count_index_with_args(const struct device_node *np,
 				  const char *list_name);
@@ -32,7 +34,13 @@ int pinctrl_parse_index_with_args(const struct device_node *np,
 
 #else
 
-static inline int pinctrl_dt_to_map(struct pinctrl *p)
+static inline bool pinctrl_dt_has_hogs(struct pinctrl_dev *pctldev)
+{
+	return false;
+}
+
+static inline int pinctrl_dt_to_map(struct pinctrl *p,
+				    struct pinctrl_dev *pctldev)
 {
 	return 0;
 }
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

Quoted 11 lines · Tony Lindgren

Having the pin control framework call pin controller functions before it's probe has finished is not nice as the pin controller device driver does not yet have struct pinctrl_dev handle. Let's fix this issue by adding deferred work for late init. This is needed to be able to add pinctrl generic helper functions that expect to know struct pinctrl_dev handle. Note that we now need to call create_pinctrl() directly as we don't want to add the pin controller to the list of controllers until the hogs are claimed. We also need to pass the pinctrl_dev to the device tree parser functions as they otherwise won't find the right controller at this point.

Quoted 1 line

Patch applied.

I felt the code path needed some extra comments so I sent those as a separate patch.

Yours,
Linus Walleij

#3 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

In reply to Tony Lindgren

Hi Tony,

Quoted 12 lines · Tony Lindgren

Having the pin control framework call pin controller functions before it's probe has finished is not nice as the pin controller device driver does not yet have struct pinctrl_dev handle.

Let's fix this issue by adding deferred work for late init. This is needed to be able to add pinctrl generic helper functions that expect to know struct pinctrl_dev handle. Note that we now need to call create_pinctrl() directly as we don't want to add the pin controller to the list of controllers until the hogs are claimed. We also need to pass the pinctrl_dev to the device tree parser functions as they otherwise won't find the right controller at this point.

Quoted 1 line

I believe this patch causes a regression on r8a7740/armadillo, where the pin controller is also a GPIO controller, and lcd0 needs a hog (cfr. arch/arm/boot/dts/r8a7740-armadillo800eva.dts):

-GPIO line 176 (lcd0) hogged as output/high
-sh-pfc e6050000.pfc: r8a7740_pfc handling gpio 0 -> 211 +gpiochip_add_data: GPIOs 0..211 (r8a7740_pfc) failed to register +sh-pfc e6050000.pfc: failed to init GPIO chip, ignoring...
sh-pfc e6050000.pfc: r8a7740_pfc support registered

Hence all drivers using GPIOs fail to initialize because their GPIOs never become available.

Adding debug prints to the failure paths shows that the call to of_pinctrl_get() in of_gpiochip_add_pin_range() fails with -EPROBE_DEFER. Adding a debug print to the top of gpiochip_add_data() makes the problem go away, presumably because it introduces a delay that allows the delayed work to kick in...

Jon's fix ("pinctrl: core: Fix panic when pinctrl devices with hogs are unregistered") doesn't help, as it affects unregistration only.

Quoted 24 lines
drivers/pinctrl/core.c +0 -17
@@ -1800,32 +1847,10 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
                goto out_err;
        }
 
-       mutex_lock(&pinctrldev_list_mutex);
-       list_add_tail(&pctldev->node, &pinctrldev_list);
-       mutex_unlock(&pinctrldev_list_mutex);
-
-       pctldev->p = pinctrl_get(pctldev->dev);
-
-       if (!IS_ERR(pctldev->p)) {
-               pctldev->hog_default =
-                       pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
-               if (IS_ERR(pctldev->hog_default)) {
-                       dev_dbg(dev, "failed to lookup the default state\n");
-               } else {
-                       if (pinctrl_select_state(pctldev->p,
-                                               pctldev->hog_default))
-                               dev_err(dev,
-                                       "failed to select default state\n");
-               }

drivers/pinctrl/core.c struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, · line 1850

Quoted 10 lines
drivers/pinctrl/core.c +1 -9
-
-               pctldev->hog_sleep =
-                       pinctrl_lookup_state(pctldev->p,
-                                                   PINCTRL_STATE_SLEEP);
-               if (IS_ERR(pctldev->hog_sleep))
-                       dev_dbg(dev, "failed to lookup the sleep state\n");
-       }
-
-       pinctrl_init_device_debugfs(pctldev);
+       if (pinctrl_dt_has_hogs(pctldev))

Changing the above line to "if (0 && pinctrl_dt_has_hogs(pctldev))" fixes the issue for me.

drivers/pinctrl/core.c struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, · line 1855

Quoted 5 lines
drivers/pinctrl/core.c +3 -0
+               schedule_delayed_work(&pctldev->late_init, 0);
+       else
+               pinctrl_late_init(&pctldev->late_init.work);
 
        return pctldev;

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#4 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

Quoted 27 lines · Geert Uytterhoeven

Hi Tony,

Quoted 12 lines · Tony Lindgren

Having the pin control framework call pin controller functions before it's probe has finished is not nice as the pin controller device driver does not yet have struct pinctrl_dev handle.

Let's fix this issue by adding deferred work for late init. This is needed to be able to add pinctrl generic helper functions that expect to know struct pinctrl_dev handle. Note that we now need to call create_pinctrl() directly as we don't want to add the pin controller to the list of controllers until the hogs are claimed. We also need to pass the pinctrl_dev to the device tree parser functions as they otherwise won't find the right controller at this point.

Quoted 1 line

I believe this patch causes a regression on r8a7740/armadillo, where the pin controller is also a GPIO controller, and lcd0 needs a hog (cfr. arch/arm/boot/dts/r8a7740-armadillo800eva.dts):

(quoted diff) +2 -2
-GPIO line 176 (lcd0) hogged as output/high
-sh-pfc e6050000.pfc: r8a7740_pfc handling gpio 0 -> 211
+gpiochip_add_data: GPIOs 0..211 (r8a7740_pfc) failed to register
+sh-pfc e6050000.pfc: failed to init GPIO chip, ignoring...
 sh-pfc e6050000.pfc: r8a7740_pfc support registered
Quoted 8 lines

Hence all drivers using GPIOs fail to initialize because their GPIOs never become available.

Adding debug prints to the failure paths shows that the call to of_pinctrl_get() in of_gpiochip_add_pin_range() fails with -EPROBE_DEFER. Adding a debug print to the top of gpiochip_add_data() makes the problem go away, presumably because it introduces a delay that allows the delayed work to kick in...

OK. What if we added also an optional pinctrl function that the pin controller driver could call to initialize hogs? Then the pin controller driver could call it during or after probe as needed. That is after there's a valid struct pinctrl_dev handle.

Quoted 32 lines

Jon's fix ("pinctrl: core: Fix panic when pinctrl devices with hogs are unregistered") doesn't help, as it affects unregistration only.

Quoted 29 lines
drivers/pinctrl/core.c +0 -22
@@ -1800,32 +1847,10 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
                goto out_err;
        }
 
-       mutex_lock(&pinctrldev_list_mutex);
-       list_add_tail(&pctldev->node, &pinctrldev_list);
-       mutex_unlock(&pinctrldev_list_mutex);
-
-       pctldev->p = pinctrl_get(pctldev->dev);
-
-       if (!IS_ERR(pctldev->p)) {
-               pctldev->hog_default =
-                       pinctrl_lookup_state(pctldev->p, PINCTRL_STATE_DEFAULT);
-               if (IS_ERR(pctldev->hog_default)) {
-                       dev_dbg(dev, "failed to lookup the default state\n");
-               } else {
-                       if (pinctrl_select_state(pctldev->p,
-                                               pctldev->hog_default))
-                               dev_err(dev,
-                                       "failed to select default state\n");
-               }
-
-               pctldev->hog_sleep =
-                       pinctrl_lookup_state(pctldev->p,
-                                                   PINCTRL_STATE_SLEEP);
-               if (IS_ERR(pctldev->hog_sleep))
Quoted 14 lines

drivers/pinctrl/core.c struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, · line 1850

Quoted 5 lines
drivers/pinctrl/core.c +1 -4
-                       dev_dbg(dev, "failed to lookup the sleep state\n");
-       }
-
-       pinctrl_init_device_debugfs(pctldev);
+       if (pinctrl_dt_has_hogs(pctldev))

Changing the above line to "if (0 && pinctrl_dt_has_hogs(pctldev))" fixes the issue for me.

Quoted 5 lines
drivers/pinctrl/core.c +3 -0
+               schedule_delayed_work(&pctldev->late_init, 0);
+       else
+               pinctrl_late_init(&pctldev->late_init.work);
 
        return pctldev;

We could also pass some flag if should always call pinctrl_late_init() directly. But that does not remove the problem of struct pinctrl_dev handle being uninitialized when the pin controller driver functionas are called.

Regards,

Tony

author maintainer
#5 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

Quoted 41 lines · Tony Lindgren
Quoted 27 lines · Geert Uytterhoeven

Hi Tony,

Quoted 12 lines · Tony Lindgren

Having the pin control framework call pin controller functions before it's probe has finished is not nice as the pin controller device driver does not yet have struct pinctrl_dev handle.

Let's fix this issue by adding deferred work for late init. This is needed to be able to add pinctrl generic helper functions that expect to know struct pinctrl_dev handle. Note that we now need to call create_pinctrl() directly as we don't want to add the pin controller to the list of controllers until the hogs are claimed. We also need to pass the pinctrl_dev to the device tree parser functions as they otherwise won't find the right controller at this point.

Quoted 1 line

I believe this patch causes a regression on r8a7740/armadillo, where the pin controller is also a GPIO controller, and lcd0 needs a hog (cfr. arch/arm/boot/dts/r8a7740-armadillo800eva.dts):

(quoted diff) +2 -2
-GPIO line 176 (lcd0) hogged as output/high
-sh-pfc e6050000.pfc: r8a7740_pfc handling gpio 0 -> 211
+gpiochip_add_data: GPIOs 0..211 (r8a7740_pfc) failed to register
+sh-pfc e6050000.pfc: failed to init GPIO chip, ignoring...
 sh-pfc e6050000.pfc: r8a7740_pfc support registered
Quoted 8 lines

Hence all drivers using GPIOs fail to initialize because their GPIOs never become available.

Adding debug prints to the failure paths shows that the call to of_pinctrl_get() in of_gpiochip_add_pin_range() fails with -EPROBE_DEFER. Adding a debug print to the top of gpiochip_add_data() makes the problem go away, presumably because it introduces a delay that allows the delayed work to kick in...

OK. What if we added also an optional pinctrl function that the pin controller driver could call to initialize hogs? Then the pin controller driver could call it during or after probe as needed. That is after there's a valid struct pinctrl_dev handle.

...

Quoted 3 lines

We could also pass some flag if should always call pinctrl_late_init() directly. But that does not remove the problem of struct pinctrl_dev handle being uninitialized when the pin controller driver functionas are called.

Looks like we need both a flag and a way for the pin controller driver to start things.

Below is an experimental fix to intorduce pinctrl_start() that I've tested with pinctrl-single. Then we should probably make all pin controller drivers call pinctrl_start() to properly fix the issue of struct pinctrl_dev handle not being initialized before driver functions are called.

Or do you guys have any better ideas?

Regards,

Tony

8< --------------------------------

drivers/pinctrl/core.c +18 -2
@@ -1962,6 +1962,17 @@ static void pinctrl_late_init(struct work_struct *work)
 	pinctrl_init_device_debugfs(pctldev);
 }
 
+int pinctrl_start(struct pinctrl_dev *pctldev)
+{
+       if (!IS_ERR(pctldev->p))
+               return -EEXIST;
+
+       pinctrl_late_init(&pctldev->late_init.work);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(pinctrl_start);
+
 /**
  * pinctrl_register() - register a pin controller device
  * @pctldesc: descriptor for this pin controller
@@ -2035,9 +2046,14 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 	/*
 	 * If the device has hogs we want the probe() function of the driver
 	 * to complete before we go in and hog them and add the pin controller
-	 * to the list of controllers. If it has no hogs, we can just complete
-	 * the registration immediately.
+	 * to the list of controllers. If the pin controller driver initializes
+	 * hogs, or the pin controller instance has no hogs, we can just
+	 * complete the registration immediately.
 	 */
+
+	if (pctldesc->flags & PINCTRL_DRIVER_START)
+		return pctldev;
+
 	if (pinctrl_dt_has_hogs(pctldev))
 		schedule_delayed_work(&pctldev->late_init, 0);
 	else
drivers/pinctrl/pinctrl-single.c +5 -0
@@ -1741,6 +1741,7 @@ static int pcs_probe(struct platform_device *pdev)
 	pcs->desc.pmxops = &pcs_pinmux_ops;
 	if (PCS_HAS_PINCONF)
 		pcs->desc.confops = &pcs_pinconf_ops;
+	pcs->desc.flags = PINCTRL_DRIVER_START;
 	pcs->desc.owner = THIS_MODULE;
 
 	ret = pcs_allocate_pin_table(pcs);
@@ -1754,6 +1755,10 @@ static int pcs_probe(struct platform_device *pdev)
 		goto free;
 	}
 
+	ret = pinctrl_start(pcs->pctl);
+	if (ret)
+		goto free;
+
 	ret = pcs_add_gpio_func(np, pcs);
 	if (ret < 0)
 		goto free;
drivers/pinctrl/sh-pfc/pinctrl.c +9 -1
@@ -815,7 +815,15 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
 	pmx->pctl_desc.confops = &sh_pfc_pinconf_ops;
 	pmx->pctl_desc.pins = pmx->pins;
 	pmx->pctl_desc.npins = pfc->info->nr_pins;
+	pmx->pctl_desc.flags = PINCTRL_DRIVER_START;
 
 	pmx->pctl = devm_pinctrl_register(pfc->dev, &pmx->pctl_desc, pmx);
-	return PTR_ERR_OR_ZERO(pmx->pctl);
+	if (IS_ERR(pmx->pctl))
+		return PTR_ERR(pmx->pctl);
+
+	ret = pinctrl_start(pmx->pctl);
+	if (ret)
+		return ret;
+
+	return 0;
 }
include/linux/pinctrl/pinctrl.h +6 -0
@@ -104,6 +104,8 @@ struct pinctrl_ops {
 			     struct pinctrl_map *map, unsigned num_maps);
 };
 
+#define PINCTRL_DRIVER_START		BIT(0)
+
 /**
  * struct pinctrl_desc - pin controller descriptor, register this to pin
  * control subsystem
@@ -112,6 +114,8 @@ struct pinctrl_ops {
  *	this pin controller
  * @npins: number of descriptors in the array, usually just ARRAY_SIZE()
  *	of the pins field above
+ * @flags: Optional pin controller feature flags
+ *	handling is needed in the pin controller driver.
  * @pctlops: pin control operation vtable, to support global concepts like
  *	grouping of pins, this is optional.
  * @pmxops: pinmux operations vtable, if you support pinmuxing in your driver
@@ -129,6 +133,7 @@ struct pinctrl_desc {
 	const char *name;
 	const struct pinctrl_pin_desc *pins;
 	unsigned int npins;
+	unsigned int flags;
 	const struct pinctrl_ops *pctlops;
 	const struct pinmux_ops *pmxops;
 	const struct pinconf_ops *confops;
@@ -149,6 +154,7 @@ extern struct pinctrl_dev *devm_pinctrl_register(struct device *dev,
 				void *driver_data);
 extern void devm_pinctrl_unregister(struct device *dev,
 				struct pinctrl_dev *pctldev);
+extern int pinctrl_start(struct pinctrl_dev *pctldev);
 
 extern bool pin_is_valid(struct pinctrl_dev *pctldev, int pin);
 extern void pinctrl_add_gpio_range(struct pinctrl_dev *pctldev,
Signature · 1 line
2.11.0
#6 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

Quoted 4 lines · Tony Lindgren

Below is an experimental fix to intorduce pinctrl_start() that I've tested with pinctrl-single. Then we should probably make all pin controller drivers call pinctrl_start() to properly fix the issue of struct pinctrl_dev handle not being initialized before driver functions are called.

Hm I guess that could work, but can we keep pinctrl_register() with the old semantics and add a separate pinctrl_register_and_defer()
for those who just wanna start it later by a separate call?

Then we don't need any special flags.

Quoted 1 line

Or do you guys have any better ideas?

Not really. So you mean revert the previous patch and apply something like this instead?

Yours,
Linus Walleij

author maintainer
#7 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

Quoted 7 lines · Linus Walleij
Quoted 4 lines · Tony Lindgren

Below is an experimental fix to intorduce pinctrl_start() that I've tested with pinctrl-single. Then we should probably make all pin controller drivers call pinctrl_start() to properly fix the issue of struct pinctrl_dev handle not being initialized before driver functions are called.

Quoted 5 lines

Hm I guess that could work, but can we keep pinctrl_register() with the old semantics and add a separate pinctrl_register_and_defer()
for those who just wanna start it later by a separate call?

Then we don't need any special flags.

OK I'll take a look.

Quoted 4 lines
Quoted 1 line

Or do you guys have any better ideas?

Not really. So you mean revert the previous patch and apply something like this instead?

Let me first take a look to see if we can fix it by making drivers using GENERIC_PINCTRL_GROUPS or GENERIC_PINMUX_FUNCTIONS register with pinctrl_register_and_defer(). I'll post a patch for that today.

Then maybe for v4.12 we can attempt to move all pin controller drivers to using it so we can fix the problem for good.

Regards,

Tony

author maintainer
#8 lore raw

Re: [PATCH 1/5] pinctrl: core: Use delayed work for hogs

Quoted 16 lines · Tony Lindgren
Quoted 7 lines · Linus Walleij
Quoted 4 lines · Tony Lindgren

Below is an experimental fix to intorduce pinctrl_start() that I've tested with pinctrl-single. Then we should probably make all pin controller drivers call pinctrl_start() to properly fix the issue of struct pinctrl_dev handle not being initialized before driver functions are called.

Quoted 5 lines

Hm I guess that could work, but can we keep pinctrl_register() with the old semantics and add a separate pinctrl_register_and_defer()
for those who just wanna start it later by a separate call?

Then we don't need any special flags.

OK I'll take a look.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Or do you guys have any better ideas?

Not really. So you mean revert the previous patch and apply something like this instead?

Let me first take a look to see if we can fix it by making drivers using GENERIC_PINCTRL_GROUPS or GENERIC_PINMUX_FUNCTIONS register with pinctrl_register_and_defer(). I'll post a patch for that today.

Yeah we can fix this by reverting the late_init parts of the earlier attempt and introducing a new pinctrl_register_and_init() for controllers to use:

extern int pinctrl_register_and_init(struct pinctrl_desc *pctldesc,

				     struct device *dev, void *driver_data,
				     struct pinctrl_dev **pctldev);
Quoted 2 lines

Then maybe for v4.12 we can attempt to move all pin controller drivers to using it so we can fix the problem for good.

And that will also make converting existing drivers to use it later on trivial.

Will post a patch shortly after some more testing.

Regards,

Tony

author maintainer
#9 lore raw

PATCH v2 2/5 pinctrl: core: Add generic pinctrl functions for managing groups

In reply to Tony Lindgren

We can add generic helpers for pin group handling for cases where the pin controller driver does not need to use static arrays.

---
 drivers/pinctrl/Kconfig |   3 +
 drivers/pinctrl/core.c  | 178 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pinctrl/core.h  |  47 +++++++++++++
 3 files changed, 228 insertions(+)
drivers/pinctrl/Kconfig +3 -0
@@ -8,6 +8,9 @@ config PINCTRL
 menu "Pin controllers"
 	depends on PINCTRL
 
+config GENERIC_PINCTRL
+	bool
+
 config PINMUX
 	bool "Support pin multiplexing controllers" if COMPILE_TEST
 
drivers/pinctrl/core.c +178 -0

196 lines not on this page · raw message

drivers/pinctrl/core.h +47 -0

71 lines not on this page · raw message

Signature · 5 lines
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

Re: [PATCH 2/5] pinctrl: core: Add generic pinctrl functions for managing groups

Quoted 4 lines · Tony Lindgren

We can add generic helpers for pin group handling for cases where the pin controller driver does not need to use static arrays.

Patch applied.

drivers/pinctrl/Kconfig config PINCTRL · line 12

Quoted 2 lines
drivers/pinctrl/Kconfig +2 -0
+config GENERIC_PINCTRL
+       bool

Then I renamed *this* to GENERIC_PINCTRL_GROUPS. (Not the other patch, I got confused because gmail threads the second and third patch together, sorry.)

Let's see if I manage to rebase the next patch on this.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#11 lore raw

Re: [PATCH 2/5] pinctrl: core: Add generic pinctrl functions for managing groups

Quoted 7 lines · Linus Walleij
Quoted 4 lines · Tony Lindgren

We can add generic helpers for pin group handling for cases where the pin controller driver does not need to use static arrays.

Quoted 8 lines

Patch applied.

drivers/pinctrl/Kconfig config PINCTRL · line 12

Quoted 2 lines
drivers/pinctrl/Kconfig +2 -0
+config GENERIC_PINCTRL
+       bool

Then I renamed *this* to GENERIC_PINCTRL_GROUPS. (Not the other patch, I got confused because gmail threads the second and third patch together, sorry.)

Yeah OK nice, the renames make sense to me.

Quoted 1 line

Let's see if I manage to rebase the next patch on this.

I'll do some testing with your devel branch today to make sure things still work for me.

Regards,

Tony

author maintainer
#12 lore raw

PATCH v2 3/5 pinctrl: core: Add generic pinctrl functions for managing groups

In reply to Tony Lindgren

We can add generic helpers for function handling for cases where the pin controller driver does not need to use static arrays.

---
 drivers/pinctrl/Kconfig  |   4 ++
 drivers/pinctrl/core.c   |   2 +
 drivers/pinctrl/core.h   |  18 +++++
 drivers/pinctrl/pinmux.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/pinctrl/pinmux.h |  42 ++++++++++++
 5 files changed, 239 insertions(+)
drivers/pinctrl/Kconfig +4 -0
@@ -14,6 +14,10 @@ config GENERIC_PINCTRL
 config PINMUX
 	bool "Support pin multiplexing controllers" if COMPILE_TEST
 
+config GENERIC_PINMUX
+	bool
+	select PINMUX
+
 config PINCONF
 	bool "Support pin configuration controllers" if COMPILE_TEST
 
drivers/pinctrl/core.c +2 -0
@@ -1988,6 +1988,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 	pctldev->driver_data = driver_data;
 	INIT_RADIX_TREE(&pctldev->pin_desc_tree, GFP_KERNEL);
 	INIT_RADIX_TREE(&pctldev->pin_group_tree, GFP_KERNEL);
+	INIT_RADIX_TREE(&pctldev->pin_function_tree, GFP_KERNEL);
 	INIT_LIST_HEAD(&pctldev->gpio_ranges);
 	INIT_DELAYED_WORK(&pctldev->late_init, pinctrl_late_init);
 	pctldev->dev = dev;
@@ -2062,6 +2063,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
 	mutex_lock(&pctldev->mutex);
 	/* TODO: check that no pinmuxes are still active? */
 	list_del(&pctldev->node);
+	pinmux_generic_free_functions(pctldev);
 	pinctrl_generic_free_groups(pctldev);
 	/* Destroy descriptor tree */
 	pinctrl_free_pindescs(pctldev, pctldev->desc->pins,
drivers/pinctrl/core.h +18 -0
@@ -25,7 +25,9 @@ struct pinctrl_gpio_range;
  * @pin_desc_tree: each pin descriptor for this pin controller is stored in
  *	this radix tree
  * @pin_group_tree: optionally each pin group can be stored in this radix tree
+ * @pin_function_tree: optionally each function can be stored in this radix tree
  * @num_groups: optionally number of groups can be kept here
+ * @num_functions: optionally number of functions can be kept here
  * @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
  *	ranges are added to this list at runtime
  * @dev: the device entry for this pin controller
@@ -44,7 +46,9 @@ struct pinctrl_dev {
 	struct pinctrl_desc *desc;
 	struct radix_tree_root pin_desc_tree;
 	struct radix_tree_root pin_group_tree;
+	struct radix_tree_root pin_function_tree;
 	unsigned int num_groups;
+	unsigned int num_functions;
 	struct list_head gpio_ranges;
 	struct device *dev;
 	struct module *owner;
@@ -180,6 +184,20 @@ struct group_desc {
 };
 
 /**
+ * struct function_desc - generic function descriptor
+ * @name: name of the function
+ * @group_names: array of pin group names
+ * @num_group_names: number of pin group names
+ * @data: pin controller driver specific data
+ */
+struct function_desc {
+	const char *name;
+	const char **group_names;
+	int num_group_names;
+	void *data;
+};
+
+/**
  * struct pinctrl_maps - a list item containing part of the mapping table
  * @node: mapping table list node
  * @maps: array of mapping table entries
drivers/pinctrl/pinmux.c +173 -0

176 lines not on this page · raw message

drivers/pinctrl/pinmux.h +42 -0

45 lines not on this page · raw message

Signature · 1 line
2.11.0
#13 lore raw

Re: [PATCH 3/5] pinctrl: core: Add generic pinctrl functions for managing groups

Quoted 4 lines · Tony Lindgren

We can add generic helpers for function handling for cases where the pin controller driver does not need to use static arrays.

Patch applied!

drivers/pinctrl/Kconfig config GENERIC_PINCTRL · line 19

Quoted 3 lines
drivers/pinctrl/Kconfig +3 -0
+config GENERIC_PINMUX
+       bool
+       select PINMUX

I applied the first that had GENERIC_PINCTRL instead,

Then I went in and renamed this GENERIC_PINCTRL_GROUPS since that is what it's all about.

Sent out as separate patch!

Yours,
Linus Walleij

#14 lore raw

Re: [PATCH 3/5] pinctrl: core: Add generic pinctrl functions for managing groups

In reply to Tony Lindgren
Quoted 4 lines · Tony Lindgren

We can add generic helpers for function handling for cases where the pin controller driver does not need to use static arrays.

Patch applied.

drivers/pinctrl/Kconfig config GENERIC_PINCTRL · line 19

Quoted 3 lines
drivers/pinctrl/Kconfig +3 -0
+config GENERIC_PINMUX
+       bool
+       select PINMUX

I renamed this GENERIC_PINMUX_FUNCTIONS

Quoted 1 line

+ INIT_RADIX_TREE(&pctldev->pin_function_tree, GFP_KERNEL);

#ifdefed this

drivers/pinctrl/core.h struct pinctrl_dev { · line 51

Quoted 3 lines
drivers/pinctrl/core.h +2 -0
+       struct radix_tree_root pin_function_tree;
        unsigned int num_groups;
+       unsigned int num_functions;

#ifdefed these

drivers/pinctrl/core.h struct group_desc { · line 198

Quoted 13 lines

/**
+ * struct function_desc - generic function descriptor
+ * @name: name of the function
+ * @group_names: array of pin group names
+ * @num_group_names: number of pin group names
+ * @data: pin controller driver specific data
+ */

drivers/pinctrl/core.h +6 -0
+struct function_desc {
+       const char *name;
+       const char **group_names;
+       int num_group_names;
+       void *data;
+};

And moved this into pinmux.h

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

Re: [3/5] pinctrl: core: Add generic pinctrl functions for managing groups

In reply to Tony Lindgren

Hi Tony,

Quoted 4 lines · Tony Lindgren

We can add generic helpers for function handling for cases where the pin controller driver does not need to use static arrays.

Shouldn't the patch title be:
pinctrl: core: Add generic pinmux functions for managing functions

It looks like a copy/paste issue since both patches have the same title:
824bef17d16c pinctrl: core: Add generic pinctrl functions for managing groups
d70a0fb14682 pinctrl: core: Add generic pinctrl functions for managing groups

That's actually my only remark, I had another comment about freeing the trees but it is actually done in the unregister so everything is good.

Regards,
Gary

author maintainer
#16 lore raw

Re: [3/5] pinctrl: core: Add generic pinctrl functions for managing groups

Quoted 8 lines · Gary Bisson

Hi Tony,

Quoted 4 lines · Tony Lindgren

We can add generic helpers for function handling for cases where the pin controller driver does not need to use static arrays.

Quoted 8 lines

Shouldn't the patch title be:
pinctrl: core: Add generic pinmux functions for managing functions

It looks like a copy/paste issue since both patches have the same title:
824bef17d16c pinctrl: core: Add generic pinctrl functions for managing groups
d70a0fb14682 pinctrl: core: Add generic pinctrl functions for managing groups

Oops, oh well.. At least the description is correct.

Quoted 2 lines

That's actually my only remark, I had another comment about freeing the trees but it is actually done in the unregister so everything is good.

OK cool.

Tony

author maintainer
#17 lore raw

PATCH v2 4/5 pinctrl: single: Use generic pinctrl helpers for managing groups

In reply to Tony Lindgren

We can now drop the driver specific code for managing groups.

---
 drivers/pinctrl/Kconfig          |   2 +-
 drivers/pinctrl/pinctrl-single.c | 156 +++------------------------------------
 2 files changed, 12 insertions(+), 146 deletions(-)
drivers/pinctrl/Kconfig +1 -1
@@ -166,8 +166,8 @@ config PINCTRL_ROCKCHIP
 config PINCTRL_SINGLE
 	tristate "One-register-per-pin type device tree based pinctrl driver"
 	depends on OF
+	select GENERIC_PINCTRL
 	select PINMUX
-	select PINCONF
 	select GENERIC_PINCONF
 	help
 	  This selects the device tree based generic pinctrl driver.
drivers/pinctrl/pinctrl-single.c +11 -145

272 lines not on this page · raw message

Signature · 1 line
2.11.0
#18 lore raw

Re: [PATCH 4/5] pinctrl: single: Use generic pinctrl helpers for managing groups

Quoted 3 lines · Tony Lindgren

We can now drop the driver specific code for managing groups.

Patch applied!

Quoted 1 line

+ select GENERIC_PINCTRL

Replaced this with GENERIC_PINCTRL_GROUPS

Yours,
Linus Walleij

author maintainer
#19 lore raw

PATCH v2 5/5 pinctrl: single: Use generic pinmux helpers for managing functions

In reply to Tony Lindgren

We can now drop the driver specific code for managing functions.

---
 drivers/pinctrl/Kconfig          |   2 +-
 drivers/pinctrl/pinctrl-single.c | 134 ++++++---------------------------------
 2 files changed, 19 insertions(+), 117 deletions(-)
drivers/pinctrl/Kconfig +1 -1
@@ -167,7 +167,7 @@ config PINCTRL_SINGLE
 	tristate "One-register-per-pin type device tree based pinctrl driver"
 	depends on OF
 	select GENERIC_PINCTRL
-	select PINMUX
+	select GENERIC_PINMUX
 	select GENERIC_PINCONF
 	help
 	  This selects the device tree based generic pinctrl driver.
drivers/pinctrl/pinctrl-single.c +18 -116

250 lines not on this page · raw message

Signature · 1 line
2.11.0
#20 lore raw

Re: [PATCH 5/5] pinctrl: single: Use generic pinmux helpers for managing functions

Quoted 3 lines · Tony Lindgren

We can now drop the driver specific code for managing functions.

Patch applied.

drivers/pinctrl/Kconfig config PINCTRL_SINGLE · line 170

Quoted 2 lines
drivers/pinctrl/Kconfig +1 -1
-       select PINMUX
+       select GENERIC_PINMUX

Replaced this with GENERIC_PINMUX_FUNCTIONS

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw
In reply to Tony Lindgren
Quoted 2 lines · Tony Lindgren

Here are some changes to add generic helpers for managing pinctrl groups and functions.

I applied it, screwed around with it and pushed to the build servers to see if it survived.

I really like the look of this and I hope lots of driver start to use it.

Gary, I just applied your radix patches for i.MX, can you look if you can use the GENERIC_PINCTRL_GROUPS and GENERIC_PINMUX_FUCNTIONS that Tony invented and that I just merged to my devel branch in the pinctrl tree?

It seems the i.MX could just reuse this right off and slim down quite a bit but the devil is in the details.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw

Hi Linus,

Quoted 8 lines · Linus Walleij
Quoted 2 lines · Tony Lindgren

Here are some changes to add generic helpers for managing pinctrl groups and functions.

I applied it, screwed around with it and pushed to the build servers to see if it survived.

Quoted 6 lines

I really like the look of this and I hope lots of driver start to use it.

Gary, I just applied your radix patches for i.MX, can you look if you can use the GENERIC_PINCTRL_GROUPS and GENERIC_PINMUX_FUCNTIONS that Tony invented and that I just merged to my devel branch in the pinctrl tree?

Yes I will have a look. It does sound like a good idea. I'll share my findings beginning of next week.

Regards,
Gary

author maintainer
#23 lore raw
Quoted 13 lines · Gary Bisson

Hi Linus,

Quoted 10 lines · Linus Walleij
Quoted 2 lines · Tony Lindgren

Here are some changes to add generic helpers for managing pinctrl groups and functions.

I applied it, screwed around with it and pushed to the build servers to see if it survived.

I really like the look of this and I hope lots of driver start to use it.

Quoted 7 lines
Quoted 4 lines

Gary, I just applied your radix patches for i.MX, can you look if you can use the GENERIC_PINCTRL_GROUPS and GENERIC_PINMUX_FUCNTIONS that Tony invented and that I just merged to my devel branch in the pinctrl tree?

Yes I will have a look. It does sound like a good idea. I'll share my findings beginning of next week.

OK great. Note that we may be able to come up also with a generic iterator function for the node_to_map functions so maybe see if you come up with some ideas for that while experimenting :)

Tony

#24 lore raw

Hi Linus, Tony,

Quoted 14 lines · Tony Lindgren
Quoted 13 lines · Gary Bisson

Hi Linus,

Quoted 10 lines · Linus Walleij
Quoted 2 lines · Tony Lindgren

Here are some changes to add generic helpers for managing pinctrl groups and functions.

I applied it, screwed around with it and pushed to the build servers to see if it survived.

I really like the look of this and I hope lots of driver start to use it.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Gary, I just applied your radix patches for i.MX, can you look if you can use the GENERIC_PINCTRL_GROUPS and GENERIC_PINMUX_FUCNTIONS that Tony invented and that I just merged to my devel branch in the pinctrl tree?

Yes I will have a look. It does sound like a good idea. I'll share my findings beginning of next week.

So I've had a look and indeed I can use some of it. Here is what my series looks like:

 drivers/pinctrl/freescale/Kconfig       |   3 +-
 drivers/pinctrl/freescale/pinctrl-imx.c | 273
+++++++++-----------------------
 drivers/pinctrl/freescale/pinctrl-imx.h |  33 +---
 3 files changed, 80 insertions(+), 229 deletions(-)

Mainly I've used the generic functions in pinctrl_ops and pinmux_ops and switched to the generic group/function_desc structures instead of the imx-specific one that didn't bring anything else.

However I couldn't use the 'add' functions to add elements since the parsing is done at probe time in its own way. So I've keep the radix_insert functions. This could be modified though, it just requires to modify the driver even more which I didn't feel like doing right now.

Quoted 3 lines

OK great. Note that we may be able to come up also with a generic iterator function for the node_to_map functions so maybe see if you come up with some ideas for that while experimenting :)

I haven't had time to think about a generic node_to_map yet, but I hopefully will have some time in a near future to think about it. Right now it doesn't look obvious.

Also, I have some comments about your patches (already applied) which I will send as a reply to the original patches.

Regards,
Gary