From 6955d47610b8cc1060ad468224ede6140ad043b0 Mon Sep 17 00:00:00 2001 From: thorpej Date: Fri, 30 May 2003 18:38:02 +0000 Subject: [PATCH] Make big-endian mode a little closer to working on the BRH. I can talk to both the EEPROM *and* the PHY on the Ethernet interface now, at least, though it is still not completely working. Many thanks to Stephen Goadhouse at ADI for some hints. --- sys/arch/arm/xscale/becc.c | 21 ++--- sys/arch/arm/xscale/becc_pci_space_asm.S | 100 +++++++++++++++++++++++ sys/arch/arm/xscale/becc_space.c | 41 +++++----- sys/arch/arm/xscale/files.becc | 5 +- 4 files changed, 129 insertions(+), 38 deletions(-) create mode 100644 sys/arch/arm/xscale/becc_pci_space_asm.S diff --git a/sys/arch/arm/xscale/becc.c b/sys/arch/arm/xscale/becc.c index 193efa3022db..1107da60b0d5 100644 --- a/sys/arch/arm/xscale/becc.c +++ b/sys/arch/arm/xscale/becc.c @@ -1,4 +1,4 @@ -/* $NetBSD: becc.c,v 1.4 2003/05/23 05:21:26 briggs Exp $ */ +/* $NetBSD: becc.c,v 1.5 2003/05/30 18:38:02 thorpej Exp $ */ /* * Copyright (c) 2002, 2003 Wasabi Systems, Inc. @@ -140,20 +140,16 @@ becc_attach(struct becc_softc *sc) } /* - * Program the two outbound PCI memory windows. On a - * big-endian system, we byte-swap the first window. - * The second window is used for STREAM transfers. + * Program the two outbound PCI memory windows. + * NOTE: WE DO NOT BYTE-SWAP OUTBOUND WINDOWS IN BIG-ENDIAN + * MODE. I know this seems counter-intuitive, but that's + * how it is. * * There's a third window on v9 and later, but we don't * use it for anything; program it anyway, just to be * safe. */ -#ifdef __ARMEB__ - BECC_CSR_WRITE(BECC_POMR1, sc->sc_owin_xlate[0] /* | POMRx_F32 */ | - POMRx_BEE); -#else BECC_CSR_WRITE(BECC_POMR1, sc->sc_owin_xlate[0] /* | POMRx_F32 */); -#endif BECC_CSR_WRITE(BECC_POMR2, sc->sc_owin_xlate[1] /* | POMRx_F32 */); if (becc_rev >= BECC_REV_V9) @@ -161,16 +157,11 @@ becc_attach(struct becc_softc *sc) sc->sc_owin_xlate[2] /* | POMRx_F32 */); /* - * Program the PCI I/O window. On a big-endian system, - * we do byte-swapping. + * Program the PCI I/O window. See note above about byte-swapping. * * XXX What about STREAM transfers? */ -#ifdef __ARMEB__ - BECC_CSR_WRITE(BECC_POIR, sc->sc_ioout_xlate | POIR_BEE); -#else BECC_CSR_WRITE(BECC_POIR, sc->sc_ioout_xlate); -#endif /* * Configure PCI configuration cycle access. diff --git a/sys/arch/arm/xscale/becc_pci_space_asm.S b/sys/arch/arm/xscale/becc_pci_space_asm.S new file mode 100644 index 000000000000..1d69d9e82a44 --- /dev/null +++ b/sys/arch/arm/xscale/becc_pci_space_asm.S @@ -0,0 +1,100 @@ +/* $NetBSD: becc_pci_space_asm.S,v 1.1 2003/05/30 18:38:02 thorpej Exp $ */ + +/* + * Copyright (c) 2003 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Jason R. Thorpe for Wasabi Systems, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +/* + * Bus space functions for BECC PCI space access. We have to swizzle + * the address for 1 and 2 byte accesses when in big-endian mode. + */ + +/* + * read single + */ + +ENTRY(becc_pci_bs_r_1) +#ifdef __ARMEB__ + add r1, r1, r2 + eor r1, r1, #0x3 + ldrb r0, [r1] +#else + ldrb r0, [r1, r2] +#endif /* __ARMEB__ */ + mov pc, lr + +ENTRY(becc_pci_bs_r_2) +#ifdef __ARMEB__ + add r1, r1, r2 + eor r1, r1, #0x2 + ldrh r0, [r1] +#else + ldrh r0, [r1, r2] +#endif /* __ARMEB__ */ + mov pc, lr + +ENTRY(becc_pci_bs_r_4) + ldr r0, [r1, r2] + mov pc, lr + +/* + * write single + */ + +ENTRY(becc_pci_bs_w_1) +#ifdef __ARMEB__ + add r1, r1, r2 + eor r1, r1, #0x3 + strb r3, [r1] +#else + strb r3, [r1, r2] +#endif /* __ARMEB__ */ + mov pc, lr + +ENTRY(becc_pci_bs_w_2) +#ifdef __ARMEB__ + add r1, r1, r2 + eor r1, r1, #0x2 + strh r3, [r1] +#else + strh r3, [r1, r2] +#endif /* __ARMEB__ */ + mov pc, lr + +ENTRY(becc_pci_bs_w_4) + str r3, [r1, r2] + mov pc, lr diff --git a/sys/arch/arm/xscale/becc_space.c b/sys/arch/arm/xscale/becc_space.c index 61702290b768..b9bc09a301ca 100644 --- a/sys/arch/arm/xscale/becc_space.c +++ b/sys/arch/arm/xscale/becc_space.c @@ -1,4 +1,4 @@ -/* $NetBSD: becc_space.c,v 1.1 2003/01/25 01:57:19 thorpej Exp $ */ +/* $NetBSD: becc_space.c,v 1.2 2003/05/30 18:38:02 thorpej Exp $ */ /* * Copyright (c) 2001, 2002 Wasabi Systems, Inc. @@ -53,8 +53,7 @@ bs_protos(becc); bs_protos(becc_io); bs_protos(becc_mem); -bs_protos(generic); -bs_protos(generic_armv4); +bs_protos(becc_pci); bs_protos(bs_notimpl); /* @@ -84,39 +83,39 @@ const struct bus_space becc_bs_tag_template = { becc_bs_barrier, /* read (single) */ - generic_bs_r_1, - generic_armv4_bs_r_2, - generic_bs_r_4, + becc_pci_bs_r_1, + becc_pci_bs_r_2, + becc_pci_bs_r_4, bs_notimpl_bs_r_8, /* read multiple */ - generic_bs_rm_1, - generic_armv4_bs_rm_2, - generic_bs_rm_4, + bs_notimpl_bs_rm_1, + bs_notimpl_bs_rm_2, + bs_notimpl_bs_rm_4, bs_notimpl_bs_rm_8, /* read region */ bs_notimpl_bs_rr_1, - generic_armv4_bs_rr_2, - generic_bs_rr_4, + bs_notimpl_bs_rr_2, + bs_notimpl_bs_rr_4, bs_notimpl_bs_rr_8, /* write (single) */ - generic_bs_w_1, - generic_armv4_bs_w_2, - generic_bs_w_4, + becc_pci_bs_w_1, + becc_pci_bs_w_2, + becc_pci_bs_w_4, bs_notimpl_bs_w_8, /* write multiple */ - generic_bs_wm_1, - generic_armv4_bs_wm_2, - generic_bs_wm_4, + bs_notimpl_bs_wm_1, + bs_notimpl_bs_wm_2, + bs_notimpl_bs_wm_4, bs_notimpl_bs_wm_8, /* write region */ bs_notimpl_bs_wr_1, - generic_armv4_bs_wr_2, - generic_bs_wr_4, + bs_notimpl_bs_wr_2, + bs_notimpl_bs_wr_4, bs_notimpl_bs_wr_8, /* set multiple */ @@ -127,13 +126,13 @@ const struct bus_space becc_bs_tag_template = { /* set region */ bs_notimpl_bs_sr_1, - generic_armv4_bs_sr_2, + bs_notimpl_bs_sr_2, bs_notimpl_bs_sr_4, bs_notimpl_bs_sr_8, /* copy */ bs_notimpl_bs_c_1, - generic_armv4_bs_c_2, + bs_notimpl_bs_c_2, bs_notimpl_bs_c_4, bs_notimpl_bs_c_8, }; diff --git a/sys/arch/arm/xscale/files.becc b/sys/arch/arm/xscale/files.becc index 0c3ac47aed23..a9b083fd4aba 100644 --- a/sys/arch/arm/xscale/files.becc +++ b/sys/arch/arm/xscale/files.becc @@ -1,4 +1,4 @@ -# $NetBSD: files.becc,v 1.2 2003/04/20 20:50:50 thorpej Exp $ +# $NetBSD: files.becc,v 1.3 2003/05/30 18:38:02 thorpej Exp $ # # Configuration info for the ADI Engineering Big Endian Companion Chip # for the Intel i80200 processor @@ -7,10 +7,11 @@ file arch/arm/xscale/becc_icu.c file arch/arm/xscale/becc_timer.c -device becc {}: pcibus, bus_space_generic +device becc {}: pcibus # Board-specific front-end provides attachment. file arch/arm/xscale/becc.c becc file arch/arm/xscale/becc_pci.c becc +file arch/arm/xscale/becc_pci_space_asm.S becc file arch/arm/xscale/becc_space.c becc # Reset button.