Date: Thu, 15 May 2014 21:21:47 +0000 (UTC) From: Ian Lepore <ian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266196 - in stable/10/sys: arm/arm arm/at91 dev/fdt Message-ID: <201405152121.s4FLLl4o014230@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ian Date: Thu May 15 21:21:47 2014 New Revision: 266196 URL: http://svnweb.freebsd.org/changeset/base/266196 Log: MFC r261681, r261682, r261683, r261684, r261685, r261686, r261687, r261688, r261689, r261690, r261783, r261791, r261836, r261837, r261841, Add FDT matching code to AT91 device drivers. Better nomatch messages: include compat string. Also, flag devices as disabled in the successful probe message, but leave what that means to the actual driver (no semantic changes). Fix Embest board name and id. Honor the disabled status by only grabbing resources and returning when running under FDT in the AT91 SPI driver. Modified: stable/10/sys/arm/arm/locore.S stable/10/sys/arm/at91/at91_machdep.c stable/10/sys/arm/at91/at91_mci.c stable/10/sys/arm/at91/at91_pio.c stable/10/sys/arm/at91/at91_pit.c stable/10/sys/arm/at91/at91_pmc.c stable/10/sys/arm/at91/at91_rst.c stable/10/sys/arm/at91/at91_spi.c stable/10/sys/arm/at91/at91_twi.c stable/10/sys/arm/at91/at91_wdt.c stable/10/sys/arm/at91/board_eb9200.c stable/10/sys/arm/at91/if_ate.c stable/10/sys/dev/fdt/simplebus.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/arm/arm/locore.S ============================================================================== --- stable/10/sys/arm/arm/locore.S Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/arm/locore.S Thu May 15 21:21:47 2014 (r266196) @@ -170,8 +170,8 @@ Lunmapped: #if defined(SOCDEV_PA) && defined(SOCDEV_VA) /* Create the custom map */ - ldr r1, =SOCDEV_VA - ldr r2, =SOCDEV_PA + ldr r1, =SOCDEV_PA + ldr r2, =SOCDEV_VA bl build_pagetables #endif Modified: stable/10/sys/arm/at91/at91_machdep.c ============================================================================== --- stable/10/sys/arm/at91/at91_machdep.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_machdep.c Thu May 15 21:21:47 2014 (r266196) @@ -590,6 +590,11 @@ initarm(struct arm_boot_params *abp) printf("Warning: No soc support for %s found.\n", soc_info.name); memsize = board_init(); + if (memsize == -1) { + printf("board_init() failed, cannot determine ram size; " + "assuming 16MB\n"); + memsize = 16 * 1024 * 1024; + } /* * Pages were allocated during the secondary bootstrap for the Modified: stable/10/sys/arm/at91/at91_mci.c ============================================================================== --- stable/10/sys/arm/at91/at91_mci.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_mci.c Thu May 15 21:21:47 2014 (r266196) @@ -25,6 +25,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -62,6 +64,12 @@ __FBSDID("$FreeBSD$"); #include <dev/mmc/mmcreg.h> #include <dev/mmc/mmcbrvar.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + #include "mmcbr_if.h" #include "opt_at91.h" @@ -342,7 +350,10 @@ at91_mci_fini(device_t dev) static int at91_mci_probe(device_t dev) { - +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,hsmci")) + return (ENXIO); +#endif device_set_desc(dev, "MCI mmc/sd host bridge"); return (0); } @@ -1393,5 +1404,10 @@ static driver_t at91_mci_driver = { static devclass_t at91_mci_devclass; +#ifdef FDT +DRIVER_MODULE(at91_mci, simplebus, at91_mci_driver, at91_mci_devclass, NULL, + NULL); +#else DRIVER_MODULE(at91_mci, atmelarm, at91_mci_driver, at91_mci_devclass, NULL, NULL); +#endif Modified: stable/10/sys/arm/at91/at91_pio.c ============================================================================== --- stable/10/sys/arm/at91/at91_pio.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_pio.c Thu May 15 21:21:47 2014 (r266196) @@ -24,6 +24,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -48,6 +50,12 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91_pioreg.h> #include <arm/at91/at91_piovar.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + #define MAX_CHANGE 64 struct at91_pio_softc @@ -122,7 +130,10 @@ static int at91_pio_probe(device_t dev) { const char *name; - +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,at91rm9200-gpio")) + return (ENXIO); +#endif switch (device_get_unit(dev)) { case 0: name = "PIOA"; @@ -136,6 +147,12 @@ at91_pio_probe(device_t dev) case 3: name = "PIOD"; break; + case 4: + name = "PIOE"; + break; + case 5: + name = "PIOF"; + break; default: name = "PIO"; break; @@ -609,5 +626,10 @@ static driver_t at91_pio_driver = { sizeof(struct at91_pio_softc), }; +#ifdef FDT +DRIVER_MODULE(at91_pio, simplebus, at91_pio_driver, at91_pio_devclass, NULL, + NULL); +#else DRIVER_MODULE(at91_pio, atmelarm, at91_pio_driver, at91_pio_devclass, NULL, NULL); +#endif Modified: stable/10/sys/arm/at91/at91_pit.c ============================================================================== --- stable/10/sys/arm/at91/at91_pit.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_pit.c Thu May 15 21:21:47 2014 (r266196) @@ -24,6 +24,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -48,6 +50,12 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91var.h> #include <arm/at91/at91_pitreg.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + #ifndef PIT_PRESCALE #define PIT_PRESCALE (16) #endif @@ -83,6 +91,9 @@ at91_pit_delay(int us) uint64_t pit_freq; const uint64_t mhz = 1E6; + if (sc == NULL) + return; + last = PIT_PIV(RD4(sc, PIT_PIIR)); /* Max delay ~= 260s. @ 133Mhz */ @@ -111,7 +122,10 @@ static struct timecounter at91_pit_timec static int at91_pit_probe(device_t dev) { - +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,at91sam9260-pit")) + return (ENXIO); +#endif device_set_desc(dev, "AT91SAM9 PIT"); return (0); } @@ -121,10 +135,8 @@ at91_pit_attach(device_t dev) { void *ih; int rid, err = 0; - struct at91_softc *at91_sc; struct resource *irq; - at91_sc = device_get_softc(device_get_parent(dev)); sc = device_get_softc(dev); sc->sc_dev = dev; @@ -158,22 +170,6 @@ out: return (err); } -static device_method_t at91_pit_methods[] = { - DEVMETHOD(device_probe, at91_pit_probe), - DEVMETHOD(device_attach, at91_pit_attach), - DEVMETHOD_END -}; - -static driver_t at91_pit_driver = { - "at91_pit", - at91_pit_methods, - sizeof(struct pit_softc), -}; - -static devclass_t at91_pit_devclass; - -DRIVER_MODULE(at91_pit, atmelarm, at91_pit_driver, at91_pit_devclass, NULL, - NULL); static int pit_intr(void *arg) @@ -202,3 +198,25 @@ at91_pit_get_timecount(struct timecounte icnt = piir >> 20; /* Overflows */ return (timecount + PIT_PIV(piir) + PIT_PIV(RD4(sc, PIT_MR)) * icnt); } + +static device_method_t at91_pit_methods[] = { + DEVMETHOD(device_probe, at91_pit_probe), + DEVMETHOD(device_attach, at91_pit_attach), + DEVMETHOD_END +}; + +static driver_t at91_pit_driver = { + "at91_pit", + at91_pit_methods, + sizeof(struct pit_softc), +}; + +static devclass_t at91_pit_devclass; + +#ifdef FDT +DRIVER_MODULE(at91_pit, simplebus, at91_pit_driver, at91_pit_devclass, NULL, + NULL); +#else +DRIVER_MODULE(at91_pit, atmelarm, at91_pit_driver, at91_pit_devclass, NULL, + NULL); +#endif Modified: stable/10/sys/arm/at91/at91_pmc.c ============================================================================== --- stable/10/sys/arm/at91/at91_pmc.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_pmc.c Thu May 15 21:21:47 2014 (r266196) @@ -24,6 +24,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -49,6 +51,12 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91_pmcreg.h> #include <arm/at91/at91_pmcvar.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + static struct at91_pmc_softc { bus_space_tag_t sc_st; bus_space_handle_t sc_sh; @@ -526,6 +534,8 @@ at91_pmc_init_clock(void) uint32_t mckr; uint32_t mdiv; + soc_info.soc_data->soc_clock_init(); + main_clock = at91_pmc_sense_main_clock(); if (at91_is_sam9() || at91_is_sam9xe()) { @@ -650,7 +660,10 @@ errout: static int at91_pmc_probe(device_t dev) { - +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,at91rm9200-pmc")) + return (ENXIO); +#endif device_set_desc(dev, "PMC"); return (0); } @@ -695,5 +708,10 @@ static driver_t at91_pmc_driver = { }; static devclass_t at91_pmc_devclass; +#ifdef FDT +DRIVER_MODULE(at91_pmc, simplebus, at91_pmc_driver, at91_pmc_devclass, NULL, + NULL); +#else DRIVER_MODULE(at91_pmc, atmelarm, at91_pmc_driver, at91_pmc_devclass, NULL, NULL); +#endif Modified: stable/10/sys/arm/at91/at91_rst.c ============================================================================== --- stable/10/sys/arm/at91/at91_rst.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_rst.c Thu May 15 21:21:47 2014 (r266196) @@ -23,6 +23,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -39,10 +41,19 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91_rstreg.h> #include <arm/at91/at91board.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#define FDT_HACKS 1 +#endif + #define RST_TIMEOUT (5) /* Seconds to hold NRST for hard reset */ #define RST_TICK (20) /* sample NRST at hz/RST_TICK intervals */ +#ifndef FDT static int at91_rst_intr(void *arg); +#endif static struct at91_rst_softc { struct resource *mem_res; /* Memory resource */ @@ -93,6 +104,10 @@ at91_rst_cpu_reset(void) static int at91_rst_probe(device_t dev) { +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,at91sam9260-rstc")) + return (ENXIO); +#endif device_set_desc(dev, "AT91SAM9 Reset Controller"); return (0); @@ -103,7 +118,7 @@ at91_rst_attach(device_t dev) { struct at91_rst_softc *sc; const char *cause; - int rid, err; + int rid, err = 0; at91_rst_sc = sc = device_get_softc(dev); sc->sc_dev = dev; @@ -118,6 +133,8 @@ at91_rst_attach(device_t dev) err = ENOMEM; goto out; } + +#ifndef FDT_HACKS rid = 0; sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | RF_SHAREABLE); @@ -132,6 +149,7 @@ at91_rst_attach(device_t dev) at91_rst_intr, NULL, sc, &sc->intrhand); if (err) device_printf(dev, "could not establish interrupt handler.\n"); +#endif WR4(at91_rst_sc, RST_MR, RST_MR_ERSTL(0xd) | RST_MR_URSIEN | RST_MR_KEY); @@ -161,6 +179,7 @@ out: return (err); } +#ifndef FDT_HACKS static void at91_rst_tick(void *argp) { @@ -191,6 +210,7 @@ at91_rst_intr(void *argp) } return (FILTER_STRAY); } +#endif static device_method_t at91_rst_methods[] = { DEVMETHOD(device_probe, at91_rst_probe), @@ -206,5 +226,10 @@ static driver_t at91_rst_driver = { static devclass_t at91_rst_devclass; +#ifdef FDT +DRIVER_MODULE(at91_rst, simplebus, at91_rst_driver, at91_rst_devclass, NULL, + NULL); +#else DRIVER_MODULE(at91_rst, atmelarm, at91_rst_driver, at91_rst_devclass, NULL, NULL); +#endif Modified: stable/10/sys/arm/at91/at91_spi.c ============================================================================== --- stable/10/sys/arm/at91/at91_spi.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_spi.c Thu May 15 21:21:47 2014 (r266196) @@ -25,6 +25,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -49,6 +51,12 @@ __FBSDID("$FreeBSD$"); #include <dev/spibus/spi.h> #include <dev/spibus/spibusvar.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + #include "spibus_if.h" struct at91_spi_softc @@ -96,7 +104,10 @@ static void at91_spi_intr(void *arg); static int at91_spi_probe(device_t dev) { - +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,at91rm9200-spi")) + return (ENXIO); +#endif device_set_desc(dev, "AT91 SPI"); return (0); } @@ -120,6 +131,15 @@ at91_spi_attach(device_t dev) if (err) goto out; +#ifdef FDT + /* + * Disable devices need to hold their resources, so return now and not attach + * the spibus, setup interrupt handlers, etc. + */ + if (!ofw_bus_status_okay(dev)) + return 0; +#endif + /* * Set up the hardware. */ @@ -428,5 +448,10 @@ static driver_t at91_spi_driver = { sizeof(struct at91_spi_softc), }; +#ifdef FDT +DRIVER_MODULE(at91_spi, simplebus, at91_spi_driver, at91_spi_devclass, NULL, + NULL); +#else DRIVER_MODULE(at91_spi, atmelarm, at91_spi_driver, at91_spi_devclass, NULL, NULL); +#endif Modified: stable/10/sys/arm/at91/at91_twi.c ============================================================================== --- stable/10/sys/arm/at91/at91_twi.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_twi.c Thu May 15 21:21:47 2014 (r266196) @@ -23,6 +23,8 @@ * SUCH DAMAGE. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -46,6 +48,12 @@ __FBSDID("$FreeBSD$"); #include <dev/iicbus/iicbus.h> #include "iicbus_if.h" +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + #define TWI_SLOW_CLOCK 1500 #define TWI_FAST_CLOCK 45000 #define TWI_FASTEST_CLOCK 90000 @@ -104,7 +112,11 @@ static void at91_twi_deactivate(device_t static int at91_twi_probe(device_t dev) { - +#ifdef FDT + /* XXXX need a whole list, since there's at least 4 different ones */ + if (!ofw_bus_is_compatible(dev, "atmel,at91sam9g20-i2c")) + return (ENXIO); +#endif device_set_desc(dev, "TWI"); return (0); } @@ -122,6 +134,15 @@ at91_twi_attach(device_t dev) AT91_TWI_LOCK_INIT(sc); +#ifdef FDT + /* + * Disable devices need to hold their resources, so return now and not attach + * the iicbus, setup interrupt handlers, etc. + */ + if (!ofw_bus_status_okay(dev)) + return 0; +#endif + /* * Activate the interrupt */ @@ -397,7 +418,12 @@ static driver_t at91_twi_driver = { sizeof(struct at91_twi_softc), }; +#ifdef FDT +DRIVER_MODULE(at91_twi, simplebus, at91_twi_driver, at91_twi_devclass, NULL, + NULL); +#else DRIVER_MODULE(at91_twi, atmelarm, at91_twi_driver, at91_twi_devclass, NULL, NULL); +#endif DRIVER_MODULE(iicbus, at91_twi, iicbus_driver, iicbus_devclass, NULL, NULL); MODULE_DEPEND(at91_twi, iicbus, 1, 1, 1); Modified: stable/10/sys/arm/at91/at91_wdt.c ============================================================================== --- stable/10/sys/arm/at91/at91_wdt.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/at91_wdt.c Thu May 15 21:21:47 2014 (r266196) @@ -29,6 +29,8 @@ * handler. The watchdog is halted in processor debug mode. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -45,6 +47,12 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91var.h> #include <arm/at91/at91_wdtreg.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + struct wdt_softc { struct mtx sc_mtx; device_t sc_dev; @@ -131,12 +139,12 @@ wdt_tick(void *argp) static int wdt_probe(device_t dev) { - - if (at91_is_sam9() || at91_is_sam9xe()) { - device_set_desc(dev, "WDT"); - return (0); - } - return (ENXIO); +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "atmel,at91sam9260-wdt")) + return (ENXIO); +#endif + device_set_desc(dev, "WDT"); + return (0); } static int @@ -223,4 +231,8 @@ static driver_t wdt_driver = { static devclass_t wdt_devclass; +#ifdef FDT +DRIVER_MODULE(at91_wdt, simplebus, wdt_driver, wdt_devclass, NULL, NULL); +#else DRIVER_MODULE(at91_wdt, atmelarm, wdt_driver, wdt_devclass, NULL, NULL); +#endif Modified: stable/10/sys/arm/at91/board_eb9200.c ============================================================================== --- stable/10/sys/arm/at91/board_eb9200.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/board_eb9200.c Thu May 15 21:21:47 2014 (r266196) @@ -65,4 +65,4 @@ board_init(void) return (at91_ramsize()); } -ARM_BOARD(KB9200, "Kwikbyte KB920x") +ARM_BOARD(ATEB9200, "Embest ATEB9200") Modified: stable/10/sys/arm/at91/if_ate.c ============================================================================== --- stable/10/sys/arm/at91/if_ate.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/arm/at91/if_ate.c Thu May 15 21:21:47 2014 (r266196) @@ -30,6 +30,8 @@ * 2) GPIO initializtion in board setup code. */ +#include "opt_platform.h" + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -74,6 +76,12 @@ __FBSDID("$FreeBSD$"); #include <arm/at91/at91var.h> #include <arm/at91/if_atereg.h> +#ifdef FDT +#include <dev/fdt/fdt_common.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> +#endif + #include "miibus_if.h" /* @@ -229,7 +237,10 @@ static int ate_miibus_writereg(device_t static int ate_probe(device_t dev) { - +#ifdef FDT + if (!ofw_bus_is_compatible(dev, "cdns,at32ap7000-macb")) + return (ENXIO); +#endif device_set_desc(dev, "EMAC"); return (0); } @@ -1458,7 +1469,11 @@ static driver_t ate_driver = { sizeof(struct ate_softc), }; +#ifdef FDT +DRIVER_MODULE(ate, simplebus, ate_driver, ate_devclass, NULL, NULL); +#else DRIVER_MODULE(ate, atmelarm, ate_driver, ate_devclass, NULL, NULL); +#endif DRIVER_MODULE(miibus, ate, miibus_driver, miibus_devclass, NULL, NULL); MODULE_DEPEND(ate, miibus, 1, 1, 1); MODULE_DEPEND(ate, ether, 1, 1, 1); Modified: stable/10/sys/dev/fdt/simplebus.c ============================================================================== --- stable/10/sys/dev/fdt/simplebus.c Thu May 15 21:19:13 2014 (r266195) +++ stable/10/sys/dev/fdt/simplebus.c Thu May 15 21:21:47 2014 (r266196) @@ -401,18 +401,24 @@ simplebus_print_res(struct simplebus_dev static void simplebus_probe_nomatch(device_t bus, device_t child) { - const char *name, *type; + const char *name, *type, *compat; if (!bootverbose) return; name = ofw_bus_get_name(child); type = ofw_bus_get_type(child); + compat = ofw_bus_get_compat(child); device_printf(bus, "<%s>", name != NULL ? name : "unknown"); simplebus_print_res(device_get_ivars(child)); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); + if (!ofw_bus_status_okay(child)) + printf(" disabled"); + if (type) + printf(" type %s", type); + if (compat) + printf(" compat %s", compat); + printf(" (no driver attached)\n"); } static int @@ -422,7 +428,8 @@ simplebus_print_child(device_t bus, devi rv = bus_print_child_header(bus, child); rv += simplebus_print_res(device_get_ivars(child)); + if (!ofw_bus_status_okay(child)) + rv += printf(" disabled"); rv += bus_print_child_footer(bus, child); return (rv); } -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405152121.s4FLLl4o014230>