From 6a017660768f8aca6ebf513cfb0c7ac241547deb Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 14:08:55 +0100 Subject: mfd: davinci_voicecodec: Remove unused read and write functions These functions are not referenced anywhere, nor prototyped, so just remove them. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/davinci_voicecodec.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c index fb64398506e9..a292d71c397c 100644 --- a/drivers/mfd/davinci_voicecodec.c +++ b/drivers/mfd/davinci_voicecodec.c @@ -32,17 +32,6 @@ #include -u32 davinci_vc_read(struct davinci_vc *davinci_vc, int reg) -{ - return __raw_readl(davinci_vc->base + reg); -} - -void davinci_vc_write(struct davinci_vc *davinci_vc, - int reg, u32 val) -{ - __raw_writel(val, davinci_vc->base + reg); -} - static int __init davinci_vc_probe(struct platform_device *pdev) { struct davinci_vc *davinci_vc; -- cgit v1.2.3 From 921a2c870faa0a88c34e5c8c2afbd898fe8d325d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 14:08:56 +0100 Subject: mfd: davinci_voicecodec: Provide a regmap for register I/O This will be used to support refactoring of the ASoC CODEC driver to use a regmap. Signed-off-by: Mark Brown Signed-off-by: Samuel Ortiz --- drivers/mfd/davinci_voicecodec.c | 14 ++++++++++++++ include/linux/mfd/davinci_voicecodec.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c index a292d71c397c..013ba8159dcd 100644 --- a/drivers/mfd/davinci_voicecodec.c +++ b/drivers/mfd/davinci_voicecodec.c @@ -27,11 +27,17 @@ #include #include #include +#include #include #include +static struct regmap_config davinci_vc_regmap = { + .reg_bits = 32, + .val_bits = 32, +}; + static int __init davinci_vc_probe(struct platform_device *pdev) { struct davinci_vc *davinci_vc; @@ -63,6 +69,14 @@ static int __init davinci_vc_probe(struct platform_device *pdev) goto fail; } + davinci_vc->regmap = devm_regmap_init_mmio(&pdev->dev, + davinci_vc->base, + &davinci_vc_regmap); + if (IS_ERR(davinci_vc->regmap)) { + ret = PTR_ERR(davinci_vc->regmap); + goto fail; + } + res = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!res) { dev_err(&pdev->dev, "no DMA resource\n"); diff --git a/include/linux/mfd/davinci_voicecodec.h b/include/linux/mfd/davinci_voicecodec.h index 13a1ee95a233..5166935ce66d 100644 --- a/include/linux/mfd/davinci_voicecodec.h +++ b/include/linux/mfd/davinci_voicecodec.h @@ -30,6 +30,8 @@ #include +struct regmap; + /* * Register values. */ @@ -113,6 +115,7 @@ struct davinci_vc { /* Memory resources */ void __iomem *base; + struct regmap *regmap; /* MFD cells */ struct mfd_cell cells[DAVINCI_VC_CELLS]; -- cgit v1.2.3 From c6f39257c952bc7da974bf93255936ff2ece2c34 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Sat, 31 Aug 2013 17:48:19 +0100 Subject: mfd: twl6040: Use regmap for register cache Rather then open coding a cache of the vibra control registers use the regmap cache code. Also cache the interrupt mask register, providing a small performance improvement for the interrupt code. Signed-off-by: Mark Brown Acked-by: Peter Ujfalusi Signed-off-by: Samuel Ortiz --- drivers/mfd/twl6040.c | 43 ++++++++++++++++++++++++++++++------------- include/linux/mfd/twl6040.h | 1 - 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c index 492ee2cd3400..c7df66a208d4 100644 --- a/drivers/mfd/twl6040.c +++ b/drivers/mfd/twl6040.c @@ -63,15 +63,9 @@ int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) int ret; unsigned int val; - /* Vibra control registers from cache */ - if (unlikely(reg == TWL6040_REG_VIBCTLL || - reg == TWL6040_REG_VIBCTLR)) { - val = twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)]; - } else { - ret = regmap_read(twl6040->regmap, reg, &val); - if (ret < 0) - return ret; - } + ret = regmap_read(twl6040->regmap, reg, &val); + if (ret < 0) + return ret; return val; } @@ -82,9 +76,6 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val) int ret; ret = regmap_write(twl6040->regmap, reg, val); - /* Cache the vibra control registers */ - if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) - twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; return ret; } @@ -461,9 +452,20 @@ EXPORT_SYMBOL(twl6040_get_sysclk); /* Get the combined status of the vibra control register */ int twl6040_get_vibralr_status(struct twl6040 *twl6040) { + unsigned int reg; + int ret; u8 status; - status = twl6040->vibra_ctrl_cache[0] | twl6040->vibra_ctrl_cache[1]; + ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLL, ®); + if (ret != 0) + return ret; + status = reg; + + ret = regmap_read(twl6040->regmap, TWL6040_REG_VIBCTLR, ®); + if (ret != 0) + return ret; + status |= reg; + status &= (TWL6040_VIBENA | TWL6040_VIBSEL); return status; @@ -490,12 +492,27 @@ static bool twl6040_readable_reg(struct device *dev, unsigned int reg) return true; } +static bool twl6040_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case TWL6040_REG_VIBCTLL: + case TWL6040_REG_VIBCTLR: + case TWL6040_REG_INTMR: + return false; + default: + return true; + } +} + static struct regmap_config twl6040_regmap_config = { .reg_bits = 8, .val_bits = 8, .max_register = TWL6040_REG_STATUS, /* 0x2e */ .readable_reg = twl6040_readable_reg, + .volatile_reg = twl6040_volatile_reg, + + .cache_type = REGCACHE_RBTREE, }; static const struct regmap_irq twl6040_irqs[] = { diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h index 7e7fbce7a308..2b7d26573431 100644 --- a/include/linux/mfd/twl6040.h +++ b/include/linux/mfd/twl6040.h @@ -229,7 +229,6 @@ struct twl6040 { int audpwron; int power_count; int rev; - u8 vibra_ctrl_cache[2]; /* PLL configuration */ int pll; -- cgit v1.2.3