diff options
author | Jared McNeill <jmcneill@FreeBSD.org> | 2016-04-06 23:11:03 +0000 |
---|---|---|
committer | Jared McNeill <jmcneill@FreeBSD.org> | 2016-04-06 23:11:03 +0000 |
commit | 6a05f063ed52ea26ce95114acfb4129df3487cb9 (patch) | |
tree | 3cc519e4e0b2976526a56c2f96d1e69dc1a61ade /sys/dev/iicbus | |
parent | 15719ec49938e1f7b3feb7a4df3c1862eeb4829a (diff) | |
download | src-6a05f063ed52ea26ce95114acfb4129df3487cb9.tar.gz src-6a05f063ed52ea26ce95114acfb4129df3487cb9.zip |
Convert Allwinner port to extres clk/hwreset/regulator APIs.
Reviewed by: andrew, gonzo, Emmanuel Vadot <manu@bidouilliste.com>
Approved by: gonzo (mentor)
Differential Revision: https://reviews.freebsd.org/D5752
Notes
Notes:
svn path=/head/; revision=297627
Diffstat (limited to 'sys/dev/iicbus')
-rw-r--r-- | sys/dev/iicbus/twsi/a10_twsi.c | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/sys/dev/iicbus/twsi/a10_twsi.c b/sys/dev/iicbus/twsi/a10_twsi.c index 6ee13ad59fe5..701153b1d438 100644 --- a/sys/dev/iicbus/twsi/a10_twsi.c +++ b/sys/dev/iicbus/twsi/a10_twsi.c @@ -48,8 +48,8 @@ __FBSDID("$FreeBSD$"); #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> -#include <arm/allwinner/a10_clk.h> -#include <arm/allwinner/a31/a31_clk.h> +#include <dev/extres/clk/clk.h> +#include <dev/extres/hwreset/hwreset.h> #include "iicbus_if.h" @@ -63,21 +63,16 @@ __FBSDID("$FreeBSD$"); #define TWI_EFR 0x1C #define TWI_LCR 0x20 -#define A10_I2C 1 -#define A31_I2C 2 - static struct ofw_compat_data compat_data[] = { - {"allwinner,sun4i-a10-i2c", A10_I2C}, - {"allwinner,sun6i-a31-i2c", A31_I2C}, + {"allwinner,sun4i-a10-i2c", 1}, + {"allwinner,sun6i-a31-i2c", 1}, {NULL, 0}, }; static int a10_twsi_probe(device_t dev) { - struct twsi_softc *sc; - sc = device_get_softc(dev); if (!ofw_bus_status_okay(dev)) return (ENXIO); @@ -92,29 +87,31 @@ static int a10_twsi_attach(device_t dev) { struct twsi_softc *sc; - int clk; + clk_t clk; + hwreset_t rst; + int error; sc = device_get_softc(dev); - /* Activate clock */ - switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) { -#if defined(SOC_ALLWINNER_A10) || defined(SOC_ALLWINNER_A20) - case A10_I2C: - clk = a10_clk_i2c_activate(device_get_unit(dev)); - break; -#endif -#if defined(SOC_ALLWINNER_A31) || defined(SOC_ALLWINNER_A31S) - case A31_I2C: - clk = a31_clk_i2c_activate(device_get_unit(dev)); - break; -#endif - default: - clk = -1; + /* De-assert reset */ + if (hwreset_get_by_ofw_idx(dev, 0, &rst) == 0) { + error = hwreset_deassert(rst); + if (error != 0) { + device_printf(dev, "could not de-assert reset\n"); + return (error); + } } - if (clk != 0) { - device_printf(dev, "could not activate i2c clock\n"); - return (ENXIO); + /* Activate clock */ + error = clk_get_by_ofw_index(dev, 0, &clk); + if (error != 0) { + device_printf(dev, "could not find clock\n"); + return (error); + } + error = clk_enable(clk); + if (error != 0) { + device_printf(dev, "could not enable clock\n"); + return (error); } sc->reg_data = TWI_DATA; |