From: "Michael Niewöhner" <mniewoeh@stud.hs-offenburg.de> To: Heiko Stuebner <heiko@sntech.de> Cc: lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: Re: [PATCH 1/2] regulator: act8865: add restart handler for act8846 Date: Thu, 14 May 2015 21:17:08 +0200 [thread overview] Message-ID: <D1089B7C-607E-48E2-B349-47B80A0596DA@stud.hs-offenburg.de> (raw) In-Reply-To: <2204003.IdqJV6LE2e@phil> I reworked the patch and here it is ;-) The act8846 provides means to reset the system when used as main pmic. This patch adds a restart handler for power cycling the regulator thus resetting the board / soc when system-power-controller in dts is set. This can be useful for example if there is no other means of reset. Signed-off-by: Michael Niewoehner <mniewoeh@stud.hs-offenburg.de> --- diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 2ff73d7..836d10b 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c @@ -27,6 +27,7 @@ #include <linux/of_device.h> #include <linux/regulator/of_regulator.h> #include <linux/regmap.h> +#include <linux/reboot.h> /* * ACT8600 Global Register Map. @@ -133,6 +134,8 @@ #define ACT8865_VOLTAGE_NUM 64 #define ACT8600_SUDCDC_VOLTAGE_NUM 255 +#define ACT8846_SIPC_MASK 0x01 + struct act8865 { struct regmap *regmap; int off_reg; @@ -402,6 +405,22 @@ static void act8865_power_off(void) while (1); } +static int act8846_power_cycle(struct notifier_block *this, + unsigned long code, void *unused) +{ + struct act8865 *act8846; + + act8846 = i2c_get_clientdata(act8865_i2c_client); + regmap_write(act8846->regmap, ACT8846_GLB_OFF_CTRL, ACT8846_SIPC_MASK); + + return NOTIFY_DONE; +} + +static struct notifier_block act8846_restart_handler = { + .notifier_call = act8846_power_cycle, + .priority = 129, +}; + static int act8865_pmic_probe(struct i2c_client *client, const struct i2c_device_id *i2c_id) { @@ -484,6 +503,8 @@ static int act8865_pmic_probe(struct i2c_client *client, } if (of_device_is_system_power_controller(dev->of_node)) { + int ret; + if (!pm_power_off && (off_reg > 0)) { act8865_i2c_client = client; act8865->off_reg = off_reg; @@ -492,6 +513,14 @@ static int act8865_pmic_probe(struct i2c_client *client, } else { dev_err(dev, "Failed to set poweroff capability, already defined\n"); } + + if (type == ACT8846) { + act8865_i2c_client = client; + ret = register_restart_handler(&act8846_restart_handler); + if (ret) + pr_err("%s: cannot register restart handler, %d\n", + __func__, ret); + } } /* Finally register devices */
WARNING: multiple messages have this Message-ID (diff)
From: mniewoeh@stud.hs-offenburg.de (Michael Niewöhner) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] regulator: act8865: add restart handler for act8846 Date: Thu, 14 May 2015 21:17:08 +0200 [thread overview] Message-ID: <D1089B7C-607E-48E2-B349-47B80A0596DA@stud.hs-offenburg.de> (raw) In-Reply-To: <2204003.IdqJV6LE2e@phil> I reworked the patch and here it is ;-) The act8846 provides means to reset the system when used as main pmic. This patch adds a restart handler for power cycling the regulator thus resetting the board / soc when system-power-controller in dts is set. This can be useful for example if there is no other means of reset. Signed-off-by: Michael Niewoehner <mniewoeh@stud.hs-offenburg.de> --- diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 2ff73d7..836d10b 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c @@ -27,6 +27,7 @@ #include <linux/of_device.h> #include <linux/regulator/of_regulator.h> #include <linux/regmap.h> +#include <linux/reboot.h> /* * ACT8600 Global Register Map. @@ -133,6 +134,8 @@ #define ACT8865_VOLTAGE_NUM 64 #define ACT8600_SUDCDC_VOLTAGE_NUM 255 +#define ACT8846_SIPC_MASK 0x01 + struct act8865 { struct regmap *regmap; int off_reg; @@ -402,6 +405,22 @@ static void act8865_power_off(void) while (1); } +static int act8846_power_cycle(struct notifier_block *this, + unsigned long code, void *unused) +{ + struct act8865 *act8846; + + act8846 = i2c_get_clientdata(act8865_i2c_client); + regmap_write(act8846->regmap, ACT8846_GLB_OFF_CTRL, ACT8846_SIPC_MASK); + + return NOTIFY_DONE; +} + +static struct notifier_block act8846_restart_handler = { + .notifier_call = act8846_power_cycle, + .priority = 129, +}; + static int act8865_pmic_probe(struct i2c_client *client, const struct i2c_device_id *i2c_id) { @@ -484,6 +503,8 @@ static int act8865_pmic_probe(struct i2c_client *client, } if (of_device_is_system_power_controller(dev->of_node)) { + int ret; + if (!pm_power_off && (off_reg > 0)) { act8865_i2c_client = client; act8865->off_reg = off_reg; @@ -492,6 +513,14 @@ static int act8865_pmic_probe(struct i2c_client *client, } else { dev_err(dev, "Failed to set poweroff capability, already defined\n"); } + + if (type == ACT8846) { + act8865_i2c_client = client; + ret = register_restart_handler(&act8846_restart_handler); + if (ret) + pr_err("%s: cannot register restart handler, %d\n", + __func__, ret); + } } /* Finally register devices */
next prev parent reply other threads:[~2015-05-14 19:17 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-05-11 20:54 [PATCH 1/2] regulator: act8865: add restart handler for act8846 Michael Niewöhner 2015-05-11 20:54 ` Michael Niewöhner 2015-05-11 20:54 ` Michael Niewöhner 2015-05-12 20:22 ` Heiko Stuebner 2015-05-12 20:22 ` Heiko Stuebner 2015-05-12 20:34 ` Michael Niewöhner 2015-05-12 20:34 ` Michael Niewöhner 2015-05-14 19:17 ` Michael Niewöhner [this message] 2015-05-14 19:17 ` Michael Niewöhner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=D1089B7C-607E-48E2-B349-47B80A0596DA@stud.hs-offenburg.de \ --to=mniewoeh@stud.hs-offenburg.de \ --cc=broonie@kernel.org \ --cc=heiko@sntech.de \ --cc=lgirdwood@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-rockchip@lists.infradead.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.