From 8224ae00b5c3c99dbc9a5dbffda12e9f3e37db79 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Mon, 15 Aug 2016 09:16:27 +0000 Subject: Use the regulator API to supply power to the target. Tested by Daniel Bolgheroni on a Cubietech Cubieboard2. ok jsg@ --- sys/arch/armv7/sunxi/sxiahci.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/armv7/sunxi/sxiahci.c b/sys/arch/armv7/sunxi/sxiahci.c index 5595c41a40d..c797b9375d5 100644 --- a/sys/arch/armv7/sunxi/sxiahci.c +++ b/sys/arch/armv7/sunxi/sxiahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxiahci.c,v 1.9 2016/08/05 19:00:25 kettenis Exp $ */ +/* $OpenBSD: sxiahci.c,v 1.10 2016/08/15 09:16:26 kettenis Exp $ */ /* * Copyright (c) 2013 Patrick Wildt * Copyright (c) 2013,2014 Artturi Alm @@ -33,9 +33,9 @@ #include #include #include -#include #include +#include #include #define SXIAHCI_CAP 0x0000 @@ -97,6 +97,7 @@ sxiahci_attach(struct device *parent, struct device *self, void *aux) struct sxiahci_softc *sxisc = (struct sxiahci_softc *)self; struct ahci_softc *sc = &sxisc->sc; struct fdt_attach_args *faa = aux; + uint32_t target_supply; uint32_t timo; if (faa->fa_nreg < 1) @@ -165,8 +166,9 @@ sxiahci_attach(struct device *parent, struct device *self, void *aux) SXIWRITE4(sc, SXIAHCI_RWC, 7); /* power up phy */ - sxipio_setcfg(SXIAHCI_PWRPIN, SXIPIO_OUTPUT); - sxipio_setpin(SXIAHCI_PWRPIN); + target_supply = OF_getpropint(faa->fa_node, "target-supply", 0); + if (target_supply) + regulator_enable(target_supply); sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_BIO, ahci_intr, sc, sc->sc_dev.dv_xname); @@ -190,7 +192,8 @@ sxiahci_attach(struct device *parent, struct device *self, void *aux) irq: arm_intr_disestablish(sc->sc_ih); clrpwr: - sxipio_clrpin(SXIAHCI_PWRPIN); + if (target_supply) + regulator_disable(target_supply); dismod: sxiccmu_disablemodule(CCMU_AHCI); bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); -- cgit v1.2.3