drivers: mfd: Add support for wcd934x 1.1 version

Add support to check for wcd934x 1.1 version and update
register values accordingly.

Change-Id: Id9fb06fa25dfdd56250a76248f71758af39bade6
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
This commit is contained in:
Phani Kumar Uppalapati 2016-09-26 14:57:53 -07:00 committed by Gerrit - the friendly Code Review server
parent 8ec8b328f3
commit 116d2e852d
3 changed files with 52 additions and 0 deletions

View file

@ -17,6 +17,18 @@
#include <linux/device.h>
#include "wcd9xxx-regmap.h"
static const struct reg_sequence wcd934x_1_1_defaults[] = {
{ WCD934X_CHIP_TIER_CTRL_CHIP_ID_BYTE0, 0x01 },
{ WCD934X_BIAS_VBG_FINE_ADJ, 0x75 },
{ WCD934X_HPH_REFBUFF_LP_CTL, 0x0E },
{ WCD934X_EAR_DAC_CTL_ATEST, 0x08 },
{ WCD934X_SIDO_NEW_VOUT_A_STARTUP, 0x17 },
{ WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL, 0x40 },
{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L, 0x81 },
{ WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R, 0x81 },
};
static const struct reg_default wcd934x_defaults[] = {
{ WCD934X_PAGE0_PAGE_REGISTER, 0x00 },
{ WCD934X_CODEC_RPM_CLK_BYPASS, 0x00 },
@ -1803,6 +1815,37 @@ static const struct reg_default wcd934x_defaults[] = {
{ WCD934X_TEST_DEBUG_CODEC_DIAGS, 0x00 },
};
/*
* wcd934x_regmap_register_patch: Update register defaults based on version
* @regmap: handle to wcd9xxx regmap
* @version: wcd934x version
*
* Returns error code in case of failure or 0 for success
*/
int wcd934x_regmap_register_patch(struct regmap *regmap, int revision)
{
int rc = 0;
if (!regmap) {
pr_err("%s: regmap struct is NULL\n", __func__);
return -EINVAL;
}
switch (revision) {
case TAVIL_VERSION_1_1:
case TAVIL_VERSION_WCD9340_1_1:
case TAVIL_VERSION_WCD9341_1_1:
regcache_cache_only(regmap, true);
rc = regmap_multi_reg_write(regmap, wcd934x_1_1_defaults,
ARRAY_SIZE(wcd934x_1_1_defaults));
regcache_cache_only(regmap, false);
break;
}
return rc;
}
EXPORT_SYMBOL(wcd934x_regmap_register_patch);
static bool wcd934x_is_readable_register(struct device *dev, unsigned int reg)
{
u8 pg_num, reg_offset;

View file

@ -21,6 +21,8 @@ typedef int (*regmap_patch_fptr)(struct regmap *, int);
#ifdef CONFIG_WCD934X_CODEC
extern struct regmap_config wcd934x_regmap_config;
extern int wcd934x_regmap_register_patch(struct regmap *regmap,
int version);
#endif
#ifdef CONFIG_WCD9335_CODEC
@ -70,6 +72,11 @@ static inline regmap_patch_fptr wcd9xxx_get_regmap_reg_patch(int type)
case WCD9335:
apply_patch = wcd9335_regmap_register_patch;
break;
#endif
#ifdef CONFIG_WCD934X_CODEC
case WCD934X:
apply_patch = wcd934x_regmap_register_patch;
break;
#endif
default:
apply_patch = NULL;

View file

@ -800,9 +800,11 @@ enum {
#define WCD934X_VBADC_NEW_ADC_DOUTLSB 0x0731
#define WCD934X_HPH_NEW_INT_RDAC_GAIN_CTL 0x0732
#define WCD934X_HPH_NEW_INT_RDAC_HD2_CTL 0x0733
#define WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_L 0x0733
#define WCD934X_HPH_NEW_INT_RDAC_VREF_CTL 0x0734
#define WCD934X_HPH_NEW_INT_RDAC_OVERRIDE_CTL 0x0735
#define WCD934X_HPH_NEW_INT_RDAC_MISC1 0x0736
#define WCD934X_HPH_NEW_INT_RDAC_HD2_CTL_R 0x0736
#define WCD934X_HPH_NEW_INT_PA_MISC1 0x0737
#define WCD934X_HPH_NEW_INT_PA_MISC2 0x0738
#define WCD934X_HPH_NEW_INT_PA_RDAC_MISC 0x0739