diff options
| author | Nicolin Chen <nicoleotsuka@gmail.com> | 2018-02-12 17:03:21 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2018-02-21 07:30:56 -0500 |
| commit | 37ac30a4bdc397cf1311111264ac35dc8473e1de (patch) | |
| tree | ceac242329cba68aab6b2a9694b1dd30a5efc505 | |
| parent | a1d154ac2765cf982be0d4d378bc6ba342c467a3 (diff) | |
ASoC: fsl_ssi: Setup AC97 in fsl_ssi_hw_init()
AC97 configures most of registers earlier to start a communication
with CODECs in order to successfully initialize CODEC. Currently,
_fsl_ssi_set_dai_fmt() and fsl_ssi_setup_ac97() are called to get
all SSI registers properly set.
Since now the driver has a fsl_ssi_hw_init() to handle all register
initial settings, this patch moves those register settings of AC97
to the fsl_ssi_hw_init() as well.
Meanwhile it applies _fsl_ssi_set_dai_fmt() call to AC97 only since
other formats would be configured via normal set_dai_fmt() directly.
This patch also adds fsl_ssi_hw_clean() to cleanup control bits for
AC97 in the platform remote() function.
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Tested-by: Caleb Crome <caleb@crome.org>
Tested-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | sound/soc/fsl/fsl_ssi.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 36f3d51c5c43..dfb0da3cedda 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
| @@ -987,9 +987,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, | |||
| 987 | regmap_write(regs, REG_SSI_SRCR, srcr); | 987 | regmap_write(regs, REG_SSI_SRCR, srcr); |
| 988 | regmap_write(regs, REG_SSI_SCR, scr); | 988 | regmap_write(regs, REG_SSI_SCR, scr); |
| 989 | 989 | ||
| 990 | if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97) | ||
| 991 | fsl_ssi_setup_ac97(ssi); | ||
| 992 | |||
| 993 | return 0; | 990 | return 0; |
| 994 | } | 991 | } |
| 995 | 992 | ||
| @@ -1255,10 +1252,34 @@ static int fsl_ssi_hw_init(struct fsl_ssi *ssi) | |||
| 1255 | regmap_update_bits(ssi->regs, REG_SSI_SCR, | 1252 | regmap_update_bits(ssi->regs, REG_SSI_SCR, |
| 1256 | SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); | 1253 | SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); |
| 1257 | 1254 | ||
| 1255 | /* AC97 should start earlier to communicate with CODECs */ | ||
| 1256 | if (fsl_ssi_is_ac97(ssi)) { | ||
| 1257 | _fsl_ssi_set_dai_fmt(ssi->dev, ssi, ssi->dai_fmt); | ||
| 1258 | fsl_ssi_setup_ac97(ssi); | ||
| 1259 | } | ||
| 1260 | |||
| 1258 | return 0; | 1261 | return 0; |
| 1259 | } | 1262 | } |
| 1260 | 1263 | ||
| 1261 | /** | 1264 | /** |
| 1265 | * Clear SSI registers | ||
| 1266 | */ | ||
| 1267 | static void fsl_ssi_hw_clean(struct fsl_ssi *ssi) | ||
| 1268 | { | ||
| 1269 | /* Disable registers for AC97 */ | ||
| 1270 | if (fsl_ssi_is_ac97(ssi)) { | ||
| 1271 | /* Disable TE and RE bits first */ | ||
| 1272 | regmap_update_bits(ssi->regs, REG_SSI_SCR, | ||
| 1273 | SSI_SCR_TE | SSI_SCR_RE, 0); | ||
| 1274 | /* Disable AC97 mode */ | ||
| 1275 | regmap_write(ssi->regs, REG_SSI_SACNT, 0); | ||
| 1276 | /* Unset WAIT bits */ | ||
| 1277 | regmap_write(ssi->regs, REG_SSI_SOR, 0); | ||
| 1278 | /* Disable SSI -- software reset */ | ||
| 1279 | regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_SSIEN, 0); | ||
| 1280 | } | ||
| 1281 | } | ||
| 1282 | /** | ||
| 1262 | * Make every character in a string lower-case | 1283 | * Make every character in a string lower-case |
| 1263 | */ | 1284 | */ |
| 1264 | static void make_lowercase(char *s) | 1285 | static void make_lowercase(char *s) |
| @@ -1540,9 +1561,6 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
| 1540 | } | 1561 | } |
| 1541 | 1562 | ||
| 1542 | done: | 1563 | done: |
| 1543 | if (ssi->dai_fmt) | ||
| 1544 | _fsl_ssi_set_dai_fmt(dev, ssi, ssi->dai_fmt); | ||
| 1545 | |||
| 1546 | /* Initially configures SSI registers */ | 1564 | /* Initially configures SSI registers */ |
| 1547 | fsl_ssi_hw_init(ssi); | 1565 | fsl_ssi_hw_init(ssi); |
| 1548 | 1566 | ||
| @@ -1592,6 +1610,9 @@ static int fsl_ssi_remove(struct platform_device *pdev) | |||
| 1592 | if (ssi->pdev) | 1610 | if (ssi->pdev) |
| 1593 | platform_device_unregister(ssi->pdev); | 1611 | platform_device_unregister(ssi->pdev); |
| 1594 | 1612 | ||
| 1613 | /* Clean up SSI registers */ | ||
| 1614 | fsl_ssi_hw_clean(ssi); | ||
| 1615 | |||
| 1595 | if (ssi->soc->imx) | 1616 | if (ssi->soc->imx) |
| 1596 | fsl_ssi_imx_clean(pdev, ssi); | 1617 | fsl_ssi_imx_clean(pdev, ssi); |
| 1597 | 1618 | ||
