diff mbox series

[v3,5/6] sandbox: Enable memio operations in board_init

Message ID 20200611194506.7263-6-p.yadav@ti.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series drivers: Add a framework for MUX drivers | expand

Commit Message

Pratyush Yadav June 11, 2020, 7:45 p.m. UTC
initr_dm_devices() is called somewhere after board_init(). It can be
used by drivers to initialize devices to some default bootup state.
Those devices might use mmio read/write operations to perform the
initialization.

One such example is the mux devices. The mux framework initializes the
muxes to their default state after idle state in
mux_uclass_post_probe(). One type of mux controller is the MMIO mux
controller. Initializing a MMIO mux to idle state can require a mmio
read and write operation.

With memio disabled, the reads return 0 and the writes go off into the
void. This makes it impossible to initialize muxes to their idle state
on boot, and consequentially makes it impossible to test that in
sandbox.

These same initializations work fine on actual hardware (tested on TI
J721E EVM). So, enable memio operations on boot so devices like mux can
perform whatever initialization they need. state_reset_for_test() will
disable it before running tests so tests still need to enable memio
manually.

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
---
 board/sandbox/sandbox.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Simon Glass June 17, 2020, 3:12 a.m. UTC | #1
Hi Pratyush,

On Thu, 11 Jun 2020 at 13:45, Pratyush Yadav <p.yadav@ti.com> wrote:
>
> initr_dm_devices() is called somewhere after board_init(). It can be
> used by drivers to initialize devices to some default bootup state.
> Those devices might use mmio read/write operations to perform the
> initialization.
>
> One such example is the mux devices. The mux framework initializes the
> muxes to their default state after idle state in
> mux_uclass_post_probe(). One type of mux controller is the MMIO mux
> controller. Initializing a MMIO mux to idle state can require a mmio
> read and write operation.
>
> With memio disabled, the reads return 0 and the writes go off into the
> void. This makes it impossible to initialize muxes to their idle state
> on boot, and consequentially makes it impossible to test that in
> sandbox.
>
> These same initializations work fine on actual hardware (tested on TI
> J721E EVM). So, enable memio operations on boot so devices like mux can
> perform whatever initialization they need. state_reset_for_test() will
> disable it before running tests so tests still need to enable memio
> manually.

We have a similar issue with PCI and we only enable it when needed.
Can we do something similar here?

>
> Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
> ---
>  board/sandbox/sandbox.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
> index 1372003018..d7eb207822 100644
> --- a/board/sandbox/sandbox.c
> +++ b/board/sandbox/sandbox.c
> @@ -55,6 +55,8 @@ int board_init(void)
>         if (IS_ENABLED(CONFIG_LED))
>                 led_default_state();
>
> +       sandbox_set_enable_memio(true);
> +
>         return 0;
>  }
>
> --
> 2.27.0
>

Regards,
Simon
Pratyush Yadav Aug. 3, 2020, 11:34 a.m. UTC | #2
Hi Simon,

On 16/06/20 09:12PM, Simon Glass wrote:
> Hi Pratyush,
> 
> On Thu, 11 Jun 2020 at 13:45, Pratyush Yadav <p.yadav@ti.com> wrote:
> >
> > initr_dm_devices() is called somewhere after board_init(). It can be
> > used by drivers to initialize devices to some default bootup state.
> > Those devices might use mmio read/write operations to perform the
> > initialization.
> >
> > One such example is the mux devices. The mux framework initializes the
> > muxes to their default state after idle state in
> > mux_uclass_post_probe(). One type of mux controller is the MMIO mux
> > controller. Initializing a MMIO mux to idle state can require a mmio
> > read and write operation.
> >
> > With memio disabled, the reads return 0 and the writes go off into the
> > void. This makes it impossible to initialize muxes to their idle state
> > on boot, and consequentially makes it impossible to test that in
> > sandbox.
> >
> > These same initializations work fine on actual hardware (tested on TI
> > J721E EVM). So, enable memio operations on boot so devices like mux can
> > perform whatever initialization they need. state_reset_for_test() will
> > disable it before running tests so tests still need to enable memio
> > manually.
> 
> We have a similar issue with PCI and we only enable it when needed.
> Can we do something similar here?

I went and looked, but I can't figure out how we do it for PCI. Any 
pointers?
 
> >
> > Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
> > ---
> >  board/sandbox/sandbox.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
> > index 1372003018..d7eb207822 100644
> > --- a/board/sandbox/sandbox.c
> > +++ b/board/sandbox/sandbox.c
> > @@ -55,6 +55,8 @@ int board_init(void)
> >         if (IS_ENABLED(CONFIG_LED))
> >                 led_default_state();
> >
> > +       sandbox_set_enable_memio(true);
> > +
> >         return 0;
> >  }
Simon Glass Aug. 4, 2020, 2 a.m. UTC | #3
Hi Pratyush,

On Mon, 3 Aug 2020 at 05:34, Pratyush Yadav <p.yadav@ti.com> wrote:
>
> Hi Simon,
>
> On 16/06/20 09:12PM, Simon Glass wrote:
> > Hi Pratyush,
> >
> > On Thu, 11 Jun 2020 at 13:45, Pratyush Yadav <p.yadav@ti.com> wrote:
> > >
> > > initr_dm_devices() is called somewhere after board_init(). It can be
> > > used by drivers to initialize devices to some default bootup state.
> > > Those devices might use mmio read/write operations to perform the
> > > initialization.
> > >
> > > One such example is the mux devices. The mux framework initializes the
> > > muxes to their default state after idle state in
> > > mux_uclass_post_probe(). One type of mux controller is the MMIO mux
> > > controller. Initializing a MMIO mux to idle state can require a mmio
> > > read and write operation.
> > >
> > > With memio disabled, the reads return 0 and the writes go off into the
> > > void. This makes it impossible to initialize muxes to their idle state
> > > on boot, and consequentially makes it impossible to test that in
> > > sandbox.
> > >
> > > These same initializations work fine on actual hardware (tested on TI
> > > J721E EVM). So, enable memio operations on boot so devices like mux can
> > > perform whatever initialization they need. state_reset_for_test() will
> > > disable it before running tests so tests still need to enable memio
> > > manually.
> >
> > We have a similar issue with PCI and we only enable it when needed.
> > Can we do something similar here?
>
> I went and looked, but I can't figure out how we do it for PCI. Any
> pointers?

Yes it is enable_pci_map in arch/sandbox/cpu/cpu.c

Regards,
Simon
diff mbox series

Patch

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 1372003018..d7eb207822 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -55,6 +55,8 @@  int board_init(void)
 	if (IS_ENABLED(CONFIG_LED))
 		led_default_state();
 
+	sandbox_set_enable_memio(true);
+
 	return 0;
 }