All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3] dm: core: Add option to configure an offset for the address translation
@ 2015-12-14 15:18 Stefan Roese
  2015-12-19 22:23 ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2015-12-14 15:18 UTC (permalink / raw)
  To: u-boot

Some platforms need to ability to configure an offset to the standard
addresses extracted from the device-tree. This patch allows this by
adding a function to DM to configure this offset (if needed).

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
---
v3:
- Add comment to variable desclaration
- Remove unnecessary checks for "!root"

v2:
- Change translation_offset type from u32 to fdt_addr_t
- Add comments to function declarations

 drivers/core/device.c | 33 +++++++++++++++++++++------------
 drivers/core/root.c   | 21 +++++++++++++++++++++
 include/dm/device.h   | 21 +++++++++++++++++++++
 3 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 758f390..41fbbc6 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -597,22 +597,31 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
 		 * Use the full-fledged translate function for complex
 		 * bus setups.
 		 */
-		return fdt_translate_address((void *)gd->fdt_blob,
+		addr = fdt_translate_address((void *)gd->fdt_blob,
 					     dev->of_offset, reg);
+	} else {
+		/*
+		 * Use the "simple" translate function for less complex
+		 * bus setups.
+		 */
+		addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+							dev->parent->of_offset,
+							dev->of_offset, "reg",
+							0, NULL);
+		if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
+			if (device_get_uclass_id(dev->parent) ==
+			    UCLASS_SIMPLE_BUS)
+				addr = simple_bus_translate(dev->parent, addr);
+		}
 	}
 
 	/*
-	 * Use the "simple" translate function for less complex
-	 * bus setups.
-	 */
-	addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-						dev->parent->of_offset,
-						dev->of_offset, "reg",
-						0, NULL);
-	if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
-		if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS)
-			addr = simple_bus_translate(dev->parent, addr);
-	}
+	 * Some platforms need a special address translation. Those
+	 * platforms (e.g. mvebu in SPL) can configure a translation
+	 * offset in the DM by calling dm_set_translation_offset() that
+	 * will get added to all addresses returned by dev_get_addr().
+ 	 */
+	addr += dm_get_translation_offset();
 
 	return addr;
 #else
diff --git a/drivers/core/root.c b/drivers/core/root.c
index e7b1f24..13c2713 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -23,6 +23,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+struct root_priv {
+	fdt_addr_t translation_offset;	/* optional translation offset */
+};
+
 static const struct driver_info root_info = {
 	.name		= "root_driver",
 };
@@ -37,6 +41,22 @@ struct udevice *dm_root(void)
 	return gd->dm_root;
 }
 
+fdt_addr_t dm_get_translation_offset(void)
+{
+	struct udevice *root = dm_root();
+	struct root_priv *priv = dev_get_priv(root);
+
+	return priv->translation_offset;
+}
+
+void dm_set_translation_offset(fdt_addr_t offs)
+{
+	struct udevice *root = dm_root();
+	struct root_priv *priv = dev_get_priv(root);
+
+	priv->translation_offset = offs;
+}
+
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 void fix_drivers(void)
 {
@@ -228,6 +248,7 @@ int dm_init_and_scan(bool pre_reloc_only)
 U_BOOT_DRIVER(root_driver) = {
 	.name	= "root_driver",
 	.id	= UCLASS_ROOT,
+	.priv_auto_alloc_size = sizeof(struct root_priv),
 };
 
 /* This is the root uclass */
diff --git a/include/dm/device.h b/include/dm/device.h
index 7fb9935..d9fc7fb 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -776,4 +776,25 @@ static inline void devm_kfree(struct udevice *dev, void *ptr)
 
 #endif /* ! CONFIG_DEVRES */
 
+/**
+ * dm_set_translation_offset() - Set translation offset
+ * @offs: Translation offset
+ *
+ * Some platforms need a special address translation. Those
+ * platforms (e.g. mvebu in SPL) can configure a translation
+ * offset in the DM by calling this function. It will be
+ * added to all addresses returned in dev_get_addr().
+ */
+void dm_set_translation_offset(fdt_addr_t offs);
+
+/**
+ * dm_get_translation_offset() - Get translation offset
+ *
+ * This function returns the translation offset that can
+ * be configured by calling dm_set_translation_offset().
+ *
+ * @return translation offset for the device address (0 as default).
+ */
+fdt_addr_t dm_get_translation_offset(void);
+
 #endif
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3] dm: core: Add option to configure an offset for the address translation
  2015-12-14 15:18 [U-Boot] [PATCH v3] dm: core: Add option to configure an offset for the address translation Stefan Roese
