diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2012-12-17 01:12:21 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-24 10:56:55 -0500 |
commit | 6cbdbffba19620db77de38094f407b6f21d3f10c (patch) | |
tree | f11601d5ff22373736c05c060664f27f8d9a0c47 /sound/soc/sh/fsi.c | |
parent | a49f0d1ea3ec94fc7cf33a7c36a16343b74bd565 (diff) |
ASoC: fsi: remove platform depended .set_rate() callback support
ab6f6d85210c4d0265cf48e9958c04e08595055a
(ASoC: fsi: add master clock control functions)
added driver level clock control functions.
And now, platform depended .set_rate() is no longer needed.
This patch removed unnecessary .set_rate() platform callback support.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/sh/fsi.c')
-rw-r--r-- | sound/soc/sh/fsi.c | 131 |
1 files changed, 12 insertions, 119 deletions
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index a606d0f93d1c..5cb1332e0438 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
@@ -131,8 +131,6 @@ | |||
131 | 131 | ||
132 | #define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) | 132 | #define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) |
133 | 133 | ||
134 | typedef int (*set_rate_func)(struct device *dev, int rate, int enable); | ||
135 | |||
136 | /* | 134 | /* |
137 | * bus options | 135 | * bus options |
138 | * | 136 | * |
@@ -244,8 +242,7 @@ struct fsi_clk { | |||
244 | struct clk *ick; | 242 | struct clk *ick; |
245 | struct clk *div; | 243 | struct clk *div; |
246 | int (*set_rate)(struct device *dev, | 244 | int (*set_rate)(struct device *dev, |
247 | struct fsi_priv *fsi, | 245 | struct fsi_priv *fsi); |
248 | unsigned long rate); | ||
249 | 246 | ||
250 | unsigned long rate; | 247 | unsigned long rate; |
251 | unsigned int count; | 248 | unsigned int count; |
@@ -270,8 +267,6 @@ struct fsi_priv { | |||
270 | int enable_stream:1; | 267 | int enable_stream:1; |
271 | int bit_clk_inv:1; | 268 | int bit_clk_inv:1; |
272 | int lr_clk_inv:1; | 269 | int lr_clk_inv:1; |
273 | |||
274 | long rate; | ||
275 | }; | 270 | }; |
276 | 271 | ||
277 | struct fsi_stream_handler { | 272 | struct fsi_stream_handler { |
@@ -431,14 +426,6 @@ static struct fsi_priv *fsi_get_priv(struct snd_pcm_substream *substream) | |||
431 | return fsi_get_priv_frm_dai(fsi_get_dai(substream)); | 426 | return fsi_get_priv_frm_dai(fsi_get_dai(substream)); |
432 | } | 427 | } |
433 | 428 | ||
434 | static set_rate_func fsi_get_info_set_rate(struct fsi_priv *fsi) | ||
435 | { | ||
436 | if (!fsi->info) | ||
437 | return NULL; | ||
438 | |||
439 | return fsi->info->set_rate; | ||
440 | } | ||
441 | |||
442 | static u32 fsi_get_info_flags(struct fsi_priv *fsi) | 429 | static u32 fsi_get_info_flags(struct fsi_priv *fsi) |
443 | { | 430 | { |
444 | if (!fsi->info) | 431 | if (!fsi->info) |
@@ -757,8 +744,7 @@ static int fsi_clk_init(struct device *dev, | |||
757 | int ick, | 744 | int ick, |
758 | int div, | 745 | int div, |
759 | int (*set_rate)(struct device *dev, | 746 | int (*set_rate)(struct device *dev, |
760 | struct fsi_priv *fsi, | 747 | struct fsi_priv *fsi)) |
761 | unsigned long rate)) | ||
762 | { | 748 | { |
763 | struct fsi_clk *clock = &fsi->clock; | 749 | struct fsi_clk *clock = &fsi->clock; |
764 | int is_porta = fsi_is_port_a(fsi); | 750 | int is_porta = fsi_is_port_a(fsi); |
@@ -829,8 +815,7 @@ static int fsi_clk_is_valid(struct fsi_priv *fsi) | |||
829 | } | 815 | } |
830 | 816 | ||
831 | static int fsi_clk_enable(struct device *dev, | 817 | static int fsi_clk_enable(struct device *dev, |
832 | struct fsi_priv *fsi, | 818 | struct fsi_priv *fsi) |
833 | unsigned long rate) | ||
834 | { | 819 | { |
835 | struct fsi_clk *clock = &fsi->clock; | 820 | struct fsi_clk *clock = &fsi->clock; |
836 | int ret = -EINVAL; | 821 | int ret = -EINVAL; |
@@ -839,7 +824,7 @@ static int fsi_clk_enable(struct device *dev, | |||
839 | return ret; | 824 | return ret; |
840 | 825 | ||
841 | if (0 == clock->count) { | 826 | if (0 == clock->count) { |
842 | ret = clock->set_rate(dev, fsi, rate); | 827 | ret = clock->set_rate(dev, fsi); |
843 | if (ret < 0) { | 828 | if (ret < 0) { |
844 | fsi_clk_invalid(fsi); | 829 | fsi_clk_invalid(fsi); |
845 | return ret; | 830 | return ret; |
@@ -946,11 +931,11 @@ static int fsi_clk_set_ackbpf(struct device *dev, | |||
946 | } | 931 | } |
947 | 932 | ||
948 | static int fsi_clk_set_rate_external(struct device *dev, | 933 | static int fsi_clk_set_rate_external(struct device *dev, |
949 | struct fsi_priv *fsi, | 934 | struct fsi_priv *fsi) |
950 | unsigned long rate) | ||
951 | { | 935 | { |
952 | struct clk *xck = fsi->clock.xck; | 936 | struct clk *xck = fsi->clock.xck; |
953 | struct clk *ick = fsi->clock.ick; | 937 | struct clk *ick = fsi->clock.ick; |
938 | unsigned long rate = fsi->clock.rate; | ||
954 | unsigned long xrate; | 939 | unsigned long xrate; |
955 | int ackmd, bpfmd; | 940 | int ackmd, bpfmd; |
956 | int ret = 0; | 941 | int ret = 0; |
@@ -978,11 +963,11 @@ static int fsi_clk_set_rate_external(struct device *dev, | |||
978 | } | 963 | } |
979 | 964 | ||
980 | static int fsi_clk_set_rate_cpg(struct device *dev, | 965 | static int fsi_clk_set_rate_cpg(struct device *dev, |
981 | struct fsi_priv *fsi, | 966 | struct fsi_priv *fsi) |
982 | unsigned long rate) | ||
983 | { | 967 | { |
984 | struct clk *ick = fsi->clock.ick; | 968 | struct clk *ick = fsi->clock.ick; |
985 | struct clk *div = fsi->clock.div; | 969 | struct clk *div = fsi->clock.div; |
970 | unsigned long rate = fsi->clock.rate; | ||
986 | unsigned long target = 0; /* 12288000 or 11289600 */ | 971 | unsigned long target = 0; /* 12288000 or 11289600 */ |
987 | unsigned long actual, cout; | 972 | unsigned long actual, cout; |
988 | unsigned long diff, min; | 973 | unsigned long diff, min; |
@@ -1063,85 +1048,6 @@ static int fsi_clk_set_rate_cpg(struct device *dev, | |||
1063 | return ret; | 1048 | return ret; |
1064 | } | 1049 | } |
1065 | 1050 | ||
1066 | static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi, | ||
1067 | long rate, int enable) | ||
1068 | { | ||
1069 | set_rate_func set_rate = fsi_get_info_set_rate(fsi); | ||
1070 | int ret; | ||
1071 | |||
1072 | /* | ||
1073 | * CAUTION | ||
1074 | * | ||
1075 | * set_rate will be deleted | ||
1076 | */ | ||
1077 | if (!set_rate) { | ||
1078 | if (enable) | ||
1079 | return fsi_clk_enable(dev, fsi, rate); | ||
1080 | else | ||
1081 | return fsi_clk_disable(dev, fsi); | ||
1082 | } | ||
1083 | |||
1084 | ret = set_rate(dev, rate, enable); | ||
1085 | if (ret < 0) /* error */ | ||
1086 | return ret; | ||
1087 | |||
1088 | if (!enable) | ||
1089 | return 0; | ||
1090 | |||
1091 | if (ret > 0) { | ||
1092 | u32 data = 0; | ||
1093 | |||
1094 | switch (ret & SH_FSI_ACKMD_MASK) { | ||
1095 | default: | ||
1096 | /* FALL THROUGH */ | ||
1097 | case SH_FSI_ACKMD_512: | ||
1098 | data |= (0x0 << 12); | ||
1099 | break; | ||
1100 | case SH_FSI_ACKMD_256: | ||
1101 | data |= (0x1 << 12); | ||
1102 | break; | ||
1103 | case SH_FSI_ACKMD_128: | ||
1104 | data |= (0x2 << 12); | ||
1105 | break; | ||
1106 | case SH_FSI_ACKMD_64: | ||
1107 | data |= (0x3 << 12); | ||
1108 | break; | ||
1109 | case SH_FSI_ACKMD_32: | ||
1110 | data |= (0x4 << 12); | ||
1111 | break; | ||
1112 | } | ||
1113 | |||
1114 | switch (ret & SH_FSI_BPFMD_MASK) { | ||
1115 | default: | ||
1116 | /* FALL THROUGH */ | ||
1117 | case SH_FSI_BPFMD_32: | ||
1118 | data |= (0x0 << 8); | ||
1119 | break; | ||
1120 | case SH_FSI_BPFMD_64: | ||
1121 | data |= (0x1 << 8); | ||
1122 | break; | ||
1123 | case SH_FSI_BPFMD_128: | ||
1124 | data |= (0x2 << 8); | ||
1125 | break; | ||
1126 | case SH_FSI_BPFMD_256: | ||
1127 | data |= (0x3 << 8); | ||
1128 | break; | ||
1129 | case SH_FSI_BPFMD_512: | ||
1130 | data |= (0x4 << 8); | ||
1131 | break; | ||
1132 | case SH_FSI_BPFMD_16: | ||
1133 | data |= (0x7 << 8); | ||
1134 | break; | ||
1135 | } | ||
1136 | |||
1137 | fsi_reg_mask_set(fsi, CKG1, (ACKMD_MASK | BPFMD_MASK) , data); | ||
1138 | udelay(10); | ||
1139 | ret = 0; | ||
1140 | } | ||
1141 | |||
1142 | return ret; | ||
1143 | } | ||
1144 | |||
1145 | /* | 1051 | /* |
1146 | * pio data transfer handler | 1052 | * pio data transfer handler |
1147 | */ | 1053 | */ |
@@ -1698,7 +1604,7 @@ static int fsi_hw_startup(struct fsi_priv *fsi, | |||
1698 | 1604 | ||
1699 | /* start master clock */ | 1605 | /* start master clock */ |
1700 | if (fsi_is_clk_master(fsi)) | 1606 | if (fsi_is_clk_master(fsi)) |
1701 | return fsi_set_master_clk(dev, fsi, fsi->rate, 1); | 1607 | return fsi_clk_enable(dev, fsi); |
1702 | 1608 | ||
1703 | return 0; | 1609 | return 0; |
1704 | } | 1610 | } |
@@ -1708,7 +1614,7 @@ static int fsi_hw_shutdown(struct fsi_priv *fsi, | |||
1708 | { | 1614 | { |
1709 | /* stop master clock */ | 1615 | /* stop master clock */ |
1710 | if (fsi_is_clk_master(fsi)) | 1616 | if (fsi_is_clk_master(fsi)) |
1711 | return fsi_set_master_clk(dev, fsi, fsi->rate, 0); | 1617 | return fsi_clk_disable(dev, fsi); |
1712 | 1618 | ||
1713 | return 0; | 1619 | return 0; |
1714 | } | 1620 | } |
@@ -1719,7 +1625,6 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream, | |||
1719 | struct fsi_priv *fsi = fsi_get_priv(substream); | 1625 | struct fsi_priv *fsi = fsi_get_priv(substream); |
1720 | 1626 | ||
1721 | fsi_clk_invalid(fsi); | 1627 | fsi_clk_invalid(fsi); |
1722 | fsi->rate = 0; | ||
1723 | 1628 | ||
1724 | return 0; | 1629 | return 0; |
1725 | } | 1630 | } |
@@ -1730,7 +1635,6 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream, | |||
1730 | struct fsi_priv *fsi = fsi_get_priv(substream); | 1635 | struct fsi_priv *fsi = fsi_get_priv(substream); |
1731 | 1636 | ||
1732 | fsi_clk_invalid(fsi); | 1637 | fsi_clk_invalid(fsi); |
1733 | fsi->rate = 0; | ||
1734 | } | 1638 | } |
1735 | 1639 | ||
1736 | static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, | 1640 | static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, |
@@ -1795,7 +1699,6 @@ static int fsi_set_fmt_spdif(struct fsi_priv *fsi) | |||
1795 | static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | 1699 | static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
1796 | { | 1700 | { |
1797 | struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); | 1701 | struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); |
1798 | set_rate_func set_rate = fsi_get_info_set_rate(fsi); | ||
1799 | int ret; | 1702 | int ret; |
1800 | 1703 | ||
1801 | /* set master/slave audio interface */ | 1704 | /* set master/slave audio interface */ |
@@ -1831,14 +1734,6 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
1831 | } | 1734 | } |
1832 | 1735 | ||
1833 | if (fsi_is_clk_master(fsi)) { | 1736 | if (fsi_is_clk_master(fsi)) { |
1834 | /* | ||
1835 | * CAUTION | ||
1836 | * | ||
1837 | * set_rate will be deleted | ||
1838 | */ | ||
1839 | if (set_rate) | ||
1840 | dev_warn(dai->dev, "set_rate will be removed soon\n"); | ||
1841 | |||
1842 | if (fsi->clk_cpg) | 1737 | if (fsi->clk_cpg) |
1843 | fsi_clk_init(dai->dev, fsi, 0, 1, 1, | 1738 | fsi_clk_init(dai->dev, fsi, 0, 1, 1, |
1844 | fsi_clk_set_rate_cpg); | 1739 | fsi_clk_set_rate_cpg); |
@@ -1862,10 +1757,8 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream, | |||
1862 | { | 1757 | { |
1863 | struct fsi_priv *fsi = fsi_get_priv(substream); | 1758 | struct fsi_priv *fsi = fsi_get_priv(substream); |
1864 | 1759 | ||
1865 | if (fsi_is_clk_master(fsi)) { | 1760 | if (fsi_is_clk_master(fsi)) |
1866 | fsi->rate = params_rate(params); | 1761 | fsi_clk_valid(fsi, params_rate(params)); |
1867 | fsi_clk_valid(fsi, fsi->rate); | ||
1868 | } | ||
1869 | 1762 | ||
1870 | return 0; | 1763 | return 0; |
1871 | } | 1764 | } |