aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-04-13 14:14:08 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-13 14:16:53 -0400
commit7203a62562dc45dcd69339d4553fb85453d6b587 (patch)
treed5726295c91a18090054c5cebc1b58c9ec6fc4ab /sound/soc/tegra
parent5939ae74753ceda976732899bef71f99ffea6ea5 (diff)
ASoC: convert Tegra20 DAS driver to regmap
Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/tegra')
-rw-r--r--sound/soc/tegra/tegra20_das.c99
-rw-r--r--sound/soc/tegra/tegra20_das.h3
2 files changed, 37 insertions, 65 deletions
diff --git a/sound/soc/tegra/tegra20_das.c b/sound/soc/tegra/tegra20_das.c
index 812696d9c863..bf99296bce95 100644
--- a/sound/soc/tegra/tegra20_das.c
+++ b/sound/soc/tegra/tegra20_das.c
@@ -20,12 +20,11 @@
20 * 20 *
21 */ 21 */
22 22
23#include <linux/debugfs.h>
24#include <linux/device.h> 23#include <linux/device.h>
25#include <linux/io.h> 24#include <linux/io.h>
26#include <linux/module.h> 25#include <linux/module.h>
27#include <linux/platform_device.h> 26#include <linux/platform_device.h>
28#include <linux/seq_file.h> 27#include <linux/regmap.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <sound/soc.h> 29#include <sound/soc.h>
31#include "tegra20_das.h" 30#include "tegra20_das.h"
@@ -36,12 +35,14 @@ static struct tegra20_das *das;
36 35
37static inline void tegra20_das_write(u32 reg, u32 val) 36static inline void tegra20_das_write(u32 reg, u32 val)
38{ 37{
39 __raw_writel(val, das->regs + reg); 38 regmap_write(das->regmap, reg, val);
40} 39}
41 40
42static inline u32 tegra20_das_read(u32 reg) 41static inline u32 tegra20_das_read(u32 reg)
43{ 42{
44 return __raw_readl(das->regs + reg); 43 u32 val;
44 regmap_read(das->regmap, reg, &val);
45 return val;
45} 46}
46 47
47int tegra20_das_connect_dap_to_dac(int dap, int dac) 48int tegra20_das_connect_dap_to_dac(int dap, int dac)
@@ -104,68 +105,36 @@ int tegra20_das_connect_dac_to_dap(int dac, int dap)
104} 105}
105EXPORT_SYMBOL_GPL(tegra20_das_connect_dac_to_dap); 106EXPORT_SYMBOL_GPL(tegra20_das_connect_dac_to_dap);
106 107
107#ifdef CONFIG_DEBUG_FS 108#define LAST_REG(name) \
108static int tegra20_das_show(struct seq_file *s, void *unused) 109 (TEGRA20_DAS_##name + \
109{ 110 (TEGRA20_DAS_##name##_STRIDE * (TEGRA20_DAS_##name##_COUNT - 1)))
110 int i;
111 u32 addr;
112 u32 reg;
113
114 for (i = 0; i < TEGRA20_DAS_DAP_CTRL_SEL_COUNT; i++) {
115 addr = TEGRA20_DAS_DAP_CTRL_SEL +
116 (i * TEGRA20_DAS_DAP_CTRL_SEL_STRIDE);
117 reg = tegra20_das_read(addr);
118 seq_printf(s, "TEGRA20_DAS_DAP_CTRL_SEL[%d] = %08x\n", i, reg);
119 }
120
121 for (i = 0; i < TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_COUNT; i++) {
122 addr = TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL +
123 (i * TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_STRIDE);
124 reg = tegra20_das_read(addr);
125 seq_printf(s, "TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL[%d] = %08x\n",
126 i, reg);
127 }
128 111
129 return 0; 112static bool tegra20_das_wr_rd_reg(struct device *dev, unsigned int reg)
130}
131
132static int tegra20_das_debug_open(struct inode *inode, struct file *file)
133{ 113{
134 return single_open(file, tegra20_das_show, inode->i_private); 114 if ((reg >= TEGRA20_DAS_DAP_CTRL_SEL) &&
115 (reg <= LAST_REG(DAP_CTRL_SEL)))
116 return true;
117 if ((reg >= TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL) &&
118 (reg <= LAST_REG(DAC_INPUT_DATA_CLK_SEL)))
119 return true;
120
121 return false;
135} 122}
136 123
137static const struct file_operations tegra20_das_debug_fops = { 124static const struct regmap_config tegra20_das_regmap_config = {
138 .open = tegra20_das_debug_open, 125 .reg_bits = 32,
139 .read = seq_read, 126 .reg_stride = 4,
140 .llseek = seq_lseek, 127 .val_bits = 32,
141 .release = single_release, 128 .max_register = LAST_REG(DAC_INPUT_DATA_CLK_SEL),
129 .writeable_reg = tegra20_das_wr_rd_reg,
130 .readable_reg = tegra20_das_wr_rd_reg,
131 .cache_type = REGCACHE_RBTREE,
142}; 132};
143 133
144static void tegra20_das_debug_add(struct tegra20_das *das)
145{
146 das->debug = debugfs_create_file(DRV_NAME, S_IRUGO,
147 snd_soc_debugfs_root, das,
148 &tegra20_das_debug_fops);
149}
150
151static void tegra20_das_debug_remove(struct tegra20_das *das)
152{
153 if (das->debug)
154 debugfs_remove(das->debug);
155}
156#else
157static inline void tegra20_das_debug_add(struct tegra20_das *das)
158{
159}
160
161static inline void tegra20_das_debug_remove(struct tegra20_das *das)
162{
163}
164#endif
165
166static int __devinit tegra20_das_probe(struct platform_device *pdev) 134static int __devinit tegra20_das_probe(struct platform_device *pdev)
167{ 135{
168 struct resource *res, *region; 136 struct resource *res, *region;
137 void __iomem *regs;
169 int ret = 0; 138 int ret = 0;
170 139
171 if (das) 140 if (das)
@@ -194,13 +163,21 @@ static int __devinit tegra20_das_probe(struct platform_device *pdev)
194 goto err; 163 goto err;
195 } 164 }
196 165
197 das->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); 166 regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
198 if (!das->regs) { 167 if (!regs) {
199 dev_err(&pdev->dev, "ioremap failed\n"); 168 dev_err(&pdev->dev, "ioremap failed\n");
200 ret = -ENOMEM; 169 ret = -ENOMEM;
201 goto err; 170 goto err;
202 } 171 }
203 172
173 das->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
174 &tegra20_das_regmap_config);
175 if (IS_ERR(das->regmap)) {
176 dev_err(&pdev->dev, "regmap init failed\n");
177 ret = PTR_ERR(das->regmap);
178 goto err;
179 }
180
204 ret = tegra20_das_connect_dap_to_dac(TEGRA20_DAS_DAP_ID_1, 181 ret = tegra20_das_connect_dap_to_dac(TEGRA20_DAS_DAP_ID_1,
205 TEGRA20_DAS_DAP_SEL_DAC1); 182 TEGRA20_DAS_DAP_SEL_DAC1);
206 if (ret) { 183 if (ret) {
@@ -214,8 +191,6 @@ static int __devinit tegra20_das_probe(struct platform_device *pdev)
214 goto err; 191 goto err;
215 } 192 }
216 193
217 tegra20_das_debug_add(das);
218
219 platform_set_drvdata(pdev, das); 194 platform_set_drvdata(pdev, das);
220 195
221 return 0; 196 return 0;
@@ -230,8 +205,6 @@ static int __devexit tegra20_das_remove(struct platform_device *pdev)
230 if (!das) 205 if (!das)
231 return -ENODEV; 206 return -ENODEV;
232 207
233 tegra20_das_debug_remove(das);
234
235 das = NULL; 208 das = NULL;
236 209
237 return 0; 210 return 0;
diff --git a/sound/soc/tegra/tegra20_das.h b/sound/soc/tegra/tegra20_das.h
index ade4fe080c45..be217f3d3a75 100644
--- a/sound/soc/tegra/tegra20_das.h
+++ b/sound/soc/tegra/tegra20_das.h
@@ -85,8 +85,7 @@
85 85
86struct tegra20_das { 86struct tegra20_das {
87 struct device *dev; 87 struct device *dev;
88 void __iomem *regs; 88 struct regmap *regmap;
89 struct dentry *debug;
90}; 89};
91 90
92/* 91/*