da9062: DA9062 driver submission
Subsystems (7)
v2 cover da9062: DA9062 driver submission
From: S Twiss <[email protected]>
This patch set adds support for the Dialog DA9062 Power Management IC.
In this patch set the following is provided:
- [PATCH V2 1/4]: MFD core support
- [PATCH V2 2/4]: BUCK and LDO regulator driver
- [PATCH V2 3/4]: Watchdog driver
- [PATCH V2 4/4]: Add bindings for all DA9062 components
Changes in V2:
- Alter subject title in 'cover letter'
- Reordered the patch numbering: now 4/4 patches instead of 6/6
- Dropped PATCH V1 3/6 RTC driver
- Dropped PATCH V1 4/6 OnKey driver
This patch applies against linux-next and v4.1-rc3
Thank you,
Steve Twiss, Dialog Semiconductor Ltd.
S Twiss (4):
mfd: da9062: DA9062 MFD core driver
regulator: da9062: DA9062 regulator driver
watchdog: da9062: DA9062 watchdog driver
devicetree: da9062: Add bindings for DA9062 driver
Documentation/devicetree/bindings/mfd/da9062.txt | 79 ++ drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 3 +- drivers/mfd/da9062-core.c | 647 +++++++++++++ drivers/regulator/Kconfig | 10 + drivers/regulator/Makefile | 1 + drivers/regulator/da9062-regulator.c | 843 ++++++++++++++++ drivers/watchdog/Kconfig | 9 + drivers/watchdog/Makefile | 1 + drivers/watchdog/da9062_wdt.c | 288 ++++++ include/linux/mfd/da9062/core.h | 62 ++ include/linux/mfd/da9062/registers.h | 1108 ++++++++++++++++++++++ 12 files changed, 3062 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/mfd/da9062.txt create mode 100644 drivers/mfd/da9062-core.c create mode 100644 drivers/regulator/da9062-regulator.c create mode 100644 drivers/watchdog/da9062_wdt.c create mode 100644 include/linux/mfd/da9062/core.h create mode 100644 include/linux/mfd/da9062/registers.h
Signature · 6 lines
end-of-patch for PATCH V2 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/4 mfd: da9062: DA9062 MFD core driver
From: S Twiss <[email protected]>
Add MFD core driver support for DA9062
---
Changes in V2:
- Copyright headers GPL v2 (and later) match correct 'GPL' in MODULE_LICENSE
- Ensure DA9062 core is tristate in Kconfig so it can be built as a module
- Move VDD_WARN code and resource into the core instead of regulator driver
This patch applies against linux-next and v4.1-rc3
drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 3 +- drivers/mfd/da9062-core.c | 647 ++++++++++++++++++++ include/linux/mfd/da9062/core.h | 62 ++ include/linux/mfd/da9062/registers.h | 1108 ++++++++++++++++++++++++++++++++++ 5 files changed, 1831 insertions(+), 1 deletion(-) create mode 100644 drivers/mfd/da9062-core.c create mode 100644 include/linux/mfd/da9062/core.h create mode 100644 include/linux/mfd/da9062/registers.h
drivers/mfd/Kconfig +12 -0
@@ -183,6 +183,18 @@ config MFD_DA9055 This driver can be built as a module. If built as a module it will be called "da9055" +config MFD_DA9062 + tristate "Dialog Semiconductor DA9062 PMIC Support" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y + help + Say yes here for support for the Dialog Semiconductor DA9062 PMIC. + This includes the I2C driver and core APIs. + Additional drivers must be enabled in order to use the functionality + of the device. + config MFD_DA9063 bool "Dialog Semiconductor DA9063 PMIC Support" select MFD_CORE
drivers/mfd/Makefile +2 -1
@@ -110,10 +110,11 @@ obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o da9055-objs := da9055-core.o da9055-i2c.o obj-$(CONFIG_MFD_DA9055) += da9055.o - +obj-$(CONFIG_MFD_DA9062) += da9062-core.o da9063-objs := da9063-core.o da9063-irq.o da9063-i2c.o obj-$(CONFIG_MFD_DA9063) += da9063.o obj-$(CONFIG_MFD_DA9150) += da9150-core.o + obj-$(CONFIG_MFD_MAX14577) += max14577.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o
drivers/mfd/da9062-core.c new file +647 -0
647 lines not on this page · raw message
include/linux/mfd/da9062/core.h new file +62 -0
62 lines not on this page · raw message
include/linux/mfd/da9062/registers.h new file +1108 -0
1,108 lines not on this page · raw message
Signature · 1 line
end-of-patch for PATCH V2
Re: [rtc-linux] [PATCH V2 1/4] mfd: da9062: DA9062 MFD core driver
drivers/mfd/Kconfig config MFD_DA9055 · line 191
Quoted 6 lines · S Twiss
drivers/mfd/Kconfig +6
-0+config MFD_DA9062 + tristate "Dialog Semiconductor DA9062 PMIC Support" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C=y
Isn't depends on I2C enough?
Quoted 19 lines
drivers/mfd/da9062-core.c new file +14
-0+#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/device.h> +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/mutex.h> +#include <linux/regmap.h> + +#include <linux/irq.h> +#include <linux/mfd/core.h> +#include <linux/i2c.h> +#include <linux/err.h>
drivers/mfd/da9062-core.c line 39
Quoted 10 lines
drivers/mfd/da9062-core.c new file +10
-0+ +#include <linux/mfd/da9062/core.h> +#include <linux/mfd/da9062/registers.h> +#include <linux/of.h> +#include <linux/regulator/of_regulator.h> + +#include <linux/proc_fs.h> +#include <linux/kthread.h> +#include <linux/uaccess.h> +
You should order the header inclusions alphabetically
[...]
Quoted 13 lines
drivers/mfd/da9062-core.c new file +13
-0+ { + .name = "da9062-watchdog", + .num_resources = ARRAY_SIZE(da9062_wdt_resources), + .resources = da9062_wdt_resources, + .of_compatible = "dlg,da9062-wdt", + }, + { + .name = "da9062-onkey", + .num_resources = ARRAY_SIZE(da9062_onkey_resources), + .resources = da9062_onkey_resources, + .of_compatible = "dlg,da9062-onkey", + }, + {
drivers/mfd/da9062-core.c line 242
Quoted 10 lines
drivers/mfd/da9062-core.c new file +10
-0+ .name = "da9062-thermal", + .num_resources = ARRAY_SIZE(da9062_thermal_resources), + .resources = da9062_thermal_resources, + .of_compatible = "dlg,da9062-thermal", + }, + { + .name = "da9062-rtc", + .num_resources = ARRAY_SIZE(da9062_rtc_resources), + .resources = da9062_rtc_resources, + .of_compatible = "dlg,da9062-rtc",
Did you try to use "da9063-rtc"? The register set seems to be exactly the same. Unfortunately, the datasheet are not available on the diasemi website...
Also, the .of_compatibles are not necessary because you don't add any of bindings to the underlying drivers. The match happens on .name.
include/linux/mfd/da9062/registers.h
Quoted 5 lines
include/linux/mfd/da9062/registers.h new file +0
-0
Comparing that file with da9063/registers.h, It really seems that DA062AA, DA9063AD and DA9063BB are register compatible, apart from a few differences in the regulator and the gpio count.
Also, at least the watchdog and rtc driver are duplicating their da9063 counterpart. I'm not trying to annoy you, I just want you to understand that the less code is duplicated, the easiest it will be to maintain later.
Signature · 7 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [rtc-linux] [PATCH V2 1/4] mfd: da9062: DA9062 MFD core driver
On 16 May 2015 09:53 Alexandre Belloni wrote:
Hi Alexandre,
Quoted 1 line · S Twiss
[...]
Quoted 19 lines
Quoted 19 lines
drivers/mfd/da9062-core.c new file +19
-0+ { + .name = "da9062-watchdog", + .num_resources = ARRAY_SIZE(da9062_wdt_resources), + .resources = da9062_wdt_resources, + .of_compatible = "dlg,da9062-wdt", + }, + { + .name = "da9062-onkey", + .num_resources = ARRAY_SIZE(da9062_onkey_resources), + .resources = da9062_onkey_resources, + .of_compatible = "dlg,da9062-onkey", + }, + { + .name = "da9062-thermal", + .num_resources = ARRAY_SIZE(da9062_thermal_resources), + .resources = da9062_thermal_resources, + .of_compatible = "dlg,da9062-thermal", + }, + {
Quoted 8 lines
drivers/mfd/da9062-core.c line 242
Quoted 4 lines
drivers/mfd/da9062-core.c new file +4
-0+ .name = "da9062-rtc", + .num_resources = ARRAY_SIZE(da9062_rtc_resources), + .resources = da9062_rtc_resources, + .of_compatible = "dlg,da9062-rtc",Did you try to use "da9063-rtc"? The register set seems to be exactly the same. Unfortunately, the datasheet are not available on the diasemi website...
I will remove the DA9062 OnKey and RTC parts with a view to putting them back when I do the work for the DA9063 alterations.
Quoted 15 lines
Also, the .of_compatibles are not necessary because you don't add any of bindings to the underlying drivers. The match happens on .name.
Review
Quoted 1 line
(quoted diff) +0
-0
b/include/linux/mfd/da9062/registers.hinclude/linux/mfd/da9062/registers.h
Quoted 4 lines
new file mode 100644
index 0000000..d07c2bcinclude/linux/mfd/da9062/registers.h new file +0
-0Comparing that file with
da9063/registers.h, It really seems that DA062AA, DA9063AD and DA9063BB are register compatible, apart from a few
differences in the regulator and the gpio count.
Quoted 4 lines
Also, at least the watchdog and rtc driver are duplicating their da9063 counterpart. I'm not trying to annoy you, I just want you to understand that the less code is duplicated, the easiest it will be to maintain later.
This has come up a lot lately.
https://lkml.org/lkml/2015/4/24/304
https://lkml.org/lkml/2015/5/13/383
https://lkml.org/lkml/2015/5/6/505
https://lkml.org/lkml/2015/5/18/511
The short answer is that the DA9062 and DA9063 chips are not identical. Although their numbers are sequential and there are functional similarities for some of the components, this is not the norm for the two chips.
In some cases re-using driver components from DA9063 is a good way forward, but making all components part of a monolithic driver would make both DA9062 and DA9063 over complicated and unmaintainable -- in my opinion.
However it's not just my opinion we have to consider here I think.
The RTC and OnKey in this case can be done fairly easily I think -- there can be some re-use in those components -- although there are fairly important RTC differences between the DA9063 AD and DA9063 BB silicon revisions (in the form of a new register, different functionality in the alarm and a register shift). So even that is not a straight-forward "swap" to run DA9062.
Regards,
Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/4 regulator: da9062: DA9062 regulator driver
In reply to S TwissFrom: S Twiss <[email protected]>
Add BUCK and LDO regulator driver support for DA9062
---
Changes in V2:
- Copyright headers GPL v2 (and later) match correct 'GPL' in MODULE_LICENSE
- Log errors for any issues in interrupt handler da9062_ldo_lim_event()
- Return IRQ_NONE when no regulators flag an event in da9062_ldo_lim_event()
- Remove VDD_WARN code and resource. Put it into the core instead of regulator driver. This IRQ handler does not belong in the regulator code.
- Usage of core functions for 'simplified DT parsing method' during probe and removal of platform data structures and unnecessary DT searches
This patch applies against linux-next and v4.1-rc3
drivers/regulator/Kconfig | 10 + drivers/regulator/Makefile | 1 + drivers/regulator/da9062-regulator.c | 843 +++++++++++++++++++++++++++++++++++ 3 files changed, 854 insertions(+) create mode 100644 drivers/regulator/da9062-regulator.c
drivers/regulator/Kconfig +10 -0
@@ -178,6 +178,16 @@ config REGULATOR_DA9055 This driver can also be built as a module. If so, the module will be called da9055-regulator. +config REGULATOR_DA9062 + tristate "Dialog Semiconductor DA9062 regulators" + depends on MFD_DA9062 + help + Say y here to support the BUCKs and LDOs regulators found on + DA9062 PMICs. + + This driver can also be built as a module. If so, the module + will be called da9062-regulator. + config REGULATOR_DA9063 tristate "Dialog Semiconductor DA9063 regulators" depends on MFD_DA9063
drivers/regulator/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o +obj-$(CONFIG_REGULATOR_DA9062) += da9062-regulator.o obj-$(CONFIG_REGULATOR_DA9063) += da9063-regulator.o obj-$(CONFIG_REGULATOR_DA9210) += da9210-regulator.o obj-$(CONFIG_REGULATOR_DA9211) += da9211-regulator.o
drivers/regulator/da9062-regulator.c new file +843 -0
843 lines not on this page · raw message
Signature · 1 line
end-of-patch for PATCH V2
PATCH v2 3/4 watchdog: da9062: DA9062 watchdog driver
In reply to S TwissFrom: S Twiss <[email protected]>
Add watchdog driver support for DA9062
---
Changes in V2:
- Removed informational dev_info() 'installed watchdog' message
- Copyright headers GPL v2 (and later) match correct 'GPL' in MODULE_LICENSE
- Removed the explicit 300 msecs delay from the reset_watchdog_timer() function and replaced it with a variable delay (depending on the difference since the last ping). A debug message is used to catch the multiple pings trying to break the 300 msecs protection barrier.
- Fix error paths for the functions da9062_wdt_update_timeout_register() and da9062_wdt_stop()
- Add error paths in the probe() and correctly clean-up the registered device if there is a problem after registration.
This patch applies against linux-next and v4.1-rc3
drivers/watchdog/Kconfig | 9 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/da9062_wdt.c | 288 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+) create mode 100644 drivers/watchdog/da9062_wdt.c
drivers/watchdog/Kconfig +9 -0
@@ -96,6 +96,15 @@ config DA9063_WATCHDOG This driver can be built as a module. The module name is da9063_wdt. +config DA9062_WATCHDOG + tristate "Dialog DA9062 Watchdog" + depends on MFD_DA9062 + select WATCHDOG_CORE + help + Support for the watchdog in the DA9062 PMIC. + + This driver can be built as a module. The module name is da9062_wdt. + config GPIO_WATCHDOG tristate "Watchdog device controlled through GPIO-line" depends on OF_GPIO
drivers/watchdog/Makefile +1 -0
@@ -179,6 +179,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o +obj-$(CONFIG_DA9062_WATCHDOG) += da9062_wdt.o obj-$(CONFIG_DA9063_WATCHDOG) += da9063_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o
drivers/watchdog/da9062_wdt.c new file +288 -0
288 lines not on this page · raw message
Signature · 6 lines
end-of-patch for PATCH V2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Guenter Roeck
maintainerRe: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 123 lines · S Twiss
From: S Twiss <[email protected]>
Add watchdog driver support for DA9062
Signed-off-by Steve Twiss <[email protected]>---
Changes in V2:
- Removed informationaldev_info()'installed watchdog' message
- Copyright headers GPL v2 (and later) match correct 'GPL' inMODULE_LICENSE
- Removed the explicit 300 msecs delay from thereset_watchdog_timer()function and replaced it with a variable delay (depending on the difference since the last ping). A debug message is used to catch the multiple pings trying to break the 300 msecs protection barrier.
- Fix error paths for the functionsda9062_wdt_update_timeout_register()and da9062_wdt_stop()- Add error paths in the
probe()and correctly clean-up the registered device if there is a problem after registration.This patch applies against linux-next and v4.1-rc3
drivers/watchdog/Kconfig | 9 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/da9062_wdt.c | 288 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+)create mode 100644
drivers/watchdog/da9062_wdt.cdrivers/watchdog/Kconfig +9
-0@@ -96,6 +96,15 @@ config DA9063_WATCHDOG This driver can be built as a module. The module name is da9063_wdt. +config DA9062_WATCHDOG + tristate "Dialog DA9062 Watchdog" + depends on MFD_DA9062 + select WATCHDOG_CORE + help + Support for the watchdog in the DA9062 PMIC. + + This driver can be built as a module. The module name is da9062_wdt. + config GPIO_WATCHDOG tristate "Watchdog device controlled through GPIO-line" depends on OF_GPIOdrivers/watchdog/Makefile +1
-0@@ -179,6 +179,7 @@ obj-$(CONFIG_XEN_WDT) += xen_wdt.o # Architecture Independent obj-$(CONFIG_DA9052_WATCHDOG) += da9052_wdt.o obj-$(CONFIG_DA9055_WATCHDOG) += da9055_wdt.o +obj-$(CONFIG_DA9062_WATCHDOG) += da9062_wdt.o obj-$(CONFIG_DA9063_WATCHDOG) += da9063_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.odrivers/watchdog/da9062_wdt.c new file +54
-0@@ -0,0 +1,288 @@ +/* +* da9062_wdt.c - WDT device driver for DA9062 +* Copyright (C) 2015 Dialog Semiconductor Ltd. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/watchdog.h> +#include <linux/platform_device.h> +#include <linux/uaccess.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/jiffies.h> +#include <linux/mfd/da9062/registers.h> +#include <linux/mfd/da9062/core.h> +#include <linux/regmap.h> +#include <linux/of.h> + +static const unsigned int wdt_timeout[] = {0 ,2 ,4 ,8 ,16 ,32 ,65 ,131 }; +#define DA9062_TWDSCALE_DISABLE 0 +#define DA9062_TWDSCALE_MIN 1 +#define DA9062_TWDSCALE_MAX (ARRAY_SIZE(wdt_timeout) - 1) +#define DA9062_WDT_MIN_TIMEOUT wdt_timeout[DA9062_TWDSCALE_MIN] +#define DA9062_WDT_MAX_TIMEOUT wdt_timeout[DA9062_TWDSCALE_MAX] +#define DA9062_WDG_DEFAULT_TIMEOUT wdt_timeout[DA9062_TWDSCALE_MAX-1] +#define DA9062_RESET_PROTECTION_MS 300 + +struct da9062_watchdog { +struct da9062 *hw; +struct watchdog_device wdtdev; +unsigned long j_time_stamp; +}; + +static void da9062_set_window_start (struct da9062_watchdog *wdt) +{ + wdt->j_time_stamp = jiffies; +} + +static void da9062_apply_window_protection (struct da9062_watchdog *wdt) +{ +unsigned long delay =msecs_to_jiffies (DA9062_RESET_PROTECTION_MS ); +unsigned long timeout = wdt->j_time_stamp + delay; +unsigned long now = jiffies; +unsigned int diff_ms;
drivers/watchdog/da9062_wdt.c line 64
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ +/* if time-limit has not elapsed then wait for remainder */ +if (time_before (now, timeout)) { + diff_ms =jiffies_to_msecs (timeout-now); +dev_dbg (wdt->hw->dev, +"Kicked too quickly. Delaying %u msecs\n" , diff_ms); +msleep (diff_ms); + } + +return ;
Unnecessary return statement.
Quoted 30 lines
drivers/watchdog/da9062_wdt.c new file +30
-0+} + +static unsigned int da9062_wdt_timeout_to_sel (unsigned int secs) +{ +unsigned int i; + +for (i =DA9062_TWDSCALE_MIN ; i <=DA9062_TWDSCALE_MAX ; i++) { +if (wdt_timeout[i] >= secs) +return i; + } + +return DA9062_TWDSCALE_MAX ; +} + +static int da9062_reset_watchdog_timer (struct da9062_watchdog *wdt) +{ +int ret; + +da9062_apply_window_protection (wdt); + + ret =regmap_update_bits (wdt->hw->regmap, +DA9062AA_CONTROL_F , +DA9062AA_WATCHDOG_MASK , +DA9062AA_WATCHDOG_MASK ); + +da9062_set_window_start (wdt); + +return ret; +} +
drivers/watchdog/da9062_wdt.c line 104
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+static int da9062_wdt_update_timeout_register (struct da9062_watchdog *wdt, +unsigned int regval) +{ +struct da9062 *chip = wdt->hw; +int ret; + + ret =da9062_reset_watchdog_timer (wdt); +if (ret) { +dev_err (chip->dev,"Failed to ping the watchdog (err = %d)\n" , + ret);
I am kind of torn about all this noisiness on error. Personally I would tend to ask people to let user space handle it, and not be that noisy in the kernel.
Wim, any guidance ?
drivers/watchdog/da9062_wdt.c line 111
Quoted 7 lines
drivers/watchdog/da9062_wdt.c new file +7
-0+return ret; + } + +return regmap_update_bits (chip->regmap, +DA9062AA_CONTROL_D , +DA9062AA_TWDSCALE_MASK , + regval);
... and it is inconsistent - no error message here.
Quoted 26 lines
drivers/watchdog/da9062_wdt.c new file +26
-0+} + +static int da9062_wdt_start (struct watchdog_device *wdd) +{ +struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9062_wdt_timeout_to_sel (wdt->wdtdev.timeout); + ret =da9062_wdt_update_timeout_register (wdt, selector); +if (ret) +dev_err (wdt->hw->dev,"Watchdog failed to start (err = %d)\n" , + ret); + +return ret; +} + +static int da9062_wdt_stop (struct watchdog_device *wdd) +{ +struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + + ret =da9062_reset_watchdog_timer (wdt); +if (ret) { +dev_err (wdt->hw->dev,"Failed to ping the watchdog (err = %d)\n" , + ret);
drivers/watchdog/da9062_wdt.c line 147
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+return ret; + } + + ret =regmap_update_bits (wdt->hw->regmap, +DA9062AA_CONTROL_D , +DA9062AA_TWDSCALE_MASK , +DA9062_TWDSCALE_DISABLE ); +if (ret) +dev_alert (wdt->hw->dev,"Watchdog failed to stop (err = %d)\n" , + ret);
.. and now we have an alert. Hmm..
drivers/watchdog/da9062_wdt.c line 158
Quoted 11 lines
drivers/watchdog/da9062_wdt.c new file +11
-0+ +return ret; +} + +static int da9062_wdt_ping (struct watchdog_device *wdd) +{ +struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +dev_dbg (wdt->hw->dev,"watchdog ping\n" ); +
Is this really valuable enough to keep in the code ?
Quoted 70 lines
drivers/watchdog/da9062_wdt.c new file +70
-0+ ret =da9062_reset_watchdog_timer (wdt); +if (ret) +dev_err (wdt->hw->dev,"Failed to ping the watchdog (err = %d)\n" , + ret); + +return ret; +} + +static int da9062_wdt_set_timeout (struct watchdog_device *wdd, +unsigned int timeout) +{ +struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd); +unsigned int selector; +int ret; + + selector =da9062_wdt_timeout_to_sel (timeout); + ret =da9062_wdt_update_timeout_register (wdt, selector); +if (ret) +dev_err (wdt->hw->dev,"Failed to set watchdog timeout (err = %d)\n" , + ret); +else + wdd->timeout = wdt_timeout[selector]; + +return ret; +} + +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler (int irq,void *data) +{ +struct da9062_watchdog *wdt = data; + +dev_notice (wdt->hw->dev,"Watchdog timeout warning trigger.\n" ); +return IRQ_HANDLED ; +} + +static const struct watchdog_info da9062_watchdog_info = { + .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , + .identity ="DA9062 WDT" , +}; + +static const struct watchdog_ops da9062_watchdog_ops = { + .owner =THIS_MODULE , + .start = da9062_wdt_start, + .stop = da9062_wdt_stop, + .ping = da9062_wdt_ping, + .set_timeout = da9062_wdt_set_timeout, +}; + +static int da9062_wdt_probe (struct platform_device *pdev) +{ +int ret; +struct da9062 *chip; +struct da9062_watchdog *wdt; +int irq; + + chip =dev_get_drvdata (pdev->dev.parent); +if (!chip) +return -EINVAL ; + + wdt =devm_kzalloc (&pdev->dev,sizeof (*wdt),GFP_KERNEL ); +if (!wdt) +return -ENOMEM ; + + wdt->hw = chip; + + wdt->wdtdev.info = &da9062_watchdog_info; + wdt->wdtdev.ops = &da9062_watchdog_ops; + wdt->wdtdev.min_timeout =DA9062_WDT_MIN_TIMEOUT ; + wdt->wdtdev.max_timeout =DA9062_WDT_MAX_TIMEOUT ; + wdt->wdtdev.timeout =DA9062_WDG_DEFAULT_TIMEOUT ;
drivers/watchdog/da9062_wdt.c line 238
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ wdt->wdtdev.status =WATCHDOG_NOWAYOUT_INIT_STATUS ; + +watchdog_set_drvdata (&wdt->wdtdev, wdt); +dev_set_drvdata (&pdev->dev, wdt); + + irq =platform_get_irq_byname (pdev,"WDG_WARN" ); +if (irq <0 ) { +dev_err (wdt->hw->dev,"Failed to get IRQ.\n" ); + ret = irq; + goto error;
Just return; the label does not serve a useful purpose. Same for the other goto statements below.
Also, is the interrupt mandatory ? All it does is to display a message. Looks very optional to me.
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +6
-0+ } + + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + da9062_wdt_wdg_warn_irq_handler, +IRQF_TRIGGER_LOW |IRQF_ONESHOT |IRQF_SHARED , +"WDG_WARN" , wdt);
drivers/watchdog/da9062_wdt.c line 254
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+if (ret) { +dev_err (wdt->hw->dev, +"Failed to request watchdog device IRQ.\n" ); + goto error; + } + + ret =watchdog_register_device (&wdt->wdtdev); +if (ret <0 ) { +dev_err (wdt->hw->dev, +"watchdog registration incomplete (%d)\n" , ret);
incomplete ? Should that be "failed" ?
Quoted 25 lines
drivers/watchdog/da9062_wdt.c new file +24
-0+ goto error; + } + +da9062_set_window_start (wdt); + + ret =da9062_wdt_ping (&wdt->wdtdev); +if (ret <0 ) +watchdog_unregister_device (&wdt->wdtdev); + +error: +return ret; +} + +static int da9062_wdt_remove (struct platform_device *pdev) +{ +struct da9062_watchdog *wdt =dev_get_drvdata (&pdev->dev); + +watchdog_unregister_device (&wdt->wdtdev); +return 0 ; +} + +static struct platform_driver da9062_wdt_driver = { + .probe = da9062_wdt_probe, + .remove = da9062_wdt_remove,
drivers/watchdog/da9062_wdt.c line 288
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ .driver = { + .name = "da9062-watchdog", + }, +}; +module_platform_driver (da9062_wdt_driver); + +MODULE_AUTHOR ("S Twiss <[email protected]>" ); +MODULE_DESCRIPTION ("WDT device driver for Dialog DA9062" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform: da9062-watchdog" );
Normally I don't see a space between "platform" and the driver name. Does this work ?
Thanks,
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Hi Guenter,
Thank you for your comments again,
Here are my responses.
Regards,
Steve
On 15 May 2015 03:13, Guenter Roeck
Quoted 2 lines
Subject: Re: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
[...]
Quoted 5 lines
Quoted 1 line
+static void da9062_apply_window_protection(struct
da9062_watchdog*wdt)
Review
Quoted 2 lines
(quoted diff) +2
-0+{ + unsigned long delay =
msecs_to_jiffies(DA9062_RESET_PROTECTION_MS);
Quoted 16 lines
drivers/watchdog/da9062_wdt.c line 64
Quoted 13 lines
drivers/watchdog/da9062_wdt.c new file +13
-0+unsigned long timeout = wdt->j_time_stamp + delay; +unsigned long now = jiffies; +unsigned int diff_ms; + +/* if time-limit has not elapsed then wait for remainder */ +if (time_before (now, timeout)) { + diff_ms =jiffies_to_msecs (timeout-now); +dev_dbg (wdt->hw->dev, +"Kicked too quickly. Delaying %u msecs\n" , diff_ms); +msleep (diff_ms); + } + +return ;Unnecessary return statement.
Deleted.
Quoted 42 lines
Quoted 28 lines
drivers/watchdog/da9062_wdt.c new file +28
-0+static unsigned int da9062_wdt_timeout_to_sel (unsigned int secs) +{ +unsigned int i; + +for (i =DA9062_TWDSCALE_MIN ; i <=DA9062_TWDSCALE_MAX ; i++) { +if (wdt_timeout[i] >= secs) +return i; + } + +return DA9062_TWDSCALE_MAX ; +} + +static int da9062_reset_watchdog_timer (struct da9062_watchdog *wdt) +{ +int ret; + +da9062_apply_window_protection (wdt); + + ret =regmap_update_bits (wdt->hw->regmap, +DA9062AA_CONTROL_F , +DA9062AA_WATCHDOG_MASK , +DA9062AA_WATCHDOG_MASK ); + +da9062_set_window_start (wdt); + +return ret; +} +drivers/watchdog/da9062_wdt.c line 104
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+static int da9062_wdt_update_timeout_register (struct da9062_watchdog *wdt, +unsigned int regval) +{ +struct da9062 *chip = wdt->hw; +int ret; + + ret =da9062_reset_watchdog_timer (wdt); +if (ret) { +dev_err (chip->dev,"Failed to ping the watchdog (err = %d)\n" , + ret);I am kind of torn about all this noisiness on error. Personally I would tend to ask people to let user space handle it, and not be that noisy in the kernel.
Quoted 1 line
Wim, any guidance ?
At the time I thought it would be a really good idea to keep a debug message in. But -- this has been questioned several times and so I will remove.
Quoted 10 lines
drivers/watchdog/da9062_wdt.c line 111
Quoted 7 lines
drivers/watchdog/da9062_wdt.c new file +7
-0+return ret; + } + +return regmap_update_bits (chip->regmap, +DA9062AA_CONTROL_D , +DA9062AA_TWDSCALE_MASK , + regval);... and it is inconsistent - no error message here.
Removed the dev_err() defined previously and therefore this makes this return without an error message more consistent with the earlier parts of the function. (no change needed)
[...]
Quoted 20 lines
drivers/watchdog/da9062_wdt.c
Quoted 8 lines
drivers/watchdog/da9062_wdt.c new file +8
-0+static int da9062_wdt_stop (struct watchdog_device *wdd) +{ +struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + + ret =da9062_reset_watchdog_timer (wdt); +if (ret) { + dev_err(wdt->hw->dev, "Failed to ping the watchdog (err =%d)\n",
drivers/watchdog/da9062_wdt.c
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ ret); +return ret; + } + + ret =regmap_update_bits (wdt->hw->regmap, +DA9062AA_CONTROL_D , +DA9062AA_TWDSCALE_MASK , +DA9062_TWDSCALE_DISABLE ); +if (ret) + dev_alert(wdt->hw->dev, "Watchdog failed to stop (err =%d)\n",
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ ret);.. and now we have an alert. Hmm..
.. I've replaced it with a dev_err()
Quoted 5 lines
Quoted 5 lines
drivers/watchdog/da9062_wdt.c new file +5
-0+ +return ret; +} + +static int da9062_wdt_ping (struct watchdog_device *wdd)
Quoted 9 lines
drivers/watchdog/da9062_wdt.c line 158
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +6
-0+{ +struct da9062_watchdog *wdt =watchdog_get_drvdata (wdd); +int ret; + +dev_dbg (wdt->hw->dev,"watchdog ping\n" ); +Is this really valuable enough to keep in the code ?
Removed also.
Quoted 9 lines
drivers/watchdog/da9062_wdt.c
Quoted 3 lines
drivers/watchdog/da9062_wdt.c new file +3
-0+ ret =da9062_reset_watchdog_timer (wdt); +if (ret) + dev_err(wdt->hw->dev, "Failed to ping the watchdog (err =%d)\n",
Quoted 5 lines
drivers/watchdog/da9062_wdt.c new file +5
-0+ ret); + +return ret; +} +
[...]
Quoted 10 lines
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler (int irq,void *data) +{ +struct da9062_watchdog *wdt = data; + +dev_notice (wdt->hw->dev,"Watchdog timeout warning trigger.\n" ); +return IRQ_HANDLED ; +} +
[...]
Quoted 27 lines
Quoted 27 lines
drivers/watchdog/da9062_wdt.c new file +27
-0+static int da9062_wdt_probe (struct platform_device *pdev) +{ +int ret; +struct da9062 *chip; +struct da9062_watchdog *wdt; +int irq; + + chip =dev_get_drvdata (pdev->dev.parent); +if (!chip) +return -EINVAL ; + + wdt =devm_kzalloc (&pdev->dev,sizeof (*wdt),GFP_KERNEL ); +if (!wdt) +return -ENOMEM ; + + wdt->hw = chip; + + wdt->wdtdev.info = &da9062_watchdog_info; + wdt->wdtdev.ops = &da9062_watchdog_ops; + wdt->wdtdev.min_timeout =DA9062_WDT_MIN_TIMEOUT ; + wdt->wdtdev.max_timeout =DA9062_WDT_MAX_TIMEOUT ; + wdt->wdtdev.timeout =DA9062_WDG_DEFAULT_TIMEOUT ; + wdt->wdtdev.status =WATCHDOG_NOWAYOUT_INIT_STATUS ; + +watchdog_set_drvdata (&wdt->wdtdev, wdt); +dev_set_drvdata (&pdev->dev, wdt); +
Quoted 8 lines
drivers/watchdog/da9062_wdt.c line 238
Quoted 5 lines
drivers/watchdog/da9062_wdt.c new file +5
-0+ irq =platform_get_irq_byname (pdev,"WDG_WARN" ); +if (irq <0 ) { +dev_err (wdt->hw->dev,"Failed to get IRQ.\n" ); + ret = irq; + goto error;Just return; the label does not serve a useful purpose. Same for the other goto statements below.
Agreed. This is changed now.
Quoted 2 lines
Also, is the interrupt mandatory ? All it does is to display a message. Looks very optional to me.
It is a place holder for something more application specific.
I could remove it, but I figured it would just get re-added when somebody takes the driver and modifies it for their needs.
If this is a problem however, it can go.
Please advise ..
Quoted 7 lines
drivers/watchdog/da9062_wdt.c
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +5
-0+ } + + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + da9062_wdt_wdg_warn_irq_handler, + IRQF_TRIGGER_LOW | IRQF_ONESHOT |
IRQF_SHARED,
Quoted 13 lines
drivers/watchdog/da9062_wdt.c line 254
Quoted 11 lines
drivers/watchdog/da9062_wdt.c new file +11
-0+ "WDG_WARN", wdt); +if (ret) { +dev_err (wdt->hw->dev, +"Failed to request watchdog device IRQ.\n" ); + goto error; + } + + ret =watchdog_register_device (&wdt->wdtdev); +if (ret <0 ) { +dev_err (wdt->hw->dev, +"watchdog registration incomplete (%d)\n" , ret);incomplete ? Should that be "failed" ?
Sure. Changed the dev_err()
[...]
Quoted 8 lines
Quoted 8 lines
drivers/watchdog/da9062_wdt.c new file +8
-0+static struct platform_driver da9062_wdt_driver = { + .probe = da9062_wdt_probe, + .remove = da9062_wdt_remove, + .driver = { + .name ="da9062-watchdog" , + }, +}; +module_platform_driver (da9062_wdt_driver);
Quoted 8 lines
drivers/watchdog/da9062_wdt.c line 288
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +5
-0+ +MODULE_AUTHOR ("S Twiss <[email protected]>" ); +MODULE_DESCRIPTION ("WDT device driver for Dialog DA9062" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform: da9062-watchdog" );Normally I don't see a space between "platform" and the driver name. Does this work ?
Removed the space
Regards,
Steve
Guenter Roeck
maintainerRe: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Hi Steve,
Quoted 14 lines · Opensource [Steve Twiss]
Hi Guenter,
Thank you for your comments again,
Here are my responses.Regards,
SteveOn 15 May 2015 03:13, Guenter Roeck
Quoted 2 lines
Subject: Re: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
[...]
[ ... ]
Quoted 15 lines
Quoted 9 lines
drivers/watchdog/da9062_wdt.c line 238
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +6
-0+ + irq =platform_get_irq_byname (pdev,"WDG_WARN" ); +if (irq <0 ) { +dev_err (wdt->hw->dev,"Failed to get IRQ.\n" ); + ret = irq; + goto error;Just return; the label does not serve a useful purpose. Same for the other goto statements below.
Agreed. This is changed now.
Quoted 2 lines
Also, is the interrupt mandatory ? All it does is to display a message. Looks very optional to me.
Quoted 7 lines
It is a place holder for something more application specific.
I could remove it, but I figured it would just get re-added when somebody takes the driver and modifies it for their needs.If this is a problem however, it can go.
Please advise ..
Then this someone should add the code. For the time being, it just increases kernel size and may cause the driver to fail for no good reason. Plus, given the driver apparently works without interrupt, even then it should be optional, and the driver does not have to fail loading if it is not supported on a given platform.
Thanks,
Guenter
RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 11 lines
drivers/watchdog/da9062_wdt.c line 193
Quoted 11 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler (int irq,void *data) +{ +struct da9062_watchdog *wdt = data; + +dev_notice (wdt->hw->dev,"Watchdog timeout warning trigger.\n" ); +return IRQ_HANDLED ; +} +
On 15 May 2015 13:58 Guenter Roeck wrote:
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +6
-0+ + irq =platform_get_irq_byname (pdev,"WDG_WARN" ); +if (irq <0 ) { +dev_err (wdt->hw->dev,"Failed to get IRQ.\n" ); + ret = irq; + goto error;
[...]
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines
Also, is the interrupt mandatory ? All it does is to display a message. Looks very optional to me.
It is a place holder for something more application specific.
I could remove it, but I figured it would just get re-added when somebody takes the driver and modifies it for their needs.If this is a problem however, it can go.
Please advise ..
Quoted 6 lines
Then this someone should add the code. For the time being, it just increases kernel size and may cause the driver to fail for no good reason. Plus, given the driver apparently works without interrupt, even then it should be optional, and the driver does not have to fail loading if it is not supported on a given platform.
Hi Guenter,
I'm not sure if I got my previous point across there ...
Leaving this in wouldn't really do any real harm I think. If this feature is not supported in somebody's platform then there wouldn't be a problem, the IRQ would fire (as a warning that the watchdog was about to time-out), the handler function would be executed, it would handle the IRQ -- and that would be it. Nothing would happen apart from a debug print.
There are already examples of this in the kernel, I've not looked very hard ...
http://lxr.free-electrons.com/source/drivers/mfd/qcom_rpm.c#L412
http://lxr.free-electrons.com/source/drivers/mfd/arizona-irq.c#L72
The problem with removing it is, I am depreciating the functionality of the chip. Unless there is a really good reason -- I would like to leave this part in please. If I was to take this part out then there could be an argument to remove WDG_WARN from the resource of the MFD -- but that would then hide this watchdog warning functionality completely.
The function da9062_wdt_wdg_warn_irq_handler() is blank -- and it just does nothing apart from handle the IRQ. But it is an important feature of the chip .. say for a developer to add in their product code to send a uevent into userspace to trigger a watchdog kick (for instance).. but that part is very specific and usually only part of a final system integration. I've just left the function as a stub for that reason.
There is the possibility that the function platform_get_irq_byname() could fail but that would mean an different type of critical failure.
Regards,
Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Guenter Roeck
maintainerRe: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 46 lines · Opensource [Steve Twiss]
Quoted 11 lines
drivers/watchdog/da9062_wdt.c line 193
Quoted 11 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler (int irq,void *data) +{ +struct da9062_watchdog *wdt = data; + +dev_notice (wdt->hw->dev,"Watchdog timeout warning trigger.\n" ); +return IRQ_HANDLED ; +} +On 15 May 2015 13:58 Guenter Roeck wrote:
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +6
-0+ + irq =platform_get_irq_byname (pdev,"WDG_WARN" ); +if (irq <0 ) { +dev_err (wdt->hw->dev,"Failed to get IRQ.\n" ); + ret = irq; + goto error;[...]
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines
Also, is the interrupt mandatory ? All it does is to display a message. Looks very optional to me.
It is a place holder for something more application specific.
I could remove it, but I figured it would just get re-added when somebody takes the driver and modifies it for their needs.If this is a problem however, it can go.
Please advise ..Quoted 6 lines
Then this someone should add the code. For the time being, it just increases kernel size and may cause the driver to fail for no good reason. Plus, given the driver apparently works without interrupt, even then it should be optional, and the driver does not have to fail loading if it is not supported on a given platform.
Hi Guenter,
Quoted 7 lines
I'm not sure if I got my previous point across there ...
Leaving this in wouldn't really do any real harm I think. If this feature is not supported in somebody's platform then there wouldn't be a problem, the IRQ would fire (as a warning that the watchdog was about to time-out), the handler function would be executed, it would handle the IRQ -- and that would be it. Nothing would happen apart from a debug print.
I didn't get my point across either. Problem is that your driver fails to load if the interrupt is not there. With the interrupt really being optional, I don't see the point in making it mandatory just to display a message if it fires.
Quoted 5 lines
There are already examples of this in the kernel, I've not looked very hard ...
http://lxr.free-electrons.com/source/drivers/mfd/qcom_rpm.c#L412
http://lxr.free-electrons.com/source/drivers/mfd/arizona-irq.c#L72
Never a good argument to make with me. 100 people doing something wrong doesn't mean you should continue to do so.
Guenter
RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
On 15 May 2015 21:20 Guenter Roeck,
Quoted 53 lines
Quoted 45 lines
Quoted 10 lines
drivers/watchdog/da9062_wdt.c line 193
Quoted 10 lines
drivers/watchdog/da9062_wdt.c new file +10
-0+ +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler (int irq,void *data) +{ +struct da9062_watchdog *wdt = data; + +dev_notice (wdt->hw->dev,"Watchdog timeout warning trigger.\n" ); +return IRQ_HANDLED ; +} +On 15 May 2015 13:58 Guenter Roeck wrote:
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/watchdog/da9062_wdt.c new file +6
-0+ + irq =platform_get_irq_byname (pdev,"WDG_WARN" ); +if (irq <0 ) { +dev_err (wdt->hw->dev,"Failed to get IRQ.\n" ); + ret = irq; + goto error;[...]
Quoted 12 lines
Quoted 11 lines
Quoted 3 lines
Also, is the interrupt mandatory ? All it does is to display a message. Looks very optional to me.
It is a place holder for something more application specific.
I could remove it, but I figured it would just get re-added when somebody takes the driver and modifies it for their needs.If this is a problem however, it can go.
Please advise ..Quoted 6 lines
Then this someone should add the code. For the time being, it just increases kernel size and may cause the driver to fail for no good reason. Plus, given the driver apparently works without interrupt, even then it should be optional, and the driver does not have to fail loading if it is not supported on a given platform.
Hi Guenter,
Quoted 7 lines
I'm not sure if I got my previous point across there ...
Leaving this in wouldn't really do any real harm I think. If this feature is not supported in somebody's platform then there wouldn't be a problem, the IRQ would fire (as a warning that the watchdog was about to time-out), the handler function would be executed, it would handle the IRQ -- and that would be it. Nothing would happen apart from a debug print.
Quoted 4 lines
I didn't get my point across either. Problem is that your driver fails to load if the interrupt is not there. With the interrupt really being optional, I don't see the point in making it mandatory just to display a message if it fires.
Hi Guenter,
Ok. I see now.
It's not a mandatory interrupt and so it should not fail the whole driver upon an error from the devm_request_threaded_irq() request ... I will let it pass through if there is a problem and just display a debug message. Something like this:
@@ -234,11 +234,9 @@ static int da9062_wdt_probe(struct platform_device *pdev)
da9062_wdt_wdg_warn_irq_handler,
IRQF_TRIGGER_LOW | IRQF_ONESHOT | IRQF_SHARED,
"WDG_WARN", wdt);- if (ret) {
- dev_err(wdt->hw->dev,
+ if (ret)
+ dev_dbg(wdt->hw->dev,
"Failed to request watchdog device IRQ.\n");
- return ret;
- }
ret = watchdog_register_device(&wdt->wdtdev);
if (ret < 0) {I think I've understood now. I guess this is it..
I'll send a PATCH V3 with this change.
Regards,
Steve
Guenter Roeck
maintainerRe: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 15 lines · Opensource [Steve Twiss]
On 15 May 2015 21:20 Guenter Roeck,
Quoted 13 lines
Quoted 13 lines
Quoted 10 lines
Review
Quoted 10 lines
(quoted diff) +10
-0+ +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler(int irq, void*data) +{ + struct da9062_watchdog *wdt = data; + + dev_notice(wdt->hw->dev, "Watchdog timeout warning trigger.\n"); + return IRQ_HANDLED; +} +On 15 May 2015 13:58 Guenter Roeck wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ + irq = platform_get_irq_byname(pdev, "WDG_WARN"); + if (irq < 0) { + dev_err(wdt->hw->dev, "Failed to get IRQ.\n"); + ret = irq;
Hi Steve,
Since the interrupt is optional, the driver should also not fail to load if no interrupt is assigned to it in the first place.
On a separate note, there was a comment stating that the da9062 watchdog is identical to the da9063 watchdog. If so, why can't you just use the da9063 watchdog driver ?
Thanks,
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 19 lines · On 18 May 2015 16:28 Guenter Roeck wrote:
Quoted 17 lines · Opensource [Steve Twiss]
On 15 May 2015 21:20 Guenter Roeck,
Quoted 15 lines
Quoted 15 lines
Quoted 10 lines
Review
Quoted 10 lines
(quoted diff) +10
-0+ +/* E_WDG_WARN interrupt handler */ +static irqreturn_t da9062_wdt_wdg_warn_irq_handler(int irq, void*data) +{ + struct da9062_watchdog *wdt = data; + + dev_notice(wdt->hw->dev, "Watchdog timeout warning trigger.\n"); + return IRQ_HANDLED; +} +On 15 May 2015 13:58 Guenter Roeck wrote:
[...]
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ + irq = platform_get_irq_byname(pdev, "WDG_WARN"); + if (irq < 0) { + dev_err(wdt->hw->dev, "Failed to get IRQ.\n"); + ret = irq;Hi Steve,
Hi Guenter,
Quoted 2 lines
Since the interrupt is optional, the driver should also not fail to load if no interrupt is assigned to it in the first place.
Yeah. I've been thinking about it and I agree now. I'll erase the handler.
Quoted 3 lines
On a separate note, there was a comment stating that the da9062 watchdog is identical to the da9063 watchdog. If so, why can't you just use the da9063 watchdog driver ?
Well, the short answer to this is, it's not the same. I was just in the process of replying to that other thread. The OnKey and RTC are functionally similar, so I am going to look at integrating the two drivers in some future patch sets, but the watchdog is definitely not based upon DA9063.
I did mention this in a previous thread:
https://lkml.org/lkml/2015/5/6/505
Regards,
Steve
Re: [rtc-linux] RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 9 lines · Opensource [Steve Twiss]
Quoted 2 lines
Since the interrupt is optional, the driver should also not fail to load if no interrupt is assigned to it in the first place.
Yeah. I've been thinking about it and I agree now. I'll erase the handler.
Quoted 3 lines
On a separate note, there was a comment stating that the da9062 watchdog is identical to the da9063 watchdog. If so, why can't you just use the da9063 watchdog driver ?
Quoted 8 lines
Well, the short answer to this is, it's not the same. I was just in the process of replying to that other thread. The OnKey and RTC are functionally similar, so I am going to look at integrating the two drivers in some future patch sets, but the watchdog is definitely not based upon DA9063.
I did mention this in a previous thread:
https://lkml.org/lkml/2015/5/6/505
Sure, what I understand is that the base functionality is the same and even the registers are compatible. Are you sure the new features can't be added to the da9063 and called conditionally? Plenty of drivers are doing that.
Signature · 7 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [rtc-linux] RE: [PATCH V2 3/4] watchdog: da9062: DA9062 watchdog driver
Quoted 4 lines · On 18 May 2015 18:39 Alexandre Belloni wrote:
Sure, what I understand is that the base functionality is the same and even the registers are compatible. Are you sure the new features can't be added to the da9063 and called conditionally? Plenty of drivers are doing that.
Hi Alexandre/Guenter,
I didn't say it couldn't be added to DA9063. Of course it's all possible, but I think it would become unmaintainable in future without separate drivers. There is some extra freeze functionality and a watchdog warn interrupt: both do not exist in the DA9063.
What I did say **one month ago** was the DA9062 watchdog driver does have some similarities with the DA9063 watchdog (https://lkml.org/lkml/2015/5/6/505).
But I would prefer two drivers for watchdog in this case. When compared to the RTC and OnKey the watchdog is very different on the hardware side. Despite the appearance of some similarity, the watchdog is not a functional clone like the RTC and OnKey components.
I would not like a combined watchdog driver because I think that the extra functions that the DA9062 contains would bloat out the DA9063 watchdog, and would make it difficult to test and to maintain for the future..
Regards,
Steve
PATCH v2 4/4 devicetree: da9062: Add bindings for DA9062 driver
In reply to S TwissFrom: S Twiss <[email protected]>
Add device tree bindings for the DA9062 driver
---
Changes in V2:
- Dropped the RTC and Onkey binding information in this patch-set Those drivers have been dropped from this patch set and the binding information has been removed accordingly.
This patch applies against linux-next and v4.1-rc3
Documentation/devicetree/bindings/mfd/da9062.txt | 79 ++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/da9062.txt
Documentation/devicetree/bindings/mfd/da9062.txt new file +79 -0
@@ -0,0 +1,79 @@ +* Dialog DA9062 Power Management Integrated Circuit (PMIC) + +DA9062 consists of a large and varied group of sub-devices: + +Device Supply Names Description +------ ------------ ----------- +da9062-regulator : : LDOs & BUCKs +da9062-watchdog : : Watchdog Timer + +====== + +Required properties: + +- compatible : Should be "dlg,da9062". +- reg : Specifies the I2C slave address (this defaults to 0x58 but it can be + modified to match the chip's OTP settings). +- interrupt-parent : Specifies the reference to the interrupt controller for + the DA9062. +- interrupts : IRQ line information. +- interrupt-controller + +See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for +further information on IRQ bindings. + +Sub-nodes: + +- regulators : This node defines the settings for the LDOs and BUCKs. The + DA9062 regulators are bound using their names listed below: + + buck1 : BUCK_1 + buck2 : BUCK_2 + buck3 : BUCK_3 + buck4 : BUCK_4 + ldo1 : LDO_1 + ldo2 : LDO_2 + ldo3 : LDO_3 + ldo4 : LDO_4 + + The component follows the standard regulator framework and the bindings + details of individual regulator device can be found in: + Documentation/devicetree/bindings/regulator/regulator.txt + + +- watchdog: This node defines the settings for the watchdog driver associated + with the DA9062 PMIC. The compatible = "dlg,da9062-watchdog" should be added + if a node is created. + + +Example: + + pmic0: da9062@58 { + compatible = "dlg,da9062"; + reg = <0x58>; + interrupt-parent = <&gpio6>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + interrupt-controller; + + watchdog { + compatible = "dlg,da9062-watchdog"; + }; + + regulators { + DA9062_BUCK1: buck1 { + regulator-name = "BUCK1"; + regulator-min-microvolt = <300000>; + regulator-max-microvolt = <1570000>; + regulator-min-microamp = <500000>; + regulator-max-microamp = <2000000>; + regulator-boot-on; + }; + DA9062_LDO1: ldo1 { + regulator-name = "LDO_1"; + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <3600000>; + regulator-boot-on; + }; + }; + }; +
Signature · 1 line
end-of-patch for PATCH V2
Hi,
Quoted 9 lines · S Twiss
From: S Twiss <[email protected]>
This patch set adds support for the Dialog DA9062 Power Management IC.
In this patch set the following is provided:
- [PATCH V2 1/4]: MFD core support
- [PATCH V2 2/4]: BUCK and LDO regulator driver
- [PATCH V2 3/4]: Watchdog driver
- [PATCH V2 4/4]: Add bindings for all DA9062 components
This patch should actually be the first one to go in, else checkpatch will complain about compatibles not being found.
Signature · 7 lines
Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
On 16 May 2015 01:47, Alexandre Belloni wrote
Quoted 5 lines · S Twiss
Quoted 4 lines
From: S Twiss <[email protected]>
This patch set adds support for the Dialog DA9062 Power Management IC.
Quoted 8 lines
Quoted 5 lines
In this patch set the following is provided:
- [PATCH V2 1/4]: MFD core support
- [PATCH V2 2/4]: BUCK and LDO regulator driver
- [PATCH V2 3/4]: Watchdog driver
- [PATCH V2 4/4]: Add bindings for all DA9062 componentsThis patch should actually be the first one to go in, else checkpatch will complain about compatibles not being found.
Hi Alexandre,
Sure thing. These DA9062 patches should be in before the RTC changes to DA9063 get made to support DA9062. I'll ensure I don't submit any RTC updates until then.
Regards,
Steve