Skip to contentSkip to conversation

pinctrl: Implement PINMUX_MAP_SYS_HOG

PATCH In review Stephen Warren 2 participants 5 messages Dec 9, 2011 – Dec 12, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 pinctrl: Implement PINMUX_MAP_SYS_HOG

This is the same as PINMUX_MAP_PRIMARY_SYS_HOG, except that it allows you to specify a particular control device.

---
 include/linux/pinctrl/machine.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/linux/pinctrl/machine.h +8 -0
index f537231..0ca32eb 100644
@@ -66,6 +66,14 @@ struct pinmux_map {
 	{ .name = a, .ctrl_dev_name = b, .function = c }
 
 /*
+ * Convenience macro to map a system function onto a certain pinctrl device,
+ * to be hogged by the pinmux core until the system shuts down.
+ */
+#define PINMUX_MAP_SYS_HOG(a, b, c) \
+	{ .name = a, .ctrl_dev_name = b, .function = c, \
+	  .hog_on_boot = true }
+
+/*
  * Convenience macro to map a function onto the primary device pinctrl device
  * this is especially helpful on systems that have only one pin controller
  * or need to set up a lot of mappings on the primary controller.
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 2/3 arm/u300: Don't use PINMUX_MAP_PRIMARY*

The next patch will remove these macros.

---
 arch/arm/mach-u300/core.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/mach-u300/core.c +6 -6
index e70ebd1..b4c6926 100644
@@ -1607,13 +1607,13 @@ static struct platform_device pinmux_device = {
 /* Pinmux settings */
 static struct pinmux_map __initdata u300_pinmux_map[] = {
 	/* anonymous maps for chip power and EMIFs */
-	PINMUX_MAP_PRIMARY_SYS_HOG("POWER", "power"),
-	PINMUX_MAP_PRIMARY_SYS_HOG("EMIF0", "emif0"),
-	PINMUX_MAP_PRIMARY_SYS_HOG("EMIF1", "emif1"),
+	PINMUX_MAP_SYS_HOG("POWER", "pinmux-u300", "power"),
+	PINMUX_MAP_SYS_HOG("EMIF0", "pinmux-u300", "emif0"),
+	PINMUX_MAP_SYS_HOG("EMIF1", "pinmux-u300", "emif1"),
 	/* per-device maps for MMC/SD, SPI and UART */
-	PINMUX_MAP_PRIMARY("MMCSD", "mmc0", "mmci"),
-	PINMUX_MAP_PRIMARY("SPI", "spi0", "pl022"),
-	PINMUX_MAP_PRIMARY("UART0", "uart0", "uart0"),
+	PINMUX_MAP("MMCSD", "pinmux-u300", "mmc0", "mmci"),
+	PINMUX_MAP("SPI", "pinmux-u300", "spi0", "pl022"),
+	PINMUX_MAP("UART0", "pinmux-u300", "uart0", "uart0"),
 };
 
 struct u300_mux_hog {
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 3/3 pinctrl: Don't create a device for each pin controller

In reply to Stephen Warren

Pin controllers should already be instantiated as a device, so there's no need for the pinctrl core to create a new struct device for each controller.

This allows the controller's real name to be used in the mux mapping table, rather than e.g. "pinctrl.0", "pinctrl.1", etc.

This necessitates removal of the PINMUX_MAP_PRIMARY*() macros, since their sole purpose was to hard-code the .ctrl_dev_name field to be "pinctrl.0".

---
 Documentation/pinctrl.txt       |   26 +++++++++++-----------
 drivers/pinctrl/core.c          |   42 +++++++++--------------------------
 drivers/pinctrl/core.h          |    2 +-
 drivers/pinctrl/pinconf.c       |   16 ++++++------
 drivers/pinctrl/pinmux.c        |   46 +++++++++++++++++++-------------------
 include/linux/pinctrl/machine.h |   25 ---------------------
 6 files changed, 56 insertions(+), 101 deletions(-)
Documentation/pinctrl.txt +13 -13
index ae5ace2..822d6ba 100644
@@ -783,17 +783,17 @@ spi on the second function mapping:
 
 static struct pinmux_map __initdata pmx_mapping[] = {
 	{
-		.ctrl_dev_name = "pinctrl.0",
+		.ctrl_dev_name = "pinctrl-foo",
 		.function = "spi0",
 		.dev_name = "foo-spi.0",
 	},
 	{
-		.ctrl_dev_name = "pinctrl.0",
+		.ctrl_dev_name = "pinctrl-foo",
 		.function = "i2c0",
 		.dev_name = "foo-i2c.0",
 	},
 	{
-		.ctrl_dev_name = "pinctrl.0",
+		.ctrl_dev_name = "pinctrl-foo",
 		.function = "mmc0",
 		.dev_name = "foo-mmc.0",
 	},
@@ -815,7 +815,7 @@ You register this pinmux mapping to the pinmux subsystem by simply:
        ret = pinmux_register_mappings(&pmx_mapping, ARRAY_SIZE(pmx_mapping));
 
 Since the above construct is pretty common there is a helper macro to make
-it even more compact which assumes you want to use pinctrl.0 and position
+it even more compact which assumes you want to use pinctrl-foo and position
 0 for mapping, for example:
 
 static struct pinmux_map __initdata pmx_mapping[] = {
@@ -832,14 +832,14 @@ As it is possible to map a function to different groups of pins an optional
 ...
 {
 	.name = "spi0-pos-A",
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "spi0",
 	.group = "spi0_0_grp",
 	.dev_name = "foo-spi.0",
 },
 {
 	.name = "spi0-pos-B",
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "spi0",
 	.group = "spi0_1_grp",
 	.dev_name = "foo-spi.0",
@@ -858,42 +858,42 @@ case), we define a mapping like this:
 ...
 {
 	.name "2bit"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "mmc0",
 	.group = "mmc0_1_grp",
 	.dev_name = "foo-mmc.0",
 },
 {
 	.name "4bit"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "mmc0",
 	.group = "mmc0_1_grp",
 	.dev_name = "foo-mmc.0",
 },
 {
 	.name "4bit"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "mmc0",
 	.group = "mmc0_2_grp",
 	.dev_name = "foo-mmc.0",
 },
 {
 	.name "8bit"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "mmc0",
 	.group = "mmc0_1_grp",
 	.dev_name = "foo-mmc.0",
 },
 {
 	.name "8bit"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "mmc0",
 	.group = "mmc0_2_grp",
 	.dev_name = "foo-mmc.0",
 },
 {
 	.name "8bit"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "mmc0",
 	.group = "mmc0_3_grp",
 	.dev_name = "foo-mmc.0",
@@ -996,7 +996,7 @@ like this:
 
 {
 	.name "POWERMAP"
-	.ctrl_dev_name = "pinctrl.0",
+	.ctrl_dev_name = "pinctrl-foo",
 	.function = "power_func",
 	.hog_on_boot = true,
 },
drivers/pinctrl/core.c +11 -31

111 lines not on this page · raw message

drivers/pinctrl/core.h +1 -1
index 855e0fb..cea6cf5 100644
@@ -38,7 +38,7 @@ struct pinctrl_dev {
 	spinlock_t pin_desc_tree_lock;
 	struct list_head gpio_ranges;
 	struct mutex gpio_ranges_lock;
-	struct device dev;
+	struct device *dev;
 	struct module *owner;
 	void *driver_data;
 #ifdef CONFIG_PINMUX
drivers/pinctrl/pinconf.c +8 -8
index aefd684..dcd85db 100644
@@ -37,13 +37,13 @@ int pin_config_get(struct pinctrl_dev *pctldev, int pin,
 	const struct pinconf_ops *ops = pctldev->desc->confops;
 
 	if (!pin_is_valid(pctldev, pin)) {
-		dev_err(&pctldev->dev, "tried to get config for unregistered "
+		dev_err(pctldev->dev, "tried to get config for unregistered "
 			"pin %d\n", pin);
 		return -EINVAL;
 	}
 
 	if (!ops || !ops->pin_config_get) {
-		dev_err(&pctldev->dev, "cannot get pin configuration, missing "
+		dev_err(pctldev->dev, "cannot get pin configuration, missing "
 			"pin_config_get() function in driver\n");
 		return -EINVAL;
 	}
@@ -67,20 +67,20 @@ int pin_config_set(struct pinctrl_dev *pctldev, int pin,
 	int ret;
 
 	if (!pin_is_valid(pctldev, pin)) {
-		dev_err(&pctldev->dev, "tried to configure unregistered "
+		dev_err(pctldev->dev, "tried to configure unregistered "
 			"pin %d\n", pin);
 		return -EINVAL;
 	}
 
 	if (!ops || !ops->pin_config_set) {
-		dev_err(&pctldev->dev, "cannot configure pin, missing "
+		dev_err(pctldev->dev, "cannot configure pin, missing "
 			"config function in driver\n");
 		return -EINVAL;
 	}
 
 	ret = ops->pin_config_set(pctldev, pin, config);
 	if (ret) {
-		dev_err(&pctldev->dev,
+		dev_err(pctldev->dev,
 			"unable to set pin configuration on pin %d\n", pin);
 		return ret;
 	}
@@ -96,7 +96,7 @@ int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group,
 	int selector;
 
 	if (!ops || !ops->pin_config_group_get) {
-		dev_err(&pctldev->dev, "cannot get configuration for pin "
+		dev_err(pctldev->dev, "cannot get configuration for pin "
 			"group, missing group config get function in "
 			"driver\n");
 		return -EINVAL;
@@ -123,7 +123,7 @@ int pin_config_group_set(struct pinctrl_dev *pctldev, const char *pin_group,
 	int i;
 
 	if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) {
-		dev_err(&pctldev->dev, "cannot configure pin group, missing "
+		dev_err(pctldev->dev, "cannot configure pin group, missing "
 			"config function in driver\n");
 		return -EINVAL;
 	}
@@ -134,7 +134,7 @@ int pin_config_group_set(struct pinctrl_dev *pctldev, const char *pin_group,
 
 	ret = pctlops->get_group_pins(pctldev, selector, &pins, &num_pins);
 	if (ret) {
-		dev_err(&pctldev->dev, "cannot configure pin group, error "
+		dev_err(pctldev->dev, "cannot configure pin group, error "
 			"getting pins\n");
 		return ret;
 	}
drivers/pinctrl/pinmux.c +23 -23

179 lines not on this page · raw message

include/linux/pinctrl/machine.h +0 -25
index 0ca32eb..ad430e0 100644
@@ -73,31 +73,6 @@ struct pinmux_map {
 	{ .name = a, .ctrl_dev_name = b, .function = c, \
 	  .hog_on_boot = true }
 
-/*
- * Convenience macro to map a function onto the primary device pinctrl device
- * this is especially helpful on systems that have only one pin controller
- * or need to set up a lot of mappings on the primary controller.
- */
-#define PINMUX_MAP_PRIMARY(a, b, c) \
-	{ .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \
-	  .dev_name = c }
-
-/*
- * Convenience macro to map a system function onto the primary pinctrl device.
- * System functions are not assigned to a particular device.
- */
-#define PINMUX_MAP_PRIMARY_SYS(a, b) \
-	{ .name = a, .ctrl_dev_name = "pinctrl.0", .function = b }
-
-/*
- * Convenience macro to map a system function onto the primary pinctrl device,
- * to be hogged by the pinmux core until the system shuts down.
- */
-#define PINMUX_MAP_PRIMARY_SYS_HOG(a, b) \
-	{ .name = a, .ctrl_dev_name = "pinctrl.0", .function = b, \
-	  .hog_on_boot = true }
-
-
 #ifdef CONFIG_PINMUX
 
 extern int pinmux_register_mappings(struct pinmux_map const *map,
Signature · 1 line
1.7.0.4
#3 lore raw

Re: [PATCH 3/3] pinctrl: Don't create a device for each pin controller

In reply to Stephen Warren
Quoted 6 lines · Stephen Warren

Pin controllers should already be instantiated as a device, so there's no need for the pinctrl core to create a new struct device for each controller.

This allows the controller's real name to be used in the mux mapping table, rather than e.g. "pinctrl.0", "pinctrl.1", etc.

Hey cool, this "just works" on U300!

And it is what we want for future device tree work I highly suspect.

I'll push the change to linux-next!

Thanks,
Linus Walleij