Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 124ec093 authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

ASoC: msm-cdc-pinctrl: Add support to control wakeup capable gpios



Some clock and data gpios are also treated as wakeup source capable
interrupts. Add support to control the wakeup capability based on
the usecase.

Change-Id: I32a12f004afbf04f82e40be62747b0af8836be82
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent d6bd9f3a
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/qcom-pinctrl.h>
#include <asoc/msm-cdc-pinctrl.h>

struct msm_cdc_pinctrl_info {
@@ -19,6 +20,8 @@ struct msm_cdc_pinctrl_info {
	struct pinctrl_state *pinctrl_sleep;
	int gpio;
	bool state;
	u32 tlmm_gpio;
	bool wakeup_capable;
};

static struct msm_cdc_pinctrl_info *msm_cdc_pinctrl_get_gpiodata(
@@ -137,10 +140,34 @@ int msm_cdc_pinctrl_get_state(struct device_node *np)
}
EXPORT_SYMBOL(msm_cdc_pinctrl_get_state);

/*
 * msm_cdc_pinctrl_set_wakeup_capable: Set a pinctrl to wakeup capable
 * @np: pointer to struct device_node
 * @enable: wakeup capable when set to true
 *
 * Returns 0 for success and error code for failure
 */
int msm_cdc_pinctrl_set_wakeup_capable(struct device_node *np, bool enable)
{
	struct msm_cdc_pinctrl_info *gpio_data;
	int ret = 0;

	gpio_data = msm_cdc_pinctrl_get_gpiodata(np);
	if (!gpio_data)
		return -EINVAL;

	if (gpio_data->wakeup_capable)
		ret = msm_gpio_mpm_wake_set(gpio_data->tlmm_gpio, enable);

	return ret;
}
EXPORT_SYMBOL(msm_cdc_pinctrl_set_wakeup_capable);

static int msm_cdc_pinctrl_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct msm_cdc_pinctrl_info *gpio_data;
	u32 tlmm_gpio = 0;

	gpio_data = devm_kzalloc(&pdev->dev,
				 sizeof(struct msm_cdc_pinctrl_info),
@@ -183,6 +210,12 @@ static int msm_cdc_pinctrl_probe(struct platform_device *pdev)
				__func__, ret);
	}

	if (!of_property_read_u32(pdev->dev.of_node, "qcom,tlmm-gpio",
				&tlmm_gpio)) {
		gpio_data->wakeup_capable = true;
		gpio_data->tlmm_gpio = tlmm_gpio;
	}

	gpio_data->gpio = of_get_named_gpio(pdev->dev.of_node,
					    "qcom,cdc-rst-n-gpio", 0);
	if (gpio_is_valid(gpio_data->gpio)) {
+7 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ extern int msm_cdc_pinctrl_select_sleep_state(struct device_node *np);
extern int msm_cdc_pinctrl_select_active_state(struct device_node *np);
extern int msm_cdc_pinctrl_get_state(struct device_node *np);
extern int msm_cdc_get_gpio_state(struct device_node *np);
extern int msm_cdc_pinctrl_set_wakeup_capable(struct device_node *np,
					      bool enable);
int msm_cdc_pinctrl_drv_init(void);
void msm_cdc_pinctrl_drv_exit(void);

@@ -40,6 +42,11 @@ int msm_cdc_pinctrl_get_state(struct device_node *np)
{
	return true;
}
static int msm_cdc_pinctrl_set_wakeup_capable(struct device_node *np,
					      bool enable)
{
	return 0;
}
#endif

#endif