rt1308-sdw.c (49ae74abc76b2d9be4777e7ac833674fa4749071) | rt1308-sdw.c (1772552eb304f3229309f66e2762e835955e2307) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2// 3// rt1308-sdw.c -- rt1308 ALSA SoC audio driver 4// 5// Copyright(c) 2019 Realtek Semiconductor Corp. 6// 7// 8#include <linux/delay.h> --- 209 unchanged lines hidden (view full) --- 218 if (rt1308->hw_init) 219 return 0; 220 221 regcache_cache_only(rt1308->regmap, false); 222 if (rt1308->first_hw_init) 223 regcache_cache_bypass(rt1308->regmap, true); 224 225 /* | 1// SPDX-License-Identifier: GPL-2.0 2// 3// rt1308-sdw.c -- rt1308 ALSA SoC audio driver 4// 5// Copyright(c) 2019 Realtek Semiconductor Corp. 6// 7// 8#include <linux/delay.h> --- 209 unchanged lines hidden (view full) --- 218 if (rt1308->hw_init) 219 return 0; 220 221 regcache_cache_only(rt1308->regmap, false); 222 if (rt1308->first_hw_init) 223 regcache_cache_bypass(rt1308->regmap, true); 224 225 /* |
226 * PM runtime is only enabled when a Slave reports as Attached | 226 * PM runtime status is marked as 'active' only when a Slave reports as Attached |
227 */ | 227 */ |
228 if (!rt1308->first_hw_init) { 229 /* set autosuspend parameters */ 230 pm_runtime_set_autosuspend_delay(&slave->dev, 3000); 231 pm_runtime_use_autosuspend(&slave->dev); 232 | 228 if (!rt1308->first_hw_init) |
233 /* update count of parent 'active' children */ 234 pm_runtime_set_active(&slave->dev); 235 | 229 /* update count of parent 'active' children */ 230 pm_runtime_set_active(&slave->dev); 231 |
236 /* make sure the device does not suspend immediately */ 237 pm_runtime_mark_last_busy(&slave->dev); 238 239 pm_runtime_enable(&slave->dev); 240 } 241 | |
242 pm_runtime_get_noresume(&slave->dev); 243 244 /* sw reset */ 245 regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0); 246 247 regmap_read(rt1308->regmap, 0xc710, &tmp); 248 rt1308->hw_ver = tmp; 249 dev_dbg(dev, "%s, hw_ver=0x%x\n", __func__, rt1308->hw_ver); --- 370 unchanged lines hidden (view full) --- 620static int rt1308_sdw_component_probe(struct snd_soc_component *component) 621{ 622 struct rt1308_sdw_priv *rt1308 = snd_soc_component_get_drvdata(component); 623 int ret; 624 625 rt1308->component = component; 626 rt1308_sdw_parse_dt(rt1308, &rt1308->sdw_slave->dev); 627 | 232 pm_runtime_get_noresume(&slave->dev); 233 234 /* sw reset */ 235 regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0); 236 237 regmap_read(rt1308->regmap, 0xc710, &tmp); 238 rt1308->hw_ver = tmp; 239 dev_dbg(dev, "%s, hw_ver=0x%x\n", __func__, rt1308->hw_ver); --- 370 unchanged lines hidden (view full) --- 610static int rt1308_sdw_component_probe(struct snd_soc_component *component) 611{ 612 struct rt1308_sdw_priv *rt1308 = snd_soc_component_get_drvdata(component); 613 int ret; 614 615 rt1308->component = component; 616 rt1308_sdw_parse_dt(rt1308, &rt1308->sdw_slave->dev); 617 |
618 if (!rt1308->first_hw_init) 619 return 0; 620 |
|
628 ret = pm_runtime_resume(component->dev); 629 if (ret < 0 && ret != -EACCES) 630 return ret; 631 632 /* apply BQ params */ 633 rt1308_apply_bq_params(rt1308); 634 635 return 0; --- 59 unchanged lines hidden (view full) --- 695 */ 696 rt1308->hw_init = false; 697 rt1308->first_hw_init = false; 698 699 ret = devm_snd_soc_register_component(dev, 700 &soc_component_sdw_rt1308, 701 rt1308_sdw_dai, 702 ARRAY_SIZE(rt1308_sdw_dai)); | 621 ret = pm_runtime_resume(component->dev); 622 if (ret < 0 && ret != -EACCES) 623 return ret; 624 625 /* apply BQ params */ 626 rt1308_apply_bq_params(rt1308); 627 628 return 0; --- 59 unchanged lines hidden (view full) --- 688 */ 689 rt1308->hw_init = false; 690 rt1308->first_hw_init = false; 691 692 ret = devm_snd_soc_register_component(dev, 693 &soc_component_sdw_rt1308, 694 rt1308_sdw_dai, 695 ARRAY_SIZE(rt1308_sdw_dai)); |
696 if (ret < 0) 697 return ret; |
|
703 | 698 |
704 dev_dbg(&slave->dev, "%s\n", __func__); | 699 /* set autosuspend parameters */ 700 pm_runtime_set_autosuspend_delay(dev, 3000); 701 pm_runtime_use_autosuspend(dev); |
705 | 702 |
706 return ret; | 703 /* make sure the device does not suspend immediately */ 704 pm_runtime_mark_last_busy(dev); 705 706 pm_runtime_enable(dev); 707 708 /* important note: the device is NOT tagged as 'active' and will remain 709 * 'suspended' until the hardware is enumerated/initialized. This is required 710 * to make sure the ASoC framework use of pm_runtime_get_sync() does not silently 711 * fail with -EACCESS because of race conditions between card creation and enumeration 712 */ 713 714 dev_dbg(dev, "%s\n", __func__); 715 716 return 0; |
707} 708 709static int rt1308_sdw_probe(struct sdw_slave *slave, 710 const struct sdw_device_id *id) 711{ 712 struct regmap *regmap; 713 714 /* Regmap Initialization */ 715 regmap = devm_regmap_init_sdw(slave, &rt1308_sdw_regmap); 716 if (IS_ERR(regmap)) 717 return PTR_ERR(regmap); 718 719 return rt1308_sdw_init(&slave->dev, regmap, slave); 720} 721 722static int rt1308_sdw_remove(struct sdw_slave *slave) 723{ | 717} 718 719static int rt1308_sdw_probe(struct sdw_slave *slave, 720 const struct sdw_device_id *id) 721{ 722 struct regmap *regmap; 723 724 /* Regmap Initialization */ 725 regmap = devm_regmap_init_sdw(slave, &rt1308_sdw_regmap); 726 if (IS_ERR(regmap)) 727 return PTR_ERR(regmap); 728 729 return rt1308_sdw_init(&slave->dev, regmap, slave); 730} 731 732static int rt1308_sdw_remove(struct sdw_slave *slave) 733{ |
724 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev); | 734 pm_runtime_disable(&slave->dev); |
725 | 735 |
726 if (rt1308->first_hw_init) 727 pm_runtime_disable(&slave->dev); 728 | |
729 return 0; 730} 731 732static const struct sdw_device_id rt1308_id[] = { 733 SDW_SLAVE_ENTRY_EXT(0x025d, 0x1308, 0x2, 0, 0), 734 {}, 735}; 736MODULE_DEVICE_TABLE(sdw, rt1308_id); --- 65 unchanged lines hidden --- | 736 return 0; 737} 738 739static const struct sdw_device_id rt1308_id[] = { 740 SDW_SLAVE_ENTRY_EXT(0x025d, 0x1308, 0x2, 0, 0), 741 {}, 742}; 743MODULE_DEVICE_TABLE(sdw, rt1308_id); --- 65 unchanged lines hidden --- |