From patchwork Thu Jan 31 09:03:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 2071531 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 9CC9FDF2E5 for ; Thu, 31 Jan 2013 09:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001Ab3AaJDt (ORCPT ); Thu, 31 Jan 2013 04:03:49 -0500 Received: from mail-da0-f42.google.com ([209.85.210.42]:37345 "EHLO mail-da0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604Ab3AaJDs (ORCPT ); Thu, 31 Jan 2013 04:03:48 -0500 Received: by mail-da0-f42.google.com with SMTP id z17so1213688dal.1 for ; Thu, 31 Jan 2013 01:03:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:sender:message-id:to:cc:in-reply-to:references:from :subject:mime-version:content-type; bh=1IQsRA2vrAAO4Q1PD0xy4syDKb8koA076e596aqXtmg=; b=IKvMapElSlSF3Y8uxpjTs3Lm+hM0/NYx7MahAeVyMGAOsgZrzANObLF2JgjfjrlkLL 8R8luvsV6D3lpFutb+whzYJJN/4/C10+ktTZOBJjRpi2KgeMOtXBUqI5ogVzDwFUA0+c spVjnkFgRVwCe4DdNvp1iSQrtSlqtz4Xn1KDRje42SCIpHwnu04MkzASGU/FobJMm5X/ iEoCQInYRKFnt4JZC2VP9i3PqUUThzndqk4Rj0vhvKahjtuK/Hsk0H+7WTrpMovgi0KE R+6xZUY+9vGRxlwdRVKGzJhaTWeBH/Wh0M58UKW5QDm8ntJTJMV6YOkPwiJp8Rns8qmd Vijw== X-Received: by 10.68.238.106 with SMTP id vj10mr20589026pbc.40.1359623027589; Thu, 31 Jan 2013 01:03:47 -0800 (PST) Received: from morimoto-Dell-XPS420.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPS id mn4sm4435230pbc.12.2013.01.31.01.03.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 31 Jan 2013 01:03:46 -0800 (PST) Date: Thu, 31 Jan 2013 01:03:46 -0800 (PST) Message-ID: <87r4l1pvv4.wl%kuninori.morimoto.gx@renesas.com> To: Zhang Rui Cc: Simon , Magnus , linux-pm@vger.kernel.org, Kuninori Morimoto In-Reply-To: <87y5f9pvxv.wl%kuninori.morimoto.gx@renesas.com> References: <87y5f9pvxv.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 5/7] thermal: rcar: add read/write functions for common/priv data MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org R-Car thermal driver will use struct common in next feature (interrupt support). But the register address is different between struct priv and common. This patch adds read/write functions for struct common, and use macro technique to avoid wrong register access. This is preparation patch for next feature (interrupt support), therefore, there is no user to use this common read/write function at this point. Signed-off-by: Kuninori Morimoto --- drivers/thermal/rcar_thermal.c | 48 ++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c index 1ba0277..cf6aa98 100644 --- a/drivers/thermal/rcar_thermal.c +++ b/drivers/thermal/rcar_thermal.c @@ -29,8 +29,8 @@ #define IDLE_INTERVAL 5000 -#define THSCR 0x2c -#define THSSR 0x30 +#define REG_THSCR 0x2c +#define REG_THSSR 0x30 /* THSCR */ #define CPCTL (1 << 12) @@ -63,21 +63,55 @@ struct rcar_thermal_priv { /* * basic functions */ -static u32 rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) +#if 0 +#define rcar_thermal_common_read(c, r) \ + _rcar_thermal_common_read(c, COMMON_ ##r) +static u32 _rcar_thermal_common_read(struct rcar_thermal_common *common, + u32 reg) +{ + return ioread32(common->base + reg); +} + +#define rcar_thermal_common_write(c, r, d) \ + _rcar_thermal_common_write(c, COMMON_ ##r, d) +static void _rcar_thermal_common_write(struct rcar_thermal_common *common, + u32 reg, u32 data) +{ + iowrite32(data, common->base + reg); +} + +#define rcar_thermal_common_bset(c, r, m, d) \ + _rcar_thermal_common_bset(c, COMMON_ ##r, m, d) +static void _rcar_thermal_common_bset(struct rcar_thermal_common *common, + u32 reg, u32 mask, u32 data) +{ + u32 val; + + val = ioread32(common->base + reg); + val &= ~mask; + val |= (data & mask); + iowrite32(val, common->base + reg); +} +#endif + +#define rcar_thermal_read(p, r) _rcar_thermal_read(p, REG_ ##r) +static u32 _rcar_thermal_read(struct rcar_thermal_priv *priv, u32 reg) { return ioread32(priv->base + reg); } #if 0 /* no user at this point */ -static void rcar_thermal_write(struct rcar_thermal_priv *priv, - u32 reg, u32 data) +#define rcar_thermal_write(p, r, d) _rcar_thermal_write(p, REG_ ##r, d) +static void _rcar_thermal_write(struct rcar_thermal_priv *priv, + u32 reg, u32 data) { iowrite32(data, priv->base + reg); } #endif -static void rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, - u32 mask, u32 data) +#define rcar_thermal_bset(p, r, m, d) _rcar_thermal_bset(p, REG_ ##r, m, d) +static void _rcar_thermal_bset(struct rcar_thermal_priv *priv, u32 reg, + u32 mask, u32 data) { u32 val;