Port-arm archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
evbarm / INTEGRATOR ifpga device_t / softc split
Hi,
because ifpgavar.h ends up being indirectly included early by
sys/device.h, the "struct device" in that file ends up being
undeclared, causing a build failure.
The attached patch tries to remedy that by doing what is known as
a "device_t / softc" split for ifpga. It does a couple of other
minor things as well:
o converts to aprint_*() print functions
o corrects three typos
These sort of changes can sometimes be tricky, and can sometimes
result in actual run-time failures even though the source builds.
Testing would therefore be beneficial in determining that I've
not broken anything which wasn't broken before... I can at least
attest that the INTEGRATOR kernel in -current now builds after
applying the attached patches, at least :)
Since I don't have the actual hardware used by the INTEGRATOR
kernel, I'm asking here for someone who can help with actually
testing these changes.
If someone would review the changes without hardware testing,
that's of course also good.
Best regards,
- Håvard
Index: ifpga.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ifpga/ifpga.c,v
retrieving revision 1.22
diff -u -p -r1.22 ifpga.c
--- ifpga.c 27 Apr 2008 18:58:46 -0000 1.22
+++ ifpga.c 17 May 2009 12:42:21 -0000
@@ -66,12 +66,12 @@ __KERNEL_RCSID(0, "$NetBSD: ifpga.c,v 1.
#include "locators.h"
/* Prototypes */
-static int ifpga_match (struct device *, struct cfdata *, void
*);
-static void ifpga_attach (struct device *, struct device *, void *);
+static int ifpga_match (device_t, cfdata_t, void *);
+static void ifpga_attach (device_t, device_t, void *);
static int ifpga_print (void *, const char *);
/* Drive and attach structures */
-CFATTACH_DECL(ifpga, sizeof(struct ifpga_softc),
+CFATTACH_DECL_NEW(ifpga, sizeof(struct ifpga_softc),
ifpga_match, ifpga_attach, NULL, NULL);
int ifpga_found;
@@ -109,10 +109,10 @@ ifpga_print(void *aux, const char *pnp)
}
static int
-ifpga_search(struct device *parent, struct cfdata *cf,
+ifpga_search(device_t parent, cfdata_t cf,
const int *ldesc, void *aux)
{
- struct ifpga_softc *sc = (struct ifpga_softc *)parent;
+ struct ifpga_softc *sc = device_private(parent);
struct ifpga_attach_args ifa;
int tryagain;
@@ -133,7 +133,7 @@ ifpga_search(struct device *parent, stru
}
static int
-ifpga_match(struct device *parent, struct cfdata *cf, void *aux)
+ifpga_match(device_t parent, cfdata_t cf, void *aux)
{
#if 0
struct mainbus_attach_args *ma = aux;
@@ -151,9 +151,9 @@ ifpga_match(struct device *parent, struc
}
static void
-ifpga_attach(struct device *parent, struct device *self, void *aux)
+ifpga_attach(device_t parent, device_t self, void *aux)
{
- struct ifpga_softc *sc = (struct ifpga_softc *)self;
+ struct ifpga_softc *sc = device_private(self);
u_int id, sysclk;
#if defined(PCI_NETBSD_CONFIGURE) && NPCI > 0
struct extent *ioext, *memext, *pmemext;
@@ -174,6 +174,7 @@ ifpga_attach(struct device *parent, stru
ifpga_create_mem_bs_tag(&ifpga_pci_mem_tag, (void *)0);
#endif
+ sc->sc_dev = self;
sc->sc_iot = &ifpga_bs_tag;
ifpga_sc = sc;
@@ -186,53 +187,53 @@ ifpga_attach(struct device *parent, stru
id = bus_space_read_4(sc->sc_iot, sc->sc_sc_ioh, IFPGA_SC_ID);
- printf(": Build %d, ", (id & IFPGA_SC_ID_BUILD_MASK) >>
+ aprint_normal(": Build %d, ", (id & IFPGA_SC_ID_BUILD_MASK) >>
IFPGA_SC_ID_BUILD_SHIFT);
switch (id & IFPGA_SC_ID_REV_MASK)
{
case IFPGA_SC_ID_REV_A:
- printf("Rev A, ");
+ aprint_normal("Rev A, ");
break;
case IFPGA_SC_ID_REV_B:
- printf("Rev B, ");
+ aprint_normal("Rev B, ");
break;
}
- printf("Manufacturer ");
+ aprint_normal("Manufacturer ");
switch (id & IFPGA_SC_ID_MAN_MASK)
{
case IFPGA_SC_ID_MAN_ARM:
- printf("ARM Ltd,");
+ aprint_normal("ARM Ltd,");
break;
default:
- printf("Unknown,");
+ aprint_normal("Unknown,");
break;
}
switch (id & IFPGA_SC_ID_ARCH_MASK)
{
case IFPGA_SC_ID_ARCH_ASBLE:
- printf(" ASB, Little-endian,");
+ aprint_normal(" ASB, Little-endian,");
break;
case IFPGA_SC_ID_ARCH_AHBLE:
- printf(" AHB, Little-endian,");
+ aprint_normal(" AHB, Little-endian,");
break;
default:
panic(" Unsupported bus");
}
- printf("\n%s: FPGA ", self->dv_xname);
+ aprint_normal_dev(self, "FPGA ");
switch (id & IFPGA_SC_ID_FPGA_MASK)
{
case IFPGA_SC_ID_FPGA_XC4062:
- printf("XC4062");
+ aprint_normal("XC4062");
break;
case IFPGA_SC_ID_FPGA_XC4085:
- printf("XC4085");
+ aprint_normal("XC4085");
break;
default:
- printf("unknown");
+ aprint_normal("unknown");
break;
}
@@ -240,7 +241,7 @@ ifpga_attach(struct device *parent, stru
sysclk &= IFPGA_SC_OSC_S_VDW;
sysclk += 8;
- printf(", SYSCLK %d.%02dMHz", sysclk >> 2, (sysclk & 3) * 25);
+ aprint_normal(", SYSCLK %d.%02dMHz", sysclk >> 2, (sysclk & 3) * 25);
/* Map the Interrupt controller */
if (bus_space_map(sc->sc_iot, IFPGA_IO_IRQ_BASE, IFPGA_IO_IRQ_SIZE,
@@ -261,13 +262,15 @@ ifpga_attach(struct device *parent, stru
&sc->sc_tmr_ioh))
panic("%s: Cannot map timer registers", self->dv_xname);
- printf("\n");
+ aprint_normal("\n");
#if NPCI > 0
pci_sc = malloc(sizeof(struct ifpga_pci_softc), M_DEVBUF, M_WAITOK);
pci_sc->sc_iot = &ifpga_pci_io_tag;
pci_sc->sc_memt = &ifpga_pci_mem_tag;
+ pci_sc->sc_dev = self;
+
if (bus_space_map(pci_sc->sc_iot, 0, IFPGA_PCI_IO_VSIZE, 0,
&pci_sc->sc_io_ioh)
|| bus_space_map(pci_sc->sc_iot,
@@ -287,7 +290,7 @@ ifpga_attach(struct device *parent, stru
pci_sc->sc_reg_ioh, V360_PCI_CC_REV);
pci_devinfo(id_reg, class_reg, 1, buf, sizeof(buf));
- printf("%s: %s\n", self->dv_xname, buf);
+ aprint_normal_dev(self, "%s\n", buf);
}
#if defined(PCI_NETBSD_CONFIGURE)
@@ -306,7 +309,7 @@ ifpga_attach(struct device *parent, stru
extent_destroy(memext);
extent_destroy(ioext);
- printf("pci_configure_bus done\n");
+ aprint_debug("pci_configure_bus done\n");
#endif /* PCI_NETBSD_CONFIGURE */
#endif /* NPCI > 0 */
Index: ifpga_clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ifpga/ifpga_clock.c,v
retrieving revision 1.13
diff -u -p -r1.13 ifpga_clock.c
--- ifpga_clock.c 18 Mar 2009 10:22:27 -0000 1.13
+++ ifpga_clock.c 17 May 2009 12:42:21 -0000
@@ -287,7 +287,7 @@ cpu_initclocks(void)
IPL_CLOCK, clockhandler, 0);
if (ifpga_sc->sc_clockintr == NULL)
panic("%s: Cannot install timer 1 interrupt handler",
- ifpga_sc->sc_dev.dv_xname);
+ device_xname(ifpga_sc->sc_dev));
ifpga_sc->sc_clock_count
= load_timer(IFPGA_TIMER1_BASE, intvl);
@@ -306,7 +306,7 @@ cpu_initclocks(void)
IPL_HIGH, statclockhandler, 0);
if (ifpga_sc->sc_statclockintr == NULL)
panic("%s: Cannot install timer 2 interrupt handler",
- ifpga_sc->sc_dev.dv_xname);
+ device_xname(ifpga_sc->sc_dev));
load_timer(IFPGA_TIMER2_BASE, statint);
tc_init(&ifpga_timecounter);
Index: ifpga_pci.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ifpga/ifpga_pci.c,v
retrieving revision 1.12
diff -u -p -r1.12 ifpga_pci.c
--- ifpga_pci.c 11 Dec 2005 12:17:09 -0000 1.12
+++ ifpga_pci.c 17 May 2009 12:42:21 -0000
@@ -85,7 +85,7 @@ __KERNEL_RCSID(0, "$NetBSD: ifpga_pci.c,
#include <evbarm/dev/v360reg.h>
-void ifpga_pci_attach_hook (struct device *, struct device *,
+void ifpga_pci_attach_hook (device_t, device_t,
struct pcibus_attach_args *);
int ifpga_pci_bus_maxdevs (void *, int);
pcitag_t ifpga_pci_make_tag (void *, int, int, int);
@@ -150,17 +150,17 @@ struct arm32_bus_dma_tag ifpga_pci_bus_d
/*static int
pci_intr(void *arg)
{
- printf("pci int %x\n", (int)arg);
+ aprint_debug("pci int %x\n", (int)arg);
return 0;
}*/
void
-ifpga_pci_attach_hook(struct device *parent, struct device *self,
+ifpga_pci_attach_hook(device_t parent, device_t self,
struct pcibus_attach_args *pba)
{
#ifdef PCI_DEBUG
- printf("ifpga_pci_attach_hook()\n");
+ aprint_debug("ifpga_pci_attach_hook()\n");
#endif
}
@@ -168,7 +168,7 @@ int
ifpga_pci_bus_maxdevs(void *pcv, int busno)
{
#ifdef PCI_DEBUG
- printf("ifpga_pci_bus_maxdevs(pcv=%p, busno=%d)\n", pcv, busno);
+ aprint_debug("ifpga_pci_bus_maxdevs(pcv=%p, busno=%d)\n", pcv, busno);
#endif
return MAX_PCI_DEVICES;
}
@@ -177,7 +177,7 @@ pcitag_t
ifpga_pci_make_tag(void *pcv, int bus, int device, int function)
{
#ifdef PCI_DEBUG
- printf("ifpga_pci_make_tag(pcv=%p, bus=%d, device=%d, function=%d)\n",
+ aprint_debug("ifpga_pci_make_tag(pcv=%p, bus=%d, device=%d,
function=%d)\n",
pcv, bus, device, function);
#endif
return (bus << 16) | (device << 11) | (function << 8);
@@ -188,7 +188,7 @@ ifpga_pci_decompose_tag(void *pcv, pcita
int *functionp)
{
#ifdef PCI_DEBUG
- printf("ifpga_pci_decompose_tag(pcv=%p, tag=0x%08lx, bp=%p, dp=%p, "
+ aprint_debug("ifpga_pci_decompose_tag(pcv=%p, tag=0x%08lx, bp=%p,
dp=%p, "
"fp=%p)\n", pcv, tag, busp, devicep, functionp);
#endif
@@ -204,7 +204,7 @@ pcireg_t
ifpga_pci_conf_read(void *pcv, pcitag_t tag, int reg)
{
pcireg_t data;
- struct ifpga_pci_softc *sc = (struct ifpga_pci_softc *)pcv;
+ struct ifpga_pci_softc *sc = device_private(pcv);
int bus, device, function;
u_int address;
@@ -242,7 +242,7 @@ ifpga_pci_conf_read(void *pcv, pcitag_t
bus_space_write_4(sc->sc_memt, sc->sc_reg_ioh, V360_LB_BASE0,
IFPGA_PCI_APP0_256MB_BASE);
#ifdef PCI_DEBUG
- printf("ifpga_pci_conf_read(pcv=%p tag=0x%08lx reg=0x%02x)=0x%08x\n",
+ aprint_debug("ifpga_pci_conf_read(pcv=%p tag=0x%08lx
reg=0x%02x)=0x%08x\n",
pcv, tag, reg, data);
#endif
return data;
@@ -251,12 +251,12 @@ ifpga_pci_conf_read(void *pcv, pcitag_t
void
ifpga_pci_conf_write(void *pcv, pcitag_t tag, int reg, pcireg_t data)
{
- struct ifpga_pci_softc *sc = (struct ifpga_pci_softc *)pcv;
+ struct ifpga_pci_softc *sc = device_private(pcv);
int bus, device, function;
u_int address;
#ifdef PCI_DEBUG
- printf("ifpga_pci_conf_write(pcv=%p tag=0x%08lx reg=0x%02x, 0x%08x)\n",
+ aprint_debug("ifpga_pci_conf_write(pcv=%p tag=0x%08lx reg=0x%02x,
0x%08x)\n",
pcv, tag, reg, data);
#endif
@@ -307,13 +307,13 @@ ifpga_pci_intr_map(struct pci_attach_arg
int bus, device, function;
ifpga_pci_decompose_tag(pcv, intrtag, &bus, &device, &function);
- printf("ifpga_pci_intr_map: pcv=%p, tag=%08lx pin=%d line=%d "
+ aprint_debug("ifpga_pci_intr_map: pcv=%p, tag=%08lx pin=%d line=%d "
"dev=%d\n", pcv, intrtag, pin, line, device);
#endif
#ifdef PCI_DEBUG
- printf("pin %d, line %d mapped to int %d\n", pin, line, line);
+ aprint_debug("pin %d, line %d mapped to int %d\n", pin, line, line);
#endif
*ihp = line;
@@ -326,7 +326,7 @@ ifpga_pci_intr_string(void *pcv, pci_int
static char irqstr[12]; /* 6 + 1 + NULL + sanity */
#ifdef PCI_DEBUG
- printf("ifpga_pci_intr_string(pcv=%p, ih=0x%lx)\n", pcv, ih);
+ aprint_debug("ifpga_pci_intr_string(pcv=%p, ih=0x%lx)\n", pcv, ih);
#endif
if (ih == 0)
panic("ifpga_pci_intr_string: bogus handle 0x%lx", ih);
@@ -351,7 +351,7 @@ ifpga_pci_intr_establish(void *pcv, pci_
int length;
#ifdef PCI_DEBUG
- printf("ifpga_pci_intr_establish(pcv=%p, ih=0x%lx, level=%d, "
+ aprint_debug("ifpga_pci_intr_establish(pcv=%p, ih=0x%lx, level=%d, "
"func=%p, arg=%p)\n", pcv, ih, level, func, arg);
#endif
@@ -366,7 +366,7 @@ void
ifpga_pci_intr_disestablish(void *pcv, void *cookie)
{
#ifdef PCI_DEBUG
- printf("ifpga_pci_intr_disestablish(pcv=%p, cookie=%p)\n",
+ aprint_debug("ifpga_pci_intr_disestablish(pcv=%p, cookie=%p)\n",
pcv, cookie);
#endif
/* XXXX Need to free the string */
Index: ifpga_pcivar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ifpga/ifpga_pcivar.h,v
retrieving revision 1.1
diff -u -p -r1.1 ifpga_pcivar.h
--- ifpga_pcivar.h 27 Oct 2001 16:19:09 -0000 1.1
+++ ifpga_pcivar.h 17 May 2009 12:42:21 -0000
@@ -30,7 +30,7 @@
*/
struct ifpga_pci_softc {
- struct device sc_dev;
+ device_t sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_io_ioh;
@@ -42,16 +42,16 @@ struct ifpga_pci_softc {
bus_space_handle_t sc_reg_ioh;
};
-/* Apperture 0, 256MB normal cycles. */
+/* Aperture 0, 256MB normal cycles. */
#define IFPGA_PCI_APP0_256MB_BASE 0x40000081
#define IFPGA_PCI_APP0_512MB_BASE 0x40000091
#define IFPGA_PCI_APP0_256MB_MAP 0x4006
-/* Apperture 1, 256MB normal cycles, prefetchable. */
+/* Aperture 1, 256MB normal cycles, prefetchable. */
#define IFPGA_PCI_APP1_256MB_BASE 0x50000081
#define IFPGA_PCI_APP1_256MB_MAP 0x5006
-/* Apperture 1, 16MB configuration cycles. */
+/* Aperture 1, 16MB configuration cycles. */
#define IFPGA_PCI_APP1_CONF_BASE 0x61000041
#define IFPGA_PCI_APP1_CONF_T0_MAP 0x000a /* Type 0 cycle */
#define IFPGA_PCI_APP1_CONF_T1_MAP 0x000b /* Type 1 cycle */
Index: ifpgavar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ifpga/ifpgavar.h,v
retrieving revision 1.4
diff -u -p -r1.4 ifpgavar.h
--- ifpgavar.h 11 Dec 2005 12:17:09 -0000 1.4
+++ ifpgavar.h 17 May 2009 12:42:21 -0000
@@ -32,6 +32,7 @@
#ifndef _IFPGAVAR_H_
#define _IFPGAVAR_H_
+#include <sys/device.h>
#include <machine/bus.h>
/* We statically map the UARTS at boot so that we can access the console
@@ -45,7 +46,7 @@
typedef paddr_t ifpga_addr_t;
struct ifpga_softc {
- struct device sc_dev; /* Device node */
+ device_t sc_dev; /* Device node */
bus_space_tag_t sc_iot; /* Bus tag */
bus_space_handle_t sc_sc_ioh; /* System Controller handle */
bus_space_handle_t sc_cm_ioh; /* Core Module handle */
Home |
Main Index |
Thread Index |
Old Index