Lines Matching refs:mcbsp

64 static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)  in omap_mcbsp_st_write()  argument
66 writel_relaxed(val, mcbsp->st_data->io_base_st + reg); in omap_mcbsp_st_write()
69 static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) in omap_mcbsp_st_read() argument
71 return readl_relaxed(mcbsp->st_data->io_base_st + reg); in omap_mcbsp_st_read()
74 #define MCBSP_ST_READ(mcbsp, reg) omap_mcbsp_st_read(mcbsp, OMAP_ST_REG_##reg) argument
75 #define MCBSP_ST_WRITE(mcbsp, reg, val) \ argument
76 omap_mcbsp_st_write(mcbsp, OMAP_ST_REG_##reg, val)
78 static void omap_mcbsp_st_on(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_on() argument
82 if (mcbsp->pdata->force_ick_on) in omap_mcbsp_st_on()
83 mcbsp->pdata->force_ick_on(mcbsp->st_data->mcbsp_iclk, true); in omap_mcbsp_st_on()
86 w = MCBSP_ST_READ(mcbsp, SYSCONFIG); in omap_mcbsp_st_on()
87 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w & ~(ST_AUTOIDLE)); in omap_mcbsp_st_on()
90 w = MCBSP_READ(mcbsp, SSELCR); in omap_mcbsp_st_on()
91 MCBSP_WRITE(mcbsp, SSELCR, w | SIDETONEEN); in omap_mcbsp_st_on()
94 w = MCBSP_ST_READ(mcbsp, SSELCR); in omap_mcbsp_st_on()
95 MCBSP_ST_WRITE(mcbsp, SSELCR, w | ST_SIDETONEEN); in omap_mcbsp_st_on()
98 static void omap_mcbsp_st_off(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_off() argument
102 w = MCBSP_ST_READ(mcbsp, SSELCR); in omap_mcbsp_st_off()
103 MCBSP_ST_WRITE(mcbsp, SSELCR, w & ~(ST_SIDETONEEN)); in omap_mcbsp_st_off()
105 w = MCBSP_READ(mcbsp, SSELCR); in omap_mcbsp_st_off()
106 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN)); in omap_mcbsp_st_off()
109 w = MCBSP_ST_READ(mcbsp, SYSCONFIG); in omap_mcbsp_st_off()
110 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w | ST_AUTOIDLE); in omap_mcbsp_st_off()
112 if (mcbsp->pdata->force_ick_on) in omap_mcbsp_st_off()
113 mcbsp->pdata->force_ick_on(mcbsp->st_data->mcbsp_iclk, false); in omap_mcbsp_st_off()
116 static void omap_mcbsp_st_fir_write(struct omap_mcbsp *mcbsp, s16 *fir) in omap_mcbsp_st_fir_write() argument
120 val = MCBSP_ST_READ(mcbsp, SSELCR); in omap_mcbsp_st_fir_write()
123 MCBSP_ST_WRITE(mcbsp, SSELCR, val & ~(ST_COEFFWREN)); in omap_mcbsp_st_fir_write()
125 MCBSP_ST_WRITE(mcbsp, SSELCR, val | ST_COEFFWREN); in omap_mcbsp_st_fir_write()
128 MCBSP_ST_WRITE(mcbsp, SFIRCR, fir[i]); in omap_mcbsp_st_fir_write()
132 val = MCBSP_ST_READ(mcbsp, SSELCR); in omap_mcbsp_st_fir_write()
134 val = MCBSP_ST_READ(mcbsp, SSELCR); in omap_mcbsp_st_fir_write()
136 MCBSP_ST_WRITE(mcbsp, SSELCR, val & ~(ST_COEFFWREN)); in omap_mcbsp_st_fir_write()
139 dev_err(mcbsp->dev, "McBSP FIR load error!\n"); in omap_mcbsp_st_fir_write()
142 static void omap_mcbsp_st_chgain(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_chgain() argument
144 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_chgain()
146 MCBSP_ST_WRITE(mcbsp, SGAINCR, ST_CH0GAIN(st_data->ch0gain) | in omap_mcbsp_st_chgain()
150 static int omap_mcbsp_st_set_chgain(struct omap_mcbsp *mcbsp, int channel, in omap_mcbsp_st_set_chgain() argument
153 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_set_chgain()
159 spin_lock_irq(&mcbsp->lock); in omap_mcbsp_st_set_chgain()
168 omap_mcbsp_st_chgain(mcbsp); in omap_mcbsp_st_set_chgain()
169 spin_unlock_irq(&mcbsp->lock); in omap_mcbsp_st_set_chgain()
174 static int omap_mcbsp_st_get_chgain(struct omap_mcbsp *mcbsp, int channel, in omap_mcbsp_st_get_chgain() argument
177 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_get_chgain()
183 spin_lock_irq(&mcbsp->lock); in omap_mcbsp_st_get_chgain()
190 spin_unlock_irq(&mcbsp->lock); in omap_mcbsp_st_get_chgain()
195 static int omap_mcbsp_st_enable(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_enable() argument
197 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_enable()
202 spin_lock_irq(&mcbsp->lock); in omap_mcbsp_st_enable()
204 omap_mcbsp_st_start(mcbsp); in omap_mcbsp_st_enable()
205 spin_unlock_irq(&mcbsp->lock); in omap_mcbsp_st_enable()
210 static int omap_mcbsp_st_disable(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_disable() argument
212 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_disable()
218 spin_lock_irq(&mcbsp->lock); in omap_mcbsp_st_disable()
219 omap_mcbsp_st_stop(mcbsp); in omap_mcbsp_st_disable()
221 spin_unlock_irq(&mcbsp->lock); in omap_mcbsp_st_disable()
226 static int omap_mcbsp_st_is_enabled(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_is_enabled() argument
228 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_is_enabled()
239 struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); in st_taps_show() local
240 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in st_taps_show()
244 spin_lock_irq(&mcbsp->lock); in st_taps_show()
250 spin_unlock_irq(&mcbsp->lock); in st_taps_show()
259 struct omap_mcbsp *mcbsp = dev_get_drvdata(dev); in st_taps_store() local
260 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in st_taps_store()
263 spin_lock_irq(&mcbsp->lock); in st_taps_store()
287 spin_unlock_irq(&mcbsp->lock); in st_taps_store()
303 int omap_mcbsp_st_start(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_start() argument
305 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_start()
308 omap_mcbsp_st_fir_write(mcbsp, st_data->taps); in omap_mcbsp_st_start()
309 omap_mcbsp_st_chgain(mcbsp); in omap_mcbsp_st_start()
311 if (!mcbsp->free) { in omap_mcbsp_st_start()
312 omap_mcbsp_st_on(mcbsp); in omap_mcbsp_st_start()
320 int omap_mcbsp_st_stop(struct omap_mcbsp *mcbsp) in omap_mcbsp_st_stop() argument
322 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; in omap_mcbsp_st_stop()
325 if (!mcbsp->free) { in omap_mcbsp_st_stop()
326 omap_mcbsp_st_off(mcbsp); in omap_mcbsp_st_stop()
336 struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); in omap_mcbsp_st_init() local
345 st_data = devm_kzalloc(mcbsp->dev, sizeof(*mcbsp->st_data), GFP_KERNEL); in omap_mcbsp_st_init()
349 st_data->mcbsp_iclk = devm_clk_get(mcbsp->dev, "ick"); in omap_mcbsp_st_init()
351 dev_warn(mcbsp->dev, in omap_mcbsp_st_init()
356 st_data->io_base_st = devm_ioremap(mcbsp->dev, res->start, in omap_mcbsp_st_init()
361 ret = devm_device_add_group(mcbsp->dev, &sidetone_attr_group); in omap_mcbsp_st_init()
365 mcbsp->st_data = st_data; in omap_mcbsp_st_init()
391 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); \
402 return omap_mcbsp_st_set_chgain(mcbsp, channel, val); \
410 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); \
413 if (omap_mcbsp_st_get_chgain(mcbsp, channel, &chgain)) \
427 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); in omap_mcbsp_st_put_mode() local
430 if (value == omap_mcbsp_st_is_enabled(mcbsp)) in omap_mcbsp_st_put_mode()
434 omap_mcbsp_st_enable(mcbsp); in omap_mcbsp_st_put_mode()
436 omap_mcbsp_st_disable(mcbsp); in omap_mcbsp_st_put_mode()
445 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); in omap_mcbsp_st_get_mode() local
447 ucontrol->value.integer.value[0] = omap_mcbsp_st_is_enabled(mcbsp); in omap_mcbsp_st_get_mode()
479 struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai); in omap_mcbsp_st_add_controls() local
481 if (!mcbsp->st_data) { in omap_mcbsp_st_add_controls()
482 dev_warn(mcbsp->dev, "No sidetone data for port\n"); in omap_mcbsp_st_add_controls()
496 dev_err(mcbsp->dev, "Port %d not supported\n", port_id); in omap_mcbsp_st_add_controls()