Skip to contentSkip to conversation

constify struct imx_pinctrl_soc_info

PATCH In review Stefan Agner 6 participants 18 messages Jan 6, 2018 – Jan 11, 2018

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

v2 cover constify struct imx_pinctrl_soc_info

This patchset grew out of the discussion around the first version of "pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL". This is necessary for pinctrls of SoCs with multiple compatible strings (currently only imx7d) since the struct uses the .data pointer in struct of_device_id. It is also helpful for all other SoCs since it decreases the .data section for all drivers by 1276 bytes.

Bai Ping (1):
pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

Stefan Agner (4):
pinctrl: imx: use struct imx_pinctrl_soc_info as a const
pinctrl: imx7d: simplify imx7d_pinctrl_probe
pinctrl: imx: constify struct imx_pinctrl_soc_info
pinctrl: imx7ulp: constify struct imx_cfg_params_decode

 .../bindings/pinctrl/fsl,imx6ul-pinctrl.txt        |  3 +-
 drivers/pinctrl/freescale/pinctrl-imx.c            | 81 ++++++++++------------
 drivers/pinctrl/freescale/pinctrl-imx.h            | 13 ++--
 drivers/pinctrl/freescale/pinctrl-imx25.c          |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx35.c          |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx50.c          |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx51.c          |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx53.c          |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx6dl.c         |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx6q.c          |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx6sl.c         |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx6sx.c         |  2 +-
 drivers/pinctrl/freescale/pinctrl-imx6ul.c         | 52 ++++++++++++--
 drivers/pinctrl/freescale/pinctrl-imx7d.c          | 10 +--
 drivers/pinctrl/freescale/pinctrl-imx7ulp.c        |  7 +-
 drivers/pinctrl/freescale/pinctrl-vf610.c          |  5 +-
 16 files changed, 111 insertions(+), 78 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH v2 1/5 pinctrl: imx: use struct imx_pinctrl_soc_info as a const

For some SoCs the struct imx_pinctrl_soc_info is passed through of_device_id.data which is const. Most variables are already const or otherwise not written. However, some fields are modified at runtime. Move those fields to the dynamically allocated struct imx_pinctrl.

Fixes b3060044e495 ("pinctrl: freescale: imx7d: make of_device_ids const")
Cc Shawn Guo <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Dong Aisheng <[email protected]>
Cc Gary Bisson <[email protected]>
---
 drivers/pinctrl/freescale/pinctrl-imx.c     | 79 ++++++++++++++---------------
 drivers/pinctrl/freescale/pinctrl-imx.h     | 11 ++--
 drivers/pinctrl/freescale/pinctrl-imx7ulp.c |  3 +-
 drivers/pinctrl/freescale/pinctrl-vf610.c   |  3 +-
 4 files changed, 44 insertions(+), 52 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +37 -42
index 6e472691d8ee..86256d25c4a3 100644
@@ -62,7 +62,6 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 			struct pinctrl_map **map, unsigned *num_maps)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct group_desc *grp;
 	struct pinctrl_map *new_map;
 	struct device_node *parent;
@@ -75,7 +74,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
 	 */
 	grp = imx_pinctrl_find_group_by_name(pctldev, np->name);
 	if (!grp) {
-		dev_err(info->dev, "unable to find group for node %s\n",
+		dev_err(ipctl->dev, "unable to find group for node %s\n",
 			np->name);
 		return -EINVAL;
 	}
@@ -146,7 +145,7 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
 		       unsigned group)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
+	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct imx_pin_reg *pin_reg;
 	unsigned int npins, pin_id;
 	int i;
@@ -174,7 +173,7 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
 		struct imx_pin *pin = &((struct imx_pin *)(grp->data))[i];
 
 		pin_id = pin->pin;
