[RAMEN9610-10736][COMMON] soc: samsungs: Add a SLEEP_GPIO driver
authorSoomin Kim <sm8326.kim@samsung.com>
Fri, 6 Jul 2018 01:55:26 +0000 (10:55 +0900)
committerlingsen1 <lingsen1@lenovo.com>
Sun, 7 Feb 2021 09:36:54 +0000 (17:36 +0800)
This driver gets GPIOs have proper setting value of
CON_PDN, PUD_PDN SRFs. Also, if there is no these
SFRs, it controls CON, PUD value before entering
and after exiting suspend.

Change-Id: I1ac9ec3e2babe0dd0eef94fbd353f1d56fd6b799
Signed-off-by: Soomin Kim <sm8326.kim@samsung.com>
Conflicts:
drivers/soc/samsung/Makefile

arch/arm64/boot/dts/exynos/exynos9610_gpio_config_macros.dtsi [new file with mode: 0644]
drivers/soc/samsung/Kconfig
drivers/soc/samsung/Makefile
drivers/soc/samsung/exynos-sleepgpio.c [new file with mode: 0644]

diff --git a/arch/arm64/boot/dts/exynos/exynos9610_gpio_config_macros.dtsi b/arch/arm64/boot/dts/exynos/exynos9610_gpio_config_macros.dtsi
new file mode 100644 (file)
index 0000000..aba0fb5
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *             http://www.samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#define PIN_PULL_DIS                           0
+#define PIN_PULL_DOWN                          1
+#define PIN_PULL_UP                                    3
+
+#define PIN_DRV_LV1                                    0x0
+#define PIN_DRV_LV2                                    0x1
+#define PIN_DRV_LV3                                    0x2
+#define PIN_DRV_LV4                                    0x3
+#define PIN_DRV_LV5                                    0x4
+#define PIN_DRV_LV6                                    0x5
+#define PIN_DRV_SLOW_LV1                       0x8
+#define PIN_DRV_SLOW_LV2                       0x9
+#define PIN_DRV_SLOW_LV3                       0xA
+#define PIN_DRV_SLOW_LV4                       0xB
+#define PIN_DRV_SLOW_LV5                       0xC
+#define PIN_DRV_SLOW_LV6                       0xF
+
+#define PIN_PDN_OUT0                           0
+#define PIN_PDN_OUT1                           1
+#define PIN_PDN_IN                                     2
+#define PIN_PDN_PREV                           3
+
+#define PIN_IN(_pin, _pull, _drv)                              \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                                   \
+               samsung,pin-function = <0>;                             \
+               samsung,pin-pud = <PIN_PULL_##_pull>;   \
+               samsung,pin-drv = <PIN_DRV_##_drv>;             \
+       }
+
+#define PIN_OUT(_pin, _drv)                                            \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                                   \
+               samsung,pin-function = <1>;                             \
+               samsung,pin-pud = <0>;                                  \
+               samsung,pin-drv = <PIN_DRV_##_drv>;             \
+       }
+
+#define PIN_PUD(_pin, _pud)                                            \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                   \
+               samsung,pin-pud = <PIN_PULL_##_pud>;    \
+       }
+
+#define PIN_IN_PUD(_pin, _pud)                                 \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                                   \
+               samsung,pin-function = <0>;                             \
+               samsung,pin-pud = <PIN_PULL_ ##_pud>;   \
+       }
+
+#define PIN_FUNC_PUD(_pin, _pud)                               \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                                   \
+               samsung,pin-function = <2>;                             \
+               samsung,pin-pud = <PIN_PULL_ ##_pud>;   \
+       }
+
+#define PIN_EINT_PUD(_pin, _pud)                               \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                                   \
+               samsung,pin-function = <0xf>;                   \
+               samsung,pin-pud = <PIN_PULL_ ##_pud>;   \
+       }
+
+#define PIN_OUT_SET(_pin, _val, _drv)                  \
+       _pin {                                                                          \
+               samsung,pins = #_pin;                                   \
+               samsung,pin-function = <1>;                             \
+               samsung,pin-pud = <0>;                                  \
+               samsung,pin-drv = <PIN_DRV_##_drv>;             \
+               samsung,pin-val = <_val>;                               \
+       }
+
+#define PIN_SLP(_pin, _mode, _pull)                                    \
+       _pin {                                                                                  \
+               samsung,pins = #_pin;                                           \
+               samsung,pin-con-pdn = <PIN_PDN_##_mode>;        \
+               samsung,pin-pud-pdn = <PIN_PULL_##_pull>;       \
+       }
index 636eeda6dd0ec11cdf14956b35e17b3af71f1df0..74cab9a239de5645cf621edbfbf397245924e0fb 100644 (file)
@@ -113,6 +113,10 @@ config ECT_DUMP
        default n
        depends on ECT
 
