Author: andrew
Date: Sat Jan 29 00:53:58 2011
New Revision: 218055
URL: http://svn.freebsd.org/changeset/base/218055

Log:
  Use bus space functions rather than inw/outw
  to help a future port of the driver to ARM.
  
  Approved by:  imp (mentor)

Modified:
  head/sys/dev/cs/if_cs.c
  head/sys/dev/cs/if_csreg.h
  head/sys/dev/cs/if_csvar.h

Modified: head/sys/dev/cs/if_cs.c
==============================================================================
--- head/sys/dev/cs/if_cs.c     Sat Jan 29 00:46:11 2011        (r218054)
+++ head/sys/dev/cs/if_cs.c     Sat Jan 29 00:53:58 2011        (r218055)
@@ -272,8 +272,6 @@ cs_cs89x0_probe(device_t dev)
        if (error)
                return (error);
 
-       sc->nic_addr = rman_get_start(sc->port_res);
-
        if ((cs_inw(sc, ADD_PORT) & ADD_MASK) != ADD_SIG) {
                /* Chip not detected. Let's try to reset it */
                if (bootverbose)
@@ -704,7 +702,7 @@ static int
 cs_get_packet(struct cs_softc *sc)
 {
        struct ifnet *ifp = sc->ifp;
-       int iobase = sc->nic_addr, status, length;
+       int status, length;
        struct ether_header *eh;
        struct mbuf *m;
 
@@ -746,7 +744,8 @@ cs_get_packet(struct cs_softc *sc)
        m->m_len = length;
 
        /* Get the data */
-       insw(iobase + RX_FRAME_PORT, m->m_data, (length+1)>>1);
+       bus_read_multi_2(sc->port_res, RX_FRAME_PORT, mtod(m, uint16_t *),
+           (length + 1) >> 1);
 
        eh = mtod(m, struct ether_header *);
 
@@ -869,7 +868,8 @@ cs_write_mbufs( struct cs_softc *sc, str
 static void
 cs_xmit_buf( struct cs_softc *sc )
 {
-       outsw(sc->nic_addr+TX_FRAME_PORT, sc->buffer, (sc->buf_len+1)>>1);
+       bus_write_multi_2(sc->port_res, TX_FRAME_PORT, (uint16_t *)sc->buffer,
+           (sc->buf_len + 1) >> 1);
        sc->buf_len = 0;
 }
 

Modified: head/sys/dev/cs/if_csreg.h
==============================================================================
--- head/sys/dev/cs/if_csreg.h  Sat Jan 29 00:46:11 2011        (r218054)
+++ head/sys/dev/cs/if_csreg.h  Sat Jan 29 00:53:58 2011        (r218055)
@@ -30,6 +30,8 @@
  * $FreeBSD$
  */
 
+#include <sys/rman.h>
+
 #define CS_89x0_IO_PORTS       0x0020
 
 #define PP_ChipID 0x0000       /* offset   0h -> Corp -ID              */
@@ -541,21 +543,21 @@ cs_inw(struct cs_softc *sc, int off)
 {
        if (off & 1)
                device_printf(sc->dev, "BUG: inw to an odd address.\n");
-       return ((inb(sc->nic_addr + off) & 0xff) |
-           (inb(sc->nic_addr + off + 1) << 8));
+       return ((bus_read_1(sc->port_res, off)) |
+           (bus_read_1(sc->port_res, off + 1) << 8));
 }
 #else
 static __inline uint16_t
 cs_inw(struct cs_softc *sc, int off)
 {
-       return (inw(sc->nic_addr + off));
+       return (bus_read_2(sc->port_res, off));
 }
 #endif
 
 static __inline void
 cs_outw(struct cs_softc *sc, int off, uint16_t val)
 {
-       outw(sc->nic_addr + off, val);
+       bus_write_2(sc->port_res, off, val);
 }
 
 static __inline uint16_t

Modified: head/sys/dev/cs/if_csvar.h
==============================================================================
--- head/sys/dev/cs/if_csvar.h  Sat Jan 29 00:46:11 2011        (r218054)
+++ head/sys/dev/cs/if_csvar.h  Sat Jan 29 00:53:58 2011        (r218055)
@@ -57,7 +57,6 @@ struct cs_softc {
 
        int     flags;
 #define        CS_NO_IRQ       0x1
-       int     nic_addr;               /* Base IO address of card */
        int     send_cmd;
        int     line_ctl;               /* */
        int     send_underrun;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to