All of lore.kernel.org
 help / color / mirror / Atom feed
From: Faiz Abbas <faiz_abbas@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 03/15] regmap: Add API regmap_init_mem_index()
Date: Wed, 29 May 2019 15:15:03 +0530	[thread overview]
Message-ID: <20190529094515.13517-4-faiz_abbas@ti.com> (raw)
In-Reply-To: <20190529094515.13517-1-faiz_abbas@ti.com>

In device nodes with more than one entry in the reg property,
it is sometimes useful to regmap only of the entries. Add an
API regmap_init_mem_index() to facilitate this.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
 drivers/core/regmap.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 include/regmap.h      |  2 ++
 2 files changed, 44 insertions(+)

diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index 5ef0f71c8b..d1d12eef38 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -108,6 +108,48 @@ static int init_range(ofnode node, struct regmap_range *range, int addr_len,
 	return 0;
 }
 
+int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index)
+{
+	struct regmap *map;
+	int addr_len, size_len;
+	int ret;
+
+	addr_len = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
+	if (addr_len < 0) {
+		debug("%s: Error while reading the addr length (ret = %d)\n",
+		      ofnode_get_name(node), addr_len);
+		return addr_len;
+	}
+
+	size_len = ofnode_read_simple_size_cells(ofnode_get_parent(node));
+	if (size_len < 0) {
+		debug("%s: Error while reading the size length: (ret = %d)\n",
+		      ofnode_get_name(node), size_len);
+		return size_len;
+	}
+
+	map = regmap_alloc(1);
+	if (!map)
+		return -ENOMEM;
+
+	ret = init_range(node, map->ranges, addr_len, size_len, index);
+	if (ret)
+		return ret;
+
+	if (ofnode_read_bool(node, "little-endian"))
+		map->endianness = REGMAP_LITTLE_ENDIAN;
+	else if (ofnode_read_bool(node, "big-endian"))
+		map->endianness = REGMAP_BIG_ENDIAN;
+	else if (ofnode_read_bool(node, "native-endian"))
+		map->endianness = REGMAP_NATIVE_ENDIAN;
+	else /* Default: native endianness */
+		map->endianness = REGMAP_NATIVE_ENDIAN;
+
+	*mapp = map;
+
+	return ret;
+}
+
 int regmap_init_mem(ofnode node, struct regmap **mapp)
 {
 	struct regmap_range *range;
diff --git a/include/regmap.h b/include/regmap.h
index 3cd7a66cea..0854200a9c 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -330,6 +330,8 @@ int regmap_init_mem(ofnode node, struct regmap **mapp);
 int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count,
 			     struct regmap **mapp);
 
+int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index);
+
 /**
  * regmap_get_range() - Obtain the base memory address of a regmap range
  *
-- 
2.19.2

  parent reply	other threads:[~2019-05-29  9:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  9:45 [U-Boot] [PATCH v5 00/15] Add Support for eMMC in Am65x-evm Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 01/15] arm64: dts: k3: Sync sdhci0 node from kernel and change driver name Faiz Abbas
2019-06-04  5:28   ` Lokesh Vutla
2019-06-04 13:12     ` Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 02/15] mmc: am654_sdhci: Remove quirks Faiz Abbas
2019-05-29  9:45 ` Faiz Abbas [this message]
2019-05-29  9:45 ` [U-Boot] [PATCH v5 04/15] mmc: sdhci: Add support for sdhci-caps-mask Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 05/15] mmc: sdhci: Make sdhci_set_clock() non static Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 06/15] arm: dts: k3: Add phy specific properties to SD card node Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 07/15] mmc: sdhci: Make set_ios_post() return int Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 08/15] mmc: am654_sdhci: Add Support for PHY Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 09/15] configs: am65x_evm: Enable CONFIG_REGMAP Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 10/15] mmc: am654_sdhci: Use f_max in mmc_config Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 11/15] mmc: sdhci: Add support for HOST_CONTROL2 and setting UHS timings Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 12/15] mmc: am654_sdhci: Add a platform specific set_control_reg() callback Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 13/15] configs: am65x: Add configs to support environment in eMMC Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 14/15] am65x_evm: Add Support for creating a filesystem GPT partition " Faiz Abbas
2019-05-29  9:45 ` [U-Boot] [PATCH v5 15/15] configs: am65x_evm_a53: Add Support for creating GPT partitions Faiz Abbas

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=20190529094515.13517-4-faiz_abbas@ti.com \
    --to=faiz_abbas@ti.com \
    --cc=u-boot@lists.denx.de \
    /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.