From patchwork Fri Jun 5 20:30:21 2020
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 1304367
X-Patchwork-Delegate: trini@ti.com
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Authentication-Results: ozlabs.org;
spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
(client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
envelope-from=u-boot-bounces@lists.denx.de; receiver=)
Authentication-Results: ozlabs.org;
dmarc=pass (p=quarantine dis=none) header.from=ti.com
Authentication-Results: ozlabs.org;
dkim=pass (1024-bit key;
unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256
header.s=ti-com-17Q1 header.b=Ji7JS20v;
dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
[IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (4096 bits))
(No client certificate requested)
by ozlabs.org (Postfix) with ESMTPS id 49dvSJ4bZqz9sPF
for ; Sat, 6 Jun 2020 06:31:28 +1000 (AEST)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
by phobos.denx.de (Postfix) with ESMTP id E27BC81EFE;
Fri, 5 Jun 2020 22:30:47 +0200 (CEST)
Authentication-Results: phobos.denx.de;
dmarc=pass (p=quarantine dis=none) header.from=ti.com
Authentication-Results: phobos.denx.de;
spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
dkim=pass (1024-bit key;
unprotected) header.d=ti.com header.i=@ti.com header.b="Ji7JS20v";
dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
id 362D881EED; Fri, 5 Jun 2020 22:30:42 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level:
X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,
DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED
autolearn=ham autolearn_force=no version=3.4.2
Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by phobos.denx.de (Postfix) with ESMTPS id 4B84C81EDF
for ; Fri, 5 Jun 2020 22:30:38 +0200 (CEST)
Authentication-Results: phobos.denx.de;
dmarc=pass (p=quarantine dis=none) header.from=ti.com
Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com
Received: from lelv0265.itg.ti.com ([10.180.67.224])
by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 055KUaG3071645;
Fri, 5 Jun 2020 15:30:36 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1591389036;
bh=dLy5/jNrVbYZtoo1/Y42sxRxoHIE3NUbTfOLN7bfCHM=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=Ji7JS20vkLsdSF+s4RI/TZwLRkp8G0S4Ym7zMJ1pchonNYEuJMdKgbZi9/6APMD5S
iK3P/ejiT+/QqVnneZA60P3cTncTet/focBmGf4kDlbiABFOx4E/9h83cvRhZWKiF+
bof6E5zMtXMZYk9wE+1BC/HjFuUscyUz6hpUV8LQ=
Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41])
by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 055KUaqe060748
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Fri, 5 Jun 2020 15:30:36 -0500
Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE109.ent.ti.com
(157.170.170.41) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 5 Jun
2020 15:30:36 -0500
Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE114.ent.ti.com
(157.170.170.25) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via
Frontend Transport; Fri, 5 Jun 2020 15:30:36 -0500
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 055KUQVs024135;
Fri, 5 Jun 2020 15:30:34 -0500
From: Pratyush Yadav
To: Simon Glass ,
CC: Pratyush Yadav , Vignesh Raghavendra ,
Sekhar Nori
Subject: [PATCH v2 4/8] regmap: Allow left shifting register offset before
access
Date: Sat, 6 Jun 2020 02:00:21 +0530
Message-ID: <20200605203025.15466-5-p.yadav@ti.com>
X-Mailer: git-send-email 2.25.0
In-Reply-To: <20200605203025.15466-1-p.yadav@ti.com>
References: <20200605203025.15466-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.30rc1
Precedence: list
List-Id: U-Boot discussion
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot"
X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de
X-Virus-Status: Clean
Drivers can configure it to adjust the final read/write location.
Signed-off-by: Pratyush Yadav
Reviewed-by: Simon Glass
---
drivers/core/regmap.c | 6 +++++-
include/regmap.h | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index c71b961234..173ae80890 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -261,8 +261,10 @@ struct regmap *devm_regmap_init(struct udevice *dev,
return ERR_PTR(rc);
map = *mapp;
- if (config)
+ if (config) {
map->width = config->width;
+ map->reg_offset_shift = config->reg_offset_shift;
+ }
devres_add(dev, mapp);
return *mapp;
@@ -349,6 +351,7 @@ int regmap_raw_read_range(struct regmap *map, uint range_num, uint offset,
}
range = &map->ranges[range_num];
+ offset <<= map->reg_offset_shift;
if (offset + val_len > range->size) {
debug("%s: offset/size combination invalid\n", __func__);
return -ERANGE;
@@ -458,6 +461,7 @@ int regmap_raw_write_range(struct regmap *map, uint range_num, uint offset,
}
range = &map->ranges[range_num];
+ offset <<= map->reg_offset_shift;
if (offset + val_len > range->size) {
debug("%s: offset/size combination invalid\n", __func__);
return -ERANGE;
diff --git a/include/regmap.h b/include/regmap.h
index 19474e6de1..e6c59dfbce 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -82,9 +82,12 @@ struct regmap_bus;
*
* @width: Width of the read/write operations. Defaults to
* REGMAP_SIZE_32 if set to 0.
+ * @reg_offset_shift Left shift the register offset by this value before
+ * performing read or write.
*/
struct regmap_config {
enum regmap_size_t width;
+ u32 reg_offset_shift;
};
/**
@@ -92,12 +95,15 @@ struct regmap_config {
*
* @width: Width of the read/write operations. Defaults to
* REGMAP_SIZE_32 if set to 0.
+ * @reg_offset_shift Left shift the register offset by this value before
+ * performing read or write.
* @range_count: Number of ranges available within the map
* @ranges: Array of ranges
*/
struct regmap {
enum regmap_endianness_t endianness;
enum regmap_size_t width;
+ u32 reg_offset_shift;
int range_count;
struct regmap_range ranges[0];
};