Re: [PATCH v3 06/10] pinctrl: Ingenic: Add pinctrl driver for JZ4730.

2021-03-25 Thread Zhou Yanjie



On 2021/3/23 上午2:17, Paul Cercueil wrote:



Le mer. 17 mars 2021 à 17:58, 周琰杰 (Zhou Yanjie) 
 a écrit :

Add support for probing the pinctrl-ingenic driver on the
JZ4730 SoC from Ingenic.

This driver is derived from Paul Boddie. It is worth to
noting that the JZ4730 SoC is special in having two control
registers (upper/lower), so add code to handle the JZ4730
specific register offsets and some register pairs which have
2 bits for each GPIO pin.

Tested-by: H. Nikolaus Schaller   # on Letux400
Co-developed-by: Paul Boddie 
Signed-off-by: Paul Boddie 
Signed-off-by: H. Nikolaus Schaller 
Signed-off-by: 周琰杰 (Zhou Yanjie) 
---

Notes:
    v3:
    New patch.

 drivers/pinctrl/pinctrl-ingenic.c | 222 
+++---

 1 file changed, 206 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c 
b/drivers/pinctrl/pinctrl-ingenic.c

index b8165f5..25458d6 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -3,8 +3,8 @@
  * Ingenic SoCs pinctrl driver
  *
  * Copyright (c) 2017 Paul Cercueil 
- * Copyright (c) 2019 周琰杰 (Zhou Yanjie) 
  * Copyright (c) 2017, 2019 Paul Boddie 
+ * Copyright (c) 2019, 2020 周琰杰 (Zhou Yanjie) 


  */

 #include 
@@ -29,6 +29,17 @@
 #define GPIO_PIN    0x00
 #define GPIO_MSK    0x20

+#define JZ4730_GPIO_DATA    0x00
+#define JZ4730_GPIO_GPDIR    0x04
+#define JZ4730_GPIO_GPPUR    0x0c
+#define JZ4730_GPIO_GPALR    0x10
+#define JZ4730_GPIO_GPAUR    0x14
+#define JZ4730_GPIO_GPIDLR    0x18
+#define JZ4730_GPIO_GPIDUR    0x1c
+#define JZ4730_GPIO_GPIER    0x20
+#define JZ4730_GPIO_GPIMR    0x24
+#define JZ4730_GPIO_GPFR    0x28
+
 #define JZ4740_GPIO_DATA    0x10
 #define JZ4740_GPIO_PULL_DIS    0x30
 #define JZ4740_GPIO_FUNC    0x40
@@ -57,6 +68,7 @@
 #define GPIO_PULL_DOWN    2

 #define PINS_PER_GPIO_CHIP    32
+#define JZ4730_PINS_PER_PAIRED_REG    16

 #define INGENIC_PIN_GROUP_FUNCS(name, id, funcs)    \
 {    \
@@ -70,6 +82,7 @@
 INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func))

 enum jz_version {
+    ID_JZ4730,
 ID_JZ4740,
 ID_JZ4725B,
 ID_JZ4760,
@@ -110,6 +123,96 @@ struct ingenic_gpio_chip {
 unsigned int irq, reg_base;
 };

+static const u32 jz4730_pull_ups[4] = {
+    0x3fa3320f, 0xf200, 0x, 0x,
+};
+
+static const u32 jz4730_pull_downs[4] = {
+    0x0df0, 0x0dff, 0x, 0x,
+};
+
+static int jz4730_mmc_1bit_pins[] = { 0x27, 0x26, 0x22, };
+static int jz4730_mmc_4bit_pins[] = { 0x23, 0x24, 0x25, };
+static int jz4730_uart0_data_pins[] = { 0x7e, 0x7f, };
+static int jz4730_uart1_data_pins[] = { 0x18, 0x19, };
+static int jz4730_uart2_data_pins[] = { 0x6f, 0x7d, };
+static int jz4730_uart3_data_pins[] = { 0x10, 0x15, };
+static int jz4730_uart3_hwflow_pins[] = { 0x11, 0x17, };
+static int jz4730_lcd_8bit_pins[] = {
+    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x3a, 0x39, 0x38,
+};
+static int jz4730_lcd_16bit_pins[] = {
+    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3b,
+};
+static int jz4730_lcd_16bit_tft_pins[] = { 0x3e, 0x3f, 0x3d, 0x3c, };
+static int jz4730_nand_cs1_pins[] = { 0x53, };
+static int jz4730_nand_cs2_pins[] = { 0x54, };
+static int jz4730_nand_cs3_pins[] = { 0x55, };
+static int jz4730_nand_cs4_pins[] = { 0x56, };
+static int jz4730_nand_cs5_pins[] = { 0x57, };
+static int jz4730_pwm_pwm0_pins[] = { 0x5e, };
+static int jz4730_pwm_pwm1_pins[] = { 0x5f, };
+
+static u8 jz4730_lcd_8bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 
2, };

