Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2562848yba; Mon, 15 Apr 2019 14:30:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5rJ12cNOgquaHtwRoI91i+ZpRMiGcvsDiOPJpSODqkkSmjW1c6Y84AYyXw77imebNuAOS X-Received: by 2002:a17:902:7c01:: with SMTP id x1mr52132904pll.299.1555363846262; Mon, 15 Apr 2019 14:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555363846; cv=none; d=google.com; s=arc-20160816; b=TuGIxiwNrngp3O8rk6K8OFszs33rHcNjr9AuRRUhIWfRkB+fUe+FU/Ln5dZsiFjJjp WkVk9INPCu+11LIvnYvikGTM8bIpkFZda91HcJ2R0Il1RTTLHqpaO2PvwCdI+0sMjSkR 70W59vc0+ODA+/FwG6dBArxYNan3/1bER/67SkIpI7wwHM3FPjGrvZtQ288j4v+hKX+c zLAEFJRpPuSB+cBk/OymurJFMQp94MSn76tyUKQuEnj+v9ESSdrNswc1uZX9cTe5N9x+ DDOVMuE+2eeJZAadX1g5XgalWA45bJc4gmQtKxetMGwpCchJtogIrNwHIXQVWINC65n0 IbmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nvH/QpAsNp9fKJBfzeJ9lVADPlRSPY/qVQRxotQYpxQ=; b=D676uY4R1GuiPlROKjdiorjzgMIiEkx9uF1ut/sJE1Mam7iVa8Z3Tf5SWL5O8IpQPm jX3M9yUNPj0NSJFy9vweAm/xV7CVLLCXqiouRbnSvdwY5bVhoa3JWKeE1elBUDss32kB N/s+I+ncZryVyP/0+hGJ9JSTpMlj4G25XbIhCSUdGN50wqBk+bIOt1ACFhb6glOynKj7 rTGznG8x5NH1h8hNS3l7+LCpSrMHNUQBEWt88z5gQurdU4QktW2GHDm7T/x4btLwWbvL nWcZIACpbBv2zCE0W+e5wGzterAf5X0BmGLD8gveStUPIMAjxrZxMtiBCB7+LYqRsrGp okbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si25848639pfo.49.2019.04.15.14.30.30; Mon, 15 Apr 2019 14:30:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbfDOV3y (ORCPT + 99 others); Mon, 15 Apr 2019 17:29:54 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46882 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726939AbfDOV3x (ORCPT ); Mon, 15 Apr 2019 17:29:53 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: gportay) with ESMTPSA id C9BB9284191 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Rob Herring , Heiko Stuebner , Enric Balletbo i Serra , Lin Huang , Brian Norris , Douglas Anderson , Klaus Goger , Derek Basehore , Randy Li , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Cc: Mark Rutland , =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Subject: [PATCH v4 1/5] devfreq: rockchip-dfi: Move GRF definitions to a common place. Date: Mon, 15 Apr 2019 17:29:44 -0400 Message-Id: <20190415212948.7736-2-gael.portay@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415212948.7736-1-gael.portay@collabora.com> References: <20190415212948.7736-1-gael.portay@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Enric Balletbo i Serra Some rk3399 GRF (Generic Register Files) definitions can be used for different drivers. Move these definitions to a common include so we don't need to duplicate these definitions. Signed-off-by: Enric Balletbo i Serra Acked-by: Chanwoo Choi Signed-off-by: Gaël PORTAY Acked-by: MyungJoo Ham --- Changes in v4: - [PATCH v3 1/5] Add Acked-by: MyungJoo Ham . Changes in v3: - [PATCH v2 1/5] Add Signed-off-by: Gaël PORTAY . Changes in v2: - [PATCH 1/8] Really add Acked-by: Chanwoo Choi . Changes in v1: - [RFC 1/10] Add Acked-by: Chanwoo Choi - [RFC 1/10] s/Generic/General/ (Robin Murphy) - [RFC 4/10] Removed from the series. I did not found a use case where not holding the mutex causes the issue. - [RFC 7/10] Removed from the series. I did not found a use case where this matters. drivers/devfreq/event/rockchip-dfi.c | 23 +++++++---------------- include/soc/rockchip/rk3399_grf.h | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 include/soc/rockchip/rk3399_grf.h diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c index 22b113363ffc..2fbbcbeb644f 100644 --- a/drivers/devfreq/event/rockchip-dfi.c +++ b/drivers/devfreq/event/rockchip-dfi.c @@ -26,6 +26,8 @@ #include #include +#include + #define RK3399_DMC_NUM_CH 2 /* DDRMON_CTRL */ @@ -43,18 +45,6 @@ #define DDRMON_CH1_COUNT_NUM 0x3c #define DDRMON_CH1_DFI_ACCESS_NUM 0x40 -/* pmu grf */ -#define PMUGRF_OS_REG2 0x308 -#define DDRTYPE_SHIFT 13 -#define DDRTYPE_MASK 7 - -enum { - DDR3 = 3, - LPDDR3 = 6, - LPDDR4 = 7, - UNUSED = 0xFF -}; - struct dmc_usage { u32 access; u32 total; @@ -83,16 +73,17 @@ static void rockchip_dfi_start_hardware_counter(struct devfreq_event_dev *edev) u32 ddr_type; /* get ddr type */ - regmap_read(info->regmap_pmu, PMUGRF_OS_REG2, &val); - ddr_type = (val >> DDRTYPE_SHIFT) & DDRTYPE_MASK; + regmap_read(info->regmap_pmu, RK3399_PMUGRF_OS_REG2, &val); + ddr_type = (val >> RK3399_PMUGRF_DDRTYPE_SHIFT) & + RK3399_PMUGRF_DDRTYPE_MASK; /* clear DDRMON_CTRL setting */ writel_relaxed(CLR_DDRMON_CTRL, dfi_regs + DDRMON_CTRL); /* set ddr type to dfi */ - if (ddr_type == LPDDR3) + if (ddr_type == RK3399_PMUGRF_DDRTYPE_LPDDR3) writel_relaxed(LPDDR3_EN, dfi_regs + DDRMON_CTRL); - else if (ddr_type == LPDDR4) + else if (ddr_type == RK3399_PMUGRF_DDRTYPE_LPDDR4) writel_relaxed(LPDDR4_EN, dfi_regs + DDRMON_CTRL); /* enable count, use software mode */ diff --git a/include/soc/rockchip/rk3399_grf.h b/include/soc/rockchip/rk3399_grf.h new file mode 100644 index 000000000000..3eebabcb2812 --- /dev/null +++ b/include/soc/rockchip/rk3399_grf.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Rockchip General Register Files definitions + * + * Copyright (c) 2018, Collabora Ltd. + * Author: Enric Balletbo i Serra + */ + +#ifndef __SOC_RK3399_GRF_H +#define __SOC_RK3399_GRF_H + +/* PMU GRF Registers */ +#define RK3399_PMUGRF_OS_REG2 0x308 +#define RK3399_PMUGRF_DDRTYPE_SHIFT 13 +#define RK3399_PMUGRF_DDRTYPE_MASK 7 +#define RK3399_PMUGRF_DDRTYPE_DDR3 3 +#define RK3399_PMUGRF_DDRTYPE_LPDDR2 5 +#define RK3399_PMUGRF_DDRTYPE_LPDDR3 6 +#define RK3399_PMUGRF_DDRTYPE_LPDDR4 7 + +#endif -- 2.21.0