msm: mpq8064: Add support to enable 100KHz level shifter
cs8427 chip will be functional at i2c 100KHz frequency and
3.3 to 5V to enable this level shifter should be enabled
Change-Id: I4d30c597edc3367be89280edc85e2a272a67ae1e
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8064.c b/arch/arm/mach-msm/board-8064.c
index d02b4be..d868d52 100644
--- a/arch/arm/mach-msm/board-8064.c
+++ b/arch/arm/mach-msm/board-8064.c
@@ -892,9 +892,31 @@
},
};
+/* enable the level shifter for cs8427 to make sure the I2C
+ * clock is running at 100KHz and voltage levels are at 3.3
+ * and 5 volts
+ */
+static int enable_100KHz_ls(int enable)
+{
+ int ret = 0;
+ if (enable) {
+ ret = gpio_request(SX150X_GPIO(1, 10),
+ "cs8427_100KHZ_ENABLE");
+ if (ret) {
+ pr_err("%s: Failed to request gpio %d\n", __func__,
+ SX150X_GPIO(1, 10));
+ return ret;
+ }
+ gpio_direction_output(SX150X_GPIO(1, 10), 1);
+ } else
+ gpio_free(SX150X_GPIO(1, 10));
+ return ret;
+}
+
static struct cs8427_platform_data cs8427_i2c_platform_data = {
.irq = SX150X_GPIO(1, 4),
.reset_gpio = SX150X_GPIO(1, 6),
+ .enable = enable_100KHz_ls,
};
static struct i2c_board_info cs8427_device_info[] __initdata = {
diff --git a/include/sound/cs8427.h b/include/sound/cs8427.h
index cf7903a..2004ec3 100644
--- a/include/sound/cs8427.h
+++ b/include/sound/cs8427.h
@@ -209,6 +209,7 @@
int irq_base;
int num_irqs;
int reset_gpio;
+ int (*enable) (int enable);
};
struct snd_pcm_substream;
diff --git a/sound/soc/codecs/cs8427.c b/sound/soc/codecs/cs8427.c
index e63e4b4..aa6a9a7 100644
--- a/sound/soc/codecs/cs8427.c
+++ b/sound/soc/codecs/cs8427.c
@@ -649,6 +649,16 @@
struct cs8427_platform_data *pdata = chip->client->dev.platform_data;
int ret = 0;
+ /*enable the 100KHz level shifter*/
+ if (pdata->enable) {
+ ret = pdata->enable(1);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "failed to enable the level shifter\n");
+ return ret;
+ }
+ }
+
ret = gpio_request(pdata->reset_gpio, "cs8427 reset");
if (ret < 0) {
dev_err(&chip->client->dev,
@@ -843,6 +853,8 @@
}
pdata = chip->client->dev.platform_data;
gpio_free(pdata->reset_gpio);
+ if (pdata->enable)
+ pdata->enable(0);
kfree(chip);
return 0;
}