PERFORCE change 53682 for review
Scott Long
scottl at FreeBSD.org
Fri May 28 13:36:03 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=53682
Change 53682 by scottl at scottl-esp-sparc64 on 2004/05/28 13:35:00
Start using FreeBSD bus_space conventions. Also eliminate dv_xname
usage.
Affected files ...
.. //depot/projects/scottl-esp/src/sys/dev/esp/esp_sbus.c#6 edit
.. //depot/projects/scottl-esp/src/sys/dev/esp/lsi64854var.h#3 edit
Differences ...
==== //depot/projects/scottl-esp/src/sys/dev/esp/esp_sbus.c#6 (text+ko) ====
@@ -67,16 +67,17 @@
/* #define ESP_SBUS_DEBUG */
struct esp_softc {
- struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */
+ struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */
#if 0
struct sbusdev sc_sd; /* sbus device */
#endif
- bus_space_tag_t sc_bustag;
- bus_dma_tag_t sc_dmatag;
+ int sc_rid;
+ struct resource *sc_res;
+ bus_space_handle_t sc_regh;
+ bus_space_tag_t sc_regt;
- bus_space_handle_t sc_reg; /* the registers */
- struct lsi64854_softc *sc_dma; /* pointer to my dma */
+ struct lsi64854_softc *sc_dma; /* pointer to my dma */
int sc_pri; /* SBUS priority */
};
@@ -151,136 +152,103 @@
struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
struct lsi64854_softc *lsc;
phandle_t node;
- char *name;
int burst, sbusburst;
node = sbus_get_node(dev);
- name = sbus_get_name(dev);
if (OF_getprop(node, "initiator-id", &sc->sc_id,
sizeof(sc->sc_id)) == -1)
sc->sc_id = 7;;
sc->sc_freq = sbus_get_clockfreq(dev);
#ifdef ESP_SBUS_DEBUG
- printf("%s: espattach_sbus: sc_id %d, freq %d\n",
- self->dv_xname, sc->sc_id, sc->sc_freq);
+ device_printf(dev, "espattach_sbus: sc_id %d, freq %d\n",
+ sc->sc_id, sc->sc_freq);
#endif
- if (strcmp("SUNW,fas", name) == 0) {
+ /*
+ * allocate space for dma, in SUNW,fas there are no separate
+ * dma device
+ */
+ lsc = malloc(sizeof (struct lsi64854_softc), M_DEVBUF, M_NOWAIT);
- /*
- * fas has 2 register spaces: dma(lsi64854) and SCSI core (ncr53c9x)
- */
- if (sa->sa_nreg != 2) {
- printf("%s: %d register spaces\n", self->dv_xname, sa->sa_nreg);
- return (ENXIO);
- }
+ if (lsc == NULL) {
+ device_printf(dev, "out of memory (lsi64854_softc)\n");
+ return (ENOMEM);
+ }
+ esc->sc_dma = lsc;
- /*
- * allocate space for dma, in SUNW,fas there are no separate
- * dma device
- */
- lsc = malloc(sizeof (struct lsi64854_softc), M_DEVBUF, M_NOWAIT);
+ /*
+ * fas has 2 register spaces: dma(lsi64854) and SCSI core (ncr53c9x)
+ */
- if (lsc == NULL) {
- printf("%s: out of memory (lsi64854_softc)\n",
- self->dv_xname);
- return (ENOMEM);
- }
- esc->sc_dma = lsc;
+ /* Map dma registers */
+ lsc->sc_rid = 0;
+ if ((lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &lsc->sc_rid, RF_ACTIVE)) == NULL) {
+ device_printf(dev, "cannot map dma registers\n");
+ free(lsc, M_DEVBUF);
+ return (ENXIO);
+ }
+ lsc->sc_regt = rman_get_bustag(lsc->sc_res);
+ lsc->sc_regh = rman_get_bushandle(lsc->sc_res);
- lsc->sc_bustag = sa->sa_bustag;
- lsc->sc_dmatag = sa->sa_dmatag;
+ /*
+ * XXX is this common(from bpp.c), the same in dma_sbus...etc.
+ *
+ * Get transfer burst size from PROM and plug it into the
+ * controller registers. This is needed on the Sun4m; do
+ * others need it too?
+ */
+#if 0
+ sbusburst = ((struct sbus_softc *)parent)->sc_burst;
+#endif
+ if (sbusburst == 0)
+ sbusburst = SBUS_BURST_32 - 1; /* 1->16 */
- bcopy(sc->sc_dev.dv_xname, lsc->sc_dev.dv_xname,
- sizeof (lsc->sc_dev.dv_xname));
-
- /* Map dma registers */
- if (sa->sa_npromvaddrs) {
- sbus_promaddr_to_handle(sa->sa_bustag,
- sa->sa_promvaddrs[0], &lsc->sc_regs);
- } else {
- if (sbus_bus_map(sa->sa_bustag,
- sa->sa_reg[0].oa_space,
- sa->sa_reg[0].oa_base,
- sa->sa_reg[0].oa_size,
- 0, &lsc->sc_regs) != 0) {
- printf("%s: cannot map dma registers\n",
- self->dv_xname);
- return (ENXIO);
- }
- }
+ burst = sbus_get_burstsz(dev);
- /*
- * XXX is this common(from bpp.c), the same in dma_sbus...etc.
- *
- * Get transfer burst size from PROM and plug it into the
- * controller registers. This is needed on the Sun4m; do
- * others need it too?
- */
- sbusburst = ((struct sbus_softc *)parent)->sc_burst;
- if (sbusburst == 0)
- sbusburst = SBUS_BURST_32 - 1; /* 1->16 */
-
- burst = sbus_get_burstsz(dev);
-
#if ESP_SBUS_DEBUG
- printf("espattach_sbus: burst 0x%x, sbus 0x%x\n",
- burst, sbusburst);
+ printf("espattach_sbus: burst 0x%x, sbus 0x%x\n", burst, sbusburst);
#endif
- if (burst == -1)
- /* take SBus burst sizes */
- burst = sbusburst;
+ if (burst == -1)
+ /* take SBus burst sizes */
+ burst = sbusburst;
- /* Clamp at parent's burst sizes */
- burst &= sbusburst;
- lsc->sc_burst = (burst & SBUS_BURST_32) ? 32 :
- (burst & SBUS_BURST_16) ? 16 : 0;
+ /* Clamp at parent's burst sizes */
+ burst &= sbusburst;
+ lsc->sc_burst = (burst & SBUS_BURST_32) ? 32 :
+ (burst & SBUS_BURST_16) ? 16 : 0;
- lsc->sc_channel = L64854_CHANNEL_SCSI;
- lsc->sc_client = sc;
+ lsc->sc_channel = L64854_CHANNEL_SCSI;
+ lsc->sc_client = sc;
- lsi64854_attach(lsc);
+ lsi64854_attach(lsc);
- /*
- * map SCSI core registers
- */
- if (sa->sa_npromvaddrs > 1) {
- sbus_promaddr_to_handle(sa->sa_bustag,
- sa->sa_promvaddrs[1], &esc->sc_reg);
- } else {
- if (sbus_bus_map(sa->sa_bustag,
- sa->sa_reg[1].oa_space,
- sa->sa_reg[1].oa_base,
- sa->sa_reg[1].oa_size,
- 0, &esc->sc_reg) != 0) {
- printf("%s @ sbus: "
- "cannot map scsi core registers\n",
- self->dv_xname);
- return (ENXIO);
- }
- }
+ /*
+ * map SCSI core registers
+ */
+ esc->sc_rid = 1;
+ if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &esc->sc_rid, RF_ACTIVE)) == NULL) {
+ device_printf(dev, "cannot map scsi core registers\n");
+ free(lsc, M_DEVBUF);
+ return (ENXIO);
+ }
+ esc->sc_regt = rman_get_bustag(esc->sc_res);
+ esc->sc_regh = rman_get_bushandle(esc->sc_res);
- if (sa->sa_nintr == 0) {
- printf("\n%s: no interrupt property\n", self->dv_xname);
- return (ENXIO);
- }
+#if 0
+ esc->sc_pri = sa->sa_pri;
- esc->sc_pri = sa->sa_pri;
-
-#if 0
- /* add me to the sbus structures */
- esc->sc_sd.sd_reset = (void *) ncr53c9x_reset;
- sbus_establish(&esc->sc_sd, &sc->sc_dev);
+ /* add me to the sbus structures */
+ esc->sc_sd.sd_reset = (void *) ncr53c9x_reset;
+ sbus_establish(&esc->sc_sd, &sc->sc_dev);
#endif
- espattach(esc, &esp_sbus_glue);
+ espattach(esc, &esp_sbus_glue);
- return (0);
- }
-
- return (ENXIO);
+ return (0);
}
/*
@@ -464,7 +432,7 @@
struct esp_softc *esc = (struct esp_softc *)sc;
u_char v;
- v = bus_space_read_1(esc->sc_bustag, esc->sc_reg, reg * 4);
+ v = bus_space_read_1(esc->sc_regt, esc->sc_regh, reg * 4);
#ifdef ESP_SBUS_DEBUG
if (esp_sbus_debug && (reg < 0x10) && esp__read_regnames[reg].r_flag)
printf("RD:%x <%s> %x\n", reg * 4,
@@ -486,7 +454,7 @@
printf("WR:%x <%s> %x\n", reg * 4,
((unsigned)reg < 0x10) ? esp__write_regnames[reg].r_name : "<***>", v);
#endif
- bus_space_write_1(esc->sc_bustag, esc->sc_reg, reg * 4, v);
+ bus_space_write_1(esc->sc_regt, esc->sc_regh, reg * 4, v);
}
int
==== //depot/projects/scottl-esp/src/sys/dev/esp/lsi64854var.h#3 (text+ko) ====
@@ -38,10 +38,11 @@
struct lsi64854_softc {
char *dv_name;
- bus_space_tag_t sc_bustag; /* bus tags */
- bus_dma_tag_t sc_dmatag;
- bus_space_handle_t sc_regs; /* the registers */
+ int sc_rid;
+ struct resource *sc_res;
+ bus_space_handle_t sc_regh;
+ bus_space_tag_t sc_regt;
u_int sc_rev; /* revision */
int sc_burst; /* max suported burst size */
@@ -72,10 +73,10 @@
};
#define L64854_GCSR(sc) \
- (bus_space_read_4((sc)->sc_bustag, (sc)->sc_regs, L64854_REG_CSR))
+ (bus_space_read_4((sc)->sc_regt, (sc)->sc_regh, L64854_REG_CSR))
#define L64854_SCSR(sc, csr) \
- bus_space_write_4((sc)->sc_bustag, (sc)->sc_regs, L64854_REG_CSR, csr)
+ bus_space_write_4((sc)->sc_regt, (sc)->sc_regh, L64854_REG_CSR, csr)
/*
More information about the p4-projects
mailing list