Date: Fri, 10 Jan 2020 14:09:59 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356600 - head/sys/arm/allwinner Message-ID: <202001101409.00AE9x2n097091@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Fri Jan 10 14:09:59 2020 New Revision: 356600 URL: https://svnweb.freebsd.org/changeset/base/356600 Log: 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}. Reported by: Ray White @ UWaterloo Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D23112 Modified: head/sys/arm/allwinner/a10_ahci.c Modified: head/sys/arm/allwinner/a10_ahci.c ============================================================================== --- head/sys/arm/allwinner/a10_ahci.c Fri Jan 10 12:20:25 2020 (r356599) +++ head/sys/arm/allwinner/a10_ahci.c Fri Jan 10 14:09:59 2020 (r356600) @@ -47,6 +47,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 @@ -118,6 +119,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) { @@ -295,10 +301,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; @@ -311,6 +319,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) { @@ -357,6 +378,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) @@ -388,7 +411,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?202001101409.00AE9x2n097091>