Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 1 | #ifndef __SOUND_FSI_H |
| 2 | #define __SOUND_FSI_H |
| 3 | |
| 4 | /* |
| 5 | * Fifo-attached Serial Interface (FSI) support for SH7724 |
| 6 | * |
| 7 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 8 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
Kuninori Morimoto | 3c2ef84 | 2010-07-16 19:51:06 +0900 | [diff] [blame] | 15 | #define FSI_PORT_A 0 |
| 16 | #define FSI_PORT_B 1 |
| 17 | |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 18 | #include <linux/clk.h> |
| 19 | #include <sound/soc.h> |
| 20 | |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 21 | /* |
| 22 | * flags format |
| 23 | * |
Kuninori Morimoto | 766812e | 2012-05-17 17:36:47 -0700 | [diff] [blame] | 24 | * 0x00000CBA |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 25 | * |
| 26 | * A: inversion |
| 27 | * B: format mode |
Kuninori Morimoto | 766812e | 2012-05-17 17:36:47 -0700 | [diff] [blame] | 28 | * C: chip specific |
Kuninori Morimoto | ab6f6d8 | 2012-11-05 18:30:38 -0800 | [diff] [blame] | 29 | * D: clock selecter if master mode |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 30 | */ |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 31 | |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 32 | /* A: clock inversion */ |
| 33 | #define SH_FSI_INVERSION_MASK 0x0000000F |
| 34 | #define SH_FSI_LRM_INV (1 << 0) |
| 35 | #define SH_FSI_BRM_INV (1 << 1) |
| 36 | #define SH_FSI_LRS_INV (1 << 2) |
| 37 | #define SH_FSI_BRS_INV (1 << 3) |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 38 | |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 39 | /* B: format mode */ |
| 40 | #define SH_FSI_FMT_MASK 0x000000F0 |
| 41 | #define SH_FSI_FMT_DAI (0 << 4) |
| 42 | #define SH_FSI_FMT_SPDIF (1 << 4) |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 43 | |
Kuninori Morimoto | 766812e | 2012-05-17 17:36:47 -0700 | [diff] [blame] | 44 | /* C: chip specific */ |
| 45 | #define SH_FSI_OPTION_MASK 0x00000F00 |
| 46 | #define SH_FSI_ENABLE_STREAM_MODE (1 << 8) /* for 16bit data */ |
Kuninori Morimoto | ccad7b4 | 2010-07-13 12:13:14 +0900 | [diff] [blame] | 47 | |
Kuninori Morimoto | ab6f6d8 | 2012-11-05 18:30:38 -0800 | [diff] [blame] | 48 | /* D: clock selecter if master mode */ |
| 49 | #define SH_FSI_CLK_MASK 0x0000F000 |
Kuninori Morimoto | ab6340c | 2012-11-16 01:17:18 -0800 | [diff] [blame] | 50 | #define SH_FSI_CLK_EXTERNAL (0 << 12) |
| 51 | #define SH_FSI_CLK_CPG (1 << 12) /* FSIxCK + FSI-DIV */ |
Kuninori Morimoto | ab6f6d8 | 2012-11-05 18:30:38 -0800 | [diff] [blame] | 52 | |
Kuninori Morimoto | ccad7b4 | 2010-07-13 12:13:14 +0900 | [diff] [blame] | 53 | /* |
| 54 | * set_rate return value |
| 55 | * |
| 56 | * see ACKMD/BPFMD on |
| 57 | * ACK_MD (FSI2) |
| 58 | * CKG1 (FSI) |
| 59 | * |
Kuninori Morimoto | d4bc99b | 2010-11-24 02:44:06 +0000 | [diff] [blame] | 60 | * err : return value < 0 |
| 61 | * no change : return value == 0 |
| 62 | * change xMD : return value > 0 |
Kuninori Morimoto | ccad7b4 | 2010-07-13 12:13:14 +0900 | [diff] [blame] | 63 | * |
| 64 | * 0x-00000AB |
| 65 | * |
| 66 | * A: ACKMD value |
| 67 | * B: BPFMD value |
| 68 | */ |
| 69 | |
| 70 | #define SH_FSI_ACKMD_MASK (0xF << 0) |
| 71 | #define SH_FSI_ACKMD_512 (1 << 0) |
| 72 | #define SH_FSI_ACKMD_256 (2 << 0) |
| 73 | #define SH_FSI_ACKMD_128 (3 << 0) |
| 74 | #define SH_FSI_ACKMD_64 (4 << 0) |
| 75 | #define SH_FSI_ACKMD_32 (5 << 0) |
| 76 | |
| 77 | #define SH_FSI_BPFMD_MASK (0xF << 4) |
| 78 | #define SH_FSI_BPFMD_512 (1 << 4) |
| 79 | #define SH_FSI_BPFMD_256 (2 << 4) |
| 80 | #define SH_FSI_BPFMD_128 (3 << 4) |
| 81 | #define SH_FSI_BPFMD_64 (4 << 4) |
| 82 | #define SH_FSI_BPFMD_32 (5 << 4) |
| 83 | #define SH_FSI_BPFMD_16 (6 << 4) |
| 84 | |
Kuninori Morimoto | fec691e | 2012-02-03 00:58:48 -0800 | [diff] [blame] | 85 | struct sh_fsi_port_info { |
| 86 | unsigned long flags; |
Kuninori Morimoto | 7da9ced | 2012-02-03 00:59:33 -0800 | [diff] [blame] | 87 | int tx_id; |
| 88 | int rx_id; |
Kuninori Morimoto | fec691e | 2012-02-03 00:58:48 -0800 | [diff] [blame] | 89 | int (*set_rate)(struct device *dev, int rate, int enable); |
| 90 | }; |
| 91 | |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 92 | struct sh_fsi_platform_info { |
Kuninori Morimoto | fec691e | 2012-02-03 00:58:48 -0800 | [diff] [blame] | 93 | struct sh_fsi_port_info port_a; |
| 94 | struct sh_fsi_port_info port_b; |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 95 | }; |
| 96 | |
Kuninori Morimoto | a4d7d55 | 2009-08-20 21:01:05 +0900 | [diff] [blame] | 97 | #endif /* __SOUND_FSI_H */ |