Merge "chore(tc): enable the full 16GB DRAM for TC3 and TC4 as default" into integration
diff --git a/plat/arm/board/tc/include/platform_def.h b/plat/arm/board/tc/include/platform_def.h
index 5fc8899..92afb62 100644
--- a/plat/arm/board/tc/include/platform_def.h
+++ b/plat/arm/board/tc/include/platform_def.h
@@ -341,13 +341,13 @@
  * PLAT_CSS_MAX_SCP_BL2_SIZE is calculated using the current
  * SCP_BL2 size plus a little space for growth.
  */
-#define PLAT_CSS_MAX_SCP_BL2_SIZE	0x20000
+#define PLAT_CSS_MAX_SCP_BL2_SIZE	0x30000
 
 /*
  * PLAT_CSS_MAX_SCP_BL2U_SIZE is calculated using the current
  * SCP_BL2U size plus a little space for growth.
  */
-#define PLAT_CSS_MAX_SCP_BL2U_SIZE	0x20000
+#define PLAT_CSS_MAX_SCP_BL2U_SIZE	0x30000
 
 #if TARGET_PLATFORM <= 2
 /* TZC Related Constants */
diff --git a/plat/mediatek/drivers/gpio/mtgpio_common.h b/plat/mediatek/drivers/gpio/mtgpio_common.h
index d6b858c..a93a065 100644
--- a/plat/mediatek/drivers/gpio/mtgpio_common.h
+++ b/plat/mediatek/drivers/gpio/mtgpio_common.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2022, MediaTek Inc. All rights reserved.
+ * Copyright (c) 2020-2024, MediaTek Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -97,7 +97,7 @@
 	}
 
 struct mt_pin_info {
-	uint8_t id;
+	uint16_t id;
 	uint8_t flag;
 	uint8_t bit;
 	uint16_t base;
diff --git a/plat/mediatek/mt8196/drivers/gpio/mtgpio.c b/plat/mediatek/mt8196/drivers/gpio/mtgpio.c
new file mode 100644
index 0000000..6257159
--- /dev/null
+++ b/plat/mediatek/mt8196/drivers/gpio/mtgpio.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2024, MediaTek Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <assert.h>
+#include <platform_def.h>
+#include <mtgpio.h>
+
+typedef enum {
+	REG_0 = 0,
+	REG_1,
+	REG_2,
+	REG_3,
+	REG_4,
+	REG_5,
+	REG_6,
+	REG_7,
+	REG_8,
+	REG_9,
+	REG_10,
+	REG_11,
+	REG_12,
+	REG_13,
+	REG_14
+} RegEnum;
+
+uintptr_t mt_gpio_find_reg_addr(uint32_t pin)
+{
+	uintptr_t reg_addr = 0U;
+	struct mt_pin_info gpio_info;
+
+	assert(pin < MAX_GPIO_PIN);
+
+	gpio_info = mt_pin_infos[pin];
+
+	switch (gpio_info.base & 0xF) {
+	case REG_0:
+		reg_addr = IOCFG_RT_BASE;
+		break;
+	case REG_1:
+		reg_addr = IOCFG_RM1_BASE;
+		break;
+	case REG_2:
+		reg_addr = IOCFG_RM2_BASE;
+		break;
+	case REG_3:
+		reg_addr = IOCFG_RB_BASE;
+		break;
+	case REG_4:
+		reg_addr = IOCFG_BM1_BASE;
+		break;
+	case REG_5:
+		reg_addr = IOCFG_BM2_BASE;
+		break;
+	case REG_6:
+		reg_addr = IOCFG_BM3_BASE;
+		break;
+	case REG_7:
+		reg_addr = IOCFG_LT_BASE;
+		break;
+	case REG_8:
+		reg_addr = IOCFG_LM1_BASE;
+		break;
+	case REG_9:
+		reg_addr = IOCFG_LM2_BASE;
+		break;
+	case REG_10:
+		reg_addr = IOCFG_LB1_BASE;
+		break;
+	case REG_11:
+		reg_addr = IOCFG_LB2_BASE;
+		break;
+	case REG_12:
+		reg_addr = IOCFG_TM1_BASE;
+		break;
+	case REG_13:
+		reg_addr = IOCFG_TM2_BASE;
+		break;
+	case REG_14:
+		reg_addr = IOCFG_TM3_BASE;
+		break;
+	default:
+		break;
+	}
+
+	return reg_addr;
+}
diff --git a/plat/mediatek/mt8196/drivers/gpio/mtgpio.h b/plat/mediatek/mt8196/drivers/gpio/mtgpio.h
new file mode 100644
index 0000000..a33bdad
--- /dev/null
+++ b/plat/mediatek/mt8196/drivers/gpio/mtgpio.h
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2024, MediaTek Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef MT_GPIO_H
+#define MT_GPIO_H
+
+#include <mtgpio_common.h>
+
+/* Enumeration for GPIO pin */
+typedef enum GPIO_PIN {
+	GPIO_UNSUPPORTED = -1,
+	GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6,
+	GPIO7, GPIO8, GPIO9, GPIO10, GPIO11, GPIO12, GPIO13, GPIO14,
+	GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO20, GPIO21, GPIO22,
+	GPIO23, GPIO24, GPIO25, GPIO26, GPIO27, GPIO28, GPIO29, GPIO30,
+	GPIO31, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO37, GPIO38,
+	GPIO39, GPIO40, GPIO41, GPIO42, GPIO43, GPIO44, GPIO45, GPIO46,
+	GPIO47, GPIO48, GPIO49, GPIO50, GPIO51, GPIO52, GPIO53, GPIO54,
+	GPIO55, GPIO56, GPIO57, GPIO58, GPIO59, GPIO60, GPIO61, GPIO62,
+	GPIO63, GPIO64, GPIO65, GPIO66, GPIO67, GPIO68, GPIO69, GPIO70,
+	GPIO71, GPIO72, GPIO73, GPIO74, GPIO75, GPIO76, GPIO77, GPIO78,
+	GPIO79, GPIO80, GPIO81, GPIO82, GPIO83, GPIO84, GPIO85, GPIO86,
+	GPIO87, GPIO88, GPIO89, GPIO90, GPIO91, GPIO92, GPIO93, GPIO94,
+	GPIO95, GPIO96, GPIO97, GPIO98, GPIO99, GPIO100, GPIO101, GPIO102,
+	GPIO103, GPIO104, GPIO105, GPIO106, GPIO107, GPIO108, GPIO109, GPIO110,
+	GPIO111, GPIO112, GPIO113, GPIO114, GPIO115, GPIO116, GPIO117, GPIO118,
+	GPIO119, GPIO120, GPIO121, GPIO122, GPIO123, GPIO124, GPIO125, GPIO126,
+	GPIO127, GPIO128, GPIO129, GPIO130, GPIO131, GPIO132, GPIO133, GPIO134,
+	GPIO135, GPIO136, GPIO137, GPIO138, GPIO139, GPIO140, GPIO141, GPIO142,
+	GPIO143, GPIO144, GPIO145, GPIO146, GPIO147, GPIO148, GPIO149, GPIO150,
+	GPIO151, GPIO152, GPIO153, GPIO154, GPIO155, GPIO156, GPIO157, GPIO158,
+	GPIO159, GPIO160, GPIO161, GPIO162, GPIO163, GPIO164, GPIO165, GPIO166,
+	GPIO167, GPIO168, GPIO169, GPIO170, GPIO171, GPIO172, GPIO173, GPIO174,
+	GPIO175, GPIO176, GPIO177, GPIO178, GPIO179, GPIO180, GPIO181, GPIO182,
+	GPIO183, GPIO184, GPIO185, GPIO186, GPIO187, GPIO188, GPIO189, GPIO190,
+	GPIO191, GPIO192, GPIO193, GPIO194, GPIO195, GPIO196, GPIO197, GPIO198,
+	GPIO199, GPIO200, GPIO201, GPIO202, GPIO203, GPIO204, GPIO205, GPIO206,
+	GPIO207, GPIO208, GPIO209, GPIO210, GPIO211, GPIO212, GPIO213, GPIO214,
+	GPIO215, GPIO216, GPIO217, GPIO218, GPIO219, GPIO220, GPIO221, GPIO222,
+	GPIO223, GPIO224, GPIO225, GPIO226, GPIO227, GPIO228, GPIO229, GPIO230,
+	GPIO231, GPIO232, GPIO233, GPIO234, GPIO235, GPIO236, GPIO237, GPIO238,
+	GPIO239, GPIO240, GPIO241, GPIO242, GPIO243, GPIO244, GPIO245, GPIO246,
+	GPIO247, GPIO248, GPIO249, GPIO250, GPIO251, GPIO252, GPIO253, GPIO254,
+	GPIO255, GPIO256, GPIO257, GPIO258, GPIO259, GPIO260, GPIO261, GPIO262,
+	GPIO263, GPIO264, GPIO265, GPIO266, GPIO267, GPIO268, GPIO269, GPIO270,
+	MT_GPIO_BASE_MAX
+} GPIO_PIN;
+
+static const struct mt_pin_info mt_pin_infos[] = {
+	PIN(0, 0, 0, 0x18, 0x90),
+	PIN(1, 0, 1, 0x18, 0x90),
+	PIN(2, 0, 1, 0x1b, 0x70),
+	PIN(3, 0, 2, 0x1b, 0x70),
+	PIN(4, 0, 3, 0x1b, 0x70),
+	PIN(5, 0, 4, 0x1b, 0x70),
+	PIN(6, 0, 5, 0x1b, 0x70),
+	PIN(7, 0, 6, 0x1b, 0x70),
+	PIN(8, 0, 7, 0x1b, 0x70),
+	PIN(9, 0, 14, 0x29, 0xa0),
+	PIN(10, 0, 12, 0x29, 0xa0),
+	PIN(11, 0, 2, 0x18, 0x90),
+	PIN(12, 0, 13, 0x29, 0xa0),
+	PIN(13, 0, 1, 0x26, 0x90),
+	PIN(14, 0, 0, 0x13, 0x80),
+	PIN(15, 0, 2, 0x26, 0x90),
+	PIN(16, 0, 3, 0x26, 0x90),
+	PIN(17, 0, 4, 0x26, 0x90),
+	PIN(18, 0, 5, 0x26, 0x90),
+	PIN(19, 0, 6, 0x26, 0x90),
+	PIN(20, 0, 1, 0x13, 0x80),
+	PIN(21, 0, 3, 0x12, 0x80),
+	PIN(22, 0, 4, 0x12, 0x80),
+	PIN(23, 0, 5, 0x12, 0x80),
+	PIN(24, 0, 6, 0x12, 0x80),
+	PIN(25, 0, 7, 0x12, 0x80),
+	PIN(26, 0, 8, 0x12, 0x80),
+	PIN(27, 0, 9, 0x12, 0x80),
+	PIN(28, 0, 10, 0x12, 0x80),
+	PIN(29, 0, 11, 0x12, 0x80),
+	PIN(30, 0, 12, 0x12, 0x80),
+	PIN(31, 0, 13, 0x12, 0x80),
+	PIN(32, 0, 8, 0x11, 0x80),
+	PIN(33, 0, 9, 0x11, 0x80),
+	PIN(34, 0, 10, 0x11, 0x80),
+	PIN(35, 0, 11, 0x11, 0x80),
+	PIN(36, 0, 12, 0x11, 0x80),
+	PIN(37, 0, 13, 0x11, 0x80),
+	PIN(38, 0, 14, 0x11, 0x80),
+	PIN(39, 0, 6, 0x18, 0x90),
+	PIN(40, 0, 3, 0x18, 0x90),
+	PIN(41, 0, 5, 0x18, 0x90),
+	PIN(42, 0, 4, 0x18, 0x90),
+	PIN(43, 0, 7, 0x18, 0x90),
+	PIN(44, 0, 8, 0x18, 0x90),
+	PIN(45, 0, 9, 0x18, 0x90),
+	PIN(46, 0, 10, 0x18, 0x90),
+	PIN(47, 0, 13, 0x18, 0x90),
+	PIN(48, 0, 11, 0x18, 0x90),
+	PIN(49, 0, 14, 0x18, 0x90),
+	PIN(50, 0, 12, 0x18, 0x90),
+	PIN(51, 0, 15, 0x18, 0x90),
+	PIN(52, 0, 7, 0x29, 0xa0),
+	PIN(53, 0, 8, 0x29, 0xa0),
+	PIN(54, 0, 2, 0x29, 0xa0),
+	PIN(55, 0, 1, 0x29, 0xa0),
+	PIN(56, 0, 5, 0x29, 0xa0),
+	PIN(57, 0, 6, 0x29, 0xa0),
+	PIN(58, 0, 3, 0x29, 0xa0),
+	PIN(59, 0, 4, 0x29, 0xa0),
+	PIN(60, 1, 0, 0x29, 0xb0),
+	PIN(61, 0, 10, 0x29, 0xa0),
+	PIN(62, 0, 9, 0x29, 0xa0),
+	PIN(63, 0, 18, 0x29, 0xa0),
+	PIN(64, 0, 0, 0x29, 0xa0),
+	PIN(65, 0, 11, 0x29, 0xa0),
+	PIN(66, 0, 24, 0x29, 0xa0),
+	PIN(67, 0, 21, 0x29, 0xa0),
+	PIN(68, 0, 20, 0x29, 0xa0),
+	PIN(69, 0, 25, 0x29, 0xa0),
+	PIN(70, 0, 16, 0x29, 0xa0),
+	PIN(71, 0, 15, 0x29, 0xa0),
+	PIN(72, 0, 23, 0x29, 0xa0),
+	PIN(73, 0, 19, 0x29, 0xa0),
+	PIN(74, 0, 17, 0x29, 0xa0),
+	PIN(75, 0, 2, 0x1a, 0x80),
+	PIN(76, 0, 3, 0x1a, 0x80),
+	PIN(77, 0, 4, 0x1a, 0x80),
+	PIN(78, 0, 5, 0x1a, 0x80),
+	PIN(79, 0, 0, 0x1a, 0x80),
+	PIN(80, 0, 1, 0x1a, 0x80),
+	PIN(81, 0, 9, 0x1b, 0x70),
+	PIN(82, 0, 10, 0x1b, 0x70),
+	PIN(83, 0, 12, 0x1b, 0x70),
+	PIN(84, 0, 11, 0x1b, 0x70),
+	PIN(85, 0, 13, 0x1b, 0x70),
+	PIN(86, 0, 14, 0x1b, 0x70),
+	PIN(87, 0, 16, 0x1b, 0x70),
+	PIN(88, 0, 15, 0x1b, 0x70),
+	PIN(89, 0, 0, 0x1b, 0x70),
+	PIN(90, 0, 8, 0x1b, 0x70),
+	PIN(91, 0, 6, 0x1c, 0x80),
+	PIN(92, 0, 7, 0x1c, 0x80),
+	PIN(93, 0, 8, 0x1c, 0x80),
+	PIN(94, 0, 4, 0x1c, 0x80),
+	PIN(95, 0, 1, 0x1c, 0x80),
+	PIN(96, 0, 3, 0x1c, 0x80),
+	PIN(97, 0, 2, 0x1c, 0x80),
+	PIN(98, 0, 5, 0x1c, 0x80),
+	PIN(99, 0, 9, 0x1c, 0x80),
+	PIN(100, 0, 12, 0x1c, 0x80),
+	PIN(101, 0, 10, 0x1c, 0x80),
+	PIN(102, 0, 13, 0x1c, 0x80),
+	PIN(103, 0, 0, 0x1c, 0x80),
+	PIN(104, 0, 11, 0x1c, 0x80),
+	PIN(105, 0, 14, 0x1c, 0x80),
+	PIN(106, 0, 0, 0x15, 0x80),
+	PIN(107, 0, 1, 0x15, 0x80),
+	PIN(108, 0, 3, 0x15, 0x80),
+	PIN(109, 0, 2, 0x15, 0x80),
+	PIN(110, 0, 4, 0x15, 0x80),
+	PIN(111, 0, 5, 0x15, 0x80),
+	PIN(112, 0, 7, 0x15, 0x80),
+	PIN(113, 0, 6, 0x15, 0x80),
+	PIN(114, 0, 8, 0x15, 0x80),
+	PIN(115, 0, 9, 0x15, 0x80),
+	PIN(116, 0, 11, 0x15, 0x80),
+	PIN(117, 0, 10, 0x15, 0x80),
+	PIN(118, 0, 9, 0x26, 0x90),
+	PIN(119, 0, 10, 0x26, 0x90),
+	PIN(120, 0, 12, 0x26, 0x90),
+	PIN(121, 0, 11, 0x26, 0x90),
+	PIN(122, 0, 0, 0x26, 0x90),
+	PIN(123, 0, 7, 0x26, 0x90),
+	PIN(124, 0, 8, 0x26, 0x90),
+	PIN(125, 1, 0, 0x17, 0x80),
+	PIN(126, 1, 1, 0x17, 0x80),
+	PIN(127, 1, 2, 0x17, 0x80),
+	PIN(128, 1, 3, 0x17, 0x80),
+	PIN(129, 1, 4, 0x17, 0x80),
+	PIN(130, 1, 5, 0x17, 0x80),
+	PIN(131, 1, 9, 0x17, 0x80),
+	PIN(132, 1, 11, 0x17, 0x80),
+	PIN(133, 1, 10, 0x17, 0x80),
+	PIN(134, 1, 6, 0x17, 0x80),
+	PIN(135, 1, 8, 0x17, 0x80),
+	PIN(136, 1, 7, 0x17, 0x80),
+	PIN(137, 1, 10, 0x14, 0x70),
+	PIN(138, 1, 11, 0x14, 0x70),
+	PIN(139, 1, 12, 0x14, 0x70),
+	PIN(140, 1, 13, 0x14, 0x70),
+	PIN(141, 1, 14, 0x14, 0x70),
+	PIN(142, 1, 15, 0x14, 0x70),
+	PIN(143, 1, 16, 0x14, 0x70),
+	PIN(144, 1, 17, 0x14, 0x70),
+	PIN(145, 1, 0, 0x14, 0x70),
+	PIN(146, 1, 1, 0x14, 0x70),
+	PIN(147, 1, 2, 0x14, 0x70),
+	PIN(148, 1, 3, 0x14, 0x70),
+	PIN(149, 1, 4, 0x14, 0x70),
+	PIN(150, 1, 5, 0x14, 0x70),
+	PIN(151, 1, 6, 0x14, 0x70),
+	PIN(152, 1, 7, 0x14, 0x70),
+	PIN(153, 1, 9, 0x14, 0x70),
+	PIN(154, 1, 8, 0x14, 0x70),
+	PIN(155, 1, 18, 0x14, 0x70),
+	PIN(156, 1, 19, 0x14, 0x70),
+	PIN(157, 0, 1, 0x12, 0x80),
+	PIN(158, 0, 2, 0x12, 0x80),
+	PIN(159, 0, 0, 0x12, 0x80),
+	PIN(160, 0, 22, 0x13, 0x80),
+	PIN(161, 0, 20, 0x13, 0x80),
+	PIN(162, 0, 23, 0x13, 0x80),
+	PIN(163, 0, 21, 0x13, 0x80),
+	PIN(164, 0, 12, 0x13, 0x80),
+	PIN(165, 0, 14, 0x13, 0x80),
+	PIN(166, 0, 13, 0x13, 0x80),
+	PIN(167, 0, 15, 0x13, 0x80),
+	PIN(168, 0, 16, 0x13, 0x80),
+	PIN(169, 0, 17, 0x13, 0x80),
+	PIN(170, 0, 19, 0x13, 0x80),
+	PIN(171, 0, 18, 0x13, 0x80),
+	PIN(172, 0, 10, 0x13, 0x80),
+	PIN(173, 0, 11, 0x13, 0x80),
+	PIN(174, 0, 15, 0x11, 0x80),
+	PIN(175, 0, 16, 0x11, 0x80),
+	PIN(176, 0, 17, 0x11, 0x80),
+	PIN(177, 0, 18, 0x11, 0x80),
+	PIN(178, 0, 6, 0x11, 0x80),
+	PIN(179, 0, 7, 0x11, 0x80),
+	PIN(180, 0, 0, 0x11, 0x80),
+	PIN(181, 0, 1, 0x11, 0x80),
+	PIN(182, 0, 2, 0x11, 0x80),
+	PIN(183, 0, 3, 0x11, 0x80),
+	PIN(184, 0, 4, 0x11, 0x80),
+	PIN(185, 0, 5, 0x11, 0x80),
+	PIN(186, 0, 4, 0x1d, 0xc0),
+	PIN(187, 0, 5, 0x1d, 0xc0),
+	PIN(188, 0, 12, 0x1d, 0xc0),
+	PIN(189, 0, 17, 0x1d, 0xc0),
+	PIN(190, 0, 13, 0x1d, 0xc0),
+	PIN(191, 0, 18, 0x1d, 0xc0),
+	PIN(192, 0, 0, 0x1d, 0xc0),
+	PIN(193, 0, 6, 0x1d, 0xc0),
+	PIN(194, 0, 14, 0x1d, 0xc0),
+	PIN(195, 0, 19, 0x1d, 0xc0),
+	PIN(196, 0, 1, 0x1d, 0xc0),
+	PIN(197, 0, 7, 0x1d, 0xc0),
+	PIN(198, 0, 15, 0x1d, 0xc0),
+	PIN(199, 0, 20, 0x1d, 0xc0),
+	PIN(200, 0, 22, 0x1d, 0xc0),
+	PIN(201, 0, 25, 0x1d, 0xc0),
+	PIN(202, 0, 16, 0x1d, 0xc0),
+	PIN(203, 0, 21, 0x1d, 0xc0),
+	PIN(204, 0, 2, 0x1d, 0xc0),
+	PIN(205, 0, 3, 0x1d, 0xc0),
+	PIN(206, 0, 8, 0x1d, 0xc0),
+	PIN(207, 0, 9, 0x1d, 0xc0),
+	PIN(208, 0, 10, 0x1d, 0xc0),
+	PIN(209, 0, 11, 0x1d, 0xc0),
+	PIN(210, 0, 0, 0x2e, 0x90),
+	PIN(211, 0, 1, 0x2e, 0x90),
+	PIN(212, 0, 2, 0x2e, 0x90),
+	PIN(213, 0, 3, 0x2e, 0x90),
+	PIN(214, 0, 23, 0x1d, 0xc0),
+	PIN(215, 0, 24, 0x1d, 0xc0),
+	PIN(216, 0, 4, 0x2e, 0x90),
+	PIN(217, 1, 1, 0x2e, 0xa0),
+	PIN(218, 1, 2, 0x2e, 0xa0),
+	PIN(219, 1, 0, 0x2e, 0xa0),
+	PIN(220, 0, 5, 0x2e, 0x90),
+	PIN(221, 0, 6, 0x2e, 0x90),
+	PIN(222, 0, 8, 0x2e, 0x90),
+	PIN(223, 0, 7, 0x2e, 0x90),
+	PIN(224, 1, 3, 0x2e, 0xa0),
+	PIN(225, 1, 4, 0x2e, 0xa0),
+	PIN(226, 1, 5, 0x2e, 0xa0),
+	PIN(227, 1, 6, 0x2e, 0xa0),
+	PIN(228, 1, 7, 0x2e, 0xa0),
+	PIN(229, 1, 8, 0x2e, 0xa0),
+	PIN(230, 0, 13, 0x2f, 0x70),
+	PIN(231, 0, 14, 0x2f, 0x70),
+	PIN(232, 0, 10, 0x2f, 0x70),
+	PIN(233, 0, 0, 0x2f, 0x70),
+	PIN(234, 0, 3, 0x2f, 0x70),
+	PIN(235, 0, 1, 0x2f, 0x70),
+	PIN(236, 0, 2, 0x2f, 0x70),
+	PIN(237, 0, 6, 0x2f, 0x70),
+	PIN(238, 0, 5, 0x2f, 0x70),
+	PIN(239, 0, 19, 0x2f, 0x70),
+	PIN(240, 0, 18, 0x2f, 0x70),
+	PIN(241, 0, 16, 0x2f, 0x70),
+	PIN(242, 0, 17, 0x2f, 0x70),
+	PIN(243, 0, 15, 0x2f, 0x70),
+	PIN(244, 0, 12, 0x2f, 0x70),
+	PIN(245, 0, 9, 0x2f, 0x70),
+	PIN(246, 0, 8, 0x2f, 0x70),
+	PIN(247, 0, 7, 0x2f, 0x70),
+	PIN(248, 0, 4, 0x2f, 0x70),
+	PIN(249, 0, 20, 0x2f, 0x70),
+	PIN(250, 0, 11, 0x2f, 0x70),
+	PIN(251, 0, 2, 0x13, 0x80),
+	PIN(252, 0, 3, 0x13, 0x80),
+	PIN(253, 0, 4, 0x13, 0x80),
+	PIN(254, 0, 5, 0x13, 0x80),
+	PIN(255, 0, 6, 0x13, 0x80),
+	PIN(256, 0, 7, 0x13, 0x80),
+	PIN(257, 0, 8, 0x13, 0x80),
+	PIN(258, 0, 9, 0x13, 0x80),
+	PIN(259, 1, 9, 0x2e, 0xa0),
+	PIN(260, 1, 10, 0x2e, 0xa0),
+	PIN(261, 1, 11, 0x2e, 0xa0),
+	PIN(262, 1, 12, 0x2e, 0xa0),
+	PIN(263, 1, 13, 0x2e, 0xa0),
+	PIN(264, 1, 14, 0x2e, 0xa0),
+	PIN(265, 1, 15, 0x2e, 0xa0),
+	PIN(266, 1, 16, 0x2e, 0xa0),
+	PIN(267, 1, 2, 0x2f, 0x80),
+	PIN(268, 1, 3, 0x2f, 0x80),
+	PIN(269, 1, 0, 0x2f, 0x80),
+	PIN(270, 1, 1, 0x2f, 0x80),
+};
+
+#endif /* MT_GPIO_H */
diff --git a/plat/mediatek/mt8196/include/platform_def.h b/plat/mediatek/mt8196/include/platform_def.h
index 66c7cf8..5b45d92 100644
--- a/plat/mediatek/mt8196/include/platform_def.h
+++ b/plat/mediatek/mt8196/include/platform_def.h
@@ -36,6 +36,28 @@
 #define SPM_BASE		(IO_PHYS + 0x0C004000)
 
 /*******************************************************************************
+ * GPIO related constants
+ ******************************************************************************/
+#define GPIO_BASE		(IO_PHYS + 0x0002D000)
+#define RGU_BASE		(IO_PHYS + 0x0C00B000)
+#define DRM_BASE		(IO_PHYS + 0x0000D000)
+#define IOCFG_RT_BASE		(IO_PHYS + 0x02000000)
+#define IOCFG_RM1_BASE		(IO_PHYS + 0x02020000)
+#define IOCFG_RM2_BASE		(IO_PHYS + 0x02040000)
+#define IOCFG_RB_BASE		(IO_PHYS + 0x02060000)
+#define IOCFG_BM1_BASE		(IO_PHYS + 0x02820000)
+#define IOCFG_BM2_BASE		(IO_PHYS + 0x02840000)
+#define IOCFG_BM3_BASE		(IO_PHYS + 0x02860000)
+#define IOCFG_LT_BASE		(IO_PHYS + 0x03000000)
+#define IOCFG_LM1_BASE		(IO_PHYS + 0x03020000)
+#define IOCFG_LM2_BASE		(IO_PHYS + 0x03040000)
+#define IOCFG_LB1_BASE		(IO_PHYS + 0x030f0000)
+#define IOCFG_LB2_BASE		(IO_PHYS + 0x03110000)
+#define IOCFG_TM1_BASE		(IO_PHYS + 0x03800000)
+#define IOCFG_TM2_BASE		(IO_PHYS + 0x03820000)
+#define IOCFG_TM3_BASE		(IO_PHYS + 0x03860000)
+
+/*******************************************************************************
  * UART related constants
  ******************************************************************************/
 #define UART0_BASE	(IO_PHYS + 0x06000000)
diff --git a/plat/mediatek/mt8196/platform.mk b/plat/mediatek/mt8196/platform.mk
index cd428b2..fede717 100644
--- a/plat/mediatek/mt8196/platform.mk
+++ b/plat/mediatek/mt8196/platform.mk
@@ -14,9 +14,11 @@
 include lib/xlat_tables_v2/xlat_tables.mk
 
 PLAT_INCLUDES := -I${MTK_PLAT}/common \
+                 -I${MTK_PLAT}/drivers/gpio/ \
 		 -I${MTK_PLAT}/include \
 		 -I${MTK_PLAT}/include/${ARCH_VERSION} \
 		 -I${MTK_PLAT} \
+		 -I${MTK_PLAT_SOC}/drivers/gpio/ \
 		 -I${MTK_PLAT_SOC}/include \
 		 -Idrivers/arm/gic \
 
@@ -34,6 +36,7 @@
 
 BL31_SOURCES += drivers/delay_timer/delay_timer.c \
 		drivers/delay_timer/generic_delay_timer.c \
+		drivers/gpio/gpio.c \
 		lib/cpus/aarch64/cortex_a720.S	\
 		lib/cpus/aarch64/cortex_x4.S	\
 		lib/cpus/aarch64/cortex_x925.S \
@@ -44,6 +47,8 @@
 		plat/common/aarch64/crash_console_helpers.S \
 		${MTK_PLAT}/common/mtk_plat_common.c \
 		${MTK_PLAT}/common/params_setup.c \
+                ${MTK_PLAT}/drivers/gpio/mtgpio_common.c \
+                $(MTK_PLAT)/$(MTK_SOC)/drivers/gpio/mtgpio.c \
 		$(MTK_PLAT)/$(MTK_SOC)/plat_mmap.c
 
 include plat/mediatek/build_helpers/mtk_build_helpers_epilogue.mk