aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/sh/fsi.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 2b3a50d48ce5..685bb7c4f039 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -80,11 +80,12 @@
80#define B_CLK 0x00000010 80#define B_CLK 0x00000010
81#define A_CLK 0x00000001 81#define A_CLK 0x00000001
82 82
83/* INT_ST */ 83/* IO SHIFT / MACRO */
84#define INT_B_IN (1 << 12) 84#define BI_SHIFT 12
85#define INT_B_OUT (1 << 8) 85#define BO_SHIFT 8
86#define INT_A_IN (1 << 4) 86#define AI_SHIFT 4
87#define INT_A_OUT (1 << 0) 87#define AO_SHIFT 0
88#define AB_IO(param, shift) (param << shift)
88 89
89/* SOFT_RST */ 90/* SOFT_RST */
90#define PBSR (1 << 12) /* Port B Software Reset */ 91#define PBSR (1 << 12) /* Port B Software Reset */
@@ -93,9 +94,7 @@
93#define FSISR (1 << 0) /* Software Reset */ 94#define FSISR (1 << 0) /* Software Reset */
94 95
95/* FIFO_SZ */ 96/* FIFO_SZ */
96#define OUT_SZ_MASK 0x7 97#define FIFO_SZ_MASK 0x7
97#define BO_SZ_SHIFT 8
98#define AO_SZ_SHIFT 0
99 98
100#define FSI_RATES SNDRV_PCM_RATE_8000_96000 99#define FSI_RATES SNDRV_PCM_RATE_8000_96000
101 100
@@ -310,17 +309,17 @@ static int fsi_is_master_mode(struct fsi_priv *fsi, int is_play)
310 return (mode & flags) != mode; 309 return (mode & flags) != mode;
311} 310}
312 311
313static u32 fsi_port_ab_io_bit(struct fsi_priv *fsi, int is_play) 312static u32 fsi_get_port_shift(struct fsi_priv *fsi, int is_play)
314{ 313{
315 int is_porta = fsi_is_port_a(fsi); 314 int is_porta = fsi_is_port_a(fsi);
316 u32 data; 315 u32 shift;
317 316
318 if (is_porta) 317 if (is_porta)
319 data = is_play ? (1 << 0) : (1 << 4); 318 shift = is_play ? AO_SHIFT : AI_SHIFT;
320 else 319 else
321 data = is_play ? (1 << 8) : (1 << 12); 320 shift = is_play ? BO_SHIFT : BI_SHIFT;
322 321
323 return data; 322 return shift;
324} 323}
325 324
326static void fsi_stream_push(struct fsi_priv *fsi, 325static void fsi_stream_push(struct fsi_priv *fsi,
@@ -435,7 +434,7 @@ static void fsi_dma_soft_pop32(struct fsi_priv *fsi, int num)
435 434
436static void fsi_irq_enable(struct fsi_priv *fsi, int is_play) 435static void fsi_irq_enable(struct fsi_priv *fsi, int is_play)
437{ 436{
438 u32 data = fsi_port_ab_io_bit(fsi, is_play); 437 u32 data = AB_IO(1, fsi_get_port_shift(fsi, is_play));
439 struct fsi_master *master = fsi_get_master(fsi); 438 struct fsi_master *master = fsi_get_master(fsi);
440 439
441 fsi_master_mask_set(master, master->core->imsk, data, data); 440 fsi_master_mask_set(master, master->core->imsk, data, data);
@@ -444,7 +443,7 @@ static void fsi_irq_enable(struct fsi_priv *fsi, int is_play)
444 443
445static void fsi_irq_disable(struct fsi_priv *fsi, int is_play) 444static void fsi_irq_disable(struct fsi_priv *fsi, int is_play)
446{ 445{
447 u32 data = fsi_port_ab_io_bit(fsi, is_play); 446 u32 data = AB_IO(1, fsi_get_port_shift(fsi, is_play));
448 struct fsi_master *master = fsi_get_master(fsi); 447 struct fsi_master *master = fsi_get_master(fsi);
449 448
450 fsi_master_mask_set(master, master->core->imsk, data, 0); 449 fsi_master_mask_set(master, master->core->imsk, data, 0);
@@ -466,8 +465,8 @@ static void fsi_irq_clear_status(struct fsi_priv *fsi)
466 u32 data = 0; 465 u32 data = 0;
467 struct fsi_master *master = fsi_get_master(fsi); 466 struct fsi_master *master = fsi_get_master(fsi);
468 467
469 data |= fsi_port_ab_io_bit(fsi, 0); 468 data |= AB_IO(1, fsi_get_port_shift(fsi, 0));
470 data |= fsi_port_ab_io_bit(fsi, 1); 469 data |= AB_IO(1, fsi_get_port_shift(fsi, 1));
471 470
472 /* clear interrupt factor */ 471 /* clear interrupt factor */
473 fsi_master_mask_set(master, master->core->int_st, data, 0); 472 fsi_master_mask_set(master, master->core->int_st, data, 0);
@@ -518,8 +517,8 @@ static void fsi_fifo_init(struct fsi_priv *fsi,
518 517
519 /* get on-chip RAM capacity */ 518 /* get on-chip RAM capacity */
520 shift = fsi_master_read(master, FIFO_SZ); 519 shift = fsi_master_read(master, FIFO_SZ);
521 shift >>= fsi_is_port_a(fsi) ? AO_SZ_SHIFT : BO_SZ_SHIFT; 520 shift >>= fsi_get_port_shift(fsi, is_play);
522 shift &= OUT_SZ_MASK; 521 shift &= FIFO_SZ_MASK;
523 fsi->fifo_max_num = 256 << shift; 522 fsi->fifo_max_num = 256 << shift;
524 dev_dbg(dai->dev, "fifo = %d words\n", fsi->fifo_max_num); 523 dev_dbg(dai->dev, "fifo = %d words\n", fsi->fifo_max_num);
525 524
@@ -700,13 +699,13 @@ static irqreturn_t fsi_interrupt(int irq, void *data)
700 fsi_master_mask_set(master, SOFT_RST, IR, 0); 699 fsi_master_mask_set(master, SOFT_RST, IR, 0);
701 fsi_master_mask_set(master, SOFT_RST, IR, IR); 700 fsi_master_mask_set(master, SOFT_RST, IR, IR);
702 701
703 if (int_st & INT_A_OUT) 702 if (int_st & AB_IO(1, AO_SHIFT))
704 fsi_data_push(&master->fsia, 0); 703 fsi_data_push(&master->fsia, 0);
705 if (int_st & INT_B_OUT) 704 if (int_st & AB_IO(1, BO_SHIFT))
706 fsi_data_push(&master->fsib, 0); 705 fsi_data_push(&master->fsib, 0);
707 if (int_st & INT_A_IN) 706 if (int_st & AB_IO(1, AI_SHIFT))
708 fsi_data_pop(&master->fsia, 0); 707 fsi_data_pop(&master->fsia, 0);
709 if (int_st & INT_B_IN) 708 if (int_st & AB_IO(1, BI_SHIFT))
710 fsi_data_pop(&master->fsib, 0); 709 fsi_data_pop(&master->fsib, 0);
711 710
712 fsi_irq_clear_all_status(master); 711 fsi_irq_clear_all_status(master);