-		pin_reg = &info->pin_regs[pin_id];
+		pin_reg = &ipctl->pin_regs[pin_id];
 
 		if (pin_reg->mux_reg == -1) {
 			dev_dbg(ipctl->dev, "Pin(%s) does not support mux function\n",
@@ -255,7 +254,7 @@ static u32 imx_pinconf_decode_generic_config(struct imx_pinctrl *ipctl,
 					      unsigned long *configs,
 					      unsigned int num_configs)
 {
-	struct imx_pinctrl_soc_info *info = ipctl->info;
+	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	struct imx_cfg_params_decode *decode;
 	enum pin_config_param param;
 	u32 raw_config = 0;
@@ -289,7 +288,7 @@ static u32 imx_pinconf_decode_generic_config(struct imx_pinctrl *ipctl,
 static u32 imx_pinconf_parse_generic_config(struct device_node *np,
 					    struct imx_pinctrl *ipctl)
 {
-	struct imx_pinctrl_soc_info *info = ipctl->info;
+	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	struct pinctrl_dev *pctl = ipctl->pctl;
 	unsigned int num_configs;
 	unsigned long *configs;
@@ -310,11 +309,11 @@ static int imx_pinconf_get(struct pinctrl_dev *pctldev,
 			     unsigned pin_id, unsigned long *config)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
-	const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id];
+	const struct imx_pinctrl_soc_info *info = ipctl->info;
+	const struct imx_pin_reg *pin_reg = &ipctl->pin_regs[pin_id];
 
 	if (pin_reg->conf_reg == -1) {
-		dev_err(info->dev, "Pin(%s) does not support config function\n",
+		dev_err(ipctl->dev, "Pin(%s) does not support config function\n",
 			info->pins[pin_id].name);
 		return -EINVAL;
 	}
@@ -332,12 +331,12 @@ static int imx_pinconf_set(struct pinctrl_dev *pctldev,
 			     unsigned num_configs)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
-	const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id];
+	const struct imx_pinctrl_soc_info *info = ipctl->info;
+	const struct imx_pin_reg *pin_reg = &ipctl->pin_regs[pin_id];
 	int i;
 
 	if (pin_reg->conf_reg == -1) {
-		dev_err(info->dev, "Pin(%s) does not support config function\n",
+		dev_err(ipctl->dev, "Pin(%s) does not support config function\n",
 			info->pins[pin_id].name);
 		return -EINVAL;
 	}
@@ -368,8 +367,7 @@ static void imx_pinconf_dbg_show(struct pinctrl_dev *pctldev,
 				   struct seq_file *s, unsigned pin_id)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
-	const struct imx_pin_reg *pin_reg = &info->pin_regs[pin_id];
+	const struct imx_pin_reg *pin_reg = &ipctl->pin_regs[pin_id];
 	unsigned long config;
 
 	if (!pin_reg || pin_reg->conf_reg == -1) {
@@ -427,13 +425,13 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
 				    struct imx_pinctrl *ipctl,
 				    u32 index)
 {
-	struct imx_pinctrl_soc_info *info = ipctl->info;
+	const struct imx_pinctrl_soc_info *info = ipctl->info;
 	int size, pin_size;
 	const __be32 *list;
 	int i;
 	u32 config;
 
-	dev_dbg(info->dev, "group(%d): %s\n", index, np->name);
+	dev_dbg(ipctl->dev, "group(%d): %s\n", index, np->name);
 
 	if (info->flags & SHARE_MUX_CONF_REG)
 		pin_size = SHARE_FSL_PIN_SIZE;
@@ -460,7 +458,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
 	if (!list) {
 		list = of_get_property(np, "pinmux", &size);
 		if (!list) {
-			dev_err(info->dev,
+			dev_err(ipctl->dev,
 				"no fsl,pins and pins property in node %pOF\n", np);
 			return -EINVAL;
 		}
@@ -468,7 +466,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
 
 	/* we do not check return since it's safe node passed down */
 	if (!size || size % pin_size) {
-		dev_err(info->dev, "Invalid fsl,pins or pins property in node %pOF\n", np);
+		dev_err(ipctl->dev, "Invalid fsl,pins or pins property in node %pOF\n", np);
 		return -EINVAL;
 	}
 
@@ -476,9 +474,9 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
 	config = imx_pinconf_parse_generic_config(np, ipctl);
 
 	grp->num_pins = size / pin_size;
-	grp->data = devm_kzalloc(info->dev, grp->num_pins *
+	grp->data = devm_kzalloc(ipctl->dev, grp->num_pins *
 				 sizeof(struct imx_pin), GFP_KERNEL);
-	grp->pins = devm_kzalloc(info->dev, grp->num_pins *
+	grp->pins = devm_kzalloc(ipctl->dev, grp->num_pins *
 				 sizeof(unsigned int), GFP_KERNEL);
 	if (!grp->pins || !grp->data)
 		return -ENOMEM;
@@ -502,7 +500,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
 		}
 
 		pin_id = (mux_reg != -1) ? mux_reg / 4 : conf_reg / 4;
-		pin_reg = &info->pin_regs[pin_id];
+		pin_reg = &ipctl->pin_regs[pin_id];
 		pin->pin = pin_id;
 		grp->pins[i] = pin_id;
 		pin_reg->mux_reg = mux_reg;
@@ -524,7 +522,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
 			pin->config = config & ~IMX_PAD_SION;
 		}
 
-		dev_dbg(info->dev, "%s: 0x%x 0x%08lx", info->pins[pin_id].name,
+		dev_dbg(ipctl->dev, "%s: 0x%x 0x%08lx", info->pins[pin_id].name,
 				pin->mux_mode, pin->config);
 	}
 
@@ -536,13 +534,12 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 				       u32 index)
 {
 	struct pinctrl_dev *pctl = ipctl->pctl;
-	struct imx_pinctrl_soc_info *info = ipctl->info;
 	struct device_node *child;
 	struct function_desc *func;
 	struct group_desc *grp;
 	u32 i = 0;
 
-	dev_dbg(info->dev, "parse function(%d): %s\n", index, np->name);
+	dev_dbg(pctl->dev, "parse function(%d): %s\n", index, np->name);
 
 	func = pinmux_generic_get_function(pctl, index);
 	if (!func)
@@ -552,10 +549,10 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 	func->name = np->name;
 	func->num_group_names = of_get_child_count(np);
 	if (func->num_group_names == 0) {
-		dev_err(info->dev, "no groups defined in %pOF\n", np);
+		dev_err(ipctl->dev, "no groups defined in %pOF\n", np);
 		return -EINVAL;
 	}
-	func->group_names = devm_kcalloc(info->dev, func->num_group_names,
+	func->group_names = devm_kcalloc(ipctl->dev, func->num_group_names,
 					 sizeof(char *), GFP_KERNEL);
 	if (!func->group_names)
 		return -ENOMEM;
@@ -563,15 +560,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
 	for_each_child_of_node(np, child) {
 		func->group_names[i] = child->name;
 
-		grp = devm_kzalloc(info->dev, sizeof(struct group_desc),
+		grp = devm_kzalloc(ipctl->dev, sizeof(struct group_desc),
 				   GFP_KERNEL);
 		if (!grp)
 			return -ENOMEM;
 
-		mutex_lock(&info->mutex);
+		mutex_lock(&ipctl->mutex);
 		radix_tree_insert(&pctl->pin_group_tree,
-				  info->group_index++, grp);
-		mutex_unlock(&info->mutex);
+				  ipctl->group_index++, grp);
+		mutex_unlock(&ipctl->mutex);
 
 		imx_pinctrl_parse_groups(child, grp, ipctl, i++);
 	}
@@ -608,7 +605,6 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
 	struct device_node *np = pdev->dev.of_node;
 	struct device_node *child;
 	struct pinctrl_dev *pctl = ipctl->pctl;
-	struct imx_pinctrl_soc_info *info = ipctl->info;
 	u32 nfuncs = 0;
 	u32 i = 0;
 	bool flat_funcs;
@@ -635,13 +631,13 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
 		if (!function)
 			return -ENOMEM;
 
-		mutex_lock(&info->mutex);
+		mutex_lock(&ipctl->mutex);
 		radix_tree_insert(&pctl->pin_function_tree, i, function);
-		mutex_unlock(&info->mutex);
+		mutex_unlock(&ipctl->mutex);
 	}
 	pctl->num_functions = nfuncs;
 
-	info->group_index = 0;
+	ipctl->group_index = 0;
 	if (flat_funcs) {
 		pctl->num_groups = of_get_child_count(np);
 	} else {
@@ -672,7 +668,7 @@ static void imx_free_resources(struct imx_pinctrl *ipctl)
 }
 
 int imx_pinctrl_probe(struct platform_device *pdev,
-		      struct imx_pinctrl_soc_info *info)
+		      const struct imx_pinctrl_soc_info *info)
 {
 	struct regmap_config config = { .name = "gpr" };
 	struct device_node *dev_np = pdev->dev.of_node;
@@ -687,7 +683,6 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 		dev_err(&pdev->dev, "wrong pinctrl info\n");
 		return -EINVAL;
 	}
-	info->dev = &pdev->dev;
 
 	if (info->gpr_compatible) {
 		gpr = syscon_regmap_lookup_by_compatible(info->gpr_compatible);
@@ -700,14 +695,14 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 	if (!ipctl)
 		return -ENOMEM;
 
-	info->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*info->pin_regs) *
+	ipctl->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*ipctl->pin_regs) *
 				      info->npins, GFP_KERNEL);
-	if (!info->pin_regs)
+	if (!ipctl->pin_regs)
 		return -ENOMEM;
 
 	for (i = 0; i < info->npins; i++) {
-		info->pin_regs[i].mux_reg = -1;
-		info->pin_regs[i].conf_reg = -1;
+		ipctl->pin_regs[i].mux_reg = -1;
+		ipctl->pin_regs[i].conf_reg = -1;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -751,10 +746,10 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 	/* platform specific callback */
 	imx_pmx_ops.gpio_set_direction = info->gpio_set_direction;
 
-	mutex_init(&info->mutex);
+	mutex_init(&ipctl->mutex);
 
 	ipctl->info = info;
-	ipctl->dev = info->dev;
+	ipctl->dev = &pdev->dev;
 	platform_set_drvdata(pdev, ipctl);
 	ret = devm_pinctrl_register_and_init(&pdev->dev,
 					     imx_pinctrl_desc, ipctl,
drivers/pinctrl/freescale/pinctrl-imx.h +5 -6
index 5aa22b52c1d4..41ee75537da4 100644
@@ -58,14 +58,10 @@ struct imx_cfg_params_decode {
 };
 
 struct imx_pinctrl_soc_info {
-	struct device *dev;
 	const struct pinctrl_pin_desc *pins;
 	unsigned int npins;
-	struct imx_pin_reg *pin_regs;
-	unsigned int group_index;
 	unsigned int flags;
 	const char *gpr_compatible;
-	struct mutex mutex;
 
 	/* MUX_MODE shift and mask in case SHARE_MUX_CONF_REG */
 	unsigned int mux_mask;
@@ -95,7 +91,10 @@ struct imx_pinctrl {
 	struct pinctrl_dev *pctl;
 	void __iomem *base;
 	void __iomem *input_sel_base;
-	struct imx_pinctrl_soc_info *info;
+	const struct imx_pinctrl_soc_info *info;
+	struct imx_pin_reg *pin_regs;
+	unsigned int group_index;
+	struct mutex mutex;
 };
 
 #define IMX_CFG_PARAMS_DECODE(p, m, o) \
@@ -117,5 +116,5 @@ struct imx_pinctrl {
 #define IOMUXC_CONFIG_SION	(0x1 << 4)
 
 int imx_pinctrl_probe(struct platform_device *pdev,
-			struct imx_pinctrl_soc_info *info);
+			const struct imx_pinctrl_soc_info *info);
 #endif /* __DRIVERS_PINCTRL_IMX_H */
drivers/pinctrl/freescale/pinctrl-imx7ulp.c +1 -2
index b7bebb292f37..9161c984f57b 100644
@@ -307,11 +307,10 @@ static int imx7ulp_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 					  unsigned offset, bool input)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct imx_pin_reg *pin_reg;
 	u32 reg;
 
-	pin_reg = &info->pin_regs[offset];
+	pin_reg = &ipctl->pin_regs[offset];
 	if (pin_reg->mux_reg == -1)
 		return -EINVAL;
 
drivers/pinctrl/freescale/pinctrl-vf610.c +1 -2
index ac18bb6d6d5e..42745c690be3 100644
@@ -300,11 +300,10 @@ static int vf610_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 					unsigned offset, bool input)
 {
 	struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
-	struct imx_pinctrl_soc_info *info = ipctl->info;
 	const struct imx_pin_reg *pin_reg;
 	u32 reg;
 
-	pin_reg = &info->pin_regs[offset];
+	pin_reg = &ipctl->pin_regs[offset];
 	if (pin_reg->mux_reg == -1)
 		return -EINVAL;
 
Signature · 1 line
2.15.1
#6 lore raw

PATCH v2 2/5 pinctrl: imx7d: simplify imx7d_pinctrl_probe

In reply to Stefan Agner

Using of_device_get_match_data in imx7d_pinctrl_probe simplifies the function. Also get rid of the void pointer cast since imx_pinctrl_probe now accepts const struct imx_pinctrl_soc_info.

---
 drivers/pinctrl/freescale/pinctrl-imx7d.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx7d.c +3 -7
index 754159ee7b1e..0b0a2f33b06a 100644
@@ -378,16 +378,12 @@ static const struct of_device_id imx7d_pinctrl_of_match[] = {
 
 static int imx7d_pinctrl_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
-	struct imx_pinctrl_soc_info *pinctrl_info;
+	const struct imx_pinctrl_soc_info *pinctrl_info;
 
-	match = of_match_device(imx7d_pinctrl_of_match, &pdev->dev);
-
-	if (!match)
+	pinctrl_info = of_device_get_match_data(&pdev->dev);
+	if (!pinctrl_info)
 		return -ENODEV;
 
-	pinctrl_info = (struct imx_pinctrl_soc_info *) match->data;
-
 	return imx_pinctrl_probe(pdev, pinctrl_info);
 }
 
Signature · 1 line
2.15.1
#8 lore raw

PATCH v2 3/5 pinctrl: imx: constify struct imx_pinctrl_soc_info

In reply to Stefan Agner

Now that imx_pinctrl_probe accepts const struct imx_pinctrl_soc_info we can constify all declarations of struct imx_pinctrl_soc_info.

---
 drivers/pinctrl/freescale/pinctrl-imx25.c   | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx35.c   | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx50.c   | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx51.c   | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx53.c   | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx6dl.c  | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx6q.c   | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx6sl.c  | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx6sx.c  | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx7ulp.c | 2 +-
 drivers/pinctrl/freescale/pinctrl-vf610.c   | 2 +-
 11 files changed, 11 insertions(+), 11 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx25.c +1 -1
index d7367fabe712..db6d9d1382f9 100644
@@ -309,7 +309,7 @@ static const struct pinctrl_pin_desc imx25_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX25_PAD_BOOT_MODE1),
 };
 
-static struct imx_pinctrl_soc_info imx25_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx25_pinctrl_info = {
 	.pins = imx25_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx25_pinctrl_pads),
 };
drivers/pinctrl/freescale/pinctrl-imx35.c +1 -1
index 6315ba6af431..6927946ae4b5 100644
@@ -999,7 +999,7 @@ static const struct pinctrl_pin_desc imx35_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX35_PAD_TEST_MODE),
 };
 
-static struct imx_pinctrl_soc_info imx35_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx35_pinctrl_info = {
 	.pins = imx35_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx35_pinctrl_pads),
 };
drivers/pinctrl/freescale/pinctrl-imx50.c +1 -1
index 8e3a17df5c5d..eb349b97290f 100644
@@ -385,7 +385,7 @@ static const struct pinctrl_pin_desc imx50_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX50_PAD_EIM_CRE),
 };
 
