aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/wm8350-core.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 764bf15ea684..2188d759cbde 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1227,52 +1227,72 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
1227 struct wm8350_platform_data *pdata) 1227 struct wm8350_platform_data *pdata)
1228{ 1228{
1229 int ret = -EINVAL; 1229 int ret = -EINVAL;
1230 u16 id1, id2, mask, mode; 1230 u16 id1, id2, mask_rev;
1231 u16 cust_id, mode, chip_rev;
1231 1232
1232 /* get WM8350 revision and config mode */ 1233 /* get WM8350 revision and config mode */
1233 wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); 1234 wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1);
1234 wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2); 1235 wm8350->read_dev(wm8350, WM8350_ID, sizeof(id2), &id2);
1236 wm8350->read_dev(wm8350, WM8350_REVISION, sizeof(mask_rev), &mask_rev);
1235 1237
1236 id1 = be16_to_cpu(id1); 1238 id1 = be16_to_cpu(id1);
1237 id2 = be16_to_cpu(id2); 1239 id2 = be16_to_cpu(id2);
1240 mask_rev = be16_to_cpu(mask_rev);
1238 1241
1239 if (id1 == 0x6143) { 1242 if (id1 != 0x6143) {
1240 switch ((id2 & WM8350_CHIP_REV_MASK) >> 12) { 1243 dev_err(wm8350->dev,
1244 "Device with ID %x is not a WM8350\n", id1);
1245 ret = -ENODEV;
1246 goto err;
1247 }
1248
1249 mode = id2 & WM8350_CONF_STS_MASK >> 10;
1250 cust_id = id2 & WM8350_CUST_ID_MASK;
1251 chip_rev = (id2 & WM8350_CHIP_REV_MASK) >> 12;
1252 dev_info(wm8350->dev,
1253 "CONF_STS %d, CUST_ID %d, MASK_REV %d, CHIP_REV %d\n",
1254 mode, cust_id, mask_rev, chip_rev);
1255
1256 if (cust_id != 0) {
1257 dev_err(wm8350->dev, "Unsupported CUST_ID\n");
1258 ret = -ENODEV;
1259 goto err;
1260 }
1261
1262 switch (mask_rev) {
1263 case 0:
1264 switch (chip_rev) {
1241 case WM8350_REV_E: 1265 case WM8350_REV_E:
1242 dev_info(wm8350->dev, "Found Rev E device\n"); 1266 dev_info(wm8350->dev, "WM8350 Rev E\n");
1243 break; 1267 break;
1244 case WM8350_REV_F: 1268 case WM8350_REV_F:
1245 dev_info(wm8350->dev, "Found Rev F device\n"); 1269 dev_info(wm8350->dev, "WM8350 Rev F\n");
1246 break; 1270 break;
1247 case WM8350_REV_G: 1271 case WM8350_REV_G:
1248 dev_info(wm8350->dev, "Found Rev G device\n"); 1272 dev_info(wm8350->dev, "WM8350 Rev G\n");
1249 wm8350->power.rev_g_coeff = 1; 1273 wm8350->power.rev_g_coeff = 1;
1250 break; 1274 break;
1251 case WM8350_REV_H: 1275 case WM8350_REV_H:
1252 dev_info(wm8350->dev, "Found Rev H device\n"); 1276 dev_info(wm8350->dev, "WM8350 Rev H\n");
1253 wm8350->power.rev_g_coeff = 1; 1277 wm8350->power.rev_g_coeff = 1;
1254 break; 1278 break;
1255 default: 1279 default:
1256 /* For safety we refuse to run on unknown hardware */ 1280 /* For safety we refuse to run on unknown hardware */
1257 dev_info(wm8350->dev, "Found unknown rev %x\n", 1281 dev_err(wm8350->dev, "Unknown WM8350 CHIP_REV\n");
1258 (id2 & WM8350_CHIP_REV_MASK) >> 12);
1259 ret = -ENODEV; 1282 ret = -ENODEV;
1260 goto err; 1283 goto err;
1261 } 1284 }
1262 } else { 1285 break;
1263 dev_info(wm8350->dev, "Device with ID %x is not a WM8350\n", 1286
1264 id1); 1287 default:
1288 dev_err(wm8350->dev, "Unknown MASK_REV\n");
1265 ret = -ENODEV; 1289 ret = -ENODEV;
1266 goto err; 1290 goto err;
1267 } 1291 }
1268 1292
1269 mode = id2 & WM8350_CONF_STS_MASK >> 10;
1270 mask = id2 & WM8350_CUST_ID_MASK;
1271 dev_info(wm8350->dev, "Config mode %d, ROM mask %d\n", mode, mask);
1272
1273 ret = wm8350_create_cache(wm8350, mode); 1293 ret = wm8350_create_cache(wm8350, mode);
1274 if (ret < 0) { 1294 if (ret < 0) {
1275 printk(KERN_ERR "wm8350: failed to create register cache\n"); 1295 dev_err(wm8350->dev, "Failed to create register cache\n");
1276 return ret; 1296 return ret;
1277 } 1297 }
1278 1298