Module Name: src Committed By: jmcneill Date: Sun Oct 29 15:00:00 UTC 2017
Modified Files: src/sys/arch/arm/sunxi: sunxi_twi.c src/sys/arch/evbarm/conf: SUNXI Log Message: sunxi_twi: provide custom read/write reg callbacks and remove the GTTWSI_ALLWINNER option from the kernel config To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_twi.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/evbarm/conf/SUNXI 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/sunxi/sunxi_twi.c diff -u src/sys/arch/arm/sunxi/sunxi_twi.c:1.5 src/sys/arch/arm/sunxi/sunxi_twi.c:1.6 --- src/sys/arch/arm/sunxi/sunxi_twi.c:1.5 Sat Oct 7 20:17:38 2017 +++ src/sys/arch/arm/sunxi/sunxi_twi.c Sun Oct 29 15:00:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_twi.c,v 1.5 2017/10/07 20:17:38 jmcneill Exp $ */ +/* $NetBSD: sunxi_twi.c,v 1.6 2017/10/29 15:00:00 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca> @@ -26,9 +26,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "opt_gttwsi.h" +#ifdef GTTWSI_ALLWINNER +# error Do not define GTTWSI_ALLWINNER when using this driver +#endif + #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.5 2017/10/07 20:17:38 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.6 2017/10/29 15:00:00 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -39,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c, #include <dev/i2c/i2cvar.h> #include <dev/i2c/gttwsivar.h> +#include <dev/i2c/gttwsireg.h> #include <dev/fdt/fdtvar.h> @@ -46,6 +52,16 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c, #define TWI_CCR_CLK_M __BITS(6,3) #define TWI_CCR_CLK_N __BITS(2,0) +static uint8_t sunxi_twi_regmap[] = { + [TWSI_SLAVEADDR] = 0x00, + [TWSI_EXTEND_SLAVEADDR] = 0x04, + [TWSI_DATA] = 0x08, + [TWSI_CONTROL] = 0x0c, + [TWSI_STATUS] = 0x10, + [TWSI_BAUDRATE] = 0x14, + [TWSI_SOFTRESET] = 0x18, +}; + static int sunxi_twi_match(device_t, cfdata_t, void *); static void sunxi_twi_attach(device_t, device_t, void *); @@ -82,6 +98,18 @@ const struct fdtbus_i2c_controller_func .get_tag = sunxi_twi_get_tag, }; +static uint32_t +sunxi_twi_reg_read(struct gttwsi_softc *sc, uint32_t reg) +{ + return bus_space_read_4(sc->sc_bust, sc->sc_bush, sunxi_twi_regmap[reg]); +} + +static void +sunxi_twi_reg_write(struct gttwsi_softc *sc, uint32_t reg, uint32_t val) +{ + bus_space_write_4(sc->sc_bust, sc->sc_bush, sunxi_twi_regmap[reg], val); +} + static int sunxi_twi_match(device_t parent, cfdata_t cf, void *aux) { @@ -149,6 +177,9 @@ sunxi_twi_attach(device_t parent, device __SHIFTIN(m, TWI_CCR_CLK_M); bus_space_write_4(bst, bsh, TWI_CCR_REG, ccr); + sc->sc_reg_read = sunxi_twi_reg_read; + sc->sc_reg_write = sunxi_twi_reg_write; + gttwsi_attach_subr(self, bst, bsh); ih = fdtbus_intr_establish(phandle, 0, IPL_VM, 0, gttwsi_intr, sc); Index: src/sys/arch/evbarm/conf/SUNXI diff -u src/sys/arch/evbarm/conf/SUNXI:1.48 src/sys/arch/evbarm/conf/SUNXI:1.49 --- src/sys/arch/evbarm/conf/SUNXI:1.48 Sun Oct 29 14:07:11 2017 +++ src/sys/arch/evbarm/conf/SUNXI Sun Oct 29 15:00:00 2017 @@ -1,5 +1,5 @@ # -# $NetBSD: SUNXI,v 1.48 2017/10/29 14:07:11 jmcneill Exp $ +# $NetBSD: SUNXI,v 1.49 2017/10/29 15:00:00 jmcneill Exp $ # # Allwinner sunxi family # @@ -170,7 +170,6 @@ com* at fdt? # UART # I2C sunxitwi* at fdt? # TWI -options GTTWSI_ALLWINNER # XXX this should be a driver flag sunxirsb* at fdt? # P2WI/RSB iic* at i2cbus? tcakp* at iic? # TI TCA8418 Keypad Scan IC