diff options
author | andrew <andrew@FreeBSD.org> | 2016-02-10 09:19:29 +0000 |
---|---|---|
committer | andrew <andrew@FreeBSD.org> | 2016-02-10 09:19:29 +0000 |
commit | 4cf4fddec8c3df6f92a4c842133d17613c459575 (patch) | |
tree | ef177bb0c7a78e6ce3af09f16bcb1a328099121c /sys/arm | |
parent | 517ee62210c3163f71681eb95e09542ec96a6b24 (diff) | |
download | FreeBSD-src-4cf4fddec8c3df6f92a4c842133d17613c459575.zip FreeBSD-src-4cf4fddec8c3df6f92a4c842133d17613c459575.tar.gz |
Update of the Allwinner drivers to:
* Use the Linux compat string
* Use EARLY_DRIVER_MODULE to attach at the right time
* Add a generic A10 kernel config file
* A20 now use generic_timer
* Add two new dts files for Olimex boards
* Update our custom DTS file for A10 and A20 to use the same compatible
property names as the vendor ones.
Submitted by: Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision: https://reviews.freebsd.org/D4792
Diffstat (limited to 'sys/arm')
-rw-r--r-- | sys/arm/allwinner/a10_clk.c | 5 | ||||
-rw-r--r-- | sys/arm/allwinner/a10_common.c | 2 | ||||
-rw-r--r-- | sys/arm/allwinner/a10_ehci.c | 12 | ||||
-rw-r--r-- | sys/arm/allwinner/a10_gpio.c | 12 | ||||
-rw-r--r-- | sys/arm/allwinner/a10_mmc.c | 9 | ||||
-rw-r--r-- | sys/arm/allwinner/a10_wdog.c | 2 | ||||
-rw-r--r-- | sys/arm/allwinner/a20/a20_cpu_cfg.c | 3 | ||||
-rw-r--r-- | sys/arm/allwinner/aintc.c | 11 | ||||
-rw-r--r-- | sys/arm/allwinner/files.a10 | 1 | ||||
-rw-r--r-- | sys/arm/allwinner/files.allwinner | 1 | ||||
-rw-r--r-- | sys/arm/allwinner/if_emac.c | 2 | ||||
-rw-r--r-- | sys/arm/allwinner/timer.c | 22 | ||||
-rw-r--r-- | sys/arm/conf/A10 | 105 | ||||
-rw-r--r-- | sys/arm/conf/A20 | 6 |
14 files changed, 163 insertions, 30 deletions
diff --git a/sys/arm/allwinner/a10_clk.c b/sys/arm/allwinner/a10_clk.c index eab95b0..d49e6d0 100644 --- a/sys/arm/allwinner/a10_clk.c +++ b/sys/arm/allwinner/a10_clk.c @@ -109,7 +109,8 @@ static driver_t a10_ccm_driver = { static devclass_t a10_ccm_devclass; -DRIVER_MODULE(a10_ccm, simplebus, a10_ccm_driver, a10_ccm_devclass, 0, 0); +EARLY_DRIVER_MODULE(a10_ccm, simplebus, a10_ccm_driver, a10_ccm_devclass, 0, 0, + BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); int a10_clk_usb_activate(void) @@ -200,7 +201,7 @@ a10_clk_gmac_activate(phandle_t node) /* Set GMAC mode. */ reg_value = CCM_GMAC_CLK_MII; - if (OF_getprop_alloc(node, "phy-type", 1, (void **)&phy_type) > 0) { + if (OF_getprop_alloc(node, "phy-mode", 1, (void **)&phy_type) > 0) { if (strcasecmp(phy_type, "rgmii") == 0) reg_value = CCM_GMAC_CLK_RGMII | CCM_GMAC_MODE_RGMII; else if (strcasecmp(phy_type, "rgmii-bpi") == 0) { diff --git a/sys/arm/allwinner/a10_common.c b/sys/arm/allwinner/a10_common.c index dacb97e..d20853a 100644 --- a/sys/arm/allwinner/a10_common.c +++ b/sys/arm/allwinner/a10_common.c @@ -50,7 +50,7 @@ fdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig, { int offset; - if (fdt_is_compatible(node, "allwinner,sun4i-ic")) + if (fdt_is_compatible(node, "allwinner,sun4i-a10-ic")) offset = 0; else if (fdt_is_compatible(node, "arm,gic")) offset = 32; diff --git a/sys/arm/allwinner/a10_ehci.c b/sys/arm/allwinner/a10_ehci.c index 91f79d3..5dbcdcb 100644 --- a/sys/arm/allwinner/a10_ehci.c +++ b/sys/arm/allwinner/a10_ehci.c @@ -43,10 +43,10 @@ __FBSDID("$FreeBSD$"); #include <sys/gpio.h> #include <machine/bus.h> -#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> -#include <dev/usb/usb.h> +#include <dev/usb/usb.h> #include <dev/usb/usbdi.h> #include <dev/usb/usb_core.h> @@ -90,6 +90,12 @@ static device_detach_t a10_ehci_detach; bs_r_1_proto(reversed); bs_w_1_proto(reversed); +static struct ofw_compat_data compat_data[] = { + {"allwinner,sun4i-a10-ehci", 1}, + {"allwinner,sun7i-a20-ehci", 1}, + {NULL, 0} +}; + static int a10_ehci_probe(device_t self) { @@ -97,7 +103,7 @@ a10_ehci_probe(device_t self) if (!ofw_bus_status_okay(self)) return (ENXIO); - if (!ofw_bus_is_compatible(self, "allwinner,usb-ehci")) + if (ofw_bus_search_compatible(self, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(self, EHCI_HC_DEVSTR); diff --git a/sys/arm/allwinner/a10_gpio.c b/sys/arm/allwinner/a10_gpio.c index e3e247e..cda2c7b 100644 --- a/sys/arm/allwinner/a10_gpio.c +++ b/sys/arm/allwinner/a10_gpio.c @@ -73,6 +73,12 @@ __FBSDID("$FreeBSD$"); #define A10_GPIO_INPUT 0 #define A10_GPIO_OUTPUT 1 +static struct ofw_compat_data compat_data[] = { + {"allwinner,sun4i-a10-pinctrl", 1}, + {"allwinner,sun7i-a20-pinctrl", 1}, + {NULL, 0} +}; + struct a10_gpio_softc { device_t sc_dev; device_t sc_busdev; @@ -373,7 +379,7 @@ a10_gpio_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-gpio")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "Allwinner GPIO controller"); @@ -493,7 +499,9 @@ static driver_t a10_gpio_driver = { sizeof(struct a10_gpio_softc), }; -DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0); +EARLY_DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); + int a10_gpio_ethernet_activate(uint32_t func) diff --git a/sys/arm/allwinner/a10_mmc.c b/sys/arm/allwinner/a10_mmc.c index eee1621..c4bb6df 100644 --- a/sys/arm/allwinner/a10_mmc.c +++ b/sys/arm/allwinner/a10_mmc.c @@ -62,6 +62,12 @@ static int a10_mmc_pio_mode = 0; TUNABLE_INT("hw.a10.mmc.pio_mode", &a10_mmc_pio_mode); +static struct ofw_compat_data compat_data[] = { + {"allwinner,sun4i-a10-mmc", 1}, + {"allwinner,sun5i-a13-mmc", 1}, + {NULL, 0} +}; + struct a10_mmc_softc { bus_space_handle_t a10_bsh; bus_space_tag_t a10_bst; @@ -123,8 +129,9 @@ a10_mmc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-mmc")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); + device_set_desc(dev, "Allwinner Integrated MMC/SD controller"); return (BUS_PROBE_DEFAULT); diff --git a/sys/arm/allwinner/a10_wdog.c b/sys/arm/allwinner/a10_wdog.c index 40609b0..1c0dd00 100644 --- a/sys/arm/allwinner/a10_wdog.c +++ b/sys/arm/allwinner/a10_wdog.c @@ -95,7 +95,7 @@ a10wd_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (ofw_bus_is_compatible(dev, "allwinner,sun4i-wdt")) { + if (ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-wdt")) { device_set_desc(dev, "Allwinner A10 Watchdog"); return (BUS_PROBE_DEFAULT); } diff --git a/sys/arm/allwinner/a20/a20_cpu_cfg.c b/sys/arm/allwinner/a20/a20_cpu_cfg.c index ed0345a..a0bdb5a 100644 --- a/sys/arm/allwinner/a20/a20_cpu_cfg.c +++ b/sys/arm/allwinner/a20/a20_cpu_cfg.c @@ -117,7 +117,8 @@ static driver_t a20_cpu_cfg_driver = { static devclass_t a20_cpu_cfg_devclass; -DRIVER_MODULE(a20_cpu_cfg, simplebus, a20_cpu_cfg_driver, a20_cpu_cfg_devclass, 0, 0); +EARLY_DRIVER_MODULE(a20_cpu_cfg, simplebus, a20_cpu_cfg_driver, a20_cpu_cfg_devclass, 0, 0, + BUS_PASS_RESOURCE + BUS_PASS_ORDER_MIDDLE); uint64_t a20_read_counter64(void) diff --git a/sys/arm/allwinner/aintc.c b/sys/arm/allwinner/aintc.c index ed5f1fc..a15ead1 100644 --- a/sys/arm/allwinner/aintc.c +++ b/sys/arm/allwinner/aintc.c @@ -79,6 +79,12 @@ __FBSDID("$FreeBSD$"); #define SW_INT_ENABLE_REG(_b) (0x40 + ((_b) * 4)) #define SW_INT_MASK_REG(_b) (0x50 + ((_b) * 4)) +static struct ofw_compat_data compat_data[] = { + {"allwinner,sun4i-a10-ic", 1}, + {"allwinner,sun7i-a20-sc-nmi", 1}, + {NULL, 0} +}; + struct a10_aintc_softc { device_t sc_dev; struct resource * aintc_res; @@ -101,7 +107,7 @@ a10_aintc_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-ic")) + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); device_set_desc(dev, "A10 AINTC Interrupt Controller"); return (BUS_PROBE_DEFAULT); @@ -158,7 +164,8 @@ static driver_t a10_aintc_driver = { static devclass_t a10_aintc_devclass; -DRIVER_MODULE(aintc, simplebus, a10_aintc_driver, a10_aintc_devclass, 0, 0); +EARLY_DRIVER_MODULE(aintc, simplebus, a10_aintc_driver, a10_aintc_devclass, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_FIRST); int arm_get_next_irq(int last_irq) diff --git a/sys/arm/allwinner/files.a10 b/sys/arm/allwinner/files.a10 index 9f28fc4..44fe55f 100644 --- a/sys/arm/allwinner/files.a10 +++ b/sys/arm/allwinner/files.a10 @@ -1,3 +1,4 @@ # $FreeBSD$ arm/allwinner/aintc.c standard +arm/allwinner/timer.c standard diff --git a/sys/arm/allwinner/files.allwinner b/sys/arm/allwinner/files.allwinner index 8606d91..5157850 100644 --- a/sys/arm/allwinner/files.allwinner +++ b/sys/arm/allwinner/files.allwinner @@ -12,5 +12,4 @@ arm/allwinner/a10_wdog.c standard arm/allwinner/a20/a20_cpu_cfg.c standard arm/allwinner/allwinner_machdep.c standard arm/allwinner/if_emac.c optional emac -arm/allwinner/timer.c standard #arm/allwinner/console.c standard diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index 18aeb8f..22422fe 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -756,7 +756,7 @@ static int emac_probe(device_t dev) { - if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-emac")) + if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-emac")) return (ENXIO); device_set_desc(dev, "A10/A20 EMAC ethernet controller"); diff --git a/sys/arm/allwinner/timer.c b/sys/arm/allwinner/timer.c index 7c2a340..d25aa3c 100644 --- a/sys/arm/allwinner/timer.c +++ b/sys/arm/allwinner/timer.c @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kdb.h> -#include "a20/a20_cpu_cfg.h" +#include <arm/allwinner/allwinner_machdep.h> /** * Timer registers addr @@ -84,7 +84,6 @@ struct a10_timer_softc { uint32_t sc_period; uint32_t timer0_freq; struct eventtimer et; - uint8_t sc_timer_type; /* 0 for A10, 1 for A20 */ }; int a10_timer_get_timerfreq(struct a10_timer_softc *); @@ -127,10 +126,6 @@ timer_read_counter64(void) { uint32_t lo, hi; - /* In case of A20 get appropriate counter info */ - if (a10_timer_sc->sc_timer_type) - return (a20_read_counter64()); - /* Latch counter, wait for it to be ready to read. */ timer_write_4(a10_timer_sc, CNT64_CTRL_REG, CNT64_RL_EN); while (timer_read_4(a10_timer_sc, CNT64_CTRL_REG) & CNT64_RL_EN) @@ -146,14 +141,16 @@ static int a10_timer_probe(device_t dev) { struct a10_timer_softc *sc; + u_int soc_family; sc = device_get_softc(dev); - if (ofw_bus_is_compatible(dev, "allwinner,sun4i-timer")) - sc->sc_timer_type = 0; - else if (ofw_bus_is_compatible(dev, "allwinner,sun7i-timer")) - sc->sc_timer_type = 1; - else + if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-timer")) + return (ENXIO); + + soc_family = allwinner_soc_family(); + if (soc_family != ALLWINNERSOC_SUN4I && + soc_family != ALLWINNERSOC_SUN5I) return (ENXIO); device_set_desc(dev, "Allwinner A10/A20 timer"); @@ -352,7 +349,8 @@ static driver_t a10_timer_driver = { static devclass_t a10_timer_devclass; -DRIVER_MODULE(a10_timer, simplebus, a10_timer_driver, a10_timer_devclass, 0, 0); +EARLY_DRIVER_MODULE(a10_timer, simplebus, a10_timer_driver, a10_timer_devclass, 0, 0, + BUS_PASS_TIMER + BUS_PASS_ORDER_MIDDLE); void DELAY(int usec) diff --git a/sys/arm/conf/A10 b/sys/arm/conf/A10 new file mode 100644 index 0000000..31073c7 --- /dev/null +++ b/sys/arm/conf/A10 @@ -0,0 +1,105 @@ +# +# A10 -- Custom configuration for the AllWinner A10 SoC +# +# For more information on this file, please read the config(5) manual page, +# and/or the handbook section on Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD$ + +ident A10 + +include "std.armv6" +include "../allwinner/std.a10" + +options HZ=100 +options SCHED_4BSD # 4BSD scheduler +options PLATFORM + +# Debugging for use in -current +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +options ALT_BREAK_TO_DEBUGGER +#options VERBOSE_SYSINIT # Enable verbose sysinit messages +options KDB # Enable kernel debugger support +# For minimum debugger support (stable branch) use: +#options KDB_TRACE # Print a stack trace for a panic +# For full debugger support use this instead: +options DDB # Enable the kernel debugger +options INVARIANTS # Enable calls of extra sanity checking +options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS +options WITNESS # Enable checks to detect deadlocks and cycles +options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed +#options DIAGNOSTIC + +# NFS root from boopt/dhcp +#options BOOTP +#options BOOTP_NFSROOT +#options BOOTP_COMPAT +#options BOOTP_NFSV3 +#options BOOTP_WIRED_TO=emac0 + +# MMC/SD/SDIO Card slot support +device mmc # mmc/sd bus +device mmcsd # mmc/sd flash cards + +# ATA controllers +device ahci # AHCI-compatible SATA controllers +#device ata # Legacy ATA/SATA controllers + +# Console and misc +device uart +device uart_ns8250 +device pty +device snp +device md +device random # Entropy device + +# I2C support +#device iicbus +#device iic + +# GPIO +device gpio +device gpioled + +device scbus # SCSI bus (required for ATA/SCSI) +device da # Direct Access (disks) +device pass # Passthrough device (direct ATA/SCSI access) + +# USB support +options USB_HOST_ALIGN=64 # Align usb buffers to cache line size. +device usb +options USB_DEBUG +#options USB_REQ_DEBUG +#options USB_VERBOSE +#device uhci +#device ohci +device ehci + +device umass + +# Ethernet +device loop +device ether +device mii +device bpf + +device emac + +# USB ethernet support, requires miibus +device miibus + +# Flattened Device Tree +options FDT # Configure using FDT/DTB data +makeoptions MODULES_EXTRA=dtb/allwinner diff --git a/sys/arm/conf/A20 b/sys/arm/conf/A20 index 353c5ec..cd07264 100644 --- a/sys/arm/conf/A20 +++ b/sys/arm/conf/A20 @@ -52,12 +52,12 @@ options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed #options BOOTP_NFSV3 #options BOOTP_WIRED_TO=dwc0 -# Boot device is 2nd slice on MMC/SD card -options ROOTDEVNAME=\"ufs:/dev/da0s2\" - # Interrupt controller device gic +# ARM Generic Timer +device generic_timer + # MMC/SD/SDIO Card slot support device mmc # mmc/sd bus device mmcsd # mmc/sd flash cards |