diff options
Diffstat (limited to 'drivers/mfd/wm8350-core.c')
-rw-r--r-- | drivers/mfd/wm8350-core.c | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c index f92595c8f16..b457a05b28d 100644 --- a/drivers/mfd/wm8350-core.c +++ b/drivers/mfd/wm8350-core.c | |||
@@ -1111,7 +1111,7 @@ int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale, int vref) | |||
1111 | do { | 1111 | do { |
1112 | schedule_timeout_interruptible(1); | 1112 | schedule_timeout_interruptible(1); |
1113 | reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); | 1113 | reg = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_1); |
1114 | } while (tries-- && (reg & WM8350_AUXADC_POLL)); | 1114 | } while (--tries && (reg & WM8350_AUXADC_POLL)); |
1115 | 1115 | ||
1116 | if (!tries) | 1116 | if (!tries) |
1117 | dev_err(wm8350->dev, "adc chn %d read timeout\n", channel); | 1117 | dev_err(wm8350->dev, "adc chn %d read timeout\n", channel); |
@@ -1297,14 +1297,29 @@ static void wm8350_client_dev_register(struct wm8350 *wm8350, | |||
1297 | int wm8350_device_init(struct wm8350 *wm8350, int irq, | 1297 | int wm8350_device_init(struct wm8350 *wm8350, int irq, |
1298 | struct wm8350_platform_data *pdata) | 1298 | struct wm8350_platform_data *pdata) |
1299 | { | 1299 | { |
1300 | int ret = -EINVAL; | 1300 | int ret; |
1301 | u16 id1, id2, mask_rev; | 1301 | u16 id1, id2, mask_rev; |
1302 | u16 cust_id, mode, chip_rev; | 1302 | u16 cust_id, mode, chip_rev; |
1303 | 1303 | ||
1304 | /* get WM8350 revision and config mode */ | 1304 | /* get WM8350 revision and config mode */ |
1305 | wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); | 1305 | ret = wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); |
1306 | wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2); | 1306 | if (ret != 0) { |
1307 | wm8350->read_dev(wm8350, WM8350_REVISION, sizeof(mask_rev), &mask_rev); | 1307 | dev_err(wm8350->dev, "Failed to read ID: %d\n", ret); |
1308 | goto err; | ||
1309 | } | ||
1310 | |||
1311 | ret = wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2); | ||
1312 | if (ret != 0) { | ||
1313 | dev_err(wm8350->dev, "Failed to read ID: %d\n", ret); | ||
1314 | goto err; | ||
1315 | } | ||
1316 | |||
1317 | ret = wm8350->read_dev(wm8350, WM8350_REVISION, sizeof(mask_rev), | ||
1318 | &mask_rev); | ||
1319 | if (ret != 0) { | ||
1320 | dev_err(wm8350->dev, "Failed to read revision: %d\n", ret); | ||
1321 | goto err; | ||
1322 | } | ||
1308 | 1323 | ||
1309 | id1 = be16_to_cpu(id1); | 1324 | id1 = be16_to_cpu(id1); |
1310 | id2 = be16_to_cpu(id2); | 1325 | id2 = be16_to_cpu(id2); |
@@ -1368,6 +1383,11 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, | |||
1368 | wm8350->power.rev_g_coeff = 1; | 1383 | wm8350->power.rev_g_coeff = 1; |
1369 | break; | 1384 | break; |
1370 | 1385 | ||
1386 | case 1: | ||
1387 | dev_info(wm8350->dev, "WM8351 Rev B\n"); | ||
1388 | wm8350->power.rev_g_coeff = 1; | ||
1389 | break; | ||
1390 | |||
1371 | default: | 1391 | default: |
1372 | dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n"); | 1392 | dev_err(wm8350->dev, "Unknown WM8351 CHIP_REV\n"); |
1373 | ret = -ENODEV; | 1393 | ret = -ENODEV; |
@@ -1404,14 +1424,12 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, | |||
1404 | return ret; | 1424 | return ret; |
1405 | } | 1425 | } |
1406 | 1426 | ||
1407 | if (pdata && pdata->init) { | 1427 | wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0xFFFF); |
1408 | ret = pdata->init(wm8350); | 1428 | wm8350_reg_write(wm8350, WM8350_INT_STATUS_1_MASK, 0xFFFF); |
1409 | if (ret != 0) { | 1429 | wm8350_reg_write(wm8350, WM8350_INT_STATUS_2_MASK, 0xFFFF); |
1410 | dev_err(wm8350->dev, "Platform init() failed: %d\n", | 1430 | wm8350_reg_write(wm8350, WM8350_UNDER_VOLTAGE_INT_STATUS_MASK, 0xFFFF); |
1411 | ret); | 1431 | wm8350_reg_write(wm8350, WM8350_GPIO_INT_STATUS_MASK, 0xFFFF); |
1412 | goto err; | 1432 | wm8350_reg_write(wm8350, WM8350_COMPARATOR_INT_STATUS_MASK, 0xFFFF); |
1413 | } | ||
1414 | } | ||
1415 | 1433 | ||
1416 | mutex_init(&wm8350->auxadc_mutex); | 1434 | mutex_init(&wm8350->auxadc_mutex); |
1417 | mutex_init(&wm8350->irq_mutex); | 1435 | mutex_init(&wm8350->irq_mutex); |
@@ -1430,6 +1448,15 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq, | |||
1430 | } | 1448 | } |
1431 | wm8350->chip_irq = irq; | 1449 | wm8350->chip_irq = irq; |
1432 | 1450 | ||
1451 | if (pdata && pdata->init) { | ||
1452 | ret = pdata->init(wm8350); | ||
1453 | if (ret != 0) { | ||
1454 | dev_err(wm8350->dev, "Platform init() failed: %d\n", | ||
1455 | ret); | ||
1456 | goto err; | ||
1457 | } | ||
1458 | } | ||
1459 | |||
1433 | wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x0); | 1460 | wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x0); |
1434 | 1461 | ||
1435 | wm8350_client_dev_register(wm8350, "wm8350-codec", | 1462 | wm8350_client_dev_register(wm8350, "wm8350-codec", |