rt1308-sdw.c (2612e3bbc0386368a850140a6c9b990cd496a5ec) rt1308-sdw.c (37aba3190891d4de189bd5192ee95220e295f34d)
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>

--- 38 unchanged lines hidden (view full) ---

47 switch (reg) {
48 case 0x2f01 ... 0x2f07:
49 case 0x3000 ... 0x3001:
50 case 0x3004 ... 0x3005:
51 case 0x3008:
52 case 0x300a:
53 case 0xc000:
54 case 0xc710:
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>

--- 38 unchanged lines hidden (view full) ---

47 switch (reg) {
48 case 0x2f01 ... 0x2f07:
49 case 0x3000 ... 0x3001:
50 case 0x3004 ... 0x3005:
51 case 0x3008:
52 case 0x300a:
53 case 0xc000:
54 case 0xc710:
55 case 0xcf01:
55 case 0xc860 ... 0xc863:
56 case 0xc870 ... 0xc873:
57 return true;
58 default:
59 return false;
60 }
61}
62

--- 145 unchanged lines hidden (view full) ---

208 regmap_write(rt1308->regmap, reg, data);
209 }
210}
211
212static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
213{
214 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
215 int ret = 0;
56 case 0xc860 ... 0xc863:
57 case 0xc870 ... 0xc873:
58 return true;
59 default:
60 return false;
61 }
62}
63

--- 145 unchanged lines hidden (view full) ---

209 regmap_write(rt1308->regmap, reg, data);
210 }
211}
212
213static int rt1308_io_init(struct device *dev, struct sdw_slave *slave)
214{
215 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
216 int ret = 0;
216 unsigned int tmp;
217 unsigned int tmp, hibernation_flag;
217
218 if (rt1308->hw_init)
219 return 0;
220
221 if (rt1308->first_hw_init) {
222 regcache_cache_only(rt1308->regmap, false);
223 regcache_cache_bypass(rt1308->regmap, true);
224 }

--- 12 unchanged lines hidden (view full) ---

237 /* make sure the device does not suspend immediately */
238 pm_runtime_mark_last_busy(&slave->dev);
239
240 pm_runtime_enable(&slave->dev);
241 }
242
243 pm_runtime_get_noresume(&slave->dev);
244
218
219 if (rt1308->hw_init)
220 return 0;
221
222 if (rt1308->first_hw_init) {
223 regcache_cache_only(rt1308->regmap, false);
224 regcache_cache_bypass(rt1308->regmap, true);
225 }

--- 12 unchanged lines hidden (view full) ---

238 /* make sure the device does not suspend immediately */
239 pm_runtime_mark_last_busy(&slave->dev);
240
241 pm_runtime_enable(&slave->dev);
242 }
243
244 pm_runtime_get_noresume(&slave->dev);
245
246 regmap_read(rt1308->regmap, 0xcf01, &hibernation_flag);
247 if ((hibernation_flag != 0x00) && rt1308->first_hw_init)
248 goto _preset_ready_;
249
245 /* sw reset */
246 regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0);
247
248 regmap_read(rt1308->regmap, 0xc710, &tmp);
249 rt1308->hw_ver = tmp;
250 dev_dbg(dev, "%s, hw_ver=0x%x\n", __func__, rt1308->hw_ver);
251
252 /* initial settings */

--- 24 unchanged lines hidden (view full) ---

277 regmap_write(rt1308->regmap, 0xc360, 0x78);
278 regmap_write(rt1308->regmap, 0xc361, 0x87);
279 regmap_write(rt1308->regmap, 0xc0a1, 0x71);
280 regmap_write(rt1308->regmap, 0xc210, 0x00);
281 regmap_write(rt1308->regmap, 0xc070, 0x00);
282 regmap_write(rt1308->regmap, 0xc100, 0xd7);
283 regmap_write(rt1308->regmap, 0xc101, 0xd7);
284
250 /* sw reset */
251 regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0);
252
253 regmap_read(rt1308->regmap, 0xc710, &tmp);
254 rt1308->hw_ver = tmp;
255 dev_dbg(dev, "%s, hw_ver=0x%x\n", __func__, rt1308->hw_ver);
256
257 /* initial settings */

--- 24 unchanged lines hidden (view full) ---

282 regmap_write(rt1308->regmap, 0xc360, 0x78);
283 regmap_write(rt1308->regmap, 0xc361, 0x87);
284 regmap_write(rt1308->regmap, 0xc0a1, 0x71);
285 regmap_write(rt1308->regmap, 0xc210, 0x00);
286 regmap_write(rt1308->regmap, 0xc070, 0x00);
287 regmap_write(rt1308->regmap, 0xc100, 0xd7);
288 regmap_write(rt1308->regmap, 0xc101, 0xd7);
289
290 /* apply BQ params */
291 rt1308_apply_bq_params(rt1308);
292
293 regmap_write(rt1308->regmap, 0xcf01, 0x01);
294
295_preset_ready_:
285 if (rt1308->first_hw_init) {
286 regcache_cache_bypass(rt1308->regmap, false);
287 regcache_mark_dirty(rt1308->regmap);
288 } else
289 rt1308->first_hw_init = true;
290
291 /* Mark Slave initialization complete */
292 rt1308->hw_init = true;

--- 510 unchanged lines hidden ---
296 if (rt1308->first_hw_init) {
297 regcache_cache_bypass(rt1308->regmap, false);
298 regcache_mark_dirty(rt1308->regmap);
299 } else
300 rt1308->first_hw_init = true;
301
302 /* Mark Slave initialization complete */
303 rt1308->hw_init = true;

--- 510 unchanged lines hidden ---