+
+static const struct group_desc jz4730_groups[] = {
+    INGENIC_PIN_GROUP("mmc-1bit", jz4730_mmc_1bit, 1),
+    INGENIC_PIN_GROUP("mmc-4bit", jz4730_mmc_4bit, 1),
+    INGENIC_PIN_GROUP("uart0-data", jz4730_uart0_data, 1),
+    INGENIC_PIN_GROUP("uart1-data", jz4730_uart1_data, 1),
+    INGENIC_PIN_GROUP("uart2-data", jz4730_uart2_data, 1),
+    INGENIC_PIN_GROUP("uart3-data", jz4730_uart3_data, 1),
+    INGENIC_PIN_GROUP("uart3-hwflow", jz4730_uart3_hwflow, 1),
+    INGENIC_PIN_GROUP_FUNCS("lcd-8bit", jz4730_lcd_8bit, 
jz4730_lcd_8bit_funcs),

+    INGENIC_PIN_GROUP("lcd-16bit", jz4730_lcd_16bit, 1),
+    INGENIC_PIN_GROUP("lcd-16bit-tft", jz4730_lcd_16bit_tft, 1),
+    INGENIC_PIN_GROUP("nand-cs1", jz4730_nand_cs1, 1),
+    INGENIC_PIN_GROUP("nand-cs2", jz4730_nand_cs2, 1),
+    INGENIC_PIN_GROUP("nand-cs3", jz4730_nand_cs3, 1),
+    INGENIC_PIN_GROUP("nand-cs4", jz4730_nand_cs4, 1),
+    INGENIC_PIN_GROUP("nand-cs5", jz4730_nand_cs5, 1),
+    INGENIC_PIN_GROUP("pwm0", jz4730_pwm_pwm0, 1),
+    INGENIC_PIN_GROUP("pwm1", jz4730_pwm_pwm1, 1),
+};
+
+static const char *jz4730_mmc_groups[] = { "mmc-1bit", "mmc-4bit", };
+static const char *jz4730_uart0_groups[] = { "uart0-data", };
+static const char *jz4730_uart1_groups[] = { "uart1-data", };
+static const char *jz4730_uart2_groups[] = { 

Re: [PATCH v3 06/10] pinctrl: Ingenic: Add pinctrl driver for JZ4730.

2021-03-22 Thread Paul Cercueil




Le mer. 17 mars 2021 à 17:58, 周琰杰 (Zhou Yanjie) 
 a écrit :

Add support for probing the pinctrl-ingenic driver on the
JZ4730 SoC from Ingenic.

This driver is derived from Paul Boddie. It is worth to
noting that the JZ4730 SoC is special in having two control
registers (upper/lower), so add code to handle the JZ4730
specific register offsets and some register pairs which have
2 bits for each GPIO pin.

Tested-by: H. Nikolaus Schaller   # on Letux400
Co-developed-by: Paul Boddie 
Signed-off-by: Paul Boddie 
Signed-off-by: H. Nikolaus Schaller 
Signed-off-by: 周琰杰 (Zhou Yanjie) 
---

Notes:
v3:
New patch.

 drivers/pinctrl/pinctrl-ingenic.c | 222 
+++---

 1 file changed, 206 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c 
b/drivers/pinctrl/pinctrl-ingenic.c

index b8165f5..25458d6 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -3,8 +3,8 @@
  * Ingenic SoCs pinctrl driver
  *
  * Copyright (c) 2017 Paul Cercueil 
- * Copyright (c) 2019 周琰杰 (Zhou Yanjie) 


  * Copyright (c) 2017, 2019 Paul Boddie 
+ * Copyright (c) 2019, 2020 周琰杰 (Zhou Yanjie) 


  */

 #include 
@@ -29,6 +29,17 @@
 #define GPIO_PIN   0x00
 #define GPIO_MSK   0x20

+#define JZ4730_GPIO_DATA   0x00
+#define JZ4730_GPIO_GPDIR  0x04
+#define JZ4730_GPIO_GPPUR  0x0c
+#define JZ4730_GPIO_GPALR  0x10
+#define JZ4730_GPIO_GPAUR  0x14
+#define JZ4730_GPIO_GPIDLR 0x18
+#define JZ4730_GPIO_GPIDUR 0x1c
+#define JZ4730_GPIO_GPIER  0x20
+#define JZ4730_GPIO_GPIMR  0x24
+#define JZ4730_GPIO_GPFR   0x28
+
 #define JZ4740_GPIO_DATA   0x10
 #define JZ4740_GPIO_PULL_DIS   0x30
 #define JZ4740_GPIO_FUNC   0x40
@@ -57,6 +68,7 @@
 #define GPIO_PULL_DOWN 2

 #define PINS_PER_GPIO_CHIP 32
+#define JZ4730_PINS_PER_PAIRED_REG 16

 #define INGENIC_PIN_GROUP_FUNCS(name, id, funcs)   \
{   \
@@ -70,6 +82,7 @@
INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func))

 enum jz_version {
+   ID_JZ4730,
ID_JZ4740,
ID_JZ4725B,
ID_JZ4760,
@@ -110,6 +123,96 @@ struct ingenic_gpio_chip {
unsigned int irq, reg_base;
 };

+static const u32 jz4730_pull_ups[4] = {
+   0x3fa3320f, 0xf200, 0x, 0x,
+};
+
+static const u32 jz4730_pull_downs[4] = {
+   0x0df0, 0x0dff, 0x, 0x,
+};
+
+static int jz4730_mmc_1bit_pins[] = { 0x27, 0x26, 0x22, };
+static int jz4730_mmc_4bit_pins[] = { 0x23, 0x24, 0x25, };
+static int jz4730_uart0_data_pins[] = { 0x7e, 0x7f, };
+static int jz4730_uart1_data_pins[] = { 0x18, 0x19, };
+static int jz4730_uart2_data_pins[] = { 0x6f, 0x7d, };
+static int jz4730_uart3_data_pins[] = { 0x10, 0x15, };
+static int jz4730_uart3_hwflow_pins[] = { 0x11, 0x17, };
+static int jz4730_lcd_8bit_pins[] = {
+   0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x3a, 0x39, 0x38,
+};
+static int jz4730_lcd_16bit_pins[] = {
+   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3b,
+};
+static int jz4730_lcd_16bit_tft_pins[] = { 0x3e, 0x3f, 0x3d, 0x3c, };
+static int jz4730_nand_cs1_pins[] = { 0x53, };
+static int jz4730_nand_cs2_pins[] = { 0x54, };
+static int jz4730_nand_cs3_pins[] = { 0x55, };
+static int jz4730_nand_cs4_pins[] = { 0x56, };
+static int jz4730_nand_cs5_pins[] = { 0x57, };
+static int jz4730_pwm_pwm0_pins[] = { 0x5e, };
+static int jz4730_pwm_pwm1_pins[] = { 0x5f, };
+
+static u8 jz4730_lcd_8bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 
2, };

