Lines Matching refs:msp

114 static void set_prot_desc_tx(struct ux500_msp *msp,  in set_prot_desc_tx()  argument
124 if (msp->def_elem_len) { in set_prot_desc_tx()
138 writel(temp_reg, msp->registers + MSP_TCF); in set_prot_desc_tx()
141 static void set_prot_desc_rx(struct ux500_msp *msp, in set_prot_desc_rx() argument
151 if (msp->def_elem_len) { in set_prot_desc_rx()
166 writel(temp_reg, msp->registers + MSP_RCF); in set_prot_desc_rx()
169 static int configure_protocol(struct ux500_msp *msp, in configure_protocol() argument
177 msp->def_elem_len = config->def_elem_len; in configure_protocol()
180 dev_err(msp->dev, "%s: ERROR: Invalid protocol!\n", in configure_protocol()
191 dev_err(msp->dev, in configure_protocol()
198 set_prot_desc_tx(msp, protdesc, data_size); in configure_protocol()
200 set_prot_desc_rx(msp, protdesc, data_size); in configure_protocol()
203 temp_reg = readl(msp->registers + MSP_GCR) & ~TX_CLK_POL_RISING; in configure_protocol()
205 writel(temp_reg, msp->registers + MSP_GCR); in configure_protocol()
206 temp_reg = readl(msp->registers + MSP_GCR) & ~RX_CLK_POL_RISING; in configure_protocol()
208 writel(temp_reg, msp->registers + MSP_GCR); in configure_protocol()
213 static int setup_bitclk(struct ux500_msp *msp, struct ux500_msp_config *config) in setup_bitclk() argument
222 reg_val_GCR = readl(msp->registers + MSP_GCR); in setup_bitclk()
223 writel(reg_val_GCR & ~SRG_ENABLE, msp->registers + MSP_GCR); in setup_bitclk()
246 dev_err(msp->dev, "%s: ERROR: Unknown protocol (%d)!\n", in setup_bitclk()
255 writel(temp_reg, msp->registers + MSP_SRG); in setup_bitclk()
257 msp->f_bitclk = (config->f_inputclk)/(sck_div + 1); in setup_bitclk()
261 reg_val_GCR = readl(msp->registers + MSP_GCR); in setup_bitclk()
262 writel(reg_val_GCR | SRG_ENABLE, msp->registers + MSP_GCR); in setup_bitclk()
268 static int configure_multichannel(struct ux500_msp *msp, in configure_multichannel() argument
277 dev_err(msp->dev, in configure_multichannel()
291 reg_val_MCR = readl(msp->registers + MSP_MCR); in configure_multichannel()
294 msp->registers + MSP_MCR); in configure_multichannel()
296 msp->registers + MSP_TCE0); in configure_multichannel()
298 msp->registers + MSP_TCE1); in configure_multichannel()
300 msp->registers + MSP_TCE2); in configure_multichannel()
302 msp->registers + MSP_TCE3); in configure_multichannel()
304 dev_err(msp->dev, in configure_multichannel()
312 reg_val_MCR = readl(msp->registers + MSP_MCR); in configure_multichannel()
315 msp->registers + MSP_MCR); in configure_multichannel()
317 msp->registers + MSP_RCE0); in configure_multichannel()
319 msp->registers + MSP_RCE1); in configure_multichannel()
321 msp->registers + MSP_RCE2); in configure_multichannel()
323 msp->registers + MSP_RCE3); in configure_multichannel()
325 dev_err(msp->dev, in configure_multichannel()
331 reg_val_MCR = readl(msp->registers + MSP_MCR); in configure_multichannel()
334 msp->registers + MSP_MCR); in configure_multichannel()
337 msp->registers + MSP_RCM); in configure_multichannel()
339 msp->registers + MSP_RCV); in configure_multichannel()
347 static int enable_msp(struct ux500_msp *msp, struct ux500_msp_config *config) in enable_msp() argument
353 configure_protocol(msp, config); in enable_msp()
354 setup_bitclk(msp, config); in enable_msp()
356 status = configure_multichannel(msp, config); in enable_msp()
358 dev_warn(msp->dev, in enable_msp()
363 reg_val_DMACR = readl(msp->registers + MSP_DMACR); in enable_msp()
368 writel(reg_val_DMACR, msp->registers + MSP_DMACR); in enable_msp()
370 writel(config->iodelay, msp->registers + MSP_IODLY); in enable_msp()
373 reg_val_GCR = readl(msp->registers + MSP_GCR); in enable_msp()
374 writel(reg_val_GCR | FRAME_GEN_ENABLE, msp->registers + MSP_GCR); in enable_msp()
379 static void flush_fifo_rx(struct ux500_msp *msp) in flush_fifo_rx() argument
384 reg_val_GCR = readl(msp->registers + MSP_GCR); in flush_fifo_rx()
385 writel(reg_val_GCR | RX_ENABLE, msp->registers + MSP_GCR); in flush_fifo_rx()
387 reg_val_FLR = readl(msp->registers + MSP_FLR); in flush_fifo_rx()
389 readl(msp->registers + MSP_DR); in flush_fifo_rx()
390 reg_val_FLR = readl(msp->registers + MSP_FLR); in flush_fifo_rx()
393 writel(reg_val_GCR, msp->registers + MSP_GCR); in flush_fifo_rx()
396 static void flush_fifo_tx(struct ux500_msp *msp) in flush_fifo_tx() argument
401 reg_val_GCR = readl(msp->registers + MSP_GCR); in flush_fifo_tx()
402 writel(reg_val_GCR | TX_ENABLE, msp->registers + MSP_GCR); in flush_fifo_tx()
403 writel(MSP_ITCR_ITEN | MSP_ITCR_TESTFIFO, msp->registers + MSP_ITCR); in flush_fifo_tx()
405 reg_val_FLR = readl(msp->registers + MSP_FLR); in flush_fifo_tx()
407 readl(msp->registers + MSP_TSTDR); in flush_fifo_tx()
408 reg_val_FLR = readl(msp->registers + MSP_FLR); in flush_fifo_tx()
410 writel(0x0, msp->registers + MSP_ITCR); in flush_fifo_tx()
411 writel(reg_val_GCR, msp->registers + MSP_GCR); in flush_fifo_tx()
414 int ux500_msp_i2s_open(struct ux500_msp *msp, in ux500_msp_i2s_open() argument
422 dev_err(msp->dev, in ux500_msp_i2s_open()
431 dev_err(msp->dev, "%s: Error: No direction selected!\n", in ux500_msp_i2s_open()
436 tx_busy = (msp->dir_busy & MSP_DIR_TX) > 0; in ux500_msp_i2s_open()
437 rx_busy = (msp->dir_busy & MSP_DIR_RX) > 0; in ux500_msp_i2s_open()
439 dev_err(msp->dev, "%s: Error: TX is in use!\n", __func__); in ux500_msp_i2s_open()
443 dev_err(msp->dev, "%s: Error: RX is in use!\n", __func__); in ux500_msp_i2s_open()
447 msp->dir_busy |= (tx_sel ? MSP_DIR_TX : 0) | (rx_sel ? MSP_DIR_RX : 0); in ux500_msp_i2s_open()
462 old_reg = readl(msp->registers + MSP_GCR); in ux500_msp_i2s_open()
465 writel(new_reg, msp->registers + MSP_GCR); in ux500_msp_i2s_open()
467 res = enable_msp(msp, config); in ux500_msp_i2s_open()
469 dev_err(msp->dev, "%s: ERROR: enable_msp failed (%d)!\n", in ux500_msp_i2s_open()
474 msp->loopback_enable = 1; in ux500_msp_i2s_open()
477 flush_fifo_tx(msp); in ux500_msp_i2s_open()
478 flush_fifo_rx(msp); in ux500_msp_i2s_open()
480 msp->msp_state = MSP_STATE_CONFIGURED; in ux500_msp_i2s_open()
484 static void disable_msp_rx(struct ux500_msp *msp) in disable_msp_rx() argument
488 reg_val_GCR = readl(msp->registers + MSP_GCR); in disable_msp_rx()
489 writel(reg_val_GCR & ~RX_ENABLE, msp->registers + MSP_GCR); in disable_msp_rx()
490 reg_val_DMACR = readl(msp->registers + MSP_DMACR); in disable_msp_rx()
491 writel(reg_val_DMACR & ~RX_DMA_ENABLE, msp->registers + MSP_DMACR); in disable_msp_rx()
492 reg_val_IMSC = readl(msp->registers + MSP_IMSC); in disable_msp_rx()
495 msp->registers + MSP_IMSC); in disable_msp_rx()
497 msp->dir_busy &= ~MSP_DIR_RX; in disable_msp_rx()
500 static void disable_msp_tx(struct ux500_msp *msp) in disable_msp_tx() argument
504 reg_val_GCR = readl(msp->registers + MSP_GCR); in disable_msp_tx()
505 writel(reg_val_GCR & ~TX_ENABLE, msp->registers + MSP_GCR); in disable_msp_tx()
506 reg_val_DMACR = readl(msp->registers + MSP_DMACR); in disable_msp_tx()
507 writel(reg_val_DMACR & ~TX_DMA_ENABLE, msp->registers + MSP_DMACR); in disable_msp_tx()
508 reg_val_IMSC = readl(msp->registers + MSP_IMSC); in disable_msp_tx()
511 msp->registers + MSP_IMSC); in disable_msp_tx()
513 msp->dir_busy &= ~MSP_DIR_TX; in disable_msp_tx()
516 static int disable_msp(struct ux500_msp *msp, unsigned int dir) in disable_msp() argument
521 reg_val_GCR = readl(msp->registers + MSP_GCR); in disable_msp()
525 reg_val_GCR = readl(msp->registers + MSP_GCR); in disable_msp()
527 msp->registers + MSP_GCR); in disable_msp()
530 flush_fifo_tx(msp); in disable_msp()
533 writel((readl(msp->registers + MSP_GCR) & in disable_msp()
534 (~TX_ENABLE)), msp->registers + MSP_GCR); in disable_msp()
537 flush_fifo_rx(msp); in disable_msp()
540 writel((readl(msp->registers + MSP_GCR) & in disable_msp()
542 msp->registers + MSP_GCR); in disable_msp()
544 disable_msp_tx(msp); in disable_msp()
545 disable_msp_rx(msp); in disable_msp()
547 disable_msp_tx(msp); in disable_msp()
549 disable_msp_rx(msp); in disable_msp()
554 int ux500_msp_i2s_trigger(struct ux500_msp *msp, int cmd, int direction) in ux500_msp_i2s_trigger() argument
558 if (msp->msp_state == MSP_STATE_IDLE) { in ux500_msp_i2s_trigger()
559 dev_err(msp->dev, "%s: ERROR: MSP is not configured!\n", in ux500_msp_i2s_trigger()
572 reg_val_GCR = readl(msp->registers + MSP_GCR); in ux500_msp_i2s_trigger()
573 writel(reg_val_GCR | enable_bit, msp->registers + MSP_GCR); in ux500_msp_i2s_trigger()
580 disable_msp_tx(msp); in ux500_msp_i2s_trigger()
582 disable_msp_rx(msp); in ux500_msp_i2s_trigger()
591 int ux500_msp_i2s_close(struct ux500_msp *msp, unsigned int dir) in ux500_msp_i2s_close() argument
595 dev_dbg(msp->dev, "%s: Enter (dir = 0x%01x).\n", __func__, dir); in ux500_msp_i2s_close()
597 status = disable_msp(msp, dir); in ux500_msp_i2s_close()
598 if (msp->dir_busy == 0) { in ux500_msp_i2s_close()
600 msp->msp_state = MSP_STATE_IDLE; in ux500_msp_i2s_close()
601 writel((readl(msp->registers + MSP_GCR) & in ux500_msp_i2s_close()
603 msp->registers + MSP_GCR); in ux500_msp_i2s_close()
605 writel(0, msp->registers + MSP_GCR); in ux500_msp_i2s_close()
606 writel(0, msp->registers + MSP_TCF); in ux500_msp_i2s_close()
607 writel(0, msp->registers + MSP_RCF); in ux500_msp_i2s_close()
608 writel(0, msp->registers + MSP_DMACR); in ux500_msp_i2s_close()
609 writel(0, msp->registers + MSP_SRG); in ux500_msp_i2s_close()
610 writel(0, msp->registers + MSP_MCR); in ux500_msp_i2s_close()
611 writel(0, msp->registers + MSP_RCM); in ux500_msp_i2s_close()
612 writel(0, msp->registers + MSP_RCV); in ux500_msp_i2s_close()
613 writel(0, msp->registers + MSP_TCE0); in ux500_msp_i2s_close()
614 writel(0, msp->registers + MSP_TCE1); in ux500_msp_i2s_close()
615 writel(0, msp->registers + MSP_TCE2); in ux500_msp_i2s_close()
616 writel(0, msp->registers + MSP_TCE3); in ux500_msp_i2s_close()
617 writel(0, msp->registers + MSP_RCE0); in ux500_msp_i2s_close()
618 writel(0, msp->registers + MSP_RCE1); in ux500_msp_i2s_close()
619 writel(0, msp->registers + MSP_RCE2); in ux500_msp_i2s_close()
620 writel(0, msp->registers + MSP_RCE3); in ux500_msp_i2s_close()
631 struct ux500_msp *msp; in ux500_msp_i2s_init_msp() local
634 msp = *msp_p; in ux500_msp_i2s_init_msp()
635 if (!msp) in ux500_msp_i2s_init_msp()
638 msp->dev = &pdev->dev; in ux500_msp_i2s_init_msp()
647 msp->tx_rx_addr = res->start + MSP_DR; in ux500_msp_i2s_init_msp()
648 msp->registers = devm_ioremap(&pdev->dev, res->start, in ux500_msp_i2s_init_msp()
650 if (msp->registers == NULL) { in ux500_msp_i2s_init_msp()
655 msp->msp_state = MSP_STATE_IDLE; in ux500_msp_i2s_init_msp()
656 msp->loopback_enable = 0; in ux500_msp_i2s_init_msp()
662 struct ux500_msp *msp) in ux500_msp_i2s_cleanup_msp() argument
664 dev_dbg(msp->dev, "%s: Enter (id = %d).\n", __func__, msp->id); in ux500_msp_i2s_cleanup_msp()