Lines Matching full:i2s
3 * linux/sound/soc/hisilicon/hi3660-i2s.c
5 * I2S IP driver for hi3660.
31 #include "hi3660-i2s.h"
56 static void update_bits(struct hi3660_i2s *i2s, u32 ofs, u32 reset, u32 set) in update_bits() argument
58 u32 val = readl(i2s->base + ofs) & ~reset; in update_bits()
60 writel(val | set, i2s->base + ofs); in update_bits()
63 static void update_bits_syscon(struct hi3660_i2s *i2s, in update_bits_syscon() argument
66 u32 val = readl(i2s->base_syscon + ofs) & ~reset; in update_bits_syscon()
68 writel(val | set, i2s->base_syscon + ofs); in update_bits_syscon()
71 static int enable_format(struct hi3660_i2s *i2s, in enable_format() argument
74 switch (i2s->format & SND_SOC_DAIFMT_MASTER_MASK) { in enable_format()
76 i2s->master = false; in enable_format()
77 update_bits_syscon(i2s, HI_ASP_CFG_R_CLK_SEL_REG, in enable_format()
81 i2s->master = true; in enable_format()
82 update_bits_syscon(i2s, HI_ASP_CFG_R_CLK_SEL_REG, in enable_format()
95 struct hi3660_i2s *i2s = dev_get_drvdata(cpu_dai->dev); in startup() local
98 update_bits_syscon(i2s, HI_ASP_CFG_R_RST_CTRLDIS_REG, in startup()
102 update_bits_syscon(i2s, HI_ASP_CFG_R_GATE_EN_REG, in startup()
106 update_bits_syscon(i2s, HI_ASP_CFG_R_GATE_CLKDIV_EN_REG, in startup()
110 update_bits_syscon(i2s, HI_ASP_CFG_R_CLK_SEL_REG, in startup()
114 update_bits_syscon(i2s, HI_ASP_CFG_R_CLK1_DIV_REG, in startup()
116 update_bits_syscon(i2s, HI_ASP_CFG_R_CLK4_DIV_REG, in startup()
118 update_bits_syscon(i2s, HI_ASP_CFG_R_CLK6_DIV_REG, in startup()
122 update_bits(i2s, HI_ASP_SIO_MODE_REG, HI_ASP_MASK, 0x0); in startup()
123 update_bits(i2s, HI_ASP_SIO_DATA_WIDTH_SET_REG, HI_ASP_MASK, 0x9); in startup()
124 update_bits(i2s, HI_ASP_SIO_I2S_POS_MERGE_EN_REG, HI_ASP_MASK, 0x1); in startup()
125 update_bits(i2s, HI_ASP_SIO_I2S_START_POS_REG, HI_ASP_MASK, 0x0); in startup()
133 struct hi3660_i2s *i2s = dev_get_drvdata(cpu_dai->dev); in shutdown() local
135 if (!IS_ERR_OR_NULL(i2s->asp_subsys_clk)) in shutdown()
136 clk_disable_unprepare(i2s->asp_subsys_clk); in shutdown()
141 struct hi3660_i2s *i2s = dev_get_drvdata(cpu_dai->dev); in txctrl() local
143 spin_lock(&i2s->lock); in txctrl()
147 update_bits(i2s, HI_ASP_SIO_CT_SET_REG, 0, in txctrl()
156 update_bits(i2s, HI_ASP_SIO_CT_CLR_REG, 0, in txctrl()
159 spin_unlock(&i2s->lock); in txctrl()
164 struct hi3660_i2s *i2s = dev_get_drvdata(cpu_dai->dev); in rxctrl() local
166 spin_lock(&i2s->lock); in rxctrl()
169 update_bits(i2s, HI_ASP_SIO_CT_SET_REG, 0, in rxctrl()
178 update_bits(i2s, HI_ASP_SIO_CT_CLR_REG, 0, in rxctrl()
180 spin_unlock(&i2s->lock); in rxctrl()
191 struct hi3660_i2s *i2s = dev_get_drvdata(cpu_dai->dev); in set_format() local
193 i2s->format = fmt; in set_format()
194 i2s->master = (i2s->format & SND_SOC_DAIFMT_MASTER_MASK) == in set_format()
204 struct hi3660_i2s *i2s = dev_get_drvdata(cpu_dai->dev); in hw_params() local
209 enable_format(i2s, substream); in hw_params()
214 dma_data->addr = i2s->base_phys + in hw_params()
217 dma_data->addr = i2s->base_phys + in hw_params()
223 i2s->bits = 16; in hw_params()
229 i2s->bits = 32; in hw_params()
268 struct hi3660_i2s *i2s = snd_soc_dai_get_drvdata(dai); in dai_probe() local
271 &i2s->dma_data[SNDRV_PCM_STREAM_PLAYBACK], in dai_probe()
272 &i2s->dma_data[SNDRV_PCM_STREAM_CAPTURE]); in dai_probe()
336 struct hi3660_i2s *i2s; in hi3660_i2s_probe() local
340 i2s = devm_kzalloc(dev, sizeof(*i2s), GFP_KERNEL); in hi3660_i2s_probe()
341 if (!i2s) in hi3660_i2s_probe()
344 i2s->dev = dev; in hi3660_i2s_probe()
345 spin_lock_init(&i2s->lock); in hi3660_i2s_probe()
352 i2s->base_phys = (phys_addr_t)res->start; in hi3660_i2s_probe()
354 i2s->dai = dai_init; in hi3660_i2s_probe()
355 dev_set_drvdata(&pdev->dev, i2s); in hi3660_i2s_probe()
357 i2s->base = devm_ioremap_resource(dev, res); in hi3660_i2s_probe()
358 if (IS_ERR(i2s->base)) { in hi3660_i2s_probe()
360 ret = PTR_ERR(i2s->base); in hi3660_i2s_probe()
369 i2s->base_syscon = devm_ioremap(dev, res->start, resource_size(res)); in hi3660_i2s_probe()
370 if (IS_ERR(i2s->base_syscon)) { in hi3660_i2s_probe()
372 ret = PTR_ERR(i2s->base_syscon); in hi3660_i2s_probe()
376 /* i2s iomux config */ in hi3660_i2s_probe()
377 i2s->pctrl = devm_pinctrl_get(dev); in hi3660_i2s_probe()
378 if (IS_ERR(i2s->pctrl)) { in hi3660_i2s_probe()
384 i2s->pin_default = pinctrl_lookup_state(i2s->pctrl, in hi3660_i2s_probe()
386 if (IS_ERR(i2s->pin_default)) { in hi3660_i2s_probe()
389 PTR_ERR(i2s->pin_default)); in hi3660_i2s_probe()
394 if (pinctrl_select_state(i2s->pctrl, i2s->pin_default)) { in hi3660_i2s_probe()
406 &i2s->dai, 1); in hi3660_i2s_probe()
417 struct hi3660_i2s *i2s = dev_get_drvdata(&pdev->dev); in hi3660_i2s_remove() local
422 pinctrl_put(i2s->pctrl); in hi3660_i2s_remove()
428 { .compatible = "hisilicon,hi3660-i2s-1.0" },
446 MODULE_DESCRIPTION("Hisilicon I2S driver");