From patchwork Tue Sep 9 23:06:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 4873301 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CB774C0338 for ; Tue, 9 Sep 2014 23:06:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBA02201B4 for ; Tue, 9 Sep 2014 23:06:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07D592018E for ; Tue, 9 Sep 2014 23:06:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRUUr-00020Q-MS; Tue, 09 Sep 2014 23:06:49 +0000 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRUUk-0001xp-IX for linux-rockchip@lists.infradead.org; Tue, 09 Sep 2014 23:06:43 +0000 Received: by mail-pd0-f174.google.com with SMTP id v10so9928581pde.19 for ; Tue, 09 Sep 2014 16:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=oM/Eiu1o+jR6u5IJT6VwQAB2PtT8sDz313eQm0teiog=; b=GBnpQl8zOovJT/fWsWCu7YsQFHyKRDvY0PNfGeabYXGk+T3Hm/dWAQX1RhktO3UOy2 SnQB/iB4AGGBrZYqhj+ESpC5xAMJQUS2aPI8Lgpgd5hffKb+Fa5X+EB2T4xxnG6grteL u6dsExvFt9OcJtO6HcNboRPOwVDEn/rXAR/zM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oM/Eiu1o+jR6u5IJT6VwQAB2PtT8sDz313eQm0teiog=; b=aCR+Z+6WOjQ9zsroyvB1wGN5t7nmt0INF55R6bnymMKDB3WGhKJabG89FTNcO3Xnjv IwZg0rmgJdyINuOrMbpjzSYX5+T6h6sU9/QoUjIP0ZDovyAA7YM6nciyUbI5pmYh0muo uY1730kTW0EMQlxtNbIcB57Ek7gjp7Alv4JYsWb6ddzuPmNQLjf4wskYhjWgxv3eFQ6n ZK1Q7WRCD9aiNc83XS0pSwIskEVQ22dMMI758Axk4ymBQ27u9vZUPmYjKBau1HnG3y9p G1n66f9OfkI1OE1AmKjfjcmsAkpr6LXDKQ28nZeezfYyJJuH8CcuCcMKZ8eyM+2ysc5Q 4RgQ== X-Gm-Message-State: ALoCoQnLBDIS9nDgpceA/6pZiYA/+9VxhuSg7ayisUN2ixHpI+PRERsgQOZ9b5LLaTiJajUZFW6j X-Received: by 10.68.213.100 with SMTP id nr4mr6208925pbc.146.1410303979017; Tue, 09 Sep 2014 16:06:19 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.15]) by mx.google.com with ESMTPSA id t16sm12744982pdl.32.2014.09.09.16.06.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 16:06:18 -0700 (PDT) From: Doug Anderson To: Lee Jones , Chris Zhong , Heiko Stuebner Subject: [PATCH] mfd: RK808: Add register caching Date: Tue, 9 Sep 2014 16:06:04 -0700 Message-Id: <1410303964-6943-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140909_160642_632473_532CAD26 X-CRM114-Status: GOOD ( 11.71 ) X-Spam-Score: -0.8 (/) Cc: sameo@linux.intel.com, linux-kernel@vger.kernel.org, Doug Anderson , linux-rockchip@lists.infradead.org, Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Chris Zhong --- 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[] = {