@ 2015-12-19 22:23 ` Simon Glass
  2016-01-12 14:42   ` Stefan Roese
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2015-12-19 22:23 UTC (permalink / raw)
  To: u-boot

On 14 December 2015 at 08:18, Stefan Roese <sr@denx.de> wrote:
> Some platforms need to ability to configure an offset to the standard
> addresses extracted from the device-tree. This patch allows this by
> adding a function to DM to configure this offset (if needed).
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Acked-by: Simon Glass <sjg@chromium.org>
> Cc: Simon Glass <sjg@chromium.org>
> ---
> v3:
> - Add comment to variable desclaration
> - Remove unnecessary checks for "!root"
>
> v2:
> - Change translation_offset type from u32 to fdt_addr_t
> - Add comments to function declarations
>
>  drivers/core/device.c | 33 +++++++++++++++++++++------------
>  drivers/core/root.c   | 21 +++++++++++++++++++++
>  include/dm/device.h   | 21 +++++++++++++++++++++
>  3 files changed, 63 insertions(+), 12 deletions(-)

Fixed whitespace nit and:

Applied to u-boot-dm/next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3] dm: core: Add option to configure an offset for the address translation
  2015-12-19 22:23 ` Simon Glass
@ 2016-01-12 14:42   ` Stefan Roese
  2016-01-13 20:10     ` Simon Glass
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2016-01-12 14:42 UTC (permalink / raw)
  To: u-boot

On 19.12.2015 23:23, Simon Glass wrote:
> On 14 December 2015 at 08:18, Stefan Roese <sr@denx.de> wrote:
>> Some platforms need to ability to configure an offset to the standard
>> addresses extracted from the device-tree. This patch allows this by
>> adding a function to DM to configure this offset (if needed).
>>
>> Signed-off-by: Stefan Roese <sr@denx.de>
>> Acked-by: Simon Glass <sjg@chromium.org>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>> v3:
>> - Add comment to variable desclaration
>> - Remove unnecessary checks for "!root"
>>
>> v2:
>> - Change translation_offset type from u32 to fdt_addr_t
>> - Add comments to function declarations
>>
>>   drivers/core/device.c | 33 +++++++++++++++++++++------------
>>   drivers/core/root.c   | 21 +++++++++++++++++++++
>>   include/dm/device.h   | 21 +++++++++++++++++++++
>>   3 files changed, 63 insertions(+), 12 deletions(-)
>
> Fixed whitespace nit and:
>
> Applied to u-boot-dm/next.

Simon, just a quick question. Do you plan to send a pull request
for this next branch soon after the merge window open? I'm asking,
since I would like to prepare a Marvell / mvebu branch to pull
also quickly after the release. And this depends on this small
DM core patch.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v3] dm: core: Add option to configure an offset for the address translation
  2016-01-12 14:42   ` Stefan Roese
@ 2016-01-13 20:10     ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2016-01-13 20:10 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 12 January 2016 at 07:42, Stefan Roese <sr@denx.de> wrote:
> On 19.12.2015 23:23, Simon Glass wrote:
>>
>> On 14 December 2015 at 08:18, Stefan Roese <sr@denx.de> wrote:
>>>
>>> Some platforms need to ability to configure an offset to the standard
>>> addresses extracted from the device-tree. This patch allows this by
>>> adding a function to DM to configure this offset (if needed).
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Acked-by: Simon Glass <sjg@chromium.org>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> ---
>>> v3:
>>> - Add comment to variable desclaration
>>> - Remove unnecessary checks for "!root"
>>>
>>> v2:
>>> - Change translation_offset type from u32 to fdt_addr_t
>>> - Add comments to function declarations
>>>
>>>   drivers/core/device.c | 33 +++++++++++++++++++++------------
>>>   drivers/core/root.c   | 21 +++++++++++++++++++++
>>>   include/dm/device.h   | 21 +++++++++++++++++++++
>>>   3 files changed, 63 insertions(+), 12 deletions(-)
>>
>>
>> Fixed whitespace nit and:
>>
>> Applied to u-boot-dm/next.
>
>
> Simon, just a quick question. Do you plan to send a pull request
> for this next branch soon after the merge window open? I'm asking,
> since I would like to prepare a Marvell / mvebu branch to pull
> also quickly after the release. And this depends on this small
> DM core patch.

Yes, will do.

Regards,
Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-13 20:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-14 15:18 [U-Boot] [PATCH v3] dm: core: Add option to configure an offset for the address translation Stefan Roese
2015-12-19 22:23 ` Simon Glass
2016-01-12 14:42   ` Stefan Roese
2016-01-13 20:10     ` Simon Glass

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.