Skip to content

Commit 523d9cf

Browse files
committed
mfd: Support software initiated shutdown of WM831x PMICs
In systems where there is no hardware signal from the processor to the PMIC to initiate the final power off sequence we must initiate the shutdown with a register write to the PMIC. Support such systems in the driver. Since this may prevent a full shutdown of the system platform data is used to enable the feature. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
1 parent 92afb28 commit 523d9cf

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/mfd/wm831x-core.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/mfd/wm831x/irq.h>
2626
#include <linux/mfd/wm831x/auxadc.h>
2727
#include <linux/mfd/wm831x/otp.h>
28+
#include <linux/mfd/wm831x/pmu.h>
2829
#include <linux/mfd/wm831x/regulator.h>
2930

3031
/* Current settings - values are 2*2^(reg_val/4) microamps. These are
@@ -1621,6 +1622,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq)
16211622
mutex_init(&wm831x->io_lock);
16221623
mutex_init(&wm831x->key_lock);
16231624
dev_set_drvdata(wm831x->dev, wm831x);
1625+
wm831x->soft_shutdown = pdata->soft_shutdown;
16241626

16251627
ret = wm831x_reg_read(wm831x, WM831X_PARENT_ID);
16261628
if (ret < 0) {
@@ -1922,6 +1924,15 @@ int wm831x_device_suspend(struct wm831x *wm831x)
19221924
return 0;
19231925
}
19241926

1927+
void wm831x_device_shutdown(struct wm831x *wm831x)
1928+
{
1929+
if (wm831x->soft_shutdown) {
1930+
dev_info(wm831x->dev, "Initiating shutdown...\n");
1931+
wm831x_set_bits(wm831x, WM831X_POWER_STATE, WM831X_CHIP_ON, 0);
1932+
}
1933+
}
1934+
EXPORT_SYMBOL_GPL(wm831x_device_shutdown);
1935+
19251936
MODULE_DESCRIPTION("Core support for the WM831X AudioPlus PMIC");
19261937
MODULE_LICENSE("GPL");
19271938
MODULE_AUTHOR("Mark Brown");

‎drivers/mfd/wm831x-i2c.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ static int wm831x_i2c_suspend(struct device *dev)
6565
return wm831x_device_suspend(wm831x);
6666
}
6767

68+
static void wm831x_i2c_shutdown(struct i2c_client *i2c)
69+
{
70+
struct wm831x *wm831x = i2c_get_clientdata(i2c);
71+
72+
wm831x_device_shutdown(wm831x);
73+
}
74+
6875
static const struct i2c_device_id wm831x_i2c_id[] = {
6976
{ "wm8310", WM8310 },
7077
{ "wm8311", WM8311 },
@@ -89,6 +96,7 @@ static struct i2c_driver wm831x_i2c_driver = {
8996
},
9097
.probe = wm831x_i2c_probe,
9198
.remove = wm831x_i2c_remove,
99+
.shutdown = wm831x_i2c_shutdown,
92100
.id_table = wm831x_i2c_id,
93101
};
94102

‎drivers/mfd/wm831x-spi.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ static int wm831x_spi_suspend(struct device *dev)
6868
return wm831x_device_suspend(wm831x);
6969
}
7070

71+
static void wm831x_spi_shutdown(struct spi_device *spi)
72+
{
73+
struct wm831x *wm831x = dev_get_drvdata(&spi->dev);
74+
75+
wm831x_device_shutdown(wm831x);
76+
}
77+
7178
static const struct dev_pm_ops wm831x_spi_pm = {
7279
.freeze = wm831x_spi_suspend,
7380
.suspend = wm831x_spi_suspend,
@@ -95,6 +102,7 @@ static struct spi_driver wm831x_spi_driver = {
95102
.id_table = wm831x_spi_ids,
96103
.probe = wm831x_spi_probe,
97104
.remove = __devexit_p(wm831x_spi_remove),
105+
.shutdown = wm831x_spi_shutdown,
98106
};
99107

100108
static int __init wm831x_spi_init(void)

‎include/linux/mfd/wm831x/core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ struct wm831x {
371371
int irq_masks_cur[WM831X_NUM_IRQ_REGS]; /* Currently active value */
372372
int irq_masks_cache[WM831X_NUM_IRQ_REGS]; /* Cached hardware value */
373373

374+
bool soft_shutdown;
375+
374376
/* Chip revision based flags */
375377
unsigned has_gpio_ena:1; /* Has GPIO enable bit */
376378
unsigned has_cs_sts:1; /* Has current sink status bit */
@@ -409,6 +411,7 @@ int wm831x_bulk_read(struct wm831x *wm831x, unsigned short reg,
409411
int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq);
410412
void wm831x_device_exit(struct wm831x *wm831x);
411413
int wm831x_device_suspend(struct wm831x *wm831x);
414+
void wm831x_device_shutdown(struct wm831x *wm831x);
412415
int wm831x_irq_init(struct wm831x *wm831x, int irq);
413416
void wm831x_irq_exit(struct wm831x *wm831x);
414417
void wm831x_auxadc_init(struct wm831x *wm831x);

‎include/linux/mfd/wm831x/pdata.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ struct wm831x_pdata {
123123
/** Disable the touchscreen */
124124
bool disable_touch;
125125

126+
/** The driver should initiate a power off sequence during shutdown */
127+
bool soft_shutdown;
128+
126129
int irq_base;
127130
int gpio_base;
128131
int gpio_defaults[WM831X_GPIO_NUM];

0 commit comments

Comments
 (0)