From: zyw@rock-chips.com (Chris Zhong)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mfd: RK808: Add register caching
Date: Thu, 11 Sep 2014 11:39:23 +0800 [thread overview]
Message-ID: <5411196B.6000507@rock-chips.com> (raw)
In-Reply-To: <1410303964-6943-1-git-send-email-dianders@chromium.org>
On 09/10/2014 07:06 AM, Doug Anderson wrote:
> Let's define the voltatile registers (those that can't be cached) and
> enable caching. The rk808 is accessed almost constantly with cpufreq
> so this is really nice.
>
> As measured by ftrace:
> before this change: cpu0_set_target() => ~2200us
> after this change: cpu0_set_target() => ~500us
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
> drivers/mfd/rk808.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index 0324422..bd02150 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -29,10 +29,40 @@ struct rk808_reg_data {
> int value;
> };
>
> +static bool rk808_is_volatile_reg(struct device *dev, unsigned int reg)
> +{
> + /*
> + * Notes:
> + * - Technically the ROUND_30s bit makes RTC_CTRL_REG volatile, but
> + * we don't use that feature. It's better to cache.
> + * - It's unlikely we care that RK808_DEVCTRL_REG is volatile since
> + * bits are cleared in case when we shutoff anyway, but better safe.
> + */
> +
> + switch (reg) {
> + case RK808_SECONDS_REG ... RK808_WEEKS_REG:
> + case RK808_RTC_STATUS_REG:
> + case RK808_VB_MON_REG:
> + case RK808_THERMAL_REG:
> + case RK808_DCDC_UV_STS_REG:
> + case RK808_LDO_UV_STS_REG:
> + case RK808_DCDC_PG_REG:
> + case RK808_LDO_PG_REG:
> + case RK808_DEVCTRL_REG:
> + case RK808_INT_STS_REG1:
> + case RK808_INT_STS_REG2:
> + return true;
> + }
> +
> + return false;
> +}
> +
> static const struct regmap_config rk808_regmap_config = {
> .reg_bits = 8,
> .val_bits = 8,
> .max_register = RK808_IO_POL_REG,
> + .cache_type = REGCACHE_RBTREE,
> + .volatile_reg = rk808_is_volatile_reg,
> };
>
> static struct resource rtc_resources[] = {
Reviewed-by: Chris Zhong <zyw@rock-chips.com>
WARNING: multiple messages have this Message-ID (diff)
From: Chris Zhong <zyw@rock-chips.com>
To: Doug Anderson <dianders@chromium.org>,
Lee Jones <lee.jones@linaro.org>,
Heiko Stuebner <heiko@sntech.de>
Cc: linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org,
Sonny Rao <sonnyrao@chromium.org>,
sameo@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: RK808: Add register caching
Date: Thu, 11 Sep 2014 11:39:23 +0800 [thread overview]
Message-ID: <5411196B.6000507@rock-chips.com> (raw)
In-Reply-To: <1410303964-6943-1-git-send-email-dianders@chromium.org>
On 09/10/2014 07:06 AM, Doug Anderson wrote:
> Let's define the voltatile registers (those that can't be cached) and
> enable caching. The rk808 is accessed almost constantly with cpufreq
> so this is really nice.
>
> As measured by ftrace:
> before this change: cpu0_set_target() => ~2200us
> after this change: cpu0_set_target() => ~500us
>
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
> drivers/mfd/rk808.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index 0324422..bd02150 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -29,10 +29,40 @@ struct rk808_reg_data {
> int value;
> };
>
> +static bool rk808_is_volatile_reg(struct device *dev, unsigned int reg)
> +{
> + /*
> + * Notes:
> + * - Technically the ROUND_30s bit makes RTC_CTRL_REG volatile, but
> + * we don't use that feature. It's better to cache.
> + * - It's unlikely we care that RK808_DEVCTRL_REG is volatile since
> + * bits are cleared in case when we shutoff anyway, but better safe.
> + */
> +
> + switch (reg) {
> + case RK808_SECONDS_REG ... RK808_WEEKS_REG:
> + case RK808_RTC_STATUS_REG:
> + case RK808_VB_MON_REG:
> + case RK808_THERMAL_REG:
> + case RK808_DCDC_UV_STS_REG:
> + case RK808_LDO_UV_STS_REG:
> + case RK808_DCDC_PG_REG:
> + case RK808_LDO_PG_REG:
> + case RK808_DEVCTRL_REG:
> + case RK808_INT_STS_REG1:
> + case RK808_INT_STS_REG2:
> + return true;
> + }
> +
> + return false;
> +}
> +
> static const struct regmap_config rk808_regmap_config = {
> .reg_bits = 8,
> .val_bits = 8,
> .max_register = RK808_IO_POL_REG,
> + .cache_type = REGCACHE_RBTREE,
> + .volatile_reg = rk808_is_volatile_reg,
> };
>
> static struct resource rtc_resources[] = {
Reviewed-by: Chris Zhong <zyw@rock-chips.com>
next prev parent reply other threads:[~2014-09-11 3:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 23:06 [PATCH] mfd: RK808: Add register caching Doug Anderson
2014-09-09 23:06 ` Doug Anderson
2014-09-11 3:39 ` Chris Zhong [this message]
2014-09-11 3:39 ` Chris Zhong
2014-09-17 16:09 ` Lee Jones
2014-09-17 16:09 ` Lee Jones
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=5411196B.6000507@rock-chips.com \
--to=zyw@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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: link
Be 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.