1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2012
5 * Author: Ola Lilja <ola.o.lilja@stericsson.com>,
6 * Roger Nilsson <roger.xr.nilsson@stericsson.com>,
7 * Sandeep Kaushik <sandeep.kaushik@st.com>
13 #include <linux/module.h>
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
16 #include <linux/slab.h>
19 #include <linux/platform_data/asoc-ux500-msp.h>
21 #include <sound/soc.h>
23 #include "ux500_msp_i2s.h"
25 /* Protocol desciptors */
26 static const struct msp_protdesc prot_descs
[] = {
30 MSP_PHASE2_START_MODE_IMEDIATE
,
31 MSP_PHASE2_START_MODE_IMEDIATE
,
50 MSP_COMPRESS_MODE_LINEAR
,
51 MSP_EXPAND_MODE_LINEAR
,
59 MSP_PHASE2_START_MODE_FSYNC
,
60 MSP_PHASE2_START_MODE_FSYNC
,
79 MSP_COMPRESS_MODE_LINEAR
,
80 MSP_EXPAND_MODE_LINEAR
,
85 }, { /* Companded PCM */
88 MSP_PHASE2_START_MODE_FSYNC
,
89 MSP_PHASE2_START_MODE_FSYNC
,
104 MSP_FSYNC_POL_ACT_HI
,
105 MSP_FSYNC_POL_ACT_HI
,
108 MSP_COMPRESS_MODE_LINEAR
,
109 MSP_EXPAND_MODE_LINEAR
,
117 static void set_prot_desc_tx(struct ux500_msp
*msp
,
118 struct msp_protdesc
*protdesc
,
119 enum msp_data_size data_size
)
123 temp_reg
|= MSP_P2_ENABLE_BIT(protdesc
->tx_phase_mode
);
124 temp_reg
|= MSP_P2_START_MODE_BIT(protdesc
->tx_phase2_start_mode
);
125 temp_reg
|= MSP_P1_FRAME_LEN_BITS(protdesc
->tx_frame_len_1
);
126 temp_reg
|= MSP_P2_FRAME_LEN_BITS(protdesc
->tx_frame_len_2
);
127 if (msp
->def_elem_len
) {
128 temp_reg
|= MSP_P1_ELEM_LEN_BITS(protdesc
->tx_elem_len_1
);
129 temp_reg
|= MSP_P2_ELEM_LEN_BITS(protdesc
->tx_elem_len_2
);
131 temp_reg
|= MSP_P1_ELEM_LEN_BITS(data_size
);
132 temp_reg
|= MSP_P2_ELEM_LEN_BITS(data_size
);
134 temp_reg
|= MSP_DATA_DELAY_BITS(protdesc
->tx_data_delay
);
135 temp_reg
|= MSP_SET_ENDIANNES_BIT(protdesc
->tx_byte_order
);
136 temp_reg
|= MSP_FSYNC_POL(protdesc
->tx_fsync_pol
);
137 temp_reg
|= MSP_DATA_WORD_SWAP(protdesc
->tx_half_word_swap
);
138 temp_reg
|= MSP_SET_COMPANDING_MODE(protdesc
->compression_mode
);
139 temp_reg
|= MSP_SET_FSYNC_IGNORE(protdesc
->frame_sync_ignore
);
141 writel(temp_reg
, msp
->registers
+ MSP_TCF
);
144 static void set_prot_desc_rx(struct ux500_msp
*msp
,
145 struct msp_protdesc
*protdesc
,
146 enum msp_data_size data_size
)
150 temp_reg
|= MSP_P2_ENABLE_BIT(protdesc
->rx_phase_mode
);
151 temp_reg
|= MSP_P2_START_MODE_BIT(protdesc
->rx_phase2_start_mode
);
152 temp_reg
|= MSP_P1_FRAME_LEN_BITS(protdesc
->rx_frame_len_1
);
153 temp_reg
|= MSP_P2_FRAME_LEN_BITS(protdesc
->rx_frame_len_2
);
154 if (msp
->def_elem_len
) {
155 temp_reg
|= MSP_P1_ELEM_LEN_BITS(protdesc
->rx_elem_len_1
);
156 temp_reg
|= MSP_P2_ELEM_LEN_BITS(protdesc
->rx_elem_len_2
);
158 temp_reg
|= MSP_P1_ELEM_LEN_BITS(data_size
);
159 temp_reg
|= MSP_P2_ELEM_LEN_BITS(data_size
);
162 temp_reg
|= MSP_DATA_DELAY_BITS(protdesc
->rx_data_delay
);
163 temp_reg
|= MSP_SET_ENDIANNES_BIT(protdesc
->rx_byte_order
);
164 temp_reg
|= MSP_FSYNC_POL(protdesc
->rx_fsync_pol
);
165 temp_reg
|= MSP_DATA_WORD_SWAP(protdesc
->rx_half_word_swap
);
166 temp_reg
|= MSP_SET_COMPANDING_MODE(protdesc
->expansion_mode
);
167 temp_reg
|= MSP_SET_FSYNC_IGNORE(protdesc
->frame_sync_ignore
);
169 writel(temp_reg
, msp
->registers
+ MSP_RCF
);
172 static int configure_protocol(struct ux500_msp
*msp
,
173 struct ux500_msp_config
*config
)
175 struct msp_protdesc
*protdesc
;
176 enum msp_data_size data_size
;
179 data_size
= config
->data_size
;
180 msp
->def_elem_len
= config
->def_elem_len
;
181 if (config
->default_protdesc
== 1) {
182 if (config
->protocol
>= MSP_INVALID_PROTOCOL
) {
183 dev_err(msp
->dev
, "%s: ERROR: Invalid protocol!\n",
188 (struct msp_protdesc
*)&prot_descs
[config
->protocol
];
190 protdesc
= (struct msp_protdesc
*)&config
->protdesc
;
193 if (data_size
< MSP_DATA_BITS_DEFAULT
|| data_size
> MSP_DATA_BITS_32
) {
195 "%s: ERROR: Invalid data-size requested (data_size = %d)!\n",
196 __func__
, data_size
);
200 if (config
->direction
& MSP_DIR_TX
)
201 set_prot_desc_tx(msp
, protdesc
, data_size
);
202 if (config
->direction
& MSP_DIR_RX
)
203 set_prot_desc_rx(msp
, protdesc
, data_size
);
205 /* The code below should not be separated. */
206 temp_reg
= readl(msp
->registers
+ MSP_GCR
) & ~TX_CLK_POL_RISING
;
207 temp_reg
|= MSP_TX_CLKPOL_BIT(~protdesc
->tx_clk_pol
);
208 writel(temp_reg
, msp
->registers
+ MSP_GCR
);
209 temp_reg
= readl(msp
->registers
+ MSP_GCR
) & ~RX_CLK_POL_RISING
;
210 temp_reg
|= MSP_RX_CLKPOL_BIT(protdesc
->rx_clk_pol
);
211 writel(temp_reg
, msp
->registers
+ MSP_GCR
);
216 static int setup_bitclk(struct ux500_msp
*msp
, struct ux500_msp_config
*config
)
223 struct msp_protdesc
*protdesc
= NULL
;
225 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
226 writel(reg_val_GCR
& ~SRG_ENABLE
, msp
->registers
+ MSP_GCR
);
228 if (config
->default_protdesc
)
230 (struct msp_protdesc
*)&prot_descs
[config
->protocol
];
232 protdesc
= (struct msp_protdesc
*)&config
->protdesc
;
234 switch (config
->protocol
) {
235 case MSP_PCM_PROTOCOL
:
236 case MSP_PCM_COMPAND_PROTOCOL
:
237 frame_width
= protdesc
->frame_width
;
238 sck_div
= config
->f_inputclk
/ (config
->frame_freq
*
239 (protdesc
->clocks_per_frame
));
240 frame_per
= protdesc
->frame_period
;
242 case MSP_I2S_PROTOCOL
:
243 frame_width
= protdesc
->frame_width
;
244 sck_div
= config
->f_inputclk
/ (config
->frame_freq
*
245 (protdesc
->clocks_per_frame
));
246 frame_per
= protdesc
->frame_period
;
249 dev_err(msp
->dev
, "%s: ERROR: Unknown protocol (%d)!\n",
255 temp_reg
= (sck_div
- 1) & SCK_DIV_MASK
;
256 temp_reg
|= FRAME_WIDTH_BITS(frame_width
);
257 temp_reg
|= FRAME_PERIOD_BITS(frame_per
);
258 writel(temp_reg
, msp
->registers
+ MSP_SRG
);
260 msp
->f_bitclk
= (config
->f_inputclk
)/(sck_div
+ 1);
262 /* Enable bit-clock */
264 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
265 writel(reg_val_GCR
| SRG_ENABLE
, msp
->registers
+ MSP_GCR
);
271 static int configure_multichannel(struct ux500_msp
*msp
,
272 struct ux500_msp_config
*config
)
274 struct msp_protdesc
*protdesc
;
275 struct msp_multichannel_config
*mcfg
;
278 if (config
->default_protdesc
== 1) {
279 if (config
->protocol
>= MSP_INVALID_PROTOCOL
) {
281 "%s: ERROR: Invalid protocol (%d)!\n",
282 __func__
, config
->protocol
);
285 protdesc
= (struct msp_protdesc
*)
286 &prot_descs
[config
->protocol
];
288 protdesc
= (struct msp_protdesc
*)&config
->protdesc
;
291 mcfg
= &config
->multichannel_config
;
292 if (mcfg
->tx_multichannel_enable
) {
293 if (protdesc
->tx_phase_mode
== MSP_SINGLE_PHASE
) {
294 reg_val_MCR
= readl(msp
->registers
+ MSP_MCR
);
295 writel(reg_val_MCR
| (mcfg
->tx_multichannel_enable
?
297 msp
->registers
+ MSP_MCR
);
298 writel(mcfg
->tx_channel_0_enable
,
299 msp
->registers
+ MSP_TCE0
);
300 writel(mcfg
->tx_channel_1_enable
,
301 msp
->registers
+ MSP_TCE1
);
302 writel(mcfg
->tx_channel_2_enable
,
303 msp
->registers
+ MSP_TCE2
);
304 writel(mcfg
->tx_channel_3_enable
,
305 msp
->registers
+ MSP_TCE3
);
308 "%s: ERROR: Only single-phase supported (TX-mode: %d)!\n",
309 __func__
, protdesc
->tx_phase_mode
);
313 if (mcfg
->rx_multichannel_enable
) {
314 if (protdesc
->rx_phase_mode
== MSP_SINGLE_PHASE
) {
315 reg_val_MCR
= readl(msp
->registers
+ MSP_MCR
);
316 writel(reg_val_MCR
| (mcfg
->rx_multichannel_enable
?
318 msp
->registers
+ MSP_MCR
);
319 writel(mcfg
->rx_channel_0_enable
,
320 msp
->registers
+ MSP_RCE0
);
321 writel(mcfg
->rx_channel_1_enable
,
322 msp
->registers
+ MSP_RCE1
);
323 writel(mcfg
->rx_channel_2_enable
,
324 msp
->registers
+ MSP_RCE2
);
325 writel(mcfg
->rx_channel_3_enable
,
326 msp
->registers
+ MSP_RCE3
);
329 "%s: ERROR: Only single-phase supported (RX-mode: %d)!\n",
330 __func__
, protdesc
->rx_phase_mode
);
333 if (mcfg
->rx_comparison_enable_mode
) {
334 reg_val_MCR
= readl(msp
->registers
+ MSP_MCR
);
336 (mcfg
->rx_comparison_enable_mode
<< RCMPM_BIT
),
337 msp
->registers
+ MSP_MCR
);
339 writel(mcfg
->comparison_mask
,
340 msp
->registers
+ MSP_RCM
);
341 writel(mcfg
->comparison_value
,
342 msp
->registers
+ MSP_RCV
);
350 static int enable_msp(struct ux500_msp
*msp
, struct ux500_msp_config
*config
)
353 u32 reg_val_DMACR
, reg_val_GCR
;
355 /* Configure msp with protocol dependent settings */
356 configure_protocol(msp
, config
);
357 setup_bitclk(msp
, config
);
358 if (config
->multichannel_configured
== 1) {
359 status
= configure_multichannel(msp
, config
);
362 "%s: WARN: configure_multichannel failed (%d)!\n",
366 /* Make sure the correct DMA-directions are configured */
367 if ((config
->direction
& MSP_DIR_RX
) &&
368 !msp
->capture_dma_data
.dma_cfg
) {
369 dev_err(msp
->dev
, "%s: ERROR: MSP RX-mode is not configured!",
373 if ((config
->direction
== MSP_DIR_TX
) &&
374 !msp
->playback_dma_data
.dma_cfg
) {
375 dev_err(msp
->dev
, "%s: ERROR: MSP TX-mode is not configured!",
380 reg_val_DMACR
= readl(msp
->registers
+ MSP_DMACR
);
381 if (config
->direction
& MSP_DIR_RX
)
382 reg_val_DMACR
|= RX_DMA_ENABLE
;
383 if (config
->direction
& MSP_DIR_TX
)
384 reg_val_DMACR
|= TX_DMA_ENABLE
;
385 writel(reg_val_DMACR
, msp
->registers
+ MSP_DMACR
);
387 writel(config
->iodelay
, msp
->registers
+ MSP_IODLY
);
389 /* Enable frame generation logic */
390 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
391 writel(reg_val_GCR
| FRAME_GEN_ENABLE
, msp
->registers
+ MSP_GCR
);
396 static void flush_fifo_rx(struct ux500_msp
*msp
)
398 u32 reg_val_GCR
, reg_val_FLR
;
401 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
402 writel(reg_val_GCR
| RX_ENABLE
, msp
->registers
+ MSP_GCR
);
404 reg_val_FLR
= readl(msp
->registers
+ MSP_FLR
);
405 while (!(reg_val_FLR
& RX_FIFO_EMPTY
) && limit
--) {
406 readl(msp
->registers
+ MSP_DR
);
407 reg_val_FLR
= readl(msp
->registers
+ MSP_FLR
);
410 writel(reg_val_GCR
, msp
->registers
+ MSP_GCR
);
413 static void flush_fifo_tx(struct ux500_msp
*msp
)
415 u32 reg_val_GCR
, reg_val_FLR
;
418 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
419 writel(reg_val_GCR
| TX_ENABLE
, msp
->registers
+ MSP_GCR
);
420 writel(MSP_ITCR_ITEN
| MSP_ITCR_TESTFIFO
, msp
->registers
+ MSP_ITCR
);
422 reg_val_FLR
= readl(msp
->registers
+ MSP_FLR
);
423 while (!(reg_val_FLR
& TX_FIFO_EMPTY
) && limit
--) {
424 readl(msp
->registers
+ MSP_TSTDR
);
425 reg_val_FLR
= readl(msp
->registers
+ MSP_FLR
);
427 writel(0x0, msp
->registers
+ MSP_ITCR
);
428 writel(reg_val_GCR
, msp
->registers
+ MSP_GCR
);
431 int ux500_msp_i2s_open(struct ux500_msp
*msp
,
432 struct ux500_msp_config
*config
)
434 u32 old_reg
, new_reg
, mask
;
436 unsigned int tx_sel
, rx_sel
, tx_busy
, rx_busy
;
438 if (in_interrupt()) {
440 "%s: ERROR: Open called in interrupt context!\n",
445 tx_sel
= (config
->direction
& MSP_DIR_TX
) > 0;
446 rx_sel
= (config
->direction
& MSP_DIR_RX
) > 0;
447 if (!tx_sel
&& !rx_sel
) {
448 dev_err(msp
->dev
, "%s: Error: No direction selected!\n",
453 tx_busy
= (msp
->dir_busy
& MSP_DIR_TX
) > 0;
454 rx_busy
= (msp
->dir_busy
& MSP_DIR_RX
) > 0;
455 if (tx_busy
&& tx_sel
) {
456 dev_err(msp
->dev
, "%s: Error: TX is in use!\n", __func__
);
459 if (rx_busy
&& rx_sel
) {
460 dev_err(msp
->dev
, "%s: Error: RX is in use!\n", __func__
);
464 msp
->dir_busy
|= (tx_sel
? MSP_DIR_TX
: 0) | (rx_sel
? MSP_DIR_RX
: 0);
466 /* First do the global config register */
467 mask
= RX_CLK_SEL_MASK
| TX_CLK_SEL_MASK
| RX_FSYNC_MASK
|
468 TX_FSYNC_MASK
| RX_SYNC_SEL_MASK
| TX_SYNC_SEL_MASK
|
469 RX_FIFO_ENABLE_MASK
| TX_FIFO_ENABLE_MASK
| SRG_CLK_SEL_MASK
|
470 LOOPBACK_MASK
| TX_EXTRA_DELAY_MASK
;
472 new_reg
= (config
->tx_clk_sel
| config
->rx_clk_sel
|
473 config
->rx_fsync_pol
| config
->tx_fsync_pol
|
474 config
->rx_fsync_sel
| config
->tx_fsync_sel
|
475 config
->rx_fifo_config
| config
->tx_fifo_config
|
476 config
->srg_clk_sel
| config
->loopback_enable
|
477 config
->tx_data_enable
);
479 old_reg
= readl(msp
->registers
+ MSP_GCR
);
482 writel(new_reg
, msp
->registers
+ MSP_GCR
);
484 res
= enable_msp(msp
, config
);
486 dev_err(msp
->dev
, "%s: ERROR: enable_msp failed (%d)!\n",
490 if (config
->loopback_enable
& 0x80)
491 msp
->loopback_enable
= 1;
497 msp
->msp_state
= MSP_STATE_CONFIGURED
;
501 static void disable_msp_rx(struct ux500_msp
*msp
)
503 u32 reg_val_GCR
, reg_val_DMACR
, reg_val_IMSC
;
505 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
506 writel(reg_val_GCR
& ~RX_ENABLE
, msp
->registers
+ MSP_GCR
);
507 reg_val_DMACR
= readl(msp
->registers
+ MSP_DMACR
);
508 writel(reg_val_DMACR
& ~RX_DMA_ENABLE
, msp
->registers
+ MSP_DMACR
);
509 reg_val_IMSC
= readl(msp
->registers
+ MSP_IMSC
);
510 writel(reg_val_IMSC
&
511 ~(RX_SERVICE_INT
| RX_OVERRUN_ERROR_INT
),
512 msp
->registers
+ MSP_IMSC
);
514 msp
->dir_busy
&= ~MSP_DIR_RX
;
517 static void disable_msp_tx(struct ux500_msp
*msp
)
519 u32 reg_val_GCR
, reg_val_DMACR
, reg_val_IMSC
;
521 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
522 writel(reg_val_GCR
& ~TX_ENABLE
, msp
->registers
+ MSP_GCR
);
523 reg_val_DMACR
= readl(msp
->registers
+ MSP_DMACR
);
524 writel(reg_val_DMACR
& ~TX_DMA_ENABLE
, msp
->registers
+ MSP_DMACR
);
525 reg_val_IMSC
= readl(msp
->registers
+ MSP_IMSC
);
526 writel(reg_val_IMSC
&
527 ~(TX_SERVICE_INT
| TX_UNDERRUN_ERR_INT
),
528 msp
->registers
+ MSP_IMSC
);
530 msp
->dir_busy
&= ~MSP_DIR_TX
;
533 static int disable_msp(struct ux500_msp
*msp
, unsigned int dir
)
536 unsigned int disable_tx
, disable_rx
;
538 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
539 disable_tx
= dir
& MSP_DIR_TX
;
540 disable_rx
= dir
& MSP_DIR_TX
;
541 if (disable_tx
&& disable_rx
) {
542 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
543 writel(reg_val_GCR
| LOOPBACK_MASK
,
544 msp
->registers
+ MSP_GCR
);
549 /* Disable TX-channel */
550 writel((readl(msp
->registers
+ MSP_GCR
) &
551 (~TX_ENABLE
)), msp
->registers
+ MSP_GCR
);
556 /* Disable Loopback and Receive channel */
557 writel((readl(msp
->registers
+ MSP_GCR
) &
558 (~(RX_ENABLE
| LOOPBACK_MASK
))),
559 msp
->registers
+ MSP_GCR
);
563 } else if (disable_tx
)
571 int ux500_msp_i2s_trigger(struct ux500_msp
*msp
, int cmd
, int direction
)
573 u32 reg_val_GCR
, enable_bit
;
575 if (msp
->msp_state
== MSP_STATE_IDLE
) {
576 dev_err(msp
->dev
, "%s: ERROR: MSP is not configured!\n",
582 case SNDRV_PCM_TRIGGER_START
:
583 case SNDRV_PCM_TRIGGER_RESUME
:
584 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
585 if (direction
== SNDRV_PCM_STREAM_PLAYBACK
)
586 enable_bit
= TX_ENABLE
;
588 enable_bit
= RX_ENABLE
;
589 reg_val_GCR
= readl(msp
->registers
+ MSP_GCR
);
590 writel(reg_val_GCR
| enable_bit
, msp
->registers
+ MSP_GCR
);
593 case SNDRV_PCM_TRIGGER_STOP
:
594 case SNDRV_PCM_TRIGGER_SUSPEND
:
595 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
596 if (direction
== SNDRV_PCM_STREAM_PLAYBACK
)
608 int ux500_msp_i2s_close(struct ux500_msp
*msp
, unsigned int dir
)
612 dev_dbg(msp
->dev
, "%s: Enter (dir = 0x%01x).\n", __func__
, dir
);
614 status
= disable_msp(msp
, dir
);
615 if (msp
->dir_busy
== 0) {
616 /* disable sample rate and frame generators */
617 msp
->msp_state
= MSP_STATE_IDLE
;
618 writel((readl(msp
->registers
+ MSP_GCR
) &
619 (~(FRAME_GEN_ENABLE
| SRG_ENABLE
))),
620 msp
->registers
+ MSP_GCR
);
622 writel(0, msp
->registers
+ MSP_GCR
);
623 writel(0, msp
->registers
+ MSP_TCF
);
624 writel(0, msp
->registers
+ MSP_RCF
);
625 writel(0, msp
->registers
+ MSP_DMACR
);
626 writel(0, msp
->registers
+ MSP_SRG
);
627 writel(0, msp
->registers
+ MSP_MCR
);
628 writel(0, msp
->registers
+ MSP_RCM
);
629 writel(0, msp
->registers
+ MSP_RCV
);
630 writel(0, msp
->registers
+ MSP_TCE0
);
631 writel(0, msp
->registers
+ MSP_TCE1
);
632 writel(0, msp
->registers
+ MSP_TCE2
);
633 writel(0, msp
->registers
+ MSP_TCE3
);
634 writel(0, msp
->registers
+ MSP_RCE0
);
635 writel(0, msp
->registers
+ MSP_RCE1
);
636 writel(0, msp
->registers
+ MSP_RCE2
);
637 writel(0, msp
->registers
+ MSP_RCE3
);
644 static int ux500_msp_i2s_of_init_msp(struct platform_device
*pdev
,
645 struct ux500_msp
*msp
,
646 struct msp_i2s_platform_data
**platform_data
)
648 struct msp_i2s_platform_data
*pdata
;
650 *platform_data
= devm_kzalloc(&pdev
->dev
,
651 sizeof(struct msp_i2s_platform_data
),
653 pdata
= *platform_data
;
657 msp
->playback_dma_data
.dma_cfg
= devm_kzalloc(&pdev
->dev
,
658 sizeof(struct stedma40_chan_cfg
),
660 if (!msp
->playback_dma_data
.dma_cfg
)
663 msp
->capture_dma_data
.dma_cfg
= devm_kzalloc(&pdev
->dev
,
664 sizeof(struct stedma40_chan_cfg
),
666 if (!msp
->capture_dma_data
.dma_cfg
)
672 int ux500_msp_i2s_init_msp(struct platform_device
*pdev
,
673 struct ux500_msp
**msp_p
,
674 struct msp_i2s_platform_data
*platform_data
)
676 struct resource
*res
= NULL
;
677 struct device_node
*np
= pdev
->dev
.of_node
;
678 struct ux500_msp
*msp
;
681 *msp_p
= devm_kzalloc(&pdev
->dev
, sizeof(struct ux500_msp
), GFP_KERNEL
);
686 if (!platform_data
) {
688 ret
= ux500_msp_i2s_of_init_msp(pdev
, msp
,
695 msp
->playback_dma_data
.dma_cfg
= platform_data
->msp_i2s_dma_tx
;
696 msp
->capture_dma_data
.dma_cfg
= platform_data
->msp_i2s_dma_rx
;
697 msp
->id
= platform_data
->id
;
700 msp
->dev
= &pdev
->dev
;
702 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
704 dev_err(&pdev
->dev
, "%s: ERROR: Unable to get resource!\n",
709 msp
->playback_dma_data
.tx_rx_addr
= res
->start
+ MSP_DR
;
710 msp
->capture_dma_data
.tx_rx_addr
= res
->start
+ MSP_DR
;
712 msp
->registers
= devm_ioremap(&pdev
->dev
, res
->start
,
714 if (msp
->registers
== NULL
) {
715 dev_err(&pdev
->dev
, "%s: ERROR: ioremap failed!\n", __func__
);
719 msp
->msp_state
= MSP_STATE_IDLE
;
720 msp
->loopback_enable
= 0;
725 void ux500_msp_i2s_cleanup_msp(struct platform_device
*pdev
,
726 struct ux500_msp
*msp
)
728 dev_dbg(msp
->dev
, "%s: Enter (id = %d).\n", __func__
, msp
->id
);
731 MODULE_LICENSE("GPL v2");