Module Name: src Committed By: matt Date: Tue Feb 1 03:16:54 UTC 2011
Modified Files: src/sys/arch/mips/sibyte/dev: sbgbus.c sbjcn.c sbjcnvar.h sbmac.c sbobio.c sbscd.c sbscn.c sbscnvar.h sbsmbus.c sbtimer.c sbwdog.c Log Message: Update to CFATTACH_DECL_NEW. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/mips/sibyte/dev/sbgbus.c cvs rdiff -u -r1.24 -r1.25 src/sys/arch/mips/sibyte/dev/sbjcn.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/mips/sibyte/dev/sbjcnvar.h cvs rdiff -u -r1.37 -r1.38 src/sys/arch/mips/sibyte/dev/sbmac.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/mips/sibyte/dev/sbobio.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/mips/sibyte/dev/sbscd.c \ src/sys/arch/mips/sibyte/dev/sbtimer.c cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mips/sibyte/dev/sbscn.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/mips/sibyte/dev/sbscnvar.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/mips/sibyte/dev/sbsmbus.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/mips/sibyte/dev/sbwdog.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/mips/sibyte/dev/sbgbus.c diff -u src/sys/arch/mips/sibyte/dev/sbgbus.c:1.11 src/sys/arch/mips/sibyte/dev/sbgbus.c:1.12 --- src/sys/arch/mips/sibyte/dev/sbgbus.c:1.11 Mon Dec 14 00:46:08 2009 +++ src/sys/arch/mips/sibyte/dev/sbgbus.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbgbus.c,v 1.11 2009/12/14 00:46:08 matt Exp $ */ +/* $NetBSD: sbgbus.c,v 1.12 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -33,32 +33,31 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbgbus.c,v 1.11 2009/12/14 00:46:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbgbus.c,v 1.12 2011/02/01 03:16:54 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> #include <sys/device.h> +#include "ioconf.h" + #include <machine/locore.h> #include <machine/sb1250/sb1250_regs.h> #include <machine/sb1250/sb1250_genbus.h> #include <sbmips/dev/sbobio/sbobiovar.h> #include <sbmips/dev/sbgbus/sbgbusvar.h> -extern struct cfdriver sbgbus_cd; - -static int sbgbus_match(struct device *, struct cfdata *, void *); -static void sbgbus_attach(struct device *, struct device *, void *); +static int sbgbus_match(device_t, cfdata_t, void *); +static void sbgbus_attach(device_t, device_t, void *); -CFATTACH_DECL(sbgbus, sizeof(struct device), +CFATTACH_DECL_NEW(sbgbus, 0, sbgbus_match, sbgbus_attach, NULL, NULL); -static int sbgbussearch(struct device *, struct cfdata *, - const int *, void *); +static int sbgbussearch(device_t, cfdata_t, const int *, void *); static int sbgbusprint(void *, const char *); static int -sbgbus_match(struct device *parent, struct cfdata *match, void *aux) +sbgbus_match(device_t parent, cfdata_t match, void *aux) { struct sbobio_attach_args *sap = aux; @@ -69,7 +68,7 @@ } static void -sbgbus_attach(struct device *parent, struct device *self, void *aux) +sbgbus_attach(device_t parent, device_t self, void *aux) { /* Configure children using indirect configuration. */ @@ -95,7 +94,7 @@ } static int -sbgbussearch(struct device *parent, struct cfdata *cf, +sbgbussearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) { struct sbgbus_attach_args sga; Index: src/sys/arch/mips/sibyte/dev/sbjcn.c diff -u src/sys/arch/mips/sibyte/dev/sbjcn.c:1.24 src/sys/arch/mips/sibyte/dev/sbjcn.c:1.25 --- src/sys/arch/mips/sibyte/dev/sbjcn.c:1.24 Mon Dec 14 00:46:08 2009 +++ src/sys/arch/mips/sibyte/dev/sbjcn.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbjcn.c,v 1.24 2009/12/14 00:46:08 matt Exp $ */ +/* $NetBSD: sbjcn.c,v 1.25 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -103,11 +103,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbjcn.c,v 1.24 2009/12/14 00:46:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbjcn.c,v 1.25 2011/02/01 03:16:54 matt Exp $"); #define SBJCN_DEBUG #include "opt_ddb.h" +#include "ioconf.h" #include <sys/param.h> #include <sys/systm.h> @@ -163,8 +164,6 @@ void sbjcn_cnputc(dev_t dev, int c); void sbjcn_cnpollc(dev_t dev, int on); -extern struct cfdriver sbjcn_cd; - dev_type_open(sbjcnopen); dev_type_close(sbjcnclose); dev_type_read(sbjcnread); @@ -218,10 +217,10 @@ void sbjcn_kgdb_putc(void *, int); #endif /* KGDB */ -static int sbjcn_match(struct device *, struct cfdata *, void *); -static void sbjcn_attach(struct device *, struct device *, void *); +static int sbjcn_match(device_t, cfdata_t, void *); +static void sbjcn_attach(device_t, device_t, void *); -CFATTACH_DECL(sbjcn, sizeof(struct sbjcn_softc), +CFATTACH_DECL_NEW(sbjcn, sizeof(struct sbjcn_softc), sbjcn_match, sbjcn_attach, NULL, NULL); #define READ_REG(rp) (mips3_ld((volatile uint64_t *)(rp))) @@ -236,7 +235,7 @@ static int -sbjcn_match(struct device *parent, struct cfdata *match, void *aux) +sbjcn_match(device_t parent, cfdata_t match, void *aux) { struct sbscd_attach_args *sap = aux; @@ -247,11 +246,12 @@ } static void -sbjcn_attach(struct device *parent, struct device *self, void *aux) +sbjcn_attach(device_t parent, device_t self, void *aux) { - struct sbjcn_softc *sc = (struct sbjcn_softc *)self; + struct sbjcn_softc *sc = device_private(self); struct sbscd_attach_args *sap = aux; + sc->sc_dev = self; sc->sc_addr = sap->sa_base + sap->sa_locs.sa_offset; printf("\n"); Index: src/sys/arch/mips/sibyte/dev/sbjcnvar.h diff -u src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.2 src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.3 --- src/sys/arch/mips/sibyte/dev/sbjcnvar.h:1.2 Fri Feb 7 17:38:49 2003 +++ src/sys/arch/mips/sibyte/dev/sbjcnvar.h Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbjcnvar.h,v 1.2 2003/02/07 17:38:49 cgd Exp $ */ +/* $NetBSD: sbjcnvar.h,v 1.3 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -163,7 +163,7 @@ }; struct sbjcn_softc { - struct device sc_dev; /* base device */ + device_t sc_dev; /* base device */ /* shared data structures */ u_long sc_addr; /* phys addr of JTAG console bus_space */ Index: src/sys/arch/mips/sibyte/dev/sbmac.c diff -u src/sys/arch/mips/sibyte/dev/sbmac.c:1.37 src/sys/arch/mips/sibyte/dev/sbmac.c:1.38 --- src/sys/arch/mips/sibyte/dev/sbmac.c:1.37 Mon Apr 5 07:19:31 2010 +++ src/sys/arch/mips/sibyte/dev/sbmac.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbmac.c,v 1.37 2010/04/05 07:19:31 joerg Exp $ */ +/* $NetBSD: sbmac.c,v 1.38 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001, 2004 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.37 2010/04/05 07:19:31 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.38 2011/02/01 03:16:54 matt Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -173,11 +173,11 @@ /* * NetBSD-specific things */ - struct device sc_dev; /* base device (must be first) */ struct ethercom sc_ethercom; /* Ethernet common part */ struct mii_data sc_mii; struct callout sc_tick_ch; + device_t sc_dev; /* device */ int sbm_if_flags; void *sbm_intrhand; @@ -255,8 +255,8 @@ static int sbmac_ether_ioctl(struct ifnet *ifp, u_long cmd, void *data); static int sbmac_ioctl(struct ifnet *, u_long, void *); static void sbmac_watchdog(struct ifnet *ifp); -static int sbmac_match(struct device *parent, struct cfdata *match, void *aux); -static void sbmac_attach(struct device *parent, struct device *self, void *aux); +static int sbmac_match(device_t parent, cfdata_t match, void *aux); +static void sbmac_attach(device_t parent, device_t self, void *aux); static int sbmac_set_speed(struct sbmac_softc *s, sbmac_speed_t speed); static int sbmac_set_duplex(struct sbmac_softc *s, sbmac_duplex_t duplex, sbmac_fc_t fc); @@ -265,11 +265,11 @@ /* Globals */ -CFATTACH_DECL(sbmac, sizeof(struct sbmac_softc), +CFATTACH_DECL_NEW(sbmac, sizeof(struct sbmac_softc), sbmac_match, sbmac_attach, NULL, NULL); -static uint32_t sbmac_mii_bitbang_read(struct device *self); -static void sbmac_mii_bitbang_write(struct device *self, uint32_t val); +static uint32_t sbmac_mii_bitbang_read(device_t self); +static void sbmac_mii_bitbang_write(device_t self, uint32_t val); static const struct mii_bitbang_ops sbmac_mii_bitbang_ops = { sbmac_mii_bitbang_read, @@ -284,9 +284,9 @@ }; static uint32_t -sbmac_mii_bitbang_read(struct device *self) +sbmac_mii_bitbang_read(device_t self) { - struct sbmac_softc *sc = (void *) self; + struct sbmac_softc *sc = device_private(self); sbmac_port_t reg; reg = PKSEG1(sc->sbm_base + R_MAC_MDIO); @@ -294,9 +294,9 @@ } static void -sbmac_mii_bitbang_write(struct device *self, uint32_t val) +sbmac_mii_bitbang_write(device_t self, uint32_t val) { - struct sbmac_softc *sc = (void *) self; + struct sbmac_softc *sc = device_private(self); sbmac_port_t reg; reg = PKSEG1(sc->sbm_base + R_MAC_MDIO); @@ -309,7 +309,7 @@ * Read an PHY register through the MII. */ static int -sbmac_mii_readreg(struct device *self, int phy, int reg) +sbmac_mii_readreg(device_t self, int phy, int reg) { return (mii_bitbang_readreg(self, &sbmac_mii_bitbang_ops, phy, reg)); @@ -319,16 +319,16 @@ * Write to a PHY register through the MII. */ static void -sbmac_mii_writereg(struct device *self, int phy, int reg, int val) +sbmac_mii_writereg(device_t self, int phy, int reg, int val) { mii_bitbang_writereg(self, &sbmac_mii_bitbang_ops, phy, reg, val); } static void -sbmac_mii_statchg(struct device *self) +sbmac_mii_statchg(device_t self) { - struct sbmac_softc *sc = (struct sbmac_softc *)self; + struct sbmac_softc *sc = device_private(self); sbmac_state_t oldstate; /* Stop the MAC in preparation for changing all of the parameters. */ @@ -364,7 +364,7 @@ } /* - * SBDMA_INITCTX(d, s, chan, txrx, maxdescr) + * SBDMA_INITCTX(d, sc, chan, txrx, maxdescr) * * Initialize a DMA channel context. Since there are potentially * eight DMA channels per MAC, it's nice to do this in a standard @@ -382,14 +382,14 @@ */ static void -sbdma_initctx(sbmacdma_t *d, struct sbmac_softc *s, int chan, int txrx, +sbdma_initctx(sbmacdma_t *d, struct sbmac_softc *sc, int chan, int txrx, int maxdescr) { /* * Save away interesting stuff in the structure */ - d->sbdma_eth = s; + d->sbdma_eth = sc; d->sbdma_channel = chan; d->sbdma_txdir = txrx; @@ -397,15 +397,15 @@ * initialize register pointers */ - d->sbdma_config0 = PKSEG1(s->sbm_base + + d->sbdma_config0 = PKSEG1(sc->sbm_base + R_MAC_DMA_REGISTER(txrx, chan, R_MAC_DMA_CONFIG0)); - d->sbdma_config1 = PKSEG1(s->sbm_base + + d->sbdma_config1 = PKSEG1(sc->sbm_base + R_MAC_DMA_REGISTER(txrx, chan, R_MAC_DMA_CONFIG1)); - d->sbdma_dscrbase = PKSEG1(s->sbm_base + + d->sbdma_dscrbase = PKSEG1(sc->sbm_base + R_MAC_DMA_REGISTER(txrx, chan, R_MAC_DMA_DSCR_BASE)); - d->sbdma_dscrcnt = PKSEG1(s->sbm_base + + d->sbdma_dscrcnt = PKSEG1(sc->sbm_base + R_MAC_DMA_REGISTER(txrx, chan, R_MAC_DMA_DSCR_CNT)); - d->sbdma_curdscr = PKSEG1(s->sbm_base + + d->sbdma_curdscr = PKSEG1(sc->sbm_base + R_MAC_DMA_REGISTER(txrx, chan, R_MAC_DMA_CUR_DSCRADDR)); /* @@ -508,15 +508,15 @@ if (m == NULL) { MGETHDR(m_new, M_DONTWAIT, MT_DATA); if (m_new == NULL) { - printf("%s: mbuf allocation failed\n", - d->sbdma_eth->sc_dev.dv_xname); + aprint_error_dev(d->sbdma_eth->sc_dev, + "mbuf allocation failed\n"); return ENOBUFS; } MCLGET(m_new, M_DONTWAIT); if (!(m_new->m_flags & M_EXT)) { - printf("%s: mbuf cluster allocation failed\n", - d->sbdma_eth->sc_dev.dv_xname); + aprint_error_dev(d->sbdma_eth->sc_dev, + "mbuf cluster allocation failed\n"); m_freem(m_new); return ENOBUFS; } @@ -721,16 +721,16 @@ MGETHDR(m_new,M_DONTWAIT,MT_DATA); if (m_new == NULL) { - printf("%s: mbuf allocation failed\n", - d->sbdma_eth->sc_dev.dv_xname); + aprint_error_dev(d->sbdma_eth->sc_dev, + "mbuf allocation failed\n"); SBMAC_EVCNT_INCR(sc->sbm_ev_txdrop); return ENOBUFS; } MCLGET(m_new,M_DONTWAIT); if (!(m_new->m_flags & M_EXT)) { - printf("%s: mbuf cluster allocation failed\n", - d->sbdma_eth->sc_dev.dv_xname); + aprint_error_dev(d->sbdma_eth->sc_dev, + "mbuf cluster allocation failed\n"); m_freem(m_new); SBMAC_EVCNT_INCR(sc->sbm_ev_txdrop); return ENOBUFS; @@ -1060,67 +1060,68 @@ */ static void -sbmac_initctx(struct sbmac_softc *s) +sbmac_initctx(struct sbmac_softc *sc) { + const char * const xname = device_xname(sc->sc_dev); uint64_t sysrev; /* * figure out the addresses of some ports */ - s->sbm_macenable = PKSEG1(s->sbm_base + R_MAC_ENABLE); - s->sbm_maccfg = PKSEG1(s->sbm_base + R_MAC_CFG); - s->sbm_fifocfg = PKSEG1(s->sbm_base + R_MAC_THRSH_CFG); - s->sbm_framecfg = PKSEG1(s->sbm_base + R_MAC_FRAMECFG); - s->sbm_rxfilter = PKSEG1(s->sbm_base + R_MAC_ADFILTER_CFG); - s->sbm_isr = PKSEG1(s->sbm_base + R_MAC_STATUS); - s->sbm_imr = PKSEG1(s->sbm_base + R_MAC_INT_MASK); + sc->sbm_macenable = PKSEG1(sc->sbm_base + R_MAC_ENABLE); + sc->sbm_maccfg = PKSEG1(sc->sbm_base + R_MAC_CFG); + sc->sbm_fifocfg = PKSEG1(sc->sbm_base + R_MAC_THRSH_CFG); + sc->sbm_framecfg = PKSEG1(sc->sbm_base + R_MAC_FRAMECFG); + sc->sbm_rxfilter = PKSEG1(sc->sbm_base + R_MAC_ADFILTER_CFG); + sc->sbm_isr = PKSEG1(sc->sbm_base + R_MAC_STATUS); + sc->sbm_imr = PKSEG1(sc->sbm_base + R_MAC_INT_MASK); /* * Initialize the DMA channels. Right now, only one per MAC is used * Note: Only do this _once_, as it allocates memory from the kernel! */ - sbdma_initctx(&(s->sbm_txdma), s, 0, DMA_TX, SBMAC_MAX_TXDESCR); - sbdma_initctx(&(s->sbm_rxdma), s, 0, DMA_RX, SBMAC_MAX_RXDESCR); + sbdma_initctx(&(sc->sbm_txdma), sc, 0, DMA_TX, SBMAC_MAX_TXDESCR); + sbdma_initctx(&(sc->sbm_rxdma), sc, 0, DMA_RX, SBMAC_MAX_RXDESCR); /* * initial state is OFF */ - s->sbm_state = sbmac_state_off; + sc->sbm_state = sbmac_state_off; /* * Initial speed is (XXX TEMP) 10MBit/s HDX no FC */ - s->sbm_speed = sbmac_speed_10; - s->sbm_duplex = sbmac_duplex_half; - s->sbm_fc = sbmac_fc_disabled; + sc->sbm_speed = sbmac_speed_10; + sc->sbm_duplex = sbmac_duplex_half; + sc->sbm_fc = sbmac_fc_disabled; /* * Determine SOC type. 112x has Pass3 SOC features. */ sysrev = SBMAC_READCSR( PKSEG1(A_SCD_SYSTEM_REVISION) ); - s->sbm_pass3_dma = (SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1120 || + sc->sbm_pass3_dma = (SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1120 || SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1125 || SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1125H || (SYS_SOC_TYPE(sysrev) == K_SYS_SOC_TYPE_BCM1250 && G_SYS_REVISION(sysrev) >= K_SYS_REVISION_BCM1250_PASS3)); #ifdef SBMAC_EVENT_COUNTERS - evcnt_attach_dynamic(&s->sbm_ev_rxintr, EVCNT_TYPE_INTR, - NULL, s->sc_dev.dv_xname, "rxintr"); - evcnt_attach_dynamic(&s->sbm_ev_txintr, EVCNT_TYPE_INTR, - NULL, s->sc_dev.dv_xname, "txintr"); - evcnt_attach_dynamic(&s->sbm_ev_txdrop, EVCNT_TYPE_MISC, - NULL, s->sc_dev.dv_xname, "txdrop"); - evcnt_attach_dynamic(&s->sbm_ev_txstall, EVCNT_TYPE_MISC, - NULL, s->sc_dev.dv_xname, "txstall"); - if (s->sbm_pass3_dma) { - evcnt_attach_dynamic(&s->sbm_ev_txsplit, EVCNT_TYPE_MISC, - NULL, s->sc_dev.dv_xname, "pass3tx-split"); - evcnt_attach_dynamic(&s->sbm_ev_txkeep, EVCNT_TYPE_MISC, - NULL, s->sc_dev.dv_xname, "pass3tx-keep"); + evcnt_attach_dynamic(&sc->sbm_ev_rxintr, EVCNT_TYPE_INTR, + NULL, xname, "rxintr"); + evcnt_attach_dynamic(&sc->sbm_ev_txintr, EVCNT_TYPE_INTR, + NULL, xname, "txintr"); + evcnt_attach_dynamic(&sc->sbm_ev_txdrop, EVCNT_TYPE_MISC, + NULL, xname, "txdrop"); + evcnt_attach_dynamic(&sc->sbm_ev_txstall, EVCNT_TYPE_MISC, + NULL, xname, "txstall"); + if (sc->sbm_pass3_dma) { + evcnt_attach_dynamic(&sc->sbm_ev_txsplit, EVCNT_TYPE_MISC, + NULL, xname, "pass3tx-split"); + evcnt_attach_dynamic(&sc->sbm_ev_txkeep, EVCNT_TYPE_MISC, + NULL, xname, "pass3tx-keep"); } #endif } @@ -1138,7 +1139,7 @@ */ static void -sbmac_channel_start(struct sbmac_softc *s) +sbmac_channel_start(struct sbmac_softc *sc) { uint64_t reg; sbmac_port_t port; @@ -1151,20 +1152,20 @@ * Don't do this if running */ - if (s->sbm_state == sbmac_state_on) + if (sc->sbm_state == sbmac_state_on) return; /* * Bring the controller out of reset, but leave it off. */ - SBMAC_WRITECSR(s->sbm_macenable, 0); + SBMAC_WRITECSR(sc->sbm_macenable, 0); /* * Ignore all received packets */ - SBMAC_WRITECSR(s->sbm_rxfilter, 0); + SBMAC_WRITECSR(sc->sbm_rxfilter, 0); /* * Calculate values for various control registers. @@ -1194,7 +1195,7 @@ * Clear out the hash address map */ - port = PKSEG1(s->sbm_base + R_MAC_HASH_BASE); + port = PKSEG1(sc->sbm_base + R_MAC_HASH_BASE); for (idx = 0; idx < MAC_HASH_COUNT; idx++) { SBMAC_WRITECSR(port, 0); port += sizeof(uint64_t); @@ -1204,7 +1205,7 @@ * Clear out the exact-match table */ - port = PKSEG1(s->sbm_base + R_MAC_ADDR_BASE); + port = PKSEG1(sc->sbm_base + R_MAC_ADDR_BASE); for (idx = 0; idx < MAC_ADDR_COUNT; idx++) { SBMAC_WRITECSR(port, 0); port += sizeof(uint64_t); @@ -1214,13 +1215,13 @@ * Clear out the DMA Channel mapping table registers */ - port = PKSEG1(s->sbm_base + R_MAC_CHUP0_BASE); + port = PKSEG1(sc->sbm_base + R_MAC_CHUP0_BASE); for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { SBMAC_WRITECSR(port, 0); port += sizeof(uint64_t); } - port = PKSEG1(s->sbm_base + R_MAC_CHLO0_BASE); + port = PKSEG1(sc->sbm_base + R_MAC_CHLO0_BASE); for (idx = 0; idx < MAC_CHMAP_COUNT; idx++) { SBMAC_WRITECSR(port, 0); port += sizeof(uint64_t); @@ -1231,11 +1232,11 @@ * register as well as the first filter register. */ - reg = sbmac_addr2reg(s->sbm_hwaddr); + reg = sbmac_addr2reg(sc->sbm_hwaddr); - port = PKSEG1(s->sbm_base + R_MAC_ADDR_BASE); + port = PKSEG1(sc->sbm_base + R_MAC_ADDR_BASE); SBMAC_WRITECSR(port, reg); - port = PKSEG1(s->sbm_base + R_MAC_ETHERNET_ADDR); + port = PKSEG1(sc->sbm_base + R_MAC_ETHERNET_ADDR); SBMAC_WRITECSR(port, 0); // pass1 workaround /* @@ -1243,44 +1244,44 @@ * to the various config registers */ - SBMAC_WRITECSR(s->sbm_rxfilter, 0); - SBMAC_WRITECSR(s->sbm_imr, 0); - SBMAC_WRITECSR(s->sbm_framecfg, framecfg); - SBMAC_WRITECSR(s->sbm_fifocfg, fifo); - SBMAC_WRITECSR(s->sbm_maccfg, cfg); + SBMAC_WRITECSR(sc->sbm_rxfilter, 0); + SBMAC_WRITECSR(sc->sbm_imr, 0); + SBMAC_WRITECSR(sc->sbm_framecfg, framecfg); + SBMAC_WRITECSR(sc->sbm_fifocfg, fifo); + SBMAC_WRITECSR(sc->sbm_maccfg, cfg); /* * Initialize DMA channels (rings should be ok now) */ - sbdma_channel_start(&(s->sbm_rxdma)); - sbdma_channel_start(&(s->sbm_txdma)); + sbdma_channel_start(&(sc->sbm_rxdma)); + sbdma_channel_start(&(sc->sbm_txdma)); /* * Configure the speed, duplex, and flow control */ - sbmac_set_speed(s, s->sbm_speed); - sbmac_set_duplex(s, s->sbm_duplex, s->sbm_fc); + sbmac_set_speed(sc, sc->sbm_speed); + sbmac_set_duplex(sc, sc->sbm_duplex, sc->sbm_fc); /* * Fill the receive ring */ - sbdma_fillring(&(s->sbm_rxdma)); + sbdma_fillring(&(sc->sbm_rxdma)); /* * Turn on the rest of the bits in the enable register */ - SBMAC_WRITECSR(s->sbm_macenable, M_MAC_RXDMA_EN0 | M_MAC_TXDMA_EN0 | + SBMAC_WRITECSR(sc->sbm_macenable, M_MAC_RXDMA_EN0 | M_MAC_TXDMA_EN0 | M_MAC_RX_ENABLE | M_MAC_TX_ENABLE); /* * Accept any kind of interrupt on TX and RX DMA channel 0 */ - SBMAC_WRITECSR(s->sbm_imr, + SBMAC_WRITECSR(sc->sbm_imr, (M_MAC_INT_CHANNEL << S_MAC_TX_CH0) | (M_MAC_INT_CHANNEL << S_MAC_RX_CH0)); @@ -1288,51 +1289,51 @@ * Enable receiving unicasts and broadcasts */ - SBMAC_WRITECSR(s->sbm_rxfilter, M_MAC_UCAST_EN | M_MAC_BCAST_EN); + SBMAC_WRITECSR(sc->sbm_rxfilter, M_MAC_UCAST_EN | M_MAC_BCAST_EN); /* * On chips which support unaligned DMA features, set the descriptor * ring for transmit channels to use the unaligned buffer format. */ - txdma = &(s->sbm_txdma); + txdma = &(sc->sbm_txdma); - if (s->sbm_pass3_dma) { + if (sc->sbm_pass3_dma) { dma_cfg0 = SBMAC_READCSR(txdma->sbdma_config0); dma_cfg0 |= V_DMA_DESC_TYPE(K_DMA_DESC_TYPE_RING_UAL_RMW) | M_DMA_TBX_EN | M_DMA_TDX_EN; SBMAC_WRITECSR(txdma->sbdma_config0,dma_cfg0); - fifo_cfg = SBMAC_READCSR(s->sbm_fifocfg); + fifo_cfg = SBMAC_READCSR(sc->sbm_fifocfg); fifo_cfg |= V_MAC_TX_WR_THRSH(8) | V_MAC_TX_RD_THRSH(8) | V_MAC_TX_RL_THRSH(8); - SBMAC_WRITECSR(s->sbm_fifocfg,fifo_cfg); + SBMAC_WRITECSR(sc->sbm_fifocfg,fifo_cfg); } /* * we're running now. */ - s->sbm_state = sbmac_state_on; - s->sc_ethercom.ec_if.if_flags |= IFF_RUNNING; + sc->sbm_state = sbmac_state_on; + sc->sc_ethercom.ec_if.if_flags |= IFF_RUNNING; /* * Program multicast addresses */ - sbmac_setmulti(s); + sbmac_setmulti(sc); /* * If channel was in promiscuous mode before, turn that on */ - if (s->sc_ethercom.ec_if.if_flags & IFF_PROMISC) - sbmac_promiscuous_mode(s, 1); + if (sc->sc_ethercom.ec_if.if_flags & IFF_PROMISC) + sbmac_promiscuous_mode(sc, 1); /* * Turn on the once-per-second timer */ - callout_reset(&(s->sc_tick_ch), hz, sbmac_tick, s); + callout_reset(&(sc->sc_tick_ch), hz, sbmac_tick, sc); } /* @@ -1348,39 +1349,39 @@ */ static void -sbmac_channel_stop(struct sbmac_softc *s) +sbmac_channel_stop(struct sbmac_softc *sc) { uint64_t ctl; /* don't do this if already stopped */ - if (s->sbm_state == sbmac_state_off) + if (sc->sbm_state == sbmac_state_off) return; /* don't accept any packets, disable all interrupts */ - SBMAC_WRITECSR(s->sbm_rxfilter, 0); - SBMAC_WRITECSR(s->sbm_imr, 0); + SBMAC_WRITECSR(sc->sbm_rxfilter, 0); + SBMAC_WRITECSR(sc->sbm_imr, 0); /* Turn off ticker */ - callout_stop(&(s->sc_tick_ch)); + callout_stop(&(sc->sc_tick_ch)); /* turn off receiver and transmitter */ - ctl = SBMAC_READCSR(s->sbm_macenable); + ctl = SBMAC_READCSR(sc->sbm_macenable); ctl &= ~(M_MAC_RXDMA_EN0 | M_MAC_TXDMA_EN0); - SBMAC_WRITECSR(s->sbm_macenable, ctl); + SBMAC_WRITECSR(sc->sbm_macenable, ctl); /* We're stopped now. */ - s->sbm_state = sbmac_state_off; - s->sc_ethercom.ec_if.if_flags &= ~IFF_RUNNING; + sc->sbm_state = sbmac_state_off; + sc->sc_ethercom.ec_if.if_flags &= ~IFF_RUNNING; /* Empty the receive and transmit rings */ - sbdma_emptyring(&(s->sbm_rxdma)); - sbdma_emptyring(&(s->sbm_txdma)); + sbdma_emptyring(&(sc->sbm_rxdma)); + sbdma_emptyring(&(sc->sbm_txdma)); } /* @@ -1474,7 +1475,7 @@ s = splnet(); mii_pollstat(&sc->sc_mii); /* poll phy for current speed */ - sbmac_mii_statchg((struct device *) sc); /* set state to new speed */ + sbmac_mii_statchg(sc->sc_dev); /* set state to new speed */ sbmac_set_channel_state(sc, sbmac_state_on); splx(s); @@ -1531,7 +1532,7 @@ */ static int -sbmac_set_speed(struct sbmac_softc *s, sbmac_speed_t speed) +sbmac_set_speed(struct sbmac_softc *sc, sbmac_speed_t speed) { uint64_t cfg; uint64_t framecfg; @@ -1540,17 +1541,17 @@ * Save new current values */ - s->sbm_speed = speed; + sc->sbm_speed = speed; - if (s->sbm_state != sbmac_state_off) + if (sc->sbm_state != sbmac_state_off) panic("sbmac_set_speed while MAC not off"); /* * Read current register values */ - cfg = SBMAC_READCSR(s->sbm_maccfg); - framecfg = SBMAC_READCSR(s->sbm_framecfg); + cfg = SBMAC_READCSR(sc->sbm_maccfg); + framecfg = SBMAC_READCSR(sc->sbm_framecfg); /* * Mask out the stuff we want to change @@ -1599,14 +1600,14 @@ * Send the bits back to the hardware */ - SBMAC_WRITECSR(s->sbm_framecfg, framecfg); - SBMAC_WRITECSR(s->sbm_maccfg, cfg); + SBMAC_WRITECSR(sc->sbm_framecfg, framecfg); + SBMAC_WRITECSR(sc->sbm_maccfg, cfg); return 1; } /* - * SBMAC_SET_DUPLEX(s, duplex, fc) + * SBMAC_SET_DUPLEX(sc, duplex, fc) * * Set Ethernet duplex and flow control options for this MAC * Warning: must be called when MAC is off! @@ -1622,7 +1623,7 @@ */ static int -sbmac_set_duplex(struct sbmac_softc *s, sbmac_duplex_t duplex, sbmac_fc_t fc) +sbmac_set_duplex(struct sbmac_softc *sc, sbmac_duplex_t duplex, sbmac_fc_t fc) { uint64_t cfg; @@ -1630,17 +1631,17 @@ * Save new current values */ - s->sbm_duplex = duplex; - s->sbm_fc = fc; + sc->sbm_duplex = duplex; + sc->sbm_fc = fc; - if (s->sbm_state != sbmac_state_off) + if (sc->sbm_state != sbmac_state_off) panic("sbmac_set_duplex while MAC not off"); /* * Read current register values */ - cfg = SBMAC_READCSR(s->sbm_maccfg); + cfg = SBMAC_READCSR(sc->sbm_maccfg); /* * Mask off the stuff we're about to change @@ -1668,7 +1669,7 @@ case sbmac_fc_frame: /* not valid in half duplex */ default: /* invalid selection */ panic("%s: invalid half duplex fc selection %d", - s->sc_dev.dv_xname, fc); + device_xname(sc->sc_dev), fc); return 0; } break; @@ -1689,7 +1690,7 @@ /* fall through */ default: panic("%s: invalid full duplex fc selection %d", - s->sc_dev.dv_xname, fc); + device_xname(sc->sc_dev), fc); return 0; } break; @@ -1697,7 +1698,7 @@ default: /* fall through */ case sbmac_duplex_auto: - panic("%s: bad duplex %d", s->sc_dev.dv_xname, duplex); + panic("%s: bad duplex %d", device_xname(sc->sc_dev), duplex); /* XXX not implemented */ break; } @@ -1706,7 +1707,7 @@ * Send the bits back to the hardware */ - SBMAC_WRITECSR(s->sbm_maccfg, cfg); + SBMAC_WRITECSR(sc->sbm_maccfg, cfg); return 1; } @@ -1727,7 +1728,7 @@ static void sbmac_intr(void *xsc, uint32_t status, vaddr_t pc) { - struct sbmac_softc *sc = (struct sbmac_softc *) xsc; + struct sbmac_softc *sc = xsc; struct ifnet *ifp = &sc->sc_ethercom.ec_if; uint64_t isr; @@ -2150,7 +2151,7 @@ */ static int -sbmac_match(struct device *parent, struct cfdata *match, void *aux) +sbmac_match(device_t parent, cfdata_t match, void *aux) { struct sbobio_attach_args *sap = aux; @@ -2261,17 +2262,18 @@ */ static void -sbmac_attach(struct device *parent, struct device *self, void *aux) +sbmac_attach(device_t parent, device_t self, void *aux) { struct ifnet *ifp; - struct sbmac_softc *sc; + struct sbmac_softc *sc = device_private(self); + const char * const xname = device_xname(self); struct sbobio_attach_args *sap = aux; u_char *eaddr; static int unit = 0; /* XXX */ uint64_t ea_reg; int idx; - sc = (struct sbmac_softc *)self; + sc->sc_dev = self; /* Determine controller base address */ @@ -2324,10 +2326,9 @@ * Display Ethernet address (this is called during the config process * so we need to finish off the config message that was being displayed) */ - printf(": Ethernet%s\n", + aprint_normal(": Ethernet%s\n", sc->sbm_pass3_dma ? ", using unaligned tx DMA" : ""); - printf("%s: Ethernet address: %s\n", self->dv_xname, - ether_sprintf(eaddr)); + aprint_normal_dev(self, "Ethernet address: %s\n", ether_sprintf(eaddr)); /* @@ -2336,7 +2337,7 @@ ifp = &sc->sc_ethercom.ec_if; ifp->if_softc = sc; - memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ); + memcpy(ifp->if_xname, xname, IFNAMSIZ); ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST | IFF_NOTRAILERS; ifp->if_ioctl = sbmac_ioctl; @@ -2358,7 +2359,7 @@ sc->sc_ethercom.ec_mii = &sc->sc_mii; ifmedia_init(&sc->sc_mii.mii_media, 0, ether_mediachange, ether_mediastatus); - mii_attach(&sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, + mii_attach(sc->sc_dev, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0); if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) { Index: src/sys/arch/mips/sibyte/dev/sbobio.c diff -u src/sys/arch/mips/sibyte/dev/sbobio.c:1.18 src/sys/arch/mips/sibyte/dev/sbobio.c:1.19 --- src/sys/arch/mips/sibyte/dev/sbobio.c:1.18 Mon Dec 14 00:46:08 2009 +++ src/sys/arch/mips/sibyte/dev/sbobio.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbobio.c,v 1.18 2009/12/14 00:46:08 matt Exp $ */ +/* $NetBSD: sbobio.c,v 1.19 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbobio.c,v 1.18 2009/12/14 00:46:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbobio.c,v 1.19 2011/02/01 03:16:54 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -48,10 +48,10 @@ #include "locators.h" -static int sbobio_match(struct device *, struct cfdata *, void *); -static void sbobio_attach(struct device *, struct device *, void *); +static int sbobio_match(device_t, cfdata_t, void *); +static void sbobio_attach(device_t, device_t, void *); -CFATTACH_DECL(sbobio, sizeof(struct device), +CFATTACH_DECL_NEW(sbobio, 0, sbobio_match, sbobio_attach, NULL, NULL); static int sbobio_print(void *, const char *); @@ -171,7 +171,7 @@ sizeof sb112x_sbobio_devs / sizeof sb112x_sbobio_devs[0]; static int -sbobio_match(struct device *parent, struct cfdata *match, void *aux) +sbobio_match(device_t parent, cfdata_t match, void *aux) { struct zbbus_attach_args *zap = aux; uint64_t sysrev; @@ -195,7 +195,7 @@ } static void -sbobio_attach(struct device *parent, struct device *self, void *aux) +sbobio_attach(device_t parent, device_t self, void *aux) { struct sbobio_attach_args sa; const char *dscr; Index: src/sys/arch/mips/sibyte/dev/sbscd.c diff -u src/sys/arch/mips/sibyte/dev/sbscd.c:1.15 src/sys/arch/mips/sibyte/dev/sbscd.c:1.16 --- src/sys/arch/mips/sibyte/dev/sbscd.c:1.15 Wed Aug 12 12:56:29 2009 +++ src/sys/arch/mips/sibyte/dev/sbscd.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbscd.c,v 1.15 2009/08/12 12:56:29 simonb Exp $ */ +/* $NetBSD: sbscd.c,v 1.16 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbscd.c,v 1.15 2009/08/12 12:56:29 simonb Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbscd.c,v 1.16 2011/02/01 03:16:54 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -47,10 +47,10 @@ #include "locators.h" -static int sbscd_match(struct device *, struct cfdata *, void *); -static void sbscd_attach(struct device *, struct device *, void *); +static int sbscd_match(device_t, cfdata_t, void *); +static void sbscd_attach(device_t, device_t, void *); -CFATTACH_DECL(sbscd, sizeof(struct device), +CFATTACH_DECL_NEW(sbscd, 0, sbscd_match, sbscd_attach, NULL, NULL); static int sbscd_print(void *, const char *); @@ -88,7 +88,7 @@ static const int sb1250_sbscd_dev_count = __arraycount(sb1250_sbscd_devs); static int -sbscd_match(struct device *parent, struct cfdata *match, void *aux) +sbscd_match(device_t parent, cfdata_t match, void *aux) { struct zbbus_attach_args *zap = aux; @@ -99,7 +99,7 @@ } static void -sbscd_attach(struct device *parent, struct device *self, void *aux) +sbscd_attach(device_t parent, device_t self, void *aux) { struct sbscd_attach_args sa; int i; Index: src/sys/arch/mips/sibyte/dev/sbtimer.c diff -u src/sys/arch/mips/sibyte/dev/sbtimer.c:1.15 src/sys/arch/mips/sibyte/dev/sbtimer.c:1.16 --- src/sys/arch/mips/sibyte/dev/sbtimer.c:1.15 Mon Dec 14 00:46:08 2009 +++ src/sys/arch/mips/sibyte/dev/sbtimer.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbtimer.c,v 1.15 2009/12/14 00:46:08 matt Exp $ */ +/* $NetBSD: sbtimer.c,v 1.16 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbtimer.c,v 1.15 2009/12/14 00:46:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbtimer.c,v 1.16 2011/02/01 03:16:54 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -47,7 +47,7 @@ #include <mips/sibyte/dev/sbscdvar.h> struct sbtimer_softc { - struct device sc_dev; + device_t sc_dev; void *sc_intrhand; int sc_flags; void *sc_addr_icnt, *sc_addr_cnt, *sc_addr_cfg; @@ -58,10 +58,10 @@ #define READ_REG(rp) (mips3_ld((volatile uint64_t *)(rp))) #define WRITE_REG(rp, val) (mips3_sd((volatile uint64_t *)(rp), (val))) -static int sbtimer_match(struct device *, struct cfdata *, void *); -static void sbtimer_attach(struct device *, struct device *, void *); +static int sbtimer_match(device_t, cfdata_t, void *); +static void sbtimer_attach(device_t, device_t, void *); -CFATTACH_DECL(sbtimer, sizeof(struct sbtimer_softc), +CFATTACH_DECL_NEW(sbtimer, sizeof(struct sbtimer_softc), sbtimer_match, sbtimer_attach, NULL, NULL); static void sbtimer_clockintr(void *arg, uint32_t status, vaddr_t pc); @@ -71,7 +71,7 @@ static void sbtimer_clock_init(void *arg); static int -sbtimer_match(struct device *parent, struct cfdata *match, void *aux) +sbtimer_match(device_t parent, cfdata_t match, void *aux) { struct sbscd_attach_args *sap = aux; @@ -82,15 +82,17 @@ } static void -sbtimer_attach(struct device *parent, struct device *self, void *aux) +sbtimer_attach(device_t parent, device_t self, void *aux) { struct sbscd_attach_args *sa = aux; - struct sbtimer_softc *sc = (struct sbtimer_softc *)self; + struct sbtimer_softc *sc = device_private(self); void (*fun)(void *, uint32_t, vaddr_t); int ipl; const char *comment = ""; - sc->sc_flags = device_cfdata(&sc->sc_dev)->cf_flags; + sc->sc_dev = self; + + sc->sc_flags = device_cfdata(sc->sc_dev)->cf_flags; sc->sc_addr_icnt = (uint64_t *)MIPS_PHYS_TO_KSEG1(sa->sa_locs.sa_addr + R_SCD_TIMER_INIT); sc->sc_addr_cnt = (uint64_t *)MIPS_PHYS_TO_KSEG1(sa->sa_locs.sa_addr + @@ -141,8 +143,9 @@ sbtimer_clock_init(void *arg) { struct sbtimer_softc *sc = arg; + const char * const xname = device_xname(sc->sc_dev); - printf("%s: ", sc->sc_dev.dv_xname); + printf("%s: ", xname); if ((1000000 % hz) == 0) printf("%dHz system timer\n", hz); else { @@ -154,7 +157,7 @@ WRITE_REG(sc->sc_addr_cfg, 0x00); /* XXX */ if (G_SYS_PLL_DIV(READ_REG(MIPS_PHYS_TO_KSEG1(A_SCD_SYSTEM_CFG))) == 0) { printf("%s: PLL_DIV == 0; speeding up clock ticks for simulator\n", - sc->sc_dev.dv_xname); + xname); WRITE_REG(sc->sc_addr_icnt, (tick/100) - 1); /* XXX */ } else { WRITE_REG(sc->sc_addr_icnt, tick - 1); /* XXX */ Index: src/sys/arch/mips/sibyte/dev/sbscn.c diff -u src/sys/arch/mips/sibyte/dev/sbscn.c:1.31 src/sys/arch/mips/sibyte/dev/sbscn.c:1.32 --- src/sys/arch/mips/sibyte/dev/sbscn.c:1.31 Mon Dec 14 00:46:08 2009 +++ src/sys/arch/mips/sibyte/dev/sbscn.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbscn.c,v 1.31 2009/12/14 00:46:08 matt Exp $ */ +/* $NetBSD: sbscn.c,v 1.32 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -109,11 +109,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.31 2009/12/14 00:46:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.32 2011/02/01 03:16:54 matt Exp $"); #define SBSCN_DEBUG #include "opt_ddb.h" +#include "ioconf.h" #include "rnd.h" #if NRND > 0 && defined(RND_SBSCN) @@ -175,8 +176,6 @@ void sbscn_cnputc(dev_t dev, int c); void sbscn_cnpollc(dev_t dev, int on); -extern struct cfdriver sbscn_cd; - dev_type_open(sbscnopen); dev_type_close(sbscnclose); dev_type_read(sbscnread); @@ -228,10 +227,10 @@ void sbscn_kgdb_putc(void *, int); #endif /* KGDB */ -static int sbscn_match(struct device *, struct cfdata *, void *); -static void sbscn_attach(struct device *, struct device *, void *); +static int sbscn_match(device_t, cfdata_t, void *); +static void sbscn_attach(device_t, device_t, void *); -CFATTACH_DECL(sbscn, sizeof(struct sbscn_softc), +CFATTACH_DECL_NEW(sbscn, sizeof(struct sbscn_softc), sbscn_match, sbscn_attach, NULL, NULL); #define READ_REG(rp) (mips3_ld((volatile uint64_t *)(rp))) @@ -258,7 +257,7 @@ } while (0) static int -sbscn_match(struct device *parent, struct cfdata *match, void *aux) +sbscn_match(device_t parent, cfdata_t match, void *aux) { struct sbobio_attach_args *sap = aux; @@ -269,9 +268,9 @@ } static void -sbscn_attach(struct device *parent, struct device *self, void *aux) +sbscn_attach(device_t parent, device_t self, void *aux) { - struct sbscn_softc *sc = (struct sbscn_softc *)self; + struct sbscn_softc *sc = device_private(self); struct sbobio_attach_args *sap = aux; int i; @@ -343,8 +342,9 @@ ch->ch_tty = tp; ch->ch_rbuf = malloc(sbscn_rbuf_size << 1, M_DEVBUF, M_NOWAIT); if (ch->ch_rbuf == NULL) { - printf("%s: channel %d: unable to allocate ring buffer\n", - sc->sc_dev.dv_xname, chan); + aprint_error_dev(sc->sc_dev, + "channel %d: unable to allocate ring buffer\n", + chan); return; } ch->ch_ebuf = ch->ch_rbuf + (sbscn_rbuf_size << 1); @@ -358,9 +358,10 @@ maj = cdevsw_lookup_major(&sbscn_cdevsw); cn_tab->cn_dev = makedev(maj, - (device_unit(&sc->sc_dev) << 1) + chan); + (device_unit(sc->sc_dev) << 1) + chan); - printf("%s: channel %d: console\n", sc->sc_dev.dv_xname, chan); + aprint_normal_dev(sc->sc_dev, "channel %d: %s\n", + chan, "console"); } #ifdef KGDB @@ -373,14 +374,15 @@ sbscn_kgdb_attached = 1; SET(sc->sc_hwflags, SBSCN_HW_KGDB); - printf("%s: channel %d: kgdb\n", sc->sc_dev.dv_xname, chan); + aprint_normal_dev(sc->sc_dev, "channel %d: %s\n", + chan, "kgdb"); } #endif ch->ch_si = softint_establish(SOFTINT_SERIAL, sbscn_soft, ch); #if NRND > 0 && defined(RND_SBSCN) - rnd_attach_source(&ch->ch_rnd_source, sc->sc_dev.dv_xname, + rnd_attach_source(&ch->ch_rnd_source, device_xname(sc->sc_dev), RND_TYPE_TTY, 0); #endif @@ -425,9 +427,10 @@ { struct sbscn_softc *sc = ch->ch_sc; struct tty *tp = ch->ch_tty; + const char * const xname = device_xname(sc->sc_dev); printf("%s: chan %d: %s %sclocal %sdcd %sts_carr_on %sdtr %stx_stopped\n", - sc->sc_dev.dv_xname, ch->ch_num, str, + xname, ch->ch_num, str, ISSET(tp->t_cflag, CLOCAL) ? "+" : "-", ISSET(ch->ch_iports, ch->ch_i_dcd) ? "+" : "-", ISSET(tp->t_state, TS_CARR_ON) ? "+" : "-", @@ -435,7 +438,7 @@ ch->ch_tx_stopped ? "+" : "-"); printf("%s: chan %d: %s %scrtscts %scts %sts_ttstop %srts %xrx_flags\n", - sc->sc_dev.dv_xname, ch->ch_num, str, + xname, ch->ch_num, str, ISSET(tp->t_cflag, CRTSCTS) ? "+" : "-", ISSET(ch->ch_iports, ch->ch_i_cts) ? "+" : "-", ISSET(tp->t_state, TS_TTSTOP) ? "+" : "-", @@ -1135,8 +1138,8 @@ READ_REG(ch->ch_base + 0x60); #ifdef DIAGNOSTIC if (!timo) - printf("%s: sbscn_iflush timeout %02x\n", - ch->ch_sc->sc_dev.dv_xname, reg & 0xff); + aprint_debug_dev(ch->ch_sc->sc_dev, + "sbscn_iflush timeout %02x\n", reg & 0xff); #endif } @@ -1301,7 +1304,7 @@ splx(s); log(LOG_WARNING, "%s: channel %d: %d fifo overflow%s, %d ibuf flood%s\n", - sc->sc_dev.dv_xname, ch->ch_num, + device_xname(sc->sc_dev), ch->ch_num, overflows, overflows == 1 ? "" : "s", floods, floods == 1 ? "" : "s"); } Index: src/sys/arch/mips/sibyte/dev/sbscnvar.h diff -u src/sys/arch/mips/sibyte/dev/sbscnvar.h:1.3 src/sys/arch/mips/sibyte/dev/sbscnvar.h:1.4 --- src/sys/arch/mips/sibyte/dev/sbscnvar.h:1.3 Tue Mar 7 14:01:41 2006 +++ src/sys/arch/mips/sibyte/dev/sbscnvar.h Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbscnvar.h,v 1.3 2006/03/07 14:01:41 he Exp $ */ +/* $NetBSD: sbscnvar.h,v 1.4 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2000, 2001 @@ -162,10 +162,10 @@ }; struct sbscn_softc { - struct device sc_dev; /* base device */ + device_t sc_dev; /* base device */ /* shared data structures */ - u_long sc_addr; /* phys addr of DUART XXX bus_space */ + u_long sc_addr; /* phys addr of DUART XXX bus_space */ struct sbscn_channel sc_channels[2]; }; Index: src/sys/arch/mips/sibyte/dev/sbsmbus.c diff -u src/sys/arch/mips/sibyte/dev/sbsmbus.c:1.13 src/sys/arch/mips/sibyte/dev/sbsmbus.c:1.14 --- src/sys/arch/mips/sibyte/dev/sbsmbus.c:1.13 Tue Mar 28 17:38:25 2006 +++ src/sys/arch/mips/sibyte/dev/sbsmbus.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbsmbus.c,v 1.13 2006/03/28 17:38:25 thorpej Exp $ */ +/* $NetBSD: sbsmbus.c,v 1.14 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbsmbus.c,v 1.13 2006/03/28 17:38:25 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbsmbus.c,v 1.14 2011/02/01 03:16:54 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -50,11 +50,11 @@ #include "locators.h" -static int smbus_match(struct device *, struct cfdata *, void *); -static void smbus_attach(struct device *, struct device *, void *); +static int smbus_match(device_t, cfdata_t, void *); +static void smbus_attach(device_t, device_t, void *); static int smbus_print(void *, const char *); -CFATTACH_DECL(smbus, sizeof(struct device), +CFATTACH_DECL_NEW(smbus, 0, smbus_match, smbus_attach, NULL, NULL); /* autoconfiguration match information for zbbus children */ @@ -73,7 +73,7 @@ static int found = 0; static int -smbus_match(struct device *parent, struct cfdata *match, void *aux) +smbus_match(device_t parent, cfdata_t match, void *aux) { /* 2 SMBus's on the BCM112x and BCM1250 */ @@ -81,7 +81,7 @@ } static void -smbus_attach(struct device *parent, struct device *self, void *aux) +smbus_attach(device_t parent, device_t self, void *aux) { struct smbus_attach_args sa; int i; Index: src/sys/arch/mips/sibyte/dev/sbwdog.c diff -u src/sys/arch/mips/sibyte/dev/sbwdog.c:1.9 src/sys/arch/mips/sibyte/dev/sbwdog.c:1.10 --- src/sys/arch/mips/sibyte/dev/sbwdog.c:1.9 Mon Dec 14 00:46:08 2009 +++ src/sys/arch/mips/sibyte/dev/sbwdog.c Tue Feb 1 03:16:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: sbwdog.c,v 1.9 2009/12/14 00:46:08 matt Exp $ */ +/* $NetBSD: sbwdog.c,v 1.10 2011/02/01 03:16:54 matt Exp $ */ /* * Copyright (c) 2002 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sbwdog.c,v 1.9 2009/12/14 00:46:08 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbwdog.c,v 1.10 2011/02/01 03:16:54 matt Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,26 +58,26 @@ #define SBWDOG_DEFAULT_PERIOD 5 /* Default to 5 seconds. */ struct sbwdog_softc { - struct device sc_dev; + device_t sc_dev; struct sysmon_wdog sc_smw; u_long sc_addr; int sc_wdog_armed; int sc_wdog_period; }; -static int sbwdog_match(struct device *, struct cfdata *, void *); -static void sbwdog_attach(struct device *, struct device *, void *); +static int sbwdog_match(device_t, cfdata_t, void *); +static void sbwdog_attach(device_t, device_t, void *); static int sbwdog_tickle(struct sysmon_wdog *); static int sbwdog_setmode(struct sysmon_wdog *); -CFATTACH_DECL(sbwdog, sizeof(struct sbwdog_softc), +CFATTACH_DECL_NEW(sbwdog, sizeof(struct sbwdog_softc), sbwdog_match, sbwdog_attach, NULL, NULL); #define READ_REG(rp) (mips3_ld((volatile uint64_t *)(rp))) #define WRITE_REG(rp, val) (mips3_sd((volatile uint64_t *)(rp), (val))) static int -sbwdog_match(struct device *parent, struct cfdata *cf, void *aux) +sbwdog_match(device_t parent, cfdata_t cf, void *aux) { struct sbscd_attach_args *sa = aux; @@ -88,25 +88,26 @@ } static void -sbwdog_attach(struct device *parent, struct device *self, void *aux) +sbwdog_attach(device_t parent, device_t self, void *aux) { - struct sbwdog_softc *sc = (void *)self; + struct sbwdog_softc *sc = device_private(self); struct sbscd_attach_args *sa = aux; + sc->sc_dev = self; sc->sc_wdog_period = SBWDOG_DEFAULT_PERIOD; sc->sc_addr = MIPS_PHYS_TO_KSEG1(sa->sa_locs.sa_addr); - printf(": %d second period\n", sc->sc_wdog_period); + aprint_normal(": %d second period\n", sc->sc_wdog_period); - sc->sc_smw.smw_name = sc->sc_dev.dv_xname; + sc->sc_smw.smw_name = device_xname(sc->sc_dev); sc->sc_smw.smw_cookie = sc; sc->sc_smw.smw_setmode = sbwdog_setmode; sc->sc_smw.smw_tickle = sbwdog_tickle; sc->sc_smw.smw_period = sc->sc_wdog_period; if (sysmon_wdog_register(&sc->sc_smw) != 0) - printf("%s: unable to register with sysmon\n", - sc->sc_dev.dv_xname); + aprint_error_dev(sc->sc_dev, + "unable to register with sysmon\n"); } static int