Module Name: src Committed By: marty Date: Mon Dec 21 03:34:34 UTC 2015
Modified Files: src/sys/arch/arm/samsung: exynos5422_clock.c exynos_usb.c files.exynos src/sys/arch/evbarm/conf: EXYNOS Log Message: XU4 FDT Last drivers converted There is a minimum conversion on the clock driver. The USB driver needs reordering and is broken, but it was broken before. Next up: tactical nuclear weapons To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/samsung/exynos5422_clock.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/samsung/exynos_usb.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/samsung/files.exynos cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/conf/EXYNOS Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/samsung/exynos5422_clock.c diff -u src/sys/arch/arm/samsung/exynos5422_clock.c:1.2 src/sys/arch/arm/samsung/exynos5422_clock.c:1.3 --- src/sys/arch/arm/samsung/exynos5422_clock.c:1.2 Sat Dec 5 18:29:22 2015 +++ src/sys/arch/arm/samsung/exynos5422_clock.c Mon Dec 21 03:34:34 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos5422_clock.c,v 1.2 2015/12/05 18:29:22 jmcneill Exp $ */ +/* $NetBSD: exynos5422_clock.c,v 1.3 2015/12/21 03:34:34 marty Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -29,7 +29,7 @@ #include "locators.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: exynos5422_clock.c,v 1.2 2015/12/05 18:29:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: exynos5422_clock.c,v 1.3 2015/12/21 03:34:34 marty Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -45,6 +45,8 @@ __KERNEL_RCSID(0, "$NetBSD: exynos5422_c #include <arm/samsung/exynos_var.h> #include <arm/samsung/exynos_clock.h> +#include <dev/fdt/fdtvar.h> + static struct clk *exynos5422_clock_get(void *, const char *); static void exynos5422_clock_put(void *, struct clk *); static u_int exynos5422_clock_get_rate(void *, struct clk *); @@ -243,20 +245,35 @@ CFATTACH_DECL_NEW(exynos5422_clock, size static int exynos5422_clock_match(device_t parent, cfdata_t cf, void *aux) { - return IS_EXYNOS5422_P(); + const char * const compatible[] = { "samsung,exynos5422-clock", + NULL }; + struct fdt_attach_args * const faa = aux; + return of_match_compatible(faa->faa_phandle, compatible); } static void exynos5422_clock_attach(device_t parent, device_t self, void *aux) { struct exynos5422_clock_softc * const sc = device_private(self); - struct exyo_attach_args * const exyo = aux; - const struct exyo_locators *loc = &exyo->exyo_loc; + struct fdt_attach_args * const faa = aux; + bus_addr_t addr; + bus_size_t size; + int error; + + if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } sc->sc_dev = self; - sc->sc_bst = exyo->exyo_core_bst; - bus_space_subregion(exyo->exyo_core_bst, exyo->exyo_core_bsh, - loc->loc_offset, loc->loc_size, &sc->sc_bsh); + sc->sc_bst = faa->faa_bst; + + error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh); + if (error) { + aprint_error(": couldn't map %#llx: %d", + (uint64_t)addr, error); + return; + } aprint_naive("\n"); aprint_normal(": Exynos5422 Clock Controller\n"); Index: src/sys/arch/arm/samsung/exynos_usb.c diff -u src/sys/arch/arm/samsung/exynos_usb.c:1.13 src/sys/arch/arm/samsung/exynos_usb.c:1.14 --- src/sys/arch/arm/samsung/exynos_usb.c:1.13 Tue Sep 30 14:23:41 2014 +++ src/sys/arch/arm/samsung/exynos_usb.c Mon Dec 21 03:34:34 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: exynos_usb.c,v 1.13 2014/09/30 14:23:41 reinoud Exp $ */ +/* $NetBSD: exynos_usb.c,v 1.14 2015/12/21 03:34:34 marty Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: exynos_usb.c,v 1.13 2014/09/30 14:23:41 reinoud Exp $"); +__KERNEL_RCSID(1, "$NetBSD: exynos_usb.c,v 1.14 2015/12/21 03:34:34 marty Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -67,6 +67,8 @@ __KERNEL_RCSID(1, "$NetBSD: exynos_usb.c #include <arm/samsung/exynos_var.h> #include <arm/samsung/exynos_io.h> +#include <dev/fdt/fdtvar.h> + struct exynos_usb_softc { device_t sc_self; @@ -74,6 +76,7 @@ struct exynos_usb_softc { bus_dma_tag_t sc_dmat; bus_space_tag_t sc_bst; + bus_space_handle_t sc_bsh; bus_space_handle_t sc_ehci_bsh; bus_space_handle_t sc_ohci_bsh; bus_space_handle_t sc_usb2phy_bsh; @@ -92,7 +95,7 @@ struct exynos_usb_attach_args { /* forwards */ -static int exynos_usb_intr(void *arg); +//static int exynos_usb_intr(void *arg); static int exynos_usb_match(device_t, cfdata_t, void *); @@ -105,11 +108,10 @@ CFATTACH_DECL_NEW(exyo_usb, 0, static int exynos_usb_match(device_t parent, cfdata_t cf, void *aux) { - /* there can only be one */ - if (exynos_usb_sc.sc_self) - return 0; - - return 1; + const char * const compatible[] = { "samsung,exynos5-dwusb3", + NULL }; + struct fdt_attach_args * const faa = aux; + return of_match_compatible(faa->faa_phandle, compatible); } @@ -117,76 +119,44 @@ static void exynos_usb_attach(device_t parent, device_t self, void *aux) { struct exynos_usb_softc * const sc = &exynos_usb_sc; - struct exyo_attach_args *exyoaa = (struct exyo_attach_args *) aux; - struct exyo_locators *loc = &exyoaa->exyo_loc; - bus_size_t ehci_offset, ohci_offset, usb2phy_offset; - - /* no locators expected */ - KASSERT(loc->loc_port == EXYOCF_PORT_DEFAULT); - KASSERT(loc->loc_intr != EXYOCF_INTR_DEFAULT); + struct fdt_attach_args *const faa = aux; + bus_addr_t addr; + bus_size_t size; + int error; + + if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } /* copy our device handle */ sc->sc_self = self; - sc->sc_irq = loc->loc_intr; +// sc->sc_irq = loc->loc_intr; /* get our bushandles */ - sc->sc_bst = exyoaa->exyo_core_bst; - sc->sc_dmat = exyoaa->exyo_dmat; + sc->sc_bst = faa->faa_bst; +// sc->sc_dmat = exyoaa->exyo_dmat; // sc->sc_dmat = exyoaa->exyo_coherent_dmat; -#ifdef EXYNOS4 - ehci_offset = EXYNOS4_USB2_HOST_EHCI_OFFSET; - ohci_offset = EXYNOS4_USB2_HOST_OHCI_OFFSET; - usb2phy_offset = EXYNOS4_USB2_HOST_PHYCTRL_OFFSET; -#endif -#ifdef EXYNOS5 - ehci_offset = EXYNOS5_USB2_HOST_EHCI_OFFSET; - ohci_offset = EXYNOS5_USB2_HOST_OHCI_OFFSET; - usb2phy_offset = EXYNOS5_USB2_HOST_PHYCTRL_OFFSET; -#endif + error = bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh); + if (error) { + aprint_error(": couldn't map %#llx: %d", + (uint64_t)addr, error); + return; + } - bus_space_subregion(sc->sc_bst, exyoaa->exyo_core_bsh, - ehci_offset, EXYNOS_BLOCK_SIZE, - &sc->sc_ehci_bsh); - bus_space_subregion(sc->sc_bst, exyoaa->exyo_core_bsh, - ohci_offset, EXYNOS_BLOCK_SIZE, - &sc->sc_ohci_bsh); - bus_space_subregion(sc->sc_bst, exyoaa->exyo_core_bsh, - usb2phy_offset, EXYNOS_BLOCK_SIZE, - &sc->sc_usb2phy_bsh); + aprint_normal(" @ 0x%08x: USB - NOT IMPLEMENTED", (uint)addr); aprint_naive("\n"); aprint_normal("\n"); /* power up USB subsystem */ - exynos_usb_soc_powerup(); +// exynos_usb_soc_powerup(); /* init USB phys */ - exynos_usb_phy_init(sc->sc_usb2phy_bsh); - - /* - * Disable interrupts - * - * To prevent OHCI lockups on Exynos5 SoCs, we first have to read the - * address before we set it; this is most likely a bug in the SoC - */ -#if NOHCI > 0 - int regval; - - regval = bus_space_read_1(sc->sc_bst, sc->sc_ohci_bsh, - OHCI_INTERRUPT_DISABLE); - regval = OHCI_ALL_INTRS; - bus_space_write_4(sc->sc_bst, sc->sc_ohci_bsh, - OHCI_INTERRUPT_DISABLE, regval); -#endif - -#if NEHCI > 0 - bus_size_t caplength = bus_space_read_1(sc->sc_bst, - sc->sc_ehci_bsh, EHCI_CAPLENGTH); - bus_space_write_4(sc->sc_bst, sc->sc_ehci_bsh, - caplength + EHCI_USBINTR, 0); -#endif +// exynos_usb_phy_init(sc->sc_usb2phy_bsh); +#if 0 /* claim shared interrupt for OHCI/EHCI */ sc->sc_intrh = intr_establish(sc->sc_irq, IPL_USB, IST_LEVEL, exynos_usb_intr, sc); @@ -196,27 +166,11 @@ exynos_usb_attach(device_t parent, devic /* disable? TBD */ return; } - aprint_normal_dev(sc->sc_self, "USB2 host interrupting on irq %d\n", - sc->sc_irq); - -#if NOHCI > 0 - /* attach OHCI */ - struct exynos_usb_attach_args usb_ohci = { - .name = "ohci", - }; - sc->sc_ohci_dev = config_found(self, &usb_ohci, NULL); -#endif - -#if NEHCI > 0 - /* attach EHCI */ - struct exynos_usb_attach_args usb_ehci = { - .name = "ehci", - }; - sc->sc_ehci_dev = config_found(self, &usb_ehci, NULL); #endif + aprint_normal_dev(sc->sc_self, "USB host NOT IMPLEMENTED\n"); } - +#if 0 static int exynos_usb_intr(void *arg) { @@ -240,7 +194,7 @@ exynos_usb_intr(void *arg) return ret; } - +#endif #if NOHCI > 0 static int exynos_ohci_match(device_t, cfdata_t, void *); @@ -253,12 +207,10 @@ CFATTACH_DECL_NEW(ohci_exyousb, sizeof(s static int exynos_ohci_match(device_t parent, cfdata_t cf, void *aux) { - struct exynos_usb_attach_args *euaa = aux; - - if (strcmp(euaa->name, "ohci")) - return 0; - - return 1; + const char * const compatible[] = { "samsung,exynos5-ohci", + NULL }; + struct fdt_attach_args * const faa = aux; + return of_match_compatible(faa->faa_phandle, compatible); } @@ -267,19 +219,34 @@ exynos_ohci_attach(device_t parent, devi { struct exynos_usb_softc *usbsc = &exynos_usb_sc; struct ohci_softc *sc = device_private(self); + struct fdt_attach_args * const faa = aux; + bus_space_handle_t bsh; + bus_addr_t addr; + bus_size_t size; + int error; int r; + if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } + sc->sc_dev = self; sc->iot = usbsc->sc_bst; - sc->ioh = usbsc->sc_ohci_bsh; - sc->sc_size = EXYNOS_BLOCK_SIZE; +// sc->ioh = usbsc->sc_ohci_bsh; + sc->sc_size = size; sc->sc_bus.dmatag = usbsc->sc_dmat; sc->sc_bus.hci_private = sc; - strlcpy(sc->sc_vendor, "exynos", sizeof(sc->sc_vendor)); + error = bus_space_map(sc->iot, addr, size, 0, &bsh); + if (error) { + aprint_error(": couldn't map %#llx: %d", + (uint64_t)addr, error); + return; + } aprint_naive(": OHCI USB controller\n"); - aprint_normal(": OHCI USB controller\n"); + aprint_normal(": OHCI USB controller NOT IMPLEMENTED\n"); /* attach */ r = ohci_init(sc); @@ -306,12 +273,10 @@ CFATTACH_DECL_NEW(ehci_exyousb, sizeof(s static int exynos_ehci_match(device_t parent, cfdata_t cf, void *aux) { - struct exynos_usb_attach_args *euaa = aux; - - if (strcmp(euaa->name, "ehci")) - return 0; - - return 1; + const char * const compatible[] = { "samsung,exynos5-ehci", + NULL }; + struct fdt_attach_args * const faa = aux; + return of_match_compatible(faa->faa_phandle, compatible); } @@ -320,12 +285,20 @@ exynos_ehci_attach(device_t parent, devi { struct exynos_usb_softc *usbsc = &exynos_usb_sc; struct ehci_softc *sc = device_private(self); + struct fdt_attach_args * const faa = aux; + bus_addr_t addr; + bus_size_t size; int r; + if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { + aprint_error(": couldn't get registers\n"); + return; + } + sc->sc_dev = self; sc->iot = usbsc->sc_bst; sc->ioh = usbsc->sc_ehci_bsh; - sc->sc_size = EXYNOS_BLOCK_SIZE; + sc->sc_size = size; sc->sc_bus.dmatag = usbsc->sc_dmat; sc->sc_bus.hci_private = sc; sc->sc_bus.usbrev = USBREV_2_0; @@ -336,7 +309,7 @@ exynos_ehci_attach(device_t parent, devi strlcpy(sc->sc_vendor, "exynos", sizeof(sc->sc_vendor)); aprint_naive(": EHCI USB controller\n"); - aprint_normal(": EHCI USB controller\n"); + aprint_normal(": EHCI USB controller NOT IMPLEMENTED\n"); /* attach */ r = ehci_init(sc); Index: src/sys/arch/arm/samsung/files.exynos diff -u src/sys/arch/arm/samsung/files.exynos:1.15 src/sys/arch/arm/samsung/files.exynos:1.16 --- src/sys/arch/arm/samsung/files.exynos:1.15 Mon Dec 21 00:52:50 2015 +++ src/sys/arch/arm/samsung/files.exynos Mon Dec 21 03:34:34 2015 @@ -1,4 +1,4 @@ -# $NetBSD: files.exynos,v 1.15 2015/12/21 00:52:50 marty Exp $ +# $NetBSD: files.exynos,v 1.16 2015/12/21 03:34:34 marty Exp $ # # Configuration info for Samsung Exynos SoC ARM Peripherals # @@ -101,8 +101,8 @@ file arch/arm/samsung/exynos_gpio.c exy #file arch/arm/samsung/exynos_gpio.c exynos_gpio | exyo_io needs-flag # USB2 Host Controller (EHCI/OHCI) -device exyousb { } -attach exyousb at exyo with exyo_usb +device exyousb { } : fdtbus +attach exyousb at fdt with exyo_usb attach ohci at exyousb with ohci_exyousb attach ehci at exyousb with ehci_exyousb file arch/arm/samsung/exynos_usb.c exyo_usb @@ -115,5 +115,5 @@ file arch/arm/samsung/exynos_i2c.c exyn file arch/arm/samsung/exynos5422_dma.c device exy5422clk: clk -attach exy5422clk at exyo with exynos5422_clock +attach exy5422clk at fdt with exynos5422_clock file arch/arm/samsung/exynos5422_clock.c exynos5422_clock Index: src/sys/arch/evbarm/conf/EXYNOS diff -u src/sys/arch/evbarm/conf/EXYNOS:1.4 src/sys/arch/evbarm/conf/EXYNOS:1.5 --- src/sys/arch/evbarm/conf/EXYNOS:1.4 Mon Dec 21 00:52:51 2015 +++ src/sys/arch/evbarm/conf/EXYNOS Mon Dec 21 03:34:34 2015 @@ -1,5 +1,5 @@ # -# $NetBSD: EXYNOS,v 1.4 2015/12/21 00:52:51 marty Exp $ +# $NetBSD: EXYNOS,v 1.5 2015/12/21 03:34:34 marty Exp $ # # ODROID-XU -- ODROID-XU4 Exynos5422 based kernel # @@ -217,7 +217,7 @@ gic* at fdt? exyo0 at mainbus? # Clock controller -exy5422clk0 at exyo0 # Exynos5422 clock controller +exy5422clk0 at fdt? # Exynos5422 clock controller # Integrated Samsung UARTs sscom* at fdt? # UART ? @@ -244,7 +244,7 @@ exyopctl4 at fdt? #gpio* at exyogpio? # On-board USB -exyousb* at exyo0 +exyousb* at fdt? ohci* at exyousb? ehci* at exyousb? usb* at ohci?