From: Soomin Kim Date: Fri, 6 Jul 2018 01:55:26 +0000 (+0900) Subject: [RAMEN9610-10736][COMMON] soc: samsungs: Add a SLEEP_GPIO driver X-Git-Tag: MMI-QSAS30.62-33-3~276 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fdfefdb5f1a159828e90a52e85396e4149872491;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git [RAMEN9610-10736][COMMON] soc: samsungs: Add a SLEEP_GPIO driver 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 Conflicts: drivers/soc/samsung/Makefile --- 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 index 000000000000..aba0fb5d64ce --- /dev/null +++ b/arch/arm64/boot/dts/exynos/exynos9610_gpio_config_macros.dtsi @@ -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 = ; \ + samsung,pin-drv = ; \ + } + +#define PIN_OUT(_pin, _drv) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-function = <1>; \ + samsung,pin-pud = <0>; \ + samsung,pin-drv = ; \ + } + +#define PIN_PUD(_pin, _pud) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-pud = ; \ + } + +#define PIN_IN_PUD(_pin, _pud) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-function = <0>; \ + samsung,pin-pud = ; \ + } + +#define PIN_FUNC_PUD(_pin, _pud) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-function = <2>; \ + samsung,pin-pud = ; \ + } + +#define PIN_EINT_PUD(_pin, _pud) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-function = <0xf>; \ + samsung,pin-pud = ; \ + } + +#define PIN_OUT_SET(_pin, _val, _drv) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-function = <1>; \ + samsung,pin-pud = <0>; \ + samsung,pin-drv = ; \ + samsung,pin-val = <_val>; \ + } + +#define PIN_SLP(_pin, _mode, _pull) \ + _pin { \ + samsung,pins = #_pin; \ + samsung,pin-con-pdn = ; \ + samsung,pin-pud-pdn = ; \ + } diff --git a/drivers/soc/samsung/Kconfig b/drivers/soc/samsung/Kconfig index 636eeda6dd0e..74cab9a239de 100644 --- a/drivers/soc/samsung/Kconfig +++ b/drivers/soc/samsung/Kconfig @@ -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 diff --git a/drivers/soc/samsung/Makefile b/drivers/soc/samsung/Makefile index b523187b1239..a9c8df5cb1ec 100644 --- a/drivers/soc/samsung/Makefile +++ b/drivers/soc/samsung/Makefile @@ -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 index 000000000000..2ca208ca2768 --- /dev/null +++ b/drivers/soc/samsung/exynos-sleepgpio.c @@ -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 +#include +#include +#include + +//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");