[PATCH v4 3/4] pinctrl: add drive for I2C related pins on MT8195

2021-04-13 Thread Zhiyong Tao
This patch provides the advanced drive raw data setting version
for I2C used pins on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |  5 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index 063f164d7c9b..a7500e18bb1d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -760,6 +760,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_range[] = {
PIN_FIELD_BASE(143, 143, 1, 0x020, 0x10, 24, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_drv_adv_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x020, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x020, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x020, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x020, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x020, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x020, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x020, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x020, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x040, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x040, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x040, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -773,6 +792,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8195_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -801,6 +821,8 @@ static const struct mtk_pin_soc mt8195_data = {
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
+   .adv_drive_get = mtk_pinconf_adv_drive_get_raw,
+   .adv_drive_set = mtk_pinconf_adv_drive_set_raw,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..2b51f4a9b860 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1027,6 +1027,20 @@ int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get);
 
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_set_raw);
+
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..fd5ce9c5dcbd 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -66,6 +66,7 @@ enum {
PINCTRL_PIN_REG_DRV_EN,
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
+   PINCTRL_PIN_REG_DRV_ADV,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -314,6 +315,10 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 arg);
 int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 *val);
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg);
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val);
 
 bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
 #endif /* __PINCTRL_MTK_COMMON_V2_H */
-- 
2.18.0



[PATCH v4 2/4] pinctrl: add pinctrl driver on mt8195

2021-04-12 Thread Zhiyong Tao
This commit includes pinctrl driver for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  828 
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 4 files changed, 2504 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index eef17f228669..90f0c8255eaf 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -147,6 +147,12 @@ config PINCTRL_MT8192
default ARM64 && ARCH_MEDIATEK
select PINCTRL_MTK_PARIS
 
+config PINCTRL_MT8195
+   bool "Mediatek MT8195 pin control"
+   depends on OF
+   depends on ARM64 || COMPILE_TEST
+   select PINCTRL_MTK_PARIS
+
 config PINCTRL_MT8516
bool "Mediatek MT8516 pin control"
depends on OF
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index 01218bf4dc30..06fde993ace2 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_PINCTRL_MT8167)  += pinctrl-mt8167.o
 obj-$(CONFIG_PINCTRL_MT8173)   += pinctrl-mt8173.o
 obj-$(CONFIG_PINCTRL_MT8183)   += pinctrl-mt8183.o
 obj-$(CONFIG_PINCTRL_MT8192)   += pinctrl-mt8192.o
+obj-$(CONFIG_PINCTRL_MT8195)+= pinctrl-mt8195.o
 obj-$(CONFIG_PINCTRL_MT8516)   += pinctrl-mt8516.o
 obj-$(CONFIG_PINCTRL_MT6397)   += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
