pinctrl: mediatek: add support for different types of IO pins

There are many pins in an SoC, and register usage may vary by pins.
This patch introduces a concept of "io type" and "io type group"
to mediatek pinctrl drivers. This can provide different pinconf
handlers implementation (eg: "bias-pull-up/down", "driving" and
"input-enable") for IO pins that belong to different types.

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h
index 91a8c05..0d9596f 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h
@@ -12,10 +12,15 @@
 #define MAX_BASE_CALC 10
 
 #define MTK_RANGE(_a)		{ .range = (_a), .nranges = ARRAY_SIZE(_a), }
-#define MTK_PIN(_number, _name, _drv_n) {				\
+
+#define MTK_PIN(_number, _name, _drv_n)					\
+	MTK_TYPED_PIN(_number, _name, _drv_n, IO_TYPE_DEFAULT)
+
+#define MTK_TYPED_PIN(_number, _name, _drv_n, _io_n) {			\
 		.number = _number,					\
 		.name = _name,						\
 		.drv_n = _drv_n,					\
+		.io_n = _io_n,						\
 	}
 
 #define PINCTRL_PIN_GROUP(name, id)					\
@@ -75,6 +80,18 @@
 	DRV_GRP4,
 };
 
+/* Group the pins by the io type */
+enum {
+	IO_TYPE_DEFAULT,
+	IO_TYPE_GRP0,
+	IO_TYPE_GRP1,
+	IO_TYPE_GRP2,
+	IO_TYPE_GRP3,
+	IO_TYPE_GRP4,
+	IO_TYPE_GRP5,
+	IO_TYPE_GRP6,
+};
+
 /**
  * struct mtk_pin_field - the structure that holds the information of the field
  *			  used to describe the attribute for the pin
@@ -139,11 +156,13 @@
  * @number:		unique pin number from the global pin number space
  * @name:		name for this pin
  * @drv_n:		the index with the driving group
+ * @io_n:		the index with the io type
  */
 struct mtk_pin_desc {
 	unsigned int number;
 	const char *name;
 	u8 drv_n;
+	u8 io_n;
 };
 
 /**
@@ -172,6 +191,21 @@
 	int num_group_names;
 };
 
+/**
+ * struct mtk_io_type_desc - io class descriptor for specific pins
+ * @name: name of the io class
+ */
+struct mtk_io_type_desc {
+	const char *name;
+#if CONFIG_IS_ENABLED(PINCONF)
+	/* Specific pinconfig operations */
+	int (*bias_set)(struct udevice *dev, u32 pin, bool disable,
+			bool pullup, u32 val);
+	int (*drive_set)(struct udevice *dev, u32 pin, u32 arg);
+	int (*input_enable)(struct udevice *dev, u32 pin, u32 arg);
+#endif
+};
+
 /* struct mtk_pin_soc - the structure that holds SoC-specific data */
 struct mtk_pinctrl_soc {
 	const char *name;
@@ -182,6 +216,8 @@
 	int ngrps;
 	const struct mtk_function_desc *funcs;
 	int nfuncs;
+	const struct mtk_io_type_desc *io_type;
+	u8 ntype;
 	int gpio_mode;
 	const char * const *base_names;
 	unsigned int nbase_names;