# $Id: openbsd-iop_smartraid_2000s.diff,v 1.1 2004/01/10 17:52:19 jcs Exp $ # XXX: no longer needed? # # (proper) dpt 2005s support for openbsd # # by joshua stein # Index: sys/dev/pci/pcidevs =================================================================== RCS file: /mirror/anoncvs/cvs/src/sys/dev/pci/pcidevs,v retrieving revision 1.701 diff -u -r1.701 pcidevs --- sys/dev/pci/pcidevs 20 Dec 2003 19:17:26 -0000 1.701 +++ sys/dev/pci/pcidevs 5 Jan 2004 21:52:33 -0000 @@ -955,6 +955,7 @@ product DPT SC_RAID 0xa400 SmartCache/Raid product DPT I960_PPB 0xa500 PCI-PCI product DPT RAID_I2O 0xa501 SmartRAID (I2O) +product DPT 2000S 0xa501 SmartRAID 2000S product DPT 2005S 0xa511 SmartRAID 2005S product DPT MEMCTLR 0x1012 Memory Control Index: sys/dev/pci/iop_pci.c =================================================================== RCS file: /mirror/anoncvs/cvs/src/sys/dev/pci/iop_pci.c,v retrieving revision 1.4 diff -u -r1.4 iop_pci.c --- sys/dev/pci/iop_pci.c 31 Mar 2002 05:25:10 -0000 1.4 +++ sys/dev/pci/iop_pci.c 5 Jan 2004 21:53:57 -0000 @@ -88,6 +88,10 @@ PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_I2O_STANDARD && PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_I2O_INTRDRIVEN) return (1); + if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_DPT && + ((PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DPT_2000S) + || (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DPT_2005S))) + return (1); return (0); } @@ -127,6 +131,31 @@ &sc->sc_ioh, NULL, NULL, 0x40000)) { printf("%s: can't map register window\n", sc->sc_dv.dv_xname); return; + } + + /* Map the 2nd register window. */ + if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_DPT_2005S) { + i += 4; /* next BAR */ + if (i == PCI_MAPREG_END) { + printf("can't find mapping\n"); + return; + } + +#if 0 + /* Should we check it? (see FreeBSD's asr driver) */ + reg = pci_conf_read(pc, pa->pa_tag, PCI_SUBSYS_ID_REG); + printf("subid %x, %x\n", PCI_VENDOR(reg), PCI_PRODUCT(reg)); +#endif + if (pci_mapreg_map(pa, i, PCI_MAPREG_TYPE_MEM, 0, + &sc->sc_rep_iot, &sc->sc_rep_ioh, NULL, NULL, 0x40000)) { + printf("%s: can't map 2nd register window\n", + sc->sc_dv.dv_xname); + return; + } + } else { + /* iop devices other than 2005S */ + sc->sc_rep_iot = sc->sc_iot; + sc->sc_rep_ioh = sc->sc_ioh; } sc->sc_dmat = pa->pa_dmat; Index: sys/dev/i2o/iop.c =================================================================== RCS file: /mirror/anoncvs/cvs/src/sys/dev/i2o/iop.c,v retrieving revision 1.24 diff -u -r1.24 iop.c --- sys/dev/i2o/iop.c 4 Sep 2003 03:45:53 -0000 1.24 +++ sys/dev/i2o/iop.c 5 Jan 2004 21:40:44 -0000 @@ -206,6 +206,9 @@ static inline u_int32_t iop_inl(struct iop_softc *, int); static inline void iop_outl(struct iop_softc *, int, u_int32_t); +static inline u_int32_t iop_inl_msg(struct iop_softc *, int); +static inline void iop_outl_rep(struct iop_softc *, int, u_int32_t); + void iop_config_interrupts(struct device *); void iop_configure_devices(struct iop_softc *, int, int); void iop_devinfo(int, char *, size_t); @@ -260,6 +263,25 @@ BUS_SPACE_BARRIER_WRITE); } +static inline u_int32_t +iop_inl_msg(struct iop_softc *sc, int off) +{ + + bus_space_barrier(sc->sc_iot, sc->sc_ioh, off, 4, + BUS_SPACE_BARRIER_WRITE | BUS_SPACE_BARRIER_READ); + return (bus_space_read_4(sc->sc_iot, sc->sc_ioh, off)); +} + +static inline void +iop_outl_rep(struct iop_softc *sc, int off, u_int32_t val) +{ + + bus_space_write_4(sc->sc_rep_iot, sc->sc_rep_ioh, off, val); + bus_space_barrier(sc->sc_rep_iot, sc->sc_rep_ioh, off, 4, + BUS_SPACE_BARRIER_WRITE); +} + + /* * Initialise the IOP and our interface. */ @@ -1512,7 +1534,7 @@ status = I2O_STATUS_SUCCESS; fn = (struct i2o_fault_notify *)rb; - tctx = iop_inl(sc, fn->lowmfa + 12); /* XXX */ + tctx = iop_inl_msg(sc, fn->lowmfa + 12); /* XXX */ iop_release_mfa(sc, fn->lowmfa); iop_tfn_print(sc, fn); } else { @@ -1964,10 +1986,11 @@ sc->sc_rep_size, BUS_DMASYNC_PREREAD); /* Copy out the message frame. */ - bus_space_write_region_4(sc->sc_iot, sc->sc_ioh, mfa, mb, + bus_space_write_region_4(sc->sc_rep_iot, sc->sc_rep_ioh, mfa, mb, size / sizeof *mb); - bus_space_barrier(sc->sc_iot, sc->sc_ioh, mfa, size, - BUS_SPACE_BARRIER_WRITE); + bus_space_barrier(sc->sc_rep_iot, sc->sc_rep_ioh, mfa, + size, BUS_SPACE_BARRIER_WRITE); + /* Post the MFA back to the IOP. */ iop_outl(sc, IOP_REG_IFIFO, mfa); @@ -2106,10 +2129,10 @@ { /* Use the frame to issue a no-op. */ - iop_outl(sc, mfa, I2O_VERSION_11 | (4 << 16)); - iop_outl(sc, mfa + 4, I2O_MSGFUNC(I2O_TID_IOP, I2O_UTIL_NOP)); - iop_outl(sc, mfa + 8, 0); - iop_outl(sc, mfa + 12, 0); + iop_outl_rep(sc, mfa, I2O_VERSION_11 | (4 << 16)); + iop_outl_rep(sc, mfa + 4, I2O_MSGFUNC(I2O_TID_IOP, I2O_UTIL_NOP)); + iop_outl_rep(sc, mfa + 8, 0); + iop_outl_rep(sc, mfa + 12, 0); iop_outl(sc, IOP_REG_IFIFO, mfa); } Index: sys/dev/i2o/iopvar.h =================================================================== RCS file: /mirror/anoncvs/cvs/src/sys/dev/i2o/iopvar.h,v retrieving revision 1.7 diff -u -r1.7 iopvar.h --- sys/dev/i2o/iopvar.h 14 Mar 2002 01:26:53 -0000 1.7 +++ sys/dev/i2o/iopvar.h 5 Jan 2004 21:35:58 -0000 @@ -112,6 +112,9 @@ bus_space_handle_t sc_ioh; /* bus space handle */ bus_space_tag_t sc_iot; /* bus space tag */ bus_dma_tag_t sc_dmat; /* bus DMA tag */ + bus_space_handle_t sc_rep_ioh; /* Bus space handle */ + bus_space_tag_t sc_rep_iot; /* Bus space tag */ + void *sc_ih; /* interrupt handler cookie */ struct lock sc_conflock; /* autoconfiguration lock */ bus_addr_t sc_memaddr; /* register window address */