* [U-Boot] [PATCH 1/3] dm: spi: Add support for all targets which requires MANUAL_RELOC
@ 2015-10-27 15:01 Michal Simek
2015-10-27 15:01 ` [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation Michal Simek
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Michal Simek @ 2015-10-27 15:01 UTC (permalink / raw)
To: u-boot
It is follow up patch based on
"dm: Add support for all targets which requires MANUAL_RELOC"
(sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3)
to update function pointers for DM.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
drivers/spi/spi-uclass.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index d666272e39ce..27409fb088ea 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -118,6 +118,26 @@ static int spi_post_probe(struct udevice *bus)
spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
"spi-max-frequency", 0);
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
+ struct dm_spi_ops *ops = spi_get_ops(bus);
+
+
+ if (ops->claim_bus)
+ ops->claim_bus += gd->reloc_off;
+ if (ops->release_bus)
+ ops->release_bus += gd->reloc_off;
+ if (ops->set_wordlen)
+ ops->set_wordlen += gd->reloc_off;
+ if (ops->xfer)
+ ops->xfer += gd->reloc_off;
+ if (ops->set_speed)
+ ops->set_speed += gd->reloc_off;
+ if (ops->set_mode)
+ ops->set_mode += gd->reloc_off;
+ if (ops->cs_info)
+ ops->cs_info += gd->reloc_off;
+#endif
+
return 0;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation
2015-10-27 15:01 [U-Boot] [PATCH 1/3] dm: spi: Add support for all targets which requires MANUAL_RELOC Michal Simek
@ 2015-10-27 15:01 ` Michal Simek
2015-10-29 17:18 ` Simon Glass
2015-10-27 15:01 ` [U-Boot] [PATCH 3/3] dm: sf: Add support for all targets which requires MANUAL_RELOC Michal Simek
2015-10-29 17:19 ` [U-Boot] [PATCH 1/3] dm: spi: " Simon Glass
2 siblings, 1 reply; 7+ messages in thread
From: Michal Simek @ 2015-10-27 15:01 UTC (permalink / raw)
To: u-boot
Patches:
"dm: core: Add a post_bind method for parents"
(sha1: 0118ce79577f9b0881f99a6e4f8a79cd5014cb87)
"dm: core: Add a uclass pre_probe() method for devices"
(sha1: 02c07b3741f1b825934b1a6eb8f23530532dc426)
"dm: core: Allow the uclass to set up a device's child after binding"
(sha1: 081f2fcbd9a95ba10677065359791f8fea3f8c58)
"dm: core: Allow uclass to set up a device's child before it is probed"
(sha1: 83c7e434c9dd3ca81f8b763e23c1881b973bcf2f)
Adds new entries to struct driver and struct uclass_driver without
extending code for manual relocation. This patch fixes it for all
architectures which requires MANUAL_RELOC.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
drivers/core/root.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index bdb394a9ae21..e7b1f249682e 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -59,6 +59,8 @@ void fix_drivers(void)
entry->unbind += gd->reloc_off;
if (entry->ofdata_to_platdata)
entry->ofdata_to_platdata += gd->reloc_off;
+ if (entry->child_post_bind)
+ entry->child_post_bind += gd->reloc_off;
if (entry->child_pre_probe)
entry->child_pre_probe += gd->reloc_off;
if (entry->child_post_remove)
@@ -81,10 +83,16 @@ void fix_uclass(void)
entry->post_bind += gd->reloc_off;
if (entry->pre_unbind)
entry->pre_unbind += gd->reloc_off;
+ if (entry->pre_probe)
+ entry->pre_probe += gd->reloc_off;
if (entry->post_probe)
entry->post_probe += gd->reloc_off;
if (entry->pre_remove)
entry->pre_remove += gd->reloc_off;
+ if (entry->child_post_bind)
+ entry->child_post_bind += gd->reloc_off;
+ if (entry->child_pre_probe)
+ entry->child_pre_probe += gd->reloc_off;
if (entry->init)
entry->init += gd->reloc_off;
if (entry->destroy)
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 3/3] dm: sf: Add support for all targets which requires MANUAL_RELOC
2015-10-27 15:01 [U-Boot] [PATCH 1/3] dm: spi: Add support for all targets which requires MANUAL_RELOC Michal Simek
2015-10-27 15:01 ` [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation Michal Simek
@ 2015-10-27 15:01 ` Michal Simek
2015-10-28 9:51 ` Michal Simek
2015-10-29 17:19 ` [U-Boot] [PATCH 1/3] dm: spi: " Simon Glass
2 siblings, 1 reply; 7+ messages in thread
From: Michal Simek @ 2015-10-27 15:01 UTC (permalink / raw)
To: u-boot
It is follow up patch based on
"dm: Add support for all targets which requires MANUAL_RELOC"
(sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3)
to update function pointers for DM.
Using post_bind is not ideal but it is one on current option what can be
used. Variable reloc_done has to be used do not call relocation after
every bind. Maybe new core functions should be introduced for this case.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
drivers/mtd/spi/sf-uclass.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 350e21aa7d65..07204094cfce 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -11,6 +11,8 @@
#include <dm/device-internal.h>
#include "sf_internal.h"
+DECLARE_GLOBAL_DATA_PTR;
+
int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
{
return sf_get_ops(dev)->read(dev, offset, len, buf);
@@ -72,8 +74,28 @@ int spi_flash_remove(struct udevice *dev)
return device_remove(dev);
}
+static int reloc_done;
+
+static int spi_flash_post_bind(struct udevice *dev)
+{
+ struct dm_spi_flash_ops *ops = sf_get_ops(dev);
+
+ if (!reloc_done) {
+ if (ops->read)
+ ops->read += gd->reloc_off;
+ if (ops->write)
+ ops->write += gd->reloc_off;
+ if (ops->erase)
+ ops->erase += gd->reloc_off;
+
+ reloc_done++;
+ }
+ return 0;
+}
+
UCLASS_DRIVER(spi_flash) = {
.id = UCLASS_SPI_FLASH,
.name = "spi_flash",
+ .post_bind = spi_flash_post_bind,
.per_device_auto_alloc_size = sizeof(struct spi_flash),
};
--
2.5.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 3/3] dm: sf: Add support for all targets which requires MANUAL_RELOC
2015-10-27 15:01 ` [U-Boot] [PATCH 3/3] dm: sf: Add support for all targets which requires MANUAL_RELOC Michal Simek
@ 2015-10-28 9:51 ` Michal Simek
0 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2015-10-28 9:51 UTC (permalink / raw)
To: u-boot
On 10/27/2015 04:01 PM, Michal Simek wrote:
> It is follow up patch based on
> "dm: Add support for all targets which requires MANUAL_RELOC"
> (sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3)
> to update function pointers for DM.
>
> Using post_bind is not ideal but it is one on current option what can be
> used. Variable reloc_done has to be used do not call relocation after
> every bind. Maybe new core functions should be introduced for this case.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> drivers/mtd/spi/sf-uclass.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
> index 350e21aa7d65..07204094cfce 100644
> --- a/drivers/mtd/spi/sf-uclass.c
> +++ b/drivers/mtd/spi/sf-uclass.c
> @@ -11,6 +11,8 @@
> #include <dm/device-internal.h>
> #include "sf_internal.h"
>
> +DECLARE_GLOBAL_DATA_PTR;
> +
> int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
> {
> return sf_get_ops(dev)->read(dev, offset, len, buf);
> @@ -72,8 +74,28 @@ int spi_flash_remove(struct udevice *dev)
> return device_remove(dev);
> }
>
> +static int reloc_done;
> +
> +static int spi_flash_post_bind(struct udevice *dev)
> +{
> + struct dm_spi_flash_ops *ops = sf_get_ops(dev);
> +
> + if (!reloc_done) {
> + if (ops->read)
> + ops->read += gd->reloc_off;
> + if (ops->write)
> + ops->write += gd->reloc_off;
> + if (ops->erase)
> + ops->erase += gd->reloc_off;
> +
> + reloc_done++;
> + }
> + return 0;
> +}
> +
This is missing some #if defined(CONFIG_NEEDS_MANUAL_RELOC) around.
Will fix it in v2 but would like to know if this is the best way how to
call this because I am not convinced about it.
That solution with static variable is not the best one.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151028/45006417/attachment.sig>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation
2015-10-27 15:01 ` [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation Michal Simek
@ 2015-10-29 17:18 ` Simon Glass
2015-10-30 5:47 ` Michal Simek
0 siblings, 1 reply; 7+ messages in thread
From: Simon Glass @ 2015-10-29 17:18 UTC (permalink / raw)
To: u-boot
On 27 October 2015 at 09:01, Michal Simek <michal.simek@xilinx.com> wrote:
> Patches:
> "dm: core: Add a post_bind method for parents"
> (sha1: 0118ce79577f9b0881f99a6e4f8a79cd5014cb87)
> "dm: core: Add a uclass pre_probe() method for devices"
> (sha1: 02c07b3741f1b825934b1a6eb8f23530532dc426)
> "dm: core: Allow the uclass to set up a device's child after binding"
> (sha1: 081f2fcbd9a95ba10677065359791f8fea3f8c58)
> "dm: core: Allow uclass to set up a device's child before it is probed"
> (sha1: 83c7e434c9dd3ca81f8b763e23c1881b973bcf2f)
>
> Adds new entries to struct driver and struct uclass_driver without
> extending code for manual relocation. This patch fixes it for all
> architectures which requires MANUAL_RELOC.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> drivers/core/root.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Looking forward to getting rid of the manual relocation!
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/3] dm: spi: Add support for all targets which requires MANUAL_RELOC
2015-10-27 15:01 [U-Boot] [PATCH 1/3] dm: spi: Add support for all targets which requires MANUAL_RELOC Michal Simek
2015-10-27 15:01 ` [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation Michal Simek
2015-10-27 15:01 ` [U-Boot] [PATCH 3/3] dm: sf: Add support for all targets which requires MANUAL_RELOC Michal Simek
@ 2015-10-29 17:19 ` Simon Glass
2 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2015-10-29 17:19 UTC (permalink / raw)
To: u-boot
On 27 October 2015 at 09:01, Michal Simek <michal.simek@xilinx.com> wrote:
> It is follow up patch based on
> "dm: Add support for all targets which requires MANUAL_RELOC"
> (sha1: 484fdf5ba058b07be5ca82763aa2b72063540ef3)
> to update function pointers for DM.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> drivers/spi/spi-uclass.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation
2015-10-29 17:18 ` Simon Glass
@ 2015-10-30 5:47 ` Michal Simek
0 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2015-10-30 5:47 UTC (permalink / raw)
To: u-boot
On 10/29/2015 06:18 PM, Simon Glass wrote:
> On 27 October 2015 at 09:01, Michal Simek <michal.simek@xilinx.com> wrote:
>> Patches:
>> "dm: core: Add a post_bind method for parents"
>> (sha1: 0118ce79577f9b0881f99a6e4f8a79cd5014cb87)
>> "dm: core: Add a uclass pre_probe() method for devices"
>> (sha1: 02c07b3741f1b825934b1a6eb8f23530532dc426)
>> "dm: core: Allow the uclass to set up a device's child after binding"
>> (sha1: 081f2fcbd9a95ba10677065359791f8fea3f8c58)
>> "dm: core: Allow uclass to set up a device's child before it is probed"
>> (sha1: 83c7e434c9dd3ca81f8b763e23c1881b973bcf2f)
>>
>> Adds new entries to struct driver and struct uclass_driver without
>> extending code for manual relocation. This patch fixes it for all
>> architectures which requires MANUAL_RELOC.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> drivers/core/root.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>
> Looking forward to getting rid of the manual relocation!
:-)
What about that third one?
Is any change in API needed or that style is fine?
Thanks,
Michal
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-10-30 5:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 15:01 [U-Boot] [PATCH 1/3] dm: spi: Add support for all targets which requires MANUAL_RELOC Michal Simek
2015-10-27 15:01 ` [U-Boot] [PATCH 2/3] dm: core: Add missing entries for manual relocation Michal Simek
2015-10-29 17:18 ` Simon Glass
2015-10-30 5:47 ` Michal Simek
2015-10-27 15:01 ` [U-Boot] [PATCH 3/3] dm: sf: Add support for all targets which requires MANUAL_RELOC Michal Simek
2015-10-28 9:51 ` Michal Simek
2015-10-29 17:19 ` [U-Boot] [PATCH 1/3] dm: spi: " Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox