diff mbox

[v3,4/4] pinctrl: qcom: Add support for reset for apq8064

Message ID 1409322659-17693-5-git-send-email-pramod.gurav@smartplayin.com (mailing list archive)
State New, archived
Headers show

Commit Message

Pramod Gurav Aug. 29, 2014, 2:30 p.m. UTC
This patch adds support for reset functions to reboot the boards
with soc apq8064.

CC: Linus Walleij <linus.walleij@linaro.org>
CC: Bjorn Andersson <bjorn.andersson@sonymobile.com>
CC: "Ivan T. Ivanov" <iivanov@mm-sol.com>
CC: Stephen Boyd <sboyd@codeaurora.org>
CC: Andy Gross <agross@codeaurora.org>
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
 drivers/pinctrl/qcom/pinctrl-apq8064.c |    7 ++++++-
 drivers/pinctrl/qcom/pinctrl-msm.c     |   30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletions(-)

Comments

Bjorn Andersson Aug. 29, 2014, 6:42 p.m. UTC | #1
On Fri 29 Aug 07:30 PDT 2014, Pramod Gurav wrote:

> This patch adds support for reset functions to reboot the boards
> with soc apq8064.
> 
> CC: Linus Walleij <linus.walleij@linaro.org>
> CC: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> CC: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> CC: Stephen Boyd <sboyd@codeaurora.org>
> CC: Andy Gross <agross@codeaurora.org>
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

Thanks for the rework, that was fast :)

Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Pramod Gurav Aug. 30, 2014, 5:08 a.m. UTC | #2
Bjorn,
Thanks for review. :)

On 30-08-2014 12:12 AM, Bjorn Andersson wrote:
> On Fri 29 Aug 07:30 PDT 2014, Pramod Gurav wrote:
> 
>> This patch adds support for reset functions to reboot the boards
>> with soc apq8064.
>>
>> CC: Linus Walleij <linus.walleij@linaro.org>
>> CC: Bjorn Andersson <bjorn.andersson@sonymobile.com>
>> CC: "Ivan T. Ivanov" <iivanov@mm-sol.com>
>> CC: Stephen Boyd <sboyd@codeaurora.org>
>> CC: Andy Gross <agross@codeaurora.org>
>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> 
> Thanks for the rework, that was fast :)
> 
> Acked-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
>
Linus Walleij Sept. 2, 2014, 12:36 p.m. UTC | #3
On Fri, Aug 29, 2014 at 4:30 PM, Pramod Gurav
<pramod.gurav@smartplayin.com> wrote:

> This patch adds support for reset functions to reboot the boards
> with soc apq8064.
>
> CC: Linus Walleij <linus.walleij@linaro.org>
> CC: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> CC: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> CC: Stephen Boyd <sboyd@codeaurora.org>
> CC: Andy Gross <agross@codeaurora.org>
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

OK patch applied with Björn's ACK.

A bit dirty to have this in this driver, but who cares.

Does the APQ8064 accompanying PMIC also have the ability to
completely shut the system down?

Yours,
Linus Walleij
Bjorn Andersson Sept. 2, 2014, 5:06 p.m. UTC | #4
On Tue 02 Sep 05:36 PDT 2014, Linus Walleij wrote:

> A bit dirty to have this in this driver, but who cares.
> 

Indeed, but we figured the taint was small enough to justify not creating
cross-references to a separate driver.

> Does the APQ8064 accompanying PMIC also have the ability to
> completely shut the system down?
> 

Upon flipping pshold the PMIC will perform either a reset or a shutdown of the
system. Per Stephen's suggestion we can hook the control of this up with a
reboot_notifier in a pmic driver, hence saving ourselves of a reference to (or
from) the PMIC here.

