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

Commit 99319e45 authored by Prasad Sodagudi's avatar Prasad Sodagudi
Browse files

pinctrl: qcom: Add syscore system suspend/resume



Add syscore system suspend and resume handlers,
to print gpio interrupts status during device resume.

Change-Id: I7c574d2e44a7e318ac9ef89063d2081bf63c09b6
Signed-off-by: default avatarPrasad Sodagudi <psodagud@codeaurora.org>
parent 22b7c752
Loading
Loading
Loading
Loading
+54 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, Sony Mobile Communications AB.
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -27,6 +27,7 @@
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/syscore_ops.h>
#include <linux/reboot.h>
#include <linux/pm.h>
#include <linux/log2.h>
@@ -70,6 +71,8 @@ struct msm_pinctrl {
	void __iomem *regs;
};

static struct msm_pinctrl *msm_pinctrl_data;

static int msm_get_groups_count(struct pinctrl_dev *pctldev)
{
	struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
@@ -877,6 +880,52 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
		}
}

#ifdef CONFIG_PM
static int msm_pinctrl_suspend(void)
{
	return 0;
}

static void msm_pinctrl_resume(void)
{
	int i, irq;
	u32 val;
	unsigned long flags;
	struct irq_desc *desc;
	const struct msm_pingroup *g;
	const char *name = "null";
	struct msm_pinctrl *pctrl = msm_pinctrl_data;

	if (!msm_show_resume_irq_mask)
		return;

	raw_spin_lock_irqsave(&pctrl->lock, flags);
	for_each_set_bit(i, pctrl->enabled_irqs, pctrl->chip.ngpio) {
		g = &pctrl->soc->groups[i];
		val = readl_relaxed(pctrl->regs + g->intr_status_reg);
		if (val & BIT(g->intr_status_bit)) {
			irq = irq_find_mapping(pctrl->chip.irqdomain, i);
			desc = irq_to_desc(irq);
			if (desc == NULL)
				name = "stray irq";
			else if (desc->action && desc->action->name)
				name = desc->action->name;

			pr_warn("%s: %d triggered %s\n", __func__, irq, name);
		}
	}
	raw_spin_unlock_irqrestore(&pctrl->lock, flags);
}
#else
#define msm_pinctrl_suspend NULL
#define msm_pinctrl_resume NULL
#endif

static struct syscore_ops msm_pinctrl_pm_ops = {
	.suspend = msm_pinctrl_suspend,
	.resume = msm_pinctrl_resume,
};

int msm_pinctrl_probe(struct platform_device *pdev,
		      const struct msm_pinctrl_soc_data *soc_data)
{
@@ -884,7 +933,8 @@ int msm_pinctrl_probe(struct platform_device *pdev,
	struct resource *res;
	int ret;

	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
	msm_pinctrl_data = pctrl = devm_kzalloc(&pdev->dev,
				sizeof(*pctrl), GFP_KERNEL);
	if (!pctrl) {
		dev_err(&pdev->dev, "Can't allocate msm_pinctrl\n");
		return -ENOMEM;
@@ -924,6 +974,7 @@ int msm_pinctrl_probe(struct platform_device *pdev,

	platform_set_drvdata(pdev, pctrl);

	register_syscore_ops(&msm_pinctrl_pm_ops);
	dev_dbg(&pdev->dev, "Probed Qualcomm pinctrl driver\n");

	return 0;
@@ -937,6 +988,7 @@ int msm_pinctrl_remove(struct platform_device *pdev)
	gpiochip_remove(&pctrl->chip);

	unregister_restart_handler(&pctrl->restart_nb);
	unregister_syscore_ops(&msm_pinctrl_pm_ops);

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -121,4 +121,5 @@ int msm_pinctrl_probe(struct platform_device *pdev,
		      const struct msm_pinctrl_soc_data *soc_data);
int msm_pinctrl_remove(struct platform_device *pdev);

extern int msm_show_resume_irq_mask;
#endif