+
+static const struct group_desc jz4730_groups[] = {
+   INGENIC_PIN_GROUP("mmc-1bit", jz4730_mmc_1bit, 1),
+   INGENIC_PIN_GROUP("mmc-4bit", jz4730_mmc_4bit, 1),
+   INGENIC_PIN_GROUP("uart0-data", jz4730_uart0_data, 1),
+   INGENIC_PIN_GROUP("uart1-data", jz4730_uart1_data, 1),
+   INGENIC_PIN_GROUP("uart2-data", jz4730_uart2_data, 1),
+   INGENIC_PIN_GROUP("uart3-data", jz4730_uart3_data, 1),
+   INGENIC_PIN_GROUP("uart3-hwflow", jz4730_uart3_hwflow, 1),
+	INGENIC_PIN_GROUP_FUNCS("lcd-8bit", jz4730_lcd_8bit, 
jz4730_lcd_8bit_funcs),

+   INGENIC_PIN_GROUP("lcd-16bit", jz4730_lcd_16bit, 1),
+   INGENIC_PIN_GROUP("lcd-16bit-tft", jz4730_lcd_16bit_tft, 1),
+   INGENIC_PIN_GROUP("nand-cs1", jz4730_nand_cs1, 1),
+   INGENIC_PIN_GROUP("nand-cs2", jz4730_nand_cs2, 1),
+   INGENIC_PIN_GROUP("nand-cs3", jz4730_nand_cs3, 1),
+   INGENIC_PIN_GROUP("nand-cs4", jz4730_nand_cs4, 1),
+   INGENIC_PIN_GROUP("nand-cs5", jz4730_nand_cs5, 1),
+   INGENIC_PIN_GROUP("pwm0", jz4730_pwm_pwm0, 1),
+   INGENIC_PIN_GROUP("pwm1", jz4730_pwm_pwm1, 1),

[PATCH v3 06/10] pinctrl: Ingenic: Add pinctrl driver for JZ4730.

2021-03-17 Thread Zhou Yanjie
Add support for probing the pinctrl-ingenic driver on the
JZ4730 SoC from Ingenic.

This driver is derived from Paul Boddie. It is worth to
noting that the JZ4730 SoC is special in having two control
registers (upper/lower), so add code to handle the JZ4730
specific register offsets and some register pairs which have
2 bits for each GPIO pin.

Tested-by: H. Nikolaus Schaller   # on Letux400
Co-developed-by: Paul Boddie 
Signed-off-by: Paul Boddie 
Signed-off-by: H. Nikolaus Schaller 
Signed-off-by: 周琰杰 (Zhou Yanjie) 
---

Notes:
v3:
New patch.

 drivers/pinctrl/pinctrl-ingenic.c | 222 +++---
 1 file changed, 206 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c 
b/drivers/pinctrl/pinctrl-ingenic.c
index b8165f5..25458d6 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -3,8 +3,8 @@
  * Ingenic SoCs pinctrl driver
  *
  * Copyright (c) 2017 Paul Cercueil 
- * Copyright (c) 2019 周琰杰 (Zhou Yanjie) 
  * Copyright (c) 2017, 2019 Paul Boddie 
+ * Copyright (c) 2019, 2020 周琰杰 (Zhou Yanjie) 
  */
 
 #include 
@@ -29,6 +29,17 @@
 #define GPIO_PIN   0x00
 #define GPIO_MSK   0x20
 
+#define JZ4730_GPIO_DATA   0x00
+#define JZ4730_GPIO_GPDIR  0x04
+#define JZ4730_GPIO_GPPUR  0x0c
+#define JZ4730_GPIO_GPALR  0x10
+#define JZ4730_GPIO_GPAUR  0x14
+#define JZ4730_GPIO_GPIDLR 0x18
+#define JZ4730_GPIO_GPIDUR 0x1c
+#define JZ4730_GPIO_GPIER  0x20
+#define JZ4730_GPIO_GPIMR  0x24
+#define JZ4730_GPIO_GPFR   0x28
+
 #define JZ4740_GPIO_DATA   0x10
 #define JZ4740_GPIO_PULL_DIS   0x30
 #define JZ4740_GPIO_FUNC   0x40
@@ -57,6 +68,7 @@
 #define GPIO_PULL_DOWN 2
 
 #define PINS_PER_GPIO_CHIP 32
+#define JZ4730_PINS_PER_PAIRED_REG 16
 
 #define INGENIC_PIN_GROUP_FUNCS(name, id, funcs)   \
{   \
@@ -70,6 +82,7 @@
INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func))
 
 enum jz_version {
+   ID_JZ4730,
ID_JZ4740,
ID_JZ4725B,
ID_JZ4760,
@@ -110,6 +123,96 @@ struct ingenic_gpio_chip {
unsigned int irq, reg_base;
 };
 
+static const u32 jz4730_pull_ups[4] = {
+   0x3fa3320f, 0xf200, 0x, 0x,
+};
+
+static const u32 jz4730_pull_downs[4] = {
+   0x0df0, 0x0dff, 0x, 0x,
+};
+
+static int jz4730_mmc_1bit_pins[] = { 0x27, 0x26, 0x22, };
+static int jz4730_mmc_4bit_pins[] = { 0x23, 0x24, 0x25, };
+static int jz4730_uart0_data_pins[] = { 0x7e, 0x7f, };
+static int jz4730_uart1_data_pins[] = { 0x18, 0x19, };
+static int jz4730_uart2_data_pins[] = { 0x6f, 0x7d, };
+static int jz4730_uart3_data_pins[] = { 0x10, 0x15, };
+static int jz4730_uart3_hwflow_pins[] = { 0x11, 0x17, };
+static int jz4730_lcd_8bit_pins[] = {
+   0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x3a, 0x39, 0x38,
+};
+static int jz4730_lcd_16bit_pins[] = {
+   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x3b,
+};
+static int jz4730_lcd_16bit_tft_pins[] = { 0x3e, 0x3f, 0x3d, 0x3c, };
+static int jz4730_nand_cs1_pins[] = { 0x53, };
+static int jz4730_nand_cs2_pins[] = { 0x54, };
+static int jz4730_nand_cs3_pins[] = { 0x55, };
+static int jz4730_nand_cs4_pins[] = { 0x56, };
+static int jz4730_nand_cs5_pins[] = { 0x57, };
+static int jz4730_pwm_pwm0_pins[] = { 0x5e, };
+static int jz4730_pwm_pwm1_pins[] = { 0x5f, };
+
+static u8 jz4730_lcd_8bit_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, };
+
+static const struct group_desc jz4730_groups[] = {
+   INGENIC_PIN_GROUP("mmc-1bit", jz4730_mmc_1bit, 1),
+   INGENIC_PIN_GROUP("mmc-4bit", jz4730_mmc_4bit, 1),
+   INGENIC_PIN_GROUP("uart0-data", jz4730_uart0_data, 1),
+   INGENIC_PIN_GROUP("uart1-data", jz4730_uart1_data, 1),
+   INGENIC_PIN_GROUP("uart2-data", jz4730_uart2_data, 1),
+   INGENIC_PIN_GROUP("uart3-data", jz4730_uart3_data, 1),
+   INGENIC_PIN_GROUP("uart3-hwflow", jz4730_uart3_hwflow, 1),
+   INGENIC_PIN_GROUP_FUNCS("lcd-8bit", jz4730_lcd_8bit, 
jz4730_lcd_8bit_funcs),
+   INGENIC_PIN_GROUP("lcd-16bit", jz4730_lcd_16bit, 1),
+   INGENIC_PIN_GROUP("lcd-16bit-tft", jz4730_lcd_16bit_tft, 1),
+   INGENIC_PIN_GROUP("nand-cs1", jz4730_nand_cs1, 1),
+   INGENIC_PIN_GROUP("nand-cs2", jz4730_nand_cs2, 1),
+   INGENIC_PIN_GROUP("nand-cs3", jz4730_nand_cs3, 1),
+   INGENIC_PIN_GROUP("nand-cs4", jz4730_nand_cs4, 1),
+   INGENIC_PIN_GROUP("nand-cs5", jz4730_nand_cs5, 1),
+   INGENIC_PIN_GROUP("pwm0", jz4730_pwm_pwm0, 1),
+   INGENIC_PIN_GROUP("pwm1", jz4730_pwm_pwm1, 1),
+};
+
+static const char *jz4730_mmc_groups[] = { "mmc-1bit",