From 25ba02d795dd37d50898996cf19659d1da1659a5 Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 15 May 2014 02:41:23 +0000 Subject: MFC r261252, r261279, r261304, r261305, r261322, r261336, r261337, r261338, r261353 Fix the name of the dts file for the HL201... When mapping an address, the bsh needs the same offset we do for other things. Add explicit depends on bus_if.h and device_if.h to avoid a chicken and egg problem in some compilation environments. Switch to using PAs rather than VAs for the addresses we map for devices. This is a nop, except for what's reported by atmelbus for the resources. Comment cleanups. Move things around for diff reduction against FDT work. --- sys/arm/at91/at91.c | 32 ++++++++++++++++++++---------- sys/arm/at91/at91_machdep.c | 46 +++++++++++++++++++++---------------------- sys/arm/at91/at91rm92reg.h | 8 ++++---- sys/arm/at91/at91sam9260reg.h | 8 ++++---- sys/arm/at91/at91sam9g20reg.h | 13 ++++++------ sys/arm/at91/at91sam9g45reg.h | 12 +++++------ sys/arm/at91/std.bwct | 1 - sys/arm/at91/std.eb9200 | 1 - sys/arm/at91/std.ethernut5 | 1 - sys/arm/at91/std.hl200 | 1 - sys/arm/at91/std.hl201 | 1 - sys/arm/at91/std.kb920x | 1 - sys/arm/at91/std.qila9g20 | 1 - sys/arm/at91/std.sam9260ek | 1 - sys/arm/at91/std.sam9g20ek | 1 - sys/arm/at91/std.sam9x25ek | 1 - sys/arm/at91/std.sn9g45 | 1 - sys/arm/at91/std.tsc4370 | 1 - 18 files changed, 64 insertions(+), 67 deletions(-) (limited to 'sys/arm/at91') diff --git a/sys/arm/at91/at91.c b/sys/arm/at91/at91.c index 0ad4888..dce1f93 100644 --- a/sys/arm/at91/at91.c +++ b/sys/arm/at91/at91.c @@ -74,7 +74,7 @@ at91_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, } endpa = round_page(bpa + size); - *bshp = (vm_offset_t)pmap_mapdev(pa, endpa - pa); + *bshp = (vm_offset_t)pmap_mapdev(pa, endpa - pa) + (bpa - pa); return (0); } @@ -260,7 +260,6 @@ static int at91_attach(device_t dev) { struct at91_softc *sc = device_get_softc(dev); - const struct arm_devmap_entry *pdevmap; int i; arm_post_filter = at91_eoi; @@ -281,11 +280,15 @@ at91_attach(device_t dev) sc->sc_mem_rman.rm_descr = "AT91 Memory"; if (rman_init(&sc->sc_mem_rman) != 0) panic("at91_attach: failed to set up memory rman"); - for (pdevmap = at91_devmap; pdevmap->pd_va != 0; pdevmap++) { - if (rman_manage_region(&sc->sc_mem_rman, pdevmap->pd_va, - pdevmap->pd_va + pdevmap->pd_size - 1) != 0) - panic("at91_attach: failed to set up memory rman"); - } + /* + * Manage the physical space, defined as being everything that isn't + * DRAM. + */ + if (rman_manage_region(&sc->sc_mem_rman, 0, PHYSADDR - 1) != 0) + panic("at91_attach: failed to set up memory rman"); + if (rman_manage_region(&sc->sc_mem_rman, PHYSADDR + (256 << 20), + 0xfffffffful) != 0) + panic("at91_attach: failed to set up memory rman"); /* * Setup the interrupt table. @@ -330,6 +333,7 @@ at91_alloc_resource(device_t dev, device_t child, int type, int *rid, struct resource_list_entry *rle; struct at91_ivar *ivar = device_get_ivars(child); struct resource_list *rl = &ivar->resources; + bus_space_handle_t bsh; if (device_get_parent(child) != dev) return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, @@ -355,8 +359,10 @@ at91_alloc_resource(device_t dev, device_t child, int type, int *rid, rle->res = rman_reserve_resource(&sc->sc_mem_rman, start, end, count, flags, child); if (rle->res != NULL) { + bus_space_map(&at91_bs_tag, start, + rman_get_size(rle->res), 0, &bsh); rman_set_bustag(rle->res, &at91_bs_tag); - rman_set_bushandle(rle->res, start); + rman_set_bushandle(rle->res, bsh); } break; } @@ -538,8 +544,14 @@ at91_add_child(device_t dev, int prio, const char *name, int unit, bus_set_resource(kid, SYS_RES_IRQ, 1, irq1, 1); if (irq2 != 0) bus_set_resource(kid, SYS_RES_IRQ, 2, irq2, 1); - if (addr != 0 && addr < AT91_BASE) - addr += AT91_BASE; + /* + * Special case for on-board devices. These have their address + * defined relative to AT91_PA_BASE in all the register files we + * have. We could change this, but that's a lot of effort which + * will be obsoleted when FDT arrives. + */ + if (addr != 0 && addr < 0x10000000 && addr >= 0x0f000000) + addr += AT91_PA_BASE; if (addr != 0) bus_set_resource(kid, SYS_RES_MEMORY, 0, addr, size); } diff --git a/sys/arm/at91/at91_machdep.c b/sys/arm/at91/at91_machdep.c index 2eb00a1d..ad38410 100644 --- a/sys/arm/at91/at91_machdep.c +++ b/sys/arm/at91/at91_machdep.c @@ -116,36 +116,22 @@ extern u_int undefined_handler_address; struct pv_addr kernel_pt_table[NUM_KERNEL_PTS]; -/* Physical and virtual addresses for some global pages */ - -vm_paddr_t phys_avail[10]; -vm_paddr_t dump_avail[4]; - -struct pv_addr systempage; -struct pv_addr msgbufpv; -struct pv_addr irqstack; -struct pv_addr undstack; -struct pv_addr abtstack; -struct pv_addr kernelstack; - /* Static device mappings. */ const struct arm_devmap_entry at91_devmap[] = { /* - * Map the on-board devices VA == PA so that we can access them - * with the MMU on or off. + * Map the critical on-board devices. The interrupt vector at + * 0xffff0000 makes it impossible to map them PA == VA, so we map all + * 0xfffxxxxx addresses to 0xdffxxxxx. This covers all critical devices + * on all members of the AT91SAM9 and AT91RM9200 families. */ { - /* - * This at least maps the interrupt controller, the UART - * and the timer. Other devices should use newbus to - * map their memory anyway. - */ 0xdff00000, 0xfff00000, 0x00100000, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, + /* There's a notion that we should do the rest of these lazily. */ /* * We can't just map the OHCI registers VA == PA, because * AT91xx_xxx_BASE belongs to the userland address space. @@ -163,16 +149,16 @@ const struct arm_devmap_entry at91_devmap[] = { * on this chip select for a VA/PA mapping. */ /* Internal Memory 1MB */ + AT91RM92_OHCI_VA_BASE, AT91RM92_OHCI_BASE, - AT91RM92_OHCI_PA_BASE, 0x00100000, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, { /* CompactFlash controller. Portion of EBI CS4 1MB */ + AT91RM92_CF_VA_BASE, AT91RM92_CF_BASE, - AT91RM92_CF_PA_BASE, 0x00100000, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, @@ -183,16 +169,16 @@ const struct arm_devmap_entry at91_devmap[] = { */ { /* Internal Memory 1MB */ + AT91SAM9G20_OHCI_VA_BASE, AT91SAM9G20_OHCI_BASE, - AT91SAM9G20_OHCI_PA_BASE, 0x00100000, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, { /* EBI CS3 256MB */ + AT91SAM9G20_NAND_VA_BASE, AT91SAM9G20_NAND_BASE, - AT91SAM9G20_NAND_PA_BASE, AT91SAM9G20_NAND_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, @@ -202,8 +188,8 @@ const struct arm_devmap_entry at91_devmap[] = { */ { /* Internal Memory 1MB */ + AT91SAM9G45_OHCI_VA_BASE, AT91SAM9G45_OHCI_BASE, - AT91SAM9G45_OHCI_PA_BASE, 0x00100000, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, @@ -211,6 +197,18 @@ const struct arm_devmap_entry at91_devmap[] = { { 0, 0, 0, 0, 0, } }; +/* Physical and virtual addresses for some global pages */ + +vm_paddr_t phys_avail[10]; +vm_paddr_t dump_avail[4]; + +struct pv_addr systempage; +struct pv_addr msgbufpv; +struct pv_addr irqstack; +struct pv_addr undstack; +struct pv_addr abtstack; +struct pv_addr kernelstack; + #ifdef LINUX_BOOT_ABI extern int membanks; extern int memstart[]; diff --git a/sys/arm/at91/at91rm92reg.h b/sys/arm/at91/at91rm92reg.h index 66fad34..5db3d7e 100644 --- a/sys/arm/at91/at91rm92reg.h +++ b/sys/arm/at91/at91rm92reg.h @@ -255,12 +255,12 @@ * other * soc's so phyical and vm address * mapping are unique. XXX */ -#define AT91RM92_OHCI_BASE 0xdfe00000 -#define AT91RM92_OHCI_PA_BASE 0x00300000 +#define AT91RM92_OHCI_VA_BASE 0xdfe00000 +#define AT91RM92_OHCI_BASE 0x00300000 #define AT91RM92_OHCI_SIZE 0x00100000 -#define AT91RM92_CF_BASE 0xdfd00000 -#define AT91RM92_CF_PA_BASE 0x51400000 +#define AT91RM92_CF_VA_BASE 0xdfd00000 +#define AT91RM92_CF_BASE 0x51400000 #define AT91RM92_CF_SIZE 0x00100000 /* SDRAMC */ diff --git a/sys/arm/at91/at91sam9260reg.h b/sys/arm/at91/at91sam9260reg.h index e04afb8..5320d8a 100644 --- a/sys/arm/at91/at91sam9260reg.h +++ b/sys/arm/at91/at91sam9260reg.h @@ -251,12 +251,12 @@ * other * soc's so phyical and vm address * mapping are unique. XXX */ -#define AT91SAM9260_OHCI_BASE 0xdfc00000 -#define AT91SAM9260_OHCI_PA_BASE 0x00500000 +#define AT91SAM9260_OHCI_VA_BASE 0xdfc00000 +#define AT91SAM9260_OHCI_BASE 0x00500000 #define AT91SAM9260_OHCI_SIZE 0x00100000 -#define AT91SAM9260_NAND_BASE 0xe0000000 -#define AT91SAM9260_NAND_PA_BASE 0x40000000 +#define AT91SAM9260_NAND_VA_BASE 0xe0000000 +#define AT91SAM9260_NAND_BASE 0x40000000 #define AT91SAM9260_NAND_SIZE 0x10000000 diff --git a/sys/arm/at91/at91sam9g20reg.h b/sys/arm/at91/at91sam9g20reg.h index ab686c3..539d718 100644 --- a/sys/arm/at91/at91sam9g20reg.h +++ b/sys/arm/at91/at91sam9g20reg.h @@ -252,14 +252,13 @@ * other * soc's so phyical and vm address * mapping are unique. XXX */ -#define AT91SAM9G20_OHCI_BASE 0xdfc00000 -#define AT91SAM9G20_OHCI_PA_BASE 0x00500000 -#define AT91SAM9G20_OHCI_SIZE 0x00100000 - -#define AT91SAM9G20_NAND_BASE 0xe0000000 -#define AT91SAM9G20_NAND_PA_BASE 0x40000000 -#define AT91SAM9G20_NAND_SIZE 0x10000000 +#define AT91SAM9G20_OHCI_VA_BASE 0xdfc00000 +#define AT91SAM9G20_OHCI_BASE 0x00500000 +#define AT91SAM9G20_OHCI_SIZE 0x00100000 +#define AT91SAM9G20_NAND_VA_BASE 0xe0000000 +#define AT91SAM9G20_NAND_BASE 0x40000000 +#define AT91SAM9G20_NAND_SIZE 0x10000000 /* SDRAMC */ #define AT91SAM9G20_SDRAMC_BASE 0xfffea00 diff --git a/sys/arm/at91/at91sam9g45reg.h b/sys/arm/at91/at91sam9g45reg.h index 86574b3..a92e3b9 100644 --- a/sys/arm/at91/at91sam9g45reg.h +++ b/sys/arm/at91/at91sam9g45reg.h @@ -243,13 +243,13 @@ * other * soc's so phyical and vm address * mapping are unique. XXX */ -#define AT91SAM9G45_OHCI_BASE 0xdfb00000 -#define AT91SAM9G45_OHCI_PA_BASE 0x00700000 -#define AT91SAM9G45_OHCI_SIZE 0x00100000 +#define AT91SAM9G45_OHCI_VA_BASE 0xdfb00000 +#define AT91SAM9G45_OHCI_BASE 0x00700000 +#define AT91SAM9G45_OHCI_SIZE 0x00100000 -#define AT91SAM9G45_NAND_BASE 0xe0000000 -#define AT91SAM9G45_NAND_PA_BASE 0x40000000 -#define AT91SAM9G45_NAND_SIZE 0x10000000 +#define AT91SAM9G45_NAND_VA_BASE 0xe0000000 +#define AT91SAM9G45_NAND_BASE 0x40000000 +#define AT91SAM9G45_NAND_SIZE 0x10000000 /* DDRSDRC */ diff --git a/sys/arm/at91/std.bwct b/sys/arm/at91/std.bwct index 6cb7ddd..19e5356 100644 --- a/sys/arm/at91/std.bwct +++ b/sys/arm/at91/std.bwct @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 options KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 diff --git a/sys/arm/at91/std.eb9200 b/sys/arm/at91/std.eb9200 index c1dcd2a..cc8f70f 100644 --- a/sys/arm/at91/std.eb9200 +++ b/sys/arm/at91/std.eb9200 @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 options KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 diff --git a/sys/arm/at91/std.ethernut5 b/sys/arm/at91/std.ethernut5 index 876b59a..7793a83 100644 --- a/sys/arm/at91/std.ethernut5 +++ b/sys/arm/at91/std.ethernut5 @@ -1,7 +1,6 @@ # $FreeBSD$ include "../at91/std.at91sam9" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 diff --git a/sys/arm/at91/std.hl200 b/sys/arm/at91/std.hl200 index f48f723..5b5ed22 100644 --- a/sys/arm/at91/std.hl200 +++ b/sys/arm/at91/std.hl200 @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91" -options STARTUP_PAGETABLE_ADDR=0x20000000 makeoptions KERNPHYSADDR=0x20100000 options KERNPHYSADDR=0x20100000 makeoptions KERNVIRTADDR=0xc0100000 diff --git a/sys/arm/at91/std.hl201 b/sys/arm/at91/std.hl201 index ff27308..6537b27 100644 --- a/sys/arm/at91/std.hl201 +++ b/sys/arm/at91/std.hl201 @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91sam9" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 diff --git a/sys/arm/at91/std.kb920x b/sys/arm/at91/std.kb920x index 85c8d03..2f52db5 100644 --- a/sys/arm/at91/std.kb920x +++ b/sys/arm/at91/std.kb920x @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 options KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 diff --git a/sys/arm/at91/std.qila9g20 b/sys/arm/at91/std.qila9g20 index e2043b6..f9dbb5f 100644 --- a/sys/arm/at91/std.qila9g20 +++ b/sys/arm/at91/std.qila9g20 @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91sam9" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 diff --git a/sys/arm/at91/std.sam9260ek b/sys/arm/at91/std.sam9260ek index e7d1884..fd4a7da 100644 --- a/sys/arm/at91/std.sam9260ek +++ b/sys/arm/at91/std.sam9260ek @@ -1,7 +1,6 @@ # $FreeBSD$ include "../at91/std.at91sam9" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 diff --git a/sys/arm/at91/std.sam9g20ek b/sys/arm/at91/std.sam9g20ek index cdbecda..160a893 100644 --- a/sys/arm/at91/std.sam9g20ek +++ b/sys/arm/at91/std.sam9g20ek @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91sam9" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 diff --git a/sys/arm/at91/std.sam9x25ek b/sys/arm/at91/std.sam9x25ek index 661213b..4536b51 100644 --- a/sys/arm/at91/std.sam9x25ek +++ b/sys/arm/at91/std.sam9x25ek @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91sam9" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 diff --git a/sys/arm/at91/std.sn9g45 b/sys/arm/at91/std.sn9g45 index e0d7c98..5376955 100644 --- a/sys/arm/at91/std.sn9g45 +++ b/sys/arm/at91/std.sn9g45 @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91sam9g45" -options STARTUP_PAGETABLE_ADDR=0x70800000 makeoptions KERNPHYSADDR=0x70008000 options KERNPHYSADDR=0x70008000 makeoptions KERNVIRTADDR=0xc0008000 diff --git a/sys/arm/at91/std.tsc4370 b/sys/arm/at91/std.tsc4370 index 6c08f8c..6eb25cb 100644 --- a/sys/arm/at91/std.tsc4370 +++ b/sys/arm/at91/std.tsc4370 @@ -1,7 +1,6 @@ #$FreeBSD$ include "../at91/std.at91" -options STARTUP_PAGETABLE_ADDR=0x20800000 makeoptions KERNPHYSADDR=0x20000000 makeoptions KERNVIRTADDR=0xc0000000 options KERNPHYSADDR=0x20000000 -- cgit v1.1