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/pxa', 'asoc/topic/qcom', 'asoc/topic/rcar' and 'asoc/topic/rockchip' into asoc-next

+347 -229
+7
Documentation/devicetree/bindings/sound/renesas,rsnd.txt
··· 4 4 - compatible : "renesas,rcar_sound-<soctype>", fallbacks 5 5 "renesas,rcar_sound-gen1" if generation1, and 6 6 "renesas,rcar_sound-gen2" if generation2 7 + "renesas,rcar_sound-gen3" if generation3 7 8 Examples with soctypes are: 8 9 - "renesas,rcar_sound-r8a7778" (R-Car M1A) 9 10 - "renesas,rcar_sound-r8a7790" (R-Car H2) 10 11 - "renesas,rcar_sound-r8a7791" (R-Car M2-W) 12 + - "renesas,rcar_sound-r8a7795" (R-Car H3) 11 13 - reg : Should contain the register physical address. 12 14 required register is 13 15 SRU/ADG/SSI if generation1 ··· 32 30 - rcar_sound,dai : DAI contents. 33 31 The number of DAI subnode should be same as HW. 34 32 see below for detail. 33 + - #sound-dai-cells : it must be 0 if your system is using single DAI 34 + it must be 1 if your system is using multi DAI 35 + - #clock-cells : it must be 0 if your system has audio_clkout 36 + it must be 1 if your system has audio_clkout0/1/2/3 37 + - clock-frequency : for all audio_clkout0/1/2/3 35 38 36 39 SSI subnode properties: 37 40 - interrupts : Should contain SSI interrupt for PIO transfer
-1
include/sound/rcar_snd.h
··· 12 12 #ifndef RCAR_SND_H 13 13 #define RCAR_SND_H 14 14 15 - #include <linux/sh_clk.h> 16 15 17 16 #define RSND_GEN1_SRU 0 18 17 #define RSND_GEN1_ADG 1
+1 -8
sound/soc/pxa/brownstone.c
··· 116 116 int ret; 117 117 118 118 brownstone.dev = &pdev->dev; 119 - ret = snd_soc_register_card(&brownstone); 119 + ret = devm_snd_soc_register_card(&pdev->dev, &brownstone); 120 120 if (ret) 121 121 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 122 122 ret); 123 123 return ret; 124 - } 125 - 126 - static int brownstone_remove(struct platform_device *pdev) 127 - { 128 - snd_soc_unregister_card(&brownstone); 129 - return 0; 130 124 } 131 125 132 126 static struct platform_driver mmp_driver = { ··· 129 135 .pm = &snd_soc_pm_ops, 130 136 }, 131 137 .probe = brownstone_probe, 132 - .remove = brownstone_remove, 133 138 }; 134 139 135 140 module_platform_driver(mmp_driver);
+1 -10
sound/soc/pxa/corgi.c
··· 295 295 296 296 card->dev = &pdev->dev; 297 297 298 - ret = snd_soc_register_card(card); 298 + ret = devm_snd_soc_register_card(&pdev->dev, card); 299 299 if (ret) 300 300 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 301 301 ret); 302 302 return ret; 303 - } 304 - 305 - static int corgi_remove(struct platform_device *pdev) 306 - { 307 - struct snd_soc_card *card = platform_get_drvdata(pdev); 308 - 309 - snd_soc_unregister_card(card); 310 - return 0; 311 303 } 312 304 313 305 static struct platform_driver corgi_driver = { ··· 308 316 .pm = &snd_soc_pm_ops, 309 317 }, 310 318 .probe = corgi_probe, 311 - .remove = corgi_remove, 312 319 }; 313 320 314 321 module_platform_driver(corgi_driver);
+1 -4
sound/soc/pxa/e740_wm9705.c
··· 138 138 139 139 card->dev = &pdev->dev; 140 140 141 - ret = snd_soc_register_card(card); 141 + ret = devm_snd_soc_register_card(&pdev->dev, card); 142 142 if (ret) { 143 143 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 144 144 ret); ··· 149 149 150 150 static int e740_remove(struct platform_device *pdev) 151 151 { 152 - struct snd_soc_card *card = platform_get_drvdata(pdev); 153 - 154 152 gpio_free_array(e740_audio_gpios, ARRAY_SIZE(e740_audio_gpios)); 155 - snd_soc_unregister_card(card); 156 153 return 0; 157 154 } 158 155
+1 -4
sound/soc/pxa/e750_wm9705.c
··· 120 120 121 121 card->dev = &pdev->dev; 122 122 123 - ret = snd_soc_register_card(card); 123 + ret = devm_snd_soc_register_card(&pdev->dev, card); 124 124 if (ret) { 125 125 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 126 126 ret); ··· 131 131 132 132 static int e750_remove(struct platform_device *pdev) 133 133 { 134 - struct snd_soc_card *card = platform_get_drvdata(pdev); 135 - 136 134 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios)); 137 - snd_soc_unregister_card(card); 138 135 return 0; 139 136 } 140 137
+1 -4
sound/soc/pxa/e800_wm9712.c
··· 119 119 120 120 card->dev = &pdev->dev; 121 121 122 - ret = snd_soc_register_card(card); 122 + ret = devm_snd_soc_register_card(&pdev->dev, card); 123 123 if (ret) { 124 124 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 125 125 ret); ··· 130 130 131 131 static int e800_remove(struct platform_device *pdev) 132 132 { 133 - struct snd_soc_card *card = platform_get_drvdata(pdev); 134 - 135 133 gpio_free_array(e800_audio_gpios, ARRAY_SIZE(e800_audio_gpios)); 136 - snd_soc_unregister_card(card); 137 134 return 0; 138 135 } 139 136
+1 -3
sound/soc/pxa/hx4700.c
··· 193 193 return ret; 194 194 195 195 snd_soc_card_hx4700.dev = &pdev->dev; 196 - ret = snd_soc_register_card(&snd_soc_card_hx4700); 196 + ret = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_hx4700); 197 197 if (ret) 198 198 gpio_free_array(hx4700_audio_gpios, 199 199 ARRAY_SIZE(hx4700_audio_gpios)); ··· 203 203 204 204 static int hx4700_audio_remove(struct platform_device *pdev) 205 205 { 206 - snd_soc_unregister_card(&snd_soc_card_hx4700); 207 - 208 206 gpio_set_value(GPIO92_HX4700_HP_DRIVER, 0); 209 207 gpio_set_value(GPIO107_HX4700_SPK_nSD, 0); 210 208
+1 -10
sound/soc/pxa/imote2.c
··· 72 72 73 73 card->dev = &pdev->dev; 74 74 75 - ret = snd_soc_register_card(card); 75 + ret = devm_snd_soc_register_card(&pdev->dev, card); 76 76 if (ret) 77 77 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 78 78 ret); 79 79 return ret; 80 - } 81 - 82 - static int imote2_remove(struct platform_device *pdev) 83 - { 84 - struct snd_soc_card *card = platform_get_drvdata(pdev); 85 - 86 - snd_soc_unregister_card(card); 87 - return 0; 88 80 } 89 81 90 82 static struct platform_driver imote2_driver = { ··· 85 93 .pm = &snd_soc_pm_ops, 86 94 }, 87 95 .probe = imote2_probe, 88 - .remove = imote2_remove, 89 96 }; 90 97 91 98 module_platform_driver(imote2_driver);
+1 -10
sound/soc/pxa/mioa701_wm9713.c
··· 181 181 return -ENODEV; 182 182 183 183 mioa701.dev = &pdev->dev; 184 - rc = snd_soc_register_card(&mioa701); 184 + rc = devm_snd_soc_register_card(&pdev->dev, &mioa701); 185 185 if (!rc) 186 186 dev_warn(&pdev->dev, "Be warned that incorrect mixers/muxes setup will" 187 187 "lead to overheating and possible destruction of your device." ··· 189 189 return rc; 190 190 } 191 191 192 - static int mioa701_wm9713_remove(struct platform_device *pdev) 193 - { 194 - struct snd_soc_card *card = platform_get_drvdata(pdev); 195 - 196 - snd_soc_unregister_card(card); 197 - return 0; 198 - } 199 - 200 192 static struct platform_driver mioa701_wm9713_driver = { 201 193 .probe = mioa701_wm9713_probe, 202 - .remove = mioa701_wm9713_remove, 203 194 .driver = { 204 195 .name = "mioa701-wm9713", 205 196 .pm = &snd_soc_pm_ops,
+1 -8
sound/soc/pxa/palm27x.c
··· 140 140 141 141 palm27x_asoc.dev = &pdev->dev; 142 142 143 - ret = snd_soc_register_card(&palm27x_asoc); 143 + ret = devm_snd_soc_register_card(&pdev->dev, &palm27x_asoc); 144 144 if (ret) 145 145 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 146 146 ret); 147 147 return ret; 148 148 } 149 149 150 - static int palm27x_asoc_remove(struct platform_device *pdev) 151 - { 152 - snd_soc_unregister_card(&palm27x_asoc); 153 - return 0; 154 - } 155 - 156 150 static struct platform_driver palm27x_wm9712_driver = { 157 151 .probe = palm27x_asoc_probe, 158 - .remove = palm27x_asoc_remove, 159 152 .driver = { 160 153 .name = "palm27x-asoc", 161 154 .pm = &snd_soc_pm_ops,
+1 -10
sound/soc/pxa/poodle.c
··· 267 267 268 268 card->dev = &pdev->dev; 269 269 270 - ret = snd_soc_register_card(card); 270 + ret = devm_snd_soc_register_card(&pdev->dev, card); 271 271 if (ret) 272 272 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 273 273 ret); 274 274 return ret; 275 - } 276 - 277 - static int poodle_remove(struct platform_device *pdev) 278 - { 279 - struct snd_soc_card *card = platform_get_drvdata(pdev); 280 - 281 - snd_soc_unregister_card(card); 282 - return 0; 283 275 } 284 276 285 277 static struct platform_driver poodle_driver = { ··· 280 288 .pm = &snd_soc_pm_ops, 281 289 }, 282 290 .probe = poodle_probe, 283 - .remove = poodle_remove, 284 291 }; 285 292 286 293 module_platform_driver(poodle_driver);
+1
sound/soc/pxa/pxa-ssp.c
··· 809 809 { .compatible = "mrvl,pxa-ssp-dai" }, 810 810 {} 811 811 }; 812 + MODULE_DEVICE_TABLE(of, pxa_ssp_of_ids); 812 813 #endif 813 814 814 815 static int asoc_ssp_probe(struct platform_device *pdev)
+1
sound/soc/pxa/pxa2xx-pcm.c
··· 132 132 { .compatible = "mrvl,pxa-pcm-audio" }, 133 133 { } 134 134 }; 135 + MODULE_DEVICE_TABLE(of, snd_soc_pxa_audio_match); 135 136 #endif 136 137 137 138 static struct platform_driver pxa_pcm_driver = {
+1 -4
sound/soc/pxa/spitz.c
··· 305 305 306 306 card->dev = &pdev->dev; 307 307 308 - ret = snd_soc_register_card(card); 308 + ret = devm_snd_soc_register_card(&pdev->dev, card); 309 309 if (ret) { 310 310 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 311 311 ret); ··· 322 322 323 323 static int spitz_remove(struct platform_device *pdev) 324 324 { 325 - struct snd_soc_card *card = platform_get_drvdata(pdev); 326 - 327 - snd_soc_unregister_card(card); 328 325 gpio_free(spitz_mic_gpio); 329 326 return 0; 330 327 }
+1 -4
sound/soc/pxa/tosa.c
··· 233 233 234 234 card->dev = &pdev->dev; 235 235 236 - ret = snd_soc_register_card(card); 236 + ret = devm_snd_soc_register_card(&pdev->dev, card); 237 237 if (ret) { 238 238 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 239 239 ret); ··· 244 244 245 245 static int tosa_remove(struct platform_device *pdev) 246 246 { 247 - struct snd_soc_card *card = platform_get_drvdata(pdev); 248 - 249 247 gpio_free(TOSA_GPIO_L_MUTE); 250 - snd_soc_unregister_card(card); 251 248 return 0; 252 249 } 253 250
+1 -11
sound/soc/pxa/ttc-dkb.c
··· 128 128 129 129 card->dev = &pdev->dev; 130 130 131 - ret = snd_soc_register_card(card); 131 + ret = devm_snd_soc_register_card(&pdev->dev, card); 132 132 if (ret) 133 133 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 134 134 ret); 135 135 136 136 return ret; 137 - } 138 - 139 - static int ttc_dkb_remove(struct platform_device *pdev) 140 - { 141 - struct snd_soc_card *card = platform_get_drvdata(pdev); 142 - 143 - snd_soc_unregister_card(card); 144 - 145 - return 0; 146 137 } 147 138 148 139 static struct platform_driver ttc_dkb_driver = { ··· 142 151 .pm = &snd_soc_pm_ops, 143 152 }, 144 153 .probe = ttc_dkb_probe, 145 - .remove = ttc_dkb_remove, 146 154 }; 147 155 148 156 module_platform_driver(ttc_dkb_driver);
+2 -1
sound/soc/qcom/lpass-cpu.c
··· 438 438 if (IS_ERR(drvdata->mi2s_bit_clk[dai_id])) { 439 439 dev_err(&pdev->dev, 440 440 "%s() error getting mi2s-bit-clk: %ld\n", 441 - __func__, PTR_ERR(drvdata->mi2s_bit_clk[i])); 441 + __func__, 442 + PTR_ERR(drvdata->mi2s_bit_clk[dai_id])); 442 443 return PTR_ERR(drvdata->mi2s_bit_clk[dai_id]); 443 444 } 444 445 }
+2 -2
sound/soc/rockchip/Kconfig
··· 17 17 18 18 config SND_SOC_ROCKCHIP_MAX98090 19 19 tristate "ASoC support for Rockchip boards using a MAX98090 codec" 20 - depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB 20 + depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP 21 21 select SND_SOC_ROCKCHIP_I2S 22 22 select SND_SOC_MAX98090 23 23 select SND_SOC_TS3A227E ··· 27 27 28 28 config SND_SOC_ROCKCHIP_RT5645 29 29 tristate "ASoC support for Rockchip boards using a RT5645/RT5650 codec" 30 - depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB 30 + depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP 31 31 select SND_SOC_ROCKCHIP_I2S 32 32 select SND_SOC_RT5645 33 33 help
+1
sound/soc/sh/Kconfig
··· 37 37 config SND_SOC_RCAR 38 38 tristate "R-Car series SRU/SCU/SSIU/SSI support" 39 39 depends on DMA_OF 40 + depends on COMMON_CLK 40 41 select SND_SIMPLE_CARD 41 42 select REGMAP_MMIO 42 43 help
+234 -69
sound/soc/sh/rcar/adg.c
··· 7 7 * License. See the file "COPYING" in the main directory of this archive 8 8 * for more details. 9 9 */ 10 - #include <linux/sh_clk.h> 10 + #include <linux/clk-provider.h> 11 11 #include "rsnd.h" 12 12 13 13 #define CLKA 0 ··· 16 16 #define CLKI 3 17 17 #define CLKMAX 4 18 18 19 + #define CLKOUT 0 20 + #define CLKOUT1 1 21 + #define CLKOUT2 2 22 + #define CLKOUT3 3 23 + #define CLKOUTMAX 4 24 + 25 + #define BRRx_MASK(x) (0x3FF & x) 26 + 27 + static struct rsnd_mod_ops adg_ops = { 28 + .name = "adg", 29 + }; 30 + 19 31 struct rsnd_adg { 20 32 struct clk *clk[CLKMAX]; 33 + struct clk *clkout[CLKOUTMAX]; 34 + struct clk_onecell_data onecell; 35 + struct rsnd_mod mod; 21 36 22 - int rbga_rate_for_441khz_div_6; /* RBGA */ 23 - int rbgb_rate_for_48khz_div_6; /* RBGB */ 24 - u32 ckr; 37 + int rbga_rate_for_441khz; /* RBGA */ 38 + int rbgb_rate_for_48khz; /* RBGB */ 25 39 }; 26 40 27 41 #define for_each_rsnd_clk(pos, adg, i) \ ··· 43 29 (i < CLKMAX) && \ 44 30 ((pos) = adg->clk[i]); \ 45 31 i++) 32 + #define for_each_rsnd_clkout(pos, adg, i) \ 33 + for (i = 0; \ 34 + (i < CLKOUTMAX) && \ 35 + ((pos) = adg->clkout[i]); \ 36 + i++) 46 37 #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg) 47 38 39 + static u32 rsnd_adg_calculate_rbgx(unsigned long div) 40 + { 41 + int i, ratio; 42 + 43 + if (!div) 44 + return 0; 45 + 46 + for (i = 3; i >= 0; i--) { 47 + ratio = 2 << (i * 2); 48 + if (0 == (div % ratio)) 49 + return (u32)((i << 8) | ((div / ratio) - 1)); 50 + } 51 + 52 + return ~0; 53 + } 48 54 49 55 static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io) 50 56 { ··· 94 60 int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod, 95 61 struct rsnd_dai_stream *io) 96 62 { 63 + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 64 + struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 65 + struct rsnd_mod *adg_mod = rsnd_mod_get(adg); 97 66 int id = rsnd_mod_id(mod); 98 67 int shift = (id % 2) ? 16 : 0; 99 68 u32 mask, val; ··· 106 69 val = val << shift; 107 70 mask = 0xffff << shift; 108 71 109 - rsnd_mod_bset(mod, CMDOUT_TIMSEL, mask, val); 72 + rsnd_mod_bset(adg_mod, CMDOUT_TIMSEL, mask, val); 110 73 111 74 return 0; 112 75 } 113 76 114 - static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *mod, 77 + static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *src_mod, 115 78 struct rsnd_dai_stream *io, 116 79 u32 timsel) 117 80 { 81 + struct rsnd_priv *priv = rsnd_mod_to_priv(src_mod); 82 + struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 83 + struct rsnd_mod *adg_mod = rsnd_mod_get(adg); 118 84 int is_play = rsnd_io_is_play(io); 119 - int id = rsnd_mod_id(mod); 85 + int id = rsnd_mod_id(src_mod); 120 86 int shift = (id % 2) ? 16 : 0; 121 87 u32 mask, ws; 122 88 u32 in, out; 89 + 90 + rsnd_mod_confirm_src(src_mod); 123 91 124 92 ws = rsnd_adg_ssi_ws_timing_gen2(io); 125 93 ··· 137 95 138 96 switch (id / 2) { 139 97 case 0: 140 - rsnd_mod_bset(mod, SRCIN_TIMSEL0, mask, in); 141 - rsnd_mod_bset(mod, SRCOUT_TIMSEL0, mask, out); 98 + rsnd_mod_bset(adg_mod, SRCIN_TIMSEL0, mask, in); 99 + rsnd_mod_bset(adg_mod, SRCOUT_TIMSEL0, mask, out); 142 100 break; 143 101 case 1: 144 - rsnd_mod_bset(mod, SRCIN_TIMSEL1, mask, in); 145 - rsnd_mod_bset(mod, SRCOUT_TIMSEL1, mask, out); 102 + rsnd_mod_bset(adg_mod, SRCIN_TIMSEL1, mask, in); 103 + rsnd_mod_bset(adg_mod, SRCOUT_TIMSEL1, mask, out); 146 104 break; 147 105 case 2: 148 - rsnd_mod_bset(mod, SRCIN_TIMSEL2, mask, in); 149 - rsnd_mod_bset(mod, SRCOUT_TIMSEL2, mask, out); 106 + rsnd_mod_bset(adg_mod, SRCIN_TIMSEL2, mask, in); 107 + rsnd_mod_bset(adg_mod, SRCOUT_TIMSEL2, mask, out); 150 108 break; 151 109 case 3: 152 - rsnd_mod_bset(mod, SRCIN_TIMSEL3, mask, in); 153 - rsnd_mod_bset(mod, SRCOUT_TIMSEL3, mask, out); 110 + rsnd_mod_bset(adg_mod, SRCIN_TIMSEL3, mask, in); 111 + rsnd_mod_bset(adg_mod, SRCOUT_TIMSEL3, mask, out); 154 112 break; 155 113 case 4: 156 - rsnd_mod_bset(mod, SRCIN_TIMSEL4, mask, in); 157 - rsnd_mod_bset(mod, SRCOUT_TIMSEL4, mask, out); 114 + rsnd_mod_bset(adg_mod, SRCIN_TIMSEL4, mask, in); 115 + rsnd_mod_bset(adg_mod, SRCOUT_TIMSEL4, mask, out); 158 116 break; 159 117 } 160 118 161 119 return 0; 162 120 } 163 121 164 - int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, 122 + int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *src_mod, 165 123 struct rsnd_dai_stream *io, 166 124 unsigned int src_rate, 167 125 unsigned int dst_rate) 168 126 { 169 - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 127 + struct rsnd_priv *priv = rsnd_mod_to_priv(src_mod); 170 128 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 129 + struct rsnd_mod *adg_mod = rsnd_mod_get(adg); 171 130 struct device *dev = rsnd_priv_to_dev(priv); 172 131 int idx, sel, div, step, ret; 173 132 u32 val, en; ··· 177 134 clk_get_rate(adg->clk[CLKA]), /* 0000: CLKA */ 178 135 clk_get_rate(adg->clk[CLKB]), /* 0001: CLKB */ 179 136 clk_get_rate(adg->clk[CLKC]), /* 0010: CLKC */ 180 - adg->rbga_rate_for_441khz_div_6,/* 0011: RBGA */ 181 - adg->rbgb_rate_for_48khz_div_6, /* 0100: RBGB */ 137 + adg->rbga_rate_for_441khz, /* 0011: RBGA */ 138 + adg->rbgb_rate_for_48khz, /* 0100: RBGB */ 182 139 }; 140 + 141 + rsnd_mod_confirm_src(src_mod); 183 142 184 143 min = ~0; 185 144 val = 0; ··· 220 175 return -EIO; 221 176 } 222 177 223 - ret = rsnd_adg_set_src_timsel_gen2(mod, io, val); 178 + ret = rsnd_adg_set_src_timsel_gen2(src_mod, io, val); 224 179 if (ret < 0) { 225 180 dev_err(dev, "timsel error\n"); 226 181 return ret; 227 182 } 228 183 229 - rsnd_mod_bset(mod, DIV_EN, en, en); 184 + rsnd_mod_bset(adg_mod, DIV_EN, en, en); 230 185 231 186 dev_dbg(dev, "convert rate %d <-> %d\n", src_rate, dst_rate); 232 187 233 188 return 0; 234 189 } 235 190 236 - int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod, 191 + int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *src_mod, 237 192 struct rsnd_dai_stream *io) 238 193 { 239 194 u32 val = rsnd_adg_ssi_ws_timing_gen2(io); 240 195 241 - return rsnd_adg_set_src_timsel_gen2(mod, io, val); 196 + rsnd_mod_confirm_src(src_mod); 197 + 198 + return rsnd_adg_set_src_timsel_gen2(src_mod, io, val); 242 199 } 243 200 244 201 int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv, ··· 249 202 unsigned int dst_rate) 250 203 { 251 204 struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 205 + struct rsnd_mod *adg_mod = rsnd_mod_get(adg); 252 206 struct device *dev = rsnd_priv_to_dev(priv); 253 207 int idx, sel, div, shift; 254 208 u32 mask, val; ··· 259 211 clk_get_rate(adg->clk[CLKB]), /* 001: CLKB */ 260 212 clk_get_rate(adg->clk[CLKC]), /* 010: CLKC */ 261 213 0, /* 011: MLBCLK (not used) */ 262 - adg->rbga_rate_for_441khz_div_6,/* 100: RBGA */ 263 - adg->rbgb_rate_for_48khz_div_6, /* 101: RBGB */ 214 + adg->rbga_rate_for_441khz, /* 100: RBGA */ 215 + adg->rbgb_rate_for_48khz, /* 101: RBGB */ 264 216 }; 265 217 266 218 /* find div (= 1/128, 1/256, 1/512, 1/1024, 1/2048 */ ··· 286 238 287 239 switch (id / 4) { 288 240 case 0: 289 - rsnd_mod_bset(mod, AUDIO_CLK_SEL3, mask, val); 241 + rsnd_mod_bset(adg_mod, AUDIO_CLK_SEL3, mask, val); 290 242 break; 291 243 case 1: 292 - rsnd_mod_bset(mod, AUDIO_CLK_SEL4, mask, val); 244 + rsnd_mod_bset(adg_mod, AUDIO_CLK_SEL4, mask, val); 293 245 break; 294 246 case 2: 295 - rsnd_mod_bset(mod, AUDIO_CLK_SEL5, mask, val); 247 + rsnd_mod_bset(adg_mod, AUDIO_CLK_SEL5, mask, val); 296 248 break; 297 249 } 298 250 ··· 305 257 return 0; 306 258 } 307 259 308 - static void rsnd_adg_set_ssi_clk(struct rsnd_mod *mod, u32 val) 260 + static void rsnd_adg_set_ssi_clk(struct rsnd_mod *ssi_mod, u32 val) 309 261 { 310 - int id = rsnd_mod_id(mod); 262 + struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod); 263 + struct rsnd_adg *adg = rsnd_priv_to_adg(priv); 264 + struct rsnd_mod *adg_mod = rsnd_mod_get(adg); 265 + int id = rsnd_mod_id(ssi_mod); 311 266 int shift = (id % 4) * 8; 312 267 u32 mask = 0xFF << shift; 268 + 269 + rsnd_mod_confirm_ssi(ssi_mod); 313 270 314 271 val = val << shift; 315 272 ··· 327 274 328 275 switch (id / 4) { 329 276 case 0: 330 - rsnd_mod_bset(mod, AUDIO_CLK_SEL0, mask, val); 277 + rsnd_mod_bset(adg_mod, AUDIO_CLK_SEL0, mask, val); 331 278 break; 332 279 case 1: 333 - rsnd_mod_bset(mod, AUDIO_CLK_SEL1, mask, val); 280 + rsnd_mod_bset(adg_mod, AUDIO_CLK_SEL1, mask, val); 334 281 break; 335 282 case 2: 336 - rsnd_mod_bset(mod, AUDIO_CLK_SEL2, mask, val); 283 + rsnd_mod_bset(adg_mod, AUDIO_CLK_SEL2, mask, val); 337 284 break; 338 285 } 339 286 } ··· 379 326 } 380 327 381 328 /* 382 - * find 1/6 clock from BRGA/BRGB 329 + * find divided clock from BRGA/BRGB 383 330 */ 384 - if (rate == adg->rbga_rate_for_441khz_div_6) { 331 + if (rate == adg->rbga_rate_for_441khz) { 385 332 data = 0x10; 386 333 goto found_clock; 387 334 } 388 335 389 - if (rate == adg->rbgb_rate_for_48khz_div_6) { 336 + if (rate == adg->rbgb_rate_for_48khz) { 390 337 data = 0x20; 391 338 goto found_clock; 392 339 } ··· 395 342 396 343 found_clock: 397 344 398 - /* see rsnd_adg_ssi_clk_init() */ 399 - rsnd_mod_bset(mod, SSICKR, 0x00FF0000, adg->ckr); 400 - rsnd_mod_write(mod, BRRA, 0x00000002); /* 1/6 */ 401 - rsnd_mod_write(mod, BRRB, 0x00000002); /* 1/6 */ 402 - 403 345 /* 404 346 * This "mod" = "ssi" here. 405 347 * we can get "ssi id" from mod 406 348 */ 407 349 rsnd_adg_set_ssi_clk(mod, data); 408 350 409 - dev_dbg(dev, "ADG: ssi%d selects clk%d = %d", 410 - rsnd_mod_id(mod), i, rate); 351 + dev_dbg(dev, "ADG: %s[%d] selects 0x%x for %d\n", 352 + rsnd_mod_name(mod), rsnd_mod_id(mod), 353 + data, rate); 411 354 412 355 return 0; 413 356 } 414 357 415 - static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg) 358 + static void rsnd_adg_get_clkin(struct rsnd_priv *priv, 359 + struct rsnd_adg *adg) 360 + { 361 + struct device *dev = rsnd_priv_to_dev(priv); 362 + struct clk *clk; 363 + static const char * const clk_name[] = { 364 + [CLKA] = "clk_a", 365 + [CLKB] = "clk_b", 366 + [CLKC] = "clk_c", 367 + [CLKI] = "clk_i", 368 + }; 369 + int i; 370 + 371 + for (i = 0; i < CLKMAX; i++) { 372 + clk = devm_clk_get(dev, clk_name[i]); 373 + adg->clk[i] = IS_ERR(clk) ? NULL : clk; 374 + } 375 + 376 + for_each_rsnd_clk(clk, adg, i) 377 + dev_dbg(dev, "clk %d : %p : %ld\n", i, clk, clk_get_rate(clk)); 378 + } 379 + 380 + static void rsnd_adg_get_clkout(struct rsnd_priv *priv, 381 + struct rsnd_adg *adg) 416 382 { 417 383 struct clk *clk; 418 - unsigned long rate; 419 - u32 ckr; 384 + struct rsnd_mod *adg_mod = rsnd_mod_get(adg); 385 + struct device *dev = rsnd_priv_to_dev(priv); 386 + struct device_node *np = dev->of_node; 387 + u32 ckr, rbgx, rbga, rbgb; 388 + u32 rate, req_rate, div; 389 + uint32_t count = 0; 390 + unsigned long req_48kHz_rate, req_441kHz_rate; 420 391 int i; 392 + const char *parent_clk_name = NULL; 393 + static const char * const clkout_name[] = { 394 + [CLKOUT] = "audio_clkout", 395 + [CLKOUT1] = "audio_clkout1", 396 + [CLKOUT2] = "audio_clkout2", 397 + [CLKOUT3] = "audio_clkout3", 398 + }; 421 399 int brg_table[] = { 422 400 [CLKA] = 0x0, 423 401 [CLKB] = 0x1, ··· 456 372 [CLKI] = 0x2, 457 373 }; 458 374 375 + of_property_read_u32(np, "#clock-cells", &count); 376 + 377 + /* 378 + * ADG supports BRRA/BRRB output only 379 + * this means all clkout0/1/2/3 will be same rate 380 + */ 381 + of_property_read_u32(np, "clock-frequency", &req_rate); 382 + req_48kHz_rate = 0; 383 + req_441kHz_rate = 0; 384 + if (0 == (req_rate % 44100)) 385 + req_441kHz_rate = req_rate; 386 + if (0 == (req_rate % 48000)) 387 + req_48kHz_rate = req_rate; 388 + 459 389 /* 460 390 * This driver is assuming that AUDIO_CLKA/AUDIO_CLKB/AUDIO_CLKC 461 391 * have 44.1kHz or 48kHz base clocks for now. 462 392 * 463 393 * SSI itself can divide parent clock by 1/1 - 1/16 464 - * So, BRGA outputs 44.1kHz base parent clock 1/32, 465 - * and, BRGB outputs 48.0kHz base parent clock 1/32 here. 466 394 * see 467 395 * rsnd_adg_ssi_clk_try_start() 396 + * rsnd_ssi_master_clk_start() 468 397 */ 469 398 ckr = 0; 470 - adg->rbga_rate_for_441khz_div_6 = 0; 471 - adg->rbgb_rate_for_48khz_div_6 = 0; 399 + rbga = 2; /* default 1/6 */ 400 + rbgb = 2; /* default 1/6 */ 401 + adg->rbga_rate_for_441khz = 0; 402 + adg->rbgb_rate_for_48khz = 0; 472 403 for_each_rsnd_clk(clk, adg, i) { 473 404 rate = clk_get_rate(clk); 474 405 ··· 491 392 continue; 492 393 493 394 /* RBGA */ 494 - if (!adg->rbga_rate_for_441khz_div_6 && (0 == rate % 44100)) { 495 - adg->rbga_rate_for_441khz_div_6 = rate / 6; 496 - ckr |= brg_table[i] << 20; 395 + if (!adg->rbga_rate_for_441khz && (0 == rate % 44100)) { 396 + div = 6; 397 + if (req_441kHz_rate) 398 + div = rate / req_441kHz_rate; 399 + rbgx = rsnd_adg_calculate_rbgx(div); 400 + if (BRRx_MASK(rbgx) == rbgx) { 401 + rbga = rbgx; 402 + adg->rbga_rate_for_441khz = rate / div; 403 + ckr |= brg_table[i] << 20; 404 + if (req_441kHz_rate) 405 + parent_clk_name = __clk_get_name(clk); 406 + } 497 407 } 498 408 499 409 /* RBGB */ 500 - if (!adg->rbgb_rate_for_48khz_div_6 && (0 == rate % 48000)) { 501 - adg->rbgb_rate_for_48khz_div_6 = rate / 6; 502 - ckr |= brg_table[i] << 16; 410 + if (!adg->rbgb_rate_for_48khz && (0 == rate % 48000)) { 411 + div = 6; 412 + if (req_48kHz_rate) 413 + div = rate / req_48kHz_rate; 414 + rbgx = rsnd_adg_calculate_rbgx(div); 415 + if (BRRx_MASK(rbgx) == rbgx) { 416 + rbgb = rbgx; 417 + adg->rbgb_rate_for_48khz = rate / div; 418 + ckr |= brg_table[i] << 16; 419 + if (req_48kHz_rate) { 420 + parent_clk_name = __clk_get_name(clk); 421 + ckr |= 0x80000000; 422 + } 423 + } 503 424 } 504 425 } 505 426 506 - adg->ckr = ckr; 427 + /* 428 + * ADG supports BRRA/BRRB output only. 429 + * this means all clkout0/1/2/3 will be * same rate 430 + */ 431 + 432 + /* 433 + * for clkout 434 + */ 435 + if (!count) { 436 + clk = clk_register_fixed_rate(dev, clkout_name[CLKOUT], 437 + parent_clk_name, 438 + (parent_clk_name) ? 439 + 0 : CLK_IS_ROOT, req_rate); 440 + if (!IS_ERR(clk)) { 441 + adg->clkout[CLKOUT] = clk; 442 + of_clk_add_provider(np, of_clk_src_simple_get, clk); 443 + } 444 + } 445 + /* 446 + * for clkout0/1/2/3 447 + */ 448 + else { 449 + for (i = 0; i < CLKOUTMAX; i++) { 450 + clk = clk_register_fixed_rate(dev, clkout_name[i], 451 + parent_clk_name, 452 + (parent_clk_name) ? 453 + 0 : CLK_IS_ROOT, 454 + req_rate); 455 + if (!IS_ERR(clk)) { 456 + adg->onecell.clks = adg->clkout; 457 + adg->onecell.clk_num = CLKOUTMAX; 458 + 459 + adg->clkout[i] = clk; 460 + 461 + of_clk_add_provider(np, of_clk_src_onecell_get, 462 + &adg->onecell); 463 + } 464 + } 465 + } 466 + 467 + rsnd_mod_bset(adg_mod, SSICKR, 0x00FF0000, ckr); 468 + rsnd_mod_write(adg_mod, BRRA, rbga); 469 + rsnd_mod_write(adg_mod, BRRB, rbgb); 470 + 471 + for_each_rsnd_clkout(clk, adg, i) 472 + dev_dbg(dev, "clkout %d : %p : %ld\n", i, clk, clk_get_rate(clk)); 473 + dev_dbg(dev, "SSICKR = 0x%08x, BRRA/BRRB = 0x%x/0x%x\n", 474 + ckr, rbga, rbgb); 507 475 } 508 476 509 477 int rsnd_adg_probe(struct platform_device *pdev, ··· 579 413 { 580 414 struct rsnd_adg *adg; 581 415 struct device *dev = rsnd_priv_to_dev(priv); 582 - struct clk *clk; 583 - int i; 584 416 585 417 adg = devm_kzalloc(dev, sizeof(*adg), GFP_KERNEL); 586 418 if (!adg) { ··· 586 422 return -ENOMEM; 587 423 } 588 424 589 - adg->clk[CLKA] = devm_clk_get(dev, "clk_a"); 590 - adg->clk[CLKB] = devm_clk_get(dev, "clk_b"); 591 - adg->clk[CLKC] = devm_clk_get(dev, "clk_c"); 592 - adg->clk[CLKI] = devm_clk_get(dev, "clk_i"); 425 + /* 426 + * ADG is special module. 427 + * Use ADG mod without rsnd_mod_init() to make debug easy 428 + * for rsnd_write/rsnd_read 429 + */ 430 + adg->mod.ops = &adg_ops; 431 + adg->mod.priv = priv; 593 432 594 - for_each_rsnd_clk(clk, adg, i) 595 - dev_dbg(dev, "clk %d : %p : %ld\n", i, clk, clk_get_rate(clk)); 596 - 597 - rsnd_adg_ssi_clk_init(priv, adg); 433 + rsnd_adg_get_clkin(priv, adg); 434 + rsnd_adg_get_clkout(priv, adg); 598 435 599 436 priv->adg = adg; 600 437
+12
sound/soc/sh/rcar/core.c
··· 110 110 static const struct of_device_id rsnd_of_match[] = { 111 111 { .compatible = "renesas,rcar_sound-gen1", .data = &rsnd_of_data_gen1 }, 112 112 { .compatible = "renesas,rcar_sound-gen2", .data = &rsnd_of_data_gen2 }, 113 + { .compatible = "renesas,rcar_sound-gen3", .data = &rsnd_of_data_gen2 }, /* gen2 compatible */ 113 114 {}, 114 115 }; 115 116 MODULE_DEVICE_TABLE(of, rsnd_of_match); ··· 126 125 ((io)->info ? (io)->info->name : NULL) 127 126 #define rsnd_info_id(priv, io, name) \ 128 127 ((io)->info->name - priv->info->name##_info) 128 + 129 + void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type) 130 + { 131 + if (mod->type != type) { 132 + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 133 + struct device *dev = rsnd_priv_to_dev(priv); 134 + 135 + dev_warn(dev, "%s[%d] is not your expected module\n", 136 + rsnd_mod_name(mod), rsnd_mod_id(mod)); 137 + } 138 + } 129 139 130 140 /* 131 141 * rsnd_mod functions
+3 -3
sound/soc/sh/rcar/ctu.c
··· 66 66 if (WARN_ON(id < 0 || id >= rsnd_ctu_nr(priv))) 67 67 id = 0; 68 68 69 - return &((struct rsnd_ctu *)(priv->ctu) + id)->mod; 69 + return rsnd_mod_get((struct rsnd_ctu *)(priv->ctu) + id); 70 70 } 71 71 72 72 static void rsnd_of_parse_ctu(struct platform_device *pdev, ··· 150 150 151 151 ctu->info = &info->ctu_info[i]; 152 152 153 - ret = rsnd_mod_init(priv, &ctu->mod, &rsnd_ctu_ops, 153 + ret = rsnd_mod_init(priv, rsnd_mod_get(ctu), &rsnd_ctu_ops, 154 154 clk, RSND_MOD_CTU, i); 155 155 if (ret) 156 156 return ret; ··· 166 166 int i; 167 167 168 168 for_each_rsnd_ctu(ctu, priv, i) { 169 - rsnd_mod_quit(&ctu->mod); 169 + rsnd_mod_quit(rsnd_mod_get(ctu)); 170 170 } 171 171 }
+3 -3
sound/soc/sh/rcar/dvc.c
··· 282 282 if (WARN_ON(id < 0 || id >= rsnd_dvc_nr(priv))) 283 283 id = 0; 284 284 285 - return &((struct rsnd_dvc *)(priv->dvc) + id)->mod; 285 + return rsnd_mod_get((struct rsnd_dvc *)(priv->dvc) + id); 286 286 } 287 287 288 288 static void rsnd_of_parse_dvc(struct platform_device *pdev, ··· 361 361 362 362 dvc->info = &info->dvc_info[i]; 363 363 364 - ret = rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops, 364 + ret = rsnd_mod_init(priv, rsnd_mod_get(dvc), &rsnd_dvc_ops, 365 365 clk, RSND_MOD_DVC, i); 366 366 if (ret) 367 367 return ret; ··· 377 377 int i; 378 378 379 379 for_each_rsnd_dvc(dvc, priv, i) { 380 - rsnd_mod_quit(&dvc->mod); 380 + rsnd_mod_quit(rsnd_mod_get(dvc)); 381 381 } 382 382 }
+3 -3
sound/soc/sh/rcar/mix.c
··· 99 99 if (WARN_ON(id < 0 || id >= rsnd_mix_nr(priv))) 100 100 id = 0; 101 101 102 - return &((struct rsnd_mix *)(priv->mix) + id)->mod; 102 + return rsnd_mod_get((struct rsnd_mix *)(priv->mix) + id); 103 103 } 104 104 105 105 static void rsnd_of_parse_mix(struct platform_device *pdev, ··· 179 179 180 180 mix->info = &info->mix_info[i]; 181 181 182 - ret = rsnd_mod_init(priv, &mix->mod, &rsnd_mix_ops, 182 + ret = rsnd_mod_init(priv, rsnd_mod_get(mix), &rsnd_mix_ops, 183 183 clk, RSND_MOD_MIX, i); 184 184 if (ret) 185 185 return ret; ··· 195 195 int i; 196 196 197 197 for_each_rsnd_mix(mix, priv, i) { 198 - rsnd_mod_quit(&mix->mod); 198 + rsnd_mod_quit(rsnd_mod_get(mix)); 199 199 } 200 200 }
+13 -2
sound/soc/sh/rcar/rsnd.h
··· 214 214 }; 215 215 #define rsnd_dma_to_dmaen(dma) (&(dma)->dma.en) 216 216 #define rsnd_dma_to_dmapp(dma) (&(dma)->dma.pp) 217 + #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) 217 218 218 219 void rsnd_dma_start(struct rsnd_dai_stream *io, struct rsnd_dma *dma); 219 220 void rsnd_dma_stop(struct rsnd_dai_stream *io, struct rsnd_dma *dma); ··· 225 224 struct rsnd_priv *priv); 226 225 struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, 227 226 struct rsnd_mod *mod, char *name); 228 - 229 - #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma) 230 227 231 228 /* 232 229 * R-Car sound mod ··· 331 332 #define rsnd_mod_id(mod) ((mod) ? (mod)->id : -1) 332 333 #define rsnd_mod_hw_start(mod) clk_enable((mod)->clk) 333 334 #define rsnd_mod_hw_stop(mod) clk_disable((mod)->clk) 335 + #define rsnd_mod_get(ip) (&(ip)->mod) 334 336 335 337 int rsnd_mod_init(struct rsnd_priv *priv, 336 338 struct rsnd_mod *mod, ··· 626 626 void rsnd_dvc_remove(struct platform_device *pdev, 627 627 struct rsnd_priv *priv); 628 628 struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id); 629 + 630 + #ifdef DEBUG 631 + void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type); 632 + #define rsnd_mod_confirm_ssi(mssi) rsnd_mod_make_sure(mssi, RSND_MOD_SSI) 633 + #define rsnd_mod_confirm_src(msrc) rsnd_mod_make_sure(msrc, RSND_MOD_SRC) 634 + #define rsnd_mod_confirm_dvc(mdvc) rsnd_mod_make_sure(mdvc, RSND_MOD_DVC) 635 + #else 636 + #define rsnd_mod_confirm_ssi(mssi) 637 + #define rsnd_mod_confirm_src(msrc) 638 + #define rsnd_mod_confirm_dvc(mdvc) 639 + #endif 629 640 630 641 #endif
+5 -12
sound/soc/sh/rcar/src.c
··· 918 918 rsnd_mod_write(mod, SRC_IFSVR, fsrate); 919 919 } 920 920 921 - static int rsnd_src_pcm_new(struct rsnd_mod *mod, 921 + static int rsnd_src_pcm_new_gen2(struct rsnd_mod *mod, 922 922 struct rsnd_dai_stream *io, 923 923 struct snd_soc_pcm_runtime *rtd) 924 924 { 925 - struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 926 925 struct rsnd_dai *rdai = rsnd_io_to_rdai(io); 927 926 struct rsnd_src *src = rsnd_mod_to_src(mod); 928 927 int ret; ··· 929 930 /* 930 931 * enable SRC sync convert if possible 931 932 */ 932 - 933 - /* 934 - * Gen1 is not supported 935 - */ 936 - if (rsnd_is_gen1(priv)) 937 - return 0; 938 933 939 934 /* 940 935 * SRC sync convert needs clock master ··· 968 975 .start = rsnd_src_start_gen2, 969 976 .stop = rsnd_src_stop_gen2, 970 977 .hw_params = rsnd_src_hw_params, 971 - .pcm_new = rsnd_src_pcm_new, 978 + .pcm_new = rsnd_src_pcm_new_gen2, 972 979 }; 973 980 974 981 struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id) ··· 976 983 if (WARN_ON(id < 0 || id >= rsnd_src_nr(priv))) 977 984 id = 0; 978 985 979 - return &((struct rsnd_src *)(priv->src) + id)->mod; 986 + return rsnd_mod_get((struct rsnd_src *)(priv->src) + id); 980 987 } 981 988 982 989 static void rsnd_of_parse_src(struct platform_device *pdev, ··· 1071 1078 1072 1079 src->info = &info->src_info[i]; 1073 1080 1074 - ret = rsnd_mod_init(priv, &src->mod, ops, clk, RSND_MOD_SRC, i); 1081 + ret = rsnd_mod_init(priv, rsnd_mod_get(src), ops, clk, RSND_MOD_SRC, i); 1075 1082 if (ret) 1076 1083 return ret; 1077 1084 } ··· 1086 1093 int i; 1087 1094 1088 1095 for_each_rsnd_src(src, priv, i) { 1089 - rsnd_mod_quit(&src->mod); 1096 + rsnd_mod_quit(rsnd_mod_get(src)); 1090 1097 } 1091 1098 }
+47 -43
sound/soc/sh/rcar/ssi.c
··· 128 128 struct rsnd_priv *priv = rsnd_io_to_priv(io); 129 129 struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); 130 130 struct device *dev = rsnd_priv_to_dev(priv); 131 - int i, j, ret; 132 - int adg_clk_div_table[] = { 133 - 1, 6, /* see adg.c */ 134 - }; 131 + struct rsnd_mod *mod = rsnd_mod_get(ssi); 132 + int j, ret; 135 133 int ssi_clk_mul_table[] = { 136 134 1, 2, 4, 8, 16, 6, 12, 137 135 }; ··· 139 141 /* 140 142 * Find best clock, and try to start ADG 141 143 */ 142 - for (i = 0; i < ARRAY_SIZE(adg_clk_div_table); i++) { 143 - for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) { 144 + for (j = 0; j < ARRAY_SIZE(ssi_clk_mul_table); j++) { 144 145 145 - /* 146 - * this driver is assuming that 147 - * system word is 64fs (= 2 x 32bit) 148 - * see rsnd_ssi_init() 149 - */ 150 - main_rate = rate / adg_clk_div_table[i] 151 - * 32 * 2 * ssi_clk_mul_table[j]; 146 + /* 147 + * this driver is assuming that 148 + * system word is 64fs (= 2 x 32bit) 149 + * see rsnd_ssi_init() 150 + */ 151 + main_rate = rate * 32 * 2 * ssi_clk_mul_table[j]; 152 152 153 - ret = rsnd_adg_ssi_clk_try_start(&ssi->mod, main_rate); 154 - if (0 == ret) { 155 - ssi->cr_clk = FORCE | SWL_32 | 156 - SCKD | SWSD | CKDV(j); 153 + ret = rsnd_adg_ssi_clk_try_start(mod, main_rate); 154 + if (0 == ret) { 155 + ssi->cr_clk = FORCE | SWL_32 | 156 + SCKD | SWSD | CKDV(j); 157 157 158 - dev_dbg(dev, "%s[%d] outputs %u Hz\n", 159 - rsnd_mod_name(&ssi->mod), 160 - rsnd_mod_id(&ssi->mod), rate); 158 + dev_dbg(dev, "%s[%d] outputs %u Hz\n", 159 + rsnd_mod_name(mod), 160 + rsnd_mod_id(mod), rate); 161 161 162 - return 0; 163 - } 162 + return 0; 164 163 } 165 164 } 166 165 ··· 167 172 168 173 static void rsnd_ssi_master_clk_stop(struct rsnd_ssi *ssi) 169 174 { 175 + struct rsnd_mod *mod = rsnd_mod_get(ssi); 176 + 170 177 ssi->cr_clk = 0; 171 - rsnd_adg_ssi_clk_stop(&ssi->mod); 178 + rsnd_adg_ssi_clk_stop(mod); 172 179 } 173 180 174 181 static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi, ··· 179 182 struct rsnd_priv *priv = rsnd_io_to_priv(io); 180 183 struct rsnd_dai *rdai = rsnd_io_to_rdai(io); 181 184 struct device *dev = rsnd_priv_to_dev(priv); 185 + struct rsnd_mod *mod = rsnd_mod_get(ssi); 182 186 u32 cr_mode; 183 187 u32 cr; 184 188 185 189 if (0 == ssi->usrcnt) { 186 - rsnd_mod_hw_start(&ssi->mod); 190 + rsnd_mod_hw_start(mod); 187 191 188 192 if (rsnd_rdai_is_clk_master(rdai)) { 189 193 struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); ··· 196 198 } 197 199 } 198 200 199 - if (rsnd_ssi_is_dma_mode(&ssi->mod)) { 201 + if (rsnd_ssi_is_dma_mode(mod)) { 200 202 cr_mode = UIEN | OIEN | /* over/under run */ 201 203 DMEN; /* DMA : enable DMA */ 202 204 } else { ··· 208 210 cr_mode | 209 211 EN; 210 212 211 - rsnd_mod_write(&ssi->mod, SSICR, cr); 213 + rsnd_mod_write(mod, SSICR, cr); 212 214 213 215 /* enable WS continue */ 214 216 if (rsnd_rdai_is_clk_master(rdai)) 215 - rsnd_mod_write(&ssi->mod, SSIWSR, CONT); 217 + rsnd_mod_write(mod, SSIWSR, CONT); 216 218 217 219 /* clear error status */ 218 - rsnd_mod_write(&ssi->mod, SSISR, 0); 220 + rsnd_mod_write(mod, SSISR, 0); 219 221 220 222 ssi->usrcnt++; 221 223 222 224 dev_dbg(dev, "%s[%d] hw started\n", 223 - rsnd_mod_name(&ssi->mod), rsnd_mod_id(&ssi->mod)); 225 + rsnd_mod_name(mod), rsnd_mod_id(mod)); 224 226 } 225 227 226 228 static void rsnd_ssi_hw_stop(struct rsnd_dai_stream *io, struct rsnd_ssi *ssi) 227 229 { 228 - struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod); 230 + struct rsnd_mod *mod = rsnd_mod_get(ssi); 231 + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 229 232 struct rsnd_dai *rdai = rsnd_io_to_rdai(io); 230 233 struct device *dev = rsnd_priv_to_dev(priv); 231 234 u32 cr; ··· 246 247 cr = ssi->cr_own | 247 248 ssi->cr_clk; 248 249 249 - rsnd_mod_write(&ssi->mod, SSICR, cr | EN); 250 - rsnd_ssi_status_check(&ssi->mod, DIRQ); 250 + rsnd_mod_write(mod, SSICR, cr | EN); 251 + rsnd_ssi_status_check(mod, DIRQ); 251 252 252 253 /* 253 254 * disable SSI, 254 255 * and, wait idle state 255 256 */ 256 - rsnd_mod_write(&ssi->mod, SSICR, cr); /* disabled all */ 257 - rsnd_ssi_status_check(&ssi->mod, IIRQ); 257 + rsnd_mod_write(mod, SSICR, cr); /* disabled all */ 258 + rsnd_ssi_status_check(mod, IIRQ); 258 259 259 260 if (rsnd_rdai_is_clk_master(rdai)) { 260 261 struct rsnd_ssi *ssi_parent = rsnd_ssi_parent(ssi); ··· 265 266 rsnd_ssi_master_clk_stop(ssi); 266 267 } 267 268 268 - rsnd_mod_hw_stop(&ssi->mod); 269 + rsnd_mod_hw_stop(mod); 269 270 270 271 ssi->chan = 0; 271 272 } 272 273 273 274 dev_dbg(dev, "%s[%d] hw stopped\n", 274 - rsnd_mod_name(&ssi->mod), rsnd_mod_id(&ssi->mod)); 275 + rsnd_mod_name(mod), rsnd_mod_id(mod)); 275 276 } 276 277 277 278 /* ··· 370 371 /* It will be removed on rsnd_ssi_hw_stop */ 371 372 ssi->chan = chan; 372 373 if (ssi_parent) 373 - return rsnd_ssi_hw_params(&ssi_parent->mod, io, 374 + return rsnd_ssi_hw_params(rsnd_mod_get(ssi_parent), io, 374 375 substream, params); 375 376 376 377 return 0; ··· 378 379 379 380 static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status) 380 381 { 382 + struct rsnd_mod *mod = rsnd_mod_get(ssi); 383 + 381 384 /* under/over flow error */ 382 385 if (status & (UIRQ | OIRQ)) { 383 386 ssi->err++; 384 387 385 388 /* clear error status */ 386 - rsnd_mod_write(&ssi->mod, SSISR, 0); 389 + rsnd_mod_write(mod, SSISR, 0); 387 390 } 388 391 } 389 392 ··· 657 656 if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv))) 658 657 id = 0; 659 658 660 - return &((struct rsnd_ssi *)(priv->ssi) + id)->mod; 659 + return rsnd_mod_get((struct rsnd_ssi *)(priv->ssi) + id); 661 660 } 662 661 663 662 int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod) ··· 669 668 670 669 static void rsnd_ssi_parent_setup(struct rsnd_priv *priv, struct rsnd_ssi *ssi) 671 670 { 672 - if (!rsnd_ssi_is_pin_sharing(&ssi->mod)) 671 + struct rsnd_mod *mod = rsnd_mod_get(ssi); 672 + 673 + if (!rsnd_ssi_is_pin_sharing(mod)) 673 674 return; 674 675 675 - switch (rsnd_mod_id(&ssi->mod)) { 676 + switch (rsnd_mod_id(mod)) { 676 677 case 1: 677 678 case 2: 678 679 ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 0)); ··· 797 794 else if (rsnd_ssi_pio_available(ssi)) 798 795 ops = &rsnd_ssi_pio_ops; 799 796 800 - ret = rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i); 797 + ret = rsnd_mod_init(priv, rsnd_mod_get(ssi), ops, clk, 798 + RSND_MOD_SSI, i); 801 799 if (ret) 802 800 return ret; 803 801 ··· 815 811 int i; 816 812 817 813 for_each_rsnd_ssi(ssi, priv, i) { 818 - rsnd_mod_quit(&ssi->mod); 814 + rsnd_mod_quit(rsnd_mod_get(ssi)); 819 815 } 820 816 }