16 #include <linux/module.h>
20 #include <linux/slab.h>
24 #include <mach/hardware.h>
126 static void set_prot_desc_tx(
struct ux500_msp *msp,
153 static void set_prot_desc_rx(
struct ux500_msp *msp,
181 static int configure_protocol(
struct ux500_msp *msp,
192 dev_err(msp->
dev,
"%s: ERROR: Invalid protocol!\n",
204 "%s: ERROR: Invalid data-size requested (data_size = %d)!\n",
205 __func__, data_size);
210 set_prot_desc_tx(msp, protdesc, data_size);
212 set_prot_desc_rx(msp, protdesc, data_size);
258 dev_err(msp->
dev,
"%s: ERROR: Unknown protocol (%d)!\n",
280 static int configure_multichannel(
struct ux500_msp *msp,
290 "%s: ERROR: Invalid protocol (%d)!\n",
317 "%s: ERROR: Only single-phase supported (TX-mode: %d)!\n",
338 "%s: ERROR: Only single-phase supported (RX-mode: %d)!\n",
362 u32 reg_val_DMACR, reg_val_GCR;
373 pr_err(
"could not set MSP defstate\n");
377 spin_unlock_irqrestore(&msp_rxtx_lock, flags);
381 configure_protocol(msp, config);
382 setup_bitclk(msp, config);
384 status = configure_multichannel(msp, config);
387 "%s: WARN: configure_multichannel failed (%d)!\n",
393 dev_err(msp->
dev,
"%s: ERROR: MSP RX-mode is not configured!",
398 dev_err(msp->
dev,
"%s: ERROR: MSP TX-mode is not configured!",
419 static void flush_fifo_rx(
struct ux500_msp *msp)
421 u32 reg_val_DR, reg_val_GCR, reg_val_FLR;
436 static void flush_fifo_tx(
struct ux500_msp *msp)
438 u32 reg_val_TSTDR, reg_val_GCR, reg_val_FLR;
463 "%s: ERROR: Open called in interrupt context!\n",
470 if (!tx_sel && !rx_sel) {
471 dev_err(msp->
dev,
"%s: Error: No direction selected!\n",
478 if (tx_busy && tx_sel) {
479 dev_err(msp->
dev,
"%s: Error: TX is in use!\n", __func__);
482 if (rx_busy && rx_sel) {
483 dev_err(msp->
dev,
"%s: Error: RX is in use!\n", __func__);
507 res = enable_msp(msp, config);
509 dev_err(msp->
dev,
"%s: ERROR: enable_msp failed (%d)!\n",
524 static void disable_msp_rx(
struct ux500_msp *msp)
526 u32 reg_val_GCR, reg_val_DMACR, reg_val_IMSC;
540 static void disable_msp_tx(
struct ux500_msp *msp)
542 u32 reg_val_GCR, reg_val_DMACR, reg_val_IMSC;
556 static int disable_msp(
struct ux500_msp *msp,
unsigned int dir)
560 unsigned int disable_tx, disable_rx;
565 if (disable_tx && disable_rx) {
587 }
else if (disable_tx)
597 u32 reg_val_GCR, enable_bit;
600 dev_err(msp->
dev,
"%s: ERROR: MSP is not configured!\n",
635 int status = 0,
retval = 0;
638 dev_dbg(msp->
dev,
"%s: Enter (dir = 0x%01x).\n", __func__, dir);
640 status = disable_msp(msp, dir);
656 pr_err(
"could not set MSP sleepstate\n");
658 spin_unlock_irqrestore(&msp_rxtx_lock, flags);
697 if (!platform_data) {
707 dev_dbg(&pdev->
dev,
"%s: Enter (name: %s, id: %d).\n", __func__,
708 pdev->
name, platform_data->
id);
710 msp->
id = platform_data->
id;
717 dev_err(&pdev->
dev,
"%s: ERROR: Unable to get resource!\n",
725 dev_err(&pdev->
dev,
"%s: ERROR: ioremap failed!\n", __func__);
736 "%s: ERROR: Failed to allocate I2S-controller!\n",
740 i2s_cont->
dev.parent = &pdev->
dev;
741 i2s_cont->
data = (
void *)msp;
750 dev_err(&pdev->
dev,
"could not get MSP pinctrl\n");
756 "could not get MSP defstate (%li)\n",
763 "could not get MSP idlestate (%li)\n",
773 dev_dbg(msp->
dev,
"%s: Enter (id = %d).\n", __func__, msp->
id);