Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: rt5645: Separate regmap for rt5645 and rt5650

rt5645.c support both rt5645 and rt5650 codec. And the default
value of registers are not identical. So we use different regmap
for the two codecs.

Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Bard Liao and committed by
Mark Brown
49abc6cd 6e5b143c

+200 -9
+200 -9
sound/soc/codecs/rt5645.c
··· 226 226 { 0xff, 0x6308 }, 227 227 }; 228 228 229 + static const struct reg_default rt5650_reg[] = { 230 + { 0x00, 0x0000 }, 231 + { 0x01, 0xc8c8 }, 232 + { 0x02, 0xc8c8 }, 233 + { 0x03, 0xc8c8 }, 234 + { 0x0a, 0x0002 }, 235 + { 0x0b, 0x2827 }, 236 + { 0x0c, 0xe000 }, 237 + { 0x0d, 0x0000 }, 238 + { 0x0e, 0x0000 }, 239 + { 0x0f, 0x0808 }, 240 + { 0x14, 0x3333 }, 241 + { 0x16, 0x4b00 }, 242 + { 0x18, 0x018b }, 243 + { 0x19, 0xafaf }, 244 + { 0x1a, 0xafaf }, 245 + { 0x1b, 0x0001 }, 246 + { 0x1c, 0x2f2f }, 247 + { 0x1d, 0x2f2f }, 248 + { 0x1e, 0x0000 }, 249 + { 0x20, 0x0000 }, 250 + { 0x27, 0x7060 }, 251 + { 0x28, 0x7070 }, 252 + { 0x29, 0x8080 }, 253 + { 0x2a, 0x5656 }, 254 + { 0x2b, 0x5454 }, 255 + { 0x2c, 0xaaa0 }, 256 + { 0x2d, 0x0000 }, 257 + { 0x2f, 0x1002 }, 258 + { 0x31, 0x5000 }, 259 + { 0x32, 0x0000 }, 260 + { 0x33, 0x0000 }, 261 + { 0x34, 0x0000 }, 262 + { 0x35, 0x0000 }, 263 + { 0x3b, 0x0000 }, 264 + { 0x3c, 0x007f }, 265 + { 0x3d, 0x0000 }, 266 + { 0x3e, 0x007f }, 267 + { 0x3f, 0x0000 }, 268 + { 0x40, 0x001f }, 269 + { 0x41, 0x0000 }, 270 + { 0x42, 0x001f }, 271 + { 0x45, 0x6000 }, 272 + { 0x46, 0x003e }, 273 + { 0x47, 0x003e }, 274 + { 0x48, 0xf807 }, 275 + { 0x4a, 0x0004 }, 276 + { 0x4d, 0x0000 }, 277 + { 0x4e, 0x0000 }, 278 + { 0x4f, 0x01ff }, 279 + { 0x50, 0x0000 }, 280 + { 0x51, 0x0000 }, 281 + { 0x52, 0x01ff }, 282 + { 0x53, 0xf000 }, 283 + { 0x56, 0x0111 }, 284 + { 0x57, 0x0064 }, 285 + { 0x58, 0xef0e }, 286 + { 0x59, 0xf0f0 }, 287 + { 0x5a, 0xef0e }, 288 + { 0x5b, 0xf0f0 }, 289 + { 0x5c, 0xef0e }, 290 + { 0x5d, 0xf0f0 }, 291 + { 0x5e, 0xf000 }, 292 + { 0x5f, 0x0000 }, 293 + { 0x61, 0x0300 }, 294 + { 0x62, 0x0000 }, 295 + { 0x63, 0x00c2 }, 296 + { 0x64, 0x0000 }, 297 + { 0x65, 0x0000 }, 298 + { 0x66, 0x0000 }, 299 + { 0x6a, 0x0000 }, 300 + { 0x6c, 0x0aaa }, 301 + { 0x70, 0x8000 }, 302 + { 0x71, 0x8000 }, 303 + { 0x72, 0x8000 }, 304 + { 0x73, 0x7770 }, 305 + { 0x74, 0x3e00 }, 306 + { 0x75, 0x2409 }, 307 + { 0x76, 0x000a }, 308 + { 0x77, 0x0c00 }, 309 + { 0x78, 0x0000 }, 310 + { 0x79, 0x0123 }, 311 + { 0x7a, 0x0123 }, 312 + { 0x80, 0x0000 }, 313 + { 0x81, 0x0000 }, 314 + { 0x82, 0x0000 }, 315 + { 0x83, 0x0000 }, 316 + { 0x84, 0x0000 }, 317 + { 0x85, 0x0000 }, 318 + { 0x8a, 0x0000 }, 319 + { 0x8e, 0x0004 }, 320 + { 0x8f, 0x1100 }, 321 + { 0x90, 0x0646 }, 322 + { 0x91, 0x0c06 }, 323 + { 0x93, 0x0000 }, 324 + { 0x94, 0x0200 }, 325 + { 0x95, 0x0000 }, 326 + { 0x9a, 0x2184 }, 327 + { 0x9b, 0x010a }, 328 + { 0x9c, 0x0aea }, 329 + { 0x9d, 0x000c }, 330 + { 0x9e, 0x0400 }, 331 + { 0xa0, 0xa0a8 }, 332 + { 0xa1, 0x0059 }, 333 + { 0xa2, 0x0001 }, 334 + { 0xae, 0x6000 }, 335 + { 0xaf, 0x0000 }, 336 + { 0xb0, 0x6000 }, 337 + { 0xb1, 0x0000 }, 338 + { 0xb2, 0x0000 }, 339 + { 0xb3, 0x001f }, 340 + { 0xb4, 0x020c }, 341 + { 0xb5, 0x1f00 }, 342 + { 0xb6, 0x0000 }, 343 + { 0xbb, 0x0000 }, 344 + { 0xbc, 0x0000 }, 345 + { 0xbd, 0x0000 }, 346 + { 0xbe, 0x0000 }, 347 + { 0xbf, 0x3100 }, 348 + { 0xc0, 0x0000 }, 349 + { 0xc1, 0x0000 }, 350 + { 0xc2, 0x0000 }, 351 + { 0xc3, 0x2000 }, 352 + { 0xcd, 0x0000 }, 353 + { 0xce, 0x0000 }, 354 + { 0xcf, 0x1813 }, 355 + { 0xd0, 0x0690 }, 356 + { 0xd1, 0x1c17 }, 357 + { 0xd3, 0xb320 }, 358 + { 0xd4, 0x0000 }, 359 + { 0xd6, 0x0400 }, 360 + { 0xd9, 0x0809 }, 361 + { 0xda, 0x0000 }, 362 + { 0xdb, 0x0003 }, 363 + { 0xdc, 0x0049 }, 364 + { 0xdd, 0x001b }, 365 + { 0xdf, 0x0008 }, 366 + { 0xe0, 0x4000 }, 367 + { 0xe6, 0x8000 }, 368 + { 0xe7, 0x0200 }, 369 + { 0xec, 0xb300 }, 370 + { 0xed, 0x0000 }, 371 + { 0xf0, 0x001f }, 372 + { 0xf1, 0x020c }, 373 + { 0xf2, 0x1f00 }, 374 + { 0xf3, 0x0000 }, 375 + { 0xf4, 0x4000 }, 376 + { 0xf8, 0x0000 }, 377 + { 0xf9, 0x0000 }, 378 + { 0xfa, 0x2060 }, 379 + { 0xfb, 0x4040 }, 380 + { 0xfc, 0x0000 }, 381 + { 0xfd, 0x0002 }, 382 + { 0xfe, 0x10ec }, 383 + { 0xff, 0x6308 }, 384 + }; 385 + 229 386 struct rt5645_eq_param_s { 230 387 unsigned short reg; 231 388 unsigned short val; ··· 3473 3316 .num_ranges = ARRAY_SIZE(rt5645_ranges), 3474 3317 }; 3475 3318 3319 + static const struct regmap_config rt5650_regmap = { 3320 + .reg_bits = 8, 3321 + .val_bits = 16, 3322 + .use_single_rw = true, 3323 + .max_register = RT5645_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5645_ranges) * 3324 + RT5645_PR_SPACING), 3325 + .volatile_reg = rt5645_volatile_register, 3326 + .readable_reg = rt5645_readable_register, 3327 + 3328 + .cache_type = REGCACHE_RBTREE, 3329 + .reg_defaults = rt5650_reg, 3330 + .num_reg_defaults = ARRAY_SIZE(rt5650_reg), 3331 + .ranges = rt5645_ranges, 3332 + .num_ranges = ARRAY_SIZE(rt5645_ranges), 3333 + }; 3334 + 3335 + static const struct regmap_config temp_regmap = { 3336 + .name="nocache", 3337 + .reg_bits = 8, 3338 + .val_bits = 16, 3339 + .use_single_rw = true, 3340 + .max_register = RT5645_VENDOR_ID2 + 1, 3341 + .cache_type = REGCACHE_NONE, 3342 + }; 3343 + 3476 3344 static const struct i2c_device_id rt5645_i2c_id[] = { 3477 3345 { "rt5645", 0 }, 3478 3346 { "rt5650", 0 }, ··· 3608 3426 struct rt5645_priv *rt5645; 3609 3427 int ret, i; 3610 3428 unsigned int val; 3429 + struct regmap *regmap; 3611 3430 3612 3431 rt5645 = devm_kzalloc(&i2c->dev, sizeof(struct rt5645_priv), 3613 3432 GFP_KERNEL); ··· 3634 3451 return PTR_ERR(rt5645->gpiod_hp_det); 3635 3452 } 3636 3453 3637 - rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap); 3638 - if (IS_ERR(rt5645->regmap)) { 3639 - ret = PTR_ERR(rt5645->regmap); 3640 - dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 3641 - ret); 3642 - return ret; 3643 - } 3644 - 3645 3454 for (i = 0; i < ARRAY_SIZE(rt5645->supplies); i++) 3646 3455 rt5645->supplies[i].supply = rt5645_supply_names[i]; 3647 3456 ··· 3652 3477 return ret; 3653 3478 } 3654 3479 3655 - regmap_read(rt5645->regmap, RT5645_VENDOR_ID2, &val); 3480 + regmap = devm_regmap_init_i2c(i2c, &temp_regmap); 3481 + if (IS_ERR(regmap)) { 3482 + ret = PTR_ERR(regmap); 3483 + dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n", 3484 + ret); 3485 + return ret; 3486 + } 3487 + regmap_read(regmap, RT5645_VENDOR_ID2, &val); 3656 3488 3657 3489 switch (val) { 3658 3490 case RT5645_DEVICE_ID: 3491 + rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5645_regmap); 3659 3492 rt5645->codec_type = CODEC_TYPE_RT5645; 3660 3493 break; 3661 3494 case RT5650_DEVICE_ID: 3495 + rt5645->regmap = devm_regmap_init_i2c(i2c, &rt5650_regmap); 3662 3496 rt5645->codec_type = CODEC_TYPE_RT5650; 3663 3497 break; 3664 3498 default: ··· 3676 3492 val); 3677 3493 ret = -ENODEV; 3678 3494 goto err_enable; 3495 + } 3496 + 3497 + if (IS_ERR(rt5645->regmap)) { 3498 + ret = PTR_ERR(rt5645->regmap); 3499 + dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 3500 + ret); 3501 + return ret; 3679 3502 } 3680 3503 3681 3504 regmap_write(rt5645->regmap, RT5645_RESET, 0);