All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests
@ 2019-10-02  9:28 Jean-Jacques Hiblot
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions Jean-Jacques Hiblot
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jean-Jacques Hiblot @ 2019-10-02  9:28 UTC (permalink / raw)
  To: u-boot

The sandbox architecture does not implement the writeX nor readX functions.
This prevents testing properly the regmaps and the other stuff relying on
it.


Jean-Jacques Hiblot (2):
  arch: sandbox: Provide working writeX/readX functions
  test: regmap: check the values read from the regmap

 arch/sandbox/include/asm/io.h | 18 +++++++++---------
 test/dm/regmap.c              | 15 ++++++++++++---
 2 files changed, 21 insertions(+), 12 deletions(-)

-- 
2.17.1

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

* [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions
  2019-10-02  9:28 [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests Jean-Jacques Hiblot
@ 2019-10-02  9:28 ` Jean-Jacques Hiblot
  2019-10-11 22:22   ` Simon Glass
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 2/2] test: regmap: check the values read from the regmap Jean-Jacques Hiblot
  2019-10-11 22:22 ` [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests Simon Glass
  2 siblings, 1 reply; 6+ messages in thread
From: Jean-Jacques Hiblot @ 2019-10-02  9:28 UTC (permalink / raw)
  To: u-boot

Those functions are used by the regmap core. Without them regmaps are
not working on sandbox.
The implementation is taken from arch/x86/include/asm/io.h.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

 arch/sandbox/include/asm/io.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 2a350a826c..504aac0691 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -38,18 +38,18 @@ static inline void unmap_sysmem(const void *vaddr)
 /* Map from a pointer to our RAM buffer */
 phys_addr_t map_to_sysmem(const void *ptr);
 
-/* Define nops for sandbox I/O access */
-#define readb(addr) ((void)addr, 0)
-#define readw(addr) ((void)addr, 0)
-#define readl(addr) ((void)addr, 0)
+#define readb(addr) (*(volatile u8 *)(uintptr_t)(addr))
+#define readw(addr) (*(volatile u16 *)(uintptr_t)(addr))
+#define readl(addr) (*(volatile u32 *)(uintptr_t)(addr))
 #ifdef CONFIG_SANDBOX64
-#define readq(addr) ((void)addr, 0)
+#define readq(addr) (*(volatile u64 *)(uintptr_t)(addr))
 #endif
-#define writeb(v, addr) ((void)addr)
-#define writew(v, addr) ((void)addr)
-#define writel(v, addr) ((void)addr)
+
+#define writeb(b, addr) (*(volatile u8 *)(addr) = (b))
+#define writew(b, addr) (*(volatile u16 *)(addr) = (b))
+#define writel(b, addr) (*(volatile u32 *)(addr) = (b))
 #ifdef CONFIG_SANDBOX64
-#define writeq(v, addr) ((void)addr)
+#define writeq(b, addr) (*(volatile u64 *)(addr) = (b))
 #endif
 
 /*
-- 
2.17.1

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

* [U-Boot] [PATCH v1 2/2] test: regmap: check the values read from the regmap
  2019-10-02  9:28 [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests Jean-Jacques Hiblot
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions Jean-Jacques Hiblot
@ 2019-10-02  9:28 ` Jean-Jacques Hiblot
  2019-10-11 22:22   ` Simon Glass
  2019-10-11 22:22 ` [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests Simon Glass
  2 siblings, 1 reply; 6+ messages in thread
From: Jean-Jacques Hiblot @ 2019-10-02  9:28 UTC (permalink / raw)
  To: u-boot

The test did reads after writes but didn't check the value.
It probably was because the sandbox didn't implement the writeX/readX
functions.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>

---

 test/dm/regmap.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 82de295cb8..4cde0d1866 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -104,13 +104,19 @@ static int dm_test_regmap_rw(struct unit_test_state *uts)
 	ut_assertok_ptr(map);
 
 	ut_assertok(regmap_write(map, 0, 0xcacafafa));
-	ut_assertok(regmap_write(map, 3, 0x55aa2211));
+	ut_assertok(regmap_write(map, 5, 0x55aa2211));
 
 	ut_assertok(regmap_read(map, 0, &reg));
-	ut_assertok(regmap_read(map, 3, &reg));
+	ut_asserteq(0xcacafafa, reg);
+	ut_assertok(regmap_read(map, 5, &reg));
+	ut_asserteq(0x55aa2211, reg);
 
 	ut_assertok(regmap_update_bits(map, 0, 0xff00ff00, 0x55aa2211));
-	ut_assertok(regmap_update_bits(map, 3, 0x00ff00ff, 0xcacafada));
+	ut_assertok(regmap_read(map, 0, &reg));
+	ut_asserteq(0x55ca22fa, reg);
+	ut_assertok(regmap_update_bits(map, 5, 0x00ff00ff, 0xcacafada));
+	ut_assertok(regmap_read(map, 5, &reg));
+	ut_asserteq(0x55ca22da, reg);
 
 	return 0;
 }
@@ -138,7 +144,9 @@ static int dm_test_regmap_getset(struct unit_test_state *uts)
 	regmap_set(map, struct layout, val3, 0x55aa2211);
 
 	ut_assertok(regmap_get(map, struct layout, val0, &reg));
+	ut_asserteq(0xcacafafa, reg);
 	ut_assertok(regmap_get(map, struct layout, val3, &reg));
+	ut_asserteq(0x55aa2211, reg);
 
 	return 0;
 }
