linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] pinctrl: ingenic: cleanups
@ 2020-01-06 23:27 Paul Cercueil
  2020-01-06 23:27 ` [PATCH 1/5] pinctrl: ingenic: Remove platform ID table Paul Cercueil
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Paul Cercueil @ 2020-01-06 23:27 UTC (permalink / raw)
  To: Linus Walleij; +Cc: 周琰杰, od, linux-gpio, linux-kernel

Hi Linus,

I saw you merged Zhou's patchset, here are some cleanup patches for
pinctrl-ingenic that should be applied on top of his commits.

Cheers,
-Paul



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] pinctrl: ingenic: Remove platform ID table
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
@ 2020-01-06 23:27 ` Paul Cercueil
  2020-01-06 23:27 ` [PATCH 2/5] pinctrl: ingenic: Put ingenic_chip_info pointer in match data Paul Cercueil
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Paul Cercueil @ 2020-01-06 23:27 UTC (permalink / raw)
  To: Linus Walleij
  Cc: 周琰杰, od, linux-gpio, linux-kernel, Paul Cercueil

We enforce devicetree support in the Kconfig and all Ingenic boards
without exception probe their drivers from devicetree. The code path to
probe the driver from arch code can then be considered as dead code and
removed.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/pinctrl/pinctrl-ingenic.c | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 4b847906b711..10a94f2f8658 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -2369,9 +2369,6 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
 	struct ingenic_pinctrl *jzpc;
 	struct pinctrl_desc *pctl_desc;
 	void __iomem *base;
-	const struct platform_device_id *id = platform_get_device_id(pdev);
-	const struct of_device_id *of_id = of_match_device(
-			ingenic_pinctrl_of_match, dev);
 	const struct ingenic_chip_info *chip_info;
 	struct device_node *node;
 	unsigned int i;
@@ -2394,11 +2391,7 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
 	}
 
 	jzpc->dev = dev;
-
-	if (of_id)
-		jzpc->version = (enum jz_version)of_id->data;
-	else
-		jzpc->version = (enum jz_version)id->driver_data;
+	jzpc->version = (enum jz_version)of_device_get_match_data(dev);
 
 	if (jzpc->version >= ID_X1830)
 		chip_info = &x1830_chip_info;
@@ -2489,26 +2482,11 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct platform_device_id ingenic_pinctrl_ids[] = {
-	{ "jz4740-pinctrl", ID_JZ4740 },
-	{ "jz4725b-pinctrl", ID_JZ4725B },
-	{ "jz4760-pinctrl", ID_JZ4760 },
-	{ "jz4760b-pinctrl", ID_JZ4760B },
-	{ "jz4770-pinctrl", ID_JZ4770 },
-	{ "jz4780-pinctrl", ID_JZ4780 },
-	{ "x1000-pinctrl", ID_X1000 },
-	{ "x1000e-pinctrl", ID_X1000E },
-	{ "x1500-pinctrl", ID_X1500 },
-	{ "x1830-pinctrl", ID_X1830 },
-	{},
-};
-
 static struct platform_driver ingenic_pinctrl_driver = {
 	.driver = {
 		.name = "pinctrl-ingenic",
-		.of_match_table = of_match_ptr(ingenic_pinctrl_of_match),
+		.of_match_table = ingenic_pinctrl_of_match,
 	},
-	.id_table = ingenic_pinctrl_ids,
 };
 
 static int __init ingenic_pinctrl_drv_register(void)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] pinctrl: ingenic: Put ingenic_chip_info pointer in match data
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
  2020-01-06 23:27 ` [PATCH 1/5] pinctrl: ingenic: Remove platform ID table Paul Cercueil
@ 2020-01-06 23:27 ` Paul Cercueil
  2020-01-06 23:27 ` [PATCH 3/5] pinctrl: ingenic: Remove duplicated ingenic_chip_info structures Paul Cercueil
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Paul Cercueil @ 2020-01-06 23:27 UTC (permalink / raw)
  To: Linus Walleij
  Cc: 周琰杰, od, linux-gpio, linux-kernel, Paul Cercueil