-static struct imx_pinctrl_soc_info imx50_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx50_pinctrl_info = {
 	.pins = imx50_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx50_pinctrl_pads),
 	.gpr_compatible = "fsl,imx50-iomuxc-gpr",
drivers/pinctrl/freescale/pinctrl-imx51.c +1 -1
index eeac64ba2709..49acd991b5fb 100644
@@ -762,7 +762,7 @@ static const struct pinctrl_pin_desc imx51_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX51_PAD_CSI1_MCLK),
 };
 
-static struct imx_pinctrl_soc_info imx51_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx51_pinctrl_info = {
 	.pins = imx51_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx51_pinctrl_pads),
 };
drivers/pinctrl/freescale/pinctrl-imx53.c +1 -1
index 46a9572f3473..6dd0c60eaea4 100644
@@ -448,7 +448,7 @@ static const struct pinctrl_pin_desc imx53_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX53_PAD_GPIO_18),
 };
 
-static struct imx_pinctrl_soc_info imx53_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx53_pinctrl_info = {
 	.pins = imx53_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx53_pinctrl_pads),
 	.gpr_compatible = "fsl,imx53-iomuxc-gpr",
drivers/pinctrl/freescale/pinctrl-imx6dl.c +1 -1
index 3f25ca5867cc..91b85fc01de8 100644
@@ -457,7 +457,7 @@ static const struct pinctrl_pin_desc imx6dl_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX6DL_PAD_SD4_DAT7),
 };
 