+config EXYNOS_SLEEP_GPIO
+       bool "Enable GPIO sleep function"
+       default n
+
 config EXYNOS_RGT
        bool "Exynos Regulator Debug Support"
        depends on REGULATOR
index b523187b1239266efe619c9b0dd7d93d44ec978f..a9c8df5cb1ecb0c05d8c8b87c98d7bbc3ebdca7a 100644 (file)
@@ -80,3 +80,6 @@ obj-$(CONFIG_MMI_SOC_INFO) += mmi_soc_info.o
 obj-$(CONFIG_MMI_RAM_INFO) += mmi-ram-info.o
 obj-$(CONFIG_MMI_STORAGE_INFO) += mmi_storage_info.o
 obj-$(CONFIG_MMI_UNIT_INFO) += mmi-unit-info.o
+
+# SLEEP GPIO
+obj-$(CONFIG_EXYNOS_SLEEP_GPIO)    += exynos-sleepgpio.o
diff --git a/drivers/soc/samsung/exynos-sleepgpio.c b/drivers/soc/samsung/exynos-sleepgpio.c
new file mode 100644 (file)
index 0000000..2ca208c
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * drivers/soc/samsung/exynos-sleepgpio.c
+ *
+ * The driver for setting exynos gpio configuration
+ *
+ * Copyright (C) 2018, Samsung Electronics.
+ *
+ * This program is free software. You can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+
+//int is_set_pdn_conf;
+
+#ifdef CONFIG_OF
+static const struct of_device_id exynos_sleepgpio_dt_match[] = {
+       {.compatible = "samsung,exynos-sleepgpio",
+     .data = NULL },
+       {},
+};
+MODULE_DEVICE_TABLE(of, exynos_gpio_dt_match);
+#endif
+
+//#if 0
+#ifdef CONFIG_PM_SLEEP
+static int exynos_sleepgpio_suspend(struct device *dev)
+{
+       struct pinctrl *pinctrl;
+
+       pinctrl = pinctrl_get_select(dev, PINCTRL_STATE_SLEEP);
+       if (IS_ERR(pinctrl)) {
+               pr_err("%s: Do not have sleep pinctrl state\n", __func__);
+               return IS_ERR(pinctrl);
+       }
+
+       dev_info(dev, "Set sleep gpio \n");
+
+       return 0;
+}
+
+static int exynos_sleepgpio_resume(struct device *dev)
+{
+       struct pinctrl *pinctrl = pinctrl_get(dev);
+
+       pinctrl = devm_pinctrl_get_select(dev, PINCTRL_STATE_DEFAULT);
+       if (IS_ERR(pinctrl))
+               pr_err("%s: Do not have default pinctrl state.\n", __func__);
+
+       dev_info(dev, "Release sleep gpio \n");
+
+       return 0;
+}
+
+const struct dev_pm_ops exynos_sleepgpio_pm_ops = {
+       SET_LATE_SYSTEM_SLEEP_PM_OPS(
+                       exynos_sleepgpio_suspend,
+                       exynos_sleepgpio_resume)
+};
+#endif
+
+static int exynos_sleepgpio_probe(struct platform_device *pdev)
+{
+       pr_info("%s: Exynos sleepgpio driver probe is done.\n", __func__);
+       return 0;
+}
+
+static int exynos_sleepgpio_remove(struct platform_device *pdev)
+{
+       return 0;
+}
+
+static struct platform_driver exynos_sleepgpio = {
+       .driver = {
+               .name   = "exynos_sleepgpio",
+               .owner  = THIS_MODULE,
+#ifdef CONFIG_OF
+               .of_match_table = of_match_ptr(exynos_sleepgpio_dt_match),
+#endif
+#ifdef CONFIG_PM_SLEEP
+               .pm             = &exynos_sleepgpio_pm_ops,
+#endif
+       },
+       .probe = exynos_sleepgpio_probe,
+       .remove = exynos_sleepgpio_remove,
+};
+
+module_platform_driver(exynos_sleepgpio);
+
+MODULE_AUTHOR("soomin.kim@samsung.com");
+MODULE_DESCRIPTION("GPIO setting driver for exynos");
+MODULE_LICENSE("GPL");