From: Peter Ujfalusi <peter.ujfalusi@ti.com> To: Samuel Ortiz <samuel.ortiz@intel.com>, Dmitry Torokhov <dtor@mail.ru>, Mark Brown <broonie@opensource.wolfsonmicro.com>, Liam Girdwood <lrg@ti.com> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Misael Lopez Cruz <misael.lopez@ti.com>, linux-input@vger.kernel.org Subject: [PATCH 2/8] MFD: twl6040: Cache the vibra control registers Date: Thu, 15 Sep 2011 15:59:15 +0300 [thread overview] Message-ID: <1316091561-30899-3-git-send-email-peter.ujfalusi@ti.com> (raw) In-Reply-To: <1316091561-30899-1-git-send-email-peter.ujfalusi@ti.com> The vibra control register will be used from the ASoC codec driver as well. In order to avoid latency issues caused by I2C read access, cache the two control register within the core driver, so we do not need to reach out to the chip to read it back. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> --- drivers/mfd/twl6040-core.c | 19 +++++++++++++++---- include/linux/mfd/twl6040.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c index 7dc8c47..75987c8 100644 --- a/drivers/mfd/twl6040-core.c +++ b/drivers/mfd/twl6040-core.c @@ -34,16 +34,24 @@ #include <linux/mfd/core.h> #include <linux/mfd/twl6040.h> +#define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) + int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) { int ret; u8 val = 0; mutex_lock(&twl6040->io_mutex); - ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); - if (ret < 0) { - mutex_unlock(&twl6040->io_mutex); - return ret; + /* 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 = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); + if (ret < 0) { + mutex_unlock(&twl6040->io_mutex); + return ret; + } } mutex_unlock(&twl6040->io_mutex); @@ -57,6 +65,9 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val) mutex_lock(&twl6040->io_mutex); ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg); + /* Cache the vibra control registers */ + if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) + twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; mutex_unlock(&twl6040->io_mutex); return ret; diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h index 6059935..3ec9591 100644 --- a/include/linux/mfd/twl6040.h +++ b/include/linux/mfd/twl6040.h @@ -185,6 +185,7 @@ struct twl6040 { int audpwron; int power_count; int rev; + u8 vibra_ctrl_cache[2]; int pll; unsigned int sysclk; -- 1.7.6.1
WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com> To: Samuel Ortiz <samuel.ortiz@intel.com>, Dmitry Torokhov <dtor@mail.ru>, Mark Brown <broonie@opensource.wolfsonmicro.com>, Liam Girdwood <lrg@ti.com> Cc: alsa-devel@alsa-project.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Misael Lopez Cruz <misael.lopez@ti.com> Subject: [PATCH 2/8] MFD: twl6040: Cache the vibra control registers Date: Thu, 15 Sep 2011 15:59:15 +0300 [thread overview] Message-ID: <1316091561-30899-3-git-send-email-peter.ujfalusi@ti.com> (raw) In-Reply-To: <1316091561-30899-1-git-send-email-peter.ujfalusi@ti.com> The vibra control register will be used from the ASoC codec driver as well. In order to avoid latency issues caused by I2C read access, cache the two control register within the core driver, so we do not need to reach out to the chip to read it back. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> --- drivers/mfd/twl6040-core.c | 19 +++++++++++++++---- include/linux/mfd/twl6040.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c index 7dc8c47..75987c8 100644 --- a/drivers/mfd/twl6040-core.c +++ b/drivers/mfd/twl6040-core.c @@ -34,16 +34,24 @@ #include <linux/mfd/core.h> #include <linux/mfd/twl6040.h> +#define VIBRACTRL_MEMBER(reg) ((reg == TWL6040_REG_VIBCTLL) ? 0 : 1) + int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg) { int ret; u8 val = 0; mutex_lock(&twl6040->io_mutex); - ret = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); - if (ret < 0) { - mutex_unlock(&twl6040->io_mutex); - return ret; + /* 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 = twl_i2c_read_u8(TWL_MODULE_AUDIO_VOICE, &val, reg); + if (ret < 0) { + mutex_unlock(&twl6040->io_mutex); + return ret; + } } mutex_unlock(&twl6040->io_mutex); @@ -57,6 +65,9 @@ int twl6040_reg_write(struct twl6040 *twl6040, unsigned int reg, u8 val) mutex_lock(&twl6040->io_mutex); ret = twl_i2c_write_u8(TWL_MODULE_AUDIO_VOICE, val, reg); + /* Cache the vibra control registers */ + if (reg == TWL6040_REG_VIBCTLL || reg == TWL6040_REG_VIBCTLR) + twl6040->vibra_ctrl_cache[VIBRACTRL_MEMBER(reg)] = val; mutex_unlock(&twl6040->io_mutex); return ret; diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h index 6059935..3ec9591 100644 --- a/include/linux/mfd/twl6040.h +++ b/include/linux/mfd/twl6040.h @@ -185,6 +185,7 @@ struct twl6040 { int audpwron; int power_count; int rev; + u8 vibra_ctrl_cache[2]; int pll; unsigned int sysclk; -- 1.7.6.1
next prev parent reply other threads:[~2011-09-15 12:59 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-09-15 12:59 [PATCH 0/8] ASoC/MFD/Input: twl6040: Support for audio driven vibra Peter Ujfalusi 2011-09-15 12:59 ` [PATCH 1/8] Input: twl6040: Simplify vibra regsiter definitions Peter Ujfalusi 2011-09-15 12:59 ` Peter Ujfalusi [this message] 2011-09-15 12:59 ` [PATCH 2/8] MFD: twl6040: Cache the vibra control registers Peter Ujfalusi 2011-09-15 12:59 ` [PATCH 3/8] MFD: twl6040: function to query the vibra status for clients Peter Ujfalusi 2011-09-15 12:59 ` Peter Ujfalusi 2011-09-15 12:59 ` [PATCH 4/8] Input: twl6040-vibra: Check the selected path for vibra Peter Ujfalusi 2011-09-16 6:27 ` Dmitry Torokhov 2011-09-16 6:42 ` Péter Ujfalusi 2011-09-16 6:42 ` Péter Ujfalusi 2011-09-24 6:00 ` Dmitry Torokhov 2011-09-24 6:00 ` Dmitry Torokhov 2011-09-26 6:41 ` Péter Ujfalusi 2011-09-26 6:41 ` Péter Ujfalusi 2011-09-16 9:26 ` Liam Girdwood 2011-09-16 11:11 ` Péter Ujfalusi 2011-09-16 11:11 ` Péter Ujfalusi 2011-09-15 12:59 ` [PATCH 5/8] ASoC: twl6040: Fix the number of channels " Peter Ujfalusi 2011-09-19 22:17 ` [alsa-devel] " Mark Brown 2011-09-15 12:59 ` [PATCH 6/8] ASoC: twl6040: Correct supported number of playback channels Peter Ujfalusi 2011-09-19 22:17 ` [alsa-devel] " Mark Brown 2011-09-15 12:59 ` [PATCH 7/8] ASoC: omap-mcpdm: Correct the supported number of channels Peter Ujfalusi 2011-09-19 22:17 ` [alsa-devel] " Mark Brown 2011-09-19 22:17 ` Mark Brown 2011-09-20 10:57 ` [alsa-devel] " Mark Brown 2011-09-20 11:10 ` Péter Ujfalusi 2011-09-20 11:10 ` Péter Ujfalusi 2011-09-20 11:19 ` Liam Girdwood 2011-09-20 11:19 ` Liam Girdwood 2011-09-20 11:24 ` Re: Re: [alsa-devel] " Péter Ujfalusi 2011-09-20 11:24 ` Péter Ujfalusi 2011-09-20 11:35 ` Mark Brown 2011-09-20 11:35 ` Mark Brown 2011-09-15 12:59 ` [PATCH 8/8] ASoC: twl6040: Support for vibra output paths Peter Ujfalusi 2011-09-21 13:12 ` Péter Ujfalusi 2011-09-21 13:12 ` Péter Ujfalusi 2011-09-21 13:26 ` Mark Brown 2011-09-21 13:26 ` Mark Brown 2011-09-21 13:10 ` [PATCH 0/8] ASoC/MFD/Input: twl6040: Support for audio driven vibra Péter Ujfalusi 2011-09-21 13:10 ` Péter Ujfalusi
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1316091561-30899-3-git-send-email-peter.ujfalusi@ti.com \ --to=peter.ujfalusi@ti.com \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@opensource.wolfsonmicro.com \ --cc=dtor@mail.ru \ --cc=linux-input@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lrg@ti.com \ --cc=misael.lopez@ti.com \ --cc=samuel.ortiz@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.