-static struct imx_pinctrl_soc_info imx6dl_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx6dl_pinctrl_info = {
 	.pins = imx6dl_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx6dl_pinctrl_pads),
 	.gpr_compatible = "fsl,imx6q-iomuxc-gpr",
drivers/pinctrl/freescale/pinctrl-imx6q.c +1 -1
index d61651c40458..5f653d69d0f5 100644
@@ -460,7 +460,7 @@ static const struct pinctrl_pin_desc imx6q_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX6Q_PAD_SD2_DAT3),
 };
 
-static struct imx_pinctrl_soc_info imx6q_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx6q_pinctrl_info = {
 	.pins = imx6q_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx6q_pinctrl_pads),
 	.gpr_compatible = "fsl,imx6q-iomuxc-gpr",
drivers/pinctrl/freescale/pinctrl-imx6sl.c +1 -1
index d023f6b00623..1167dc273c04 100644
@@ -363,7 +363,7 @@ static const struct pinctrl_pin_desc imx6sl_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX6SL_PAD_WDOG_B),
 };
 
-static struct imx_pinctrl_soc_info imx6sl_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx6sl_pinctrl_info = {
 	.pins = imx6sl_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx6sl_pinctrl_pads),
 	.gpr_compatible = "fsl,imx6sl-iomuxc-gpr",
