提交 7203a625 编写于 作者: S Stephen Warren 提交者: Mark Brown

ASoC: convert Tegra20 DAS driver to regmap

Signed-off-by: NStephen Warren <swarren@nvidia.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 5939ae74
...@@ -20,12 +20,11 @@ ...@@ -20,12 +20,11 @@
* *
*/ */
#include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/seq_file.h> #include <linux/regmap.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/soc.h> #include <sound/soc.h>
#include "tegra20_das.h" #include "tegra20_das.h"
...@@ -36,12 +35,14 @@ static struct tegra20_das *das; ...@@ -36,12 +35,14 @@ static struct tegra20_das *das;
static inline void tegra20_das_write(u32 reg, u32 val) static inline void tegra20_das_write(u32 reg, u32 val)
{ {
__raw_writel(val, das->regs + reg); regmap_write(das->regmap, reg, val);
} }
static inline u32 tegra20_das_read(u32 reg) static inline u32 tegra20_das_read(u32 reg)
{ {
return __raw_readl(das->regs + reg); u32 val;
regmap_read(das->regmap, reg, &val);
return val;
} }
int tegra20_das_connect_dap_to_dac(int dap, int dac) int 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,68 +105,36 @@ int tegra20_das_connect_dac_to_dap(int dac, int dap)
} }
EXPORT_SYMBOL_GPL(tegra20_das_connect_dac_to_dap); EXPORT_SYMBOL_GPL(tegra20_das_connect_dac_to_dap);
#ifdef CONFIG_DEBUG_FS #define LAST_REG(name) \
static int tegra20_das_show(struct seq_file *s, void *unused) (TEGRA20_DAS_##name + \
{ (TEGRA20_DAS_##name##_STRIDE * (TEGRA20_DAS_##name##_COUNT - 1)))
int i;
u32 addr;
u32 reg;
for (i = 0; i < TEGRA20_DAS_DAP_CTRL_SEL_COUNT; i++) {
addr = TEGRA20_DAS_DAP_CTRL_SEL +
(i * TEGRA20_DAS_DAP_CTRL_SEL_STRIDE);
reg = tegra20_das_read(addr);
seq_printf(s, "TEGRA20_DAS_DAP_CTRL_SEL[%d] = %08x\n", i, reg);
}
for (i = 0; i < TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_COUNT; i++) {
addr = TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL +
(i * TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL_STRIDE);
reg = tegra20_das_read(addr);
seq_printf(s, "TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL[%d] = %08x\n",
i, reg);
}
return 0; static bool tegra20_das_wr_rd_reg(struct device *dev, unsigned int reg)
}
static int tegra20_das_debug_open(struct inode *inode, struct file *file)
{ {
return single_open(file, tegra20_das_show, inode->i_private); if ((reg >= TEGRA20_DAS_DAP_CTRL_SEL) &&
(reg <= LAST_REG(DAP_CTRL_SEL)))
return true;
if ((reg >= TEGRA20_DAS_DAC_INPUT_DATA_CLK_SEL) &&
(reg <= LAST_REG(DAC_INPUT_DATA_CLK_SEL)))
return true;
return false;
} }
static const struct file_operations tegra20_das_debug_fops = { static const struct regmap_config tegra20_das_regmap_config = {
.open = tegra20_das_debug_open, .reg_bits = 32,
.read = seq_read, .reg_stride = 4,
.llseek = seq_lseek, .val_bits = 32,
.release = single_release, .max_register = LAST_REG(DAC_INPUT_DATA_CLK_SEL),
.writeable_reg = tegra20_das_wr_rd_reg,
.readable_reg = tegra20_das_wr_rd_reg,
.cache_type = REGCACHE_RBTREE,
}; };
static void tegra20_das_debug_add(struct tegra20_das *das)
{
das->debug = debugfs_create_file(DRV_NAME, S_IRUGO,
snd_soc_debugfs_root, das,
&tegra20_das_debug_fops);
}
static void tegra20_das_debug_remove(struct tegra20_das *das)
{
if (das->debug)
debugfs_remove(das->debug);
}
#else
static inline void tegra20_das_debug_add(struct tegra20_das *das)
{
}
static inline void tegra20_das_debug_remove(struct tegra20_das *das)
{
}
#endif
static int __devinit tegra20_das_probe(struct platform_device *pdev) static int __devinit tegra20_das_probe(struct platform_device *pdev)
{ {
struct resource *res, *region; struct resource *res, *region;
void __iomem *regs;
int ret = 0; int ret = 0;
if (das) if (das)
...@@ -194,13 +163,21 @@ static int __devinit tegra20_das_probe(struct platform_device *pdev) ...@@ -194,13 +163,21 @@ static int __devinit tegra20_das_probe(struct platform_device *pdev)
goto err; goto err;
} }
das->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
if (!das->regs) { if (!regs) {
dev_err(&pdev->dev, "ioremap failed\n"); dev_err(&pdev->dev, "ioremap failed\n");
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
das->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
&tegra20_das_regmap_config);
if (IS_ERR(das->regmap)) {
dev_err(&pdev->dev, "regmap init failed\n");
ret = PTR_ERR(das->regmap);
goto err;
}
ret = tegra20_das_connect_dap_to_dac(TEGRA20_DAS_DAP_ID_1, ret = tegra20_das_connect_dap_to_dac(TEGRA20_DAS_DAP_ID_1,
TEGRA20_DAS_DAP_SEL_DAC1); TEGRA20_DAS_DAP_SEL_DAC1);
if (ret) { if (ret) {
...@@ -214,8 +191,6 @@ static int __devinit tegra20_das_probe(struct platform_device *pdev) ...@@ -214,8 +191,6 @@ static int __devinit tegra20_das_probe(struct platform_device *pdev)
goto err; goto err;
} }
tegra20_das_debug_add(das);
platform_set_drvdata(pdev, das); platform_set_drvdata(pdev, das);
return 0; return 0;
...@@ -230,8 +205,6 @@ static int __devexit tegra20_das_remove(struct platform_device *pdev) ...@@ -230,8 +205,6 @@ static int __devexit tegra20_das_remove(struct platform_device *pdev)
if (!das) if (!das)
return -ENODEV; return -ENODEV;
tegra20_das_debug_remove(das);
das = NULL; das = NULL;
return 0; return 0;
......
...@@ -85,8 +85,7 @@ ...@@ -85,8 +85,7 @@
struct tegra20_das { struct tegra20_das {
struct device *dev; struct device *dev;
void __iomem *regs; struct regmap *regmap;
struct dentry *debug;
}; };
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册