backlight: Add WM831x backlight driver
Subsystems (7)
PATCH 1/5 backlight: Add WM831x backlight driver
The WM831x series of PMICs provide DC-DC boost convertors and current sinks which can be used together to drive LEDs for use as backlights. Expose this functionality via the backlight API.
Since when used in this configuration the current sink and boost convertor are very tightly coupled with a multi-stage startup for the current sink which overlaps with the boost convertor startup this driver bypasses the regulator API. Machine inititialisation is responsible for ensuring that the regulators are not accessed via both APIs.
--- drivers/video/backlight/Kconfig | 7 + drivers/video/backlight/Makefile | 1 + drivers/video/backlight/wm831x_bl.c | 250 +++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+), 0 deletions(-) create mode 100644 drivers/video/backlight/wm831x_bl.c
drivers/video/backlight/Kconfig +7 -0
@@ -229,3 +229,10 @@ config BACKLIGHT_SAHARA help If you have a Tabletkiosk Sahara Touch-iT, say y to enable the backlight driver. + +config BACKLIGHT_WM831X + tristate "WM831x PMIC Backlight Driver" + depends on BACKLIGHT_CLASS_DEVICE && MFD_WM831X + help + If you have a backlight driven by the ISINK and DCDC of a + WM831x PMIC say y to enable the backlight driver for it.
drivers/video/backlight/Makefile +1 -0
@@ -24,4 +24,5 @@ obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o +obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o
drivers/video/backlight/wm831x_bl.c new file +250 -0
250 lines not on this page · raw message
Signature · 1 line
1.6.3.3
PATCH 2/5 leds: Add WM831x status LED driver
The WM831x devices feature two software controlled status LEDs with hardware assisted blinking.
The device can also autonomously control the LEDs based on a selection of sources. This can be configured at boot time using either platform data or the chip OTP. A sysfs file in the style of that for triggers allowing the control source to be configured at run time. Triggers can't be used here since they can't depend on the implementation details of a specific LED type.
--- drivers/leds/Kconfig | 7 + drivers/leds/Makefile | 1 + drivers/leds/leds-wm831x-status.c | 341 +++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm831x/status.h | 34 ++++ 4 files changed, 383 insertions(+), 0 deletions(-) create mode 100644 drivers/leds/leds-wm831x-status.c create mode 100644 include/linux/mfd/wm831x/status.h
drivers/leds/Kconfig +7 -0
@@ -195,6 +195,13 @@ config LEDS_PCA955X LED driver chips accessed via the I2C bus. Supported devices include PCA9550, PCA9551, PCA9552, and PCA9553. +config LEDS_WM831X_STATUS + tristate "LED support for status LEDs on WM831x PMICs" + depends on LEDS_CLASS && MFD_WM831X + help + This option enables support for the status LEDs of the WM831x + series of PMICs. + config LEDS_WM8350 tristate "LED Support for WM8350 AudioPlus PMIC" depends on LEDS_CLASS && MFD_WM8350
drivers/leds/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o obj-$(CONFIG_LEDS_FSG) += leds-fsg.o obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o +obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
drivers/leds/leds-wm831x-status.c new file +341 -0
341 lines not on this page · raw message
include/linux/mfd/wm831x/status.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* include/linux/mfd/wm831x/status.h -- Status LEDs for WM831x +* +* Copyright 2009 Wolfson Microelectronics PLC. +* +* Author: Mark Brown <[email protected]> +* +* 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. +* +*/ + +#ifndef __MFD_WM831X_STATUS_H__ +#define __MFD_WM831X_STATUS_H__ + +#define WM831X_LED_SRC_MASK 0xC000/* LED_SRC - [15:14] */ +#define WM831X_LED_SRC_SHIFT 14/* LED_SRC - [15:14] */ +#define WM831X_LED_SRC_WIDTH 2/* LED_SRC - [15:14] */ +#define WM831X_LED_MODE_MASK 0x0300/* LED_MODE - [9:8] */ +#define WM831X_LED_MODE_SHIFT 8/* LED_MODE - [9:8] */ +#define WM831X_LED_MODE_WIDTH 2/* LED_MODE - [9:8] */ +#define WM831X_LED_SEQ_LEN_MASK 0x0030/* LED_SEQ_LEN - [5:4] */ +#define WM831X_LED_SEQ_LEN_SHIFT 4/* LED_SEQ_LEN - [5:4] */ +#define WM831X_LED_SEQ_LEN_WIDTH 2/* LED_SEQ_LEN - [5:4] */ +#define WM831X_LED_DUR_MASK 0x000C/* LED_DUR - [3:2] */ +#define WM831X_LED_DUR_SHIFT 2/* LED_DUR - [3:2] */ +#define WM831X_LED_DUR_WIDTH 2/* LED_DUR - [3:2] */ +#define WM831X_LED_DUTY_CYC_MASK 0x0003/* LED_DUTY_CYC - [1:0] */ +#define WM831X_LED_DUTY_CYC_SHIFT 0/* LED_DUTY_CYC - [1:0] */ +#define WM831X_LED_DUTY_CYC_WIDTH 2/* LED_DUTY_CYC - [1:0] */ + +#endif
Signature · 1 line
1.6.3.3
PATCH 3/5 power_supply: Add driver for the PMU on WM831x PMICs
In reply to Mark BrownThe WM831x PMICs provide power path management from three sources:
a wall supply, USB and a battery with integrated charger. They also provide an additional backup supply with integrated for maintaining always on functionality such as the RTC and monitoring of power switches.
After some initial configuration at startup the device operates autonomously, the driver simply provides reporting of the current state.
--- drivers/power/Kconfig | 7 + drivers/power/Makefile | 1 + drivers/power/wm831x_power.c | 779 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/wm831x/pmu.h | 189 ++++++++++ 4 files changed, 976 insertions(+), 0 deletions(-) create mode 100644 drivers/power/wm831x_power.c create mode 100644 include/linux/mfd/wm831x/pmu.h
drivers/power/Kconfig +7 -0
@@ -29,6 +29,13 @@ config APM_POWER Say Y here to enable support APM status emulation using battery class devices. +config WM831X_POWER + tristate "WM831X PMU support" + depends on MFD_WM831X + help + Say Y here to enable support for the power management unit + provided by Wolfson Microelectronics WM831x PMICs. + config WM8350_POWER tristate "WM8350 PMU support" depends on MFD_WM8350
drivers/power/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_POWER_SUPPLY) += power_supply.o obj-$(CONFIG_PDA_POWER) += pda_power.o obj-$(CONFIG_APM_POWER) += apm_power.o +obj-$(CONFIG_WM831X_POWER) += wm831x_power.o obj-$(CONFIG_WM8350_POWER) += wm8350_power.o obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
drivers/power/wm831x_power.c new file +779 -0
779 lines not on this page · raw message
include/linux/mfd/wm831x/pmu.h new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Re: [PATCH 3/5] power_supply: Add driver for the PMU on WM831x PMICs
Quoted 11 lines · Mark Brown
The WM831x PMICs provide power path management from three sources:
a wall supply, USB and a battery with integrated charger. They also provide an additional backup supply with integrated for maintaining always on functionality such as the RTC and monitoring of power switches.After some initial configuration at startup the device operates autonomously, the driver simply provides reporting of the current state.
Signed-off-by Mark Brown <[email protected]>
I don't see the rest of the series, so I assume this patch depends on some other patches. So, feel free to merge it through your tree.
Thanks!
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Re: [PATCH 3/5] power_supply: Add driver for the PMU on WM831x PMICs
Quoted 5 lines · Anton Vorontsov
I don't see the rest of the series, so I assume this patch depends on some other patches. So, feel free to merge it through your tree.
Acked-by Anton Vorontsov <[email protected]>
Actually the only merge dependency is on the power tree - the Kconfig dependency on MFD_WM831X will prevent it being built until the MFD dependencies are but the driver uses the new charge_type property from the power tree.
Re: [PATCH 3/5] power_supply: Add driver for the PMU on WM831x PMICs
Quoted 6 lines · Mark Brown
Quoted 3 lines · Anton Vorontsov
I don't see the rest of the series, so I assume this patch depends on some other patches. So, feel free to merge it through your tree.
Quoted 6 lines
Quoted 1 line
Acked-by Anton Vorontsov <[email protected]>Actually the only merge dependency is on the power tree - the
Kconfigdependency onMFD_WM831Xwill prevent it being built until the MFD dependencies are but the driver uses the newcharge_typeproperty from the power tree.
OK, then I'll apply it.
Thanks again.
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
PATCH 4/5 RTC: Add support for RTCs on Wolfson WM831x devices
In reply to Mark BrownThe WM831x series of PMICs contain RTC functionality. The hardware provides a 32 bit counter incrementing at 1Hz together with a per tick interrupt and an alarm value. For simplicity the driver chooses to define the epoch for the counter as the Unix epoch - if required platform data can be used in future to customise this.
When powered on from a completely cold state the RTC reports that it has not been configured - when this happens an error is returned when attempting to read the RTC in order to avoid use of values we know to be invalid.
The hardware also provides security features which mean that it can ignore attempts to set the RTC time in certain circumstances, most notably if the RTC is written to too often. These errors are detected by verifying the written RTC value.
--- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-wm831x.c | 538 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 549 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-wm831x.c
drivers/rtc/Kconfig +10 -0
@@ -537,6 +537,16 @@ config RTC_DRV_V3020 This driver can also be built as a module. If so, the module will be called rtc-v3020. +config RTC_DRV_WM831X + tristate "Wolfson Microelectronics WM831x RTC" + depends on MFD_WM831X + help + If you say yes here you will get support for the RTC subsystem + of the Wolfson Microelectronics WM831X series PMICs. + + This driver can also be built as a module. If so, the module + will be called "rtc-wm831x". + config RTC_DRV_WM8350 tristate "Wolfson Microelectronics WM8350 RTC" depends on MFD_WM8350
drivers/rtc/Makefile +1 -0
@@ -76,6 +76,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl4030.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
drivers/rtc/rtc-wm831x.c new file +538 -0
538 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Re: [rtc-linux] [PATCH 4/5] RTC: Add support for RTCs on Wolfson WM831x devices
Quoted 6 lines · On Mon, 10 Aug 2009 17:43:54 +0100 Mark Brown…
The WM831x series of PMICs contain RTC functionality. The hardware provides a 32 bit counter incrementing at 1Hz together with a per tick interrupt and an alarm value. For simplicity the driver chooses to define the epoch for the counter as the Unix epoch - if required platform data can be used in future to customise this.
[...]
HI, comments below:
Quoted 129 lines
Signed-off-by Mark Brown <[email protected]>Cc Alessandro Zummo <[email protected]>--- drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-wm831x.c | 538 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 549 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-wm831x.cdrivers/rtc/Kconfig +10
-0@@ -537,6 +537,16 @@ config RTC_DRV_V3020 This driver can also be built as a module. If so, the module will be called rtc-v3020. +config RTC_DRV_WM831X + tristate "Wolfson Microelectronics WM831x RTC" + depends on MFD_WM831X + help + If you say yes here you will get support for the RTC subsystem + of the Wolfson Microelectronics WM831X series PMICs. + + This driver can also be built as a module. If so, the module + will be called "rtc-wm831x". + config RTC_DRV_WM8350 tristate "Wolfson Microelectronics WM8350 RTC" depends on MFD_WM8350drivers/rtc/Makefile +1
-0@@ -76,6 +76,7 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl4030.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o +obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.odrivers/rtc/rtc-wm831x.c new file +80
-0@@ -0,0 +1,538 @@ +/* +* Real Time Clock driver for Wolfson Microelectronics WM831x +* +* Copyright (C) 2009 Wolfson Microelectronics PLC. +* +* Author: Mark Brown <[email protected]> +* +* 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. +* +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/time.h> +#include <linux/rtc.h> +#include <linux/bcd.h> +#include <linux/interrupt.h> +#include <linux/ioctl.h> +#include <linux/completion.h> +#include <linux/mfd/wm831x/core.h> +#include <linux/delay.h> +#include <linux/platform_device.h> + + +/* +* R16416 (0x4020) - RTC Write Counter +*/ +#define WM831X_RTC_WR_CNT_MASK 0xFFFF/* RTC_WR_CNT - [15:0] */ +#define WM831X_RTC_WR_CNT_SHIFT 0/* RTC_WR_CNT - [15:0] */ +#define WM831X_RTC_WR_CNT_WIDTH 16/* RTC_WR_CNT - [15:0] */ + +/* +* R16417 (0x4021) - RTC Time 1 +*/ +#define WM831X_RTC_TIME_MASK 0xFFFF/* RTC_TIME - [15:0] */ +#define WM831X_RTC_TIME_SHIFT 0/* RTC_TIME - [15:0] */ +#define WM831X_RTC_TIME_WIDTH 16/* RTC_TIME - [15:0] */ + +/* +* R16418 (0x4022) - RTC Time 2 +*/ +#define WM831X_RTC_TIME_MASK 0xFFFF/* RTC_TIME - [15:0] */ +#define WM831X_RTC_TIME_SHIFT 0/* RTC_TIME - [15:0] */ +#define WM831X_RTC_TIME_WIDTH 16/* RTC_TIME - [15:0] */ + +/* +* R16419 (0x4023) - RTC Alarm 1 +*/ +#define WM831X_RTC_ALM_MASK 0xFFFF/* RTC_ALM - [15:0] */ +#define WM831X_RTC_ALM_SHIFT 0/* RTC_ALM - [15:0] */ +#define WM831X_RTC_ALM_WIDTH 16/* RTC_ALM - [15:0] */ + +/* +* R16420 (0x4024) - RTC Alarm 2 +*/ +#define WM831X_RTC_ALM_MASK 0xFFFF/* RTC_ALM - [15:0] */ +#define WM831X_RTC_ALM_SHIFT 0/* RTC_ALM - [15:0] */ +#define WM831X_RTC_ALM_WIDTH 16/* RTC_ALM - [15:0] */ + +/* +* R16421 (0x4025) - RTC Control +*/ +#define WM831X_RTC_VALID 0x8000/* RTC_VALID */ +#define WM831X_RTC_VALID_MASK 0x8000/* RTC_VALID */ +#define WM831X_RTC_VALID_SHIFT 15/* RTC_VALID */ +#define WM831X_RTC_VALID_WIDTH 1/* RTC_VALID */ +#define WM831X_RTC_SYNC_BUSY 0x4000/* RTC_SYNC_BUSY */ +#define WM831X_RTC_SYNC_BUSY_MASK 0x4000/* RTC_SYNC_BUSY */ +#define WM831X_RTC_SYNC_BUSY_SHIFT 14/* RTC_SYNC_BUSY */ +#define WM831X_RTC_SYNC_BUSY_WIDTH 1/* RTC_SYNC_BUSY */ +#define WM831X_RTC_ALM_ENA 0x0400/* RTC_ALM_ENA */ +#define WM831X_RTC_ALM_ENA_MASK 0x0400/* RTC_ALM_ENA */ +#define WM831X_RTC_ALM_ENA_SHIFT 10/* RTC_ALM_ENA */ +#define WM831X_RTC_ALM_ENA_WIDTH 1/* RTC_ALM_ENA */ +#define WM831X_RTC_PINT_FREQ_MASK 0x0070/* RTC_PINT_FREQ - [6:4] */ +#define WM831X_RTC_PINT_FREQ_SHIFT 4/* RTC_PINT_FREQ - [6:4] */ +#define WM831X_RTC_PINT_FREQ_WIDTH 3/* RTC_PINT_FREQ - [6:4] */
drivers/rtc/rtc-wm831x.c line 90
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+ +/* +* R16422 (0x4026) - RTC Trim +*/ +#define WM831X_RTC_TRIM_MASK 0x03FF/* RTC_TRIM - [9:0] */ +#define WM831X_RTC_TRIM_SHIFT 0/* RTC_TRIM - [9:0] */ +#define WM831X_RTC_TRIM_WIDTH 10/* RTC_TRIM - [9:0] */ + +#define WM831X_SET_TIME_RETRIES 5 +#define WM831X_GET_TIME_RETRIES 5
given you have your own include directory undef mfd/ you might want to move those #defines there
drivers/rtc/rtc-wm831x.c line 96
Quoted 5 lines
drivers/rtc/rtc-wm831x.c new file +5
-0+struct wm831x_rtc { +struct wm831x *wm831x; +struct rtc_device *rtc; +int alarm_enabled; +int per_irq;
are those tows int or unsigned int?
or maybe alarm_enabled could be :1 ?
Quoted 32 lines
drivers/rtc/rtc-wm831x.c new file +32
-0+}; + +/* +* Read current time and date in RTC +*/ +static int wm831x_rtc_readtime (struct device *dev,struct rtc_time *tm) +{ +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (dev); +struct wm831x *wm831x = wm831x_rtc->wm831x; +u16 time1[2 ], time2[2 ]; +int ret; +int count =0 ; + +/* Has the RTC been programmed? */ + ret =wm831x_reg_read (wm831x,WM831X_RTC_CONTROL ); +if (ret <0 ) { +dev_err (dev,"Failed to read RTC control: %d\n" , ret); +return ret; + } +if (!(ret &WM831X_RTC_VALID )) { +dev_dbg (dev,"RTC not yet configured\n" ); +return -EINVAL ; + } + +/* Read twice to make sure we don't read a corrupt, partially +* incremented, value. +*/ + do { + ret = wm831x_bulk_read(wm831x, WM831X_RTC_TIME_1, + 2, time1); + if (ret != 0) + continue;
drivers/rtc/rtc-wm831x.c line 138
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+ + ret =wm831x_bulk_read (wm831x,WM831X_RTC_TIME_1 , +2 , time2); +if (ret !=0 ) +continue ; + +if (memcmp (time1, time2,sizeof (time1)) ==0 ) { +u32 time = (time1[0 ] <<16 ) | time1[1 ]; + +rtc_time_to_tm (time, tm);
use return rtc_valid_tm(..
Quoted 4 lines
drivers/rtc/rtc-wm831x.c new file +4
-0+return 0 ; + } + + }while (++count <WM831X_GET_TIME_RETRIES );
drivers/rtc/rtc-wm831x.c line 152
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+ +dev_err (dev,"Timed out reading current time\n" ); + +return -EIO ; +} + +/* +* Set current time and date in RTC +*/ +static int wm831x_rtc_settime (struct device *dev,struct rtc_time *tm)
isn't rtc_set_mmss more appropriate?
Quoted 221 lines
drivers/rtc/rtc-wm831x.c new file +221
-0+struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (dev); +struct wm831x *wm831x = wm831x_rtc->wm831x; +struct rtc_time new_tm; +unsigned long time, new_time; +int ret; +int count =0 ; + + ret =rtc_tm_to_time (tm, &time); +if (ret <0 ) { +dev_err (dev,"Failed to convert time: %d\n" , ret); +return ret; + } + + ret =wm831x_reg_write (wm831x,WM831X_RTC_TIME_1 , + (time >>16 ) &0xffff ); +if (ret <0 ) { +dev_err (dev,"Failed to write TIME_1: %d\n" , ret); +return ret; + } + + ret =wm831x_reg_write (wm831x,WM831X_RTC_TIME_2 , time &0xffff ); +if (ret <0 ) { +dev_err (dev,"Failed to write TIME_2: %d\n" , ret); +return ret; + } + +/* Wait for the update to complete - should happen first time +* round but be conservative. +*/ +do { +msleep (1 ); + + ret =wm831x_reg_read (wm831x,WM831X_RTC_CONTROL ); +if (ret <0 ) + ret =WM831X_RTC_SYNC_BUSY ; + }while (!(ret &WM831X_RTC_SYNC_BUSY ) && + ++count <WM831X_SET_TIME_RETRIES ); + +if (ret &WM831X_RTC_SYNC_BUSY ) { +dev_err (dev,"Timed out writing RTC update\n" ); +return -EIO ; + } + +/* Check that the update was accepted; security features may +* have caused the update to be ignored. +*/ + ret =wm831x_rtc_readtime (dev, &new_tm); +if (ret <0 ) +return ret; + + ret =rtc_tm_to_time (&new_tm, &new_time); +if (ret <0 ) { +dev_err (dev,"Failed to convert time: %d\n" , ret); +return ret; + } + +/* Allow a second of change in case of tick */ +if (new_time - time >1 ) { +dev_err (dev,"RTC update not permitted by hardware\n" ); +return -EPERM ; + } + +return 0 ; +} + +/* +* Read alarm time and date in RTC +*/ +static int wm831x_rtc_readalarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (dev); +int ret; +u16 data[2 ]; +u32 time; + + ret =wm831x_bulk_read (wm831x_rtc->wm831x,WM831X_RTC_ALARM_1 , +2 , data); +if (ret !=0 ) { +dev_err (dev,"Failed to read alarm time: %d\n" , ret); +return ret; + } + + time = (data[0 ] <<16 ) | data[1 ]; + +rtc_time_to_tm (time, &alrm->time); + + ret =wm831x_reg_read (wm831x_rtc->wm831x,WM831X_RTC_CONTROL ); +if (ret <0 ) { +dev_err (dev,"Failed to read RTC control: %d\n" , ret); +return ret; + } + +if (ret &WM831X_RTC_ALM_ENA ) + alrm->enabled =1 ; +else + alrm->enabled =0 ; + +return 0 ; +} + +static int wm831x_rtc_stop_alarm (struct wm831x_rtc *wm831x_rtc) +{ + wm831x_rtc->alarm_enabled =0 ; + +return wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA ,0 ); +} + +static int wm831x_rtc_start_alarm (struct wm831x_rtc *wm831x_rtc) +{ + wm831x_rtc->alarm_enabled =1 ; + +return wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA ,WM831X_RTC_ALM_ENA ); +} + +static int wm831x_rtc_setalarm (struct device *dev,struct rtc_wkalrm *alrm) +{ +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (dev); +struct wm831x *wm831x = wm831x_rtc->wm831x; +int ret; +unsigned long time; + + ret =rtc_tm_to_time (&alrm->time, &time); +if (ret <0 ) { +dev_err (dev,"Failed to convert time: %d\n" , ret); +return ret; + } + + ret =wm831x_rtc_stop_alarm (wm831x_rtc); +if (ret <0 ) { +dev_err (dev,"Failed to stop alarm: %d\n" , ret); +return ret; + } + + ret =wm831x_reg_write (wm831x,WM831X_RTC_ALARM_1 , + (time >>16 ) &0xffff ); +if (ret <0 ) { +dev_err (dev,"Failed to write ALARM_1: %d\n" , ret); +return ret; + } + + ret =wm831x_reg_write (wm831x,WM831X_RTC_ALARM_2 , time &0xffff ); +if (ret <0 ) { +dev_err (dev,"Failed to write ALARM_2: %d\n" , ret); +return ret; + } + +if (alrm->enabled) { + ret =wm831x_rtc_start_alarm (wm831x_rtc); +if (ret <0 ) { +dev_err (dev,"Failed to start alarm: %d\n" , ret); +return ret; + } + } + +return 0 ; +} + +static int wm831x_rtc_alarm_irq_enable (struct device *dev, +unsigned int enabled) +{ +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (dev); + +if (enabled) +return wm831x_rtc_start_alarm (wm831x_rtc); +else +return wm831x_rtc_stop_alarm (wm831x_rtc); +} + +static int wm831x_rtc_update_irq_enable (struct device *dev, +unsigned int enabled) +{ +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (dev); +int val; + +if (enabled) + val =1 <<WM831X_RTC_PINT_FREQ_SHIFT ; +else + val =0 ; + +return wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_PINT_FREQ_MASK , val); +} + +static irqreturn_t wm831x_alm_irq (int irq,void *data) +{ +struct wm831x_rtc *wm831x_rtc = data; + +rtc_update_irq (wm831x_rtc->rtc,1 ,RTC_IRQF |RTC_AF ); + +return IRQ_HANDLED ; +} + +static irqreturn_t wm831x_per_irq (int irq,void *data) +{ +struct wm831x_rtc *wm831x_rtc = data; + +rtc_update_irq (wm831x_rtc->rtc,1 ,RTC_IRQF |RTC_UF ); + +return IRQ_HANDLED ; +} + +static const struct rtc_class_ops wm831x_rtc_ops = { + .read_time = wm831x_rtc_readtime, + .set_time = wm831x_rtc_settime, + .read_alarm = wm831x_rtc_readalarm, + .set_alarm = wm831x_rtc_setalarm, + .alarm_irq_enable = wm831x_rtc_alarm_irq_enable, + .update_irq_enable = wm831x_rtc_update_irq_enable, +}; + +#ifdef CONFIG_PM +/* Turn off the alarm if it should not be a wake source. */ +static int wm831x_rtc_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (&pdev->dev); +int ret, enable; + +if (wm831x_rtc->alarm_enabled &&device_may_wakeup (&pdev->dev))
drivers/rtc/rtc-wm831x.c line 384
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+ enable =WM831X_RTC_ALM_ENA ; + else + enable =0 ; + + ret =wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA , enable); +if (ret !=0 ) +dev_err (&pdev->dev,"Failed to update RTC alarm: %d\n" , ret); + +return 0 ;
always 0 ? (also below..)
Quoted 62 lines
drivers/rtc/rtc-wm831x.c new file +62
-0+} + +/* Enable the alarm if it should be enabled (in case it was disabled to +* prevent use as a wake source). +*/ +static int wm831x_rtc_resume (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (&pdev->dev); +int ret; + +if (wm831x_rtc->alarm_enabled) { + ret =wm831x_rtc_start_alarm (wm831x_rtc); +if (ret !=0 ) +dev_err (&pdev->dev, +"Failed to restart RTC alarm: %d\n" , ret); + } + +return 0 ; +} + +/* Unconditionally disable the alarm */ +static int wm831x_rtc_freeze (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct wm831x_rtc *wm831x_rtc =dev_get_drvdata (&pdev->dev); +int ret; + + ret =wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA ,0 ); +if (ret !=0 ) +dev_err (&pdev->dev,"Failed to stop RTC alarm: %d\n" , ret); + +return 0 ; +} +#else +#define wm831x_rtc_suspend NULL +#define wm831x_rtc_resume NULL +#define wm831x_rtc_freeze NULL +#endif + +static int wm831x_rtc_probe (struct platform_device *pdev) +{ +struct wm831x *wm831x =dev_get_drvdata (pdev->dev.parent); +struct wm831x_rtc *wm831x_rtc; +int per_irq =platform_get_irq_byname (pdev,"PER" ); +int alm_irq =platform_get_irq_byname (pdev,"ALM" ); +int ret =0 ; + + wm831x_rtc =kzalloc (sizeof (*wm831x_rtc),GFP_KERNEL ); +if (wm831x_rtc ==NULL ) +return -ENOMEM ; + +platform_set_drvdata (pdev, wm831x_rtc); + wm831x_rtc->wm831x = wm831x; + wm831x_rtc->per_irq = per_irq; + + ret =wm831x_reg_read (wm831x,WM831X_RTC_CONTROL ); +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to read RTC control: %d\n" , ret); + goto err; + }
drivers/rtc/rtc-wm831x.c line 456
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+if (ret &WM831X_RTC_ALM_ENA ) + wm831x_rtc->alarm_enabled =1 ; + +device_init_wakeup (&pdev->dev,1 ); + + wm831x_rtc->rtc =rtc_device_register ("wm831x" , &pdev->dev, + &wm831x_rtc_ops,THIS_MODULE ); +if (IS_ERR (wm831x_rtc->rtc)) { + ret =PTR_ERR (wm831x_rtc->rtc); +dev_err (&pdev->dev,"Failed to register RTC: %d\n" , ret);
useless, rtc core will emit his own message.
drivers/rtc/rtc-wm831x.c line 465
Quoted 9 lines
drivers/rtc/rtc-wm831x.c new file +9
-0+ goto err; + } + + ret =wm831x_request_irq (wm831x, per_irq, wm831x_per_irq, +IRQF_TRIGGER_RISING ,"wm831x_rtc_per" , + wm831x_rtc); +if (ret !=0 ) { +dev_err (&pdev->dev,"Failed to request periodic IRQ %d: %d\n" , + per_irq, ret);
can't the rtc work without the periodic irq?
drivers/rtc/rtc-wm831x.c line 474
Quoted 9 lines
drivers/rtc/rtc-wm831x.c new file +9
-0+ goto err_rtc; + } + + ret =wm831x_request_irq (wm831x, alm_irq, wm831x_alm_irq, +IRQF_TRIGGER_RISING ,"wm831x_rtc_alm" , + wm831x_rtc); +if (ret !=0 ) { +dev_err (&pdev->dev,"Failed to request alarm IRQ %d: %d\n" , + alm_irq, ret);
ditto.
Quoted 9 lines
drivers/rtc/rtc-wm831x.c new file +9
-0+ goto err_per; + } + +return 0 ; + +err_per: +wm831x_free_irq (wm831x, per_irq, wm831x_rtc); +err_rtc: +rtc_device_unregister (wm831x_rtc->rtc);
drivers/rtc/rtc-wm831x.c line 493
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+err: +kfree (wm831x_rtc); +return ret; +} + +static int __devexit wm831x_rtc_remove(struct platform_device *pdev) +{ +struct wm831x_rtc *wm831x_rtc =platform_get_drvdata (pdev); +int per_irq =platform_get_irq (pdev,0 ); +int alm_irq =platform_get_irq (pdev,1 );
why not _byname() ?
Quoted 22 lines
drivers/rtc/rtc-wm831x.c new file +22
-0+ +wm831x_free_irq (wm831x_rtc->wm831x, alm_irq, wm831x_rtc); +wm831x_free_irq (wm831x_rtc->wm831x, per_irq, wm831x_rtc); +rtc_device_unregister (wm831x_rtc->rtc); +kfree (wm831x_rtc); + +return 0 ; +} + +static struct dev_pm_ops wm831x_rtc_pm_ops = { + .suspend = wm831x_rtc_suspend, + .resume = wm831x_rtc_resume, + + .freeze = wm831x_rtc_freeze, + .thaw = wm831x_rtc_resume, + .restore = wm831x_rtc_resume, + + .poweroff = wm831x_rtc_suspend, +}; + +static struct platform_driver wm831x_rtc_driver = { + .probe = wm831x_rtc_probe,
drivers/rtc/rtc-wm831x.c line 525
Quoted 10 lines
drivers/rtc/rtc-wm831x.c new file +10
-0+ .remove = __devexit_p(wm831x_rtc_remove), + .driver = { + .name = "wm831x-rtc", + .pm = &wm831x_rtc_pm_ops, + }, +}; + +static int __init wm831x_rtc_init (void ) +{ +return platform_driver_register (&wm831x_rtc_driver);
can you use platform_driver_probe() ?
Quoted 24 lines
drivers/rtc/rtc-wm831x.c new file +13
-0+} +module_init (wm831x_rtc_init); + +static void __exit wm831x_rtc_exit(void) +{ +platform_driver_unregister (&wm831x_rtc_driver); +} +module_exit (wm831x_rtc_exit); + +MODULE_AUTHOR ("Mark Brown <[email protected]>" ); +MODULE_DESCRIPTION ("RTC driver for the WM831x series PMICs" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:wm831x-rtc" );Signature · 9 lines
1.6.3.3 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~---
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Torino, Italy http://www.towertech.it
Re: [rtc-linux] [PATCH 4/5] RTC: Add support for RTCs on Wolfson WM831x devices
Quoted 4 lines · Alessandro Zummo
Mark Brown <[email protected]> wrote:
given you have your own include directory undef mfd/ you might want to move those #defines there
Unlike the others these registers can't really be used outside of this driver - for the other drivers there's potential for at least platform specific code if not multiple drivers to use some or all of the register definitions.
Quoted 7 lines
drivers/rtc/rtc-wm831x.c line 96
Quoted 5 lines
drivers/rtc/rtc-wm831x.c new file +5
-0+struct wm831x_rtc { +struct wm831x *wm831x; +struct rtc_device *rtc; +int alarm_enabled; +int per_irq;are those tows int or unsigned int?
I've just dropped per_irq, it's not needed anyway.
Quoted 1 line
or maybe
alarm_enabledcould be :1 ?
Done, but it doesn't really buy us much given that there's nothing else to pack it with.
Quoted 6 lines
drivers/rtc/rtc-wm831x.c line 152
Quoted 4 lines
drivers/rtc/rtc-wm831x.c new file +4
-0+/* +* Set current time and date in RTC +*/ +static int wm831x_rtc_settime (struct device *dev,struct rtc_time *tm)isn't
rtc_set_mmssmore appropriate?
Hrm, I think so so I've made the change. It's not a particularly discoverable API - the fact that there's no readback equivalent hides the fact that it's supposed to be an equivalent for settime. Some documentation would really help here.
Quoted 8 lines
drivers/rtc/rtc-wm831x.c line 384
Quoted 6 lines
drivers/rtc/rtc-wm831x.c new file +6
-0+ ret =wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA , enable); +if (ret !=0 ) +dev_err (&pdev->dev,"Failed to update RTC alarm: %d\n" , ret); + +return 0 ;always 0 ? (also below..)
Failing suspend and resume due to failure to disable the RTC alarm would be excessive - indeed, I'd expect the overwhelming majority of systems to function perfectly well with no suspend/resume support in the driver at all. RTC alarms are infrequent relative to other suspend/resume events in typical systems but suspend is normally used fairly heavily to preserve battery (typical applications include things like MP3 players or phones). Typically the error handling would at best cause more serious consequences than the original error and there's little chance the user will be able to even report the error.
Quoted 5 lines
drivers/rtc/rtc-wm831x.c line 525
Quoted 3 lines
drivers/rtc/rtc-wm831x.c new file +3
-0+static int __init wm831x_rtc_init (void ) +{ +return platform_driver_register (&wm831x_rtc_driver);can you use
platform_driver_probe()?
No, this is a MFD accessed over slow buses and we can't guarantee that the device will be registered.
Fixed everything else, will repost tomorrow.
Alessandro Zummo
Acked-byRe: [rtc-linux] Re: [PATCH 4/5] RTC: Add support for RTCs on Wolfson WM831x devices
Quoted 8 lines · On Mon, 10 Aug 2009 21:57:13 +0100 Mark Brown…
Quoted 3 lines
given you have your own include directory undef mfd/ you might want to move those #defines there
Unlike the others these registers can't really be used outside of this driver - for the other drivers there's potential for at least platform specific code if not multiple drivers to use some or all of the register definitions.
ack.
Quoted 8 lines
Quoted 7 lines
drivers/rtc/rtc-wm831x.c line 96
Quoted 5 lines
drivers/rtc/rtc-wm831x.c new file +5
-0+struct wm831x_rtc { +struct wm831x *wm831x; +struct rtc_device *rtc; +int alarm_enabled; +int per_irq;are those tows int or unsigned int?
Quoted 6 lines
I've just dropped
per_irq, it's not needed anyway.Quoted 1 line
or maybe
alarm_enabledcould be :1 ?Done, but it doesn't really buy us much given that there's nothing else to pack it with.
ack.
Quoted 11 lines
Quoted 6 lines
drivers/rtc/rtc-wm831x.c line 152
Quoted 4 lines
drivers/rtc/rtc-wm831x.c new file +4
-0+/* +* Set current time and date in RTC +*/ +static int wm831x_rtc_settime (struct device *dev,struct rtc_time *tm)isn't
rtc_set_mmssmore appropriate?Hrm, I think so so I've made the change. It's not a particularly discoverable API - the fact that there's no readback equivalent hides the fact that it's supposed to be an equivalent for settime. Some documentation would really help here.
you're right. there's one but it's still in my tree. will push it one day.
Quoted 10 lines
Quoted 9 lines
drivers/rtc/rtc-wm831x.c line 384
Quoted 7 lines
drivers/rtc/rtc-wm831x.c new file +6
-0+ ret =wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA , enable); +if (ret !=0 ) +dev_err (&pdev->dev,"Failed to update RTC alarm: %d\n" , ret); + +return 0 ;always 0 ? (also below..)
Quoted 9 lines
Failing suspend and resume due to failure to disable the RTC alarm would be excessive - indeed, I'd expect the overwhelming majority of systems to function perfectly well with no suspend/resume support in the driver at all. RTC alarms are infrequent relative to other suspend/resume events in typical systems but suspend is normally used fairly heavily to preserve battery (typical applications include things like MP3 players or phones). Typically the error handling would at best cause more serious consequences than the original error and there's little chance the user will be able to even report the error.
ack.
Quoted 10 lines
Quoted 5 lines
drivers/rtc/rtc-wm831x.c line 525
Quoted 3 lines
drivers/rtc/rtc-wm831x.c new file +3
-0+static int __init wm831x_rtc_init (void ) +{ +return platform_driver_register (&wm831x_rtc_driver);can you use
platform_driver_probe()?No, this is a MFD accessed over slow buses and we can't guarantee that the device will be registered.
Fixed everything else, will repost tomorrow.
here's my acked-by in advance, feel free to push the patch with the series.
Signature · 6 lines
Best regards, Alessandro Zummo, Tower Technologies - Torino, Italy http://www.towertech.it
Re: [rtc-linux] Re: [PATCH 4/5] RTC: Add support for RTCs on Wolfson WM831x devices
Hi Alessandro,
Quoted 77 lines · Alessandro Zummo
Quoted 8 lines · On Mon, 10 Aug 2009 21:57:13 +0100 Mark Brown…
Quoted 3 lines
given you have your own include directory undef mfd/ you might want to move those #defines there
Unlike the others these registers can't really be used outside of this driver - for the other drivers there's potential for at least platform specific code if not multiple drivers to use some or all of the register definitions.
ack.
Quoted 8 lines
Quoted 7 lines
drivers/rtc/rtc-wm831x.c line 96
Quoted 5 lines
drivers/rtc/rtc-wm831x.c new file +5
-0+struct wm831x_rtc { +struct wm831x *wm831x; +struct rtc_device *rtc; +int alarm_enabled; +int per_irq;are those tows int or unsigned int?
Quoted 6 lines
I've just dropped
per_irq, it's not needed anyway.Quoted 1 line
or maybe
alarm_enabledcould be :1 ?Done, but it doesn't really buy us much given that there's nothing else to pack it with.
ack.
Quoted 11 lines
Quoted 6 lines
drivers/rtc/rtc-wm831x.c line 152
Quoted 4 lines
drivers/rtc/rtc-wm831x.c new file +4
-0+/* +* Set current time and date in RTC +*/ +static int wm831x_rtc_settime (struct device *dev,struct rtc_time *tm)isn't
rtc_set_mmssmore appropriate?Hrm, I think so so I've made the change. It's not a particularly discoverable API - the fact that there's no readback equivalent hides the fact that it's supposed to be an equivalent for settime. Some documentation would really help here.
you're right. there's one but it's still in my tree. will push it one day.
Quoted 10 lines
Quoted 9 lines
drivers/rtc/rtc-wm831x.c line 384
Quoted 7 lines
drivers/rtc/rtc-wm831x.c new file +6
-0+ ret =wm831x_set_bits (wm831x_rtc->wm831x,WM831X_RTC_CONTROL , +WM831X_RTC_ALM_ENA , enable); +if (ret !=0 ) +dev_err (&pdev->dev,"Failed to update RTC alarm: %d\n" , ret); + +return 0 ;always 0 ? (also below..)
Quoted 9 lines
Failing suspend and resume due to failure to disable the RTC alarm would be excessive - indeed, I'd expect the overwhelming majority of systems to function perfectly well with no suspend/resume support in the driver at all. RTC alarms are infrequent relative to other suspend/resume events in typical systems but suspend is normally used fairly heavily to preserve battery (typical applications include things like MP3 players or phones). Typically the error handling would at best cause more serious consequences than the original error and there's little chance the user will be able to even report the error.
ack.
Quoted 9 lines
Quoted 5 lines
drivers/rtc/rtc-wm831x.c line 525
Quoted 3 lines
drivers/rtc/rtc-wm831x.c new file +3
-0+static int __init wm831x_rtc_init (void ) +{ +return platform_driver_register (&wm831x_rtc_driver);can you use
platform_driver_probe()?No, this is a MFD accessed over slow buses and we can't guarantee that the device will be registered.
Quoted 6 lines
Quoted 1 line
Fixed everything else, will repost tomorrow.
here's my acked-by in advance, feel free to push the patch with the series.
Acked-by Alessandro Zummo <[email protected]>
Thanks, patch applied.
Cheers,
Samuel.
Quoted 11 lines
Signature · 8 lines
-- Best regards, Alessandro Zummo, Tower Technologies - Torino, Italy http://www.towertech.it
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
PATCH 5/5 Add support for WM831x watchdog
In reply to Mark BrownThe WM831x series of devices provide a watchdog with configurable behaviour on timer expiry.
Currently this driver support refreshes via a register or GPIO line and autonomous refreshes from a hardware source (eg, a clock).
--- drivers/watchdog/Kconfig | 7 + drivers/watchdog/Makefile | 1 + drivers/watchdog/wm831x_wdt.c | 441 +++++++++++++++++++++++++++++++++++ include/linux/mfd/wm831x/watchdog.h | 52 ++++ 4 files changed, 501 insertions(+), 0 deletions(-) create mode 100644 drivers/watchdog/wm831x_wdt.c create mode 100644 include/linux/mfd/wm831x/watchdog.h
drivers/watchdog/Kconfig +7 -0
@@ -55,6 +55,13 @@ config SOFT_WATCHDOG To compile this driver as a module, choose M here: the module will be called softdog. +config WM831X_WATCHDOG + tristate "WM831x watchdog" + depends on MFD_WM831X + help + Support for the watchdog in the WM831x AudioPlus PMICs. When + the watchdog triggers the system will be reset. + config WM8350_WATCHDOG tristate "WM8350 watchdog" depends on MFD_WM8350
drivers/watchdog/Makefile +1 -0
@@ -140,5 +140,6 @@ obj-$(CONFIG_WATCHDOG_CP1XXX) += cpwd.o # XTENSA Architecture # Architecture Independant +obj-$(CONFIG_WM831X_WATCHDOG) += wm831x_wdt.o obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
drivers/watchdog/wm831x_wdt.c new file +441 -0
441 lines not on this page · raw message
include/linux/mfd/wm831x/watchdog.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Re: [PATCH 5/5] [WATCHDOG] Add support for WM831x watchdog
Hi Mark,
Quoted 8 lines
The WM831x series of devices provide a watchdog with configurable behaviour on timer expiry.
Currently this driver support refreshes via a register or GPIO line and autonomous refreshes from a hardware source (eg, a clock).
Signed-off-by Mark Brown <[email protected]>Cc Wim Van Sebroeck <[email protected]>
Will review this the coming week.
Kind regards,
Wim.
Re: [PATCH 5/5] [WATCHDOG] Add support for WM831x watchdog
In reply to Mark BrownHi Mark,
Quoted 8 lines
The WM831x series of devices provide a watchdog with configurable behaviour on timer expiry.
Currently this driver support refreshes via a register or GPIO line and autonomous refreshes from a hardware source (eg, a clock).
Signed-off-by Mark Brown <[email protected]>Cc Wim Van Sebroeck <[email protected]>
the driver is OK. Just 2 small remarks:
drivers/watchdog/wm831x_wdt.c line 219
Quoted 4 lines
drivers/watchdog/wm831x_wdt.c new file +4
-0+static struct watchdog_info ident = { + .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING |WDIOF_MAGICCLOSE , + .identity ="WM831x Watchdog" , +};
this can be static const struct in the future (need to do a clean-up on that).
include/linux/mfd/wm831x/watchdog.h line 47
Quoted 6 lines
include/linux/mfd/wm831x/watchdog.h new file +6
-0+#define WM831X_WDOG_SECACT_MASK 0x0300/* WDOG_SECACT - [9:8] */ +#define WM831X_WDOG_SECACT_SHIFT 8/* WDOG_SECACT - [9:8] */ +#define WM831X_WDOG_SECACT_WIDTH 2/* WDOG_SECACT - [9:8] */ +#define WM831X_WDOG_PRIMACT_MASK 0x0030/* WDOG_PRIMACT - [5:4] */ +#define WM831X_WDOG_PRIMACT_SHIFT 4/* WDOG_PRIMACT - [5:4] */ +#define WM831X_WDOG_PRIMACT_WIDTH 2/* WDOG_PRIMACT - [5:4] */
These lines exceed 80 characters. Is there any reason why we can't reduce the spacing between the name and the value?
Just let me know how we will proceed on my second question. I can then add this to the linux-2.6-watchdog-next tree.
Kind regards,
Wim.
Re: [PATCH 5/5] [WATCHDOG] Add support for WM831x watchdog
Quoted 5 lines · Wim Van Sebroeck
Quoted 1 line
+#define
WM831X_WDOG_PRIMACT_WIDTH2 /*WDOG_PRIMACT- [5:4] */These lines exceed 80 characters. Is there any reason why we can't reduce the spacing between the name and the value?
Just let me know how we will proceed on my second question. I can then add this to the linux-2.6-watchdog-next tree.
The register definitions are automatically generated using the chip design information using a tool which I'm not the only user for. It simplifies maintinance to keep the output code as-is since it allows easier comparison with future devices with the same or similar IP in them. If anything were done I'd remove the comments.
Re: [PATCH 5/5] [WATCHDOG] Add support for WM831x watchdog
In reply to Mark BrownHi Mark,
Quoted 5 lines
The WM831x series of devices provide a watchdog with configurable behaviour on timer expiry.
Currently this driver support refreshes via a register or GPIO line and autonomous refreshes from a hardware source (eg, a clock).
Added this driver to the linux-2.6-watchdog-next tree.
Kind regards,
Wim.