drivers/pinctrl/freescale/pinctrl-imx6sx.c +1 -1
index 898b781701e6..15ea56c75f68 100644
@@ -367,7 +367,7 @@ static const struct pinctrl_pin_desc imx6sx_pinctrl_pads[] = {
 	IMX_PINCTRL_PIN(MX6SX_PAD_USB_H_STROBE),
 };
 
-static struct imx_pinctrl_soc_info imx6sx_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx6sx_pinctrl_info = {
 	.pins = imx6sx_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx6sx_pinctrl_pads),
 	.gpr_compatible = "fsl,imx6sx-iomuxc-gpr",
drivers/pinctrl/freescale/pinctrl-imx7ulp.c +1 -1
index 9161c984f57b..0406d8b39e6a 100644
@@ -324,7 +324,7 @@ static int imx7ulp_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 	return 0;
 }
 
-static struct imx_pinctrl_soc_info imx7ulp_pinctrl_info = {
+static const struct imx_pinctrl_soc_info imx7ulp_pinctrl_info = {
 	.pins = imx7ulp_pinctrl_pads,
 	.npins = ARRAY_SIZE(imx7ulp_pinctrl_pads),
 	.flags = ZERO_OFFSET_VALID | SHARE_MUX_CONF_REG,
drivers/pinctrl/freescale/pinctrl-vf610.c +1 -1
index 42745c690be3..c078f859ae15 100644
@@ -318,7 +318,7 @@ static int vf610_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
 	return 0;
 }
 
-static struct imx_pinctrl_soc_info vf610_pinctrl_info = {
+static const struct imx_pinctrl_soc_info vf610_pinctrl_info = {
 	.pins = vf610_pinctrl_pads,
 	.npins = ARRAY_SIZE(vf610_pinctrl_pads),
 	.flags = SHARE_MUX_CONF_REG | ZERO_OFFSET_VALID,
Signature · 1 line
2.15.1
#10 lore raw

PATCH v2 4/5 pinctrl: imx7ulp: constify struct imx_cfg_params_decode

In reply to Stefan Agner

The decode parameters are constant mark them const.

---
 drivers/pinctrl/freescale/pinctrl-imx.c     | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx.h     | 2 +-
 drivers/pinctrl/freescale/pinctrl-imx7ulp.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +1 -1
index 86256d25c4a3..24aaddd760a0 100644
@@ -255,7 +255,7 @@ static u32 imx_pinconf_decode_generic_config(struct imx_pinctrl *ipctl,
 					      unsigned int num_configs)
 {
 	const struct imx_pinctrl_soc_info *info = ipctl->info;
-	struct imx_cfg_params_decode *decode;
+	const struct imx_cfg_params_decode *decode;
 	enum pin_config_param param;
 	u32 raw_config = 0;
 	u32 param_val;
drivers/pinctrl/freescale/pinctrl-imx.h +1 -1
index 41ee75537da4..038e8c0e5b96 100644
@@ -71,7 +71,7 @@ struct imx_pinctrl_soc_info {
 	bool generic_pinconf;
 	const struct pinconf_generic_params *custom_params;
 	unsigned int num_custom_params;
-	struct imx_cfg_params_decode *decodes;
+	const struct imx_cfg_params_decode *decodes;
 	unsigned int num_decodes;
 	void (*fixup)(unsigned long *configs, unsigned int num_configs,
 		      u32 *raw_config);
drivers/pinctrl/freescale/pinctrl-imx7ulp.c +1 -1
index 0406d8b39e6a..f363e45fd246 100644
@@ -266,7 +266,7 @@ static const struct pinctrl_pin_desc imx7ulp_pinctrl_pads[] = {
 #define BP_MUX_MODE		8
 #define BM_PULL_ENABLED		BIT(1)
 
-struct imx_cfg_params_decode imx7ulp_cfg_decodes[] = {
+static const struct imx_cfg_params_decode imx7ulp_cfg_decodes[] = {
 	IMX_CFG_PARAMS_DECODE(PIN_CONFIG_DRIVE_STRENGTH, 		BIT(6), 6),
 	IMX_CFG_PARAMS_DECODE(PIN_CONFIG_DRIVE_PUSH_PULL,		BIT(5), 5),
 	IMX_CFG_PARAMS_DECODE(PIN_CONFIG_SLEW_RATE,			BIT(2), 2),
Signature · 1 line
2.15.1
#12 lore raw

PATCH v2 5/5 pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

In reply to Stefan Agner

From: Bai Ping <[email protected]>

On i.MX 6ULL, the BOOT_MODEx and TAMPERx pin MUX and CTRL registers are available in a separate IOMUXC_SNVS module. Add support for the IOMUXC_SNVS module to the i.MX 6UL pinctrl driver.

---
 .../bindings/pinctrl/fsl,imx6ul-pinctrl.txt        |  3 +-
 drivers/pinctrl/freescale/pinctrl-imx6ul.c         | 52 ++++++++++++++++++++--
 2 files changed, 50 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/pinctrl/fsl,imx6ul-pinctrl.txt +2 -1
index a81bbf37ed66..7ca4f6118d9a 100644
@@ -4,7 +4,8 @@ Please refer to fsl,imx-pinctrl.txt in this directory for common binding part
 and usage.
 
 Required properties:
-- compatible: "fsl,imx6ul-iomuxc"
+- compatible: "fsl,imx6ul-iomuxc" for main IOMUX controller or
+  "fsl,imx6ull-iomuxc-snvs" for i.MX 6ULL's SNVS IOMUX controller.
 - fsl,pins: each entry consists of 6 integers and represents the mux and config
   setting for one pin.  The first 5 integers <mux_reg conf_reg input_reg mux_val
   input_val> are specified using a PIN_FUNC_ID macro, which can be found in
drivers/pinctrl/freescale/pinctrl-imx6ul.c +48 -4

74 lines not on this page · raw message

Signature · 1 line
2.15.1
Acked-by on the v2 series
#17 lore raw
In reply to Stefan Agner
Quoted 8 lines · Stefan Agner

This patchset grew out of the discussion around the first version of "pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL". This is necessary for pinctrls of SoCs with multiple compatible strings (currently only imx7d) since the struct uses the .data pointer in struct of_device_id. It is also helpful for all other SoCs since it decreases the .data section for all drivers by 1276 bytes.

Quoted 9 lines

Bai Ping (1):
pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

Stefan Agner (4):
pinctrl: imx: use struct imx_pinctrl_soc_info as a const
pinctrl: imx7d: simplify imx7d_pinctrl_probe
pinctrl: imx: constify struct imx_pinctrl_soc_info
pinctrl: imx7ulp: constify struct imx_cfg_params_decode

This patch series looks really good to me.

So

Regards
Dong Aisheng

#2 lore raw

Re: [PATCH v2 1/5] pinctrl: imx: use struct imx_pinctrl_soc_info as a const

In reply to Stefan Agner

Hi Stefan,

Quoted 6 lines · Stefan Agner

For some SoCs the struct imx_pinctrl_soc_info is passed through of_device_id.data which is const. Most variables are already const or otherwise not written. However, some fields are modified at runtime. Move those fields to the dynamically allocated struct imx_pinctrl.

Quoted 6 lines
Fixes b3060044e495 ("pinctrl: freescale: imx7d: make of_device_ids const")
Cc Shawn Guo <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Dong Aisheng <[email protected]>
Cc Gary Bisson <[email protected]>

This is actually more or less a revert of a previous commit:
b28742be4709 pinctrl: imx: remove const qualifier of imx_pinctrl_soc_info

Note that the idea for this commit was to get dt-overlays working and able to do pinctrl changes using configfs interface to load an overlay (using Pantelis patch). Not sure where we stand on loading such overlay from user-space, is it still something that will happen?

Regards,
Gary

#3 lore raw

Re: [PATCH v2 1/5] pinctrl: imx: use struct imx_pinctrl_soc_info as a const

Quoted 16 lines · Gary Bisson

Hi Stefan,

Quoted 6 lines · Stefan Agner

For some SoCs the struct imx_pinctrl_soc_info is passed through of_device_id.data which is const. Most variables are already const or otherwise not written. However, some fields are modified at runtime. Move those fields to the dynamically allocated struct imx_pinctrl.

Quoted 6 lines
Fixes b3060044e495 ("pinctrl: freescale: imx7d: make of_device_ids const")
Cc Shawn Guo <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Dong Aisheng <[email protected]>
Cc Gary Bisson <[email protected]>
Quoted 2 lines

This is actually more or less a revert of a previous commit:
b28742be4709 pinctrl: imx: remove const qualifier of imx_pinctrl_soc_info

Hm, I see. However, back then imx_pinctrl_probe still consumed a non-const struct imx_pinctrl_soc_info pointer. So this constifies all the way through.

Quoted 5 lines

Note that the idea for this commit was to get dt-overlays working and able to do pinctrl changes using configfs interface to load an overlay (using Pantelis patch). Not sure where we stand on loading such overlay from user-space, is it still something that will happen?

I am all for dt-overlays and actually also hope that it will make it completely into mainline. So whatever prevents using device tree overlays should be addressed.

It seems that ngroups is now part of struct pinctrl_dev (num_groups), which is still writable. So we should be fine?

As far as I can tell all remaining properties come from the drivers directly and should not be influenced by anything in the device tree....

--
Stefan

#13 lore raw

Re: [PATCH v2 5/5] pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

In reply to Stefan Agner
Quoted 9 lines · Stefan Agner

From: Bai Ping <[email protected]>

On i.MX 6ULL, the BOOT_MODEx and TAMPERx pin MUX and CTRL registers are available in a separate IOMUXC_SNVS module. Add support for the IOMUXC_SNVS module to the i.MX 6UL pinctrl driver.

Patch applied.

I need clear maintainership for Freescale pin controllers.

Stefan, would you consider making a patch adding you, Dong Aisheng and Shawn Guo as maintainers in MAINTAINERS for
drivers/pinctrl/freescale/* Documentation/devicetree/bindings/pinctrl/fsl,*
?

I don't know if Shawn want to be added, but he wrote the first version so unless he says explicitly no I think he should be included.

Sascha, do you also wanna be included?

Yours,
Linus Walleij

maintainer
#14 lore raw

Re: [PATCH v2 5/5] pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

Hi Linus,

Quoted 11 lines · Linus Walleij

Patch applied.

I need clear maintainership for Freescale pin controllers.

Stefan, would you consider making a patch adding you, Dong Aisheng and Shawn Guo as maintainers in MAINTAINERS for
drivers/pinctrl/freescale/* Documentation/devicetree/bindings/pinctrl/fsl,*
?

Quoted 5 lines

I don't know if Shawn want to be added, but he wrote the first version so unless he says explicitly no I think he should be included.

Sascha, do you also wanna be included?

I would also like to be included, if possible.

Thanks

#4 lore raw

Re: [PATCH v2 1/5] pinctrl: imx: use struct imx_pinctrl_soc_info as a const

In reply to Stefan Agner

Hi Stefan,

Quoted 30 lines · Stefan Agner
Quoted 16 lines · Gary Bisson

Hi Stefan,

Quoted 6 lines · Stefan Agner

For some SoCs the struct imx_pinctrl_soc_info is passed through of_device_id.data which is const. Most variables are already const or otherwise not written. However, some fields are modified at runtime. Move those fields to the dynamically allocated struct imx_pinctrl.

Quoted 6 lines
Fixes b3060044e495 ("pinctrl: freescale: imx7d: make of_device_ids const")
Cc Shawn Guo <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Dong Aisheng <[email protected]>
Cc Gary Bisson <[email protected]>
Quoted 2 lines

This is actually more or less a revert of a previous commit:
b28742be4709 pinctrl: imx: remove const qualifier of imx_pinctrl_soc_info

Hm, I see. However, back then imx_pinctrl_probe still consumed a non-const struct imx_pinctrl_soc_info pointer. So this constifies all the way through.

Quoted 5 lines

Note that the idea for this commit was to get dt-overlays working and able to do pinctrl changes using configfs interface to load an overlay (using Pantelis patch). Not sure where we stand on loading such overlay from user-space, is it still something that will happen?

Quoted 6 lines

I am all for dt-overlays and actually also hope that it will make it completely into mainline. So whatever prevents using device tree overlays should be addressed.

It seems that ngroups is now part of struct pinctrl_dev (num_groups), which is still writable. So we should be fine?

Correct, I forgot about the generic pinmux/pinctrl patches. Indeed having the structure as const is perfectly fine now, even with dt-overlays in mind.

Regards,
Gary

#15 lore raw

Re: [PATCH v2 5/5] pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

In reply to Fabio Estevam
Quoted 13 lines · Fabio Estevam
Quoted 11 lines · Linus Walleij

Patch applied.

I need clear maintainership for Freescale pin controllers.

Stefan, would you consider making a patch adding you, Dong Aisheng and Shawn Guo as maintainers in MAINTAINERS for
drivers/pinctrl/freescale/* Documentation/devicetree/bindings/pinctrl/fsl,*
?

Quoted 7 lines
Quoted 5 lines

I don't know if Shawn want to be added, but he wrote the first version so unless he says explicitly no I think he should be included.

Sascha, do you also wanna be included?

I would also like to be included, if possible.

The more the merrier :D

Yours,
Linus Walleij

maintainer
#16 lore raw

RE: [PATCH v2 5/5] pinctrl: imx6ul: add IOMUXC SNVS pinctrl driver for i.MX 6ULL

In reply to Linus Walleij

Hi Linus,

Quoted 3 lines

-----Original Message-----
From: Linus Walleij [mailto:linus.walleij at linaro.org]
Sent: Tuesday, January 09, 2018 10:08 PM

....

Quoted 6 lines

Stefan, would you consider making a patch adding you, Dong Aisheng and Shawn Guo as maintainers in MAINTAINERS for drivers/pinctrl/freescale/* Documentation/devicetree/bindings/pinctrl/fsl,*
?

I'm okay to take that MAINTAINER work.
Thanks for the nomination.

Regards
Dong Aisheng

#5 lore raw

Re: [PATCH v2 1/5] pinctrl: imx: use struct imx_pinctrl_soc_info as a const

In reply to Stefan Agner
Quoted 6 lines · Stefan Agner

For some SoCs the struct imx_pinctrl_soc_info is passed through of_device_id.data which is const. Most variables are already const or otherwise not written. However, some fields are modified at runtime. Move those fields to the dynamically allocated struct imx_pinctrl.

Quoted 6 lines
Fixes b3060044e495 ("pinctrl: freescale: imx7d: make of_device_ids const")
Cc Shawn Guo <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Dong Aisheng <[email protected]>
Cc Gary Bisson <[email protected]>

Patch applied.

Yours,
Linus Walleij