Date: Mon, 13 Jan 2020 18:16:57 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356689 - stable/12/sys/arm/allwinner Message-ID: <202001131816.00DIGvkS010375@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Mon Jan 13 18:16:57 2020 New Revision: 356689 URL: https://svnweb.freebsd.org/changeset/base/356689 Log: MFC r356600: a10_ahci: grab the target-supply regulator and enable it This regulator is marked regulator-boot-on, but it will get shutdown if it's not actually used/enabled by a driver. This should fix sata on the cubieboard{1,2}. Modified: stable/12/sys/arm/allwinner/a10_ahci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/allwinner/a10_ahci.c ============================================================================== --- stable/12/sys/arm/allwinner/a10_ahci.c Mon Jan 13 17:02:42 2020 (r356688) +++ stable/12/sys/arm/allwinner/a10_ahci.c Mon Jan 13 18:16:57 2020 (r356689) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include <dev/ahci/ahci.h> #include <dev/extres/clk/clk.h> +#include <dev/extres/regulator/regulator.h> /* * Allwinner a1x/a2x/a8x SATA attachment. This is just the AHCI register @@ -119,6 +120,11 @@ __FBSDID("$FreeBSD$"); #define PLL_FREQ 100000000 +struct ahci_a10_softc { + struct ahci_controller ahci_ctlr; + regulator_t ahci_reg; +}; + static void inline ahci_set(struct resource *m, bus_size_t off, uint32_t set) { @@ -296,10 +302,12 @@ static int ahci_a10_attach(device_t dev) { int error; + struct ahci_a10_softc *sc; struct ahci_controller *ctlr; clk_t clk_pll, clk_gate; - ctlr = device_get_softc(dev); + sc = device_get_softc(dev); + ctlr = &sc->ahci_ctlr; clk_pll = clk_gate = NULL; ctlr->quirks = AHCI_Q_NOPMP; @@ -312,6 +320,19 @@ ahci_a10_attach(device_t dev) &ctlr->r_rid, RF_ACTIVE))) return (ENXIO); + /* Enable the regulator */ + error = regulator_get_by_ofw_property(dev, 0, "target-supply", + &sc->ahci_reg); + if (error != 0) { + device_printf(dev, "Cannot get regulator\n"); + goto fail; + } + error = regulator_enable(sc->ahci_reg); + if (error != 0) { + device_printf(dev, "Could not enable regulator\n"); + goto fail; + } + /* Enable clocks */ error = clk_get_by_ofw_index(dev, 0, 0, &clk_gate); if (error != 0) { @@ -358,6 +379,8 @@ ahci_a10_attach(device_t dev) return (ahci_attach(dev)); fail: + if (sc->ahci_reg != 0) + regulator_disable(sc->ahci_reg); if (clk_gate != NULL) clk_release(clk_gate); if (clk_pll != NULL) @@ -389,7 +412,7 @@ static device_method_t ahci_ata_methods[] = { static driver_t ahci_ata_driver = { "ahci", ahci_ata_methods, - sizeof(struct ahci_controller) + sizeof(struct ahci_a10_softc) }; DRIVER_MODULE(a10_ahci, simplebus, ahci_ata_driver, ahci_devclass, 0, 0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001131816.00DIGvkS010375>