On Tue, Feb 02, 2016 at 10:55:57AM +1100, Jonathan Gray wrote:
> On Mon, Feb 01, 2016 at 02:55:52AM +0200, Artturi Alm wrote:
> > On Sun, Jan 31, 2016 at 10:45:42PM +1100, Jonathan Gray wrote:
> > > On Sun, Jan 31, 2016 at 10:12:05AM +0200, Artturi Alm wrote:
> > > > On Sun, Jan 31, 2016 at 01:14:35AM +0100, Patrick Wildt wrote:
> > > > > Hi,
> > > > > 
> > > > > one of the reasons Allwinner A20/sun7i-based boards, like the
> > > > > Cubieboard 2 or Banana Pi, don't boot is that the sxitimer does
> > > > > not work for us.  We are getting no hardclock ticks and so the
> > > > > system can't work.
> > > > > 
> > > > > There's a simple fix for that.  We can just not use the sxitimer
> > > > > and instead use the ARM architected timer (agtimer) that is
> > > > > supposed to be a generic implementation for all new cores and
> > > > > already attaches anyway.  The sxitimer attachment currently
> > > > > overrides the agtimer.  Removing sxitimer thus allows agtimer
> > > > > to actually do its work.
> > > > > 
> > > > > Currently sxirtc uncondtionally ties into sxitimer.  To make
> > > > > this work, just make sxirtc map its own page instead of relying
> > > > > on the existence of a mapping created by sxitimer.
> > > > > 
> > > > > The address/size used for the sxirtc is from a device tree
> > > > > source.
> > > > > 
> > > > > Patrick
> > > > > 
> > > > 
> > > > Hi,
> > > > 
> > > > nothing i would change about your diff, given now there's agtimer,
> > > > but it doesn't really seem to even try fixing rtc on A20, and leaves
> > > > ugly glue into sxitimer written just for A20, which imho should also
> > > > get cleaned up.
> > > > 
> > > > -Artturi
> > > 
> > > There seem to be at least two diffs here, the different rtc handling
> > > for a20 should be split out, store sxirtc_a20 in the softc and fix
> > > the test from
> > > if (BOARD_ID_SUN7I_A20)
> > > to
> > > if (board_id == BOARD_ID_SUN7I_A20)
> > > 
> > 
> > Yes, it was quick try during my morning coffee, i'm sorry to have wasted
> > your time with the previous obviously wrong diff.
> > 
> > sxitimer a20 support glue cleanup diff inline.
> > 
> > -Artturi
> 
> Thanks, both diffs committed.  Any chance you could create another to
> move the sxitimer_* globals into the softc?

Sure, here's fix for sxidog while waiting, i know the mapping does overlap
with sxitimer, but that is what sxirtc already does too since Patrick's diff
without problems.
As is, sxidog is the last user of 'extern bus_.._t sxitimer_ioh;', and use of
it on A20 is now obviously wrong, and might mean that reboot ends up spinning.

-Artturi


diff --git a/sys/arch/armv7/sunxi/sunxireg.h b/sys/arch/armv7/sunxi/sunxireg.h
index 323264b..c82990c 100644
--- a/sys/arch/armv7/sunxi/sunxireg.h
+++ b/sys/arch/armv7/sunxi/sunxireg.h
@@ -65,7 +65,7 @@
 #define        TIMER2_IRQ              24
 #define        STATTIMER_IRQ           TIMER1_IRQ /* XXX */
 
-#define        WDOG_ADDR               0x90
+#define        WDOG_ADDR               0x01c20c90
 #define        WDOG_SIZE               0x08
 #define        WDOG_IRQ                24
 
diff --git a/sys/arch/armv7/sunxi/sxidog.c b/sys/arch/armv7/sunxi/sxidog.c
index 6212e58..347b534 100644
--- a/sys/arch/armv7/sunxi/sxidog.c
+++ b/sys/arch/armv7/sunxi/sxidog.c
@@ -30,9 +30,6 @@
 #include <armv7/sunxi/sunxireg.h>
 #include <armv7/armv7/armv7var.h>
 
-/* XXX other way around than bus_space_subregion? */
-extern bus_space_handle_t sxitimer_ioh;
-
 /* registers */
 #define WDOG_CR                        0x00
 #define WDOG_MR                        0x04
@@ -89,9 +86,9 @@ sxidog_attach(struct device *parent, struct device *self, 
void *args)
        struct sxidog_softc *sc = (struct sxidog_softc *)self;
 
        sc->sc_iot = aa->aa_iot;
-       if (bus_space_subregion(sc->sc_iot, sxitimer_ioh,
-           aa->aa_dev->mem[0].addr, aa->aa_dev->mem[0].size, &sc->sc_ioh))
-               panic("sxidog_attach: bus_space_subregion failed!");
+       if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
+           aa->aa_dev->mem[0].size, 0, &sc->sc_ioh))
+               panic("sxidog_attach: bus_space_map failed!");
 
 #ifdef DEBUG
        printf(": ctrl %x mode %x\n", SXIREAD4(sc, WDOG_CR),

Reply via email to