15 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/slab.h>
18 #include <linux/i2c.h>
105 unsigned short mask,
unsigned short val)
111 static struct mfd_cell wm8994_regulator_devs[] = {
113 .name =
"wm8994-ldo",
115 .pm_runtime_no_callbacks =
true,
118 .name =
"wm8994-ldo",
120 .pm_runtime_no_callbacks =
true,
124 static struct resource wm8994_codec_resources[] = {
132 static struct resource wm8994_gpio_resources[] = {
140 static struct mfd_cell wm8994_devs[] = {
142 .name =
"wm8994-codec",
143 .num_resources =
ARRAY_SIZE(wm8994_codec_resources),
144 .resources = wm8994_codec_resources,
148 .
name =
"wm8994-gpio",
149 .num_resources =
ARRAY_SIZE(wm8994_gpio_resources),
150 .resources = wm8994_gpio_resources,
151 .pm_runtime_no_callbacks =
true,
160 static const char *wm1811_main_supplies[] = {
172 static const char *wm8994_main_supplies[] = {
182 static const char *wm8958_main_supplies[] = {
195 static int wm8994_suspend(
struct device *
dev)
204 dev_err(dev,
"Failed to read power status: %d\n", ret);
206 dev_dbg(dev,
"CODEC still active, ignoring suspend\n");
212 dev_err(dev,
"Failed to read power status: %d\n", ret);
216 dev_dbg(dev,
"CODEC still active, ignoring suspend\n");
222 dev_err(dev,
"Failed to read power status: %d\n", ret);
226 dev_dbg(dev,
"CODEC still active, ignoring suspend\n");
230 switch (wm8994->
type) {
235 dev_err(dev,
"Failed to read power status: %d\n", ret);
237 dev_dbg(dev,
"CODEC still active, ignoring suspend\n");
245 switch (wm8994->
type) {
249 dev_err(dev,
"Failed to read jackdet: %d\n", ret);
251 dev_dbg(dev,
"CODEC still active, ignoring suspend\n");
259 switch (wm8994->
type) {
263 dev_err(dev,
"Failed to read jackdet: %d\n", ret);
265 dev_dbg(dev,
"CODEC still active, ignoring suspend\n");
294 dev_err(dev,
"Failed to restore GPIO registers: %d\n", ret);
301 dev_err(dev,
"Failed to restore interrupt mask: %d\n", ret);
309 dev_err(dev,
"Failed to disable supplies: %d\n", ret);
316 static int wm8994_resume(
struct device *dev)
328 dev_err(dev,
"Failed to enable supplies: %d\n", ret);
335 dev_err(dev,
"Failed to restore register map: %d\n", ret);
355 #ifdef CONFIG_REGULATOR
363 ldo_pdata = &pdata->
ldo[ldo];
368 return ldo_pdata->
init_data->num_consumer_supplies != 0;
371 static int wm8994_ldo_in_use(
struct wm8994_pdata *pdata,
int ldo)
402 static __devinit int wm8994_device_init(
struct wm8994 *wm8994,
int irq)
405 struct regmap_config *regmap_config;
408 int ret,
i, patch_regs;
415 wm8994_regulator_devs,
419 dev_err(wm8994->
dev,
"Failed to add children: %d\n", ret);
423 switch (wm8994->
type) {
446 switch (wm8994->
type) {
448 for (i = 0; i <
ARRAY_SIZE(wm1811_main_supplies); i++)
449 wm8994->
supplies[i].supply = wm1811_main_supplies[i];
453 wm8994->
supplies[i].supply = wm8994_main_supplies[i];
457 wm8994->
supplies[i].supply = wm8958_main_supplies[i];
467 dev_err(wm8994->
dev,
"Failed to get supplies: %d\n", ret);
474 dev_err(wm8994->
dev,
"Failed to enable supplies: %d\n", ret);
480 dev_err(wm8994->
dev,
"Failed to read ID register\n");
487 dev_warn(wm8994->
dev,
"Device registered as type %d\n",
494 dev_warn(wm8994->
dev,
"Device registered as type %d\n",
501 dev_warn(wm8994->
dev,
"Device registered as type %d\n",
506 dev_err(wm8994->
dev,
"Device is not a WM8994, ID is %x\n",
514 dev_err(wm8994->
dev,
"Failed to read revision register: %d\n",
521 switch (wm8994->
type) {
527 "revision %c not fully supported\n",
532 regmap_patch = wm8994_revc_patch;
543 regmap_patch = wm8958_reva_patch;
560 regmap_patch = wm1811_reva_patch;
572 dev_info(wm8994->
dev,
"%s revision %c CUST_ID %02x\n", devname,
575 switch (wm8994->
type) {
592 dev_err(wm8994->
dev,
"Failed to reinit register cache: %d\n",
601 dev_err(wm8994->
dev,
"Failed to register patch: %d\n",
639 if (wm8994_ldo_in_use(pdata, i))
653 dev_err(wm8994->
dev,
"Failed to add children: %d\n", ret);
658 pm_runtime_idle(wm8994->
dev);
674 static __devexit void wm8994_device_exit(
struct wm8994 *wm8994)
676 pm_runtime_disable(wm8994->
dev);
685 { .compatible =
"wlf,wm1811", },
686 { .compatible =
"wlf,wm8994", },
687 { .compatible =
"wlf,wm8958", },
695 struct wm8994 *wm8994;
702 i2c_set_clientdata(i2c, wm8994);
705 wm8994->
type =
id->driver_data;
708 if (IS_ERR(wm8994->
regmap)) {
709 ret = PTR_ERR(wm8994->
regmap);
710 dev_err(wm8994->
dev,
"Failed to allocate register map: %d\n",
715 return wm8994_device_init(wm8994, i2c->
irq);
720 struct wm8994 *wm8994 = i2c_get_clientdata(i2c);
722 wm8994_device_exit(wm8994);
739 static struct i2c_driver wm8994_i2c_driver = {
743 .pm = &wm8994_pm_ops,
744 .of_match_table = wm8994_of_match,
746 .probe = wm8994_i2c_probe,
748 .id_table = wm8994_i2c_id,