mediatek: mt8183: support system off

- Add PMIC driver
- Add RTC drvier
- Refactor PMIC and RTC to mediatek/common
- Implement system off handler

Change-Id: If76497646ace1b78bc9a5fa0110b652fe512281a
diff --git a/plat/mediatek/mt8183/plat_pm.c b/plat/mediatek/mt8183/plat_pm.c
index fa24e2e..e2aa2b9 100644
--- a/plat/mediatek/mt8183/plat_pm.c
+++ b/plat/mediatek/mt8183/plat_pm.c
@@ -22,6 +22,8 @@
 #include <plat_dcm.h>
 #include <plat_debug.h>
 #include <plat_private.h>
+#include <pmic.h>
+#include <rtc.h>
 
 #define MTK_LOCAL_STATE_OFF     2
 
@@ -115,6 +117,22 @@
 }
 
 /*******************************************************************************
+ * MTK handlers to shutdown/reboot the system
+ ******************************************************************************/
+static void __dead2 plat_mtk_system_off(void)
+{
+	INFO("MTK System Off\n");
+
+	rtc_power_off_sequence();
+	wk_pmic_enable_sdn_delay();
+	pmic_power_off();
+
+	wfi();
+	ERROR("MTK System Off: operation not handled.\n");
+	panic();
+}
+
+/*******************************************************************************
  * MTK_platform handler called when an affinity instance is about to be turned
  * on. The level and mpidr determine the affinity instance.
  ******************************************************************************/
@@ -125,7 +143,7 @@
 	.pwr_domain_off			= plat_mtk_power_domain_off,
 	.pwr_domain_suspend		= NULL,
 	.pwr_domain_suspend_finish	= NULL,
-	.system_off			= NULL,
+	.system_off			= plat_mtk_system_off,
 	.system_reset			= NULL,
 	.validate_power_state		= NULL,
 	.get_sys_suspend_power_state	= NULL,