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

Merge remote-tracking branches 'asoc/topic/rcar', 'asoc/topic/reg-default', 'asoc/topic/rl6231', 'asoc/topic/rockchip' and 'asoc/topic/rt286' into asoc-next

+1142 -304
+22
Documentation/devicetree/bindings/sound/renesas,rsnd.txt
··· 18 18 - rcar_sound,src : Should contain SRC feature. 19 19 The number of SRC subnode should be same as HW. 20 20 see below for detail. 21 + - rcar_sound,ctu : Should contain CTU feature. 22 + The number of CTU subnode should be same as HW. 23 + see below for detail. 24 + - rcar_sound,mix : Should contain MIX feature. 25 + The number of MIX subnode should be same as HW. 26 + see below for detail. 21 27 - rcar_sound,dvc : Should contain DVC feature. 22 28 The number of DVC subnode should be same as HW. 23 29 see below for detail. ··· 94 88 dmas = <&audma0 0xbe>; 95 89 dma-names = "tx"; 96 90 }; 91 + }; 92 + 93 + rcar_sound,mix { 94 + mix0: mix@0 { }; 95 + mix1: mix@1 { }; 96 + }; 97 + 98 + rcar_sound,ctu { 99 + ctu00: ctu@0 { }; 100 + ctu01: ctu@1 { }; 101 + ctu02: ctu@2 { }; 102 + ctu03: ctu@3 { }; 103 + ctu10: ctu@4 { }; 104 + ctu11: ctu@5 { }; 105 + ctu12: ctu@6 { }; 106 + ctu13: ctu@7 { }; 97 107 }; 98 108 99 109 rcar_sound,src {
+7
Documentation/devicetree/bindings/sound/renesas,rsrc-card.txt
··· 6 6 7 7 - compatible : "renesas,rsrc-card,<board>" 8 8 Examples with soctypes are: 9 + - "renesas,rsrc-card" 9 10 - "renesas,rsrc-card,lager" 10 11 - "renesas,rsrc-card,koelsch" 11 12 Optional properties: ··· 30 29 - frame-inversion : bool property. Add this if the 31 30 dai-link uses frame clock inversion. 32 31 - convert-rate : platform specified sampling rate convert 32 + - audio-prefix : see audio-routing 33 + - audio-routing : A list of the connections between audio components. 34 + Each entry is a pair of strings, the first being the connection's sink, 35 + the second being the connection's source. Valid names for sources. 36 + use audio-prefix if some components is using same sink/sources naming. 37 + it can be used if compatible was "renesas,rsrc-card"; 33 38 34 39 Required CPU/CODEC subnodes properties: 35 40
+1 -1
drivers/base/regmap/internal.h
··· 136 136 /* if set, the HW registers are known to match map->reg_defaults */ 137 137 bool no_sync_defaults; 138 138 139 - struct reg_default *patch; 139 + struct reg_sequence *patch; 140 140 int patch_regs; 141 141 142 142 /* if set, converts bulk rw to single rw */
+54 -19
drivers/base/regmap/regmap.c
··· 34 34 35 35 static int _regmap_update_bits(struct regmap *map, unsigned int reg, 36 36 unsigned int mask, unsigned int val, 37 - bool *change); 37 + bool *change, bool force_write); 38 38 39 39 static int _regmap_bus_reg_read(void *context, unsigned int reg, 40 40 unsigned int *val); ··· 1178 1178 ret = _regmap_update_bits(map, range->selector_reg, 1179 1179 range->selector_mask, 1180 1180 win_page << range->selector_shift, 1181 - &page_chg); 1181 + &page_chg, false); 1182 1182 1183 1183 map->work_buf = orig_work_buf; 1184 1184 ··· 1624 1624 } 1625 1625 EXPORT_SYMBOL_GPL(regmap_fields_write); 1626 1626 1627 + int regmap_fields_force_write(struct regmap_field *field, unsigned int id, 1628 + unsigned int val) 1629 + { 1630 + if (id >= field->id_size) 1631 + return -EINVAL; 1632 + 1633 + return regmap_write_bits(field->regmap, 1634 + field->reg + (field->id_offset * id), 1635 + field->mask, val << field->shift); 1636 + } 1637 + EXPORT_SYMBOL_GPL(regmap_fields_force_write); 1638 + 1627 1639 /** 1628 1640 * regmap_fields_update_bits(): Perform a read/modify/write cycle 1629 1641 * on the register field ··· 1755 1743 * relative. The page register has been written if that was neccessary. 1756 1744 */ 1757 1745 static int _regmap_raw_multi_reg_write(struct regmap *map, 1758 - const struct reg_default *regs, 1746 + const struct reg_sequence *regs, 1759 1747 size_t num_regs) 1760 1748 { 1761 1749 int ret; ··· 1812 1800 } 1813 1801 1814 1802 static int _regmap_range_multi_paged_reg_write(struct regmap *map, 1815 - struct reg_default *regs, 1803 + struct reg_sequence *regs, 1816 1804 size_t num_regs) 1817 1805 { 1818 1806 int ret; 1819 1807 int i, n; 1820 - struct reg_default *base; 1808 + struct reg_sequence *base; 1821 1809 unsigned int this_page = 0; 1822 1810 /* 1823 1811 * the set of registers are not neccessarily in order, but ··· 1855 1843 } 1856 1844 1857 1845 static int _regmap_multi_reg_write(struct regmap *map, 1858 - const struct reg_default *regs, 1846 + const struct reg_sequence *regs, 1859 1847 size_t num_regs) 1860 1848 { 1861 1849 int i; ··· 1907 1895 struct regmap_range_node *range; 1908 1896 range = _regmap_range_lookup(map, reg); 1909 1897 if (range) { 1910 - size_t len = sizeof(struct reg_default)*num_regs; 1911 - struct reg_default *base = kmemdup(regs, len, 1898 + size_t len = sizeof(struct reg_sequence)*num_regs; 1899 + struct reg_sequence *base = kmemdup(regs, len, 1912 1900 GFP_KERNEL); 1913 1901 if (!base) 1914 1902 return -ENOMEM; ··· 1941 1929 * A value of zero will be returned on success, a negative errno will be 1942 1930 * returned in error cases. 1943 1931 */ 1944 - int regmap_multi_reg_write(struct regmap *map, const struct reg_default *regs, 1932 + int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, 1945 1933 int num_regs) 1946 1934 { 1947 1935 int ret; ··· 1974 1962 * be returned in error cases. 1975 1963 */ 1976 1964 int regmap_multi_reg_write_bypassed(struct regmap *map, 1977 - const struct reg_default *regs, 1965 + const struct reg_sequence *regs, 1978 1966 int num_regs) 1979 1967 { 1980 1968 int ret; ··· 2339 2327 2340 2328 static int _regmap_update_bits(struct regmap *map, unsigned int reg, 2341 2329 unsigned int mask, unsigned int val, 2342 - bool *change) 2330 + bool *change, bool force_write) 2343 2331 { 2344 2332 int ret; 2345 2333 unsigned int tmp, orig; ··· 2351 2339 tmp = orig & ~mask; 2352 2340 tmp |= val & mask; 2353 2341 2354 - if (tmp != orig) { 2342 + if (force_write || (tmp != orig)) { 2355 2343 ret = _regmap_write(map, reg, tmp); 2356 2344 if (change) 2357 2345 *change = true; ··· 2379 2367 int ret; 2380 2368 2381 2369 map->lock(map->lock_arg); 2382 - ret = _regmap_update_bits(map, reg, mask, val, NULL); 2370 + ret = _regmap_update_bits(map, reg, mask, val, NULL, false); 2383 2371 map->unlock(map->lock_arg); 2384 2372 2385 2373 return ret; 2386 2374 } 2387 2375 EXPORT_SYMBOL_GPL(regmap_update_bits); 2376 + 2377 + /** 2378 + * regmap_write_bits: Perform a read/modify/write cycle on the register map 2379 + * 2380 + * @map: Register map to update 2381 + * @reg: Register to update 2382 + * @mask: Bitmask to change 2383 + * @val: New value for bitmask 2384 + * 2385 + * Returns zero for success, a negative number on error. 2386 + */ 2387 + int regmap_write_bits(struct regmap *map, unsigned int reg, 2388 + unsigned int mask, unsigned int val) 2389 + { 2390 + int ret; 2391 + 2392 + map->lock(map->lock_arg); 2393 + ret = _regmap_update_bits(map, reg, mask, val, NULL, true); 2394 + map->unlock(map->lock_arg); 2395 + 2396 + return ret; 2397 + } 2398 + EXPORT_SYMBOL_GPL(regmap_write_bits); 2388 2399 2389 2400 /** 2390 2401 * regmap_update_bits_async: Perform a read/modify/write cycle on the register ··· 2433 2398 2434 2399 map->async = true; 2435 2400 2436 - ret = _regmap_update_bits(map, reg, mask, val, NULL); 2401 + ret = _regmap_update_bits(map, reg, mask, val, NULL, false); 2437 2402 2438 2403 map->async = false; 2439 2404 ··· 2462 2427 int ret; 2463 2428 2464 2429 map->lock(map->lock_arg); 2465 - ret = _regmap_update_bits(map, reg, mask, val, change); 2430 + ret = _regmap_update_bits(map, reg, mask, val, change, false); 2466 2431 map->unlock(map->lock_arg); 2467 2432 return ret; 2468 2433 } ··· 2495 2460 2496 2461 map->async = true; 2497 2462 2498 - ret = _regmap_update_bits(map, reg, mask, val, change); 2463 + ret = _regmap_update_bits(map, reg, mask, val, change, false); 2499 2464 2500 2465 map->async = false; 2501 2466 ··· 2587 2552 * The caller must ensure that this function cannot be called 2588 2553 * concurrently with either itself or regcache_sync(). 2589 2554 */ 2590 - int regmap_register_patch(struct regmap *map, const struct reg_default *regs, 2555 + int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, 2591 2556 int num_regs) 2592 2557 { 2593 - struct reg_default *p; 2558 + struct reg_sequence *p; 2594 2559 int ret; 2595 2560 bool bypass; 2596 2561 ··· 2599 2564 return 0; 2600 2565 2601 2566 p = krealloc(map->patch, 2602 - sizeof(struct reg_default) * (map->patch_regs + num_regs), 2567 + sizeof(struct reg_sequence) * (map->patch_regs + num_regs), 2603 2568 GFP_KERNEL); 2604 2569 if (p) { 2605 2570 memcpy(p + map->patch_regs, regs, num_regs * sizeof(*regs));
+1 -1
drivers/gpu/drm/i2c/adv7511.c
··· 54 54 } 55 55 56 56 /* ADI recommended values for proper operation. */ 57 - static const struct reg_default adv7511_fixed_registers[] = { 57 + static const struct reg_sequence adv7511_fixed_registers[] = { 58 58 { 0x98, 0x03 }, 59 59 { 0x9a, 0xe0 }, 60 60 { 0x9c, 0x30 },
+3 -3
drivers/input/misc/drv260x.c
··· 313 313 gpiod_set_value(haptics->enable_gpio, 0); 314 314 } 315 315 316 - static const struct reg_default drv260x_lra_cal_regs[] = { 316 + static const struct reg_sequence drv260x_lra_cal_regs[] = { 317 317 { DRV260X_MODE, DRV260X_AUTO_CAL }, 318 318 { DRV260X_CTRL3, DRV260X_NG_THRESH_2 }, 319 319 { DRV260X_FEEDBACK_CTRL, DRV260X_FB_REG_LRA_MODE | 320 320 DRV260X_BRAKE_FACTOR_4X | DRV260X_LOOP_GAIN_HIGH }, 321 321 }; 322 322 323 - static const struct reg_default drv260x_lra_init_regs[] = { 323 + static const struct reg_sequence drv260x_lra_init_regs[] = { 324 324 { DRV260X_MODE, DRV260X_RT_PLAYBACK }, 325 325 { DRV260X_A_TO_V_CTRL, DRV260X_AUDIO_HAPTICS_PEAK_20MS | 326 326 DRV260X_AUDIO_HAPTICS_FILTER_125HZ }, ··· 337 337 { DRV260X_CTRL4, DRV260X_AUTOCAL_TIME_500MS }, 338 338 }; 339 339 340 - static const struct reg_default drv260x_erm_cal_regs[] = { 340 + static const struct reg_sequence drv260x_erm_cal_regs[] = { 341 341 { DRV260X_MODE, DRV260X_AUTO_CAL }, 342 342 { DRV260X_A_TO_V_MIN_INPUT, DRV260X_AUDIO_HAPTICS_MIN_IN_VOLT }, 343 343 { DRV260X_A_TO_V_MAX_INPUT, DRV260X_AUDIO_HAPTICS_MAX_IN_VOLT },
+1 -1
drivers/input/misc/drv2665.c
··· 132 132 "Failed to enter standby mode: %d\n", error); 133 133 } 134 134 135 - static const struct reg_default drv2665_init_regs[] = { 135 + static const struct reg_sequence drv2665_init_regs[] = { 136 136 { DRV2665_CTRL_2, 0 | DRV2665_10_MS_IDLE_TOUT }, 137 137 { DRV2665_CTRL_1, DRV2665_25_VPP_GAIN }, 138 138 };
+2 -2
drivers/input/misc/drv2667.c
··· 262 262 "Failed to enter standby mode: %d\n", error); 263 263 } 264 264 265 - static const struct reg_default drv2667_init_regs[] = { 265 + static const struct reg_sequence drv2667_init_regs[] = { 266 266 { DRV2667_CTRL_2, 0 }, 267 267 { DRV2667_CTRL_1, DRV2667_25_VPP_GAIN }, 268 268 { DRV2667_WV_SEQ_0, 1 }, 269 269 { DRV2667_WV_SEQ_1, 0 } 270 270 }; 271 271 272 - static const struct reg_default drv2667_page1_init[] = { 272 + static const struct reg_sequence drv2667_page1_init[] = { 273 273 { DRV2667_RAM_HDR_SZ, 0x05 }, 274 274 { DRV2667_RAM_START_HI, 0x80 }, 275 275 { DRV2667_RAM_START_LO, 0x06 },
+1 -1
drivers/mfd/arizona-core.c
··· 392 392 * Register patch to some of the CODECs internal write sequences 393 393 * to ensure a clean exit from the low power sleep state. 394 394 */ 395 - static const struct reg_default wm5110_sleep_patch[] = { 395 + static const struct reg_sequence wm5110_sleep_patch[] = { 396 396 { 0x337A, 0xC100 }, 397 397 { 0x337B, 0x0041 }, 398 398 { 0x3300, 0xA210 },
+1 -1
drivers/mfd/twl6040.c
··· 86 86 { 0x2E, 0x00 }, /* REG_STATUS (ro) */ 87 87 }; 88 88 89 - static struct reg_default twl6040_patch[] = { 89 + static struct reg_sequence twl6040_patch[] = { 90 90 /* 91 91 * Select I2C bus access to dual access registers 92 92 * Interrupt register is cleared on read
+3 -3
drivers/mfd/wm5102-tables.c
··· 21 21 #define WM5102_NUM_AOD_ISR 2 22 22 #define WM5102_NUM_ISR 5 23 23 24 - static const struct reg_default wm5102_reva_patch[] = { 24 + static const struct reg_sequence wm5102_reva_patch[] = { 25 25 { 0x80, 0x0003 }, 26 26 { 0x221, 0x0090 }, 27 27 { 0x211, 0x0014 }, ··· 57 57 { 0x80, 0x0000 }, 58 58 }; 59 59 60 - static const struct reg_default wm5102_revb_patch[] = { 60 + static const struct reg_sequence wm5102_revb_patch[] = { 61 61 { 0x19, 0x0001 }, 62 62 { 0x80, 0x0003 }, 63 63 { 0x081, 0xE022 }, ··· 80 80 /* We use a function so we can use ARRAY_SIZE() */ 81 81 int wm5102_patch(struct arizona *arizona) 82 82 { 83 - const struct reg_default *wm5102_patch; 83 + const struct reg_sequence *wm5102_patch; 84 84 int patch_size; 85 85 86 86 switch (arizona->rev) {
+3 -3
drivers/mfd/wm5110-tables.c
··· 21 21 #define WM5110_NUM_AOD_ISR 2 22 22 #define WM5110_NUM_ISR 5 23 23 24 - static const struct reg_default wm5110_reva_patch[] = { 24 + static const struct reg_sequence wm5110_reva_patch[] = { 25 25 { 0x80, 0x3 }, 26 26 { 0x44, 0x20 }, 27 27 { 0x45, 0x40 }, ··· 134 134 { 0x209, 0x002A }, 135 135 }; 136 136 137 - static const struct reg_default wm5110_revb_patch[] = { 137 + static const struct reg_sequence wm5110_revb_patch[] = { 138 138 { 0x80, 0x3 }, 139 139 { 0x36e, 0x0210 }, 140 140 { 0x370, 0x0210 }, ··· 224 224 { 0x80, 0x0 }, 225 225 }; 226 226 227 - static const struct reg_default wm5110_revd_patch[] = { 227 + static const struct reg_sequence wm5110_revd_patch[] = { 228 228 { 0x80, 0x3 }, 229 229 { 0x80, 0x3 }, 230 230 { 0x393, 0x27 },
+4 -4
drivers/mfd/wm8994-core.c
··· 243 243 } 244 244 #endif 245 245 246 - static const struct reg_default wm8994_revc_patch[] = { 246 + static const struct reg_sequence wm8994_revc_patch[] = { 247 247 { 0x102, 0x3 }, 248 248 { 0x56, 0x3 }, 249 249 { 0x817, 0x0 }, 250 250 { 0x102, 0x0 }, 251 251 }; 252 252 253 - static const struct reg_default wm8958_reva_patch[] = { 253 + static const struct reg_sequence wm8958_reva_patch[] = { 254 254 { 0x102, 0x3 }, 255 255 { 0xcb, 0x81 }, 256 256 { 0x817, 0x0 }, 257 257 { 0x102, 0x0 }, 258 258 }; 259 259 260 - static const struct reg_default wm1811_reva_patch[] = { 260 + static const struct reg_sequence wm1811_reva_patch[] = { 261 261 { 0x102, 0x3 }, 262 262 { 0x56, 0xc07 }, 263 263 { 0x5d, 0x7e }, ··· 326 326 { 327 327 struct wm8994_pdata *pdata; 328 328 struct regmap_config *regmap_config; 329 - const struct reg_default *regmap_patch = NULL; 329 + const struct reg_sequence *regmap_patch = NULL; 330 330 const char *devname; 331 331 int ret, i, patch_regs = 0; 332 332 int pulls = 0;
+1 -1
drivers/mfd/wm8997-tables.c
··· 17 17 18 18 #include "arizona.h" 19 19 20 - static const struct reg_default wm8997_reva_patch[] = { 20 + static const struct reg_sequence wm8997_reva_patch[] = { 21 21 { 0x80, 0x0003 }, 22 22 { 0x214, 0x0008 }, 23 23 { 0x458, 0x0000 },
+25 -3
include/linux/regmap.h
··· 50 50 unsigned int def; 51 51 }; 52 52 53 + /** 54 + * Register/value pairs for sequences of writes 55 + * 56 + * @reg: Register address. 57 + * @def: Register value. 58 + */ 59 + struct reg_sequence { 60 + unsigned int reg; 61 + unsigned int def; 62 + }; 63 + 53 64 #ifdef CONFIG_REGMAP 54 65 55 66 enum regmap_endian { ··· 421 410 const void *val, size_t val_len); 422 411 int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, 423 412 size_t val_count); 424 - int regmap_multi_reg_write(struct regmap *map, const struct reg_default *regs, 413 + int regmap_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, 425 414 int num_regs); 426 415 int regmap_multi_reg_write_bypassed(struct regmap *map, 427 - const struct reg_default *regs, 416 + const struct reg_sequence *regs, 428 417 int num_regs); 429 418 int regmap_raw_write_async(struct regmap *map, unsigned int reg, 430 419 const void *val, size_t val_len); ··· 434 423 int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, 435 424 size_t val_count); 436 425 int regmap_update_bits(struct regmap *map, unsigned int reg, 426 + unsigned int mask, unsigned int val); 427 + int regmap_write_bits(struct regmap *map, unsigned int reg, 437 428 unsigned int mask, unsigned int val); 438 429 int regmap_update_bits_async(struct regmap *map, unsigned int reg, 439 430 unsigned int mask, unsigned int val); ··· 463 450 bool regmap_check_range_table(struct regmap *map, unsigned int reg, 464 451 const struct regmap_access_table *table); 465 452 466 - int regmap_register_patch(struct regmap *map, const struct reg_default *regs, 453 + int regmap_register_patch(struct regmap *map, const struct reg_sequence *regs, 467 454 int num_regs); 468 455 int regmap_parse_val(struct regmap *map, const void *buf, 469 456 unsigned int *val); ··· 515 502 unsigned int mask, unsigned int val); 516 503 517 504 int regmap_fields_write(struct regmap_field *field, unsigned int id, 505 + unsigned int val); 506 + int regmap_fields_force_write(struct regmap_field *field, unsigned int id, 518 507 unsigned int val); 519 508 int regmap_fields_read(struct regmap_field *field, unsigned int id, 520 509 unsigned int *val); ··· 654 639 } 655 640 656 641 static inline int regmap_update_bits(struct regmap *map, unsigned int reg, 642 + unsigned int mask, unsigned int val) 643 + { 644 + WARN_ONCE(1, "regmap API is disabled"); 645 + return -EINVAL; 646 + } 647 + 648 + static inline int regmap_write_bits(struct regmap *map, unsigned int reg, 657 649 unsigned int mask, unsigned int val) 658 650 { 659 651 WARN_ONCE(1, "regmap API is disabled");
+14
include/sound/rcar_snd.h
··· 61 61 /* 62 62 * flags 63 63 */ 64 + struct rsnd_ctu_platform_info { 65 + u32 flags; 66 + }; 67 + 68 + struct rsnd_mix_platform_info { 69 + u32 flags; 70 + }; 71 + 64 72 struct rsnd_dvc_platform_info { 65 73 u32 flags; 66 74 }; ··· 76 68 struct rsnd_dai_path_info { 77 69 struct rsnd_ssi_platform_info *ssi; 78 70 struct rsnd_src_platform_info *src; 71 + struct rsnd_ctu_platform_info *ctu; 72 + struct rsnd_mix_platform_info *mix; 79 73 struct rsnd_dvc_platform_info *dvc; 80 74 }; 81 75 ··· 103 93 int ssi_info_nr; 104 94 struct rsnd_src_platform_info *src_info; 105 95 int src_info_nr; 96 + struct rsnd_ctu_platform_info *ctu_info; 97 + int ctu_info_nr; 98 + struct rsnd_mix_platform_info *mix_info; 99 + int mix_info_nr; 106 100 struct rsnd_dvc_platform_info *dvc_info; 107 101 int dvc_info_nr; 108 102 struct rsnd_dai_platform_info *dai_info;
+1 -1
sound/soc/codecs/arizona.c
··· 1366 1366 { 1367 1367 struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); 1368 1368 struct arizona *arizona = priv->arizona; 1369 - struct reg_default dac_comp[] = { 1369 + struct reg_sequence dac_comp[] = { 1370 1370 { 0x80, 0x3 }, 1371 1371 { ARIZONA_DAC_COMP_1, 0 }, 1372 1372 { ARIZONA_DAC_COMP_2, 0 },
+1 -1
sound/soc/codecs/cs35l32.c
··· 241 241 }; 242 242 243 243 /* Current and threshold powerup sequence Pg37 in datasheet */ 244 - static const struct reg_default cs35l32_monitor_patch[] = { 244 + static const struct reg_sequence cs35l32_monitor_patch[] = { 245 245 246 246 { 0x00, 0x99 }, 247 247 { 0x48, 0x17 },
+1 -1
sound/soc/codecs/cs42l52.c
··· 1067 1067 }; 1068 1068 1069 1069 /* Current and threshold powerup sequence Pg37 */ 1070 - static const struct reg_default cs42l52_threshold_patch[] = { 1070 + static const struct reg_sequence cs42l52_threshold_patch[] = { 1071 1071 1072 1072 { 0x00, 0x99 }, 1073 1073 { 0x3E, 0xBA },
+2 -2
sound/soc/codecs/da7210.c
··· 1182 1182 1183 1183 #if IS_ENABLED(CONFIG_I2C) 1184 1184 1185 - static const struct reg_default da7210_regmap_i2c_patch[] = { 1185 + static const struct reg_sequence da7210_regmap_i2c_patch[] = { 1186 1186 1187 1187 /* System controller master disable */ 1188 1188 { DA7210_STARTUP1, 0x00 }, ··· 1268 1268 1269 1269 #if defined(CONFIG_SPI_MASTER) 1270 1270 1271 - static const struct reg_default da7210_regmap_spi_patch[] = { 1271 + static const struct reg_sequence da7210_regmap_spi_patch[] = { 1272 1272 /* Dummy read to give two pulses over nCS for SPI */ 1273 1273 { DA7210_AUX2, 0x00 }, 1274 1274 { DA7210_AUX2, 0x00 },
+89 -17
sound/soc/codecs/rl6231.c
··· 11 11 */ 12 12 13 13 #include <linux/module.h> 14 + #include <linux/regmap.h> 14 15 15 16 #include "rl6231.h" 16 17 17 18 /** 18 - * rl6231_calc_dmic_clk - Calculate the parameter of dmic. 19 + * rl6231_get_pre_div - Return the value of pre divider. 20 + * 21 + * @map: map for setting. 22 + * @reg: register. 23 + * @sft: shift. 24 + * 25 + * Return the value of pre divider from given register value. 26 + * Return negative error code for unexpected register value. 27 + */ 28 + int rl6231_get_pre_div(struct regmap *map, unsigned int reg, int sft) 29 + { 30 + int pd, val; 31 + 32 + regmap_read(map, reg, &val); 33 + 34 + val = (val >> sft) & 0x7; 35 + 36 + switch (val) { 37 + case 0: 38 + case 1: 39 + case 2: 40 + case 3: 41 + pd = val + 1; 42 + break; 43 + case 4: 44 + pd = 6; 45 + break; 46 + case 5: 47 + pd = 8; 48 + break; 49 + case 6: 50 + pd = 12; 51 + break; 52 + case 7: 53 + pd = 16; 54 + break; 55 + default: 56 + pd = -EINVAL; 57 + break; 58 + } 59 + 60 + return pd; 61 + } 62 + EXPORT_SYMBOL_GPL(rl6231_get_pre_div); 63 + 64 + /** 65 + * rl6231_calc_dmic_clk - Calculate the frequency divider parameter of dmic. 19 66 * 20 67 * @rate: base clock rate. 21 68 * 22 - * Choose dmic clock between 1MHz and 3MHz. 23 - * It is better for clock to approximate 3MHz. 69 + * Choose divider parameter that gives the highest possible DMIC frequency in 70 + * 1MHz - 3MHz range. 24 71 */ 25 72 int rl6231_calc_dmic_clk(int rate) 26 73 { 27 - int div[] = {2, 3, 4, 6, 8, 12}, idx = -EINVAL; 28 - int i, red, bound, temp; 74 + int div[] = {2, 3, 4, 6, 8, 12}; 75 + int i; 29 76 30 - red = 3000000 * 12; 31 - for (i = 0; i < ARRAY_SIZE(div); i++) { 32 - bound = div[i] * 3000000; 33 - if (rate > bound) 34 - continue; 35 - temp = bound - rate; 36 - if (temp < red) { 37 - red = temp; 38 - idx = i; 39 - } 77 + if (rate < 1000000 * div[0]) { 78 + pr_warn("Base clock rate %d is too low\n", rate); 79 + return -EINVAL; 40 80 } 41 81 42 - return idx; 82 + for (i = 0; i < ARRAY_SIZE(div); i++) { 83 + /* find divider that gives DMIC frequency below 3MHz */ 84 + if (3000000 * div[i] >= rate) 85 + return i; 86 + } 87 + 88 + pr_warn("Base clock rate %d is too high\n", rate); 89 + return -EINVAL; 43 90 } 44 91 EXPORT_SYMBOL_GPL(rl6231_calc_dmic_clk); 92 + 93 + struct pll_calc_map { 94 + unsigned int pll_in; 95 + unsigned int pll_out; 96 + int k; 97 + int n; 98 + int m; 99 + bool m_bp; 100 + }; 101 + 102 + static const struct pll_calc_map pll_preset_table[] = { 103 + {19200000, 24576000, 3, 30, 3, false}, 104 + }; 45 105 46 106 /** 47 107 * rl6231_pll_calc - Calcualte PLL M/N/K code. ··· 117 57 const unsigned int freq_out, struct rl6231_pll_code *pll_code) 118 58 { 119 59 int max_n = RL6231_PLL_N_MAX, max_m = RL6231_PLL_M_MAX; 120 - int k, red, n_t, pll_out, in_t, out_t; 60 + int i, k, red, n_t, pll_out, in_t, out_t; 121 61 int n = 0, m = 0, m_t = 0; 122 62 int red_t = abs(freq_out - freq_in); 123 63 bool bypass = false; 124 64 125 65 if (RL6231_PLL_INP_MAX < freq_in || RL6231_PLL_INP_MIN > freq_in) 126 66 return -EINVAL; 67 + 68 + for (i = 0; i < ARRAY_SIZE(pll_preset_table); i++) { 69 + if (freq_in == pll_preset_table[i].pll_in && 70 + freq_out == pll_preset_table[i].pll_out) { 71 + k = pll_preset_table[i].k; 72 + m = pll_preset_table[i].m; 73 + n = pll_preset_table[i].n; 74 + bypass = pll_preset_table[i].m_bp; 75 + pr_debug("Use preset PLL parameter table\n"); 76 + goto code_find; 77 + } 78 + } 127 79 128 80 k = 100000000 / freq_out - 2; 129 81 if (k > RL6231_PLL_K_MAX)
+1
sound/soc/codecs/rl6231.h
··· 30 30 int rl6231_pll_calc(const unsigned int freq_in, 31 31 const unsigned int freq_out, struct rl6231_pll_code *pll_code); 32 32 int rl6231_get_clk_info(int sclk, int rate); 33 + int rl6231_get_pre_div(struct regmap *map, unsigned int reg, int sft); 33 34 34 35 #endif /* __RL6231_H__ */
+3 -3
sound/soc/codecs/rt286.c
··· 1108 1108 }; 1109 1109 MODULE_DEVICE_TABLE(acpi, rt286_acpi_match); 1110 1110 1111 - static struct dmi_system_id force_combo_jack_table[] = { 1111 + static const struct dmi_system_id force_combo_jack_table[] = { 1112 1112 { 1113 1113 .ident = "Intel Wilson Beach", 1114 1114 .matches = { ··· 1118 1118 { } 1119 1119 }; 1120 1120 1121 - static struct dmi_system_id dmi_dell_dino[] = { 1121 + static const struct dmi_system_id dmi_dell_dino[] = { 1122 1122 { 1123 1123 .ident = "Dell Dino", 1124 1124 .matches = { ··· 1157 1157 } 1158 1158 if (val != RT286_VENDOR_ID && val != RT288_VENDOR_ID) { 1159 1159 dev_err(&i2c->dev, 1160 - "Device with ID register %x is not rt286\n", val); 1160 + "Device with ID register %#x is not rt286\n", val); 1161 1161 return -ENODEV; 1162 1162 } 1163 1163
+5 -4
sound/soc/codecs/rt5640.c
··· 51 51 .window_len = 0x1, }, 52 52 }; 53 53 54 - static const struct reg_default init_list[] = { 54 + static const struct reg_sequence init_list[] = { 55 55 {RT5640_PR_BASE + 0x3d, 0x3600}, 56 56 {RT5640_PR_BASE + 0x12, 0x0aa8}, 57 57 {RT5640_PR_BASE + 0x14, 0x0aaa}, ··· 459 459 { 460 460 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 461 461 struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); 462 - int idx = -EINVAL; 462 + int idx, rate; 463 463 464 - idx = rl6231_calc_dmic_clk(rt5640->sysclk); 465 - 464 + rate = rt5640->sysclk / rl6231_get_pre_div(rt5640->regmap, 465 + RT5640_ADDA_CLK1, RT5640_I2S_PD1_SFT); 466 + idx = rl6231_calc_dmic_clk(rate); 466 467 if (idx < 0) 467 468 dev_err(codec->dev, "Failed to set DMIC clock\n"); 468 469 else
+6 -5
sound/soc/codecs/rt5645.c
··· 55 55 }, 56 56 }; 57 57 58 - static const struct reg_default init_list[] = { 58 + static const struct reg_sequence init_list[] = { 59 59 {RT5645_PR_BASE + 0x3d, 0x3600}, 60 60 {RT5645_PR_BASE + 0x1c, 0xfd20}, 61 61 {RT5645_PR_BASE + 0x20, 0x611f}, ··· 64 64 }; 65 65 #define RT5645_INIT_REG_LEN ARRAY_SIZE(init_list) 66 66 67 - static const struct reg_default rt5650_init_list[] = { 67 + static const struct reg_sequence rt5650_init_list[] = { 68 68 {0xf6, 0x0100}, 69 69 }; 70 70 ··· 545 545 { 546 546 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 547 547 struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); 548 - int idx = -EINVAL; 548 + int idx, rate; 549 549 550 - idx = rl6231_calc_dmic_clk(rt5645->sysclk); 551 - 550 + rate = rt5645->sysclk / rl6231_get_pre_div(rt5645->regmap, 551 + RT5645_ADDA_CLK1, RT5645_I2S_PD1_SFT); 552 + idx = rl6231_calc_dmic_clk(rate); 552 553 if (idx < 0) 553 554 dev_err(codec->dev, "Failed to set DMIC clock\n"); 554 555 else
+5 -4
sound/soc/codecs/rt5651.c
··· 46 46 .window_len = 0x1, }, 47 47 }; 48 48 49 - static const struct reg_default init_list[] = { 49 + static const struct reg_sequence init_list[] = { 50 50 {RT5651_PR_BASE + 0x3d, 0x3e00}, 51 51 }; 52 52 ··· 378 378 { 379 379 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 380 380 struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); 381 - int idx = -EINVAL; 381 + int idx, rate; 382 382 383 - idx = rl6231_calc_dmic_clk(rt5651->sysclk); 384 - 383 + rate = rt5651->sysclk / rl6231_get_pre_div(rt5651->regmap, 384 + RT5651_ADDA_CLK1, RT5651_I2S_PD1_SFT); 385 + idx = rl6231_calc_dmic_clk(rate); 385 386 if (idx < 0) 386 387 dev_err(codec->dev, "Failed to set DMIC clock\n"); 387 388 else
+5 -4
sound/soc/codecs/rt5670.c
··· 51 51 .window_len = 0x1, }, 52 52 }; 53 53 54 - static const struct reg_default init_list[] = { 54 + static const struct reg_sequence init_list[] = { 55 55 { RT5670_PR_BASE + 0x14, 0x9a8a }, 56 56 { RT5670_PR_BASE + 0x38, 0x3ba1 }, 57 57 { RT5670_PR_BASE + 0x3d, 0x3640 }, ··· 683 683 { 684 684 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 685 685 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); 686 - int idx = -EINVAL; 686 + int idx, rate; 687 687 688 - idx = rl6231_calc_dmic_clk(rt5670->sysclk); 689 - 688 + rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, 689 + RT5670_ADDA_CLK1, RT5670_I2S_PD1_SFT); 690 + idx = rl6231_calc_dmic_clk(rate); 690 691 if (idx < 0) 691 692 dev_err(codec->dev, "Failed to set DMIC clock\n"); 692 693 else
+5 -2
sound/soc/codecs/rt5677.c
··· 54 54 }, 55 55 }; 56 56 57 - static const struct reg_default init_list[] = { 57 + static const struct reg_sequence init_list[] = { 58 58 {RT5677_ASRC_12, 0x0018}, 59 59 {RT5677_PR_BASE + 0x3d, 0x364d}, 60 60 {RT5677_PR_BASE + 0x17, 0x4fc0}, ··· 917 917 { 918 918 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 919 919 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 920 - int idx = rl6231_calc_dmic_clk(rt5677->lrck[RT5677_AIF1] << 8); 920 + int idx, rate; 921 921 922 + rate = rt5677->sysclk / rl6231_get_pre_div(rt5677->regmap, 923 + RT5677_CLK_TREE_CTRL1, RT5677_I2S_PD1_SFT); 924 + idx = rl6231_calc_dmic_clk(rate); 922 925 if (idx < 0) 923 926 dev_err(codec->dev, "Failed to set DMIC clock\n"); 924 927 else
+1 -1
sound/soc/codecs/tlv320aic3x.c
··· 1668 1668 }; 1669 1669 MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id); 1670 1670 1671 - static const struct reg_default aic3007_class_d[] = { 1671 + static const struct reg_sequence aic3007_class_d[] = { 1672 1672 /* Class-D speaker driver init; datasheet p. 46 */ 1673 1673 { AIC3X_PAGE_SELECT, 0x0D }, 1674 1674 { 0xD, 0x0D },
+1 -1
sound/soc/codecs/wm2200.c
··· 897 897 } 898 898 } 899 899 900 - static const struct reg_default wm2200_reva_patch[] = { 900 + static const struct reg_sequence wm2200_reva_patch[] = { 901 901 { 0x07, 0x0003 }, 902 902 { 0x102, 0x0200 }, 903 903 { 0x203, 0x0084 },
+1 -1
sound/soc/codecs/wm5100.c
··· 1247 1247 { "PWM2", NULL, "PWM2 Driver" }, 1248 1248 }; 1249 1249 1250 - static const struct reg_default wm5100_reva_patches[] = { 1250 + static const struct reg_sequence wm5100_reva_patches[] = { 1251 1251 { WM5100_AUDIO_IF_1_10, 0 }, 1252 1252 { WM5100_AUDIO_IF_1_11, 1 }, 1253 1253 { WM5100_AUDIO_IF_1_12, 2 },
+1 -1
sound/soc/codecs/wm8962.c
··· 3495 3495 }; 3496 3496 3497 3497 /* Improve power consumption for IN4 DC measurement mode */ 3498 - static const struct reg_default wm8962_dc_measure[] = { 3498 + static const struct reg_sequence wm8962_dc_measure[] = { 3499 3499 { 0xfd, 0x1 }, 3500 3500 { 0xcc, 0x40 }, 3501 3501 { 0xfd, 0 },
+1 -1
sound/soc/codecs/wm8993.c
··· 1595 1595 #endif 1596 1596 1597 1597 /* Tune DC servo configuration */ 1598 - static const struct reg_default wm8993_regmap_patch[] = { 1598 + static const struct reg_sequence wm8993_regmap_patch[] = { 1599 1599 { 0x44, 3 }, 1600 1600 { 0x56, 3 }, 1601 1601 { 0x44, 0 },
-1
sound/soc/rockchip/rockchip_max98090.c
··· 223 223 .probe = snd_rk_mc_probe, 224 224 .driver = { 225 225 .name = DRV_NAME, 226 - .owner = THIS_MODULE, 227 226 .pm = &snd_soc_pm_ops, 228 227 .of_match_table = rockchip_max98090_of_match, 229 228 },
+1 -2
sound/soc/rockchip/rockchip_rt5645.c
··· 118 118 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 119 119 SND_JACK_BTN_2 | SND_JACK_BTN_3, 120 120 &headset_jack, NULL, 0); 121 - if (!ret) { 121 + if (ret) { 122 122 dev_err(card->dev, "New Headset Jack failed! (%d)\n", ret); 123 123 return ret; 124 124 } ··· 212 212 .probe = snd_rk_mc_probe, 213 213 .driver = { 214 214 .name = DRV_NAME, 215 - .owner = THIS_MODULE, 216 215 .pm = &snd_soc_pm_ops, 217 216 .of_match_table = rockchip_rt5645_of_match, 218 217 },
+1 -1
sound/soc/sh/rcar/Makefile
··· 1 - snd-soc-rcar-objs := core.o gen.o dma.o src.o adg.o ssi.o dvc.o 1 + snd-soc-rcar-objs := core.o gen.o dma.o adg.o ssi.o src.o ctu.o mix.o dvc.o 2 2 obj-$(CONFIG_SND_SOC_RCAR) += snd-soc-rcar.o 3 3 4 4 snd-soc-rsrc-card-objs := rsrc-card.o
+174 -23
sound/soc/sh/rcar/core.c
··· 203 203 } 204 204 205 205 /* 206 - * settting function 206 + * ADINR function 207 207 */ 208 - u32 rsnd_get_adinr(struct rsnd_mod *mod, struct rsnd_dai_stream *io) 208 + u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io) 209 209 { 210 210 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 211 211 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); ··· 227 227 return adinr; 228 228 } 229 229 230 + u32 rsnd_get_adinr_chan(struct rsnd_mod *mod, struct rsnd_dai_stream *io) 231 + { 232 + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 233 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 234 + struct device *dev = rsnd_priv_to_dev(priv); 235 + u32 chan = runtime->channels; 236 + 237 + switch (chan) { 238 + case 1: 239 + case 2: 240 + case 4: 241 + case 6: 242 + case 8: 243 + break; 244 + default: 245 + dev_warn(dev, "not supported channel\n"); 246 + chan = 0; 247 + break; 248 + } 249 + 250 + return chan; 251 + } 252 + 253 + /* 254 + * DALIGN function 255 + */ 256 + u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io) 257 + { 258 + struct rsnd_mod *src = rsnd_io_to_mod_src(io); 259 + struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io); 260 + struct rsnd_mod *target = src ? src : ssi; 261 + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 262 + u32 val = 0x76543210; 263 + u32 mask = ~0; 264 + 265 + mask <<= runtime->channels * 4; 266 + val = val & mask; 267 + 268 + switch (runtime->sample_bits) { 269 + case 16: 270 + val |= 0x67452301 & ~mask; 271 + break; 272 + case 32: 273 + val |= 0x76543210 & ~mask; 274 + break; 275 + } 276 + 277 + /* 278 + * exchange channeles on SRC if possible, 279 + * otherwise, R/L volume settings on DVC 280 + * changes inverted channels 281 + */ 282 + if (mod == target) 283 + return val; 284 + else 285 + return 0x76543210; 286 + } 287 + 230 288 /* 231 289 * rsnd_dai functions 232 290 */ ··· 300 242 if (val == __rsnd_mod_call_##func) { \ 301 243 called = 1; \ 302 244 ret = (mod)->ops->func(mod, io, param); \ 303 - mod->status = (mod->status & ~mask) + \ 304 - (add << __rsnd_mod_shift_##func); \ 305 245 } \ 246 + mod->status = (mod->status & ~mask) + \ 247 + (add << __rsnd_mod_shift_##func); \ 306 248 dev_dbg(dev, "%s[%d] 0x%08x %s\n", \ 307 249 rsnd_mod_name(mod), rsnd_mod_id(mod), mod->status, \ 308 250 called ? #func : ""); \ ··· 332 274 static int rsnd_dai_connect(struct rsnd_mod *mod, 333 275 struct rsnd_dai_stream *io) 334 276 { 277 + struct rsnd_priv *priv; 278 + struct device *dev; 279 + 335 280 if (!mod) 336 281 return -EIO; 337 282 338 - if (io->mod[mod->type]) { 339 - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 340 - struct device *dev = rsnd_priv_to_dev(priv); 341 - 342 - dev_err(dev, "%s[%d] is not empty\n", 343 - rsnd_mod_name(mod), 344 - rsnd_mod_id(mod)); 345 - return -EIO; 346 - } 283 + priv = rsnd_mod_to_priv(mod); 284 + dev = rsnd_priv_to_dev(priv); 347 285 348 286 io->mod[mod->type] = mod; 287 + 288 + dev_dbg(dev, "%s[%d] is connected to io (%s)\n", 289 + rsnd_mod_name(mod), rsnd_mod_id(mod), 290 + rsnd_io_is_play(io) ? "Playback" : "Capture"); 349 291 350 292 return 0; 351 293 } ··· 575 517 .set_fmt = rsnd_soc_dai_set_fmt, 576 518 }; 577 519 578 - #define rsnd_path_parse(priv, io, type) \ 520 + #define rsnd_path_add(priv, io, type) \ 579 521 ({ \ 580 522 struct rsnd_mod *mod; \ 581 523 int ret = 0; \ ··· 591 533 ret; \ 592 534 }) 593 535 594 - #define rsnd_path_break(priv, io, type) \ 536 + #define rsnd_path_remove(priv, io, type) \ 595 537 { \ 596 538 struct rsnd_mod *mod; \ 597 539 int id = -1; \ ··· 603 545 rsnd_dai_disconnect(mod, io); \ 604 546 } \ 605 547 } \ 548 + } 549 + 550 + void rsnd_path_parse(struct rsnd_priv *priv, 551 + struct rsnd_dai_stream *io) 552 + { 553 + struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io); 554 + struct rsnd_mod *mix = rsnd_io_to_mod_mix(io); 555 + struct rsnd_mod *src = rsnd_io_to_mod_src(io); 556 + struct rsnd_mod *cmd; 557 + struct device *dev = rsnd_priv_to_dev(priv); 558 + u32 data; 559 + 560 + /* Gen1 is not supported */ 561 + if (rsnd_is_gen1(priv)) 562 + return; 563 + 564 + if (!mix && !dvc) 565 + return; 566 + 567 + if (mix) { 568 + struct rsnd_dai *rdai; 569 + int i; 570 + u32 path[] = { 571 + [0] = 0, 572 + [1] = 1 << 0, 573 + [2] = 0, 574 + [3] = 0, 575 + [4] = 0, 576 + [5] = 1 << 8 577 + }; 578 + 579 + /* 580 + * it is assuming that integrater is well understanding about 581 + * data path. Here doesn't check impossible connection, 582 + * like src2 + src5 583 + */ 584 + data = 0; 585 + for_each_rsnd_dai(rdai, priv, i) { 586 + io = &rdai->playback; 587 + if (mix == rsnd_io_to_mod_mix(io)) 588 + data |= path[rsnd_mod_id(src)]; 589 + 590 + io = &rdai->capture; 591 + if (mix == rsnd_io_to_mod_mix(io)) 592 + data |= path[rsnd_mod_id(src)]; 593 + } 594 + 595 + /* 596 + * We can't use ctu = rsnd_io_ctu() here. 597 + * Since, ID of dvc/mix are 0 or 1 (= same as CMD number) 598 + * but ctu IDs are 0 - 7 (= CTU00 - CTU13) 599 + */ 600 + cmd = mix; 601 + } else { 602 + u32 path[] = { 603 + [0] = 0x30000, 604 + [1] = 0x30001, 605 + [2] = 0x40000, 606 + [3] = 0x10000, 607 + [4] = 0x20000, 608 + [5] = 0x40100 609 + }; 610 + 611 + data = path[rsnd_mod_id(src)]; 612 + 613 + cmd = dvc; 614 + } 615 + 616 + dev_dbg(dev, "ctu/mix path = 0x%08x", data); 617 + 618 + rsnd_mod_write(cmd, CMD_ROUTE_SLCT, data); 619 + 620 + rsnd_mod_write(cmd, CMD_CTRL, 0x10); 606 621 } 607 622 608 623 static int rsnd_path_init(struct rsnd_priv *priv, ··· 695 564 * using fixed path. 696 565 */ 697 566 698 - /* SRC */ 699 - ret = rsnd_path_parse(priv, io, src); 567 + /* SSI */ 568 + ret = rsnd_path_add(priv, io, ssi); 700 569 if (ret < 0) 701 570 return ret; 702 571 703 - /* SSI */ 704 - ret = rsnd_path_parse(priv, io, ssi); 572 + /* SRC */ 573 + ret = rsnd_path_add(priv, io, src); 574 + if (ret < 0) 575 + return ret; 576 + 577 + /* CTU */ 578 + ret = rsnd_path_add(priv, io, ctu); 579 + if (ret < 0) 580 + return ret; 581 + 582 + /* MIX */ 583 + ret = rsnd_path_add(priv, io, mix); 705 584 if (ret < 0) 706 585 return ret; 707 586 708 587 /* DVC */ 709 - ret = rsnd_path_parse(priv, io, dvc); 588 + ret = rsnd_path_add(priv, io, dvc); 710 589 if (ret < 0) 711 590 return ret; 712 591 ··· 730 589 struct device_node *dai_node, *dai_np; 731 590 struct device_node *ssi_node, *ssi_np; 732 591 struct device_node *src_node, *src_np; 592 + struct device_node *ctu_node, *ctu_np; 593 + struct device_node *mix_node, *mix_np; 733 594 struct device_node *dvc_node, *dvc_np; 734 595 struct device_node *playback, *capture; 735 596 struct rsnd_dai_platform_info *dai_info; 736 597 struct rcar_snd_info *info = rsnd_priv_to_info(priv); 737 598 struct device *dev = &pdev->dev; 738 599 int nr, i; 739 - int dai_i, ssi_i, src_i, dvc_i; 600 + int dai_i, ssi_i, src_i, ctu_i, mix_i, dvc_i; 740 601 741 602 if (!of_data) 742 603 return; ··· 764 621 765 622 ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi"); 766 623 src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src"); 624 + ctu_node = of_get_child_by_name(dev->of_node, "rcar_sound,ctu"); 625 + mix_node = of_get_child_by_name(dev->of_node, "rcar_sound,mix"); 767 626 dvc_node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc"); 768 627 769 628 #define mod_parse(name) \ ··· 802 657 803 658 mod_parse(ssi); 804 659 mod_parse(src); 660 + mod_parse(ctu); 661 + mod_parse(mix); 805 662 mod_parse(dvc); 806 663 807 664 of_node_put(playback); ··· 1180 1033 /* 1181 1034 * remove SRC/DVC from DAI, 1182 1035 */ 1183 - rsnd_path_break(priv, io, src); 1184 - rsnd_path_break(priv, io, dvc); 1036 + rsnd_path_remove(priv, io, src); 1037 + rsnd_path_remove(priv, io, dvc); 1185 1038 1186 1039 /* 1187 1040 * fallback ··· 1216 1069 rsnd_dma_probe, 1217 1070 rsnd_ssi_probe, 1218 1071 rsnd_src_probe, 1072 + rsnd_ctu_probe, 1073 + rsnd_mix_probe, 1219 1074 rsnd_dvc_probe, 1220 1075 rsnd_adg_probe, 1221 1076 rsnd_dai_probe, ··· 1313 1164 struct rsnd_priv *priv) = { 1314 1165 rsnd_ssi_remove, 1315 1166 rsnd_src_remove, 1167 + rsnd_ctu_remove, 1168 + rsnd_mix_remove, 1316 1169 rsnd_dvc_remove, 1317 1170 }; 1318 1171 int ret = 0, i;
+171
sound/soc/sh/rcar/ctu.c
··· 1 + /* 2 + * ctu.c 3 + * 4 + * Copyright (c) 2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + #include "rsnd.h" 11 + 12 + #define CTU_NAME_SIZE 16 13 + #define CTU_NAME "ctu" 14 + 15 + struct rsnd_ctu { 16 + struct rsnd_ctu_platform_info *info; /* rcar_snd.h */ 17 + struct rsnd_mod mod; 18 + }; 19 + 20 + #define rsnd_ctu_nr(priv) ((priv)->ctu_nr) 21 + #define for_each_rsnd_ctu(pos, priv, i) \ 22 + for ((i) = 0; \ 23 + ((i) < rsnd_ctu_nr(priv)) && \ 24 + ((pos) = (struct rsnd_ctu *)(priv)->ctu + i); \ 25 + i++) 26 + 27 + #define rsnd_ctu_initialize_lock(mod) __rsnd_ctu_initialize_lock(mod, 1) 28 + #define rsnd_ctu_initialize_unlock(mod) __rsnd_ctu_initialize_lock(mod, 0) 29 + static void __rsnd_ctu_initialize_lock(struct rsnd_mod *mod, u32 enable) 30 + { 31 + rsnd_mod_write(mod, CTU_CTUIR, enable); 32 + } 33 + 34 + static int rsnd_ctu_init(struct rsnd_mod *mod, 35 + struct rsnd_dai_stream *io, 36 + struct rsnd_priv *priv) 37 + { 38 + rsnd_mod_hw_start(mod); 39 + 40 + rsnd_ctu_initialize_lock(mod); 41 + 42 + rsnd_mod_write(mod, CTU_ADINR, rsnd_get_adinr_chan(mod, io)); 43 + 44 + rsnd_ctu_initialize_unlock(mod); 45 + 46 + return 0; 47 + } 48 + 49 + static int rsnd_ctu_quit(struct rsnd_mod *mod, 50 + struct rsnd_dai_stream *io, 51 + struct rsnd_priv *priv) 52 + { 53 + rsnd_mod_hw_stop(mod); 54 + 55 + return 0; 56 + } 57 + 58 + static struct rsnd_mod_ops rsnd_ctu_ops = { 59 + .name = CTU_NAME, 60 + .init = rsnd_ctu_init, 61 + .quit = rsnd_ctu_quit, 62 + }; 63 + 64 + struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id) 65 + { 66 + if (WARN_ON(id < 0 || id >= rsnd_ctu_nr(priv))) 67 + id = 0; 68 + 69 + return &((struct rsnd_ctu *)(priv->ctu) + id)->mod; 70 + } 71 + 72 + static void rsnd_of_parse_ctu(struct platform_device *pdev, 73 + const struct rsnd_of_data *of_data, 74 + struct rsnd_priv *priv) 75 + { 76 + struct device_node *node; 77 + struct rsnd_ctu_platform_info *ctu_info; 78 + struct rcar_snd_info *info = rsnd_priv_to_info(priv); 79 + struct device *dev = &pdev->dev; 80 + int nr; 81 + 82 + if (!of_data) 83 + return; 84 + 85 + node = of_get_child_by_name(dev->of_node, "rcar_sound,ctu"); 86 + if (!node) 87 + return; 88 + 89 + nr = of_get_child_count(node); 90 + if (!nr) 91 + goto rsnd_of_parse_ctu_end; 92 + 93 + ctu_info = devm_kzalloc(dev, 94 + sizeof(struct rsnd_ctu_platform_info) * nr, 95 + GFP_KERNEL); 96 + if (!ctu_info) { 97 + dev_err(dev, "ctu info allocation error\n"); 98 + goto rsnd_of_parse_ctu_end; 99 + } 100 + 101 + info->ctu_info = ctu_info; 102 + info->ctu_info_nr = nr; 103 + 104 + rsnd_of_parse_ctu_end: 105 + of_node_put(node); 106 + 107 + } 108 + 109 + int rsnd_ctu_probe(struct platform_device *pdev, 110 + const struct rsnd_of_data *of_data, 111 + struct rsnd_priv *priv) 112 + { 113 + struct rcar_snd_info *info = rsnd_priv_to_info(priv); 114 + struct device *dev = rsnd_priv_to_dev(priv); 115 + struct rsnd_ctu *ctu; 116 + struct clk *clk; 117 + char name[CTU_NAME_SIZE]; 118 + int i, nr, ret; 119 + 120 + /* This driver doesn't support Gen1 at this point */ 121 + if (rsnd_is_gen1(priv)) { 122 + dev_warn(dev, "CTU is not supported on Gen1\n"); 123 + return -EINVAL; 124 + } 125 + 126 + rsnd_of_parse_ctu(pdev, of_data, priv); 127 + 128 + nr = info->ctu_info_nr; 129 + if (!nr) 130 + return 0; 131 + 132 + ctu = devm_kzalloc(dev, sizeof(*ctu) * nr, GFP_KERNEL); 133 + if (!ctu) 134 + return -ENOMEM; 135 + 136 + priv->ctu_nr = nr; 137 + priv->ctu = ctu; 138 + 139 + for_each_rsnd_ctu(ctu, priv, i) { 140 + /* 141 + * CTU00, CTU01, CTU02, CTU03 => CTU0 142 + * CTU10, CTU11, CTU12, CTU13 => CTU1 143 + */ 144 + snprintf(name, CTU_NAME_SIZE, "%s.%d", 145 + CTU_NAME, i / 4); 146 + 147 + clk = devm_clk_get(dev, name); 148 + if (IS_ERR(clk)) 149 + return PTR_ERR(clk); 150 + 151 + ctu->info = &info->ctu_info[i]; 152 + 153 + ret = rsnd_mod_init(priv, &ctu->mod, &rsnd_ctu_ops, 154 + clk, RSND_MOD_CTU, i); 155 + if (ret) 156 + return ret; 157 + } 158 + 159 + return 0; 160 + } 161 + 162 + void rsnd_ctu_remove(struct platform_device *pdev, 163 + struct rsnd_priv *priv) 164 + { 165 + struct rsnd_ctu *ctu; 166 + int i; 167 + 168 + for_each_rsnd_ctu(ctu, priv, i) { 169 + rsnd_mod_quit(&ctu->mod); 170 + } 171 + }
+96 -50
sound/soc/sh/rcar/dma.c
··· 27 27 int dmapp_num; 28 28 }; 29 29 30 + struct rsnd_dma_ops { 31 + char *name; 32 + void (*start)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 33 + void (*stop)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 34 + int (*init)(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id, 35 + struct rsnd_mod *mod_from, struct rsnd_mod *mod_to); 36 + void (*quit)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 37 + }; 38 + 30 39 #define rsnd_priv_to_dmac(p) ((struct rsnd_dma_ctrl *)(p)->dma) 31 40 32 41 /* ··· 177 168 dma_cap_set(DMA_SLAVE, mask); 178 169 179 170 dmaen->chan = dma_request_channel(mask, shdma_chan_filter, 180 - (void *)id); 171 + (void *)(uintptr_t)id); 181 172 } 182 173 if (IS_ERR_OR_NULL(dmaen->chan)) { 183 174 dmaen->chan = NULL; ··· 191 182 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 192 183 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 193 184 194 - dev_dbg(dev, "dma : %pad -> %pad\n", 185 + dev_dbg(dev, "%s %pad -> %pad\n", 186 + dma->ops->name, 195 187 &cfg.src_addr, &cfg.dst_addr); 196 188 197 189 ret = dmaengine_slave_config(dmaen->chan, &cfg); ··· 225 215 } 226 216 227 217 static struct rsnd_dma_ops rsnd_dmaen_ops = { 218 + .name = "audmac", 228 219 .start = rsnd_dmaen_start, 229 220 .stop = rsnd_dmaen_stop, 230 221 .init = rsnd_dmaen_init, ··· 371 360 } 372 361 373 362 static struct rsnd_dma_ops rsnd_dmapp_ops = { 363 + .name = "audmac-pp", 374 364 .start = rsnd_dmapp_start, 375 365 .stop = rsnd_dmapp_stop, 376 366 .init = rsnd_dmapp_init, ··· 426 414 phys_addr_t src_reg = rsnd_gen_get_phy_addr(priv, RSND_GEN2_SCU); 427 415 int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod); 428 416 int use_src = !!rsnd_io_to_mod_src(io); 429 - int use_dvc = !!rsnd_io_to_mod_dvc(io); 417 + int use_cmd = !!rsnd_io_to_mod_dvc(io) || 418 + !!rsnd_io_to_mod_mix(io) || 419 + !!rsnd_io_to_mod_ctu(io); 430 420 int id = rsnd_mod_id(mod); 431 421 struct dma_addr { 432 422 dma_addr_t out_addr; ··· 466 452 }; 467 453 468 454 /* it shouldn't happen */ 469 - if (use_dvc && !use_src) 455 + if (use_cmd && !use_src) 470 456 dev_err(dev, "DVC is selected without SRC\n"); 471 457 472 458 /* use SSIU or SSI ? */ ··· 474 460 is_ssi++; 475 461 476 462 return (is_from) ? 477 - dma_addrs[is_ssi][is_play][use_src + use_dvc].out_addr : 478 - dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr; 463 + dma_addrs[is_ssi][is_play][use_src + use_cmd].out_addr : 464 + dma_addrs[is_ssi][is_play][use_src + use_cmd].in_addr; 479 465 } 480 466 481 467 static dma_addr_t rsnd_dma_addr(struct rsnd_dai_stream *io, ··· 496 482 return rsnd_gen2_dma_addr(io, mod, is_play, is_from); 497 483 } 498 484 499 - #define MOD_MAX 4 /* MEM/SSI/SRC/DVC */ 485 + #define MOD_MAX (RSND_MOD_MAX + 1) /* +Memory */ 500 486 static void rsnd_dma_of_path(struct rsnd_dma *dma, 501 487 struct rsnd_dai_stream *io, 502 488 int is_play, ··· 506 492 struct rsnd_mod *this = rsnd_dma_to_mod(dma); 507 493 struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io); 508 494 struct rsnd_mod *src = rsnd_io_to_mod_src(io); 495 + struct rsnd_mod *ctu = rsnd_io_to_mod_ctu(io); 496 + struct rsnd_mod *mix = rsnd_io_to_mod_mix(io); 509 497 struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io); 510 498 struct rsnd_mod *mod[MOD_MAX]; 511 - int i, index; 499 + struct rsnd_mod *mod_start, *mod_end; 500 + struct rsnd_priv *priv = rsnd_mod_to_priv(this); 501 + struct device *dev = rsnd_priv_to_dev(priv); 502 + int nr, i; 512 503 504 + if (!ssi) 505 + return; 513 506 514 - for (i = 0; i < MOD_MAX; i++) 507 + nr = 0; 508 + for (i = 0; i < MOD_MAX; i++) { 515 509 mod[i] = NULL; 516 - 517 - /* 518 - * in play case... 519 - * 520 - * src -> dst 521 - * 522 - * mem -> SSI 523 - * mem -> SRC -> SSI 524 - * mem -> SRC -> DVC -> SSI 525 - */ 526 - mod[0] = NULL; /* for "mem" */ 527 - index = 1; 528 - for (i = 1; i < MOD_MAX; i++) { 529 - if (!src) { 530 - mod[i] = ssi; 531 - } else if (!dvc) { 532 - mod[i] = src; 533 - src = NULL; 534 - } else { 535 - if ((!is_play) && (this == src)) 536 - this = dvc; 537 - 538 - mod[i] = (is_play) ? src : dvc; 539 - i++; 540 - mod[i] = (is_play) ? dvc : src; 541 - src = NULL; 542 - dvc = NULL; 543 - } 544 - 545 - if (mod[i] == this) 546 - index = i; 547 - 548 - if (mod[i] == ssi) 549 - break; 510 + nr += !!rsnd_io_to_mod(io, i); 550 511 } 551 512 552 - if (is_play) { 553 - *mod_from = mod[index - 1]; 554 - *mod_to = mod[index]; 513 + /* 514 + * [S] -*-> [E] 515 + * [S] -*-> SRC -o-> [E] 516 + * [S] -*-> SRC -> DVC -o-> [E] 517 + * [S] -*-> SRC -> CTU -> MIX -> DVC -o-> [E] 518 + * 519 + * playback [S] = mem 520 + * [E] = SSI 521 + * 522 + * capture [S] = SSI 523 + * [E] = mem 524 + * 525 + * -*-> Audio DMAC 526 + * -o-> Audio DMAC peri peri 527 + */ 528 + mod_start = (is_play) ? NULL : ssi; 529 + mod_end = (is_play) ? ssi : NULL; 530 + 531 + mod[0] = mod_start; 532 + for (i = 1; i < nr; i++) { 533 + if (src) { 534 + mod[i] = src; 535 + src = NULL; 536 + } else if (ctu) { 537 + mod[i] = ctu; 538 + ctu = NULL; 539 + } else if (mix) { 540 + mod[i] = mix; 541 + mix = NULL; 542 + } else if (dvc) { 543 + mod[i] = dvc; 544 + dvc = NULL; 545 + } 546 + } 547 + mod[i] = mod_end; 548 + 549 + /* 550 + * | SSI | SRC | 551 + * -------------+-----+-----+ 552 + * is_play | o | * | 553 + * !is_play | * | o | 554 + */ 555 + if ((this == ssi) == (is_play)) { 556 + *mod_from = mod[nr - 1]; 557 + *mod_to = mod[nr]; 555 558 } else { 556 - *mod_from = mod[index]; 557 - *mod_to = mod[index - 1]; 559 + *mod_from = mod[0]; 560 + *mod_to = mod[1]; 561 + } 562 + 563 + dev_dbg(dev, "module connection (this is %s[%d])\n", 564 + rsnd_mod_name(this), rsnd_mod_id(this)); 565 + for (i = 0; i <= nr; i++) { 566 + dev_dbg(dev, " %s[%d]%s\n", 567 + rsnd_mod_name(mod[i]), rsnd_mod_id(mod[i]), 568 + (mod[i] == *mod_from) ? " from" : 569 + (mod[i] == *mod_to) ? " to" : ""); 558 570 } 559 571 } 560 572 ··· 608 568 609 569 int rsnd_dma_init(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id) 610 570 { 611 - struct rsnd_mod *mod_from; 612 - struct rsnd_mod *mod_to; 571 + struct rsnd_mod *mod_from = NULL; 572 + struct rsnd_mod *mod_to = NULL; 613 573 struct rsnd_priv *priv = rsnd_io_to_priv(io); 614 574 struct rsnd_dma_ctrl *dmac = rsnd_priv_to_dmac(priv); 575 + struct device *dev = rsnd_priv_to_dev(priv); 615 576 int is_play = rsnd_io_is_play(io); 616 577 617 578 /* ··· 638 597 /* for Gen1, overwrite */ 639 598 if (rsnd_is_gen1(priv)) 640 599 dma->ops = &rsnd_dmaen_ops; 600 + 601 + dev_dbg(dev, "%s %s[%d] -> %s[%d]\n", 602 + dma->ops->name, 603 + rsnd_mod_name(mod_from), rsnd_mod_id(mod_from), 604 + rsnd_mod_name(mod_to), rsnd_mod_id(mod_to)); 641 605 642 606 return dma->ops->init(io, dma, id, mod_from, mod_to); 643 607 }
+31 -42
sound/soc/sh/rcar/dvc.c
··· 24 24 struct rsnd_kctrl_cfg_s rdown; /* Ramp Rate Down */ 25 25 }; 26 26 27 + #define rsnd_dvc_nr(priv) ((priv)->dvc_nr) 27 28 #define rsnd_dvc_of_node(priv) \ 28 29 of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,dvc") 29 30 ··· 63 62 "0.125 dB/4096 steps", /* 10110 */ 64 63 "0.125 dB/8192 steps", /* 10111 */ 65 64 }; 65 + 66 + static void rsnd_dvc_soft_reset(struct rsnd_mod *mod) 67 + { 68 + rsnd_mod_write(mod, DVC_SWRSR, 0); 69 + rsnd_mod_write(mod, DVC_SWRSR, 1); 70 + } 71 + 72 + #define rsnd_dvc_initialize_lock(mod) __rsnd_dvc_initialize_lock(mod, 1) 73 + #define rsnd_dvc_initialize_unlock(mod) __rsnd_dvc_initialize_lock(mod, 0) 74 + static void __rsnd_dvc_initialize_lock(struct rsnd_mod *mod, u32 enable) 75 + { 76 + rsnd_mod_write(mod, DVC_DVUIR, enable); 77 + } 66 78 67 79 static void rsnd_dvc_volume_update(struct rsnd_dai_stream *io, 68 80 struct rsnd_mod *mod) ··· 149 135 return 0; 150 136 } 151 137 152 - static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, 138 + static int rsnd_dvc_init(struct rsnd_mod *mod, 153 139 struct rsnd_dai_stream *io, 154 140 struct rsnd_priv *priv) 155 141 { 156 - struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); 157 - struct device *dev = rsnd_priv_to_dev(priv); 158 - int dvc_id = rsnd_mod_id(dvc_mod); 159 - int src_id = rsnd_mod_id(src_mod); 160 - u32 route[] = { 161 - [0] = 0x30000, 162 - [1] = 0x30001, 163 - [2] = 0x40000, 164 - [3] = 0x10000, 165 - [4] = 0x20000, 166 - [5] = 0x40100 167 - }; 142 + rsnd_mod_hw_start(mod); 168 143 169 - if (src_id >= ARRAY_SIZE(route)) { 170 - dev_err(dev, "DVC%d isn't connected to SRC%d\n", dvc_id, src_id); 171 - return -EINVAL; 172 - } 144 + rsnd_dvc_soft_reset(mod); 173 145 174 - rsnd_mod_hw_start(dvc_mod); 146 + rsnd_dvc_initialize_lock(mod); 175 147 176 - /* 177 - * fixme 178 - * it doesn't support CTU/MIX 179 - */ 180 - rsnd_mod_write(dvc_mod, CMD_ROUTE_SLCT, route[src_id]); 148 + rsnd_path_parse(priv, io); 181 149 182 - rsnd_mod_write(dvc_mod, DVC_SWRSR, 0); 183 - rsnd_mod_write(dvc_mod, DVC_SWRSR, 1); 184 - 185 - rsnd_mod_write(dvc_mod, DVC_DVUIR, 1); 186 - 187 - rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod, io)); 150 + rsnd_mod_write(mod, DVC_ADINR, rsnd_get_adinr_bit(mod, io)); 188 151 189 152 /* ch0/ch1 Volume */ 190 - rsnd_dvc_volume_update(io, dvc_mod); 153 + rsnd_dvc_volume_update(io, mod); 191 154 192 - rsnd_mod_write(dvc_mod, DVC_DVUIR, 0); 193 - 194 - rsnd_adg_set_cmd_timsel_gen2(dvc_mod, io); 155 + rsnd_adg_set_cmd_timsel_gen2(mod, io); 195 156 196 157 return 0; 197 158 } ··· 184 195 struct rsnd_dai_stream *io, 185 196 struct rsnd_priv *priv) 186 197 { 198 + rsnd_dvc_initialize_unlock(mod); 199 + 187 200 rsnd_mod_write(mod, CMD_CTRL, 0x10); 188 201 189 202 return 0; ··· 332 341 char name[RSND_DVC_NAME_SIZE]; 333 342 int i, nr, ret; 334 343 335 - rsnd_of_parse_dvc(pdev, of_data, priv); 336 - 337 - nr = info->dvc_info_nr; 338 - if (!nr) 339 - return 0; 340 - 341 344 /* This driver doesn't support Gen1 at this point */ 342 345 if (rsnd_is_gen1(priv)) { 343 346 dev_warn(dev, "CMD is not supported on Gen1\n"); 344 347 return -EINVAL; 345 348 } 346 349 350 + rsnd_of_parse_dvc(pdev, of_data, priv); 351 + 352 + nr = info->dvc_info_nr; 353 + if (!nr) 354 + return 0; 355 + 347 356 dvc = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL); 348 - if (!dvc) { 349 - dev_err(dev, "CMD allocate failed\n"); 357 + if (!dvc) 350 358 return -ENOMEM; 351 - } 352 359 353 360 priv->dvc_nr = nr; 354 361 priv->dvc = dvc;
+31 -2
sound/soc/sh/rcar/gen.c
··· 103 103 regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); 104 104 } 105 105 106 + void rsnd_force_write(struct rsnd_priv *priv, 107 + struct rsnd_mod *mod, 108 + enum rsnd_reg reg, u32 data) 109 + { 110 + struct device *dev = rsnd_priv_to_dev(priv); 111 + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); 112 + 113 + if (!rsnd_is_accessible_reg(priv, gen, reg)) 114 + return; 115 + 116 + dev_dbg(dev, "w %s[%d] - %4d : %08x\n", 117 + rsnd_mod_name(mod), rsnd_mod_id(mod), reg, data); 118 + 119 + regmap_fields_force_write(gen->regs[reg], rsnd_mod_id(mod), data); 120 + } 121 + 106 122 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, 107 123 enum rsnd_reg reg, u32 mask, u32 data) 108 124 { ··· 216 200 /* FIXME: it needs SSI_MODE2/3 in the future */ 217 201 RSND_GEN_M_REG(SSI_BUSIF_MODE, 0x0, 0x80), 218 202 RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4, 0x80), 219 - RSND_GEN_M_REG(BUSIF_DALIGN, 0x8, 0x80), 203 + RSND_GEN_M_REG(SSI_BUSIF_DALIGN,0x8, 0x80), 220 204 RSND_GEN_M_REG(SSI_CTRL, 0x10, 0x80), 221 - RSND_GEN_M_REG(INT_ENABLE, 0x18, 0x80), 205 + RSND_GEN_M_REG(SSI_INT_ENABLE, 0x18, 0x80), 222 206 }; 223 207 struct rsnd_regmap_field_conf conf_scu[] = { 224 208 RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x0, 0x20), 209 + RSND_GEN_M_REG(SRC_BUSIF_DALIGN,0x8, 0x20), 225 210 RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0xc, 0x20), 226 211 RSND_GEN_M_REG(SRC_CTRL, 0x10, 0x20), 227 212 RSND_GEN_M_REG(SRC_INT_ENABLE0, 0x18, 0x20), ··· 240 223 RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40), 241 224 RSND_GEN_M_REG(SRC_BSDSR, 0x22c, 0x40), 242 225 RSND_GEN_M_REG(SRC_BSISR, 0x238, 0x40), 226 + RSND_GEN_M_REG(CTU_CTUIR, 0x504, 0x100), 227 + RSND_GEN_M_REG(CTU_ADINR, 0x508, 0x100), 228 + RSND_GEN_M_REG(MIX_SWRSR, 0xd00, 0x40), 229 + RSND_GEN_M_REG(MIX_MIXIR, 0xd04, 0x40), 230 + RSND_GEN_M_REG(MIX_ADINR, 0xd08, 0x40), 231 + RSND_GEN_M_REG(MIX_MIXMR, 0xd10, 0x40), 232 + RSND_GEN_M_REG(MIX_MVPDR, 0xd14, 0x40), 233 + RSND_GEN_M_REG(MIX_MDBAR, 0xd18, 0x40), 234 + RSND_GEN_M_REG(MIX_MDBBR, 0xd1c, 0x40), 235 + RSND_GEN_M_REG(MIX_MDBCR, 0xd20, 0x40), 236 + RSND_GEN_M_REG(MIX_MDBDR, 0xd24, 0x40), 237 + RSND_GEN_M_REG(MIX_MDBER, 0xd28, 0x40), 243 238 RSND_GEN_M_REG(DVC_SWRSR, 0xe00, 0x100), 244 239 RSND_GEN_M_REG(DVC_DVUIR, 0xe04, 0x100), 245 240 RSND_GEN_M_REG(DVC_ADINR, 0xe08, 0x100),
+200
sound/soc/sh/rcar/mix.c
··· 1 + /* 2 + * mix.c 3 + * 4 + * Copyright (c) 2015 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + #include "rsnd.h" 11 + 12 + #define MIX_NAME_SIZE 16 13 + #define MIX_NAME "mix" 14 + 15 + struct rsnd_mix { 16 + struct rsnd_mix_platform_info *info; /* rcar_snd.h */ 17 + struct rsnd_mod mod; 18 + }; 19 + 20 + #define rsnd_mix_nr(priv) ((priv)->mix_nr) 21 + #define for_each_rsnd_mix(pos, priv, i) \ 22 + for ((i) = 0; \ 23 + ((i) < rsnd_mix_nr(priv)) && \ 24 + ((pos) = (struct rsnd_mix *)(priv)->mix + i); \ 25 + i++) 26 + 27 + 28 + static void rsnd_mix_soft_reset(struct rsnd_mod *mod) 29 + { 30 + rsnd_mod_write(mod, MIX_SWRSR, 0); 31 + rsnd_mod_write(mod, MIX_SWRSR, 1); 32 + } 33 + 34 + #define rsnd_mix_initialize_lock(mod) __rsnd_mix_initialize_lock(mod, 1) 35 + #define rsnd_mix_initialize_unlock(mod) __rsnd_mix_initialize_lock(mod, 0) 36 + static void __rsnd_mix_initialize_lock(struct rsnd_mod *mod, u32 enable) 37 + { 38 + rsnd_mod_write(mod, MIX_MIXIR, enable); 39 + } 40 + 41 + static void rsnd_mix_volume_update(struct rsnd_dai_stream *io, 42 + struct rsnd_mod *mod) 43 + { 44 + 45 + /* Disable MIX dB setting */ 46 + rsnd_mod_write(mod, MIX_MDBER, 0); 47 + 48 + rsnd_mod_write(mod, MIX_MDBAR, 0); 49 + rsnd_mod_write(mod, MIX_MDBBR, 0); 50 + rsnd_mod_write(mod, MIX_MDBCR, 0); 51 + rsnd_mod_write(mod, MIX_MDBDR, 0); 52 + 53 + /* Enable MIX dB setting */ 54 + rsnd_mod_write(mod, MIX_MDBER, 1); 55 + } 56 + 57 + static int rsnd_mix_init(struct rsnd_mod *mod, 58 + struct rsnd_dai_stream *io, 59 + struct rsnd_priv *priv) 60 + { 61 + rsnd_mod_hw_start(mod); 62 + 63 + rsnd_mix_soft_reset(mod); 64 + 65 + rsnd_mix_initialize_lock(mod); 66 + 67 + rsnd_mod_write(mod, MIX_ADINR, rsnd_get_adinr_chan(mod, io)); 68 + 69 + rsnd_path_parse(priv, io); 70 + 71 + /* volume step */ 72 + rsnd_mod_write(mod, MIX_MIXMR, 0); 73 + rsnd_mod_write(mod, MIX_MVPDR, 0); 74 + 75 + rsnd_mix_volume_update(io, mod); 76 + 77 + rsnd_mix_initialize_unlock(mod); 78 + 79 + return 0; 80 + } 81 + 82 + static int rsnd_mix_quit(struct rsnd_mod *mod, 83 + struct rsnd_dai_stream *io, 84 + struct rsnd_priv *priv) 85 + { 86 + rsnd_mod_hw_stop(mod); 87 + 88 + return 0; 89 + } 90 + 91 + static struct rsnd_mod_ops rsnd_mix_ops = { 92 + .name = MIX_NAME, 93 + .init = rsnd_mix_init, 94 + .quit = rsnd_mix_quit, 95 + }; 96 + 97 + struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id) 98 + { 99 + if (WARN_ON(id < 0 || id >= rsnd_mix_nr(priv))) 100 + id = 0; 101 + 102 + return &((struct rsnd_mix *)(priv->mix) + id)->mod; 103 + } 104 + 105 + static void rsnd_of_parse_mix(struct platform_device *pdev, 106 + const struct rsnd_of_data *of_data, 107 + struct rsnd_priv *priv) 108 + { 109 + struct device_node *node; 110 + struct rsnd_mix_platform_info *mix_info; 111 + struct rcar_snd_info *info = rsnd_priv_to_info(priv); 112 + struct device *dev = &pdev->dev; 113 + int nr; 114 + 115 + if (!of_data) 116 + return; 117 + 118 + node = of_get_child_by_name(dev->of_node, "rcar_sound,mix"); 119 + if (!node) 120 + return; 121 + 122 + nr = of_get_child_count(node); 123 + if (!nr) 124 + goto rsnd_of_parse_mix_end; 125 + 126 + mix_info = devm_kzalloc(dev, 127 + sizeof(struct rsnd_mix_platform_info) * nr, 128 + GFP_KERNEL); 129 + if (!mix_info) { 130 + dev_err(dev, "mix info allocation error\n"); 131 + goto rsnd_of_parse_mix_end; 132 + } 133 + 134 + info->mix_info = mix_info; 135 + info->mix_info_nr = nr; 136 + 137 + rsnd_of_parse_mix_end: 138 + of_node_put(node); 139 + 140 + } 141 + 142 + int rsnd_mix_probe(struct platform_device *pdev, 143 + const struct rsnd_of_data *of_data, 144 + struct rsnd_priv *priv) 145 + { 146 + struct rcar_snd_info *info = rsnd_priv_to_info(priv); 147 + struct device *dev = rsnd_priv_to_dev(priv); 148 + struct rsnd_mix *mix; 149 + struct clk *clk; 150 + char name[MIX_NAME_SIZE]; 151 + int i, nr, ret; 152 + 153 + /* This driver doesn't support Gen1 at this point */ 154 + if (rsnd_is_gen1(priv)) { 155 + dev_warn(dev, "MIX is not supported on Gen1\n"); 156 + return -EINVAL; 157 + } 158 + 159 + rsnd_of_parse_mix(pdev, of_data, priv); 160 + 161 + nr = info->mix_info_nr; 162 + if (!nr) 163 + return 0; 164 + 165 + mix = devm_kzalloc(dev, sizeof(*mix) * nr, GFP_KERNEL); 166 + if (!mix) 167 + return -ENOMEM; 168 + 169 + priv->mix_nr = nr; 170 + priv->mix = mix; 171 + 172 + for_each_rsnd_mix(mix, priv, i) { 173 + snprintf(name, MIX_NAME_SIZE, "%s.%d", 174 + MIX_NAME, i); 175 + 176 + clk = devm_clk_get(dev, name); 177 + if (IS_ERR(clk)) 178 + return PTR_ERR(clk); 179 + 180 + mix->info = &info->mix_info[i]; 181 + 182 + ret = rsnd_mod_init(priv, &mix->mod, &rsnd_mix_ops, 183 + clk, RSND_MOD_MIX, i); 184 + if (ret) 185 + return ret; 186 + } 187 + 188 + return 0; 189 + } 190 + 191 + void rsnd_mix_remove(struct platform_device *pdev, 192 + struct rsnd_priv *priv) 193 + { 194 + struct rsnd_mix *mix; 195 + int i; 196 + 197 + for_each_rsnd_mix(mix, priv, i) { 198 + rsnd_mod_quit(&mix->mod); 199 + } 200 + }
+81 -32
sound/soc/sh/rcar/rsnd.h
··· 47 47 RSND_REG_SCU_SYS_STATUS0, 48 48 RSND_REG_SCU_SYS_INT_EN0, 49 49 RSND_REG_CMD_ROUTE_SLCT, 50 + RSND_REG_CTU_CTUIR, 51 + RSND_REG_CTU_ADINR, 52 + RSND_REG_MIX_SWRSR, 53 + RSND_REG_MIX_MIXIR, 54 + RSND_REG_MIX_ADINR, 55 + RSND_REG_MIX_MIXMR, 56 + RSND_REG_MIX_MVPDR, 57 + RSND_REG_MIX_MDBAR, 58 + RSND_REG_MIX_MDBBR, 59 + RSND_REG_MIX_MDBCR, 60 + RSND_REG_MIX_MDBDR, 61 + RSND_REG_MIX_MDBER, 50 62 RSND_REG_DVC_SWRSR, 51 63 RSND_REG_DVC_DVUIR, 52 64 RSND_REG_DVC_ADINR, ··· 111 99 RSND_REG_SHARE26, 112 100 RSND_REG_SHARE27, 113 101 RSND_REG_SHARE28, 102 + RSND_REG_SHARE29, 114 103 115 104 RSND_REG_MAX, 116 105 }; ··· 132 119 #define RSND_REG_SSI_CTRL RSND_REG_SHARE02 133 120 #define RSND_REG_SSI_BUSIF_MODE RSND_REG_SHARE03 134 121 #define RSND_REG_SSI_BUSIF_ADINR RSND_REG_SHARE04 135 - #define RSND_REG_INT_ENABLE RSND_REG_SHARE05 122 + #define RSND_REG_SSI_INT_ENABLE RSND_REG_SHARE05 136 123 #define RSND_REG_SRC_BSDSR RSND_REG_SHARE06 137 124 #define RSND_REG_SRC_BSISR RSND_REG_SHARE07 138 125 #define RSND_REG_DIV_EN RSND_REG_SHARE08 ··· 149 136 #define RSND_REG_AUDIO_CLK_SEL2 RSND_REG_SHARE19 150 137 #define RSND_REG_CMD_CTRL RSND_REG_SHARE20 151 138 #define RSND_REG_CMDOUT_TIMSEL RSND_REG_SHARE21 152 - #define RSND_REG_BUSIF_DALIGN RSND_REG_SHARE22 139 + #define RSND_REG_SSI_BUSIF_DALIGN RSND_REG_SHARE22 153 140 #define RSND_REG_DVC_VRCTR RSND_REG_SHARE23 154 141 #define RSND_REG_DVC_VRPDR RSND_REG_SHARE24 155 142 #define RSND_REG_DVC_VRDBR RSND_REG_SHARE25 156 143 #define RSND_REG_SCU_SYS_STATUS1 RSND_REG_SHARE26 157 144 #define RSND_REG_SCU_SYS_INT_EN1 RSND_REG_SHARE27 158 145 #define RSND_REG_SRC_INT_ENABLE0 RSND_REG_SHARE28 146 + #define RSND_REG_SRC_BUSIF_DALIGN RSND_REG_SHARE29 159 147 160 148 struct rsnd_of_data; 161 149 struct rsnd_priv; ··· 171 157 rsnd_read(rsnd_mod_to_priv(m), m, RSND_REG_##r) 172 158 #define rsnd_mod_write(m, r, d) \ 173 159 rsnd_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d) 160 + #define rsnd_mod_force_write(m, r, d) \ 161 + rsnd_force_write(rsnd_mod_to_priv(m), m, RSND_REG_##r, d) 174 162 #define rsnd_mod_bset(m, r, s, d) \ 175 163 rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d) 176 164 177 165 u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); 178 166 void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod, 179 167 enum rsnd_reg reg, u32 data); 168 + void rsnd_force_write(struct rsnd_priv *priv, struct rsnd_mod *mod, 169 + enum rsnd_reg reg, u32 data); 180 170 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg, 181 171 u32 mask, u32 data); 182 - u32 rsnd_get_adinr(struct rsnd_mod *mod, struct rsnd_dai_stream *io); 172 + u32 rsnd_get_adinr_bit(struct rsnd_mod *mod, struct rsnd_dai_stream *io); 173 + u32 rsnd_get_adinr_chan(struct rsnd_mod *mod, struct rsnd_dai_stream *io); 174 + u32 rsnd_get_dalign(struct rsnd_mod *mod, struct rsnd_dai_stream *io); 175 + void rsnd_path_parse(struct rsnd_priv *priv, 176 + struct rsnd_dai_stream *io); 183 177 184 178 /* 185 179 * R-Car DMA 186 180 */ 187 181 struct rsnd_dma; 188 - struct rsnd_dma_ops { 189 - void (*start)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 190 - void (*stop)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 191 - int (*init)(struct rsnd_dai_stream *io, struct rsnd_dma *dma, int id, 192 - struct rsnd_mod *mod_from, struct rsnd_mod *mod_to); 193 - void (*quit)(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 194 - }; 195 182 196 183 struct rsnd_dmaen { 197 184 struct dma_chan *chan; ··· 232 217 */ 233 218 enum rsnd_mod_type { 234 219 RSND_MOD_DVC = 0, 220 + RSND_MOD_MIX, 221 + RSND_MOD_CTU, 235 222 RSND_MOD_SRC, 236 223 RSND_MOD_SSI, 237 224 RSND_MOD_MAX, ··· 329 312 330 313 #define rsnd_mod_to_priv(mod) ((mod)->priv) 331 314 #define rsnd_mod_to_dma(mod) (&(mod)->dma) 332 - #define rsnd_mod_id(mod) ((mod)->id) 315 + #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1) 333 316 #define rsnd_mod_hw_start(mod) clk_enable((mod)->clk) 334 317 #define rsnd_mod_hw_stop(mod) clk_disable((mod)->clk) 335 318 ··· 362 345 int byte_per_period; 363 346 int next_period_byte; 364 347 }; 365 - #define rsnd_io_to_mod_ssi(io) ((io)->mod[RSND_MOD_SSI]) 366 - #define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC]) 367 - #define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC]) 348 + #define rsnd_io_to_mod(io, i) ((i) < RSND_MOD_MAX ? (io)->mod[(i)] : NULL) 349 + #define rsnd_io_to_mod_ssi(io) rsnd_io_to_mod((io), RSND_MOD_SSI) 350 + #define rsnd_io_to_mod_src(io) rsnd_io_to_mod((io), RSND_MOD_SRC) 351 + #define rsnd_io_to_mod_ctu(io) rsnd_io_to_mod((io), RSND_MOD_CTU) 352 + #define rsnd_io_to_mod_mix(io) rsnd_io_to_mod((io), RSND_MOD_MIX) 353 + #define rsnd_io_to_mod_dvc(io) rsnd_io_to_mod((io), RSND_MOD_DVC) 368 354 #define rsnd_io_to_rdai(io) ((io)->rdai) 369 355 #define rsnd_io_to_priv(io) (rsnd_rdai_to_priv(rsnd_io_to_rdai(io))) 370 356 #define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io) ··· 457 437 void *gen; 458 438 459 439 /* 460 - * below value will be filled on rsnd_src_probe() 461 - */ 462 - void *src; 463 - int src_nr; 464 - 465 - /* 466 440 * below value will be filled on rsnd_adg_probe() 467 441 */ 468 442 void *adg; ··· 471 457 */ 472 458 void *ssi; 473 459 int ssi_nr; 460 + 461 + /* 462 + * below value will be filled on rsnd_src_probe() 463 + */ 464 + void *src; 465 + int src_nr; 466 + 467 + /* 468 + * below value will be filled on rsnd_ctu_probe() 469 + */ 470 + void *ctu; 471 + int ctu_nr; 472 + 473 + /* 474 + * below value will be filled on rsnd_mix_probe() 475 + */ 476 + void *mix; 477 + int mix_nr; 474 478 475 479 /* 476 480 * below value will be filled on rsnd_dvc_probe() ··· 563 531 u32 max); 564 532 565 533 /* 534 + * R-Car SSI 535 + */ 536 + int rsnd_ssi_probe(struct platform_device *pdev, 537 + const struct rsnd_of_data *of_data, 538 + struct rsnd_priv *priv); 539 + void rsnd_ssi_remove(struct platform_device *pdev, 540 + struct rsnd_priv *priv); 541 + struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id); 542 + int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); 543 + int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); 544 + int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod); 545 + 546 + /* 566 547 * R-Car SRC 567 548 */ 568 549 int rsnd_src_probe(struct platform_device *pdev, ··· 595 550 int rsnd_src_ssi_irq_enable(struct rsnd_mod *ssi_mod); 596 551 int rsnd_src_ssi_irq_disable(struct rsnd_mod *ssi_mod); 597 552 598 - #define rsnd_src_nr(priv) ((priv)->src_nr) 599 - 600 553 /* 601 - * R-Car SSI 554 + * R-Car CTU 602 555 */ 603 - int rsnd_ssi_probe(struct platform_device *pdev, 556 + int rsnd_ctu_probe(struct platform_device *pdev, 604 557 const struct rsnd_of_data *of_data, 605 558 struct rsnd_priv *priv); 606 - void rsnd_ssi_remove(struct platform_device *pdev, 559 + 560 + void rsnd_ctu_remove(struct platform_device *pdev, 607 561 struct rsnd_priv *priv); 608 - struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id); 609 - int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod); 610 - int rsnd_ssi_is_dma_mode(struct rsnd_mod *mod); 611 - int rsnd_ssi_use_busif(struct rsnd_dai_stream *io, struct rsnd_mod *mod); 562 + struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id); 563 + 564 + /* 565 + * R-Car MIX 566 + */ 567 + int rsnd_mix_probe(struct platform_device *pdev, 568 + const struct rsnd_of_data *of_data, 569 + struct rsnd_priv *priv); 570 + 571 + void rsnd_mix_remove(struct platform_device *pdev, 572 + struct rsnd_priv *priv); 573 + struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id); 612 574 613 575 /* 614 576 * R-Car DVC ··· 626 574 void rsnd_dvc_remove(struct platform_device *pdev, 627 575 struct rsnd_priv *priv); 628 576 struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id); 629 - 630 - #define rsnd_dvc_nr(priv) ((priv)->dvc_nr) 631 - 632 577 633 578 #endif
+18 -4
sound/soc/sh/rcar/rsrc-card.c
··· 41 41 static const struct of_device_id rsrc_card_of_match[] = { 42 42 { .compatible = "renesas,rsrc-card,lager", .data = &routes_of_ssi0_ak4642 }, 43 43 { .compatible = "renesas,rsrc-card,koelsch", .data = &routes_of_ssi0_ak4642 }, 44 + { .compatible = "renesas,rsrc-card", }, 44 45 {}, 45 46 }; 46 47 MODULE_DEVICE_TABLE(of, rsrc_card_of_match); ··· 243 242 snd_soc_of_get_dai_name(np, &dai_link->codec_dai_name); 244 243 245 244 /* additional name prefix */ 246 - priv->codec_conf.of_node = dai_link->codec_of_node; 247 - priv->codec_conf.name_prefix = of_data->prefix; 245 + if (of_data) { 246 + priv->codec_conf.of_node = dai_link->codec_of_node; 247 + priv->codec_conf.name_prefix = of_data->prefix; 248 + } else { 249 + snd_soc_of_parse_audio_prefix(&priv->snd_card, 250 + &priv->codec_conf, 251 + dai_link->codec_of_node, 252 + "audio-prefix"); 253 + } 248 254 249 255 /* set dai_name */ 250 256 snprintf(dai_props->dai_name, DAI_NAME_NUM, "be.%s", ··· 369 361 priv->snd_card.num_links = num; 370 362 priv->snd_card.codec_conf = &priv->codec_conf; 371 363 priv->snd_card.num_configs = 1; 372 - priv->snd_card.of_dapm_routes = of_data->routes; 373 - priv->snd_card.num_of_dapm_routes = of_data->num_routes; 364 + 365 + if (of_data) { 366 + priv->snd_card.of_dapm_routes = of_data->routes; 367 + priv->snd_card.num_of_dapm_routes = of_data->num_routes; 368 + } else { 369 + snd_soc_of_parse_audio_routing(&priv->snd_card, 370 + "audio-routing"); 371 + } 374 372 375 373 /* Parse the card name from DT */ 376 374 snd_soc_of_parse_card_name(&priv->snd_card, "card-name");
+65 -52
sound/soc/sh/rcar/src.c
··· 30 30 31 31 #define RSND_SRC_NAME_SIZE 16 32 32 33 + #define rsnd_src_nr(priv) ((priv)->src_nr) 33 34 #define rsnd_enable_sync_convert(src) ((src)->sen.val) 34 35 #define rsnd_src_of_node(priv) \ 35 36 of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,src") ··· 118 117 /* 119 118 * Gen1/Gen2 common functions 120 119 */ 120 + static void rsnd_src_soft_reset(struct rsnd_mod *mod) 121 + { 122 + rsnd_mod_write(mod, SRC_SWRSR, 0); 123 + rsnd_mod_write(mod, SRC_SWRSR, 1); 124 + } 125 + 126 + 127 + #define rsnd_src_initialize_lock(mod) __rsnd_src_initialize_lock(mod, 1) 128 + #define rsnd_src_initialize_unlock(mod) __rsnd_src_initialize_lock(mod, 0) 129 + static void __rsnd_src_initialize_lock(struct rsnd_mod *mod, u32 enable) 130 + { 131 + rsnd_mod_write(mod, SRC_SRCIR, enable); 132 + } 133 + 121 134 static struct dma_chan *rsnd_src_dma_req(struct rsnd_dai_stream *io, 122 135 struct rsnd_mod *mod) 123 136 { ··· 148 133 int use_busif) 149 134 { 150 135 struct rsnd_dai *rdai = rsnd_io_to_rdai(io); 151 - struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 152 136 int ssi_id = rsnd_mod_id(ssi_mod); 153 137 154 138 /* ··· 184 170 * DMA settings for SSIU 185 171 */ 186 172 if (use_busif) { 187 - u32 val = 0x76543210; 188 - u32 mask = ~0; 173 + u32 val = rsnd_get_dalign(ssi_mod, io); 189 174 190 175 rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR, 191 - rsnd_get_adinr(ssi_mod, io)); 176 + rsnd_get_adinr_bit(ssi_mod, io)); 192 177 rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE, 1); 193 178 rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1); 194 179 195 - mask <<= runtime->channels * 4; 196 - val = val & mask; 197 - 198 - switch (runtime->sample_bits) { 199 - case 16: 200 - val |= 0x67452301 & ~mask; 201 - break; 202 - case 32: 203 - val |= 0x76543210 & ~mask; 204 - break; 205 - } 206 - rsnd_mod_write(ssi_mod, BUSIF_DALIGN, val); 207 - 180 + rsnd_mod_write(ssi_mod, SSI_BUSIF_DALIGN, val); 208 181 } 209 182 210 183 return 0; ··· 216 215 return 0; 217 216 218 217 /* enable SSI interrupt if Gen2 */ 219 - if (rsnd_ssi_is_dma_mode(ssi_mod)) 220 - rsnd_mod_write(ssi_mod, INT_ENABLE, 0x0e000000); 221 - else 222 - rsnd_mod_write(ssi_mod, INT_ENABLE, 0x0f000000); 218 + rsnd_mod_write(ssi_mod, SSI_INT_ENABLE, 219 + rsnd_ssi_is_dma_mode(ssi_mod) ? 220 + 0x0e000000 : 0x0f000000); 223 221 224 222 return 0; 225 223 } ··· 231 231 return 0; 232 232 233 233 /* disable SSI interrupt if Gen2 */ 234 - rsnd_mod_write(ssi_mod, INT_ENABLE, 0x00000000); 234 + rsnd_mod_write(ssi_mod, SSI_INT_ENABLE, 0x00000000); 235 235 236 236 return 0; 237 237 } ··· 294 294 if (convert_rate) 295 295 fsrate = 0x0400000 / convert_rate * runtime->rate; 296 296 297 - /* set/clear soft reset */ 298 - rsnd_mod_write(mod, SRC_SWRSR, 0); 299 - rsnd_mod_write(mod, SRC_SWRSR, 1); 300 - 301 297 /* Set channel number and output bit length */ 302 - rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod, io)); 298 + rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr_bit(mod, io)); 303 299 304 300 /* Enable the initial value of IFS */ 305 301 if (fsrate) { ··· 354 358 355 359 rsnd_mod_hw_start(mod); 356 360 361 + rsnd_src_soft_reset(mod); 362 + 363 + rsnd_src_initialize_lock(mod); 364 + 357 365 src->err = 0; 358 366 359 367 /* reset sync convert_rate */ 360 368 src->sync.val = 0; 361 - 362 - /* 363 - * Initialize the operation of the SRC internal circuits 364 - * see rsnd_src_start() 365 - */ 366 - rsnd_mod_write(mod, SRC_SRCIR, 1); 367 369 368 370 return 0; 369 371 } ··· 389 395 390 396 static int rsnd_src_start(struct rsnd_mod *mod) 391 397 { 392 - /* 393 - * Cancel the initialization and operate the SRC function 394 - * see rsnd_src_init() 395 - */ 396 - rsnd_mod_write(mod, SRC_SRCIR, 0); 398 + rsnd_src_initialize_unlock(mod); 397 399 398 400 return 0; 399 401 } ··· 607 617 int_val = 0; 608 618 } 609 619 620 + /* 621 + * WORKAROUND 622 + * 623 + * ignore over flow error when rsnd_enable_sync_convert() 624 + */ 625 + if (rsnd_enable_sync_convert(src)) 626 + sys_int_val = sys_int_val & 0xffff; 627 + 610 628 rsnd_mod_write(mod, SRC_INT_ENABLE0, int_val); 611 629 rsnd_mod_bset(mod, SCU_SYS_INT_EN0, sys_int_mask, sys_int_val); 612 630 rsnd_mod_bset(mod, SCU_SYS_INT_EN1, sys_int_mask, sys_int_val); ··· 630 632 631 633 static bool rsnd_src_error_record_gen2(struct rsnd_mod *mod) 632 634 { 633 - u32 val = OUF_SRC(rsnd_mod_id(mod)); 635 + struct rsnd_src *src = rsnd_mod_to_src(mod); 636 + u32 val0, val1; 634 637 bool ret = false; 635 638 636 - if ((rsnd_mod_read(mod, SCU_SYS_STATUS0) & val) || 637 - (rsnd_mod_read(mod, SCU_SYS_STATUS1) & val)) { 639 + val0 = val1 = OUF_SRC(rsnd_mod_id(mod)); 640 + 641 + /* 642 + * WORKAROUND 643 + * 644 + * ignore over flow error when rsnd_enable_sync_convert() 645 + */ 646 + if (rsnd_enable_sync_convert(src)) 647 + val0 = val0 & 0xffff; 648 + 649 + if ((rsnd_mod_read(mod, SCU_SYS_STATUS0) & val0) || 650 + (rsnd_mod_read(mod, SCU_SYS_STATUS1) & val1)) { 638 651 struct rsnd_src *src = rsnd_mod_to_src(mod); 639 652 640 653 src->err++; ··· 661 652 static int _rsnd_src_start_gen2(struct rsnd_mod *mod, 662 653 struct rsnd_dai_stream *io) 663 654 { 664 - u32 val = rsnd_io_to_mod_dvc(io) ? 0x01 : 0x11; 655 + struct rsnd_src *src = rsnd_mod_to_src(mod); 656 + u32 val; 657 + 658 + val = rsnd_get_dalign(mod, io); 659 + 660 + rsnd_mod_write(mod, SRC_BUSIF_DALIGN, val); 661 + 662 + /* 663 + * WORKAROUND 664 + * 665 + * Enable SRC output if you want to use sync convert together with DVC 666 + */ 667 + val = (rsnd_io_to_mod_dvc(io) && !rsnd_enable_sync_convert(src)) ? 668 + 0x01 : 0x11; 665 669 666 670 rsnd_mod_write(mod, SRC_CTRL, val); 667 671 ··· 944 922 return 0; 945 923 946 924 /* 947 - * We can't use SRC sync convert 948 - * if it has DVC 949 - */ 950 - if (rsnd_io_to_mod_dvc(io)) 951 - return 0; 952 - 953 - /* 954 925 * enable sync convert 955 926 */ 956 927 ret = rsnd_kctrl_new_s(mod, io, rtd, ··· 1062 1047 return 0; 1063 1048 1064 1049 src = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL); 1065 - if (!src) { 1066 - dev_err(dev, "SRC allocate failed\n"); 1050 + if (!src) 1067 1051 return -ENOMEM; 1068 - } 1069 1052 1070 1053 priv->src_nr = nr; 1071 1054 priv->src = src;
+1 -3
sound/soc/sh/rcar/ssi.c
··· 770 770 */ 771 771 nr = info->ssi_info_nr; 772 772 ssi = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL); 773 - if (!ssi) { 774 - dev_err(dev, "SSI allocate failed\n"); 773 + if (!ssi) 775 774 return -ENOMEM; 776 - } 777 775 778 776 priv->ssi = ssi; 779 777 priv->ssi_nr = nr;