From fe99796a13aee2f6530e2dc0b0cad4d6e5c6e2a1 Mon Sep 17 00:00:00 2001 From: enami Date: Thu, 15 Mar 2001 23:01:33 +0000 Subject: [PATCH] Make fwohci works on big endian cpu (e.g., powermac g4). --- sys/dev/ieee1394/fwohci.c | 6 +++++- sys/dev/ieee1394/fwohcivar.h | 8 +++++--- sys/dev/pci/fwohci_pci.c | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/dev/ieee1394/fwohci.c b/sys/dev/ieee1394/fwohci.c index 4ad5bf13c335..6bd90bfed499 100644 --- a/sys/dev/ieee1394/fwohci.c +++ b/sys/dev/ieee1394/fwohci.c @@ -1,4 +1,4 @@ -/* $NetBSD: fwohci.c,v 1.21 2001/03/14 06:46:17 onoe Exp $ */ +/* $NetBSD: fwohci.c,v 1.22 2001/03/15 23:01:33 enami Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -528,6 +528,10 @@ fwohci_hw_init(struct fwohci_softc *sc) OHCI_CSR_WRITE(sc, OHCI_REG_HCControlClear, OHCI_HCControl_NoByteSwapData | OHCI_HCControl_APhyEnhanceEnable); +#if BYTE_ORDER == BIG_ENDIAN + OHCI_CSR_WRITE(sc, OHCI_REG_HCControlSet, + OHCI_HCControl_NoByteSwapData); +#endif OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskClear, ~0); OHCI_CSR_WRITE(sc, OHCI_REG_IntMaskSet, OHCI_Int_BusReset | diff --git a/sys/dev/ieee1394/fwohcivar.h b/sys/dev/ieee1394/fwohcivar.h index fa96db82f252..707e2cc4f8bf 100644 --- a/sys/dev/ieee1394/fwohcivar.h +++ b/sys/dev/ieee1394/fwohcivar.h @@ -1,4 +1,4 @@ -/* $NetBSD: fwohcivar.h,v 1.7 2000/12/13 11:30:15 enami Exp $ */ +/* $NetBSD: fwohcivar.h,v 1.8 2001/03/15 23:03:43 enami Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -161,7 +161,9 @@ int fwohci_print (void *, const char *); /* Macros to read and write the OHCI registers */ -#define OHCI_CSR_WRITE(sc, reg, val) bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, reg, val) -#define OHCI_CSR_READ(sc, reg) bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg) +#define OHCI_CSR_WRITE(sc, reg, val) \ + bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, reg, htole32(val)) +#define OHCI_CSR_READ(sc, reg) \ + le32toh(bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, reg)) #endif /* _DEV_IEEE1394_FWOHCIVAR_H_ */ diff --git a/sys/dev/pci/fwohci_pci.c b/sys/dev/pci/fwohci_pci.c index 6e679bc01a44..dafdff1d338f 100644 --- a/sys/dev/pci/fwohci_pci.c +++ b/sys/dev/pci/fwohci_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: fwohci_pci.c,v 1.7 2001/03/15 22:20:12 enami Exp $ */ +/* $NetBSD: fwohci_pci.c,v 1.8 2001/03/15 23:01:34 enami Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -114,6 +114,12 @@ fwohci_pci_attach(struct device *parent, struct device *self, void *aux) pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr | PCI_COMMAND_MASTER_ENABLE); +#if BYTE_ORDER == BIG_ENDIAN + csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_OHCI_CONTROL_REGISTER); + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_OHCI_CONTROL_REGISTER, + csr | PCI_GLOBAL_SWAP_BE); +#endif + /* Map and establish the interrupt. */ if (pci_intr_map(pa, &ih)) { printf("%s: couldn't map interrupt\n", self->dv_xname);