Instead of passing a numeric ID as match data, and retrieve a pointer to
the ingenic_chip_info structure in an ugly succession of if/else in the
probe function, get the pointer to the ingenic_chip_info structure
directly from the match data, and store the numeric ID inside the
ingenic_chip_info structure.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/pinctrl/pinctrl-ingenic.c | 102 +++++++++++++-----------------
 1 file changed, 45 insertions(+), 57 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 10a94f2f8658..7a1d6a720b78 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -73,6 +73,7 @@ enum jz_version {
 struct ingenic_chip_info {
 	unsigned int num_chips;
 	unsigned int reg_offset;
+	enum jz_version version;
 
 	const struct group_desc *groups;
 	unsigned int num_groups;
@@ -88,7 +89,6 @@ struct ingenic_pinctrl {
 	struct regmap *map;
 	struct pinctrl_dev *pctl;
 	struct pinctrl_pin_desc *pdesc;
-	enum jz_version version;
 
 	const struct ingenic_chip_info *info;
 };
@@ -226,6 +226,7 @@ static const struct function_desc jz4740_functions[] = {
 static const struct ingenic_chip_info jz4740_chip_info = {
 	.num_chips = 4,
 	.reg_offset = 0x100,
+	.version = ID_JZ4740,
 	.groups = jz4740_groups,
 	.num_groups = ARRAY_SIZE(jz4740_groups),
 	.functions = jz4740_functions,
@@ -350,6 +351,7 @@ static const struct function_desc jz4725b_functions[] = {
 static const struct ingenic_chip_info jz4725b_chip_info = {
 	.num_chips = 4,
 	.reg_offset = 0x100,
+	.version = ID_JZ4725B,
 	.groups = jz4725b_groups,
 	.num_groups = ARRAY_SIZE(jz4725b_groups),
 	.functions = jz4725b_functions,
@@ -604,6 +606,7 @@ static const struct function_desc jz4760_functions[] = {
 static const struct ingenic_chip_info jz4760_chip_info = {
 	.num_chips = 6,
 	.reg_offset = 0x100,
+	.version = ID_JZ4760,
 	.groups = jz4760_groups,
 	.num_groups = ARRAY_SIZE(jz4760_groups),
 	.functions = jz4760_functions,
@@ -615,6 +618,7 @@ static const struct ingenic_chip_info jz4760_chip_info = {
 static const struct ingenic_chip_info jz4760b_chip_info = {
 	.num_chips = 6,
 	.reg_offset = 0x100,
+	.version = ID_JZ4760B,
 	.groups = jz4760_groups,
 	.num_groups = ARRAY_SIZE(jz4760_groups),
 	.functions = jz4760_functions,
@@ -894,6 +898,7 @@ static const struct function_desc jz4770_functions[] = {
 static const struct ingenic_chip_info jz4770_chip_info = {
 	.num_chips = 6,
 	.reg_offset = 0x100,
+	.version = ID_JZ4770,
 	.groups = jz4770_groups,
 	.num_groups = ARRAY_SIZE(jz4770_groups),
 	.functions = jz4770_functions,
@@ -1028,6 +1033,7 @@ static const struct function_desc jz4780_functions[] = {
 static const struct ingenic_chip_info jz4780_chip_info = {
 	.num_chips = 6,
 	.reg_offset = 0x100,
+	.version = ID_JZ4780,
 	.groups = jz4780_groups,
 	.num_groups = ARRAY_SIZE(jz4780_groups),
 	.functions = jz4780_functions,
@@ -1285,6 +1291,7 @@ static const struct function_desc x1000_functions[] = {
 static const struct ingenic_chip_info x1000_chip_info = {
 	.num_chips = 4,
 	.reg_offset = 0x100,
+	.version = ID_X1000,
 	.groups = x1000_groups,
 	.num_groups = ARRAY_SIZE(x1000_groups),
 	.functions = x1000_functions,
@@ -1296,6 +1303,7 @@ static const struct ingenic_chip_info x1000_chip_info = {
 static const struct ingenic_chip_info x1000e_chip_info = {
 	.num_chips = 4,
 	.reg_offset = 0x100,
+	.version = ID_X1000E,
 	.groups = x1000_groups,
 	.num_groups = ARRAY_SIZE(x1000_groups),
 	.functions = x1000_functions,
@@ -1409,6 +1417,7 @@ static const struct function_desc x1500_functions[] = {
 static const struct ingenic_chip_info x1500_chip_info = {
 	.num_chips = 4,
 	.reg_offset = 0x100,
+	.version = ID_X1500,
 	.groups = x1500_groups,
 	.num_groups = ARRAY_SIZE(x1500_groups),
 	.functions = x1500_functions,
@@ -1624,6 +1633,7 @@ static const struct function_desc x1830_functions[] = {
 static const struct ingenic_chip_info x1830_chip_info = {
 	.num_chips = 4,
 	.reg_offset = 0x1000,
+	.version = ID_X1830,
 	.groups = x1830_groups,
 	.num_groups = ARRAY_SIZE(x1830_groups),
 	.functions = x1830_functions,
@@ -1682,7 +1692,7 @@ static inline bool ingenic_gpio_get_value(struct ingenic_gpio_chip *jzgc,
 static void ingenic_gpio_set_value(struct ingenic_gpio_chip *jzgc,
 				   u8 offset, int value)
 {
-	if (jzgc->jzpc->version >= ID_JZ4760)
+	if (jzgc->jzpc->info->version >= ID_JZ4760)
 		ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_PAT0, offset, !!value);
 	else
 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, offset, !!value);
@@ -1693,7 +1703,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
 {
 	u8 reg1, reg2;
 
-	if (jzgc->jzpc->version >= ID_JZ4760) {
+	if (jzgc->jzpc->info->version >= ID_JZ4760) {
 		reg1 = JZ4760_GPIO_PAT1;
 		reg2 = JZ4760_GPIO_PAT0;
 	} else {
@@ -1703,7 +1713,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
 
 	switch (type) {
 	case IRQ_TYPE_EDGE_RISING:
-		if (jzgc->jzpc->version >= ID_X1000) {
+		if (jzgc->jzpc->info->version >= ID_X1000) {
 			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, true);
 			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, true);
 			ingenic_gpio_shadow_set_bit_load(jzgc);
@@ -1713,7 +1723,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
 		}
 		break;
 	case IRQ_TYPE_EDGE_FALLING:
-		if (jzgc->jzpc->version >= ID_X1000) {
+		if (jzgc->jzpc->info->version >= ID_X1000) {
 			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, false);
 			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, true);
 			ingenic_gpio_shadow_set_bit_load(jzgc);
@@ -1723,7 +1733,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
 		}
 		break;
 	case IRQ_TYPE_LEVEL_HIGH:
-		if (jzgc->jzpc->version >= ID_X1000) {
+		if (jzgc->jzpc->info->version >= ID_X1000) {
 			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, true);
 			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, false);
 			ingenic_gpio_shadow_set_bit_load(jzgc);
@@ -1734,7 +1744,7 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
 		break;
 	case IRQ_TYPE_LEVEL_LOW:
 	default:
-		if (jzgc->jzpc->version >= ID_X1000) {
+		if (jzgc->jzpc->info->version >= ID_X1000) {
 			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, false);
 			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, false);
 			ingenic_gpio_shadow_set_bit_load(jzgc);
@@ -1768,7 +1778,7 @@ static void ingenic_gpio_irq_enable(struct irq_data *irqd)
 	struct ingenic_gpio_chip *jzgc = gpiochip_get_data(gc);
 	int irq = irqd->hwirq;
 
-	if (jzgc->jzpc->version >= ID_JZ4760)
+	if (jzgc->jzpc->info->version >= ID_JZ4760)
 		ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, true);
 	else
 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, true);
@@ -1784,7 +1794,7 @@ static void ingenic_gpio_irq_disable(struct irq_data *irqd)
 
 	ingenic_gpio_irq_mask(irqd);
 
-	if (jzgc->jzpc->version >= ID_JZ4760)
+	if (jzgc->jzpc->info->version >= ID_JZ4760)
 		ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_INT, irq, false);
 	else
 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_SELECT, irq, false);
@@ -1809,7 +1819,7 @@ static void ingenic_gpio_irq_ack(struct irq_data *irqd)
 			irq_set_type(jzgc, irq, IRQ_TYPE_EDGE_RISING);
 	}
 
-	if (jzgc->jzpc->version >= ID_JZ4760)
+	if (jzgc->jzpc->info->version >= ID_JZ4760)
 		ingenic_gpio_set_bit(jzgc, JZ4760_GPIO_FLAG, irq, false);
 	else
 		ingenic_gpio_set_bit(jzgc, JZ4740_GPIO_DATA, irq, true);
@@ -1866,7 +1876,7 @@ static void ingenic_gpio_irq_handler(struct irq_desc *desc)
 
 	chained_irq_enter(irq_chip, desc);
 
-	if (jzgc->jzpc->version >= ID_JZ4760)
+	if (jzgc->jzpc->info->version >= ID_JZ4760)
 		flag = ingenic_gpio_read_reg(jzgc, JZ4760_GPIO_FLAG);
 	else
 		flag = ingenic_gpio_read_reg(jzgc, JZ4740_GPIO_FLAG);
@@ -1948,7 +1958,7 @@ static int ingenic_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
 	struct ingenic_pinctrl *jzpc = jzgc->jzpc;
 	unsigned int pin = gc->base + offset;
 
-	if (jzpc->version >= ID_JZ4760)
+	if (jzpc->info->version >= ID_JZ4760)
 		return ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PAT1);
 
 	if (ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_SELECT))
@@ -1974,13 +1984,13 @@ static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
 	dev_dbg(jzpc->dev, "set pin P%c%u to function %u\n",
 			'A' + offt, idx, func);
 
-	if (jzpc->version >= ID_X1000) {
+	if (jzpc->info->version >= ID_X1000) {
 		ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
 		ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, false);
 		ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
 		ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, func & 0x1);
 		ingenic_shadow_config_pin_load(jzpc, pin);
-	} else if (jzpc->version >= ID_JZ4760) {
+	} else if (jzpc->info->version >= ID_JZ4760) {
 		ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
 		ingenic_config_pin(jzpc, pin, GPIO_MSK, false);
 		ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, func & 0x2);
@@ -2033,12 +2043,12 @@ static int ingenic_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
 	dev_dbg(pctldev->dev, "set pin P%c%u to %sput\n",
 			'A' + offt, idx, input ? "in" : "out");
 
-	if (jzpc->version >= ID_X1000) {
+	if (jzpc->info->version >= ID_X1000) {
 		ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
 		ingenic_shadow_config_pin(jzpc, pin, GPIO_MSK, true);
 		ingenic_shadow_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
 		ingenic_shadow_config_pin_load(jzpc, pin);
-	} else if (jzpc->version >= ID_JZ4760) {
+	} else if (jzpc->info->version >= ID_JZ4760) {
 		ingenic_config_pin(jzpc, pin, JZ4760_GPIO_INT, false);
 		ingenic_config_pin(jzpc, pin, GPIO_MSK, true);
 		ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT1, input);
@@ -2068,7 +2078,7 @@ static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
 	unsigned int offt = pin / PINS_PER_GPIO_CHIP;
 	bool pull;
 
-	if (jzpc->version >= ID_JZ4760)
+	if (jzpc->info->version >= ID_JZ4760)
 		pull = !ingenic_get_pin_config(jzpc, pin, JZ4760_GPIO_PEN);
 	else
 		pull = !ingenic_get_pin_config(jzpc, pin, JZ4740_GPIO_PULL_DIS);
@@ -2100,7 +2110,7 @@ static int ingenic_pinconf_get(struct pinctrl_dev *pctldev,
 static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
 		unsigned int pin, unsigned int bias)
 {
-	if (jzpc->version >= ID_X1830) {
+	if (jzpc->info->version >= ID_X1830) {
 		unsigned int idx = pin % PINS_PER_GPIO_CHIP;
 		unsigned int half = PINS_PER_GPIO_CHIP / 2;
 		unsigned int idxh = pin % half * 2;
@@ -2118,7 +2128,7 @@ static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
 					REG_SET(X1830_GPIO_PEH), bias << idxh);
 		}
 
-	} else if (jzpc->version >= ID_JZ4760) {
+	} else if (jzpc->info->version >= ID_JZ4760) {
 		ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PEN, !bias);
 	} else {
 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_PULL_DIS, !bias);
@@ -2128,7 +2138,7 @@ static void ingenic_set_bias(struct ingenic_pinctrl *jzpc,
 static void ingenic_set_output_level(struct ingenic_pinctrl *jzpc,
 				     unsigned int pin, bool high)
 {
-	if (jzpc->version >= ID_JZ4760)
+	if (jzpc->info->version >= ID_JZ4760)
 		ingenic_config_pin(jzpc, pin, JZ4760_GPIO_PAT0, high);
 	else
 		ingenic_config_pin(jzpc, pin, JZ4740_GPIO_DATA, high);
@@ -2258,20 +2268,6 @@ static const struct regmap_config ingenic_pinctrl_regmap_config = {
 	.reg_stride = 4,
 };
 
-static const struct of_device_id ingenic_pinctrl_of_match[] = {
-	{ .compatible = "ingenic,jz4740-pinctrl", .data = (void *) ID_JZ4740 },
-	{ .compatible = "ingenic,jz4725b-pinctrl", .data = (void *)ID_JZ4725B },
-	{ .compatible = "ingenic,jz4760-pinctrl", .data = (void *) ID_JZ4760 },
-	{ .compatible = "ingenic,jz4760b-pinctrl", .data = (void *) ID_JZ4760B },
-	{ .compatible = "ingenic,jz4770-pinctrl", .data = (void *) ID_JZ4770 },
-	{ .compatible = "ingenic,jz4780-pinctrl", .data = (void *) ID_JZ4780 },
-	{ .compatible = "ingenic,x1000-pinctrl", .data = (void *) ID_X1000 },
-	{ .compatible = "ingenic,x1000e-pinctrl", .data = (void *) ID_X1000E },
-	{ .compatible = "ingenic,x1500-pinctrl", .data = (void *) ID_X1500 },
-	{ .compatible = "ingenic,x1830-pinctrl", .data = (void *) ID_X1830 },
-	{},
-};
-
 static const struct of_device_id ingenic_gpio_of_match[] __initconst = {
 	{ .compatible = "ingenic,jz4740-gpio", },
 	{ .compatible = "ingenic,jz4760-gpio", },
@@ -2391,29 +2387,7 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
 	}
 
 	jzpc->dev = dev;
-	jzpc->version = (enum jz_version)of_device_get_match_data(dev);
-
-	if (jzpc->version >= ID_X1830)
-		chip_info = &x1830_chip_info;
-	else if (jzpc->version >= ID_X1500)
-		chip_info = &x1500_chip_info;
-	else if (jzpc->version >= ID_X1000E)
-		chip_info = &x1000e_chip_info;
-	else if (jzpc->version >= ID_X1000)
-		chip_info = &x1000_chip_info;
-	else if (jzpc->version >= ID_JZ4780)
-		chip_info = &jz4780_chip_info;
-	else if (jzpc->version >= ID_JZ4770)
-		chip_info = &jz4770_chip_info;
-	else if (jzpc->version >= ID_JZ4760B)
-		chip_info = &jz4760b_chip_info;
-	else if (jzpc->version >= ID_JZ4760)
-		chip_info = &jz4760_chip_info;
-	else if (jzpc->version >= ID_JZ4725B)
-		chip_info = &jz4725b_chip_info;
-	else
-		chip_info = &jz4740_chip_info;
-	jzpc->info = chip_info;
+	jzpc->info = chip_info = of_device_get_match_data(dev);
 
 	pctl_desc = devm_kzalloc(&pdev->dev, sizeof(*pctl_desc), GFP_KERNEL);
 	if (!pctl_desc)
@@ -2482,6 +2456,20 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id ingenic_pinctrl_of_match[] = {
+	{ .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info },
+	{ .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info },
+	{ .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info },
+	{ .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760b_chip_info },
+	{ .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info },
+	{ .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info },
+	{ .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info },
+	{ .compatible = "ingenic,x1000e-pinctrl", .data = &x1000e_chip_info },
+	{ .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info },
+	{ .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info },
+	{},
+};
+
 static struct platform_driver ingenic_pinctrl_driver = {
 	.driver = {
 		.name = "pinctrl-ingenic",
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] pinctrl: ingenic: Remove duplicated ingenic_chip_info structures
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
  2020-01-06 23:27 ` [PATCH 1/5] pinctrl: ingenic: Remove platform ID table Paul Cercueil
  2020-01-06 23:27 ` [PATCH 2/5] pinctrl: ingenic: Put ingenic_chip_info pointer in match data Paul Cercueil
@ 2020-01-06 23:27 ` Paul Cercueil
  2020-01-06 23:27 ` [PATCH 4/5] pinctrl: ingenic: Factorize irq_set_type function Paul Cercueil
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Paul Cercueil @ 2020-01-06 23:27 UTC (permalink / raw)
  To: Linus Walleij
  Cc: 周琰杰, od, linux-gpio, linux-kernel, Paul Cercueil

Until there is the need to handle the JZ4760B and X1000E differently
there is no reason to use a separate ingenic_chip_info since the data
it contains is the same than for the JZ4760 and X1000 respectively.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/pinctrl/pinctrl-ingenic.c | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 7a1d6a720b78..7f73f27cce91 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -61,11 +61,9 @@ enum jz_version {
 	ID_JZ4740,
 	ID_JZ4725B,
 	ID_JZ4760,
-	ID_JZ4760B,
 	ID_JZ4770,
 	ID_JZ4780,
 	ID_X1000,
-	ID_X1000E,
 	ID_X1500,
 	ID_X1830,
 };
@@ -615,18 +613,6 @@ static const struct ingenic_chip_info jz4760_chip_info = {
 	.pull_downs = jz4760_pull_downs,
 };
 
-static const struct ingenic_chip_info jz4760b_chip_info = {
-	.num_chips = 6,
-	.reg_offset = 0x100,
-	.version = ID_JZ4760B,
-	.groups = jz4760_groups,
-	.num_groups = ARRAY_SIZE(jz4760_groups),
-	.functions = jz4760_functions,
-	.num_functions = ARRAY_SIZE(jz4760_functions),
-	.pull_ups = jz4760_pull_ups,
-	.pull_downs = jz4760_pull_downs,
-};
-
 static const u32 jz4770_pull_ups[6] = {
 	0x3fffffff, 0xfff0030c, 0xffffffff, 0xffff4fff, 0xfffffb7c, 0xffa7f00f,
 };
@@ -1300,18 +1286,6 @@ static const struct ingenic_chip_info x1000_chip_info = {
 	.pull_downs = x1000_pull_downs,
 };
 
-static const struct ingenic_chip_info x1000e_chip_info = {
-	.num_chips = 4,
-	.reg_offset = 0x100,
-	.version = ID_X1000E,
-	.groups = x1000_groups,
-	.num_groups = ARRAY_SIZE(x1000_groups),
-	.functions = x1000_functions,
-	.num_functions = ARRAY_SIZE(x1000_functions),
-	.pull_ups = x1000_pull_ups,
-	.pull_downs = x1000_pull_downs,
-};
-
 static int x1500_uart0_data_pins[] = { 0x4a, 0x4b, };
 static int x1500_uart0_hwflow_pins[] = { 0x4c, 0x4d, };
 static int x1500_uart1_data_a_pins[] = { 0x04, 0x05, };
@@ -2460,11 +2434,11 @@ static const struct of_device_id ingenic_pinctrl_of_match[] = {
 	{ .compatible = "ingenic,jz4740-pinctrl", .data = &jz4740_chip_info },
 	{ .compatible = "ingenic,jz4725b-pinctrl", .data = &jz4725b_chip_info },
 	{ .compatible = "ingenic,jz4760-pinctrl", .data = &jz4760_chip_info },
-	{ .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760b_chip_info },
+	{ .compatible = "ingenic,jz4760b-pinctrl", .data = &jz4760_chip_info },
 	{ .compatible = "ingenic,jz4770-pinctrl", .data = &jz4770_chip_info },
 	{ .compatible = "ingenic,jz4780-pinctrl", .data = &jz4780_chip_info },
 	{ .compatible = "ingenic,x1000-pinctrl", .data = &x1000_chip_info },
-	{ .compatible = "ingenic,x1000e-pinctrl", .data = &x1000e_chip_info },
+	{ .compatible = "ingenic,x1000e-pinctrl", .data = &x1000_chip_info },
 	{ .compatible = "ingenic,x1500-pinctrl", .data = &x1500_chip_info },
 	{ .compatible = "ingenic,x1830-pinctrl", .data = &x1830_chip_info },
 	{},
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] pinctrl: ingenic: Factorize irq_set_type function
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
                   ` (2 preceding siblings ...)
  2020-01-06 23:27 ` [PATCH 3/5] pinctrl: ingenic: Remove duplicated ingenic_chip_info structures Paul Cercueil
@ 2020-01-06 23:27 ` Paul Cercueil
  2020-01-06 23:27 ` [PATCH 5/5] pinctrl: ingenic: Use devm_platform_ioremap_resource() Paul Cercueil
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Paul Cercueil @ 2020-01-06 23:27 UTC (permalink / raw)
  To: Linus Walleij
  Cc: 周琰杰, od, linux-gpio, linux-kernel, Paul Cercueil

Simplify the code of the driver's irq_set_type() function by doing some
factorization. The behaviour is unchanged.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/pinctrl/pinctrl-ingenic.c | 64 ++++++++++++-------------------
 1 file changed, 24 insertions(+), 40 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 7f73f27cce91..419717fc7793 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -1676,58 +1676,42 @@ static void irq_set_type(struct ingenic_gpio_chip *jzgc,
 		u8 offset, unsigned int type)
 {
 	u8 reg1, reg2;
-
-	if (jzgc->jzpc->info->version >= ID_JZ4760) {
-		reg1 = JZ4760_GPIO_PAT1;
-		reg2 = JZ4760_GPIO_PAT0;
-	} else {
-		reg1 = JZ4740_GPIO_TRIG;
-		reg2 = JZ4740_GPIO_DIR;
-	}
+	bool val1, val2;
 
 	switch (type) {
 	case IRQ_TYPE_EDGE_RISING:
-		if (jzgc->jzpc->info->version >= ID_X1000) {
-			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, true);
-			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, true);
-			ingenic_gpio_shadow_set_bit_load(jzgc);
-		} else {
-			ingenic_gpio_set_bit(jzgc, reg2, offset, true);
-			ingenic_gpio_set_bit(jzgc, reg1, offset, true);
-		}
+		val1 = val2 = true;
 		break;
 	case IRQ_TYPE_EDGE_FALLING:
-		if (jzgc->jzpc->info->version >= ID_X1000) {
-			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, false);
-			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, true);
-			ingenic_gpio_shadow_set_bit_load(jzgc);
-		} else {
-			ingenic_gpio_set_bit(jzgc, reg2, offset, false);
-			ingenic_gpio_set_bit(jzgc, reg1, offset, true);
-		}
+		val1 = false;
+		val2 = true;
 		break;
 	case IRQ_TYPE_LEVEL_HIGH:
-		if (jzgc->jzpc->info->version >= ID_X1000) {
-			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, true);
-			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, false);
-			ingenic_gpio_shadow_set_bit_load(jzgc);
-		} else {
-			ingenic_gpio_set_bit(jzgc, reg2, offset, true);
-			ingenic_gpio_set_bit(jzgc, reg1, offset, false);
-		}
+		val1 = true;
+		val2 = false;
 		break;
 	case IRQ_TYPE_LEVEL_LOW:
 	default:
-		if (jzgc->jzpc->info->version >= ID_X1000) {
-			ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, false);
-			ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, false);
-			ingenic_gpio_shadow_set_bit_load(jzgc);
-		} else {
-			ingenic_gpio_set_bit(jzgc, reg2, offset, false);
-			ingenic_gpio_set_bit(jzgc, reg1, offset, false);
-		}
+		val1 = val2 = false;
 		break;
 	}
+
+	if (jzgc->jzpc->info->version >= ID_JZ4760) {
+		reg1 = JZ4760_GPIO_PAT1;
+		reg2 = JZ4760_GPIO_PAT0;
+	} else {
+		reg1 = JZ4740_GPIO_TRIG;
+		reg2 = JZ4740_GPIO_DIR;
+	}
+
+	if (jzgc->jzpc->info->version >= ID_X1000) {
+		ingenic_gpio_shadow_set_bit(jzgc, reg2, offset, val1);
+		ingenic_gpio_shadow_set_bit(jzgc, reg1, offset, val2);
+		ingenic_gpio_shadow_set_bit_load(jzgc);
+	} else {
+		ingenic_gpio_set_bit(jzgc, reg2, offset, val1);
+		ingenic_gpio_set_bit(jzgc, reg1, offset, val2);
+	}
 }
 
 static void ingenic_gpio_irq_mask(struct irq_data *irqd)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] pinctrl: ingenic: Use devm_platform_ioremap_resource()
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
                   ` (3 preceding siblings ...)
  2020-01-06 23:27 ` [PATCH 4/5] pinctrl: ingenic: Factorize irq_set_type function Paul Cercueil
@ 2020-01-06 23:27 ` Paul Cercueil
  2020-01-07 12:35 ` [PATCH 0/5] pinctrl: ingenic: cleanups Linus Walleij
  2020-01-07 14:11 ` Zhou Yanjie
  6 siblings, 0 replies; 10+ messages in thread
From: Paul Cercueil @ 2020-01-06 23:27 UTC (permalink / raw)
  To: Linus Walleij
  Cc: 周琰杰, od, linux-gpio, linux-kernel, Paul Cercueil

Use devm_platform_ioremap_resource() instead of platform_get_resource +
devm_ioremap_resource.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/pinctrl/pinctrl-ingenic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 419717fc7793..96f04d121ebd 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -2332,8 +2332,7 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
 	if (!jzpc)
 		return -ENOMEM;
 
-	base = devm_ioremap_resource(dev,
-			platform_get_resource(pdev, IORESOURCE_MEM, 0));
+	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] pinctrl: ingenic: cleanups
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
                   ` (4 preceding siblings ...)
  2020-01-06 23:27 ` [PATCH 5/5] pinctrl: ingenic: Use devm_platform_ioremap_resource() Paul Cercueil
@ 2020-01-07 12:35 ` Linus Walleij
  2020-01-07 14:23   ` Zhou Yanjie
  2020-01-07 14:11 ` Zhou Yanjie
  6 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2020-01-07 12:35 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: 周琰杰, od, open list:GPIO SUBSYSTEM, linux-kernel

On Tue, Jan 7, 2020 at 12:27 AM Paul Cercueil <paul@crapouillou.net> wrote:

> I saw you merged Zhou's patchset, here are some cleanup patches for
> pinctrl-ingenic that should be applied on top of his commits.

All five patches applied!

Zhou can you test the result? I am pushing the devel branch
out and as soon as it builds cleanly I will push it for-next.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] pinctrl: ingenic: cleanups
  2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
                   ` (5 preceding siblings ...)
  2020-01-07 12:35 ` [PATCH 0/5] pinctrl: ingenic: cleanups Linus Walleij
@ 2020-01-07 14:11 ` Zhou Yanjie
  6 siblings, 0 replies; 10+ messages in thread
From: Zhou Yanjie @ 2020-01-07 14:11 UTC (permalink / raw)
  To: Paul Cercueil, Linus Walleij; +Cc: od, linux-gpio, linux-kernel

Hi Linus,

On 2020年01月07日 07:27, Paul Cercueil wrote:
> Hi Linus,
>
> I saw you merged Zhou's patchset, here are some cleanup patches for
> pinctrl-ingenic that should be applied on top of his commits.

I agree with Paul, these cleanups look pretty good.

>
> Cheers,
> -Paul
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] pinctrl: ingenic: cleanups
  2020-01-07 12:35 ` [PATCH 0/5] pinctrl: ingenic: cleanups Linus Walleij
@ 2020-01-07 14:23   ` Zhou Yanjie
  2020-01-08 11:18     ` Zhou Yanjie
  0 siblings, 1 reply; 10+ messages in thread
From: Zhou Yanjie @ 2020-01-07 14:23 UTC (permalink / raw)
  To: Linus Walleij, Paul Cercueil; +Cc: od, open list:GPIO SUBSYSTEM, linux-kernel

Hi Linus,

On 2020年01月07日 20:35, Linus Walleij wrote:
> On Tue, Jan 7, 2020 at 12:27 AM Paul Cercueil <paul@crapouillou.net> wrote:
>
>> I saw you merged Zhou's patchset, here are some cleanup patches for
>> pinctrl-ingenic that should be applied on top of his commits.
> All five patches applied!
>
> Zhou can you test the result? I am pushing the devel branch
> out and as soon as it builds cleanly I will push it for-next.

I tested it on JZ4760 and JZ4780. The hardware of X1000 and X1830 is not 
in my hand right now, I can test them tomorrow, but from the view of the 
code, it should work fine. You can add:
Tested-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>

Thanks and best regards!

>
> Yours,
> Linus Walleij


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] pinctrl: ingenic: cleanups
  2020-01-07 14:23   ` Zhou Yanjie
@ 2020-01-08 11:18     ` Zhou Yanjie
  0 siblings, 0 replies; 10+ messages in thread
From: Zhou Yanjie @ 2020-01-08 11:18 UTC (permalink / raw)
  To: Linus Walleij, Paul Cercueil; +Cc: od, open list:GPIO SUBSYSTEM, linux-kernel

Hi Linus & Paul,

I have tested X1000 and X1830 and they both work fine.

Thanks and best regards!

On 2020年01月07日 22:23, Zhou Yanjie wrote:
> Hi Linus,
>
> On 2020年01月07日 20:35, Linus Walleij wrote:
>> On Tue, Jan 7, 2020 at 12:27 AM Paul Cercueil <paul@crapouillou.net> 
>> wrote:
>>
>>> I saw you merged Zhou's patchset, here are some cleanup patches for
>>> pinctrl-ingenic that should be applied on top of his commits.
>> All five patches applied!
>>
>> Zhou can you test the result? I am pushing the devel branch
>> out and as soon as it builds cleanly I will push it for-next.
>
> I tested it on JZ4760 and JZ4780. The hardware of X1000 and X1830 is 
> not in my hand right now, I can test them tomorrow, but from the view 
> of the code, it should work fine. You can add:
> Tested-by: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
>
> Thanks and best regards!
>
>>
>> Yours,
>> Linus Walleij
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-01-08 11:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06 23:27 [PATCH 0/5] pinctrl: ingenic: cleanups Paul Cercueil
2020-01-06 23:27 ` [PATCH 1/5] pinctrl: ingenic: Remove platform ID table Paul Cercueil
2020-01-06 23:27 ` [PATCH 2/5] pinctrl: ingenic: Put ingenic_chip_info pointer in match data Paul Cercueil
2020-01-06 23:27 ` [PATCH 3/5] pinctrl: ingenic: Remove duplicated ingenic_chip_info structures Paul Cercueil
2020-01-06 23:27 ` [PATCH 4/5] pinctrl: ingenic: Factorize irq_set_type function Paul Cercueil
2020-01-06 23:27 ` [PATCH 5/5] pinctrl: ingenic: Use devm_platform_ioremap_resource() Paul Cercueil
2020-01-07 12:35 ` [PATCH 0/5] pinctrl: ingenic: cleanups Linus Walleij
2020-01-07 14:23   ` Zhou Yanjie
2020-01-08 11:18     ` Zhou Yanjie
2020-01-07 14:11 ` Zhou Yanjie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).