Lines Matching +full:msb +full:- +full:justified
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
11 #include <sound/soc-dai.h>
97 axg_spdifout_enable(priv->map); in axg_spdifout_trigger()
103 axg_spdifout_disable(priv->map); in axg_spdifout_trigger()
107 return -EINVAL; in axg_spdifout_trigger()
116 regmap_update_bits(priv->map, SPDIFOUT_CTRL0, SPDIFOUT_CTRL0_VSET, in axg_spdifout_mute()
137 dev_err(dai->dev, "too many channels for spdif dai: %u\n", in axg_spdifout_sample_fmt()
139 return -EINVAL; in axg_spdifout_sample_fmt()
142 regmap_update_bits(priv->map, SPDIFOUT_CTRL0, in axg_spdifout_sample_fmt()
152 /* 4 samples of 16 bits - right justified */ in axg_spdifout_sample_fmt()
156 /* 2 samples of 32 bits - right justified */ in axg_spdifout_sample_fmt()
160 dev_err(dai->dev, "Unsupported physical width: %u\n", in axg_spdifout_sample_fmt()
162 return -EINVAL; in axg_spdifout_sample_fmt()
165 /* Position of the MSB in FIFO samples */ in axg_spdifout_sample_fmt()
166 val |= SPDIFOUT_CTRL1_MSB_POS(params_width(params) - 1); in axg_spdifout_sample_fmt()
168 regmap_update_bits(priv->map, SPDIFOUT_CTRL1, in axg_spdifout_sample_fmt()
172 regmap_update_bits(priv->map, SPDIFOUT_CTRL0, in axg_spdifout_sample_fmt()
190 dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", in axg_spdifout_set_chsts()
196 /* Setup channel status A bits [31 - 0]*/ in axg_spdifout_set_chsts()
197 regmap_write(priv->map, SPDIFOUT_CHSTS0, val); in axg_spdifout_set_chsts()
199 /* Clear channel status A bits [191 - 32] */ in axg_spdifout_set_chsts()
201 offset += regmap_get_reg_stride(priv->map)) in axg_spdifout_set_chsts()
202 regmap_write(priv->map, offset, 0); in axg_spdifout_set_chsts()
204 /* Setup channel status B bits [31 - 0]*/ in axg_spdifout_set_chsts()
205 regmap_write(priv->map, SPDIFOUT_CHSTS6, val); in axg_spdifout_set_chsts()
207 /* Clear channel status B bits [191 - 32] */ in axg_spdifout_set_chsts()
209 offset += regmap_get_reg_stride(priv->map)) in axg_spdifout_set_chsts()
210 regmap_write(priv->map, offset, 0); in axg_spdifout_set_chsts()
224 ret = clk_set_rate(priv->mclk, rate * 128); in axg_spdifout_hw_params()
226 dev_err(dai->dev, "failed to set spdif clock\n"); in axg_spdifout_hw_params()
232 dev_err(dai->dev, "failed to setup sample format\n"); in axg_spdifout_hw_params()
238 dev_err(dai->dev, "failed to setup channel status words\n"); in axg_spdifout_hw_params()
252 ret = clk_prepare_enable(priv->pclk); in axg_spdifout_startup()
254 dev_err(dai->dev, "failed to enable pclk\n"); in axg_spdifout_startup()
259 axg_spdifout_disable(priv->map); in axg_spdifout_startup()
262 regmap_update_bits(priv->map, SPDIFOUT_CTRL0, in axg_spdifout_startup()
267 regmap_update_bits(priv->map, SPDIFOUT_CTRL0, in axg_spdifout_startup()
273 regmap_write(priv->map, SPDIFOUT_SWAP, 0x10); in axg_spdifout_startup()
283 clk_disable_unprepare(priv->pclk); in axg_spdifout_shutdown()
362 ret = clk_prepare_enable(priv->mclk); in axg_spdifout_set_bias_level()
367 clk_disable_unprepare(priv->mclk); in axg_spdifout_set_bias_level()
397 { .compatible = "amlogic,axg-spdifout", },
404 struct device *dev = &pdev->dev; in axg_spdifout_probe()
410 return -ENOMEM; in axg_spdifout_probe()
417 priv->map = devm_regmap_init_mmio(dev, regs, &axg_spdifout_regmap_cfg); in axg_spdifout_probe()
418 if (IS_ERR(priv->map)) { in axg_spdifout_probe()
420 PTR_ERR(priv->map)); in axg_spdifout_probe()
421 return PTR_ERR(priv->map); in axg_spdifout_probe()
424 priv->pclk = devm_clk_get(dev, "pclk"); in axg_spdifout_probe()
425 if (IS_ERR(priv->pclk)) in axg_spdifout_probe()
426 return dev_err_probe(dev, PTR_ERR(priv->pclk), "failed to get pclk\n"); in axg_spdifout_probe()
428 priv->mclk = devm_clk_get(dev, "mclk"); in axg_spdifout_probe()
429 if (IS_ERR(priv->mclk)) in axg_spdifout_probe()
430 return dev_err_probe(dev, PTR_ERR(priv->mclk), "failed to get mclk\n"); in axg_spdifout_probe()
439 .name = "axg-spdifout",