@@ -159,6 +167,7 @@ static int dm_test_regmap_poll(struct unit_test_state *uts)
 
 	start = get_timer(0);
 
+	ut_assertok(regmap_write(map, 0, 0x0));
 	ut_asserteq(-ETIMEDOUT,
 		    regmap_read_poll_timeout_test(map, 0, reg,
 						  (reg == 0xcacafafa),
-- 
2.17.1

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

* [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests
  2019-10-02  9:28 [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests Jean-Jacques Hiblot
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions Jean-Jacques Hiblot
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 2/2] test: regmap: check the values read from the regmap Jean-Jacques Hiblot
@ 2019-10-11 22:22 ` Simon Glass
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2019-10-11 22:22 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Wed, 2 Oct 2019 at 03:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> The sandbox architecture does not implement the writeX nor readX functions.
> This prevents testing properly the regmaps and the other stuff relying on
> it.

I just added a feature to sandbox to support mmio. I'll send a little
series with an updated version of your patch and some other fixes.

>
>
> Jean-Jacques Hiblot (2):
>   arch: sandbox: Provide working writeX/readX functions
>   test: regmap: check the values read from the regmap
>
>  arch/sandbox/include/asm/io.h | 18 +++++++++---------
>  test/dm/regmap.c              | 15 ++++++++++++---
>  2 files changed, 21 insertions(+), 12 deletions(-)
>
> --
> 2.17.1
>

Regards,
Simon

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

* [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions Jean-Jacques Hiblot
@ 2019-10-11 22:22   ` Simon Glass
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2019-10-11 22:22 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Wed, 2 Oct 2019 at 03:29, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> Those functions are used by the regmap core. Without them regmaps are
> not working on sandbox.
> The implementation is taken from arch/x86/include/asm/io.h.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> ---
>
>  arch/sandbox/include/asm/io.h | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

This feature is already present in master, so we can skip this patch.

Regards,
SImon

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

* [U-Boot] [PATCH v1 2/2] test: regmap: check the values read from the regmap
  2019-10-02  9:28 ` [U-Boot] [PATCH v1 2/2] test: regmap: check the values read from the regmap Jean-Jacques Hiblot
@ 2019-10-11 22:22   ` Simon Glass
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2019-10-11 22:22 UTC (permalink / raw)
  To: u-boot

Hi Jean-Jacques,

On Wed, 2 Oct 2019 at 03:28, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> The test did reads after writes but didn't check the value.
> It probably was because the sandbox didn't implement the writeX/readX
> functions.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>
> ---
>
>  test/dm/regmap.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)

I'm going to send an updated version of this patch.

Regards,
Simon

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

end of thread, other threads:[~2019-10-11 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02  9:28 [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests Jean-Jacques Hiblot
2019-10-02  9:28 ` [U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions Jean-Jacques Hiblot
2019-10-11 22:22   ` Simon Glass
2019-10-02  9:28 ` [U-Boot] [PATCH v1 2/2] test: regmap: check the values read from the regmap Jean-Jacques Hiblot
2019-10-11 22:22   ` Simon Glass
2019-10-11 22:22 ` [U-Boot] [PATCH v1 0/2] sandbox: Fixes the regmap tests 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.