Regards,
Bjorn
Timur Tabi Jan. 14, 2015, 11:38 p.m. UTC | #5
On Fri, Aug 29, 2014 at 9:30 AM, Pramod Gurav
<pramod.gurav@smartplayin.com> wrote:
>
> +static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
> +{
> +       int i = 0;
> +       const struct msm_function *func = pctrl->soc->functions;
> +
> +       for (; i <= pctrl->soc->nfunctions; i++)

Shouldn't this be

            i < pctrl->soc->nfunctions

As it stands, if nfunctions == 0, this function crashes.
Stephen Boyd Jan. 14, 2015, 11:44 p.m. UTC | #6
On 01/14/2015 03:38 PM, Timur Tabi wrote:
> On Fri, Aug 29, 2014 at 9:30 AM, Pramod Gurav
> <pramod.gurav@smartplayin.com> wrote:
>> +static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
>> +{
>> +       int i = 0;
>> +       const struct msm_function *func = pctrl->soc->functions;
>> +
>> +       for (; i <= pctrl->soc->nfunctions; i++)
> Shouldn't this be
>
>             i < pctrl->soc->nfunctions
>
> As it stands, if nfunctions == 0, this function crashes.
>

I think so. Can you send a patch? Plus it would be nice to move i = 0 in
the for loop at the same time.
Timur Tabi Jan. 14, 2015, 11:54 p.m. UTC | #7
On Wed, Jan 14, 2015 at 5:44 PM, Stephen Boyd <sboyd@codeaurora.org> wrote:
>
> I think so. Can you send a patch? Plus it would be nice to move i = 0 in
> the for loop at the same time.

Sadly, Qualcomm policy makes that very cumbersome for me.  I won't be
able to send a patch any time soon.
diff mbox

Patch

diff --git a/drivers/pinctrl/qcom/pinctrl-apq8064.c b/drivers/pinctrl/qcom/pinctrl-apq8064.c
index feb6f15..ef1263c 100644
--- a/drivers/pinctrl/qcom/pinctrl-apq8064.c
+++ b/drivers/pinctrl/qcom/pinctrl-apq8064.c
@@ -324,6 +324,7 @@  enum apq8064_functions {
 	APQ_MUX_tsif1,
 	APQ_MUX_tsif2,
 	APQ_MUX_usb2_hsic,
+	APQ_MUX_ps_hold,
 	APQ_MUX_NA,
 };
 
@@ -351,6 +352,9 @@  static const char * const gpio_groups[] = {
 	"gpio78", "gpio79", "gpio80", "gpio81", "gpio82", "gpio83", "gpio84",
 	"gpio85", "gpio86", "gpio87", "gpio88", "gpio89"
 };
+static const char * const ps_hold_groups[] = {
+	"gpio78"
+};
 static const char * const gsbi1_groups[] = {
 	"gpio18", "gpio19", "gpio20", "gpio21"
 };
@@ -477,6 +481,7 @@  static const struct msm_function apq8064_functions[] = {
 	FUNCTION(tsif1),
 	FUNCTION(tsif2),
 	FUNCTION(usb2_hsic),
+	FUNCTION(ps_hold),
 };
 
 static const struct msm_pingroup apq8064_groups[] = {
@@ -558,7 +563,7 @@  static const struct msm_pingroup apq8064_groups[] = {
 	PINGROUP(75, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
 	PINGROUP(76, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
 	PINGROUP(77, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
-	PINGROUP(78, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
+	PINGROUP(78, ps_hold, NA, NA, NA, NA, NA, NA, NA, NA, NA),
 	PINGROUP(79, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
 	PINGROUP(80, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
 	PINGROUP(81, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 9175bbc..80a64ca 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -12,6 +12,7 @@ 
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -27,12 +28,15 @@ 
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 
+#include <asm/system_misc.h>
+
 #include "../core.h"
 #include "../pinconf.h"
 #include "pinctrl-msm.h"
 #include "../pinctrl-utils.h"
 
 #define MAX_NR_GPIO 300
+#define PS_HOLD_OFFSET 0x820
 
 /**
  * struct msm_pinctrl - state for a pinctrl-msm device
@@ -850,6 +854,30 @@  static int msm_gpio_init(struct msm_pinctrl *pctrl)
 	return 0;
 }
 
+#ifdef CONFIG_ARM
+static void __iomem *msm_ps_hold;
+
+static void msm_reset(enum reboot_mode reboot_mode, const char *cmd)
+{
+	writel(0, msm_ps_hold);
+	mdelay(10000);
+}
+
+static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
+{
+	int i = 0;
+	const struct msm_function *func = pctrl->soc->functions;
+
+	for (; i <= pctrl->soc->nfunctions; i++)
+		if (!strcmp(func[i].name, "ps_hold")) {
+			msm_ps_hold = pctrl->regs + PS_HOLD_OFFSET;
+			arm_pm_restart = msm_reset;
+		}
+}
+#else
+static void msm_pinctrl_setup_pm_reset(const struct msm_pinctrl *pctrl) {}
+#endif
+
 int msm_pinctrl_probe(struct platform_device *pdev,
 		      const struct msm_pinctrl_soc_data *soc_data)
 {
@@ -873,6 +901,8 @@  int msm_pinctrl_probe(struct platform_device *pdev,
 	if (IS_ERR(pctrl->regs))
 		return PTR_ERR(pctrl->regs);
 
+	msm_pinctrl_setup_pm_reset(pctrl);
+
 	pctrl->irq = platform_get_irq(pdev, 0);
 	if (pctrl->irq < 0) {
 		dev_err(&pdev->dev, "No interrupt defined for msmgpio\n");