new file mode 100644
index ..063f164d7c9b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -0,0 +1,828 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#include "pinctrl-mtk-mt8195.h"
+#include "pinctrl-paris.h"
+
+/* MT8195 have multiple bases to program pin configuration listed as the below:
+ * iocfg[0]:0x10005000, iocfg[1]:0x11d1, iocfg[2]:0x11d3,
+ * iocfg[3]:0x11d4, iocfg[4]:0x11e2, iocfg[5]:0x11eb,
+ * iocfg[6]:0x11f4.
+ * _i_based could be used to indicate what base the pin should be mapped into.
+ */
+
+#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
+  32, 0)
+
+#define PINS_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits,  \
+  32, 1)
+
+static const struct mtk_pin_field_calc mt8195_pin_mode_range[] = {
+   PIN_FIELD(0, 144, 0x300, 0x10, 0, 4),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_dir_range[] = {
+   PIN_FIELD(0, 144, 0x0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_di_range[] = {
+   PIN_FIELD(0, 144, 0x200, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_do_range[] = {
+   PIN_FIELD(0, 144, 0x100, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_ies_range[] = {
+   PIN_FIELD_BASE(0, 0, 4, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(1, 1, 4, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(2, 2, 4, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(3, 3, 4, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(4, 4, 4, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(5, 5, 4, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(6, 6, 4, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(7, 7, 4, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(8, 8, 4, 0x040, 0x10, 13, 1),
+   PIN_FIELD_BASE(9, 9, 4, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(10, 10, 4, 0x040, 0x10, 14, 1),
+   PIN_FIELD_BASE(11, 11, 4, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BASE(12, 12, 4, 0x040, 0x10, 15, 1),
+   PIN_FIELD_BASE(13, 13, 4, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(14, 14, 4, 0x040, 0x10, 16, 1),
+   PIN_FIELD_BASE(15, 15, 4, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(16, 16, 4, 0x040, 0x10, 17, 1),
+   PIN_FIELD_BASE(17, 17, 4, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(18, 18, 2, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(19, 19, 2, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(20, 20, 2, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(21, 21, 2, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(22, 22, 2, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(23, 23, 2, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(24, 24, 2, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(25, 25, 2, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(26, 26, 2, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(27, 27, 2, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(28, 28, 2, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(29, 29, 2, 0x040, 0x10, 8, 1),
+  

[PATCH v4 4/4] pinctrl: add rsel setting on MT8195

2021-04-12 Thread Zhiyong Tao
This patch provides rsel setting on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  | 10 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 16 ++
 4 files changed, 62 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index a7500e18bb1d..66608b8d346a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -779,6 +779,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_adv_range[] = {
PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_rsel_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x0c0, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x0c0, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x0c0, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x0c0, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x0c0, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x0c0, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x0c0, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x0c0, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x0c0, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x0c0, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x080, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x080, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x0e0, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x0e0, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x0e0, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x0e0, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -793,6 +812,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
[PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
+   [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt8195_pin_rsel_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -823,6 +843,8 @@ static const struct mtk_pin_soc mt8195_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_drive_get = mtk_pinconf_adv_drive_get_raw,
.adv_drive_set = mtk_pinconf_adv_drive_set_raw,
+   .rsel_set = mtk_pinconf_rsel_set,
+   .rsel_get = mtk_pinconf_rsel_get,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2b51f4a9b860..d1526d0c6248 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1041,6 +1041,20 @@ int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
 
+int mtk_pinconf_rsel_set(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_RSEL, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_set);
+
+int mtk_pinconf_rsel_get(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_RSEL, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_get);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index fd5ce9c5dcbd..570e8da7bf38 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -67,6 +67,7 @@ enum {
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_DRV_ADV,
+   PINCTRL_PIN_REG_RSEL,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -237,6 +238,10 @@ struct mtk_pin_soc {
 const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
 const struct mtk_pin_desc *desc, u32 *val);
+   int (*rsel_set)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 arg);
+   int (*rsel_get)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 *val);
 
/* Specific driver data */
void*driver_data;
@@ -320,5 +325,10 @@ int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
 int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
  const struct mtk_pin

[PATCH v4 1/4] dt-bindings: pinctrl: mt8195: add pinctrl file and binding document

2021-04-12 Thread Zhiyong Tao
1. This patch adds pinctrl file for mt8195.
2. This patch adds mt8195 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8195.yaml  | 151 +++
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  | 962 ++
 2 files changed, 1113 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
new file mode 100644
index ..2f12ec59eee5
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
@@ -0,0 +1,151 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8195.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8195 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8195-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 8 GPIO
+  physical address base in mt8195.
+maxItems: 8
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 8
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '-pins$':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+gpio_pin {
+  pinmux = ;
+};
+/* GPIO8 set as multifunction SDA0 */
+i2c0_pin {
+  pinmux = ;
+};
+  };
+$ref: "pinmux-node.yaml"
+
+properties:
+  pinmux:
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments which is from 0 to 7. It can only 
support
+  2/4/6/8/10/12/14/16mA in mt8195.
+enum: [0, 1, 2, 3, 4, 5, 6, 7]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8195-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11eb 0x1000>,
+  <0x11f4 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_bm", "iocfg_bl",
+  "iocfg_br", "iocfg_lm", "iocfg_rb",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 144>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+
+pio-pins {
+  pinmux = ;
+  output-low;
+};
+};
diff --git a/

[PATCH v4 0/4] Mediatek pinctrl patch on mt8195

2021-04-12 Thread Zhiyong Tao
This series includes 4 patches:
1.add pinctrl file and inding document on mt8195.
2.add pinctrl driver on MT8195.
3.add pinctrl drive for I2C related pins on MT8195.
4.add pinctrl rsel setting on MT8195.

Changes in patch v4:
1)fix pinctrl-mt8195.yaml warning error.
2)remove pinctrl device node patch which is based on "mt8195.dtsi".

Changes in patch v3:
1)change '^pins' to '-pins$'.
2)change 'state_0_node_a' to 'gpio_pin' which is defined in dts.
3)change 'state_0_node_b' to 'i2c0_pin' which is defined in dts.
4)reorder this series patches. change pinctrl file and binding document
together in one patch.

There are no changes in v1 & v2.

Zhiyong Tao (4):
  dt-bindings: pinctrl: mt8195: add pinctrl file and binding document
  pinctrl: add pinctrl driver on mt8195
  pinctrl: add drive for I2C related pins on MT8195
  pinctrl: add rsel setting on MT8195

 .../bindings/pinctrl/pinctrl-mt8195.yaml  |  151 ++
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  872 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  |   28 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |   15 +
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  |   16 +
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  |  962 ++
 9 files changed, 3720 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

--
2.18.0




[PATCH v3 1/5] dt-bindings: pinctrl: mt8195: add pinctrl file and binding document

2021-04-11 Thread Zhiyong Tao
1. This patch adds pinctrl file for mt8195.
2. This patch adds mt8195 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 +++
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  | 962 ++
 2 files changed, 1114 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
new file mode 100644
index ..b4b4bfa701ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
@@ -0,0 +1,152 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8195.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8195 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8195-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 8 GPIO
+  physical address base in mt8195.
+maxItems: 8
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 8
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '-pins$':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+gpio_pin {
+  pinmux = ;
+};
+/* GPIO8 set as multifunction SDA0 */
+i2c0_pin {
+  pinmux = ;
+};
+  };
+$ref: "pinmux-node.yaml"
+
+properties:
+  pinmux:
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments which is from 0 to 7. It can only 
support
+  2/4/6/8/10/12/14/16mA in mt8195.
+enum: [0, 1, 2, 3, 4, 5, 6, 7]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8195-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11eb 0x1000>,
+  <0x11f4 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_bm", "iocfg_bl",
+  "iocfg_br", "iocfg_lm", "iocfg_rb",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 144>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+
+pio-pins {
+  pinmux = ;
+  output-low;

[PATCH v3 5/5] pinctrl: add rsel setting on MT8195

2021-04-11 Thread Zhiyong Tao
This patch provides rsel setting on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  | 10 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 16 ++
 4 files changed, 62 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index a7500e18bb1d..66608b8d346a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -779,6 +779,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_adv_range[] = {
PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_rsel_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x0c0, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x0c0, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x0c0, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x0c0, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x0c0, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x0c0, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x0c0, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x0c0, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x0c0, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x0c0, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x080, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x080, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x0e0, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x0e0, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x0e0, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x0e0, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -793,6 +812,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
[PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
+   [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt8195_pin_rsel_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -823,6 +843,8 @@ static const struct mtk_pin_soc mt8195_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_drive_get = mtk_pinconf_adv_drive_get_raw,
.adv_drive_set = mtk_pinconf_adv_drive_set_raw,
+   .rsel_set = mtk_pinconf_rsel_set,
+   .rsel_get = mtk_pinconf_rsel_get,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2b51f4a9b860..d1526d0c6248 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1041,6 +1041,20 @@ int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
 
+int mtk_pinconf_rsel_set(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_RSEL, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_set);
+
+int mtk_pinconf_rsel_get(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_RSEL, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_get);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index fd5ce9c5dcbd..570e8da7bf38 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -67,6 +67,7 @@ enum {
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_DRV_ADV,
+   PINCTRL_PIN_REG_RSEL,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -237,6 +238,10 @@ struct mtk_pin_soc {
 const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
 const struct mtk_pin_desc *desc, u32 *val);
+   int (*rsel_set)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 arg);
+   int (*rsel_get)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 *val);
 
/* Specific driver data */
void*driver_data;
@@ -320,5 +325,10 @@ int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
 int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
  const struct mtk_pin

[PATCH v3 3/5] pinctrl: add pinctrl driver on mt8195

2021-04-11 Thread Zhiyong Tao
This commit includes pinctrl driver for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  828 
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 4 files changed, 2504 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index eef17f228669..90f0c8255eaf 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -147,6 +147,12 @@ config PINCTRL_MT8192
default ARM64 && ARCH_MEDIATEK
select PINCTRL_MTK_PARIS
 
+config PINCTRL_MT8195
+   bool "Mediatek MT8195 pin control"
+   depends on OF
+   depends on ARM64 || COMPILE_TEST
+   select PINCTRL_MTK_PARIS
+
 config PINCTRL_MT8516
bool "Mediatek MT8516 pin control"
depends on OF
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index 01218bf4dc30..06fde993ace2 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_PINCTRL_MT8167)  += pinctrl-mt8167.o
 obj-$(CONFIG_PINCTRL_MT8173)   += pinctrl-mt8173.o
 obj-$(CONFIG_PINCTRL_MT8183)   += pinctrl-mt8183.o
 obj-$(CONFIG_PINCTRL_MT8192)   += pinctrl-mt8192.o
+obj-$(CONFIG_PINCTRL_MT8195)+= pinctrl-mt8195.o
 obj-$(CONFIG_PINCTRL_MT8516)   += pinctrl-mt8516.o
 obj-$(CONFIG_PINCTRL_MT6397)   += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
new file mode 100644
index ..063f164d7c9b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -0,0 +1,828 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#include "pinctrl-mtk-mt8195.h"
+#include "pinctrl-paris.h"
+
+/* MT8195 have multiple bases to program pin configuration listed as the below:
+ * iocfg[0]:0x10005000, iocfg[1]:0x11d1, iocfg[2]:0x11d3,
+ * iocfg[3]:0x11d4, iocfg[4]:0x11e2, iocfg[5]:0x11eb,
+ * iocfg[6]:0x11f4.
+ * _i_based could be used to indicate what base the pin should be mapped into.
+ */
+
+#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
+  32, 0)
+
+#define PINS_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits,  \
+  32, 1)
+
+static const struct mtk_pin_field_calc mt8195_pin_mode_range[] = {
+   PIN_FIELD(0, 144, 0x300, 0x10, 0, 4),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_dir_range[] = {
+   PIN_FIELD(0, 144, 0x0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_di_range[] = {
+   PIN_FIELD(0, 144, 0x200, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_do_range[] = {
+   PIN_FIELD(0, 144, 0x100, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_ies_range[] = {
+   PIN_FIELD_BASE(0, 0, 4, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(1, 1, 4, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(2, 2, 4, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(3, 3, 4, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(4, 4, 4, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(5, 5, 4, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(6, 6, 4, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(7, 7, 4, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(8, 8, 4, 0x040, 0x10, 13, 1),
+   PIN_FIELD_BASE(9, 9, 4, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(10, 10, 4, 0x040, 0x10, 14, 1),
+   PIN_FIELD_BASE(11, 11, 4, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BASE(12, 12, 4, 0x040, 0x10, 15, 1),
+   PIN_FIELD_BASE(13, 13, 4, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(14, 14, 4, 0x040, 0x10, 16, 1),
+   PIN_FIELD_BASE(15, 15, 4, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(16, 16, 4, 0x040, 0x10, 17, 1),
+   PIN_FIELD_BASE(17, 17, 4, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(18, 18, 2, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(19, 19, 2, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(20, 20, 2, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(21, 21, 2, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(22, 22, 2, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(23, 23, 2, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(24, 24, 2, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(25, 25, 2, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(26, 26, 2, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(27, 27, 2, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(28, 28, 2, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(29, 29, 2, 0x040, 0x10, 8, 1),
+  

[PATCH v3 2/5] arm64: dts: mt8195: add pinctrl device node

2021-04-11 Thread Zhiyong Tao
This commit adds pinctrl device node for mt8195

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
index 068fe24efd2d..48b28a9d35cc 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
@@ -273,6 +273,27 @@
};
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8195-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11d1 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d4 0 0x1000>,
+ <0 0x11e2 0 0x1000>,
+ <0 0x11eb 0 0x1000>,
+ <0 0x11f4 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg_bm",
+   "iocfg_bl", "iocfg_br", "iocfg_lm",
+   "iocfg_rb", "iocfg_tl", "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 144>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
watchdog: watchdog@10007000 {
compatible = "mediatek,mt8195-wdt", 
"mediatek,mt6589-wdt";
reg = <0 0x10007000 0 0x100>;
-- 
2.18.0



[PATCH v3 0/5] Mediatek pinctrl patch on mt8195

2021-04-11 Thread Zhiyong Tao
This series includes 5 patches:
1.add pinctrl file and inding document on mt8195.
2.add pinctrl device node on mt8195.
3.add pinctrl driver on MT8195.
4.add pinctrl drive for I2C related pins on MT8195.
5.add pinctrl rsel setting on MT8195.

Changes in patch v3:
1)change '^pins' to '-pins$'.
2)change 'state_0_node_a' to 'gpio_pin' which is defined in dts.
3)change 'state_0_node_b' to 'i2c0_pin' which is defined in dts.
4)reorder this series patches. change pinctrl file and binding document
together in one patch.

There are no changes in v1 & v2.

Zhiyong Tao (5):
  dt-bindings: pinctrl: mt8195: add pinctrl file and binding document
  arm64: dts: mt8195: add pinctrl device node
  pinctrl: add pinctrl driver on mt8195
  pinctrl: add drive for I2C related pins on MT8195
  pinctrl: add rsel setting on MT8195

 .../bindings/pinctrl/pinctrl-mt8195.yaml  |  152 ++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi  |   21 +
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  872 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  |   28 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |   15 +
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  |   16 +
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  |  962 ++
 10 files changed, 3742 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

--
2.18.0 




[PATCH v3 4/5] pinctrl: add drive for I2C related pins on MT8195

2021-04-11 Thread Zhiyong Tao
This patch provides the advanced drive raw data setting version
for I2C used pins on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |  5 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index 063f164d7c9b..a7500e18bb1d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -760,6 +760,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_range[] = {
PIN_FIELD_BASE(143, 143, 1, 0x020, 0x10, 24, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_drv_adv_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x020, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x020, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x020, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x020, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x020, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x020, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x020, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x020, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x040, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x040, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x040, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -773,6 +792,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8195_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -801,6 +821,8 @@ static const struct mtk_pin_soc mt8195_data = {
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
+   .adv_drive_get = mtk_pinconf_adv_drive_get_raw,
+   .adv_drive_set = mtk_pinconf_adv_drive_set_raw,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..2b51f4a9b860 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1027,6 +1027,20 @@ int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get);
 
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_set_raw);
+
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..fd5ce9c5dcbd 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -66,6 +66,7 @@ enum {
PINCTRL_PIN_REG_DRV_EN,
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
+   PINCTRL_PIN_REG_DRV_ADV,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -314,6 +315,10 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 arg);
 int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 *val);
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg);
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val);
 
 bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
 #endif /* __PINCTRL_MTK_COMMON_V2_H */
-- 
2.18.0



Re: [PATCH Resend v0 2/6] dt-bindings: pinctrl: mt8195: add binding document

2021-03-30 Thread zhiyong tao
On Tue, 2021-03-30 at 08:39 -0500, Rob Herring wrote:
> On Tue, Mar 30, 2021 at 05:05:28PM +0800, zhiyong tao wrote:
> > On Mon, 2021-03-29 at 14:21 -0500, Rob Herring wrote:
> > > On Mon, 29 Mar 2021 19:30:59 +0800, Zhiyong Tao wrote:
> > > > The commit adds mt8195 compatible node in binding document.
> > > > 
> > > > Signed-off-by: Zhiyong Tao 
> > > > ---
> > > >  .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 ++
> > > >  1 file changed, 152 insertions(+)
> > > >  create mode 100644 
> > > > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> > > > 
> > > 
> > > My bot found errors running 'make dt_binding_check' on your patch:
> > > 
> > > yamllint warnings/errors:
> > > 
> > > dtschema/dtc warnings/errors:
> > > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.example.dts:19:18:
> > >  fatal error: dt-bindings/pinctrl/mt8195-pinfunc.h: No such file or 
> > > directory
> > >19 | #include 
> > >   |  ^~
> > > compilation terminated.
> > > make[1]: *** [scripts/Makefile.lib:349: 
> > > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.example.dt.yaml] 
> > > Error 1
> > > make[1]: *** Waiting for unfinished jobs
> > > make: *** [Makefile:1380: dt_binding_check] Error 2
> > > 
> > > See https://patchwork.ozlabs.org/patch/1459558
> > > 
> > > This check can fail if there are any dependencies. The base for a patch
> > > series is generally the most recent rc1.
> > > 
> > > If you already ran 'make dt_binding_check' and didn't see the above
> > > error(s), then make sure 'yamllint' is installed and dt-schema is up to
> > > date:
> > > 
> > > pip3 install dtschema --upgrade
> > > 
> > > Please check and re-submit.
> > > 
> > 
> > ==> I set the patch file "mt8195-pinfunc.h" patch in "4/6". so we should
> > add the file "mt8195-pinfunc.h" in this patch ? or we should put it
> > before this patch(2/6)?
> 
> It is part of the binding, so it belongs in this patch.
> 
> Rob

==> Thanks for your suggestion. We will add it in this patch in next
version.



Re: [PATCH 2/6] dt-bindings: pinctrl: mt8195: add binding document

2021-03-30 Thread zhiyong tao
On Mon, 2021-03-29 at 08:58 -0500, Rob Herring wrote:
> On Mon, Mar 29, 2021 at 02:50:43PM +0800, Zhiyong Tao wrote:
> > The commit adds mt8195 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 ++
> >  1 file changed, 152 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> > new file mode 100644
> > index ..7915b9568c29
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> > @@ -0,0 +1,152 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8195.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Mediatek MT8195 Pin Controller
> > +
> > +maintainers:
> > +  - Sean Wang 
> > +
> > +description: |
> > +  The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +properties:
> > +  compatible:
> > +const: mediatek,mt8195-pinctrl
> > +
> > +  gpio-controller: true
> > +
> > +  '#gpio-cells':
> > +description: |
> > +  Number of cells in GPIO specifier. Since the generic GPIO binding is 
> > used,
> > +  the amount of cells must be specified as 2. See the below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +const: 2
> > +
> > +  gpio-ranges:
> > +description: gpio valid number range.
> > +maxItems: 1
> > +
> > +  reg:
> > +description: |
> > +  Physical address base for gpio base registers. There are 8 GPIO
> > +  physical address base in mt8195.
> > +maxItems: 8
> > +
> > +  reg-names:
> > +description: |
> > +  Gpio base register names.
> > +maxItems: 8
> > +
> > +  interrupt-controller: true
> > +
> > +  '#interrupt-cells':
> > +const: 2
> > +
> > +  interrupts:
> > +description: The interrupt outputs to sysirq.
> > +maxItems: 1
> > +
> > +#PIN CONFIGURATION NODES
> > +patternProperties:
> > +  '^pins':
> 
> Normally we're doing '-pins$'.

==> Thanks for your suggestion. we will change it in next version.
> 
> > +type: object
> > +description: |
> > +  A pinctrl node should contain at least one subnodes representing the
> > +  pinctrl groups available on the machine. Each subnode will list the
> > +  pins it needs, and how they should be configured, with regard to 
> > muxer
> > +  configuration, pullups, drive strength, input enable/disable and
> > +  input schmitt.
> > +  An example of using macro:
> > +  pincontroller {
> > +/* GPIO0 set as multifunction GPIO0 */
> > +state_0_node_a {
> 
> Use the node name pattern defined.

==> Thanks for your suggestion. we will change it in next version.
> 
> > +  pinmux = ;
> > +};
> > +/* GPIO1 set as multifunction CLKM1 */
> > +state_0_node_b {
> > +  pinmux = ;
> > +};
> > +  };
> > +$ref: "pinmux-node.yaml"
> > +
> > +properties:
> > +  pinmux:
> > +description: |
> > +  Integer array, represents gpio pin number and mux setting.
> > +  Supported pin number and mux varies for different SoCs, and are 
> > defined
> > +  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
> > +
> > +  drive-strength:
> > +description: |
> > +  It can support some arguments, such as MTK_DRIVE_4mA, 
> > MTK_DRIVE_6mA, etc. See
> > +  dt-bindings/pinctrl/mt65xx.h. It can only support 
> > 2/4/6/8/10/12/14/16mA in mt8195.
> > +enum: [2, 4, 6, 8, 10, 12, 14, 16]
> > +
> > +  bias-pull-down: true
> > +
> > +  bias-pull-up: true
> > +
> > +  bias-disable: true
> > +
> > +  output-high: true
> > +
> > +  output-low: true
> > +
> > +  input-enable: true
> > +
> > +  input-disable: true
> > +
> > +  input-schmitt-enable: true
> > +
> > +  input-schmit

Re: [PATCH Resend v0 2/6] dt-bindings: pinctrl: mt8195: add binding document

2021-03-30 Thread zhiyong tao
On Mon, 2021-03-29 at 14:21 -0500, Rob Herring wrote:
> On Mon, 29 Mar 2021 19:30:59 +0800, Zhiyong Tao wrote:
> > The commit adds mt8195 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 ++
> >  1 file changed, 152 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.example.dts:19:18: 
> fatal error: dt-bindings/pinctrl/mt8195-pinfunc.h: No such file or directory
>19 | #include 
>   |  ^~
> compilation terminated.
> make[1]: *** [scripts/Makefile.lib:349: 
> Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.example.dt.yaml] 
> Error 1
> make[1]: *** Waiting for unfinished jobs
> make: *** [Makefile:1380: dt_binding_check] Error 2
> 
> See https://patchwork.ozlabs.org/patch/1459558
> 
> This check can fail if there are any dependencies. The base for a patch
> series is generally the most recent rc1.
> 
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure 'yamllint' is installed and dt-schema is up to
> date:
> 
> pip3 install dtschema --upgrade
> 
> Please check and re-submit.
> 

==> I set the patch file "mt8195-pinfunc.h" patch in "4/6". so we should
add the file "mt8195-pinfunc.h" in this patch ? or we should put it
before this patch(2/6)?

Thanks.



Re: [PATCH Resend v0 0/6] Mediatek pinctrl patch on mt8195

2021-03-29 Thread zhiyong tao
On Mon, 2021-03-29 at 14:35 +0300, Andy Shevchenko wrote:
> On Mon, Mar 29, 2021 at 2:32 PM Zhiyong Tao  wrote:
> >
> > This series includes 6 patches:
> > 1.add pinctrl file on mt8195.
> > 2.add pinctrl binding document on mt8195.
> > 3.add pinctrl device node on mt8195.
> > 4.add pinctrl driver on MT8195.
> > 5.add pinctrl drive for I2C related pins on MT8195.
> > 6.add pinctrl rsel setting on MT8195.
> 
> Patch series w/o version is de facto v1.
> Dropping to v0 seems not right.
> You missed changelog.
> 
> So, send v2 properly.
> 
> Material to study:
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html
> 

Hi Andy,

There is not any change between v0 and v1. so we send "Resend v0" as v2
in this time.Is it also properly? and we send the version which is v3 in
next time. 

Thanks.


[PATCH Resend v0 6/6] pinctrl: add rsel setting on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides rsel setting on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  | 10 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 16 ++
 4 files changed, 62 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index a7500e18bb1d..66608b8d346a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -779,6 +779,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_adv_range[] = {
PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_rsel_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x0c0, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x0c0, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x0c0, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x0c0, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x0c0, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x0c0, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x0c0, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x0c0, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x0c0, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x0c0, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x080, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x080, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x0e0, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x0e0, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x0e0, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x0e0, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -793,6 +812,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
[PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
+   [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt8195_pin_rsel_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -823,6 +843,8 @@ static const struct mtk_pin_soc mt8195_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_drive_get = mtk_pinconf_adv_drive_get_raw,
.adv_drive_set = mtk_pinconf_adv_drive_set_raw,
+   .rsel_set = mtk_pinconf_rsel_set,
+   .rsel_get = mtk_pinconf_rsel_get,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2b51f4a9b860..d1526d0c6248 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1041,6 +1041,20 @@ int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
 
+int mtk_pinconf_rsel_set(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_RSEL, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_set);
+
+int mtk_pinconf_rsel_get(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_RSEL, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_get);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index fd5ce9c5dcbd..570e8da7bf38 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -67,6 +67,7 @@ enum {
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_DRV_ADV,
+   PINCTRL_PIN_REG_RSEL,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -237,6 +238,10 @@ struct mtk_pin_soc {
 const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
 const struct mtk_pin_desc *desc, u32 *val);
+   int (*rsel_set)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 arg);
+   int (*rsel_get)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 *val);
 
/* Specific driver data */
void*driver_data;
@@ -320,5 +325,10 @@ int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
 int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
  const struct mtk_pin

[PATCH Resend v0 4/6] pinctrl: add pinctrl driver on mt8195

2021-03-29 Thread Zhiyong Tao
This commit includes pinctrl driver for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/Kconfig |   6 +
 drivers/pinctrl/mediatek/Makefile|   1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c| 828 
 include/dt-bindings/pinctrl/mt8195-pinfunc.h | 962 +++
 4 files changed, 1797 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index eef17f228669..90f0c8255eaf 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -147,6 +147,12 @@ config PINCTRL_MT8192
default ARM64 && ARCH_MEDIATEK
select PINCTRL_MTK_PARIS
 
+config PINCTRL_MT8195
+   bool "Mediatek MT8195 pin control"
+   depends on OF
+   depends on ARM64 || COMPILE_TEST
+   select PINCTRL_MTK_PARIS
+
 config PINCTRL_MT8516
bool "Mediatek MT8516 pin control"
depends on OF
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index 01218bf4dc30..06fde993ace2 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_PINCTRL_MT8167)  += pinctrl-mt8167.o
 obj-$(CONFIG_PINCTRL_MT8173)   += pinctrl-mt8173.o
 obj-$(CONFIG_PINCTRL_MT8183)   += pinctrl-mt8183.o
 obj-$(CONFIG_PINCTRL_MT8192)   += pinctrl-mt8192.o
+obj-$(CONFIG_PINCTRL_MT8195)+= pinctrl-mt8195.o
 obj-$(CONFIG_PINCTRL_MT8516)   += pinctrl-mt8516.o
 obj-$(CONFIG_PINCTRL_MT6397)   += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
new file mode 100644
index ..063f164d7c9b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -0,0 +1,828 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#include "pinctrl-mtk-mt8195.h"
+#include "pinctrl-paris.h"
+
+/* MT8195 have multiple bases to program pin configuration listed as the below:
+ * iocfg[0]:0x10005000, iocfg[1]:0x11d1, iocfg[2]:0x11d3,
+ * iocfg[3]:0x11d4, iocfg[4]:0x11e2, iocfg[5]:0x11eb,
+ * iocfg[6]:0x11f4.
+ * _i_based could be used to indicate what base the pin should be mapped into.
+ */
+
+#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
+  32, 0)
+
+#define PINS_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits,  \
+  32, 1)
+
+static const struct mtk_pin_field_calc mt8195_pin_mode_range[] = {
+   PIN_FIELD(0, 144, 0x300, 0x10, 0, 4),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_dir_range[] = {
+   PIN_FIELD(0, 144, 0x0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_di_range[] = {
+   PIN_FIELD(0, 144, 0x200, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_do_range[] = {
+   PIN_FIELD(0, 144, 0x100, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_ies_range[] = {
+   PIN_FIELD_BASE(0, 0, 4, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(1, 1, 4, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(2, 2, 4, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(3, 3, 4, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(4, 4, 4, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(5, 5, 4, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(6, 6, 4, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(7, 7, 4, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(8, 8, 4, 0x040, 0x10, 13, 1),
+   PIN_FIELD_BASE(9, 9, 4, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(10, 10, 4, 0x040, 0x10, 14, 1),
+   PIN_FIELD_BASE(11, 11, 4, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BASE(12, 12, 4, 0x040, 0x10, 15, 1),
+   PIN_FIELD_BASE(13, 13, 4, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(14, 14, 4, 0x040, 0x10, 16, 1),
+   PIN_FIELD_BASE(15, 15, 4, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(16, 16, 4, 0x040, 0x10, 17, 1),
+   PIN_FIELD_BASE(17, 17, 4, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(18, 18, 2, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(19, 19, 2, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(20, 20, 2, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(21, 21, 2, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(22, 22, 2, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(23, 23, 2, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(24, 24, 2, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(25, 25, 2, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(26, 26, 2, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(27, 27, 2, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(28, 28, 2, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(29, 29, 2, 0x040, 0x10, 8, 1),
+  

[PATCH Resend v0 5/6] pinctrl: add drive for I2C related pins on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides the advanced drive raw data setting version
for I2C used pins on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |  5 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index 063f164d7c9b..a7500e18bb1d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -760,6 +760,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_range[] = {
PIN_FIELD_BASE(143, 143, 1, 0x020, 0x10, 24, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_drv_adv_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x020, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x020, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x020, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x020, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x020, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x020, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x020, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x020, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x040, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x040, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x040, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -773,6 +792,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8195_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -801,6 +821,8 @@ static const struct mtk_pin_soc mt8195_data = {
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
+   .adv_drive_get = mtk_pinconf_adv_drive_get_raw,
+   .adv_drive_set = mtk_pinconf_adv_drive_set_raw,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..2b51f4a9b860 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1027,6 +1027,20 @@ int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get);
 
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_set_raw);
+
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..fd5ce9c5dcbd 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -66,6 +66,7 @@ enum {
PINCTRL_PIN_REG_DRV_EN,
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
+   PINCTRL_PIN_REG_DRV_ADV,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -314,6 +315,10 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 arg);
 int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 *val);
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg);
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val);
 
 bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
 #endif /* __PINCTRL_MTK_COMMON_V2_H */
-- 
2.18.0



[PATCH Resend v0 2/6] dt-bindings: pinctrl: mt8195: add binding document

2021-03-29 Thread Zhiyong Tao
The commit adds mt8195 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 ++
 1 file changed, 152 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
new file mode 100644
index ..7915b9568c29
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
@@ -0,0 +1,152 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8195.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8195 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8195-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 8 GPIO
+  physical address base in mt8195.
+maxItems: 8
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 8
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '^pins':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+state_0_node_a {
+  pinmux = ;
+};
+/* GPIO1 set as multifunction CLKM1 */
+state_0_node_b {
+  pinmux = ;
+};
+  };
+$ref: "pinmux-node.yaml"
+
+properties:
+  pinmux:
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments, such as MTK_DRIVE_4mA, MTK_DRIVE_6mA, 
etc. See
+  dt-bindings/pinctrl/mt65xx.h. It can only support 
2/4/6/8/10/12/14/16mA in mt8195.
+enum: [2, 4, 6, 8, 10, 12, 14, 16]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8195-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11eb 0x1000>,
+  <0x11f4 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_bm", "iocfg_bl",
+  "iocfg_br", "iocfg_lm", "iocfg_rb",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 144>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+
+pins {
+  pinmux = ;
+  output-low;
+};
+};
-- 
2.18.0



[PATCH Resend v0 3/6] arm64: dts: mt8195: add pinctrl device node

2021-03-29 Thread Zhiyong Tao
This commit adds pinctrl device node for mt8195

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
index 068fe24efd2d..48b28a9d35cc 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
@@ -273,6 +273,27 @@
};
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8195-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11d1 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d4 0 0x1000>,
+ <0 0x11e2 0 0x1000>,
+ <0 0x11eb 0 0x1000>,
+ <0 0x11f4 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg_bm",
+   "iocfg_bl", "iocfg_br", "iocfg_lm",
+   "iocfg_rb", "iocfg_tl", "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 144>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
watchdog: watchdog@10007000 {
compatible = "mediatek,mt8195-wdt", 
"mediatek,mt6589-wdt";
reg = <0 0x10007000 0 0x100>;
-- 
2.18.0



[PATCH Resend v0 1/6] dt-bindings: pinctrl: mt8195: add pinctrl file

2021-03-29 Thread Zhiyong Tao
This patch adds pinctrl file for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 1 file changed, 1669 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
new file mode 100644
index ..de4a8a80bf1d
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
@@ -0,0 +1,1669 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __PINCTRL_MTK_MT8195_H
+#define __PINCTRL_MTK_MT8195_H
+
+#include "pinctrl-paris.h"
+
+static const struct mtk_pin_desc mtk_pins_mt8195[] = {
+   MTK_PIN(
+   0, "GPIO0",
+   MTK_EINT_FUNCTION(0, 0),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO0"),
+   MTK_FUNCTION(1, "TP_GPIO0_AO"),
+   MTK_FUNCTION(2, "MSDC2_CMD"),
+   MTK_FUNCTION(3, "TDMIN_MCK"),
+   MTK_FUNCTION(4, "CLKM0"),
+   MTK_FUNCTION(5, "PERSTN_1"),
+   MTK_FUNCTION(6, "IDDIG_1P"),
+   MTK_FUNCTION(7, "DMIC4_CLK")
+   ),
+   MTK_PIN(
+   1, "GPIO1",
+   MTK_EINT_FUNCTION(0, 1),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO1"),
+   MTK_FUNCTION(1, "TP_GPIO1_AO"),
+   MTK_FUNCTION(2, "MSDC2_CLK"),
+   MTK_FUNCTION(3, "TDMIN_DI"),
+   MTK_FUNCTION(4, "CLKM1"),
+   MTK_FUNCTION(5, "CLKREQN_1"),
+   MTK_FUNCTION(6, "USB_DRVVBUS_1P"),
+   MTK_FUNCTION(7, "DMIC4_DAT")
+   ),
+   MTK_PIN(
+   2, "GPIO2",
+   MTK_EINT_FUNCTION(0, 2),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO2"),
+   MTK_FUNCTION(1, "TP_GPIO2_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT3"),
+   MTK_FUNCTION(3, "TDMIN_LRCK"),
+   MTK_FUNCTION(4, "CLKM2"),
+   MTK_FUNCTION(5, "WAKEN_1"),
+   MTK_FUNCTION(7, "DMIC2_CLK")
+   ),
+   MTK_PIN(
+   3, "GPIO3",
+   MTK_EINT_FUNCTION(0, 3),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO3"),
+   MTK_FUNCTION(1, "TP_GPIO3_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT0"),
+   MTK_FUNCTION(3, "TDMIN_BCK"),
+   MTK_FUNCTION(4, "CLKM3"),
+   MTK_FUNCTION(7, "DMIC2_DAT")
+   ),
+   MTK_PIN(
+   4, "GPIO4",
+   MTK_EINT_FUNCTION(0, 4),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO4"),
+   MTK_FUNCTION(1, "TP_GPIO4_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT2"),
+   MTK_FUNCTION(3, "SPDIF_IN1"),
+   MTK_FUNCTION(4, "UTXD3"),
+   MTK_FUNCTION(5, "SDA2"),
+   MTK_FUNCTION(7, "IDDIG_2P")
+   ),
+   MTK_PIN(
+   5, "GPIO5",
+   MTK_EINT_FUNCTION(0, 5),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO5"),
+   MTK_FUNCTION(1, "TP_GPIO5_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT1"),
+   MTK_FUNCTION(3, "SPDIF_IN0"),
+   MTK_FUNCTION(4, "URXD3"),
+   MTK_FUNCTION(5, "SCL2"),
+   MTK_FUNCTION(7, "USB_DRVVBUS_2P")
+   ),
+   MTK_PIN(
+   6, "GPIO6",
+   MTK_EINT_FUNCTION(0, 6),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO6"),
+   MTK_FUNCTION(1, "TP_GPIO6_AO"),
+   MTK_FUNCTION(2, "DP_TX_HPD"),
+   MTK_FUNCTION(3, "I2SO1_D4"),
+   MTK_FUNCTION(4, "UTXD4"),
+   MTK_FUNCTION(5, "CMVREF3"),
+   MTK_FUNCTION(7, "DMIC3_CLK")
+   ),
+   MTK_PIN(
+   7, "GPIO7",
+   MTK_EINT_FUNCTION(0, 7),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO7"),
+   MTK_FUNCTION(1, "TP_GPIO7_AO"),
+   MTK_FUNCTION(2, "EDP_TX_HPD"),
+   MTK_FUNCTION(3, "I2SO1_D5"),
+   MTK_FUNCTION(4, "URXD4"),
+   MTK_FUNCTION(5, "CMVREF4"),
+   MTK_FUNCTION(7, "DMIC3_DAT")
+   ),
+

[PATCH Resend v0 0/6] Mediatek pinctrl patch on mt8195

2021-03-29 Thread Zhiyong Tao
This series includes 6 patches:
1.add pinctrl file on mt8195.
2.add pinctrl binding document on mt8195.
3.add pinctrl device node on mt8195.
4.add pinctrl driver on MT8195.
5.add pinctrl drive for I2C related pins on MT8195.
6.add pinctrl rsel setting on MT8195.

Zhiyong Tao (6):
  dt-bindings: pinctrl: mt8195: add pinctrl file
  dt-bindings: pinctrl: mt8195: add binding document
  arm64: dts: mt8195: add pinctrl device node
  pinctrl: add pinctrl driver on mt8195
  pinctrl: add drive for I2C related pins on MT8195
  pinctrl: add rsel setting on MT8195

 .../bindings/pinctrl/pinctrl-mt8195.yaml  |  152 ++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi  |   21 +
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  872 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  |   29 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |   14 +
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  |   16 +
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  |  961 ++
 10 files changed, 3741 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

--
2.18.0




Re: [PATCH Resend 0/6] Mediatek pinctrl patch on mt8195

2021-03-29 Thread zhiyong tao
On Mon, 2021-03-29 at 13:47 +0300, Andy Shevchenko wrote:
> On Mon, Mar 29, 2021 at 11:09 AM Zhiyong Tao  wrote:
> >
> > This series includes 6 patches:
> > 1.add pinctrl file on mt8195.
> > 2.add pinctrl binding document on mt8195.
> > 3.add pinctrl device node on mt8195.
> > 4.add pinctrl driver on MT8195.
> > 5.add pinctrl drive for I2C related pins on MT8195.
> > 6.add pinctrl rsel setting on MT8195.
> 
> You submitted the same version of the series twice, but it confuses people.
> Now you have to properly send the series only one time with the
> correct version added and changelog explains the changes done between
> the versions.
> 
> 

==> Hi, Andy,
There are no change between the two version.
Because we get the refused mail from
"linux-arm-ker...@lists.infradead.org".
The error mail:
Delivery has failed to these recipients or groups:
linux-arm-ker...@lists.infradead.org
A problem occurred while delivering this message to this email address.
Try sending this message again. If the problem continues, please contact
your helpdesk.
The following organization rejected your message: desiato.infradead.org
[90.155.92.199].

We will send v0 version  and add v0 version in every patch next time.

Thanks.



[PATCH 6/6] pinctrl: add rsel setting on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides rsel setting on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  | 10 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 16 ++
 4 files changed, 62 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index a7500e18bb1d..66608b8d346a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -779,6 +779,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_adv_range[] = {
PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_rsel_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x0c0, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x0c0, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x0c0, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x0c0, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x0c0, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x0c0, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x0c0, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x0c0, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x0c0, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x0c0, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x080, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x080, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x0e0, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x0e0, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x0e0, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x0e0, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -793,6 +812,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
[PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
+   [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt8195_pin_rsel_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -823,6 +843,8 @@ static const struct mtk_pin_soc mt8195_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_drive_get = mtk_pinconf_adv_drive_get_raw,
.adv_drive_set = mtk_pinconf_adv_drive_set_raw,
+   .rsel_set = mtk_pinconf_rsel_set,
+   .rsel_get = mtk_pinconf_rsel_get,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2b51f4a9b860..d1526d0c6248 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1041,6 +1041,20 @@ int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
 
+int mtk_pinconf_rsel_set(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_RSEL, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_set);
+
+int mtk_pinconf_rsel_get(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_RSEL, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_get);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index fd5ce9c5dcbd..570e8da7bf38 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -67,6 +67,7 @@ enum {
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_DRV_ADV,
+   PINCTRL_PIN_REG_RSEL,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -237,6 +238,10 @@ struct mtk_pin_soc {
 const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
 const struct mtk_pin_desc *desc, u32 *val);
+   int (*rsel_set)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 arg);
+   int (*rsel_get)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 *val);
 
/* Specific driver data */
void*driver_data;
@@ -320,5 +325,10 @@ int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
 int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
  const struct mtk_pin

[PATCH 4/6] pinctrl: add pinctrl driver on mt8195

2021-03-29 Thread Zhiyong Tao
This commit includes pinctrl driver for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/Kconfig |   6 +
 drivers/pinctrl/mediatek/Makefile|   1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c| 828 
 include/dt-bindings/pinctrl/mt8195-pinfunc.h | 962 +++
 4 files changed, 1797 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index eef17f228669..90f0c8255eaf 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -147,6 +147,12 @@ config PINCTRL_MT8192
default ARM64 && ARCH_MEDIATEK
select PINCTRL_MTK_PARIS
 
+config PINCTRL_MT8195
+   bool "Mediatek MT8195 pin control"
+   depends on OF
+   depends on ARM64 || COMPILE_TEST
+   select PINCTRL_MTK_PARIS
+
 config PINCTRL_MT8516
bool "Mediatek MT8516 pin control"
depends on OF
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index 01218bf4dc30..06fde993ace2 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_PINCTRL_MT8167)  += pinctrl-mt8167.o
 obj-$(CONFIG_PINCTRL_MT8173)   += pinctrl-mt8173.o
 obj-$(CONFIG_PINCTRL_MT8183)   += pinctrl-mt8183.o
 obj-$(CONFIG_PINCTRL_MT8192)   += pinctrl-mt8192.o
+obj-$(CONFIG_PINCTRL_MT8195)+= pinctrl-mt8195.o
 obj-$(CONFIG_PINCTRL_MT8516)   += pinctrl-mt8516.o
 obj-$(CONFIG_PINCTRL_MT6397)   += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
new file mode 100644
index ..063f164d7c9b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -0,0 +1,828 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#include "pinctrl-mtk-mt8195.h"
+#include "pinctrl-paris.h"
+
+/* MT8195 have multiple bases to program pin configuration listed as the below:
+ * iocfg[0]:0x10005000, iocfg[1]:0x11d1, iocfg[2]:0x11d3,
+ * iocfg[3]:0x11d4, iocfg[4]:0x11e2, iocfg[5]:0x11eb,
+ * iocfg[6]:0x11f4.
+ * _i_based could be used to indicate what base the pin should be mapped into.
+ */
+
+#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
+  32, 0)
+
+#define PINS_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits,  \
+  32, 1)
+
+static const struct mtk_pin_field_calc mt8195_pin_mode_range[] = {
+   PIN_FIELD(0, 144, 0x300, 0x10, 0, 4),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_dir_range[] = {
+   PIN_FIELD(0, 144, 0x0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_di_range[] = {
+   PIN_FIELD(0, 144, 0x200, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_do_range[] = {
+   PIN_FIELD(0, 144, 0x100, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_ies_range[] = {
+   PIN_FIELD_BASE(0, 0, 4, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(1, 1, 4, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(2, 2, 4, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(3, 3, 4, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(4, 4, 4, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(5, 5, 4, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(6, 6, 4, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(7, 7, 4, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(8, 8, 4, 0x040, 0x10, 13, 1),
+   PIN_FIELD_BASE(9, 9, 4, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(10, 10, 4, 0x040, 0x10, 14, 1),
+   PIN_FIELD_BASE(11, 11, 4, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BASE(12, 12, 4, 0x040, 0x10, 15, 1),
+   PIN_FIELD_BASE(13, 13, 4, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(14, 14, 4, 0x040, 0x10, 16, 1),
+   PIN_FIELD_BASE(15, 15, 4, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(16, 16, 4, 0x040, 0x10, 17, 1),
+   PIN_FIELD_BASE(17, 17, 4, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(18, 18, 2, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(19, 19, 2, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(20, 20, 2, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(21, 21, 2, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(22, 22, 2, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(23, 23, 2, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(24, 24, 2, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(25, 25, 2, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(26, 26, 2, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(27, 27, 2, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(28, 28, 2, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(29, 29, 2, 0x040, 0x10, 8, 1),
+  

[PATCH 3/6] arm64: dts: mt8195: add pinctrl device node

2021-03-29 Thread Zhiyong Tao
This commit adds pinctrl device node for mt8195

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
index 068fe24efd2d..48b28a9d35cc 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
@@ -273,6 +273,27 @@
};
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8195-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11d1 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d4 0 0x1000>,
+ <0 0x11e2 0 0x1000>,
+ <0 0x11eb 0 0x1000>,
+ <0 0x11f4 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg_bm",
+   "iocfg_bl", "iocfg_br", "iocfg_lm",
+   "iocfg_rb", "iocfg_tl", "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 144>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
watchdog: watchdog@10007000 {
compatible = "mediatek,mt8195-wdt", 
"mediatek,mt6589-wdt";
reg = <0 0x10007000 0 0x100>;
-- 
2.18.0



[PATCH 5/6] pinctrl: add drive for I2C related pins on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides the advanced drive raw data setting version
for I2C used pins on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |  5 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index 063f164d7c9b..a7500e18bb1d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -760,6 +760,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_range[] = {
PIN_FIELD_BASE(143, 143, 1, 0x020, 0x10, 24, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_drv_adv_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x020, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x020, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x020, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x020, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x020, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x020, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x020, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x020, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x040, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x040, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x040, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -773,6 +792,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8195_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -801,6 +821,8 @@ static const struct mtk_pin_soc mt8195_data = {
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
+   .adv_drive_get = mtk_pinconf_adv_drive_get_raw,
+   .adv_drive_set = mtk_pinconf_adv_drive_set_raw,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..2b51f4a9b860 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1027,6 +1027,20 @@ int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get);
 
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_set_raw);
+
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..fd5ce9c5dcbd 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -66,6 +66,7 @@ enum {
PINCTRL_PIN_REG_DRV_EN,
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
+   PINCTRL_PIN_REG_DRV_ADV,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -314,6 +315,10 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 arg);
 int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 *val);
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg);
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val);
 
 bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
 #endif /* __PINCTRL_MTK_COMMON_V2_H */
-- 
2.18.0



[PATCH 2/6] dt-bindings: pinctrl: mt8195: add binding document

2021-03-29 Thread Zhiyong Tao
The commit adds mt8195 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 ++
 1 file changed, 152 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
new file mode 100644
index ..7915b9568c29
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
@@ -0,0 +1,152 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8195.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8195 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8195-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 8 GPIO
+  physical address base in mt8195.
+maxItems: 8
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 8
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '^pins':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+state_0_node_a {
+  pinmux = ;
+};
+/* GPIO1 set as multifunction CLKM1 */
+state_0_node_b {
+  pinmux = ;
+};
+  };
+$ref: "pinmux-node.yaml"
+
+properties:
+  pinmux:
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments, such as MTK_DRIVE_4mA, MTK_DRIVE_6mA, 
etc. See
+  dt-bindings/pinctrl/mt65xx.h. It can only support 
2/4/6/8/10/12/14/16mA in mt8195.
+enum: [2, 4, 6, 8, 10, 12, 14, 16]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8195-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11eb 0x1000>,
+  <0x11f4 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_bm", "iocfg_bl",
+  "iocfg_br", "iocfg_lm", "iocfg_rb",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 144>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+
+pins {
+  pinmux = ;
+  output-low;
+};
+};
-- 
2.18.0



[PATCH 1/6] dt-bindings: pinctrl: mt8195: add pinctrl file

2021-03-29 Thread Zhiyong Tao
This patch adds pinctrl file for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 1 file changed, 1669 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
new file mode 100644
index ..de4a8a80bf1d
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
@@ -0,0 +1,1669 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __PINCTRL_MTK_MT8195_H
+#define __PINCTRL_MTK_MT8195_H
+
+#include "pinctrl-paris.h"
+
+static const struct mtk_pin_desc mtk_pins_mt8195[] = {
+   MTK_PIN(
+   0, "GPIO0",
+   MTK_EINT_FUNCTION(0, 0),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO0"),
+   MTK_FUNCTION(1, "TP_GPIO0_AO"),
+   MTK_FUNCTION(2, "MSDC2_CMD"),
+   MTK_FUNCTION(3, "TDMIN_MCK"),
+   MTK_FUNCTION(4, "CLKM0"),
+   MTK_FUNCTION(5, "PERSTN_1"),
+   MTK_FUNCTION(6, "IDDIG_1P"),
+   MTK_FUNCTION(7, "DMIC4_CLK")
+   ),
+   MTK_PIN(
+   1, "GPIO1",
+   MTK_EINT_FUNCTION(0, 1),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO1"),
+   MTK_FUNCTION(1, "TP_GPIO1_AO"),
+   MTK_FUNCTION(2, "MSDC2_CLK"),
+   MTK_FUNCTION(3, "TDMIN_DI"),
+   MTK_FUNCTION(4, "CLKM1"),
+   MTK_FUNCTION(5, "CLKREQN_1"),
+   MTK_FUNCTION(6, "USB_DRVVBUS_1P"),
+   MTK_FUNCTION(7, "DMIC4_DAT")
+   ),
+   MTK_PIN(
+   2, "GPIO2",
+   MTK_EINT_FUNCTION(0, 2),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO2"),
+   MTK_FUNCTION(1, "TP_GPIO2_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT3"),
+   MTK_FUNCTION(3, "TDMIN_LRCK"),
+   MTK_FUNCTION(4, "CLKM2"),
+   MTK_FUNCTION(5, "WAKEN_1"),
+   MTK_FUNCTION(7, "DMIC2_CLK")
+   ),
+   MTK_PIN(
+   3, "GPIO3",
+   MTK_EINT_FUNCTION(0, 3),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO3"),
+   MTK_FUNCTION(1, "TP_GPIO3_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT0"),
+   MTK_FUNCTION(3, "TDMIN_BCK"),
+   MTK_FUNCTION(4, "CLKM3"),
+   MTK_FUNCTION(7, "DMIC2_DAT")
+   ),
+   MTK_PIN(
+   4, "GPIO4",
+   MTK_EINT_FUNCTION(0, 4),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO4"),
+   MTK_FUNCTION(1, "TP_GPIO4_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT2"),
+   MTK_FUNCTION(3, "SPDIF_IN1"),
+   MTK_FUNCTION(4, "UTXD3"),
+   MTK_FUNCTION(5, "SDA2"),
+   MTK_FUNCTION(7, "IDDIG_2P")
+   ),
+   MTK_PIN(
+   5, "GPIO5",
+   MTK_EINT_FUNCTION(0, 5),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO5"),
+   MTK_FUNCTION(1, "TP_GPIO5_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT1"),
+   MTK_FUNCTION(3, "SPDIF_IN0"),
+   MTK_FUNCTION(4, "URXD3"),
+   MTK_FUNCTION(5, "SCL2"),
+   MTK_FUNCTION(7, "USB_DRVVBUS_2P")
+   ),
+   MTK_PIN(
+   6, "GPIO6",
+   MTK_EINT_FUNCTION(0, 6),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO6"),
+   MTK_FUNCTION(1, "TP_GPIO6_AO"),
+   MTK_FUNCTION(2, "DP_TX_HPD"),
+   MTK_FUNCTION(3, "I2SO1_D4"),
+   MTK_FUNCTION(4, "UTXD4"),
+   MTK_FUNCTION(5, "CMVREF3"),
+   MTK_FUNCTION(7, "DMIC3_CLK")
+   ),
+   MTK_PIN(
+   7, "GPIO7",
+   MTK_EINT_FUNCTION(0, 7),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO7"),
+   MTK_FUNCTION(1, "TP_GPIO7_AO"),
+   MTK_FUNCTION(2, "EDP_TX_HPD"),
+   MTK_FUNCTION(3, "I2SO1_D5"),
+   MTK_FUNCTION(4, "URXD4"),
+   MTK_FUNCTION(5, "CMVREF4"),
+   MTK_FUNCTION(7, "DMIC3_DAT")
+   ),
+

[PATCH Resend 0/6] Mediatek pinctrl patch on mt8195

2021-03-29 Thread Zhiyong Tao
This series includes 6 patches:
1.add pinctrl file on mt8195.
2.add pinctrl binding document on mt8195.
3.add pinctrl device node on mt8195.
4.add pinctrl driver on MT8195.
5.add pinctrl drive for I2C related pins on MT8195.
6.add pinctrl rsel setting on MT8195.

Zhiyong Tao (6):
  dt-bindings: pinctrl: mt8195: add pinctrl file
  dt-bindings: pinctrl: mt8195: add binding document
  arm64: dts: mt8195: add pinctrl device node
  pinctrl: add pinctrl driver on mt8195
  pinctrl: add drive for I2C related pins on MT8195
  pinctrl: add rsel setting on MT8195

 .../bindings/pinctrl/pinctrl-mt8195.yaml  |  152 ++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi  |   21 +
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  872 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  |   29 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |   14 +
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  |   16 +
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  |  961 ++
 10 files changed, 3741 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

--
2.18.0





[PATCH 4/6] pinctrl: add pinctrl driver on mt8195

2021-03-29 Thread Zhiyong Tao
This commit includes pinctrl driver for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/Kconfig |   6 +
 drivers/pinctrl/mediatek/Makefile|   1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c| 828 
 include/dt-bindings/pinctrl/mt8195-pinfunc.h | 962 +++
 4 files changed, 1797 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig
index eef17f228669..90f0c8255eaf 100644
--- a/drivers/pinctrl/mediatek/Kconfig
+++ b/drivers/pinctrl/mediatek/Kconfig
@@ -147,6 +147,12 @@ config PINCTRL_MT8192
default ARM64 && ARCH_MEDIATEK
select PINCTRL_MTK_PARIS
 
+config PINCTRL_MT8195
+   bool "Mediatek MT8195 pin control"
+   depends on OF
+   depends on ARM64 || COMPILE_TEST
+   select PINCTRL_MTK_PARIS
+
 config PINCTRL_MT8516
bool "Mediatek MT8516 pin control"
depends on OF
diff --git a/drivers/pinctrl/mediatek/Makefile 
b/drivers/pinctrl/mediatek/Makefile
index 01218bf4dc30..06fde993ace2 100644
--- a/drivers/pinctrl/mediatek/Makefile
+++ b/drivers/pinctrl/mediatek/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_PINCTRL_MT8167)  += pinctrl-mt8167.o
 obj-$(CONFIG_PINCTRL_MT8173)   += pinctrl-mt8173.o
 obj-$(CONFIG_PINCTRL_MT8183)   += pinctrl-mt8183.o
 obj-$(CONFIG_PINCTRL_MT8192)   += pinctrl-mt8192.o
+obj-$(CONFIG_PINCTRL_MT8195)+= pinctrl-mt8195.o
 obj-$(CONFIG_PINCTRL_MT8516)   += pinctrl-mt8516.o
 obj-$(CONFIG_PINCTRL_MT6397)   += pinctrl-mt6397.o
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
new file mode 100644
index ..063f164d7c9b
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -0,0 +1,828 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#include "pinctrl-mtk-mt8195.h"
+#include "pinctrl-paris.h"
+
+/* MT8195 have multiple bases to program pin configuration listed as the below:
+ * iocfg[0]:0x10005000, iocfg[1]:0x11d1, iocfg[2]:0x11d3,
+ * iocfg[3]:0x11d4, iocfg[4]:0x11e2, iocfg[5]:0x11eb,
+ * iocfg[6]:0x11f4.
+ * _i_based could be used to indicate what base the pin should be mapped into.
+ */
+
+#define PIN_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits, \
+  32, 0)
+
+#define PINS_FIELD_BASE(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits) \
+   PIN_FIELD_CALC(s_pin, e_pin, i_base, s_addr, x_addrs, s_bit, x_bits,  \
+  32, 1)
+
+static const struct mtk_pin_field_calc mt8195_pin_mode_range[] = {
+   PIN_FIELD(0, 144, 0x300, 0x10, 0, 4),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_dir_range[] = {
+   PIN_FIELD(0, 144, 0x0, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_di_range[] = {
+   PIN_FIELD(0, 144, 0x200, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_do_range[] = {
+   PIN_FIELD(0, 144, 0x100, 0x10, 0, 1),
+};
+
+static const struct mtk_pin_field_calc mt8195_pin_ies_range[] = {
+   PIN_FIELD_BASE(0, 0, 4, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(1, 1, 4, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(2, 2, 4, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(3, 3, 4, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(4, 4, 4, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(5, 5, 4, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(6, 6, 4, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(7, 7, 4, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(8, 8, 4, 0x040, 0x10, 13, 1),
+   PIN_FIELD_BASE(9, 9, 4, 0x040, 0x10, 8, 1),
+   PIN_FIELD_BASE(10, 10, 4, 0x040, 0x10, 14, 1),
+   PIN_FIELD_BASE(11, 11, 4, 0x040, 0x10, 9, 1),
+   PIN_FIELD_BASE(12, 12, 4, 0x040, 0x10, 15, 1),
+   PIN_FIELD_BASE(13, 13, 4, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(14, 14, 4, 0x040, 0x10, 16, 1),
+   PIN_FIELD_BASE(15, 15, 4, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(16, 16, 4, 0x040, 0x10, 17, 1),
+   PIN_FIELD_BASE(17, 17, 4, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(18, 18, 2, 0x040, 0x10, 5, 1),
+   PIN_FIELD_BASE(19, 19, 2, 0x040, 0x10, 12, 1),
+   PIN_FIELD_BASE(20, 20, 2, 0x040, 0x10, 11, 1),
+   PIN_FIELD_BASE(21, 21, 2, 0x040, 0x10, 10, 1),
+   PIN_FIELD_BASE(22, 22, 2, 0x040, 0x10, 0, 1),
+   PIN_FIELD_BASE(23, 23, 2, 0x040, 0x10, 1, 1),
+   PIN_FIELD_BASE(24, 24, 2, 0x040, 0x10, 2, 1),
+   PIN_FIELD_BASE(25, 25, 2, 0x040, 0x10, 4, 1),
+   PIN_FIELD_BASE(26, 26, 2, 0x040, 0x10, 3, 1),
+   PIN_FIELD_BASE(27, 27, 2, 0x040, 0x10, 6, 1),
+   PIN_FIELD_BASE(28, 28, 2, 0x040, 0x10, 7, 1),
+   PIN_FIELD_BASE(29, 29, 2, 0x040, 0x10, 8, 1),
+  

[PATCH 2/6] dt-bindings: pinctrl: mt8195: add binding document

2021-03-29 Thread Zhiyong Tao
The commit adds mt8195 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8195.yaml  | 152 ++
 1 file changed, 152 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
new file mode 100644
index ..7915b9568c29
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
@@ -0,0 +1,152 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8195.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8195 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8195-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 8 GPIO
+  physical address base in mt8195.
+maxItems: 8
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 8
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '^pins':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+state_0_node_a {
+  pinmux = ;
+};
+/* GPIO1 set as multifunction CLKM1 */
+state_0_node_b {
+  pinmux = ;
+};
+  };
+$ref: "pinmux-node.yaml"
+
+properties:
+  pinmux:
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments, such as MTK_DRIVE_4mA, MTK_DRIVE_6mA, 
etc. See
+  dt-bindings/pinctrl/mt65xx.h. It can only support 
2/4/6/8/10/12/14/16mA in mt8195.
+enum: [2, 4, 6, 8, 10, 12, 14, 16]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8195-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11eb 0x1000>,
+  <0x11f4 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_bm", "iocfg_bl",
+  "iocfg_br", "iocfg_lm", "iocfg_rb",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 144>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+
+pins {
+  pinmux = ;
+  output-low;
+};
+};
-- 
2.18.0



[PATCH 3/6] arm64: dts: mt8195: add pinctrl device node

2021-03-29 Thread Zhiyong Tao
This commit adds pinctrl device node for mt8195

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 21 +
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
index 068fe24efd2d..48b28a9d35cc 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
@@ -273,6 +273,27 @@
};
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8195-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11d1 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d4 0 0x1000>,
+ <0 0x11e2 0 0x1000>,
+ <0 0x11eb 0 0x1000>,
+ <0 0x11f4 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg_bm",
+   "iocfg_bl", "iocfg_br", "iocfg_lm",
+   "iocfg_rb", "iocfg_tl", "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 144>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
watchdog: watchdog@10007000 {
compatible = "mediatek,mt8195-wdt", 
"mediatek,mt6589-wdt";
reg = <0 0x10007000 0 0x100>;
-- 
2.18.0



[PATCH 5/6] pinctrl: add drive for I2C related pins on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides the advanced drive raw data setting version
for I2C used pins on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |  5 +
 3 files changed, 41 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index 063f164d7c9b..a7500e18bb1d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -760,6 +760,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_range[] = {
PIN_FIELD_BASE(143, 143, 1, 0x020, 0x10, 24, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_drv_adv_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x020, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x020, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x020, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x020, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x020, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x020, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x020, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x020, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x020, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x020, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x040, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x040, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x040, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -773,6 +792,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8195_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -801,6 +821,8 @@ static const struct mtk_pin_soc mt8195_data = {
.bias_get_combo = mtk_pinconf_bias_get_combo,
.drive_set = mtk_pinconf_drive_set_rev1,
.drive_get = mtk_pinconf_drive_get_rev1,
+   .adv_drive_get = mtk_pinconf_adv_drive_get_raw,
+   .adv_drive_set = mtk_pinconf_adv_drive_set_raw,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..2b51f4a9b860 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1027,6 +1027,20 @@ int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get);
 
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_set_raw);
+
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_ADV, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..fd5ce9c5dcbd 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -66,6 +66,7 @@ enum {
PINCTRL_PIN_REG_DRV_EN,
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
+   PINCTRL_PIN_REG_DRV_ADV,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -314,6 +315,10 @@ int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 arg);
 int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw,
  const struct mtk_pin_desc *desc, u32 *val);
+int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 arg);
+int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, u32 *val);
 
 bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n);
 #endif /* __PINCTRL_MTK_COMMON_V2_H */
-- 
2.18.0



[PATCH 1/6] dt-bindings: pinctrl: mt8195: add pinctrl file

2021-03-29 Thread Zhiyong Tao
This patch adds pinctrl file for mt8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 1 file changed, 1669 insertions(+)
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
new file mode 100644
index ..de4a8a80bf1d
--- /dev/null
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
@@ -0,0 +1,1669 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 MediaTek Inc.
+ *
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __PINCTRL_MTK_MT8195_H
+#define __PINCTRL_MTK_MT8195_H
+
+#include "pinctrl-paris.h"
+
+static const struct mtk_pin_desc mtk_pins_mt8195[] = {
+   MTK_PIN(
+   0, "GPIO0",
+   MTK_EINT_FUNCTION(0, 0),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO0"),
+   MTK_FUNCTION(1, "TP_GPIO0_AO"),
+   MTK_FUNCTION(2, "MSDC2_CMD"),
+   MTK_FUNCTION(3, "TDMIN_MCK"),
+   MTK_FUNCTION(4, "CLKM0"),
+   MTK_FUNCTION(5, "PERSTN_1"),
+   MTK_FUNCTION(6, "IDDIG_1P"),
+   MTK_FUNCTION(7, "DMIC4_CLK")
+   ),
+   MTK_PIN(
+   1, "GPIO1",
+   MTK_EINT_FUNCTION(0, 1),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO1"),
+   MTK_FUNCTION(1, "TP_GPIO1_AO"),
+   MTK_FUNCTION(2, "MSDC2_CLK"),
+   MTK_FUNCTION(3, "TDMIN_DI"),
+   MTK_FUNCTION(4, "CLKM1"),
+   MTK_FUNCTION(5, "CLKREQN_1"),
+   MTK_FUNCTION(6, "USB_DRVVBUS_1P"),
+   MTK_FUNCTION(7, "DMIC4_DAT")
+   ),
+   MTK_PIN(
+   2, "GPIO2",
+   MTK_EINT_FUNCTION(0, 2),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO2"),
+   MTK_FUNCTION(1, "TP_GPIO2_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT3"),
+   MTK_FUNCTION(3, "TDMIN_LRCK"),
+   MTK_FUNCTION(4, "CLKM2"),
+   MTK_FUNCTION(5, "WAKEN_1"),
+   MTK_FUNCTION(7, "DMIC2_CLK")
+   ),
+   MTK_PIN(
+   3, "GPIO3",
+   MTK_EINT_FUNCTION(0, 3),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO3"),
+   MTK_FUNCTION(1, "TP_GPIO3_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT0"),
+   MTK_FUNCTION(3, "TDMIN_BCK"),
+   MTK_FUNCTION(4, "CLKM3"),
+   MTK_FUNCTION(7, "DMIC2_DAT")
+   ),
+   MTK_PIN(
+   4, "GPIO4",
+   MTK_EINT_FUNCTION(0, 4),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO4"),
+   MTK_FUNCTION(1, "TP_GPIO4_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT2"),
+   MTK_FUNCTION(3, "SPDIF_IN1"),
+   MTK_FUNCTION(4, "UTXD3"),
+   MTK_FUNCTION(5, "SDA2"),
+   MTK_FUNCTION(7, "IDDIG_2P")
+   ),
+   MTK_PIN(
+   5, "GPIO5",
+   MTK_EINT_FUNCTION(0, 5),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO5"),
+   MTK_FUNCTION(1, "TP_GPIO5_AO"),
+   MTK_FUNCTION(2, "MSDC2_DAT1"),
+   MTK_FUNCTION(3, "SPDIF_IN0"),
+   MTK_FUNCTION(4, "URXD3"),
+   MTK_FUNCTION(5, "SCL2"),
+   MTK_FUNCTION(7, "USB_DRVVBUS_2P")
+   ),
+   MTK_PIN(
+   6, "GPIO6",
+   MTK_EINT_FUNCTION(0, 6),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO6"),
+   MTK_FUNCTION(1, "TP_GPIO6_AO"),
+   MTK_FUNCTION(2, "DP_TX_HPD"),
+   MTK_FUNCTION(3, "I2SO1_D4"),
+   MTK_FUNCTION(4, "UTXD4"),
+   MTK_FUNCTION(5, "CMVREF3"),
+   MTK_FUNCTION(7, "DMIC3_CLK")
+   ),
+   MTK_PIN(
+   7, "GPIO7",
+   MTK_EINT_FUNCTION(0, 7),
+   DRV_GRP4,
+   MTK_FUNCTION(0, "GPIO7"),
+   MTK_FUNCTION(1, "TP_GPIO7_AO"),
+   MTK_FUNCTION(2, "EDP_TX_HPD"),
+   MTK_FUNCTION(3, "I2SO1_D5"),
+   MTK_FUNCTION(4, "URXD4"),
+   MTK_FUNCTION(5, "CMVREF4"),
+   MTK_FUNCTION(7, "DMIC3_DAT")
+   ),
+

[PATCH 6/6] pinctrl: add rsel setting on MT8195

2021-03-29 Thread Zhiyong Tao
This patch provides rsel setting on MT8195.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8195.c | 22 +++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 14 
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  | 10 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 16 ++
 4 files changed, 62 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8195.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
index a7500e18bb1d..66608b8d346a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8195.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8195.c
@@ -779,6 +779,25 @@ static const struct mtk_pin_field_calc 
mt8195_pin_drv_adv_range[] = {
PIN_FIELD_BASE(45, 45, 1, 0x040, 0x10, 9, 3),
 };
 
+static const struct mtk_pin_field_calc mt8195_pin_rsel_range[] = {
+   PIN_FIELD_BASE(8, 8, 4, 0x0c0, 0x10, 15, 3),
+   PIN_FIELD_BASE(9, 9, 4, 0x0c0, 0x10, 0, 3),
+   PIN_FIELD_BASE(10, 10, 4, 0x0c0, 0x10, 18, 3),
+   PIN_FIELD_BASE(11, 11, 4, 0x0c0, 0x10, 3, 3),
+   PIN_FIELD_BASE(12, 12, 4, 0x0c0, 0x10, 21, 3),
+   PIN_FIELD_BASE(13, 13, 4, 0x0c0, 0x10, 6, 3),
+   PIN_FIELD_BASE(14, 14, 4, 0x0c0, 0x10, 24, 3),
+   PIN_FIELD_BASE(15, 15, 4, 0x0c0, 0x10, 9, 3),
+   PIN_FIELD_BASE(16, 16, 4, 0x0c0, 0x10, 27, 3),
+   PIN_FIELD_BASE(17, 17, 4, 0x0c0, 0x10, 12, 3),
+   PIN_FIELD_BASE(29, 29, 2, 0x080, 0x10, 0, 3),
+   PIN_FIELD_BASE(30, 30, 2, 0x080, 0x10, 3, 3),
+   PIN_FIELD_BASE(34, 34, 1, 0x0e0, 0x10, 0, 3),
+   PIN_FIELD_BASE(35, 35, 1, 0x0e0, 0x10, 3, 3),
+   PIN_FIELD_BASE(44, 44, 1, 0x0e0, 0x10, 6, 3),
+   PIN_FIELD_BASE(45, 45, 1, 0x0e0, 0x10, 9, 3),
+};
+
 static const struct mtk_pin_reg_calc mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8195_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8195_pin_dir_range),
@@ -793,6 +812,7 @@ static const struct mtk_pin_reg_calc 
mt8195_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8195_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8195_pin_r1_range),
[PINCTRL_PIN_REG_DRV_ADV] = MTK_RANGE(mt8195_pin_drv_adv_range),
+   [PINCTRL_PIN_REG_RSEL] = MTK_RANGE(mt8195_pin_rsel_range),
 };
 
 static const char * const mt8195_pinctrl_register_base_names[] = {
@@ -823,6 +843,8 @@ static const struct mtk_pin_soc mt8195_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_drive_get = mtk_pinconf_adv_drive_get_raw,
.adv_drive_set = mtk_pinconf_adv_drive_set_raw,
+   .rsel_set = mtk_pinconf_rsel_set,
+   .rsel_get = mtk_pinconf_rsel_get,
 };
 
 static const struct of_device_id mt8195_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 2b51f4a9b860..d1526d0c6248 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -1041,6 +1041,20 @@ int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
 }
 EXPORT_SYMBOL_GPL(mtk_pinconf_adv_drive_get_raw);
 
+int mtk_pinconf_rsel_set(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 arg)
+{
+   return mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_RSEL, arg);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_set);
+
+int mtk_pinconf_rsel_get(struct mtk_pinctrl *hw,
+const struct mtk_pin_desc *desc, u32 *val)
+{
+   return mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_RSEL, val);
+}
+EXPORT_SYMBOL_GPL(mtk_pinconf_rsel_get);
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Sean Wang ");
 MODULE_DESCRIPTION("Pin configuration library module for mediatek SoCs");
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index fd5ce9c5dcbd..570e8da7bf38 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -67,6 +67,7 @@ enum {
PINCTRL_PIN_REG_DRV_E0,
PINCTRL_PIN_REG_DRV_E1,
PINCTRL_PIN_REG_DRV_ADV,
+   PINCTRL_PIN_REG_RSEL,
PINCTRL_PIN_REG_MAX,
 };
 
@@ -237,6 +238,10 @@ struct mtk_pin_soc {
 const struct mtk_pin_desc *desc, u32 arg);
int (*adv_drive_get)(struct mtk_pinctrl *hw,
 const struct mtk_pin_desc *desc, u32 *val);
+   int (*rsel_set)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 arg);
+   int (*rsel_get)(struct mtk_pinctrl *hw,
+   const struct mtk_pin_desc *desc, u32 *val);
 
/* Specific driver data */
void*driver_data;
@@ -320,5 +325,10 @@ int mtk_pinconf_adv_drive_set_raw(struct mtk_pinctrl *hw,
 int mtk_pinconf_adv_drive_get_raw(struct mtk_pinctrl *hw,
  const struct mtk_pin

[PATCH 0/6] Mediatek pinctrl patch on mt8195

2021-03-29 Thread Zhiyong Tao
This series includes 6 patches:
1.add pinctrl file on mt8195.
2.add pinctrl binding document on mt8195.
3.add pinctrl device node on mt8195.
4.add pinctrl driver on MT8195.
5.add pinctrl drive for I2C related pins on MT8195.
6.add pinctrl rsel setting on MT8195.

Zhiyong Tao (6):
  dt-bindings: pinctrl: mt8195: add pinctrl file
  dt-bindings: pinctrl: mt8195: add binding document
  arm64: dts: mt8195: add pinctrl device node
  pinctrl: add pinctrl driver on mt8195
  pinctrl: add drive for I2C related pins on MT8195
  pinctrl: add rsel setting on MT8195

 .../bindings/pinctrl/pinctrl-mt8195.yaml  |  152 ++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi  |   21 +
 drivers/pinctrl/mediatek/Kconfig  |6 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8195.c |  872 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  |   29 +
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |   14 +
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h | 1669 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  |   16 +
 include/dt-bindings/pinctrl/mt8195-pinfunc.h  |  961 ++
 10 files changed, 3741 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8195.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8195.h
 create mode 100644 include/dt-bindings/pinctrl/mt8195-pinfunc.h

--
2.18.0




[PATCH v2 0/1] Mediatek pinctrl patch

2021-03-20 Thread Zhiyong Tao
This series includes 1 patches:
1.add lock in mtk_rmw function.

Changes in patch v2:
1)add mutex lock init in "pinctrl-moore.c".

Zhiyong Tao (1):
  pinctrl: add lock in mtk_rmw function.

 drivers/pinctrl/mediatek/pinctrl-moore.c | 2 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 4 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 2 ++
 4 files changed, 10 insertions(+)

--
2.25.1




[PATCH] pinctrl: add lock in mtk_rmw function.

2021-03-20 Thread Zhiyong Tao
When multiple threads operate on the same register resource
which include multiple pin, It will make the register resource
wrong to control. So we add lock to avoid the case.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-moore.c | 2 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 4 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 2 ++
 4 files changed, 10 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c 
b/drivers/pinctrl/mediatek/pinctrl-moore.c
index 0fa7de43bc4c..f77921957f15 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -619,6 +619,8 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,
 
hw->nbase = hw->soc->nbase_names;
 
+   mutex_init(>lock);
+
/* Copy from internal struct mtk_pin_desc to register to the core */
pins = devm_kmalloc_array(>dev, hw->soc->npins, sizeof(*pins),
  GFP_KERNEL);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..fcf7c34a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -58,10 +58,14 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 
mask, u32 set)
 {
u32 val;
 
+   mutex_lock(>lock);
+
val = mtk_r32(pctl, i, reg);
val &= ~mask;
val |= set;
mtk_w32(pctl, i, reg, val);
+
+   mutex_unlock(>lock);
 }
 
 static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..65eac708a3b3 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -251,6 +251,8 @@ struct mtk_pinctrl {
struct mtk_eint *eint;
struct mtk_pinctrl_group*groups;
const char  **grp_names;
+   /* lock pin's register resource to avoid multiple threads issue*/
+   struct mutex lock;
 };
 
 void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set);
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c 
b/drivers/pinctrl/mediatek/pinctrl-paris.c
index da1f19288aa6..48e823f6d293 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -970,6 +970,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,
 
hw->nbase = hw->soc->nbase_names;
 
+   mutex_init(>lock);
+
err = mtk_pctrl_build_state(pdev);
if (err) {
dev_err(>dev, "build state failed: %d\n", err);
-- 
2.18.0



Re: [PATCH] pinctrl: add lock in mtk_rmw function.

2021-03-16 Thread zhiyong tao
On Tue, 2021-03-16 at 13:05 +0800, Sean Wang wrote:
> Hi Zhiyong,
> 
> On Fri, Mar 12, 2021 at 2:35 PM Zhiyong Tao  wrote:
> >
> > When multiple threads operate on the same register resource
> > which include multiple pin, It will make the register resource
> > wrong to control. So we add lock to avoid the case.
> >
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 4 
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 ++
> >  drivers/pinctrl/mediatek/pinctrl-paris.c | 2 ++
> >  3 files changed, 8 insertions(+)
> >
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
> > b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > index 72f17f26acd8..fcf7c34a 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
> > @@ -58,10 +58,14 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, 
> > u32 mask, u32 set)
> >  {
> > u32 val;
> >
> > +   mutex_lock(>lock);
> > +
> > val = mtk_r32(pctl, i, reg);
> > val &= ~mask;
> > val |= set;
> > mtk_w32(pctl, i, reg, val);
> > +
> > +   mutex_unlock(>lock);
> >  }
> >
> >  static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
> > b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
> > index e2aae285b5fc..65eac708a3b3 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
> > @@ -251,6 +251,8 @@ struct mtk_pinctrl {
> > struct mtk_eint *eint;
> > struct mtk_pinctrl_group*groups;
> > const char  **grp_names;
> > +   /* lock pin's register resource to avoid multiple threads issue*/
> > +   struct mutex lock;
> >  };
> >
> >  void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set);
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c 
> > b/drivers/pinctrl/mediatek/pinctrl-paris.c
> > index da1f19288aa6..48e823f6d293 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
> > @@ -970,6 +970,8 @@ int mtk_paris_pinctrl_probe(struct platform_device 
> > *pdev,
> >
> > hw->nbase = hw->soc->nbase_names;
> >
> > +   mutex_init(>lock);
> > +
> 
> Could you help add the mutex initialization into pinctrl-moore.c too?
> and then the patch would look good to me.

==>Hi sean,
We will add add the mutex initialization into pinctrl-moore.c too in v2.

Thanks.
> 
> > err = mtk_pctrl_build_state(pdev);
> > if (err) {
> > dev_err(>dev, "build state failed: %d\n", err);
> > --
> > 2.18.0
> >



[PATCH 0/1] Mediatek pinctrl patch

2021-03-11 Thread Zhiyong Tao
This series includes 1 patches:
1.add lock in mtk_rmw function.

Zhiyong Tao (1):
  pinctrl: add lock in mtk_rmw function.

 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 4 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 2 ++
 3 files changed, 8 insertions(+)

--
2.25.1




[PATCH] pinctrl: add lock in mtk_rmw function.

2021-03-11 Thread Zhiyong Tao
When multiple threads operate on the same register resource
which include multiple pin, It will make the register resource
wrong to control. So we add lock to avoid the case.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 4 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 72f17f26acd8..fcf7c34a 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -58,10 +58,14 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 
mask, u32 set)
 {
u32 val;
 
+   mutex_lock(>lock);
+
val = mtk_r32(pctl, i, reg);
val &= ~mask;
val |= set;
mtk_w32(pctl, i, reg, val);
+
+   mutex_unlock(>lock);
 }
 
 static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index e2aae285b5fc..65eac708a3b3 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -251,6 +251,8 @@ struct mtk_pinctrl {
struct mtk_eint *eint;
struct mtk_pinctrl_group*groups;
const char  **grp_names;
+   /* lock pin's register resource to avoid multiple threads issue*/
+   struct mutex lock;
 };
 
 void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set);
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c 
b/drivers/pinctrl/mediatek/pinctrl-paris.c
index da1f19288aa6..48e823f6d293 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -970,6 +970,8 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,
 
hw->nbase = hw->soc->nbase_names;
 
+   mutex_init(>lock);
+
err = mtk_pctrl_build_state(pdev);
if (err) {
dev_err(>dev, "build state failed: %d\n", err);
-- 
2.18.0



[PATCH] pinctrl: fix low level output voltage issue

2020-11-20 Thread Zhiyong Tao
This patch is used to fix low level output voltage issue.
A pin is changed from input pull-up to output high.
The Dout value of the pin is default as 0.
If we change the direction of the pin before the dout value of the pin,
It maybe produce a low level output voltage between "input pull-up" and
"output high".

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-paris.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c 
b/drivers/pinctrl/mediatek/pinctrl-paris.c
index 623af4410b07..039ce9be19c5 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -247,13 +247,13 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, 
unsigned int pin,
err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_SR, !!arg);
break;
case PIN_CONFIG_OUTPUT:
-   err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
-  MTK_OUTPUT);
+   err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO,
+  arg);
if (err)
goto err;
 
-   err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO,
-  arg);
+   err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DIR,
+  MTK_OUTPUT);
break;
case PIN_CONFIG_INPUT_SCHMITT:
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
-- 
2.18.0



[PATCH 0/1] Mediatek pinctrl patch

2020-11-20 Thread Zhiyong Tao
This series includes 1 patches:
1.fix low level output voltage issue.

Zhiyong Tao (1):
  pinctrl: fix low level output voltage issue

 drivers/pinctrl/mediatek/pinctrl-paris.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

--
2.18.0




[PATCH v4 1/3] dt-bindings: pinctrl: mt8192: add pinctrl file

2020-08-16 Thread Zhiyong Tao
This patch adds pinctrl file for mt8192.

Signed-off-by: Zhiyong Tao 
Reviewed-by: Rob Herring 
---
 include/dt-bindings/pinctrl/mt8192-pinfunc.h | 1344 ++
 1 file changed, 1344 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

diff --git a/include/dt-bindings/pinctrl/mt8192-pinfunc.h 
b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
new file mode 100644
index ..71ffe3a52578
--- /dev/null
+++ b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
@@ -0,0 +1,1344 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8192_PINFUNC_H
+#define __MT8192_PINFUNC_H
+
+#include "mt65xx.h"
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_SPI6_CLK (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_I2S5_MCK (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_PWM_0 (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_TDM_LRCK (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_MD_INT0 (MTK_PIN_NO(0) | 6)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_SPI6_CSB (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_I2S5_BCK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_PWM_1 (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_TDM_BCK (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_MD_INT1_C2K_UIM0_HOT_PLUG (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_DBG_MON_A9 (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_SPI6_MI (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_I2S5_LRCK (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_PWM_2 (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_TDM_MCK (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_MD_INT2_C2K_UIM1_HOT_PLUG (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_DBG_MON_A10 (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_SPI6_MO (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_I2S5_DO (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_PWM_3 (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_TDM_DATA0 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_CLKM0 (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_DBG_MON_A11 (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_SPI4_A_CLK (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S2_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_DMIC1_CLK (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_TDM_DATA1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_PCM1_DI (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_IDDIG (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_SPI4_A_CSB (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S2_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_DMIC1_DAT (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_TDM_DATA2 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_PCM1_CLK (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_USB_DRVVBUS (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_SPI4_A_MI (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S2_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_DMIC_CLK (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_TDM_DATA3 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_PCM1_SYNC (MTK_PIN_NO(6) | 6)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI4_A_MO (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S2_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_DMIC_DAT (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_WIFI_TXD (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_PCM1_DO0 (MTK_PIN_NO(7) | 6)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SRCLKENAI1 (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_I2S2_DI2 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_KPCOL2 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_TCXOENA_REQ (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_CLKM1 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_PCM1_DO1 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_DBG_MON_A12 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define PINMUX_GPIO9__FUNC_SRCLKENAI0 (MTK_PIN_NO(9) | 1)
+#define PINMUX_GPIO9__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(9) | 2)
+#define PINMUX_GPIO9__FUNC_KPROW2 (MTK_PIN_NO(9) | 3)
+#define PINMUX_GPIO9__FUNC_CMMCLK4 (MTK_PIN

[PATCH v4 0/3] Mediatek pinctrl patch on mt8192

2020-08-16 Thread Zhiyong Tao
This series includes 3 patches:
1.add pinctrl file on mt8192.
2.add pinctrl binding document on mt8192.
3.add pinctrl driver on MT8192.

Changes in patch v4:
1)remove execute permission of 'pinctrl-mt8192.yaml'.
2)change '$ref: "pinmux-node.yaml"' under '^pins'.
3)add a pin node sample in 'examples'.

Changes in patch v3:
1)fix running 'make dt_binding_check' errors.
2)change 'node' to 'pincontroller'.
3)add an actual example.
4)change ref as 'pinmux-node.yaml'.
5)remove 'GENERIC_PINCONFIG'.
6)add 'addtionalProperties: false'.

Changes in patch v2:
1)change maintainers name in pinctrl-mt8192.yaml.
2)remove unused description for "reg-names".
3)change 'subnode format:' which is not a child name to "^pins".
4)add ('|') after "description:".
5)remove "i2c0_pins_a: i2c0" and "i2c0_pins_a: i2c1".
6)add properties for pin configuration nodes.

Zhiyong Tao (3):
  dt-bindings: pinctrl: mt8192: add pinctrl file
  dt-bindings: pinctrl: mt8192: add binding document
  pinctrl: add pinctrl driver on mt8192

 .../bindings/pinctrl/pinctrl-mt8192.yaml  |  155 ++
 drivers/pinctrl/mediatek/Kconfig  |7 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8192.c | 1409 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h | 2275 +
 include/dt-bindings/pinctrl/mt8192-pinfunc.h  | 1344 ++
 6 files changed, 5191 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8192.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

--
2.25.1



[PATCH v4 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-08-16 Thread Zhiyong Tao
The commit adds mt8192 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8192.yaml  | 155 ++
 1 file changed, 155 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
new file mode 100644
index ..5556def6b99b
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
@@ -0,0 +1,155 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8192.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8192 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8192-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 11 GPIO
+  physical address base in mt8192.
+maxItems: 11
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 11
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '^pins':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+state_0_node_a {
+  pinmux = ;
+};
+/* GPIO1 set as multifunction PWM */
+state_0_node_b {
+  pinmux = ;
+};
+  };
+$ref: "pinmux-node.yaml"
+
+properties:
+  pinmux:
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments, such as MTK_DRIVE_4mA, MTK_DRIVE_6mA, 
etc. See
+  dt-bindings/pinctrl/mt65xx.h. It can only support 
2/4/6/8/10/12/14/16mA in mt8192.
+enum: [2, 4, 6, 8, 10, 12, 14, 16]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties:  false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8192-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11c2 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11e7 0x1000>,
+  <0x11ea 0x1000>,
+  <0x11f2 0x1000>,
+  <0x11f3 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_rm", "iocfg_bm",
+  "iocfg_bl", "iocfg_br", "iocfg_lm",
+  "iocfg_lb", "iocfg_rt", "iocfg_lt",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 220>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+
+pins {
+  pinmux = ;
+  output-low;
+};
+};
-- 
2.18.0


[PATCH v3 1/3] dt-bindings: pinctrl: mt8192: add pinctrl file

2020-08-07 Thread Zhiyong Tao
This patch adds pinctrl file for mt8192.

Signed-off-by: Zhiyong Tao 
---
 include/dt-bindings/pinctrl/mt8192-pinfunc.h | 1344 ++
 1 file changed, 1344 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

diff --git a/include/dt-bindings/pinctrl/mt8192-pinfunc.h 
b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
new file mode 100644
index ..71ffe3a52578
--- /dev/null
+++ b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
@@ -0,0 +1,1344 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8192_PINFUNC_H
+#define __MT8192_PINFUNC_H
+
+#include "mt65xx.h"
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_SPI6_CLK (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_I2S5_MCK (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_PWM_0 (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_TDM_LRCK (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_MD_INT0 (MTK_PIN_NO(0) | 6)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_SPI6_CSB (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_I2S5_BCK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_PWM_1 (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_TDM_BCK (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_MD_INT1_C2K_UIM0_HOT_PLUG (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_DBG_MON_A9 (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_SPI6_MI (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_I2S5_LRCK (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_PWM_2 (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_TDM_MCK (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_MD_INT2_C2K_UIM1_HOT_PLUG (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_DBG_MON_A10 (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_SPI6_MO (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_I2S5_DO (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_PWM_3 (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_TDM_DATA0 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_CLKM0 (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_DBG_MON_A11 (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_SPI4_A_CLK (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S2_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_DMIC1_CLK (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_TDM_DATA1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_PCM1_DI (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_IDDIG (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_SPI4_A_CSB (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S2_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_DMIC1_DAT (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_TDM_DATA2 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_PCM1_CLK (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_USB_DRVVBUS (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_SPI4_A_MI (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S2_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_DMIC_CLK (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_TDM_DATA3 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_PCM1_SYNC (MTK_PIN_NO(6) | 6)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI4_A_MO (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S2_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_DMIC_DAT (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_WIFI_TXD (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_PCM1_DO0 (MTK_PIN_NO(7) | 6)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SRCLKENAI1 (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_I2S2_DI2 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_KPCOL2 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_TCXOENA_REQ (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_CLKM1 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_PCM1_DO1 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_DBG_MON_A12 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define PINMUX_GPIO9__FUNC_SRCLKENAI0 (MTK_PIN_NO(9) | 1)
+#define PINMUX_GPIO9__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(9) | 2)
+#define PINMUX_GPIO9__FUNC_KPROW2 (MTK_PIN_NO(9) | 3)
+#define PINMUX_GPIO9__FUNC_CMMCLK4 (MTK_PIN_NO(9) | 4

[PATCH v3 0/3] Mediatek pinctrl patch on mt8192

2020-08-07 Thread Zhiyong Tao
This series includes 3 patches:
1.add pinctrl file on mt8192.
2.add pinctrl binding document on mt8192.
3.add pinctrl driver on MT8192.

Changes in patch v3:
1)fix running 'make dt_binding_check' errors.
2)change 'node' to 'pincontroller'.
3)add an actual example.
4)change ref as 'pinmux-node.yaml'.
5)remove 'GENERIC_PINCONFIG'.
6)add 'addtionalProperties: false'.

Changes in patch v2:
1)change maintainers name in pinctrl-mt8192.yaml.
2)remove unused description for "reg-names".
3)change 'subnode format:' which is not a child name to "^pins".
4)add ('|') after "description:".
5)remove "i2c0_pins_a: i2c0" and "i2c0_pins_a: i2c1".
6)add properties for pin configuration nodes.

Zhiyong Tao (3):
  dt-bindings: pinctrl: mt8192: add pinctrl file
  dt-bindings: pinctrl: mt8192: add binding document
  pinctrl: add pinctrl driver on mt8192

 .../bindings/pinctrl/pinctrl-mt8192.yaml  |  195 ++
 drivers/pinctrl/mediatek/Kconfig  |7 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8192.c | 1408 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h | 2275 +
 include/dt-bindings/pinctrl/mt8192-pinfunc.h  | 1344 ++
 6 files changed, 5230 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8192.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

--
2.25.1



[PATCH v3 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-08-07 Thread Zhiyong Tao
The commit adds mt8192 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8192.yaml  | 149 ++
 1 file changed, 149 insertions(+)
 create mode 100755 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
new file mode 100755
index ..3b46bbfa38ec
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
@@ -0,0 +1,149 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8192.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8192 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8192-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 11 GPIO
+  physical address base in mt8192.
+maxItems: 11
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 11
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '^pins':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  pincontroller {
+/* GPIO0 set as multifunction GPIO0 */
+state_0_node_a {
+  pinmux = ;
+};
+/* GPIO1 set as multifunction PWM */
+state_0_node_a {
+  pinmux = ;
+};
+  };
+properties:
+  pinmux:
+$ref: "pinmux-node.yaml"
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  drive-strength:
+description: |
+  It can support some arguments, such as MTK_DRIVE_4mA, MTK_DRIVE_6mA, 
etc. See
+  dt-bindings/pinctrl/mt65xx.h. It can only support 
2/4/6/8/10/12/14/16mA in mt8192.
+enum: [2, 4, 6, 8, 10, 12, 14, 16]
+
+  bias-pull-down: true
+
+  bias-pull-up: true
+
+  bias-disable: true
+
+  output-high: true
+
+  output-low: true
+
+  input-enable: true
+
+  input-disable: true
+
+  input-schmitt-enable: true
+
+  input-schmitt-disable: true
+
+required:
+  - pinmux
+
+additionalProperties:  false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - gpio-controller
+  - '#gpio-cells'
+  - gpio-ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+pio: pinctrl@10005000 {
+compatible = "mediatek,mt8192-pinctrl";
+reg = <0x10005000 0x1000>,
+  <0x11c2 0x1000>,
+  <0x11d1 0x1000>,
+  <0x11d3 0x1000>,
+  <0x11d4 0x1000>,
+  <0x11e2 0x1000>,
+  <0x11e7 0x1000>,
+  <0x11ea 0x1000>,
+  <0x11f2 0x1000>,
+  <0x11f3 0x1000>,
+  <0x1000b000 0x1000>;
+reg-names = "iocfg0", "iocfg_rm", "iocfg_bm",
+  "iocfg_bl", "iocfg_br", "iocfg_lm",
+  "iocfg_lb", "iocfg_rt", "iocfg_lt",
+  "iocfg_tl", "eint";
+gpio-controller;
+#gpio-cells = <2>;
+gpio-ranges = < 0 0 220>;
+interrupt-controller;
+interrupts = ;
+#interrupt-cells = <2>;
+};
-- 
2.18.0


Re: [PATCH v2 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-08-03 Thread zhiyong tao
On Mon, 2020-08-03 at 15:46 -0600, Rob Herring wrote:
> On Sat, Aug 01, 2020 at 12:33:02PM +0800, Zhiyong Tao wrote:
> > The commit adds mt8192 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  .../bindings/pinctrl/pinctrl-mt8192.yaml  | 175 ++
> >  1 file changed, 175 insertions(+)
> >  create mode 100755 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > new file mode 100755
> > index ..88e18e2e23a0
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > @@ -0,0 +1,175 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8192.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Mediatek MT8192 Pin Controller
> > +
> > +maintainers:
> > +  - Sean Wang 
> > +
> > +description: |
> > +  The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +properties:
> > +  compatible:
> > +const: mediatek,mt8192-pinctrl
> > +
> > +  gpio-controller: true
> > +
> > +  '#gpio-cells':
> > +description: |
> > +  Number of cells in GPIO specifier. Since the generic GPIO binding is 
> > used,
> > +  the amount of cells must be specified as 2. See the below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +const: 2
> > +
> > +  gpio-ranges:
> > +description: gpio valid number range.
> > +maxItems: 1
> > +
> > +  reg:
> > +description: |
> > +  Physical address base for gpio base registers. There are 11 GPIO
> > +  physical address base in mt8192.
> > +maxItems: 11
> > +
> > +  reg-names:
> > +description: |
> > +  Gpio base register names.
> > +maxItems: 11
> > +
> > +  interrupt-controller: true
> > +
> > +  '#interrupt-cells':
> > +const: 2
> > +
> > +  interrupts:
> > +description: The interrupt outputs to sysirq.
> > +maxItems: 1
> > +
> > +#PIN CONFIGURATION NODES
> > +patternProperties:
> > +  '^pins':
> > +type: object
> > +description: |
> > +  A pinctrl node should contain at least one subnodes representing the
> > +  pinctrl groups available on the machine. Each subnode will list the
> > +  pins it needs, and how they should be configured, with regard to 
> > muxer
> > +  configuration, pullups, drive strength, input enable/disable and
> > +  input schmitt.
> > +  An example of using macro:
> > +  node {
> 
> 'node' doesn't match '^pins' regex.
> 
> Better to put an example in the actual example so it is checked.

==>  
Dear Rob,
  we will change it as the actual example in v3:
   pincontroller {
 /* GPIO0 set as multifunction GPIO0*/
 state_0_node_a {
   pinmux = ;
 };
 /* GPIO0 set as multifunction PWM*/
 state_0_node_b {
   pinmux = ;
 };
   };

  Is it ok?
 
> > +pinmux = ;
> > +GENERIC_PINCONFIG;
> > +  };
> > +properties:
> > +  pinmux:
> > +$ref: "/schemas/types.yaml#/definitions/uint32-array"
> 
> Already a common definition in pinmux-node.yaml. Reference that file in 
> '^pins'
> .
==>
  we will change the ref as "$ref: "pinmux-node.yaml"" in v3.

> > +description: |
> > +  Integer array, represents gpio pin number and mux setting.
> > +  Supported pin number and mux varies for different SoCs, and are 
> > defined
> > +  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
> > +
> > +  GENERIC_PINCONFIG:
> 
> That's not a property name.
==> we will remove it in v3. and separate out the property name
"mediatek,pull-up-adv", "mediatek,pull-down-adv", "mediatek,tdsel",
"mediatek,rdsel", "drive-strength", "mediatek,drive-strength-adv =
;" in v3.
> 
> > +description: |
> > +  It is the generic pinconfig options to use, bias-disable,
> > +  bias-pull-down, bias-pull-up, input-enable, input-disable, 
> > output-low,
> &

Re: [PATCH v2 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-08-03 Thread zhiyong tao
On Mon, 2020-08-03 at 15:40 -0600, Rob Herring wrote:
> On Sat, 01 Aug 2020 12:33:02 +0800, Zhiyong Tao wrote:
> > The commit adds mt8192 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  .../bindings/pinctrl/pinctrl-mt8192.yaml  | 175 ++
> >  1 file changed, 175 insertions(+)
> >  create mode 100755 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > 
> 
> 
> My bot found errors running 'make dt_binding_check' on your patch:

==> Dear Rob,
I will fix it in v3. Thanks.
> 
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:0: [0, 268455936, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:1: [0, 297926656, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:2: [0, 298909696, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:3: [0, 299040768, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:4: [0, 299106304, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:5: [0, 300023808, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:6: [0, 300351488, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:7: [0, 300548096, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:8: [0, 301072384, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:9: [0, 301137920, 0, 4096] is too long
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.example.dt.yaml:
>  example-0: pinctrl@10005000:reg:10: [0, 268480512, 0, 4096] is too long
> 
> 
> See https://patchwork.ozlabs.org/patch/1339661
> 
> If you already ran 'make dt_binding_check' and didn't see the above
> error(s), then make sure dt-schema is up to date:
> 
> pip3 install git+https://github.com/devicetree-org/dt-schema.git@master 
> --upgrade
> 
> Please check and re-submit.
> 



[PATCH v2 0/3] Mediatek pinctrl patch on mt8192

2020-07-31 Thread Zhiyong Tao
This series includes 3 patches:
1.add pinctrl file on mt8192.
2.add pinctrl binding document on mt8192.
3.add pinctrl driver on MT8192.

Changes in patch v2:
1)change maintainers name in pinctrl-mt8192.yaml.
2)remove unused description for "reg-names".
3)change 'subnode format:' which is not a child name to "^pins".
4)add ('|') after "description:".
5)remove "i2c0_pins_a: i2c0" and "i2c0_pins_a: i2c1".
6)add properties for pin configuration nodes.

Zhiyong Tao (3):
  dt-bindings: pinctrl: mt8192: add pinctrl file
  dt-bindings: pinctrl: mt8192: add binding document
  pinctrl: add pinctrl driver on mt8192

 .../bindings/pinctrl/pinctrl-mt8192.yaml  |  151 ++
 drivers/pinctrl/mediatek/Kconfig  |7 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8192.c | 1453 +++
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h | 2228 +
 include/dt-bindings/pinctrl/mt8192-pinfunc.h  | 1344 ++
 6 files changed, 5184 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8192.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

--
2.18.0



[PATCH v2 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-07-31 Thread Zhiyong Tao
The commit adds mt8192 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8192.yaml  | 175 ++
 1 file changed, 175 insertions(+)
 create mode 100755 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
new file mode 100755
index ..88e18e2e23a0
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
@@ -0,0 +1,175 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8192.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8192 Pin Controller
+
+maintainers:
+  - Sean Wang 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8192-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description: |
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description: |
+  Physical address base for gpio base registers. There are 11 GPIO
+  physical address base in mt8192.
+maxItems: 11
+
+  reg-names:
+description: |
+  Gpio base register names.
+maxItems: 11
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  '^pins':
+type: object
+description: |
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+  An example of using macro:
+  node {
+pinmux = ;
+GENERIC_PINCONFIG;
+  };
+properties:
+  pinmux:
+$ref: "/schemas/types.yaml#/definitions/uint32-array"
+description: |
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are 
defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+
+  GENERIC_PINCONFIG:
+description: |
+  It is the generic pinconfig options to use, bias-disable,
+  bias-pull-down, bias-pull-up, input-enable, input-disable, 
output-low,
+  output-high, input-schmitt-enable, input-schmitt-disable
+  and drive-strength are valid.
+
+  Some special pins have extra pull up strength, there are R0 and R1 
pull-up
+  resistors available, but for user, it's only need to set R1R0 as 00, 
01,
+  10 or 11. So It needs config "mediatek,pull-up-adv" or
+  "mediatek,pull-down-adv" to support arguments for those special pins.
+  Valid arguments are from 0 to 3.
+
+  We can use "mediatek,tdsel" which is an integer describing the steps 
for
+  output level shifter duty cycle when asserted (high pulse width 
adjustment).
+  Valid arguments  are from 0 to 15.
+  We can use "mediatek,rdsel" which is an integer describing the steps 
for
+  input level shifter duty cycle when asserted (high pulse width 
adjustment).
+  Valid arguments are from 0 to 63.
+
+  When config drive-strength, it can support some arguments, such as
+  MTK_DRIVE_4mA, MTK_DRIVE_6mA, etc. See dt-bindings/pinctrl/mt65xx.h.
+  It can only support 2/4/6/8/10/12/14/16mA in mt8192.
+  For I2C pins, there are existing generic driving setup and the 
specific
+  driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA 
driving
+  adjustment in generic driving setup. But in specific driving setup,
+  they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific
+  driving setup for I2C pins, the existing generic driving setup will 
be
+  disabled. For some special features, we need the I2C pins specific
+  driving setup. The specific driving setup is controlled by E1E0EN.
+  So we need add extra vendor driving preperty instead of
+  the generic driving property.
+  We can add "mediatek,drive-strength-adv = ;" to describe the 
specific
+  driving setup property. "XXX" means the value of E1E0EN. EN is 0 or 
1.
+  It is used to enable or disable the specific driving setup.
+  E1E0

[PATCH v2 1/3] dt-bindings: pinctrl: mt8192: add pinctrl file

2020-07-31 Thread Zhiyong Tao
This patch adds pinctrl file for mt8192.

Signed-off-by: Zhiyong Tao 
---
 include/dt-bindings/pinctrl/mt8192-pinfunc.h | 1344 ++
 1 file changed, 1344 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

diff --git a/include/dt-bindings/pinctrl/mt8192-pinfunc.h 
b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
new file mode 100644
index ..71ffe3a52578
--- /dev/null
+++ b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
@@ -0,0 +1,1344 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8192_PINFUNC_H
+#define __MT8192_PINFUNC_H
+
+#include "mt65xx.h"
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_SPI6_CLK (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_I2S5_MCK (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_PWM_0 (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_TDM_LRCK (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_MD_INT0 (MTK_PIN_NO(0) | 6)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_SPI6_CSB (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_I2S5_BCK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_PWM_1 (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_TDM_BCK (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_MD_INT1_C2K_UIM0_HOT_PLUG (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_DBG_MON_A9 (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_SPI6_MI (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_I2S5_LRCK (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_PWM_2 (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_TDM_MCK (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_MD_INT2_C2K_UIM1_HOT_PLUG (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_DBG_MON_A10 (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_SPI6_MO (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_I2S5_DO (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_PWM_3 (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_TDM_DATA0 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_CLKM0 (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_DBG_MON_A11 (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_SPI4_A_CLK (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S2_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_DMIC1_CLK (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_TDM_DATA1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_PCM1_DI (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_IDDIG (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_SPI4_A_CSB (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S2_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_DMIC1_DAT (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_TDM_DATA2 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_PCM1_CLK (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_USB_DRVVBUS (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_SPI4_A_MI (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S2_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_DMIC_CLK (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_TDM_DATA3 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_PCM1_SYNC (MTK_PIN_NO(6) | 6)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI4_A_MO (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S2_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_DMIC_DAT (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_WIFI_TXD (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_PCM1_DO0 (MTK_PIN_NO(7) | 6)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SRCLKENAI1 (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_I2S2_DI2 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_KPCOL2 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_TCXOENA_REQ (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_CLKM1 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_PCM1_DO1 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_DBG_MON_A12 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define PINMUX_GPIO9__FUNC_SRCLKENAI0 (MTK_PIN_NO(9) | 1)
+#define PINMUX_GPIO9__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(9) | 2)
+#define PINMUX_GPIO9__FUNC_KPROW2 (MTK_PIN_NO(9) | 3)
+#define PINMUX_GPIO9__FUNC_CMMCLK4 (MTK_PIN_NO(9) | 4

Re: [PATCH 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-07-20 Thread zhiyong tao
On Fri, 2020-07-10 at 10:39 -0600, Rob Herring wrote:
> On Fri, Jul 10, 2020 at 03:27:16PM +0800, Zhiyong Tao wrote:
> > The commit adds mt8192 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  .../bindings/pinctrl/pinctrl-mt8192.yaml  | 170 ++
> >  1 file changed, 170 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > new file mode 100644
> > index ..c698b7f65950
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
> > @@ -0,0 +1,170 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8192.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Mediatek MT8192 Pin Controller
> > +
> > +maintainers:
> > +  - Linus Walleij 
> 
> Should be someone who knows the h/w (Mediatek).
> 
==> 
Dear Rob,

Thanks for your suggestion.
we will change it in v2.
> > +
> > +description: |
> > +  The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +properties:
> > +  compatible:
> > +const: mediatek,mt8192-pinctrl
> > +
> > +  gpio-controller: true
> > +
> > +  '#gpio-cells':
> > +description:
> > +  Number of cells in GPIO specifier. Since the generic GPIO binding is 
> > used,
> > +  the amount of cells must be specified as 2. See the below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +const: 2
> > +
> > +  gpio-ranges:
> > +description: gpio valid number range.
> > +maxItems: 1
> > +
> > +  reg:
> > +description:
> > +  Physical address base for gpio base registers. There are 11 GPIO
> > +  physical address base in mt8192.
> > +maxItems: 11
> > +
> > +  reg-names:
> > +description:
> > +  Gpio base register names. There are 11 gpio base register names in 
> > mt8192.
> > +  They are "iocfg0", "iocfg_rm", "iocfg_bm", "iocfg_bl", "iocfg_br",
> > +  "iocfg_lm", "iocfg_lb", "iocfg_rt", "iocfg_lt", "iocfg_tl", "eint".
> 
> Should be a schema.
==>ok, we will retain the description "Gpio base register names.", The
other description will be removed. Is it ok?
> 
> > +maxItems: 11
> > +
> > +  interrupt-controller: true
> > +
> > +  '#interrupt-cells':
> > +const: 2
> > +
> > +  interrupts:
> > +description: The interrupt outputs to sysirq.
> > +maxItems: 1
> > +
> > +#PIN CONFIGURATION NODES
> > +patternProperties:
> > +  subnode format:
> 
> The child node name is 'subnode format'?
> 
No, 'subnode format' is not child name. It is used to describe the
subnode format. so we should remove it?
> > +description:
> > +  A pinctrl node should contain at least one subnodes representing the
> > +  pinctrl groups available on the machine. Each subnode will list the
> > +  pins it needs, and how they should be configured, with regard to 
> > muxer
> > +  configuration, pullups, drive strength, input enable/disable and
> > +  input schmitt.
> > +
> > +  node {
> > +pinmux = ;
> > +GENERIC_PINCONFIG;
> > +  };
> 
> If you want to preserve formatting, description needs a literal block 
> notation on the end ('|').
==>ok, we will change it in v2. we will add ('|') after "description:"
in v2.
> 
> > +  '-pinmux$':
> > +description:
> > +  Integer array, represents gpio pin number and mux setting.
> > +  Supported pin number and mux varies for different SoCs, and are 
> > defined
> > +  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
> > +$ref: "/schemas/pinctrl/pincfg-node.yaml"
> > +
> > +  GENERIC_PINCONFIG:
> 
> You just defined a property called 'GENERIC_PINCONFIG'..
==> yes, it is. But we add all property description in the
GENERIC_PINCONFIG.
> .
> 
> > +description:
> > +  It is the generic pinconfig options to use, bias-disable,
> > +  bias-pull-down, bias-pull-up, input-enable, input-disa

[PATCH 1/3] dt-bindings: pinctrl: mt8192: add pinctrl file

2020-07-10 Thread Zhiyong Tao
This patch adds pinctrl file for mt8192.

Signed-off-by: Zhiyong Tao 
---
 include/dt-bindings/pinctrl/mt8192-pinfunc.h | 1344 ++
 1 file changed, 1344 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

diff --git a/include/dt-bindings/pinctrl/mt8192-pinfunc.h 
b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
new file mode 100644
index ..71ffe3a52578
--- /dev/null
+++ b/include/dt-bindings/pinctrl/mt8192-pinfunc.h
@@ -0,0 +1,1344 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8192_PINFUNC_H
+#define __MT8192_PINFUNC_H
+
+#include "mt65xx.h"
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_SPI6_CLK (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_I2S5_MCK (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_PWM_0 (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_TDM_LRCK (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_MD_INT0 (MTK_PIN_NO(0) | 6)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_SPI6_CSB (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_I2S5_BCK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_PWM_1 (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_TDM_BCK (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_MD_INT1_C2K_UIM0_HOT_PLUG (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_DBG_MON_A9 (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_SPI6_MI (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_I2S5_LRCK (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_PWM_2 (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_TDM_MCK (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_MD_INT2_C2K_UIM1_HOT_PLUG (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_DBG_MON_A10 (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_SPI6_MO (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_I2S5_DO (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_PWM_3 (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_TDM_DATA0 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_CLKM0 (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_DBG_MON_A11 (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_SPI4_A_CLK (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S2_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_DMIC1_CLK (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_TDM_DATA1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_PCM1_DI (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_IDDIG (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_SPI4_A_CSB (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S2_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_DMIC1_DAT (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_TDM_DATA2 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_PCM1_CLK (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_USB_DRVVBUS (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_SPI4_A_MI (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S2_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_DMIC_CLK (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_TDM_DATA3 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_PCM1_SYNC (MTK_PIN_NO(6) | 6)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI4_A_MO (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S2_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_DMIC_DAT (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_WIFI_TXD (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_PCM1_DO0 (MTK_PIN_NO(7) | 6)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SRCLKENAI1 (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_I2S2_DI2 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_KPCOL2 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_TCXOENA_REQ (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_CLKM1 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_PCM1_DO1 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_DBG_MON_A12 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define PINMUX_GPIO9__FUNC_SRCLKENAI0 (MTK_PIN_NO(9) | 1)
+#define PINMUX_GPIO9__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(9) | 2)
+#define PINMUX_GPIO9__FUNC_KPROW2 (MTK_PIN_NO(9) | 3)
+#define PINMUX_GPIO9__FUNC_CMMCLK4 (MTK_PIN_NO(9) | 4

[PATCH 0/3] Mediatek pinctrl patch on mt8192

2020-07-10 Thread Zhiyong Tao
This series includes 3 patches:
1.add pinctrl file on mt8192.
2.add pinctrl binding document on mt8192.
3.add pinctrl driver on MT8192.

Zhiyong Tao (3):
  dt-bindings: pinctrl: mt8192: add pinctrl file
  dt-bindings: pinctrl: mt8192: add binding document
  pinctrl: add pinctrl driver on mt8192

 .../bindings/pinctrl/pinctrl-mt8192.yaml  |  170 ++
 drivers/pinctrl/mediatek/Kconfig  |7 +
 drivers/pinctrl/mediatek/Makefile |1 +
 drivers/pinctrl/mediatek/pinctrl-mt8192.c | 1453 +++
 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h | 2228 +
 include/dt-bindings/pinctrl/mt8192-pinfunc.h  | 1344 ++
 6 files changed, 5203 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8192.c
 create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8192.h
 create mode 100644 include/dt-bindings/pinctrl/mt8192-pinfunc.h

--
2.25.1



[PATCH 2/3] dt-bindings: pinctrl: mt8192: add binding document

2020-07-10 Thread Zhiyong Tao
The commit adds mt8192 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../bindings/pinctrl/pinctrl-mt8192.yaml  | 170 ++
 1 file changed, 170 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
new file mode 100644
index ..c698b7f65950
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
@@ -0,0 +1,170 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pinctrl/pinctrl-mt8192.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT8192 Pin Controller
+
+maintainers:
+  - Linus Walleij 
+
+description: |
+  The Mediatek's Pin controller is used to control SoC pins.
+
+properties:
+  compatible:
+const: mediatek,mt8192-pinctrl
+
+  gpio-controller: true
+
+  '#gpio-cells':
+description:
+  Number of cells in GPIO specifier. Since the generic GPIO binding is 
used,
+  the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular 
cells.
+const: 2
+
+  gpio-ranges:
+description: gpio valid number range.
+maxItems: 1
+
+  reg:
+description:
+  Physical address base for gpio base registers. There are 11 GPIO
+  physical address base in mt8192.
+maxItems: 11
+
+  reg-names:
+description:
+  Gpio base register names. There are 11 gpio base register names in 
mt8192.
+  They are "iocfg0", "iocfg_rm", "iocfg_bm", "iocfg_bl", "iocfg_br",
+  "iocfg_lm", "iocfg_lb", "iocfg_rt", "iocfg_lt", "iocfg_tl", "eint".
+maxItems: 11
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+const: 2
+
+  interrupts:
+description: The interrupt outputs to sysirq.
+maxItems: 1
+
+#PIN CONFIGURATION NODES
+patternProperties:
+  subnode format:
+description:
+  A pinctrl node should contain at least one subnodes representing the
+  pinctrl groups available on the machine. Each subnode will list the
+  pins it needs, and how they should be configured, with regard to muxer
+  configuration, pullups, drive strength, input enable/disable and
+  input schmitt.
+
+  node {
+pinmux = ;
+GENERIC_PINCONFIG;
+  };
+  '-pinmux$':
+description:
+  Integer array, represents gpio pin number and mux setting.
+  Supported pin number and mux varies for different SoCs, and are defined
+  as macros in dt-bindings/pinctrl/-pinfunc.h directly.
+$ref: "/schemas/pinctrl/pincfg-node.yaml"
+
+  GENERIC_PINCONFIG:
+description:
+  It is the generic pinconfig options to use, bias-disable,
+  bias-pull-down, bias-pull-up, input-enable, input-disable, output-low,
+  output-high, input-schmitt-enable, input-schmitt-disable
+  and drive-strength are valid.
+
+  Some special pins have extra pull up strength, there are R0 and R1 
pull-up
+  resistors available, but for user, it's only need to set R1R0 as 00, 01,
+  10 or 11. So It needs config "mediatek,pull-up-adv" or
+  "mediatek,pull-down-adv" to support arguments for those special pins.
+  Valid arguments are from 0 to 3.
+
+  We can use "mediatek,tdsel" which is an integer describing the steps for
+  output level shifter duty cycle when asserted (high pulse width 
adjustment).
+  Valid arguments  are from 0 to 15.
+  We can use "mediatek,rdsel" which is an integer describing the steps for
+  input level shifter duty cycle when asserted (high pulse width 
adjustment).
+  Valid arguments are from 0 to 63.
+
+  When config drive-strength, it can support some arguments, such as
+  MTK_DRIVE_4mA, MTK_DRIVE_6mA, etc. See dt-bindings/pinctrl/mt65xx.h.
+  It can only support 2/4/6/8/10/12/14/16mA in mt8192.
+  For I2C pins, there are existing generic driving setup and the specific
+  driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA driving
+  adjustment in generic driving setup. But in specific driving setup,
+  they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific
+  driving setup for I2C pins, the existing generic driving setup will be
+  disabled. For some special features, we need the I2C pins specific
+  driving setup. The specific driving setup is controlled by E1E0EN.
+  So we need add extra vendor driving preperty instead of
+  the generic driving property.
+  We can add "mediatek,drive-strength-adv = ;" to describe the 
specific
+  driving setup property. "XXX" means the value of E1E0EN. EN is 0 or 1.
+  It is use

[PATCH v1 1/2] arm64: dts: mt8183: auxadc: add efuse information in device tree

2019-07-18 Thread Zhiyong Tao
The commit add add efuse information in device tree

Signed-off-by: Zhiyong Tao 
Signed-off-by: jg_poxu 
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index c2749c4631bc..59b4f3d933b5 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -261,6 +261,8 @@
clocks = < CLK_INFRA_AUXADC>;
clock-names = "main";
#io-channel-cells = <1>;
+   nvmem-cells = <_calibration>;
+   nvmem-cell-names = "calibration-data";
status = "disabled";
};
 
@@ -382,6 +384,9 @@
compatible = "mediatek,mt8183-efuse",
 "mediatek,efuse";
reg = <0 0x11f1 0 0x1000>;
+   auxadc_calibration: auxadccali@1b4 {
+   reg = <0x1b4 0x4>;
+   };
};
 
mfgcfg: syscon@1300 {
-- 
2.12.5



[PATCH v1 2/2] auxadc: mediatek: support efuse calibration in auxadc driver

2019-07-18 Thread Zhiyong Tao
This patch support efuse calibration in auxadc driver

Signed-off-by: Zhiyong Tao 
Signed-off-by: jg_poxu 
---
 drivers/iio/adc/mt6577_auxadc.c | 71 +
 1 file changed, 71 insertions(+)

diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
index 95d76abb64ec..e30d9736b1a5 100644
--- a/drivers/iio/adc/mt6577_auxadc.c
+++ b/drivers/iio/adc/mt6577_auxadc.c
@@ -17,12 +17,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 /* Register definitions */
 #define MT6577_AUXADC_CON00x00
@@ -42,6 +44,13 @@
 #define MT6577_AUXADC_POWER_READY_MS  1
 #define MT6577_AUXADC_SAMPLE_READY_US 25
 
+#define ADC_GE_A_SHIFT  10
+#define ADC_GE_A_MASK   (0x3ff << ADC_GE_A_SHIFT)
+#define ADC_OE_A_SHIFT  0
+#define ADC_OE_A_MASK   (0x3ff << ADC_OE_A_SHIFT)
+#define ADC_CALI_EN_A_SHIFT 20
+#define ADC_CALI_EN_A_MASK  (0x1 << ADC_CALI_EN_A_SHIFT)
+
 struct mt6577_auxadc_device {
void __iomem *reg_base;
struct clk *adc_clk;
@@ -74,6 +83,64 @@ static const struct iio_chan_spec 
mt6577_auxadc_iio_channels[] = {
MT6577_AUXADC_CHANNEL(15),
 };
 
+s32 cali_oe;
+s32 cali_ge;
+struct adc_cali_info {
+   u32 cali_ge_a;
+   u32 cali_oe_a;
+   u32 gain;
+};
+static struct adc_cali_info adc_cali;
+
+static int mt6577_auxadc_update_cali(struct device *dev)
+{
+   struct nvmem_cell *cell;
+   u32 *buf;
+   size_t len;
+   int ret = 0;
+
+   cali_oe = 0;
+   cali_ge = 0;
+
+   cell = nvmem_cell_get(dev, "calibration-data");
+   if (IS_ERR(cell)) {
+   if (PTR_ERR(cell) == -EPROBE_DEFER)
+   return PTR_ERR(cell);
+   return 0;
+   }
+
+   buf = (u32 *)nvmem_cell_read(cell, );
+
+   nvmem_cell_put(cell);
+
+   if (IS_ERR(buf))
+   return PTR_ERR(buf);
+
+   if (len < sizeof(u32)) {
+   dev_warn(dev, "invalid calibration data\n");
+   ret = -EINVAL;
+   goto out;
+   }
+
+   if (((buf[0] & ADC_CALI_EN_A_MASK) >> ADC_CALI_EN_A_SHIFT) != 0) {
+   adc_cali.cali_oe_a =
+   (buf[0] & ADC_OE_A_MASK) >> ADC_OE_A_SHIFT;
+   adc_cali.cali_ge_a =
+   ((buf[0] & ADC_GE_A_MASK) >> ADC_GE_A_SHIFT);
+
+   cali_ge = adc_cali.cali_ge_a - 512;
+   cali_oe = adc_cali.cali_oe_a - 512;
+   adc_cali.gain = 1 + cali_ge;
+   }  else {
+   dev_info(dev, "Device not calibrated, using default calibration 
values\n");
+   }
+
+out:
+   kfree(buf);
+
+   return ret;
+}
+
 static inline void mt6577_auxadc_mod_reg(void __iomem *reg,
 u32 or_mask, u32 and_mask)
 {
@@ -274,6 +341,10 @@ static int mt6577_auxadc_probe(struct platform_device 
*pdev)
goto err_power_off;
}
 
+   ret = mt6577_auxadc_update_cali(>dev);
+   if (ret)
+   return ret;
+
return 0;
 
 err_power_off:
-- 
2.12.5



[PATCH v1 0/2] AUXADC: support efuse calibration on MT818

2019-07-18 Thread Zhiyong Tao
This series includes two patches:
1.Add mt8183 auxadc efuse information in device tree.
1.Add mt8183 efuse calibration function in auxadc driver.

Zhiyong Tao (2):
  arm64: dts: mt8183: auxadc: add efuse information in device tree
  auxadc: mediatek: support efuse calibration in auxadc driver

 arch/arm64/boot/dts/mediatek/mt8183.dtsi |  5 +++
 drivers/iio/adc/mt6577_auxadc.c  | 71 
 2 files changed, 76 insertions(+)

--
2.12.5



[PATCH v2 2/2] arm64: dts: mt8183: Add auxadc device node

2019-04-23 Thread Zhiyong Tao
Add auxadc device node for MT8183

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts |  4 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi| 10 ++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts 
b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
index 9b525597e5ec..49909acc6efa 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
@@ -26,6 +26,10 @@
};
 };
 
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 75c4881bbe5e..57580d973316 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -269,6 +269,16 @@
clock-names = "spi", "wrap";
};
 
+   auxadc: auxadc@11001000 {
+   compatible = "mediatek,mt8183-auxadc",
+"mediatek,mt8173-auxadc";
+   reg = <0 0x11001000 0 0x1000>;
+   clocks = < CLK_INFRA_AUXADC>;
+   clock-names = "main";
+   #io-channel-cells = <1>;
+   status = "disabled";
+   };
+
uart0: serial@11002000 {
compatible = "mediatek,mt8183-uart",
 "mediatek,mt6577-uart";
-- 
2.12.5



[PATCH v2 1/2] dt-bindings: adc: mt8183: add binding document

2019-04-23 Thread Zhiyong Tao
The commit adds mt8183 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt 
b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
index 0df9befdaecc..936a0b4666da 100644
--- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
@@ -15,6 +15,7 @@ Required properties:
 - "mediatek,mt2712-auxadc": For MT2712 family of SoCs
 - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
 - "mediatek,mt8173-auxadc": For MT8173 family of SoCs
+- "mediatek,mt8183-auxadc", "mediatek,mt8173-auxadc": For MT8183 family of 
SoCs
   - reg: Address range of the AUXADC unit.
   - clocks: Should contain a clock specifier for each entry in clock-names
   - clock-names: Should contain "main".
-- 
2.12.5



[PATCH v2 0/2] AUXADC: Mediatek auxadc driver on MT8183

2019-04-23 Thread Zhiyong Tao
This series includes two patches:
1.Add mt8183 auxadc compatible node in binding document.
1.Add mt8183 auxadc device node.

Changes in patch v2:
1)change auxadc compatible node in binding document for mt8183.

Zhiyong Tao (2):
  dt-bindings: adc: mt8183: add binding document
  arm64: dts: mt8183: Add auxadc device node

 Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt |  1 +
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts |  4 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi| 10 ++
 3 files changed, 15 insertions(+)

--
2.12.5


Re: [PATCH 1/2] dt-bindings: adc: mt8183: add binding document

2019-04-23 Thread Zhiyong Tao
On Tue, 2019-04-23 at 16:35 +0200, Matthias Brugger wrote:
> 
> On 22/04/2019 13:54, Zhiyong Tao wrote:
> > The commit adds mt8183 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt 
> > b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> > index 0df9befdaecc..05bc79d8483c 100644
> > --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> > +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> > @@ -15,6 +15,7 @@ Required properties:
> >  - "mediatek,mt2712-auxadc": For MT2712 family of SoCs
> >  - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
> >  - "mediatek,mt8173-auxadc": For MT8173 family of SoCs
> > +- "mediatek,mt8183-auxadc": For MT8183 family of SoCs
> >- reg: Address range of the AUXADC unit.
> >- clocks: Should contain a clock specifier for each entry in clock-names
> >- clock-names: Should contain "main".
> > 
> 
> You are missing the logic in the driver to bind against this compatible.
> If there is nothing different from other SoCs then you could add a compatible
> with a fallback, like:
> 
> "mediatek,mt8183-auxadc", "mediatek,mt7622-auxadc": For MT8183 family of SoCs

==> Thanks for your suggestion. In v2, we will add the comment here:
- "mediatek,mt8183-auxadc", "mediatek,mt8173-auxadc": For MT8183 family
of SoCs.

> 
> Regards,
> Matthias




[PATCH 1/2] dt-bindings: adc: mt8183: add binding document

2019-04-22 Thread Zhiyong Tao
The commit adds mt8183 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt 
b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
index 0df9befdaecc..05bc79d8483c 100644
--- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
@@ -15,6 +15,7 @@ Required properties:
 - "mediatek,mt2712-auxadc": For MT2712 family of SoCs
 - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
 - "mediatek,mt8173-auxadc": For MT8173 family of SoCs
+- "mediatek,mt8183-auxadc": For MT8183 family of SoCs
   - reg: Address range of the AUXADC unit.
   - clocks: Should contain a clock specifier for each entry in clock-names
   - clock-names: Should contain "main".
-- 
2.12.5



[PATCH 2/2] arm64: dts: mt8183: Add auxadc device node

2019-04-22 Thread Zhiyong Tao
Add auxadc device node for MT8183

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts |  4 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi| 10 ++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts 
b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
index 9b525597e5ec..49909acc6efa 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
@@ -26,6 +26,10 @@
};
 };
 
+ {
+   status = "okay";
+};
+
  {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 75c4881bbe5e..57580d973316 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -269,6 +269,16 @@
clock-names = "spi", "wrap";
};
 
+   auxadc: auxadc@11001000 {
+   compatible = "mediatek,mt8183-auxadc",
+"mediatek,mt8173-auxadc";
+   reg = <0 0x11001000 0 0x1000>;
+   clocks = < CLK_INFRA_AUXADC>;
+   clock-names = "main";
+   #io-channel-cells = <1>;
+   status = "disabled";
+   };
+
uart0: serial@11002000 {
compatible = "mediatek,mt8183-uart",
 "mediatek,mt6577-uart";
-- 
2.12.5



[PATCH 0/1] AUXADC: Mediatek auxadc driver on MT8183

2019-04-22 Thread Zhiyong Tao
This series includes two patches:
1.Add mt8183 auxadc compatible node in binding document.
1.Add mt8183 auxadc device node.

Zhiyong Tao (1):
  arm64: dts: mt8183: Add auxadc device node

 arch/arm64/boot/dts/mediatek/mt8183-evb.dts |  4 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi| 10 ++
 2 files changed, 14 insertions(+)

--
2.12.5


[PATCH v4 4/4] pinctrl: add drive for I2C related pins on MT8183

2019-03-31 Thread Zhiyong Tao
This patch provides the advanced drive for I2C used pins on MT8183.
The detail strength specification description of the I2C pin:
When E1=0/E0=0, the strength is 0.125mA.
When E1=0/E0=1, the strength is 0.25mA.
When E1=1/E0=0, the strength is 0.5mA.
When E1=1/E0=1, the strength is 1mA.
For I2C pins, there are existing generic driving setup and the above
specific driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA
driving adjustment in generic driving setup. But in specific driving
setup, they can support 0.125/0.25/0.5/1mA adjustment.
If we enable specific driving setup for I2C pins,
the existing generic driving setup will be disabled.
For some special features, we need the I2C pins specific driving setup.
The specific driving setup is controlled by E1E0EN.
So we need add extra vendor driving preperty instead of the generic
driving property. We can add "mediatek,drive-strength-adv = ;"
to describe the specific driving setup property.
"XXX" means the value of E1E0EN. So the valid arguments of
"mediatek,drive-strength-adv" are from 0 to 7.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 49 +++
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 11 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 21 ++
 4 files changed, 131 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
index 6262fd3678ea..2c7409ed16fa 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
@@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
mt8183_pin_r1_range[] = {
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
 };
 
+static const struct mtk_pin_field_calc mt8183_pin_e1e0en_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e0_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e1_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1),
+};
+
 static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
@@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc 
mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_EN] = MTK_RANGE(mt8183_pin_e1e0en_range),
+   [PINCTRL_PIN_REG_DRV_E0] = MTK_RANGE(mt8183_pin_e0_range),
+   [PINCTRL_PIN_REG_DRV_E1] = MTK_RANGE(mt8183_pin_e1_range),
 };
 
 static const char * const mt8183_pinctrl_register_base_names[] = {
@@ -517,6 +565,8 @@ static const struct mtk_pin_soc mt8183_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_pull_get = mtk_pinconf_adv_p

[PATCH v4 2/4] arm64: dts: mt8183: add pinctrl file

2019-03-31 Thread Zhiyong Tao
This patch adds pinctrl file for mt8183.

Signed-off-by: Zhiyong Tao 
Signed-off-by: Erin Lo 
Reviewed-by: Rob Herring 

---
This patch is based on patch "https://patchwork.kernel.org/patch/10814251/;.
---
 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h | 1120 +
 1 file changed, 1120 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h 
b/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
new file mode 100644
index ..6221cd712718
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
@@ -0,0 +1,1120 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8183_PINFUNC_H
+#define __MT8183_PINFUNC_H
+
+#include 
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_MRG_SYNC (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_PCM0_SYNC (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_SRCLKENAI0 (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_SCP_SPI2_CS (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_I2S3_MCK (MTK_PIN_NO(0) | 6)
+#define PINMUX_GPIO0__FUNC_SPI2_CSB (MTK_PIN_NO(0) | 7)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_MRG_CLK (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_PCM0_CLK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_CLKM3 (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_SCP_SPI2_MO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_I2S3_BCK (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_SPI2_MO (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_MRG_DO (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_PCM0_DO (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_SCL6 (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_SCP_SPI2_CK (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_I2S3_LRCK (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_SPI2_CLK (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_MRG_DI (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_PCM0_DI (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_SDA6 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TDM_MCK (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_I2S3_DO (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_SCP_VREQ_VAO (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_PWM_B (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S0_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_SSPM_UTXD_AO (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_MD_URXD1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TDM_BCK (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_DAP_MD32_SWD (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_PWM_C (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S0_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_SSPM_URXD_AO (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_MD_UTXD1 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TDM_LRCK (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_DAP_MD32_SWCK (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_PWM_A (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S0_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_IDDIG (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_MD_URXD0 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TDM_DATA0 (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 6)
+#define PINMUX_GPIO6__FUNC_CMFLASH (MTK_PIN_NO(6) | 7)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI1_B_MI (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S0_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_USB_DRVVBUS (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_MD_UTXD0 (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TDM_DATA1 (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 6)
+#define PINMUX_GPIO7__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(7) | 7)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SPI1_B_CSB (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_ANT_SEL3 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_SCL7 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_MCU_TRST_B (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_TDM_DATA2 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_MD_INT0 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_JTRSTN_SEL1 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_

[PATCH v4 1/4] dt-bindings: pinctrl: mt8183: add binding document

2019-03-31 Thread Zhiyong Tao
The commit adds mt8183 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
Signed-off-by: Erin Lo 
Reviewed-by: Rob Herring 

---
This patch is based on patch "https://patchwork.kernel.org/patch/10778511/;.
---
 .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 132 +
 1 file changed, 132 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
new file mode 100644
index ..eccbe3f55d3f
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
@@ -0,0 +1,132 @@
+* Mediatek MT8183 Pin Controller
+
+The Mediatek's Pin controller is used to control SoC pins.
+
+Required properties:
+- compatible: value should be one of the following.
+   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
+- gpio-controller : Marks the device node as a gpio controller.
+- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
+  binding is used, the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular cells.
+- gpio-ranges : gpio valid number range.
+- reg: physical address base for gpio base registers. There are 10 GPIO
+  physical address base in mt8183.
+
+Optional properties:
+- reg-names: gpio base register names. There are 10 gpio base register
+  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", "iocfg4",
+  "iocfg5", "iocfg6", "iocfg7", "iocfg8", "eint".
+- interrupt-controller: Marks the device node as an interrupt controller
+- #interrupt-cells: Should be two.
+- interrupts : The interrupt outputs to sysirq.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices.
+
+Subnode format
+A pinctrl node should contain at least one subnodes representing the
+pinctrl groups available on the machine. Each subnode will list the
+pins it needs, and how they should be configured, with regard to muxer
+configuration, pullups, drive strength, input enable/disable and input schmitt.
+
+node {
+   pinmux = ;
+   GENERIC_PINCONFIG;
+};
+
+Required properties:
+- pinmux: integer array, represents gpio pin number and mux setting.
+Supported pin number and mux varies for different SoCs, and are defined
+as macros in boot/dts/-pinfunc.h directly.
+
+Optional properties:
+- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
+bias-pull-down, bias-pull-up, input-enable, input-disable, output-low,
+output-high, input-schmitt-enable, input-schmitt-disable
+and drive-strength are valid.
+
+Some special pins have extra pull up strength, there are R0 and R1 pull-up
+resistors available, but for user, it's only need to set R1R0 as 00, 01,
+10 or 11. So It needs config "mediatek,pull-up-adv" or
+"mediatek,pull-down-adv" to support arguments for those special pins.
+Valid arguments are from 0 to 3.
+
+mediatek,tdsel: An integer describing the steps for output level shifter
+  duty cycle when asserted (high pulse width adjustment). Valid arguments
+  are from 0 to 15.
+mediatek,rdsel: An integer describing the steps for input level shifter
+  duty cycle when asserted (high pulse width adjustment). Valid arguments
+  are from 0 to 63.
+
+When config drive-strength, it can support some arguments, such as
+MTK_DRIVE_4mA, MTK_DRIVE_6mA, etc. See dt-bindings/pinctrl/mt65xx.h.
+It can only support 2/4/6/8/10/12/14/16mA in mt8183.
+For I2C pins, there are existing generic driving setup and the specific
+driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA driving
+adjustment in generic driving setup. But in specific driving setup,
+they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific
+driving setup for I2C pins, the existing generic driving setup will be
+disabled. For some special features, we need the I2C pins specific
+driving setup. The specific driving setup is controlled by E1E0EN.
+So we need add extra vendor driving preperty instead of
+the generic driving property.
+We can add "mediatek,drive-strength-adv = ;" to describe the specific
+driving setup property. "XXX" means the value of E1E0EN. EN is 0 or 1.
+It is used to enable or disable the specific driving setup.
+E1E0 is used to describe the detail strength specification of the I2C pin.
+When E1=0/E0=0, the strength is 0.125mA.
+When E1=0/E0=1, the strength is 0.25mA.
+When E1=1/E0=0, the strength is 0.5mA.
+When E1=1/E0=1, the strength is 1mA.
+So the valid arguments of "mediatek,drive-strength-a

[PATCH v4 3/4] arm64: dts: mt8183: add pinctrl device node

2019-03-31 Thread Zhiyong Tao
The commit adds pinctrl device node for mt8183

Signed-off-by: Zhiyong Tao 
Signed-off-by: Erin Lo 

---
This patch is based on patch "https://patchwork.kernel.org/patch/10814239/;.
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 75c4881bbe5e..cf92504e2a9b 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -9,7 +9,7 @@
 #include 
 #include 
 #include 
-
+#include "mt8183-pinfunc.h"
 / {
compatible = "mediatek,mt8183";
interrupt-parent = <>;
@@ -197,6 +197,30 @@
#clock-cells = <1>;
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8183-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11f2 0 0x1000>,
+ <0 0x11e8 0 0x1000>,
+ <0 0x11e7 0 0x1000>,
+ <0 0x11e9 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d2 0 0x1000>,
+ <0 0x11c5 0 0x1000>,
+ <0 0x11f3 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg1", "iocfg2",
+   "iocfg3", "iocfg4", "iocfg5",
+   "iocfg6", "iocfg7", "iocfg8",
+   "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 192>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
scpsys: syscon@10006000 {
compatible = "mediatek,mt8183-scpsys", "syscon";
#power-domain-cells = <1>;
-- 
2.12.5



[PATCH v4 0/4] PINCTRL: Mediatek pinctrl patch on mt8183

2019-03-31 Thread Zhiyong Tao
This series includes 4 patches:
1.add pinctrl binding document on mt8183.
2.add pinctrl file on mt8183.
3.add pinctrl device node on mt8183.
4.add drive for I2C related pins on MT8183.

Changes in patch v4:
1)patch [1/4] is based on patch "https://patchwork.kernel.org/patch/10778511/;.
2)patch [2/4] is based on patch "https://patchwork.kernel.org/patch/10814251/;.
3)patch [3/4] is based on patch "https://patchwork.kernel.org/patch/10814239/;.
4)modify correct title on patch [2/4] and patch [3/4].
5)add Reviewed-by on patch [1/4] and [2/4].
6)modify the function "mtk_pinconf_adv_pull_get" and "mtk_pinconf_adv_pull_set"
7)change "drive-strengt-adv" to "drive-strength-adv".
8)call "mtk_pinconf_adv_pull_get" in "mtk_pinconf_get".

Changes in patch v3:
1)add the patch "dt-bindings: pinctrl: mt8183: add binding document".
2)add the patch "arm64: dts: mt8183: add pintcrl file".
3)add the patch "arm64: dts: mt8183: add pintcrl device node".
4)add more datail information for the specific driving setup in commit message.
5)use "mediatek,drive-strength-adv" instead of
  "mediatek,drive-enable-adv" and "mediatek,drive-enable-disable".
6)change "PINCTRL_PIN_REG_DRV_EN_DIS" to "PINCTRL_PIN_REG_DRV_EN".
7)change the function "mtk_pinconf_adv_drive_set".

Changes in patch v2:
1)add the details strength specification of the I2c pins.
2)change "mt8183_pin_drv_en_dis_range" to "mt8183_pin_e1e0en_range".
3)change "mt8183_pin_drv_e0_range" to "mt8183_pin_e0_range".
4)change "mt8183_pin_drv_e1_range" to "mt8183_pin_e1_range".

Zhiyong Tao (4):
  dt-bindings: pinctrl: mt8183: add binding document
  arm64: dts: mt8183: add pinctrl file
  arm64: dts: mt8183: add pinctrl device node
  pinctrl: add drive for I2C related pins on MT8183

 .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt |  132 +++
 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h  | 1120 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi   |   26 +-
 drivers/pinctrl/mediatek/pinctrl-mt8183.c  |   50 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c   |   49 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h   |   11 +
 drivers/pinctrl/mediatek/pinctrl-paris.c   |   21 +
 7 files changed, 1408 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h

--
2.12.5



Re: [PATCH 4/4] pinctrl: add drive for I2C related pins on MT8183

2019-03-25 Thread Zhiyong Tao
On Mon, 2019-03-25 at 11:25 -0700, Nicolas Boichat wrote:
> On Mon, Mar 25, 2019 at 5:23 AM Zhiyong Tao  wrote:
> >
> > This patch provides the advanced drive for I2C used pins on MT8183.
> > The detail strength specification description of the I2C pin:
> > When E1=0/E0=0, the strength is 0.125mA.
> > When E1=0/E0=1, the strength is 0.25mA.
> > When E1=1/E0=0, the strength is 0.5mA.
> > When E1=1/E0=1, the strength is 1mA.
> > For I2C pins, there are existing generic driving setup and the above
> > specific driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA
> > driving adjustment in generic driving setup. But in specific driving
> > setup, they can support 0.125/0.25/0.5/1mA adjustment.
> > If we enable specific driving setup for I2C pins,
> > the existing generic driving setup will be disabled.
> > For some special features, we need the I2C pins specific driving setup.
> > The specific driving setup is controlled by E1E0EN.
> > So we need add extra vendor driving preperty instead of the generic
> > driving property. We can add "mediatek,drive-strength-adv = ;"
> > to describe the specific driving setup property.
> > "XXX" means the value of E1E0EN. So the valid arguments of
> > "mediatek,drive-strength-adv" are from 0 to 7.
> >
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
> > 
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 47 
> > ++
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 11 ++
> >  drivers/pinctrl/mediatek/pinctrl-paris.c | 12 ++
> >  4 files changed, 120 insertions(+)
> >
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
> > b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
> > index 6262fd3678ea..2c7409ed16fa 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
> > @@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
> > mt8183_pin_r1_range[] = {
> > PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
> >  };
> >
> > +static const struct mtk_pin_field_calc mt8183_pin_e1e0en_range[] = {
> > +   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
> > +   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
> > +   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
> > +   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
> > +   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
> > +   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
> > +   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
> > +   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
> > +   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
> > +   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
> > +   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
> > +   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
> > +};
> > +
> > +static const struct mtk_pin_field_calc mt8183_pin_e0_range[] = {
> > +   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
> > +   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
> > +   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
> > +   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
> > +   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
> > +   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
> > +   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
> > +   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
> > +   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
> > +   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
> > +   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
> > +   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
> > +};
> > +
> > +static const struct mtk_pin_field_calc mt8183_pin_e1_range[] = {
> > +   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
> > +   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
> > +   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
> > +   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
> > +   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
> > +   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
> > +   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
> > +   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
> > +   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
> > +   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
> > +   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
> > +   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19

Re: [PATCH RESEND v3 3/4] arm64: dts: mt8183: add pintcrl device node

2019-03-25 Thread Zhiyong Tao
On Mon, 2019-03-25 at 11:17 -0700, Nicolas Boichat wrote:
> On Mon, Mar 25, 2019 at 5:41 AM Zhiyong Tao  wrote:
> >
> > The commit adds pintcrl device node for mt8183
> 
> Minor nit: This should say pinctrl (in the commit title as well).
==> Thanks for your suggestion, we will change it in next version.
> 
> >
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  arch/arm64/boot/dts/mediatek/mt8183.dtsi | 26 +-
> >  1 file changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
> > b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
> > index 75c4881bbe5e..cf92504e2a9b 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
> > @@ -9,7 +9,7 @@
> >  #include 
> >  #include 
> >  #include 
> > -
> > +#include "mt8183-pinfunc.h"
> >  / {
> > compatible = "mediatek,mt8183";
> > interrupt-parent = <>;
> > @@ -197,6 +197,30 @@
> > #clock-cells = <1>;
> > };
> >
> > +   pio: pinctrl@10005000 {
> > +   compatible = "mediatek,mt8183-pinctrl";
> > +   reg = <0 0x10005000 0 0x1000>,
> > + <0 0x11f2 0 0x1000>,
> > + <0 0x11e8 0 0x1000>,
> > + <0 0x11e7 0 0x1000>,
> > + <0 0x11e9 0 0x1000>,
> > + <0 0x11d3 0 0x1000>,
> > + <0 0x11d2 0 0x1000>,
> > + <0 0x11c5 0 0x1000>,
> > + <0 0x11f3 0 0x1000>,
> > + <0 0x1000b000 0 0x1000>;
> > +   reg-names = "iocfg0", "iocfg1", "iocfg2",
> > +   "iocfg3", "iocfg4", "iocfg5",
> > +   "iocfg6", "iocfg7", "iocfg8",
> > +   "eint";
> > +   gpio-controller;
> > +   #gpio-cells = <2>;
> > +   gpio-ranges = < 0 0 192>;
> > +   interrupt-controller;
> > +   interrupts = ;
> > +   #interrupt-cells = <2>;
> > +   };
> > +
> > scpsys: syscon@10006000 {
> > compatible = "mediatek,mt8183-scpsys", "syscon";
> > #power-domain-cells = <1>;
> > --
> > 2.12.5
> >




Re: [PATCH 2/4] arm64: dts: mt8183: add pintcrl file

2019-03-25 Thread Zhiyong Tao
On Mon, 2019-03-25 at 14:30 -0500, Rob Herring wrote:
> On Mon, Mar 25, 2019 at 08:23:00PM +0800, Zhiyong Tao wrote:
> > This patch adds pinctrl file for mt8183.
> 
> Still has a typo in the subject.

==>we will change it in next version
> 
> > 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h | 1120 
> > +
> >  1 file changed, 1120 insertions(+)
> >  create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
> 
> Add acks/reviewed-bys when posting new versions. This should also be 
> called v8 even though a different person sent it.

==>we will add acks/reviewed-bys when posting new versions in nxet
version.
This patch is based on "https://patchwork.kernel.org/patch/10814251/;.
If it is based on the patch
"https://patchwork.kernel.org/patch/10814251/;, it should called v8.
But I send this patch, we call it v3. Because it it is based on the
patch "https://patchwork.kernel.org/patch/10836969/;.

In these v3 patches, we send 4 patches. So we should call 1/4,2/4,3/4 as
v9 in next patch, and call 4/4 patch as v5. is it right?

Thanks.
> 
> Rob
> 




[PATCH RESEND v3 1/4] dt-bindings: pinctrl: mt8183: add binding document

2019-03-25 Thread Zhiyong Tao
The commit adds mt8183 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 132 +
 1 file changed, 132 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
new file mode 100644
index ..eccbe3f55d3f
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
@@ -0,0 +1,132 @@
+* Mediatek MT8183 Pin Controller
+
+The Mediatek's Pin controller is used to control SoC pins.
+
+Required properties:
+- compatible: value should be one of the following.
+   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
+- gpio-controller : Marks the device node as a gpio controller.
+- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
+  binding is used, the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular cells.
+- gpio-ranges : gpio valid number range.
+- reg: physical address base for gpio base registers. There are 10 GPIO
+  physical address base in mt8183.
+
+Optional properties:
+- reg-names: gpio base register names. There are 10 gpio base register
+  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", "iocfg4",
+  "iocfg5", "iocfg6", "iocfg7", "iocfg8", "eint".
+- interrupt-controller: Marks the device node as an interrupt controller
+- #interrupt-cells: Should be two.
+- interrupts : The interrupt outputs to sysirq.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices.
+
+Subnode format
+A pinctrl node should contain at least one subnodes representing the
+pinctrl groups available on the machine. Each subnode will list the
+pins it needs, and how they should be configured, with regard to muxer
+configuration, pullups, drive strength, input enable/disable and input schmitt.
+
+node {
+   pinmux = ;
+   GENERIC_PINCONFIG;
+};
+
+Required properties:
+- pinmux: integer array, represents gpio pin number and mux setting.
+Supported pin number and mux varies for different SoCs, and are defined
+as macros in boot/dts/-pinfunc.h directly.
+
+Optional properties:
+- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
+bias-pull-down, bias-pull-up, input-enable, input-disable, output-low,
+output-high, input-schmitt-enable, input-schmitt-disable
+and drive-strength are valid.
+
+Some special pins have extra pull up strength, there are R0 and R1 pull-up
+resistors available, but for user, it's only need to set R1R0 as 00, 01,
+10 or 11. So It needs config "mediatek,pull-up-adv" or
+"mediatek,pull-down-adv" to support arguments for those special pins.
+Valid arguments are from 0 to 3.
+
+mediatek,tdsel: An integer describing the steps for output level shifter
+  duty cycle when asserted (high pulse width adjustment). Valid arguments
+  are from 0 to 15.
+mediatek,rdsel: An integer describing the steps for input level shifter
+  duty cycle when asserted (high pulse width adjustment). Valid arguments
+  are from 0 to 63.
+
+When config drive-strength, it can support some arguments, such as
+MTK_DRIVE_4mA, MTK_DRIVE_6mA, etc. See dt-bindings/pinctrl/mt65xx.h.
+It can only support 2/4/6/8/10/12/14/16mA in mt8183.
+For I2C pins, there are existing generic driving setup and the specific
+driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA driving
+adjustment in generic driving setup. But in specific driving setup,
+they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific
+driving setup for I2C pins, the existing generic driving setup will be
+disabled. For some special features, we need the I2C pins specific
+driving setup. The specific driving setup is controlled by E1E0EN.
+So we need add extra vendor driving preperty instead of
+the generic driving property.
+We can add "mediatek,drive-strength-adv = ;" to describe the specific
+driving setup property. "XXX" means the value of E1E0EN. EN is 0 or 1.
+It is used to enable or disable the specific driving setup.
+E1E0 is used to describe the detail strength specification of the I2C pin.
+When E1=0/E0=0, the strength is 0.125mA.
+When E1=0/E0=1, the strength is 0.25mA.
+When E1=1/E0=0, the strength is 0.5mA.
+When E1=1/E0=1, the strength is 1mA.
+So the valid arguments of "mediatek,drive-strength-adv" are from 0 to 7.
+
+Examples:
+
+#include "mt8183-pinfunc.h"
+
+...
+{
+   pio: pinctrl@10005000 {
+   c

[PATCH RESEND v3 4/4] pinctrl: add drive for I2C related pins on MT8183

2019-03-25 Thread Zhiyong Tao
This patch provides the advanced drive for I2C used pins on MT8183.
The detail strength specification description of the I2C pin:
When E1=0/E0=0, the strength is 0.125mA.
When E1=0/E0=1, the strength is 0.25mA.
When E1=1/E0=0, the strength is 0.5mA.
When E1=1/E0=1, the strength is 1mA.
For I2C pins, there are existing generic driving setup and the above
specific driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA
driving adjustment in generic driving setup. But in specific driving
setup, they can support 0.125/0.25/0.5/1mA adjustment.
If we enable specific driving setup for I2C pins,
the existing generic driving setup will be disabled.
For some special features, we need the I2C pins specific driving setup.
The specific driving setup is controlled by E1E0EN.
So we need add extra vendor driving preperty instead of the generic
driving property. We can add "mediatek,drive-strength-adv = ;"
to describe the specific driving setup property.
"XXX" means the value of E1E0EN. So the valid arguments of
"mediatek,drive-strength-adv" are from 0 to 7.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 47 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 11 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 12 ++
 4 files changed, 120 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
index 6262fd3678ea..2c7409ed16fa 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
@@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
mt8183_pin_r1_range[] = {
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
 };
 
+static const struct mtk_pin_field_calc mt8183_pin_e1e0en_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e0_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e1_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1),
+};
+
 static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
@@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc 
mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_EN] = MTK_RANGE(mt8183_pin_e1e0en_range),
+   [PINCTRL_PIN_REG_DRV_E0] = MTK_RANGE(mt8183_pin_e0_range),
+   [PINCTRL_PIN_REG_DRV_E1] = MTK_RANGE(mt8183_pin_e1_range),
 };
 
 static const char * const mt8183_pinctrl_register_base_names[] = {
@@ -517,6 +565,8 @@ static const struct mtk_pin_soc mt8183_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_pull_get = mtk_pinconf_adv_p

[PATCH v3 RESEND 0/4] PINCTRL: Mediatek pinctrl patch on mt8183

2019-03-25 Thread Zhiyong Tao
This series includes 4 patches:
1.add pintcrl binding document on mt8183.
2.add pintcrl file on mt8183.
3.add pintcrl device node on mt8183.
4.add drive for I2C related pins on MT8183.

Changes in patch v3:
1)add the patch "dt-bindings: pinctrl: mt8183: add binding document".
2)add the patch "arm64: dts: mt8183: add pintcrl file".
3)add the patch "arm64: dts: mt8183: add pintcrl device node".
4)add more datail information for the specific driving setup in commit message.
5)use "mediatek,drive-strength-adv" instead of
  "mediatek,drive-enable-adv" and "mediatek,drive-enable-disable".
6)change "PINCTRL_PIN_REG_DRV_EN_DIS" to "PINCTRL_PIN_REG_DRV_EN".
7)change the function "mtk_pinconf_adv_drive_set".

Changes in patch v2:
1)add the details strength specification of the I2c pins.
2)change "mt8183_pin_drv_en_dis_range" to "mt8183_pin_e1e0en_range".
3)change "mt8183_pin_drv_e0_range" to "mt8183_pin_e0_range".
4)change "mt8183_pin_drv_e1_range" to "mt8183_pin_e1_range".

Zhiyong Tao (4):
  dt-bindings: pinctrl: mt8183: add binding document
  arm64: dts: mt8183: add pintcrl file
  arm64: dts: mt8183: add pintcrl device node
  pinctrl: add drive for I2C related pins on MT8183

 .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt |  132 +++
 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h  | 1120 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi   |   27 +-
 drivers/pinctrl/mediatek/pinctrl-mt8183.c  |   50 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c   |   47 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h   |   11 +
 drivers/pinctrl/mediatek/pinctrl-paris.c   |   12 +
 7 files changed, 1398 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h

--
2.12.5


[PATCH RESEND v3 2/4] arm64: dts: mt8183: add pintcrl file

2019-03-25 Thread Zhiyong Tao
This patch adds pinctrl file for mt8183.

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h | 1120 +
 1 file changed, 1120 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h 
b/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
new file mode 100644
index ..6221cd712718
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
@@ -0,0 +1,1120 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8183_PINFUNC_H
+#define __MT8183_PINFUNC_H
+
+#include 
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_MRG_SYNC (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_PCM0_SYNC (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_SRCLKENAI0 (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_SCP_SPI2_CS (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_I2S3_MCK (MTK_PIN_NO(0) | 6)
+#define PINMUX_GPIO0__FUNC_SPI2_CSB (MTK_PIN_NO(0) | 7)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_MRG_CLK (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_PCM0_CLK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_CLKM3 (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_SCP_SPI2_MO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_I2S3_BCK (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_SPI2_MO (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_MRG_DO (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_PCM0_DO (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_SCL6 (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_SCP_SPI2_CK (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_I2S3_LRCK (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_SPI2_CLK (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_MRG_DI (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_PCM0_DI (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_SDA6 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TDM_MCK (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_I2S3_DO (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_SCP_VREQ_VAO (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_PWM_B (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S0_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_SSPM_UTXD_AO (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_MD_URXD1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TDM_BCK (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_DAP_MD32_SWD (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_PWM_C (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S0_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_SSPM_URXD_AO (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_MD_UTXD1 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TDM_LRCK (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_DAP_MD32_SWCK (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_PWM_A (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S0_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_IDDIG (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_MD_URXD0 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TDM_DATA0 (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 6)
+#define PINMUX_GPIO6__FUNC_CMFLASH (MTK_PIN_NO(6) | 7)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI1_B_MI (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S0_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_USB_DRVVBUS (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_MD_UTXD0 (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TDM_DATA1 (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 6)
+#define PINMUX_GPIO7__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(7) | 7)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SPI1_B_CSB (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_ANT_SEL3 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_SCL7 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_MCU_TRST_B (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_TDM_DATA2 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_MD_INT0 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_JTRSTN_SEL1 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define PINMUX_GPIO9__FUNC_SPI1_B_MO (MTK_PIN_NO(9) | 1)
+#define PINMUX_GPIO9__FUNC_ANT_SEL4 (MTK_PIN_NO(9) | 2

[PATCH RESEND v3 3/4] arm64: dts: mt8183: add pintcrl device node

2019-03-25 Thread Zhiyong Tao
The commit adds pintcrl device node for mt8183

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 75c4881bbe5e..cf92504e2a9b 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -9,7 +9,7 @@
 #include 
 #include 
 #include 
-
+#include "mt8183-pinfunc.h"
 / {
compatible = "mediatek,mt8183";
interrupt-parent = <>;
@@ -197,6 +197,30 @@
#clock-cells = <1>;
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8183-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11f2 0 0x1000>,
+ <0 0x11e8 0 0x1000>,
+ <0 0x11e7 0 0x1000>,
+ <0 0x11e9 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d2 0 0x1000>,
+ <0 0x11c5 0 0x1000>,
+ <0 0x11f3 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg1", "iocfg2",
+   "iocfg3", "iocfg4", "iocfg5",
+   "iocfg6", "iocfg7", "iocfg8",
+   "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 192>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
scpsys: syscon@10006000 {
compatible = "mediatek,mt8183-scpsys", "syscon";
#power-domain-cells = <1>;
-- 
2.12.5



[PATCH 3/4] arm64: dts: mt8183: add pintcrl device node

2019-03-25 Thread Zhiyong Tao
The commit adds pintcrl device node for mt8183

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 75c4881bbe5e..cf92504e2a9b 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -9,7 +9,7 @@
 #include 
 #include 
 #include 
-
+#include "mt8183-pinfunc.h"
 / {
compatible = "mediatek,mt8183";
interrupt-parent = <>;
@@ -197,6 +197,30 @@
#clock-cells = <1>;
};
 
+   pio: pinctrl@10005000 {
+   compatible = "mediatek,mt8183-pinctrl";
+   reg = <0 0x10005000 0 0x1000>,
+ <0 0x11f2 0 0x1000>,
+ <0 0x11e8 0 0x1000>,
+ <0 0x11e7 0 0x1000>,
+ <0 0x11e9 0 0x1000>,
+ <0 0x11d3 0 0x1000>,
+ <0 0x11d2 0 0x1000>,
+ <0 0x11c5 0 0x1000>,
+ <0 0x11f3 0 0x1000>,
+ <0 0x1000b000 0 0x1000>;
+   reg-names = "iocfg0", "iocfg1", "iocfg2",
+   "iocfg3", "iocfg4", "iocfg5",
+   "iocfg6", "iocfg7", "iocfg8",
+   "eint";
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-ranges = < 0 0 192>;
+   interrupt-controller;
+   interrupts = ;
+   #interrupt-cells = <2>;
+   };
+
scpsys: syscon@10006000 {
compatible = "mediatek,mt8183-scpsys", "syscon";
#power-domain-cells = <1>;
-- 
2.12.5



[PATCH v3 0/4] PINCTRL: Mediatek pinctrl patch on mt8183

2019-03-25 Thread Zhiyong Tao
This series includes 4 patches:
1.add pintcrl binding document on mt8183.
2.add pintcrl file on mt8183.
3.add pintcrl device node on mt8183.
4.add drive for I2C related pins on MT8183.

Changes in patch v3:
1)add the patch "dt-bindings: pinctrl: mt8183: add binding document".
2)add the patch "arm64: dts: mt8183: add pintcrl file".
3)add the patch "arm64: dts: mt8183: add pintcrl device node".
4)add more datail information for the specific driving setup in commit message.
5)use "mediatek,drive-strength-adv" instead of
  "mediatek,drive-enable-adv" and "mediatek,drive-enable-disable".
6)change "PINCTRL_PIN_REG_DRV_EN_DIS" to "PINCTRL_PIN_REG_DRV_EN".
7)change the function "mtk_pinconf_adv_drive_set".

Changes in patch v2:
1)add the details strength specification of the I2c pins.
2)change "mt8183_pin_drv_en_dis_range" to "mt8183_pin_e1e0en_range".
3)change "mt8183_pin_drv_e0_range" to "mt8183_pin_e0_range".
4)change "mt8183_pin_drv_e1_range" to "mt8183_pin_e1_range".

Zhiyong Tao (4):
  dt-bindings: pinctrl: mt8183: add binding document
  arm64: dts: mt8183: add pintcrl file
  arm64: dts: mt8183: add pintcrl device node
  pinctrl: add drive for I2C related pins on MT8183

 .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt |  132 +++
 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h  | 1120 
 arch/arm64/boot/dts/mediatek/mt8183.dtsi   |   27 +-
 drivers/pinctrl/mediatek/pinctrl-mt8183.c  |   50 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c   |   47 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h   |   11 +
 drivers/pinctrl/mediatek/pinctrl-paris.c   |   12 +
 7 files changed, 1398 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h

--
2.12.5



[PATCH 4/4] pinctrl: add drive for I2C related pins on MT8183

2019-03-25 Thread Zhiyong Tao
This patch provides the advanced drive for I2C used pins on MT8183.
The detail strength specification description of the I2C pin:
When E1=0/E0=0, the strength is 0.125mA.
When E1=0/E0=1, the strength is 0.25mA.
When E1=1/E0=0, the strength is 0.5mA.
When E1=1/E0=1, the strength is 1mA.
For I2C pins, there are existing generic driving setup and the above
specific driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA
driving adjustment in generic driving setup. But in specific driving
setup, they can support 0.125/0.25/0.5/1mA adjustment.
If we enable specific driving setup for I2C pins,
the existing generic driving setup will be disabled.
For some special features, we need the I2C pins specific driving setup.
The specific driving setup is controlled by E1E0EN.
So we need add extra vendor driving preperty instead of the generic
driving property. We can add "mediatek,drive-strength-adv = ;"
to describe the specific driving setup property.
"XXX" means the value of E1E0EN. So the valid arguments of
"mediatek,drive-strength-adv" are from 0 to 7.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 47 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 11 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 12 ++
 4 files changed, 120 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
index 6262fd3678ea..2c7409ed16fa 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
@@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
mt8183_pin_r1_range[] = {
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
 };
 
+static const struct mtk_pin_field_calc mt8183_pin_e1e0en_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e0_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e1_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1),
+};
+
 static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
@@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc 
mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_EN] = MTK_RANGE(mt8183_pin_e1e0en_range),
+   [PINCTRL_PIN_REG_DRV_E0] = MTK_RANGE(mt8183_pin_e0_range),
+   [PINCTRL_PIN_REG_DRV_E1] = MTK_RANGE(mt8183_pin_e1_range),
 };
 
 static const char * const mt8183_pinctrl_register_base_names[] = {
@@ -517,6 +565,8 @@ static const struct mtk_pin_soc mt8183_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_pull_get = mtk_pinconf_adv_p

[PATCH 1/4] dt-bindings: pinctrl: mt8183: add binding document

2019-03-25 Thread Zhiyong Tao
The commit adds mt8183 compatible node in binding document.

Signed-off-by: Zhiyong Tao 
---
 .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 133 +
 1 file changed, 133 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt

diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
new file mode 100644
index ..fe828675bbe2
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
@@ -0,0 +1,133 @@
+* Mediatek MT8183 Pin Controller
+
+The Mediatek's Pin controller is used to control SoC pins.
+
+Required properties:
+- compatible: value should be one of the following.
+   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
+- gpio-controller : Marks the device node as a gpio controller.
+- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
+  binding is used, the amount of cells must be specified as 2. See the below
+  mentioned gpio binding representation for description of particular cells.
+- gpio-ranges : gpio valid number range.
+- reg: physical address base for gpio base registers. There are 10 GPIO
+  physical address base in mt8183.
+
+Optional properties:
+- reg-names: gpio base register names. There are 10 gpio base register
+  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", "iocfg4",
+  "iocfg5", "iocfg6", "iocfg7", "iocfg8", "eint".
+- interrupt-controller: Marks the device node as an interrupt controller
+- #interrupt-cells: Should be two.
+- interrupts : The interrupt outputs to sysirq.
+
+Please refer to pinctrl-bindings.txt in this directory for details of the
+common pinctrl bindings used by client devices.
+
+Subnode format
+A pinctrl node should contain at least one subnodes representing the
+pinctrl groups available on the machine. Each subnode will list the
+pins it needs, and how they should be configured, with regard to muxer
+configuration, pullups, drive strength, input enable/disable and input schmitt.
+
+node {
+   pinmux = ;
+   GENERIC_PINCONFIG;
+};
+
+Required properties:
+- pinmux: integer array, represents gpio pin number and mux setting.
+Supported pin number and mux varies for different SoCs, and are defined
+as macros in boot/dts/-pinfunc.h directly.
+
+Optional properties:
+- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
+bias-pull-down, bias-pull-up, input-enable, input-disable, output-low,
+output-high, input-schmitt-enable, input-schmitt-disable
+and drive-strength are valid.
+
+Some special pins have extra pull up strength, there are R0 and R1 pull-up
+resistors available, but for user, it's only need to set R1R0 as 00, 01,
+10 or 11. So It needs config "mediatek,pull-up-adv" or
+"mediatek,pull-down-adv" to support arguments for those special pins.
+Valid arguments are from 0 to 3.
+
+mediatek,tdsel: An integer describing the steps for output level shifter
+  duty cycle when asserted (high pulse width adjustment). Valid arguments
+  are from 0 to 15.
+mediatek,rdsel: An integer describing the steps for input level shifter
+  duty cycle when asserted (high pulse width adjustment). Valid arguments
+  are from 0 to 63.
+
+When config drive-strength, it can support some arguments, such as
+MTK_DRIVE_4mA, MTK_DRIVE_6mA, etc. See dt-bindings/pinctrl/mt65xx.h.
+It can only support 2/4/6/8/10/12/14/16mA in mt8183.
+For I2C pins, there are existing generic driving setup and the specific
+driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA driving
+adjustment in generic driving setup. But in specific driving setup,
+they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific
+driving setup for I2C pins, the existing generic driving setup will be
+disabled. For some special features, we need the I2C pins specific
+driving setup. The specific driving setup is controlled by E1E0EN.
+So we need add extra vendor driving preperty instead of
+the generic driving property.
+We can add "mediatek,drive-strength-adv = ;" to describe the specific
+driving setup property. "XXX" means the value of E1E0EN. EN is 0 or 1.
+It is used to enable or disable the specific driving setup.
+E1E0 is used to describe the detail strength specification of the I2C pin.
+When E1=0/E0=0, the strength is 0.125mA.
+When E1=0/E0=1, the strength is 0.25mA.
+When E1=1/E0=0, the strength is 0.5mA.
+When E1=1/E0=1, the strength is 1mA.
+So the valid arguments of "mediatek,drive-strength-adv" are from 0 to 7.
+
+Examples:
+
+#include "mt8183-pinfunc.h"
+
+...
+{
+   pio: pinctrl@10005000 {
+   c

[PATCH 2/4] arm64: dts: mt8183: add pintcrl file

2019-03-25 Thread Zhiyong Tao
This patch adds pinctrl file for mt8183.

Signed-off-by: Zhiyong Tao 
---
 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h | 1120 +
 1 file changed, 1120 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h 
b/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
new file mode 100644
index ..6221cd712718
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt8183-pinfunc.h
@@ -0,0 +1,1120 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 MediaTek Inc.
+ * Author: Zhiyong Tao 
+ *
+ */
+
+#ifndef __MT8183_PINFUNC_H
+#define __MT8183_PINFUNC_H
+
+#include 
+
+#define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define PINMUX_GPIO0__FUNC_MRG_SYNC (MTK_PIN_NO(0) | 1)
+#define PINMUX_GPIO0__FUNC_PCM0_SYNC (MTK_PIN_NO(0) | 2)
+#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 3)
+#define PINMUX_GPIO0__FUNC_SRCLKENAI0 (MTK_PIN_NO(0) | 4)
+#define PINMUX_GPIO0__FUNC_SCP_SPI2_CS (MTK_PIN_NO(0) | 5)
+#define PINMUX_GPIO0__FUNC_I2S3_MCK (MTK_PIN_NO(0) | 6)
+#define PINMUX_GPIO0__FUNC_SPI2_CSB (MTK_PIN_NO(0) | 7)
+
+#define PINMUX_GPIO1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define PINMUX_GPIO1__FUNC_MRG_CLK (MTK_PIN_NO(1) | 1)
+#define PINMUX_GPIO1__FUNC_PCM0_CLK (MTK_PIN_NO(1) | 2)
+#define PINMUX_GPIO1__FUNC_TP_GPIO1_AO (MTK_PIN_NO(1) | 3)
+#define PINMUX_GPIO1__FUNC_CLKM3 (MTK_PIN_NO(1) | 4)
+#define PINMUX_GPIO1__FUNC_SCP_SPI2_MO (MTK_PIN_NO(1) | 5)
+#define PINMUX_GPIO1__FUNC_I2S3_BCK (MTK_PIN_NO(1) | 6)
+#define PINMUX_GPIO1__FUNC_SPI2_MO (MTK_PIN_NO(1) | 7)
+
+#define PINMUX_GPIO2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define PINMUX_GPIO2__FUNC_MRG_DO (MTK_PIN_NO(2) | 1)
+#define PINMUX_GPIO2__FUNC_PCM0_DO (MTK_PIN_NO(2) | 2)
+#define PINMUX_GPIO2__FUNC_TP_GPIO2_AO (MTK_PIN_NO(2) | 3)
+#define PINMUX_GPIO2__FUNC_SCL6 (MTK_PIN_NO(2) | 4)
+#define PINMUX_GPIO2__FUNC_SCP_SPI2_CK (MTK_PIN_NO(2) | 5)
+#define PINMUX_GPIO2__FUNC_I2S3_LRCK (MTK_PIN_NO(2) | 6)
+#define PINMUX_GPIO2__FUNC_SPI2_CLK (MTK_PIN_NO(2) | 7)
+
+#define PINMUX_GPIO3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define PINMUX_GPIO3__FUNC_MRG_DI (MTK_PIN_NO(3) | 1)
+#define PINMUX_GPIO3__FUNC_PCM0_DI (MTK_PIN_NO(3) | 2)
+#define PINMUX_GPIO3__FUNC_TP_GPIO3_AO (MTK_PIN_NO(3) | 3)
+#define PINMUX_GPIO3__FUNC_SDA6 (MTK_PIN_NO(3) | 4)
+#define PINMUX_GPIO3__FUNC_TDM_MCK (MTK_PIN_NO(3) | 5)
+#define PINMUX_GPIO3__FUNC_I2S3_DO (MTK_PIN_NO(3) | 6)
+#define PINMUX_GPIO3__FUNC_SCP_VREQ_VAO (MTK_PIN_NO(3) | 7)
+
+#define PINMUX_GPIO4__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define PINMUX_GPIO4__FUNC_PWM_B (MTK_PIN_NO(4) | 1)
+#define PINMUX_GPIO4__FUNC_I2S0_MCK (MTK_PIN_NO(4) | 2)
+#define PINMUX_GPIO4__FUNC_SSPM_UTXD_AO (MTK_PIN_NO(4) | 3)
+#define PINMUX_GPIO4__FUNC_MD_URXD1 (MTK_PIN_NO(4) | 4)
+#define PINMUX_GPIO4__FUNC_TDM_BCK (MTK_PIN_NO(4) | 5)
+#define PINMUX_GPIO4__FUNC_TP_GPIO4_AO (MTK_PIN_NO(4) | 6)
+#define PINMUX_GPIO4__FUNC_DAP_MD32_SWD (MTK_PIN_NO(4) | 7)
+
+#define PINMUX_GPIO5__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define PINMUX_GPIO5__FUNC_PWM_C (MTK_PIN_NO(5) | 1)
+#define PINMUX_GPIO5__FUNC_I2S0_BCK (MTK_PIN_NO(5) | 2)
+#define PINMUX_GPIO5__FUNC_SSPM_URXD_AO (MTK_PIN_NO(5) | 3)
+#define PINMUX_GPIO5__FUNC_MD_UTXD1 (MTK_PIN_NO(5) | 4)
+#define PINMUX_GPIO5__FUNC_TDM_LRCK (MTK_PIN_NO(5) | 5)
+#define PINMUX_GPIO5__FUNC_TP_GPIO5_AO (MTK_PIN_NO(5) | 6)
+#define PINMUX_GPIO5__FUNC_DAP_MD32_SWCK (MTK_PIN_NO(5) | 7)
+
+#define PINMUX_GPIO6__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define PINMUX_GPIO6__FUNC_PWM_A (MTK_PIN_NO(6) | 1)
+#define PINMUX_GPIO6__FUNC_I2S0_LRCK (MTK_PIN_NO(6) | 2)
+#define PINMUX_GPIO6__FUNC_IDDIG (MTK_PIN_NO(6) | 3)
+#define PINMUX_GPIO6__FUNC_MD_URXD0 (MTK_PIN_NO(6) | 4)
+#define PINMUX_GPIO6__FUNC_TDM_DATA0 (MTK_PIN_NO(6) | 5)
+#define PINMUX_GPIO6__FUNC_TP_GPIO6_AO (MTK_PIN_NO(6) | 6)
+#define PINMUX_GPIO6__FUNC_CMFLASH (MTK_PIN_NO(6) | 7)
+
+#define PINMUX_GPIO7__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define PINMUX_GPIO7__FUNC_SPI1_B_MI (MTK_PIN_NO(7) | 1)
+#define PINMUX_GPIO7__FUNC_I2S0_DI (MTK_PIN_NO(7) | 2)
+#define PINMUX_GPIO7__FUNC_USB_DRVVBUS (MTK_PIN_NO(7) | 3)
+#define PINMUX_GPIO7__FUNC_MD_UTXD0 (MTK_PIN_NO(7) | 4)
+#define PINMUX_GPIO7__FUNC_TDM_DATA1 (MTK_PIN_NO(7) | 5)
+#define PINMUX_GPIO7__FUNC_TP_GPIO7_AO (MTK_PIN_NO(7) | 6)
+#define PINMUX_GPIO7__FUNC_DVFSRC_EXT_REQ (MTK_PIN_NO(7) | 7)
+
+#define PINMUX_GPIO8__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define PINMUX_GPIO8__FUNC_SPI1_B_CSB (MTK_PIN_NO(8) | 1)
+#define PINMUX_GPIO8__FUNC_ANT_SEL3 (MTK_PIN_NO(8) | 2)
+#define PINMUX_GPIO8__FUNC_SCL7 (MTK_PIN_NO(8) | 3)
+#define PINMUX_GPIO8__FUNC_CONN_MCU_TRST_B (MTK_PIN_NO(8) | 4)
+#define PINMUX_GPIO8__FUNC_TDM_DATA2 (MTK_PIN_NO(8) | 5)
+#define PINMUX_GPIO8__FUNC_MD_INT0 (MTK_PIN_NO(8) | 6)
+#define PINMUX_GPIO8__FUNC_JTRSTN_SEL1 (MTK_PIN_NO(8) | 7)
+
+#define PINMUX_GPIO9__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define PINMUX_GPIO9__FUNC_SPI1_B_MO (MTK_PIN_NO(9) | 1)
+#define PINMUX_GPIO9__FUNC_ANT_SEL4 (MTK_PIN_NO(9) | 2

[PATCH v2 0/1] PINCTRL: Mediatek pinctrl patch for mt8183

2019-03-02 Thread Zhiyong Tao
This series includes one patche:
1.Add drive for I2C related pins on MT8183.

Changes in patch v2:
1)add the details strength specification description of the I2C pin.
2)change "mt8183_pin_drv_en_dis_range" to "mt8183_pin_e1e0en_range".
3)change "mt8183_pin_drv_e0_range" to "mt8183_pin_e0_range".
4)change "mt8183_pin_drv_e1_range" to "mt8183_pin_drv_e1_range".

Zhiyong Tao (1):
  pinctrl: add drive for I2C related pins on MT8183

 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 13 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 20 ++
 4 files changed, 128 insertions(+)

--
2.12.5


[PATCH] pinctrl: add drive for I2C related pins on MT8183

2019-03-02 Thread Zhiyong Tao
This patch provides the advanced drive for I2C used pins on MT8183.
The detail strength specification description of the I2C pin is as follows.
When E1=0/E0=0, the strength is 0.125mA.
When E1=0/E0=1, the strength is 0.25mA.
When E1=1/E0=0, the strength is 0.5mA.
When E1=1/E0=1, the strength is 1mA.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 13 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 20 ++
 4 files changed, 128 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
index 6262fd3678ea..f034574fc593 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
@@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
mt8183_pin_r1_range[] = {
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
 };
 
+static const struct mtk_pin_field_calc mt8183_pin_e1e0en_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e0_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_e1_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1),
+};
+
 static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
@@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc 
mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_EN_DIS] = MTK_RANGE(mt8183_pin_e1e0en_range),
+   [PINCTRL_PIN_REG_DRV_E0] = MTK_RANGE(mt8183_pin_e0_range),
+   [PINCTRL_PIN_REG_DRV_E1] = MTK_RANGE(mt8183_pin_e1_range),
 };
 
 static const char * const mt8183_pinctrl_register_base_names[] = {
@@ -517,6 +565,8 @@ static const struct mtk_pin_soc mt8183_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_pull_get = mtk_pinconf_adv_pull_get,
.adv_pull_set = mtk_pinconf_adv_pull_set,
+   .adv_drive_get = mtk_pinconf_adv_drive_get,
+   .adv_drive_set = mtk_pinconf_adv_drive_set,
 };
 
 static const struct of_device_id mt8183_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 4a9e0d4c2bbc..da024279ec59 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -668,3 +668,48 @@ int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
 
return 0;
 }
+
+int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool enable,
+ u32 arg)
+{
+   int err

Re: [PATCH v7 3/6] dt-bindings: pinctrl: mt8183: add binding document

2019-02-18 Thread Zhiyong Tao
On Mon, 2019-02-18 at 10:32 -0600, Rob Herring wrote:
> On Fri, Feb 15, 2019 at 02:02:35PM +0800, Erin Lo wrote:
> > From: Zhiyong Tao 
> > 
> > The commit adds mt8183 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > Signed-off-by: Erin Lo 
> > ---
> >  .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 115 
> > +
> >  1 file changed, 115 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > new file mode 100644
> > index 000..364e673
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > @@ -0,0 +1,115 @@
> > +* Mediatek MT8183 Pin Controller
> > +
> > +The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +Required properties:
> > +- compatible: value should be one of the following.
> > +   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
> > +- gpio-controller : Marks the device node as a gpio controller.
> > +- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
> > +  binding is used, the amount of cells must be specified as 2. See the 
> > below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +- gpio-ranges : gpio valid number range.
> > +- reg: physicall address base for gpio base registers. There are nine
> > +  physicall address base in mt8183. They are 0x10005000, 0x11F2,
> > +  0x11E8, 0x11E7, 0x11E9, 0x11D3, 0x11D2, 0x11C5,
> > +  0x11F3.
> 
> You don't need to list out each address, just what each address is. (Or 
> just '9 GPIO base addresses'.)

==>ok, we will change it.
> 
> > +
> > +   Eg: < 6 0>
> 
> How is this an example of reg? Seems something is missing.
> 
> > +   <[phandle of the gpio controller node]
> > +   [line number within the gpio controller]
> > +   [flags]>
> > +
> > +   Values for gpio specifier:
> > +   - Line number: is a value between 0 to 202.
> > +   - Flags:  bit field of flags, as defined in .
> > +Only the following flags are supported:
> > +0 - GPIO_ACTIVE_HIGH
> > +1 - GPIO_ACTIVE_LOW
> > +
> > +Optional properties:
> > +- reg-names: gpio base register names. There are nine gpio base register
> > +  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", 
> > "iocfg4",
> > +  "iocfg5", "iocfg6", "iocfg7", "iocfg8".
> > +- interrupt-controller: Marks the device node as an interrupt controller
> > +- #interrupt-cells: Should be two.
> > +- interrupts : The interrupt outputs from the controller.
> 
> outputs? More than 1? If so, need to say what they are and the order.
> 
==> there is only use one interrupt in mt8183. we will change
"interrupts" to "interrupt" in v8.
> > +
> > +Please refer to pinctrl-bindings.txt in this directory for details of the
> > +common pinctrl bindings used by client devices.
> > +
> > +Subnode format
> > +A pinctrl node should contain at least one subnodes representing the
> > +pinctrl groups available on the machine. Each subnode will list the
> > +pins it needs, and how they should be configured, with regard to muxer
> > +configuration, pullups, drive strength, input enable/disable and input 
> > schmitt.
> > +
> > +node {
> > +   pinmux = ;
> > +   GENERIC_PINCONFIG;
> > +};
> > +
> > +Required properties:
> > +- pinmux: integer array, represents gpio pin number and mux setting.
> > +Supported pin number and mux varies for different SoCs, and are defined
> > +as macros in boot/dts/-pinfunc.h directly.
> > +
> > +Optional properties:
> > +- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
> > +bias-pull-down, bias-pull-up, input-enable, input-disable, output-low, 
> > output-high,
> > +input-schmitt-enable, input-schmitt-disable and drive-strength are 
> > valid.
> > +
> > +Some special pins have extra pull up strength, there are R0 and R1 
> > pull-up
> > +resistors available, but for user, it's only need to set R1R0 as 00, 
> > 01, 10 or 11.
> > +So when config mediatek,pull-up-adv or mediatek,pu

Re: [PATCH v7 3/6] dt-bindings: pinctrl: mt8183: add binding document

2019-02-18 Thread Zhiyong Tao
On Fri, 2019-02-15 at 10:35 +0100, Matthias Brugger wrote:
> 
> On 15/02/2019 07:02, Erin Lo wrote:
> > From: Zhiyong Tao 
> > 
> > The commit adds mt8183 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > Signed-off-by: Erin Lo 
> > ---
> >  .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 115 
> > +
> >  1 file changed, 115 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > new file mode 100644
> > index 000..364e673
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > @@ -0,0 +1,115 @@
> > +* Mediatek MT8183 Pin Controller
> > +
> > +The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +Required properties:
> > +- compatible: value should be one of the following.
> > +   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
> > +- gpio-controller : Marks the device node as a gpio controller.
> > +- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
> > +  binding is used, the amount of cells must be specified as 2. See the 
> > below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +- gpio-ranges : gpio valid number range.
> > +- reg: physicall address base for gpio base registers. There are nine
> 
> s/physicall/physical

==>we will modify it.
> 
> > +  physicall address base in mt8183. They are 0x10005000, 0x11F2,
> > +  0x11E8, 0x11E7, 0x11E9, 0x11D3, 0x11D2, 0x11C5,
> > +  0x11F3.
> > +
> > +   Eg: < 6 0>
> > +   <[phandle of the gpio controller node]
> > +   [line number within the gpio controller]
> > +   [flags]>
> > +
> > +   Values for gpio specifier:
> > +   - Line number: is a value between 0 to 202.
> > +   - Flags:  bit field of flags, as defined in .
> > +Only the following flags are supported:
> > +0 - GPIO_ACTIVE_HIGH
> > +1 - GPIO_ACTIVE_LOW
> > +
> > +Optional properties:
> > +- reg-names: gpio base register names. There are nine gpio base register
> > +  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", 
> > "iocfg4",
> > +  "iocfg5", "iocfg6", "iocfg7", "iocfg8".
> > +- interrupt-controller: Marks the device node as an interrupt controller
> > +- #interrupt-cells: Should be two.
> > +- interrupts : The interrupt outputs from the controller.
> 
> we are missing interrupt-parent here.

==> we will add it in next version. we will add like this:
- interrupts-parents : The interrupt connector. In mt8183, it is sysirq.

> 
> > +
> > +Please refer to pinctrl-bindings.txt in this directory for details of the
> > +common pinctrl bindings used by client devices.
> > +
> > +Subnode format
> > +A pinctrl node should contain at least one subnodes representing the
> > +pinctrl groups available on the machine. Each subnode will list the
> > +pins it needs, and how they should be configured, with regard to muxer
> > +configuration, pullups, drive strength, input enable/disable and input 
> > schmitt.
> > +
> > +node {
> > +   pinmux = ;
> > +   GENERIC_PINCONFIG;
> > +};
> > +
> > +Required properties:
> > +- pinmux: integer array, represents gpio pin number and mux setting.
> > +Supported pin number and mux varies for different SoCs, and are defined
> > +as macros in boot/dts/-pinfunc.h directly.
> > +
> > +Optional properties:
> > +- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
> > +bias-pull-down, bias-pull-up, input-enable, input-disable, output-low, 
> > output-high,
> > +input-schmitt-enable, input-schmitt-disable and drive-strength are 
> > valid.
> > +
> > +Some special pins have extra pull up strength, there are R0 and R1 
> > pull-up
> > +resistors available, but for user, it's only need to set R1R0 as 00, 
> > 01, 10 or 11.
> > +So when config mediatek,pull-up-adv or mediatek,pull-down-adv,
> > +it support arguments for those special pins.
> 
> I wonder if we should mention which this special pins are. A look at the 
> driver
> told me that it is not possib

Re: [PATCH v6 5/6] dt-bindings: pinctrl: mt8183: add binding document

2019-01-31 Thread Zhiyong Tao
On Wed, 2019-01-30 at 10:17 -0600, Rob Herring wrote:
> On Thu, Jan 24, 2019 at 04:07:19PM +0800, Erin Lo wrote:
> > From: Zhiyong Tao 
> > 
> > The commit adds mt8183 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > Signed-off-by: Erin Lo 
> > ---
> >  .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 115 
> > +
> >  1 file changed, 115 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > new file mode 100644
> > index 000..364e673
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > @@ -0,0 +1,115 @@
> > +* Mediatek MT8183 Pin Controller
> > +
> > +The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +Required properties:
> > +- compatible: value should be one of the following.
> > +   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
> > +- gpio-controller : Marks the device node as a gpio controller.
> > +- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
> > +  binding is used, the amount of cells must be specified as 2. See the 
> > below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +- gpio-ranges : gpio valid number range.
> > +- reg: physicall address base for gpio base registers. There are nine
> > +  physicall address base in mt8183. They are 0x10005000, 0x11F2,
> 
> Still have a typo in 'physicall'

==>sorry, we will change it in next version.
> 
> > +  0x11E8, 0x11E7, 0x11E9, 0x11D3, 0x11D2, 0x11C5,
> > +  0x11F3.
> 
> You don't need to list the address values. Only how many and what each 
> one is.
==>ok, because every base address don't have the detailed name. We will
remove the address values list and change it like this:
- reg: physical address base for gpio base registers. There are nine
  physical address base in mt8183.
> 
> > +
> > +   Eg: < 6 0>
> > +   <[phandle of the gpio controller node]
> > +   [line number within the gpio controller]
> > +   [flags]>
> > +
> > +   Values for gpio specifier:
> > +   - Line number: is a value between 0 to 202.
> > +   - Flags:  bit field of flags, as defined in .
> > +Only the following flags are supported:
> > +0 - GPIO_ACTIVE_HIGH
> > +1 - GPIO_ACTIVE_LOW
> > +
> > +Optional properties:
> > +- reg-names: gpio base register names. There are nine gpio base register
> > +  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", 
> > "iocfg4",
> > +  "iocfg5", "iocfg6", "iocfg7", "iocfg8".
> 
> As I said before, these names aren't useful. There's already 
> inheritently an index with 'reg'.
> 
> Unless some are optional and can be sparsely populated.

==> Do you mean that we can remove Optional properties the reg-names
description?
> 
> > +- interrupt-controller: Marks the device node as an interrupt controller
> > +- #interrupt-cells: Should be two.
> > +- interrupts : The interrupt outputs from the controller.
> > +
> > +Please refer to pinctrl-bindings.txt in this directory for details of the
> > +common pinctrl bindings used by client devices.
> > +
> > +Subnode format
> > +A pinctrl node should contain at least one subnodes representing the
> > +pinctrl groups available on the machine. Each subnode will list the
> > +pins it needs, and how they should be configured, with regard to muxer
> > +configuration, pullups, drive strength, input enable/disable and input 
> > schmitt.
> > +
> > +node {
> > +   pinmux = ;
> > +   GENERIC_PINCONFIG;
> > +};
> > +
> > +Required properties:
> > +- pinmux: integer array, represents gpio pin number and mux setting.
> > +Supported pin number and mux varies for different SoCs, and are defined
> > +as macros in boot/dts/-pinfunc.h directly.
> > +
> > +Optional properties:
> > +- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
> > +bias-pull-down, bias-pull-up, input-enable, input-disable, output-low, 
> > output-high,
> > +input-schmitt-enable, input-schmitt-disable and drive-strength are 
> > valid.
> > +
&

Re: [PATCH v5 5/6] dt-bindings: pinctrl: mt8183: add binding document

2019-01-06 Thread Zhiyong Tao
On Fri, 2019-01-04 at 01:55 -0800, Sean Wang wrote:
> On Fri, Jan 4, 2019 at 1:40 AM Zhiyong Tao  wrote:
> >
> > On Fri, 2019-01-04 at 01:14 -0800, Sean Wang wrote:
> > > On Thu, Jan 3, 2019 at 11:09 PM Zhiyong Tao  
> > > wrote:
> > > >
> > > > On Sat, 2018-12-29 at 06:04 +0800, Rob Herring wrote:
> > > > > On Fri, Dec 28, 2018 at 04:09:40PM +0800, Erin Lo wrote:
> > > > > > From: Zhiyong Tao 
> > > > > >
> > > > > > The commit adds mt8183 compatible node in binding document.
> > > > > >
> > > > > > Signed-off-by: Zhiyong Tao 
> > > > > > Signed-off-by: Erin Lo 
> > > > > > ---
> > > > > >  .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 110 
> > > > > > +
> > > > > >  1 file changed, 110 insertions(+)
> > > > > >  create mode 100644 
> > > > > > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > > > > >
> > > > > > diff --git 
> > > > > > a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
> > > > > > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > > > > > new file mode 100644
> > > > > > index 000..7b5285e
> > > > > > --- /dev/null
> > > > > > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > > > > > @@ -0,0 +1,110 @@
> > > > > > +* Mediatek MT8183 Pin Controller
> > > > > > +
> > > > > > +The Mediatek's Pin controller is used to control SoC pins.
> > > > > > +
> > > > > > +Required properties:
> > > > > > +- compatible: value should be one of the following.
> > > > > > +   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
> > > > > > +- gpio-controller : Marks the device node as a gpio controller.
> > > > > > +- #gpio-cells: number of cells in GPIO specifier. Since the 
> > > > > > generic GPIO
> > > > > > +  binding is used, the amount of cells must be specified as 2. See 
> > > > > > the below
> > > > > > +  mentioned gpio binding representation for description of 
> > > > > > particular cells.
> > > > > > +- gpio-ranges : gpio valid number range.
> > > > > > +
> > > > > > +   Eg: < 6 0>
> > > > > > +   <[phandle of the gpio controller node]
> > > > > > +   [line number within the gpio controller]
> > > > > > +   [flags]>
> > > > > > +
> > > > > > +   Values for gpio specifier:
> > > > > > +   - Line number: is a value between 0 to 202.
> > > > > > +   - Flags:  bit field of flags, as defined in 
> > > > > > .
> > > > > > +Only the following flags are supported:
> > > > > > +0 - GPIO_ACTIVE_HIGH
> > > > > > +1 - GPIO_ACTIVE_LOW
> > > > > > +
> > > > > > +Optional properties:
> > > > > > +- reg: physicall address base for gpio base registers.
> > > > >
> > > > > s/physicall/physical/
> > > > >
> > > > > reg should never be optional.
> > > > >
> > > > > Need to say how many reg entries.
> > > >
> > > > ==> Thanks for your suggestion. We will change 'reg' to Required
> > > > properties and add the reg entries in next version.
> > > > >
> > > > > > +- reg-names: gpio base registers name.
> > > > >
> > > > > Need to say what are the names. However, I don't find the names in the
> > > > > example all that useful, so I'd just drop it.
> > > >
> > > > ==> we will add the reg-names in next version.
> > > > They are used in the sample code, such as:
> > > > > + reg-names = "iocfg0", "iocfg1", "iocfg2",
> > > > > > +   "iocfg3", "iocfg4", "iocfg5",
> > > > > > +   "iocfg6", "iocfg7", "iocfg8";
> > > >
> > > > >
> > > > > > +- interrupt-controller: Marks the device node as an interrupt 
&g

Re: [PATCH v5 5/6] dt-bindings: pinctrl: mt8183: add binding document

2019-01-04 Thread Zhiyong Tao
On Fri, 2019-01-04 at 01:14 -0800, Sean Wang wrote:
> On Thu, Jan 3, 2019 at 11:09 PM Zhiyong Tao  wrote:
> >
> > On Sat, 2018-12-29 at 06:04 +0800, Rob Herring wrote:
> > > On Fri, Dec 28, 2018 at 04:09:40PM +0800, Erin Lo wrote:
> > > > From: Zhiyong Tao 
> > > >
> > > > The commit adds mt8183 compatible node in binding document.
> > > >
> > > > Signed-off-by: Zhiyong Tao 
> > > > Signed-off-by: Erin Lo 
> > > > ---
> > > >  .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 110 
> > > > +
> > > >  1 file changed, 110 insertions(+)
> > > >  create mode 100644 
> > > > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > > >
> > > > diff --git 
> > > > a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
> > > > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > > > new file mode 100644
> > > > index 000..7b5285e
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > > > @@ -0,0 +1,110 @@
> > > > +* Mediatek MT8183 Pin Controller
> > > > +
> > > > +The Mediatek's Pin controller is used to control SoC pins.
> > > > +
> > > > +Required properties:
> > > > +- compatible: value should be one of the following.
> > > > +   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
> > > > +- gpio-controller : Marks the device node as a gpio controller.
> > > > +- #gpio-cells: number of cells in GPIO specifier. Since the generic 
> > > > GPIO
> > > > +  binding is used, the amount of cells must be specified as 2. See the 
> > > > below
> > > > +  mentioned gpio binding representation for description of particular 
> > > > cells.
> > > > +- gpio-ranges : gpio valid number range.
> > > > +
> > > > +   Eg: < 6 0>
> > > > +   <[phandle of the gpio controller node]
> > > > +   [line number within the gpio controller]
> > > > +   [flags]>
> > > > +
> > > > +   Values for gpio specifier:
> > > > +   - Line number: is a value between 0 to 202.
> > > > +   - Flags:  bit field of flags, as defined in 
> > > > .
> > > > +Only the following flags are supported:
> > > > +0 - GPIO_ACTIVE_HIGH
> > > > +1 - GPIO_ACTIVE_LOW
> > > > +
> > > > +Optional properties:
> > > > +- reg: physicall address base for gpio base registers.
> > >
> > > s/physicall/physical/
> > >
> > > reg should never be optional.
> > >
> > > Need to say how many reg entries.
> >
> > ==> Thanks for your suggestion. We will change 'reg' to Required
> > properties and add the reg entries in next version.
> > >
> > > > +- reg-names: gpio base registers name.
> > >
> > > Need to say what are the names. However, I don't find the names in the
> > > example all that useful, so I'd just drop it.
> >
> > ==> we will add the reg-names in next version.
> > They are used in the sample code, such as:
> > > + reg-names = "iocfg0", "iocfg1", "iocfg2",
> > > > +   "iocfg3", "iocfg4", "iocfg5",
> > > > +   "iocfg6", "iocfg7", "iocfg8";
> >
> > >
> > > > +- interrupt-controller: Marks the device node as an interrupt 
> > > > controller
> > > > +- #interrupt-cells: Should be two.
> > > > +- interrupts : The interrupt outputs from the controller.
> > > > +
> > > > +Please refer to pinctrl-bindings.txt in this directory for details of 
> > > > the
> > > > +common pinctrl bindings used by client devices.
> > > > +
> > > > +Subnode format
> > > > +A pinctrl node should contain at least one subnodes representing the
> > > > +pinctrl groups available on the machine. Each subnode will list the
> > > > +pins it needs, and how they should be configured, with regard to muxer
> > > > +configuration, pullups, drive strength, input enable/disable and input 
> > > > schmitt.
> > > > +
> > > > +node {
> > > > +   pinmux = ;
> >

Re: [PATCH] pinctrl: add drive for I2C related pins on MT8183

2019-01-04 Thread Zhiyong Tao
On Wed, 2018-12-12 at 04:51 +0800, Sean Wang wrote:
> The subject should be refined to be close to the content
> 
> On Tue, Dec 11, 2018 at 12:02 AM Zhiyong Tao  wrote:
> >
> > This patch provides the advanced drive for I2C used pins on MT8183.
> >
> 
> Additionally, you should state more how much strength in mA given on
> each step E1, E0 move forward. This way would help to reuse the scheme
> on the similar SoCs.

==> 
Hi sean,
Thanks for your suggestion. 
when E1=0/E0=0, the strength is 0.125mA;
when E1=0/E0=1, the strength is 0.25mA;
when E1=1/E0=0, the strength is 0.5mA;
when E1=1/E0=1, the strength is 1mA;
we will add it in the commit message in the next version.

Thanks.
> 
> > Signed-off-by: Zhiyong Tao 
> > ---
> >  drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
> > 
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 +
> >  drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 13 ++
> >  drivers/pinctrl/mediatek/pinctrl-paris.c | 20 ++
> >  4 files changed, 128 insertions(+)
> >
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
> > b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
> > index 6262fd3678ea..5244e1b27b1d 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
> > @@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
> > mt8183_pin_r1_range[] = {
> > PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
> >  };
> >
> > +static const struct mtk_pin_field_calc mt8183_pin_drv_en_dis_range[] = {
> 
> I'd prefer using the word mt8183_pin_e1e0en_range to keep people away from
> be confused the relationship with the existing mt8183_pin_drv_range.
> 
> > +   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
> > +   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
> > +   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
> > +   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
> > +   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
> > +   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
> > +   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
> > +   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
> > +   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
> > +   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
> > +   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
> > +   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
> > +};
> > +
> > +static const struct mtk_pin_field_calc mt8183_pin_drv_e0_range[] = {
> 
> Ditto, I'd prefer using the word mt8183_pin_e0_range
> 
> > +   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
> > +   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
> > +   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
> > +   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
> > +   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
> > +   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
> > +   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
> > +   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
> > +   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
> > +   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
> > +   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
> > +   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
> > +};
> > +
> > +static const struct mtk_pin_field_calc mt8183_pin_drv_e1_range[] = {
> 
> Ditto, I'd prefer using the word mt8183_pin_e1_range
> 
> > +   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
> > +   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
> > +   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
> > +   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
> > +   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
> > +   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
> > +   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
> > +   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
> > +   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
> > +   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
> > +   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
> > +   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1),
> > +};
> > +
> >  static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] 
> > = {
> > [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
> > [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
> > @@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc 
> > mt8183_reg_c

Re: [PATCH v5 5/6] dt-bindings: pinctrl: mt8183: add binding document

2019-01-03 Thread Zhiyong Tao
On Sat, 2018-12-29 at 06:04 +0800, Rob Herring wrote:
> On Fri, Dec 28, 2018 at 04:09:40PM +0800, Erin Lo wrote:
> > From: Zhiyong Tao 
> > 
> > The commit adds mt8183 compatible node in binding document.
> > 
> > Signed-off-by: Zhiyong Tao 
> > Signed-off-by: Erin Lo 
> > ---
> >  .../devicetree/bindings/pinctrl/pinctrl-mt8183.txt | 110 
> > +
> >  1 file changed, 110 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt 
> > b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > new file mode 100644
> > index 000..7b5285e
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8183.txt
> > @@ -0,0 +1,110 @@
> > +* Mediatek MT8183 Pin Controller
> > +
> > +The Mediatek's Pin controller is used to control SoC pins.
> > +
> > +Required properties:
> > +- compatible: value should be one of the following.
> > +   "mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
> > +- gpio-controller : Marks the device node as a gpio controller.
> > +- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
> > +  binding is used, the amount of cells must be specified as 2. See the 
> > below
> > +  mentioned gpio binding representation for description of particular 
> > cells.
> > +- gpio-ranges : gpio valid number range.
> > +
> > +   Eg: < 6 0>
> > +   <[phandle of the gpio controller node]
> > +   [line number within the gpio controller]
> > +   [flags]>
> > +
> > +   Values for gpio specifier:
> > +   - Line number: is a value between 0 to 202.
> > +   - Flags:  bit field of flags, as defined in .
> > +Only the following flags are supported:
> > +0 - GPIO_ACTIVE_HIGH
> > +1 - GPIO_ACTIVE_LOW
> > +
> > +Optional properties:
> > +- reg: physicall address base for gpio base registers.
> 
> s/physicall/physical/
> 
> reg should never be optional. 
> 
> Need to say how many reg entries.

==> Thanks for your suggestion. We will change 'reg' to Required
properties and add the reg entries in next version.
> 
> > +- reg-names: gpio base registers name.
> 
> Need to say what are the names. However, I don't find the names in the 
> example all that useful, so I'd just drop it.

==> we will add the reg-names in next version.
They are used in the sample code, such as:
> + reg-names = "iocfg0", "iocfg1", "iocfg2",
> > +   "iocfg3", "iocfg4", "iocfg5",
> > +   "iocfg6", "iocfg7", "iocfg8";

> 
> > +- interrupt-controller: Marks the device node as an interrupt controller
> > +- #interrupt-cells: Should be two.
> > +- interrupts : The interrupt outputs from the controller.
> > +
> > +Please refer to pinctrl-bindings.txt in this directory for details of the
> > +common pinctrl bindings used by client devices.
> > +
> > +Subnode format
> > +A pinctrl node should contain at least one subnodes representing the
> > +pinctrl groups available on the machine. Each subnode will list the
> > +pins it needs, and how they should be configured, with regard to muxer
> > +configuration, pullups, drive strength, input enable/disable and input 
> > schmitt.
> > +
> > +node {
> > +   pinmux = ;
> > +   GENERIC_PINCONFIG;
> > +};
> > +
> > +Required properties:
> > +- pinmux: integer array, represents gpio pin number and mux setting.
> > +Supported pin number and mux varies for different SoCs, and are defined
> > +as macros in boot/dts/-pinfunc.h directly.
> > +
> > +Optional properties:
> > +- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
> > +bias-pull-down, bias-pull-up, input-enable, input-disable, output-low, 
> > output-high,
> > +input-schmitt-enable, input-schmitt-disable and drive-strength are 
> > valid.
> > +
> > +Some special pins have extra pull up strength, there are R0 and R1 
> > pull-up
> > +resistors available, but for user, it's only need to set R1R0 as 00, 
> > 01, 10 or 11.
> > +So when config mediatek,pull-up-adv or mediatek,pull-down-adv,
> > +it support arguments for those special pins.
> > +
> > +When config drive-strength, it can support some arguments, such as
>

[PATCH] pinctrl: add drive for I2C related pins on MT8183

2018-12-11 Thread Zhiyong Tao
This patch provides the advanced drive for I2C used pins on MT8183.

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 13 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 20 ++
 4 files changed, 128 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c 
b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
index 6262fd3678ea..5244e1b27b1d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c
@@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc 
mt8183_pin_r1_range[] = {
PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1),
 };
 
+static const struct mtk_pin_field_calc mt8183_pin_drv_en_dis_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_drv_e0_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1),
+};
+
+static const struct mtk_pin_field_calc mt8183_pin_drv_e1_range[] = {
+   PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1),
+   PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1),
+   PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1),
+   PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1),
+   PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1),
+   PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1),
+   PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1),
+   PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1),
+   PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1),
+   PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1),
+   PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1),
+};
+
 static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range),
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range),
@@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc 
mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = {
[PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range),
[PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range),
[PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range),
+   [PINCTRL_PIN_REG_DRV_EN_DIS] = MTK_RANGE(mt8183_pin_drv_en_dis_range),
+   [PINCTRL_PIN_REG_DRV_E0] = MTK_RANGE(mt8183_pin_drv_e0_range),
+   [PINCTRL_PIN_REG_DRV_E1] = MTK_RANGE(mt8183_pin_drv_e1_range),
 };
 
 static const char * const mt8183_pinctrl_register_base_names[] = {
@@ -517,6 +565,8 @@ static const struct mtk_pin_soc mt8183_data = {
.drive_get = mtk_pinconf_drive_get_rev1,
.adv_pull_get = mtk_pinconf_adv_pull_get,
.adv_pull_set = mtk_pinconf_adv_pull_set,
+   .adv_drive_get = mtk_pinconf_adv_drive_get,
+   .adv_drive_set = mtk_pinconf_adv_drive_set,
 };
 
 static const struct of_device_id mt8183_pinctrl_of_match[] = {
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 4a9e0d4c2bbc..da024279ec59 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -668,3 +668,48 @@ int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,
 
return 0;
 }
+
+int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw,
+ const struct mtk_pin_desc *desc, bool enable,
+ u32 arg)
+{
+   int err;
+
+   err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_E0, arg & 1);
+   if (err)
+   return 0;
+
+   err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DR

[PATCH v1 0/1] PINCTRL: Mediatek pinctrl patch for mt8183

2018-12-11 Thread Zhiyong Tao
This series includes one patche:
1.Add drive for I2C related pins on MT8183.

Zhiyong Tao (1):
  pinctrl: add drive for I2C related pins on MT8183

 drivers/pinctrl/mediatek/pinctrl-mt8183.c| 50 
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 13 ++
 drivers/pinctrl/mediatek/pinctrl-paris.c | 20 ++
 4 files changed, 128 insertions(+)

--
2.12.5



[PATCH v4 4/5] pintcrl: support bias-disable of generic and special pins simultaneously

2018-03-21 Thread Zhiyong Tao
For generic pins, parameter "arg" is 0 or 1.
For special pins, bias-disable is set by R0R1,
so we need transmited "00" to set bias-disable
When we set "bias-disable" as high-z property,
the parameter should be "MTK_PUPD_SET_R1R0_00".

Signed-off-by: Zhiyong Tao <zhiyong@mediatek.com>
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 3cf384f..f991ff3 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -293,7 +293,7 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl 
*pctl,
unsigned int pin, bool enable, bool isup, unsigned int arg)
 {
unsigned int bit;
-   unsigned int reg_pullen, reg_pullsel;
+   unsigned int reg_pullen, reg_pullsel, r1r0;
int ret;
 
/* Some pins' pull setting are very different,
@@ -301,8 +301,12 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl 
*pctl,
 * resistor bit, so we need this special handle.
 */
if (pctl->devdata->spec_pull_set) {
+   /* For special pins, bias-disable is set by R1R0,
+* the parameter should be "MTK_PUPD_SET_R1R0_00".
+*/
+   r1r0 = enable ? arg : MTK_PUPD_SET_R1R0_00;
ret = pctl->devdata->spec_pull_set(mtk_get_regmap(pctl, pin),
-   pin, pctl->devdata->port_align, isup, arg);
+   pin, pctl->devdata->port_align, isup, r1r0);
if (!ret)
return 0;
}
-- 
1.9.1



[PATCH v4 4/5] pintcrl: support bias-disable of generic and special pins simultaneously

2018-03-21 Thread Zhiyong Tao
For generic pins, parameter "arg" is 0 or 1.
For special pins, bias-disable is set by R0R1,
so we need transmited "00" to set bias-disable
When we set "bias-disable" as high-z property,
the parameter should be "MTK_PUPD_SET_R1R0_00".

Signed-off-by: Zhiyong Tao 
---
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c 
b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index 3cf384f..f991ff3 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -293,7 +293,7 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl 
*pctl,
unsigned int pin, bool enable, bool isup, unsigned int arg)
 {
unsigned int bit;
-   unsigned int reg_pullen, reg_pullsel;
+   unsigned int reg_pullen, reg_pullsel, r1r0;
int ret;
 
/* Some pins' pull setting are very different,
@@ -301,8 +301,12 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl 
*pctl,
 * resistor bit, so we need this special handle.
 */
if (pctl->devdata->spec_pull_set) {
+   /* For special pins, bias-disable is set by R1R0,
+* the parameter should be "MTK_PUPD_SET_R1R0_00".
+*/
+   r1r0 = enable ? arg : MTK_PUPD_SET_R1R0_00;
ret = pctl->devdata->spec_pull_set(mtk_get_regmap(pctl, pin),
-   pin, pctl->devdata->port_align, isup, arg);
+   pin, pctl->devdata->port_align, isup, r1r0);
if (!ret)
return 0;
}
-- 
1.9.1



  1   2   3   >