mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-27 15:36:48 +00:00
pinctrl: qcom: use restart_notifier mechanism for ps_hold
By converting to the restart_notifier mechanism for restart, we allow for other mechanisms, like the watchdog, to be used for restart in the case where PS_HOLD has failed to reset the chip. Since this mechanism may be one of several mechanisms registered, change the post-ps_hold write timeout to be a more reasonable 1 second instead of 10 seconds. Choose priority 128, as according to documentation, this mechanism "is sufficient to restart the entire system". Tested-by: Pramod Gurav <pramod.gurav@smartplayin.com> Signed-off-by: Josh Cartwright <joshc@codeaurora.org> Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
0a332c96c2
commit
cf1fc18762
@ -27,8 +27,7 @@
|
|||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/reboot.h>
|
||||||
#include <asm/system_misc.h>
|
|
||||||
|
|
||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../pinconf.h"
|
#include "../pinconf.h"
|
||||||
@ -43,6 +42,7 @@
|
|||||||
* @dev: device handle.
|
* @dev: device handle.
|
||||||
* @pctrl: pinctrl handle.
|
* @pctrl: pinctrl handle.
|
||||||
* @chip: gpiochip handle.
|
* @chip: gpiochip handle.
|
||||||
|
* @restart_nb: restart notifier block.
|
||||||
* @irq: parent irq for the TLMM irq_chip.
|
* @irq: parent irq for the TLMM irq_chip.
|
||||||
* @lock: Spinlock to protect register resources as well
|
* @lock: Spinlock to protect register resources as well
|
||||||
* as msm_pinctrl data structures.
|
* as msm_pinctrl data structures.
|
||||||
@ -56,6 +56,7 @@ struct msm_pinctrl {
|
|||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct pinctrl_dev *pctrl;
|
struct pinctrl_dev *pctrl;
|
||||||
struct gpio_chip chip;
|
struct gpio_chip chip;
|
||||||
|
struct notifier_block restart_nb;
|
||||||
int irq;
|
int irq;
|
||||||
|
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
@ -852,13 +853,14 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARM
|
static int msm_ps_hold_restart(struct notifier_block *nb, unsigned long action,
|
||||||
static void __iomem *msm_ps_hold;
|
void *data)
|
||||||
|
|
||||||
static void msm_reset(enum reboot_mode reboot_mode, const char *cmd)
|
|
||||||
{
|
{
|
||||||
writel(0, msm_ps_hold);
|
struct msm_pinctrl *pctrl = container_of(nb, struct msm_pinctrl, restart_nb);
|
||||||
mdelay(10000);
|
|
||||||
|
writel(0, pctrl->regs + PS_HOLD_OFFSET);
|
||||||
|
mdelay(1000);
|
||||||
|
return NOTIFY_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
|
static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
|
||||||
@ -868,13 +870,14 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
|
|||||||
|
|
||||||
for (; i <= pctrl->soc->nfunctions; i++)
|
for (; i <= pctrl->soc->nfunctions; i++)
|
||||||
if (!strcmp(func[i].name, "ps_hold")) {
|
if (!strcmp(func[i].name, "ps_hold")) {
|
||||||
msm_ps_hold = pctrl->regs + PS_HOLD_OFFSET;
|
pctrl->restart_nb.notifier_call = msm_ps_hold_restart;
|
||||||
arm_pm_restart = msm_reset;
|
pctrl->restart_nb.priority = 128;
|
||||||
|
if (register_restart_handler(&pctrl->restart_nb))
|
||||||
|
dev_err(pctrl->dev,
|
||||||
|
"failed to setup restart handler.\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static void msm_pinctrl_setup_pm_reset(const struct msm_pinctrl *pctrl) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int msm_pinctrl_probe(struct platform_device *pdev,
|
int msm_pinctrl_probe(struct platform_device *pdev,
|
||||||
const struct msm_pinctrl_soc_data *soc_data)
|
const struct msm_pinctrl_soc_data *soc_data)
|
||||||
@ -943,6 +946,8 @@ int msm_pinctrl_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
pinctrl_unregister(pctrl->pctrl);
|
pinctrl_unregister(pctrl->pctrl);
|
||||||
|
|
||||||
|
unregister_restart_handler(&pctrl->restart_nb);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(msm_pinctrl_remove);
|
EXPORT_SYMBOL(msm_pinctrl_remove);
|
||||||
|
Loading…
Reference in New Issue
Block a user