15 #include <linux/kernel.h>
16 #include <linux/module.h>
18 #include <linux/slab.h>
20 #include <linux/device.h>
35 #define WM8350_CLOCK_CONTROL_1 0x28
36 #define WM8350_AIF_TEST 0x74
39 #define WM8350_BUS_DEBUG 0
41 #define dump(regs, src) do { \
45 for (i_ = 0; i_ < regs; i_++) \
46 printk(" 0x%4.4x", *src_++); \
50 #define dump(bytes, src)
53 #define WM8350_LOCK_DEBUG 0
55 #define ldbg(format, arg...) printk(format, ## arg)
57 #define ldbg(format, arg...)
87 dev_err(wm8350->
dev,
"read from reg R%d failed\n", reg);
100 dev_err(wm8350->
dev,
"write to reg R%d failed\n", reg);
112 dev_err(wm8350->
dev,
"block read starting from R%d failed\n",
126 dev_err(wm8350->
dev,
"block write starting at R%d failed\n",
196 && (scale != 0 || vref != 0))
226 dev_err(wm8350->
dev,
"adc chn %d read timeout\n", channel);
255 static void wm8350_client_dev_register(
struct wm8350 *
wm8350,
263 dev_err(wm8350->
dev,
"Failed to allocate %s\n", name);
267 (*pdev)->dev.parent = wm8350->
dev;
268 platform_set_drvdata(*pdev, wm8350);
271 dev_err(wm8350->
dev,
"Failed to register %s: %d\n", name, ret);
281 unsigned int id1,
id2, mask_rev;
282 unsigned int cust_id,
mode, chip_rev;
289 dev_err(wm8350->
dev,
"Failed to read ID: %d\n", ret);
295 dev_err(wm8350->
dev,
"Failed to read ID: %d\n", ret);
301 dev_err(wm8350->
dev,
"Failed to read revision: %d\n", ret);
307 "Device with ID %x is not a WM8350\n", id1);
316 "CONF_STS %d, CUST_ID %d, MASK_REV %d, CHIP_REV %d\n",
317 mode, cust_id, mask_rev, chip_rev);
320 dev_err(wm8350->
dev,
"Unsupported CUST_ID\n");
339 wm8350->
power.rev_g_coeff = 1;
343 wm8350->
power.rev_g_coeff = 1;
347 dev_err(wm8350->
dev,
"Unknown WM8350 CHIP_REV\n");
360 wm8350->
power.rev_g_coeff = 1;
365 wm8350->
power.rev_g_coeff = 1;
369 dev_err(wm8350->
dev,
"Unknown WM8351 CHIP_REV\n");
382 wm8350->
power.rev_g_coeff = 1;
386 dev_err(wm8350->
dev,
"Unknown WM8352 CHIP_REV\n");
408 NULL, wm8350_auxadc_irq, 0,
412 "Failed to request AUXADC IRQ: %d\n", ret);
415 if (pdata && pdata->
init) {
416 ret = pdata->
init(wm8350);
418 dev_err(wm8350->
dev,
"Platform init() failed: %d\n",
426 wm8350_client_dev_register(wm8350,
"wm8350-codec",
427 &(wm8350->
codec.pdev));
428 wm8350_client_dev_register(wm8350,
"wm8350-gpio",
429 &(wm8350->
gpio.pdev));
430 wm8350_client_dev_register(wm8350,
"wm8350-hwmon",
431 &(wm8350->
hwmon.pdev));
432 wm8350_client_dev_register(wm8350,
"wm8350-power",
433 &(wm8350->
power.pdev));
434 wm8350_client_dev_register(wm8350,
"wm8350-rtc", &(wm8350->
rtc.pdev));
435 wm8350_client_dev_register(wm8350,
"wm8350-wdt", &(wm8350->
wdt.pdev));