Sun Jan 12 17:48:42 2020 UTC ()
Clean up gttwsi's register access stuff:
- Garbage-collect the obsolete GTTWSI_ALLWINNER option; it hasn't been
  needed since FDT'ization of the Allwinner support code.
- Redefine thw "TWSI_*" register definitions to clearly call out:
  -> The Marvell flavor of the offsets
  -> The Allwinner flavor of the offsets
  ...and make the regular definitions indices into a register map.
- Pass the appropriate register map from the front-end to the core.
- Remove the customer register read/write callbacks -- they are no longer
  needed now that each front-end passes an appropriate register map to
  the core.


(thorpej)
diff -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_twi.c
diff -r1.107 -r1.108 src/sys/dev/i2c/files.i2c
diff -r1.11 -r1.12 src/sys/dev/i2c/gttwsi_core.c
diff -r1.3 -r1.4 src/sys/dev/i2c/gttwsireg.h
diff -r1.5 -r1.6 src/sys/dev/i2c/gttwsivar.h
diff -r1.11 -r1.12 src/sys/dev/marvell/gttwsi.c

cvs diff -r1.10 -r1.11 src/sys/arch/arm/sunxi/sunxi_twi.c (expand / switch to unified diff)

--- src/sys/arch/arm/sunxi/sunxi_twi.c 2018/07/01 21:16:19 1.10
+++ src/sys/arch/arm/sunxi/sunxi_twi.c 2020/01/12 17:48:42 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sunxi_twi.c,v 1.10 2018/07/01 21:16:19 jmcneill Exp $ */ 1/* $NetBSD: sunxi_twi.c,v 1.11 2020/01/12 17:48:42 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -16,68 +16,55 @@ @@ -16,68 +16,55 @@
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include "opt_gttwsi.h" 
30#ifdef GTTWSI_ALLWINNER 
31# error Do not define GTTWSI_ALLWINNER when using this driver 
32#endif 
33 
34#include <sys/cdefs.h> 29#include <sys/cdefs.h>
35 30
36__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.10 2018/07/01 21:16:19 jmcneill Exp $"); 31__KERNEL_RCSID(0, "$NetBSD: sunxi_twi.c,v 1.11 2020/01/12 17:48:42 thorpej Exp $");
37 32
38#include <sys/param.h> 33#include <sys/param.h>
39#include <sys/bus.h> 34#include <sys/bus.h>
40#include <sys/device.h> 35#include <sys/device.h>
41#include <sys/intr.h> 36#include <sys/intr.h>
42#include <sys/systm.h> 37#include <sys/systm.h>
43#include <sys/time.h> 38#include <sys/time.h>
44 39
45#include <dev/i2c/i2cvar.h> 40#include <dev/i2c/i2cvar.h>
46#include <dev/i2c/gttwsivar.h> 41#include <dev/i2c/gttwsivar.h>
47#include <dev/i2c/gttwsireg.h> 42#include <dev/i2c/gttwsireg.h>
48 43
49#include <dev/fdt/fdtvar.h> 44#include <dev/fdt/fdtvar.h>
50 45
51#define TWI_CCR_REG 0x14 46#define TWI_CCR_REG 0x14
52#define TWI_CCR_CLK_M __BITS(6,3) 47#define TWI_CCR_CLK_M __BITS(6,3)
53#define TWI_CCR_CLK_N __BITS(2,0) 48#define TWI_CCR_CLK_N __BITS(2,0)
54 49
55static uint8_t sunxi_twi_regmap_rd[] = { 50static const bus_size_t sunxi_twi_regmap[] = {
56 [TWSI_SLAVEADDR/4] = 0x00, 51 [TWSI_SLAVEADDR] = TWSI_ALLWINNER_SLAVEADDR,
57 [TWSI_EXTEND_SLAVEADDR/4] = 0x04, 52 [TWSI_EXTEND_SLAVEADDR] = TWSI_ALLWINNER_EXTEND_SLAVEADDR,
58 [TWSI_DATA/4] = 0x08, 53 [TWSI_DATA] = TWSI_ALLWINNER_DATA,
59 [TWSI_CONTROL/4] = 0x0c, 54 [TWSI_CONTROL] = TWSI_ALLWINNER_CONTROL,
60 [TWSI_STATUS/4] = 0x10, 55 [TWSI_STATUS] = TWSI_ALLWINNER_STATUS,
61 [TWSI_SOFTRESET/4] = 0x18, 56 [TWSI_BAUDRATE] = TWSI_ALLWINNER_BAUDRATE,
62}; 57 [TWSI_SOFTRESET] = TWSI_ALLWINNER_SOFTRESET,
63 
64static uint8_t sunxi_twi_regmap_wr[] = { 
65 [TWSI_SLAVEADDR/4] = 0x00, 
66 [TWSI_EXTEND_SLAVEADDR/4] = 0x04, 
67 [TWSI_DATA/4] = 0x08, 
68 [TWSI_CONTROL/4] = 0x0c, 
69 [TWSI_BAUDRATE/4] = 0x14, 
70 [TWSI_SOFTRESET/4] = 0x18, 
71}; 58};
72 59
73static int sunxi_twi_match(device_t, cfdata_t, void *); 60static int sunxi_twi_match(device_t, cfdata_t, void *);
74static void sunxi_twi_attach(device_t, device_t, void *); 61static void sunxi_twi_attach(device_t, device_t, void *);
75 62
76struct sunxi_twi_config { 63struct sunxi_twi_config {
77 bool iflg_rwc; 64 bool iflg_rwc;
78}; 65};
79 66
80static const struct sunxi_twi_config sun4i_a10_i2c_config = { 67static const struct sunxi_twi_config sun4i_a10_i2c_config = {
81 .iflg_rwc = false, 68 .iflg_rwc = false,
82}; 69};
83 70
@@ -96,64 +83,53 @@ CFATTACH_DECL_NEW(sunxi_twi, sizeof(stru @@ -96,64 +83,53 @@ CFATTACH_DECL_NEW(sunxi_twi, sizeof(stru
96 83
97static i2c_tag_t 84static i2c_tag_t
98sunxi_twi_get_tag(device_t dev) 85sunxi_twi_get_tag(device_t dev)
99{ 86{
100 struct gttwsi_softc * const sc = device_private(dev); 87 struct gttwsi_softc * const sc = device_private(dev);
101 88
102 return &sc->sc_i2c; 89 return &sc->sc_i2c;
103} 90}
104 91
105const struct fdtbus_i2c_controller_func sunxi_twi_funcs = { 92const struct fdtbus_i2c_controller_func sunxi_twi_funcs = {
106 .get_tag = sunxi_twi_get_tag, 93 .get_tag = sunxi_twi_get_tag,
107}; 94};
108 95
109static uint32_t 
110sunxi_twi_reg_read(struct gttwsi_softc *sc, uint32_t reg) 
111{ 
112 return bus_space_read_4(sc->sc_bust, sc->sc_bush, sunxi_twi_regmap_rd[reg/4]); 
113} 
114 
115static void 
116sunxi_twi_reg_write(struct gttwsi_softc *sc, uint32_t reg, uint32_t val) 
117{ 
118 bus_space_write_4(sc->sc_bust, sc->sc_bush, sunxi_twi_regmap_wr[reg/4], val); 
119} 
120 
121static u_int 96static u_int
122sunxi_twi_calc_rate(u_int parent_rate, u_int n, u_int m) 97sunxi_twi_calc_rate(u_int parent_rate, u_int n, u_int m)
123{ 98{
124 return parent_rate / (10 * (m + 1) * (1 << n)); 99 return parent_rate / (10 * (m + 1) * (1 << n));
125} 100}
126 101
127static void 102static void
128sunxi_twi_set_clock(struct gttwsi_softc *sc, u_int parent_rate, u_int rate) 103sunxi_twi_set_clock(struct gttwsi_softc *sc, u_int parent_rate, u_int rate)
129{ 104{
130 uint32_t baud; 105 uint32_t baud;
131 u_int n, m, best_rate; 106 u_int n, m, best_rate;
132 107
133 baud = sunxi_twi_reg_read(sc, TWSI_BAUDRATE); 108 baud = gttwsi_read_4(sc, TWSI_BAUDRATE);
134 109
135 for (best_rate = 0, n = 0; n < 8; n++) { 110 for (best_rate = 0, n = 0; n < 8; n++) {
136 for (m = 0; m < 16; m++) { 111 for (m = 0; m < 16; m++) {
137 const u_int tmp_rate = sunxi_twi_calc_rate(parent_rate, n, m); 112 const u_int tmp_rate =
 113 sunxi_twi_calc_rate(parent_rate, n, m);
138 if (tmp_rate <= rate && tmp_rate > best_rate) { 114 if (tmp_rate <= rate && tmp_rate > best_rate) {
139 best_rate = tmp_rate; 115 best_rate = tmp_rate;
140 baud = __SHIFTIN(n, TWI_CCR_CLK_N) | 116 baud = __SHIFTIN(n, TWI_CCR_CLK_N) |
141 __SHIFTIN(m, TWI_CCR_CLK_M); 117 __SHIFTIN(m, TWI_CCR_CLK_M);
142 } 118 }
143 } 119 }
144 } 120 }
145 121
146 sunxi_twi_reg_write(sc, TWSI_BAUDRATE, baud); 122 gttwsi_write_4(sc, TWSI_BAUDRATE, baud);
147 delay(10000); 123 delay(10000);
148} 124}
149 125
150static int 126static int
151sunxi_twi_match(device_t parent, cfdata_t cf, void *aux) 127sunxi_twi_match(device_t parent, cfdata_t cf, void *aux)
152{ 128{
153 struct fdt_attach_args * const faa = aux; 129 struct fdt_attach_args * const faa = aux;
154 130
155 return of_match_compat_data(faa->faa_phandle, compat_data); 131 return of_match_compat_data(faa->faa_phandle, compat_data);
156} 132}
157 133
158static void 134static void
159sunxi_twi_attach(device_t parent, device_t self, void *aux) 135sunxi_twi_attach(device_t parent, device_t self, void *aux)
@@ -192,29 +168,27 @@ sunxi_twi_attach(device_t parent, device @@ -192,29 +168,27 @@ sunxi_twi_attach(device_t parent, device
192 return; 168 return;
193 } 169 }
194 if ((rst = fdtbus_reset_get_index(phandle, 0)) != NULL) 170 if ((rst = fdtbus_reset_get_index(phandle, 0)) != NULL)
195 if (fdtbus_reset_deassert(rst) != 0) { 171 if (fdtbus_reset_deassert(rst) != 0) {
196 aprint_error(": couldn't de-assert reset\n"); 172 aprint_error(": couldn't de-assert reset\n");
197 return; 173 return;
198 } 174 }
199 175
200 conf = (void *)of_search_compatible(phandle, compat_data)->data; 176 conf = (void *)of_search_compatible(phandle, compat_data)->data;
201 prop_dictionary_set_bool(device_properties(self), "iflg-rwc", 177 prop_dictionary_set_bool(device_properties(self), "iflg-rwc",
202 conf->iflg_rwc); 178 conf->iflg_rwc);
203 179
204 /* Attach gttwsi core */ 180 /* Attach gttwsi core */
205 sc->sc_reg_read = sunxi_twi_reg_read; 181 gttwsi_attach_subr(self, bst, bsh, sunxi_twi_regmap);
206 sc->sc_reg_write = sunxi_twi_reg_write; 
207 gttwsi_attach_subr(self, bst, bsh); 
208 182
209 /* 183 /*
210 * Set clock rate to 100kHz. 184 * Set clock rate to 100kHz.
211 */ 185 */
212 if (clk != NULL) 186 if (clk != NULL)
213 sunxi_twi_set_clock(sc, clk_get_rate(clk), 100000); 187 sunxi_twi_set_clock(sc, clk_get_rate(clk), 100000);
214 188
215 ih = fdtbus_intr_establish(phandle, 0, IPL_VM, 0, gttwsi_intr, sc); 189 ih = fdtbus_intr_establish(phandle, 0, IPL_VM, 0, gttwsi_intr, sc);
216 if (ih == NULL) { 190 if (ih == NULL) {
217 aprint_error_dev(self, "couldn't establish interrupt on %s\n", 191 aprint_error_dev(self, "couldn't establish interrupt on %s\n",
218 intrstr); 192 intrstr);
219 return; 193 return;
220 } 194 }

cvs diff -r1.107 -r1.108 src/sys/dev/i2c/files.i2c (expand / switch to unified diff)

--- src/sys/dev/i2c/files.i2c 2020/01/03 18:00:05 1.107
+++ src/sys/dev/i2c/files.i2c 2020/01/12 17:48:42 1.108
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files.i2c,v 1.107 2020/01/03 18:00:05 jmcneill Exp $ 1# $NetBSD: files.i2c,v 1.108 2020/01/12 17:48:42 thorpej Exp $
2 2
3obsolete defflag opt_i2cbus.h I2C_SCAN 3obsolete defflag opt_i2cbus.h I2C_SCAN
4define i2cbus { } 4define i2cbus { }
5define i2cexec 5define i2cexec
6 6
7device iic { [addr = -1] } : i2c_bitbang 7device iic { [addr = -1] } : i2c_bitbang
8attach iic at i2cbus 8attach iic at i2cbus
9file dev/i2c/i2c.c iic 9file dev/i2c/i2c.c iic
10file dev/i2c/i2c_exec.c iic | i2cbus | i2cexec 10file dev/i2c/i2c_exec.c iic | i2cbus | i2cexec
11file dev/i2c/i2c_subr.c i2cbus 11file dev/i2c/i2c_subr.c i2cbus
12defparam opt_i2c.h I2C_MAX_ADDR 12defparam opt_i2c.h I2C_MAX_ADDR
13 13
14# Common module for bit-bang'ing an I2C bus 14# Common module for bit-bang'ing an I2C bus
@@ -45,27 +45,26 @@ define mt2131: i2cexec @@ -45,27 +45,26 @@ define mt2131: i2cexec
45file dev/i2c/mt2131.c mt2131 45file dev/i2c/mt2131.c mt2131
46 46
47# Conexant/Samsung CX24227/S5H1409 demodulator 47# Conexant/Samsung CX24227/S5H1409 demodulator
48define cx24227: i2cexec 48define cx24227: i2cexec
49file dev/i2c/cx24227.c cx24227 49file dev/i2c/cx24227.c cx24227
50 50
51# 51#
52# I2C master devices 52# I2C master devices
53# 53#
54define motoi2c 54define motoi2c
55file dev/i2c/motoi2c.c motoi2c 55file dev/i2c/motoi2c.c motoi2c
56define mvi2c 56define mvi2c
57file dev/i2c/gttwsi_core.c mvi2c 57file dev/i2c/gttwsi_core.c mvi2c
58defflag opt_gttwsi.h GTTWSI_ALLWINNER 
59 58
60# 59#
61# I2C client devices 60# I2C client devices
62# 61#
63 62
64# M41T00 Real Time Clock 63# M41T00 Real Time Clock
65device m41trtc 64device m41trtc
66attach m41trtc at iic 65attach m41trtc at iic
67file dev/i2c/m41t00.c m41trtc 66file dev/i2c/m41t00.c m41trtc
68 67
69# M41ST84 Real Time Clock 68# M41ST84 Real Time Clock
70device strtc 69device strtc
71attach strtc at iic 70attach strtc at iic

cvs diff -r1.11 -r1.12 src/sys/dev/i2c/gttwsi_core.c (expand / switch to unified diff)

--- src/sys/dev/i2c/gttwsi_core.c 2020/01/11 22:21:25 1.11
+++ src/sys/dev/i2c/gttwsi_core.c 2020/01/12 17:48:42 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gttwsi_core.c,v 1.11 2020/01/11 22:21:25 thorpej Exp $ */ 1/* $NetBSD: gttwsi_core.c,v 1.12 2020/01/12 17:48:42 thorpej Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Eiji Kawauchi. 3 * Copyright (c) 2008 Eiji Kawauchi.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -56,127 +56,112 @@ @@ -56,127 +56,112 @@
56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
60 * OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THE POSSIBILITY OF SUCH DAMAGE.
61 */ 61 */
62//#define TWSI_DEBUG 62//#define TWSI_DEBUG
63 63
64/* 64/*
65 * Marvell Two-Wire Serial Interface (aka I2C) master driver 65 * Marvell Two-Wire Serial Interface (aka I2C) master driver
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.11 2020/01/11 22:21:25 thorpej Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.12 2020/01/12 17:48:42 thorpej Exp $");
70#include "locators.h" 70#include "locators.h"
71 71
72#include <sys/param.h> 72#include <sys/param.h>
73#include <sys/bus.h> 73#include <sys/bus.h>
74#include <sys/condvar.h> 74#include <sys/condvar.h>
75#include <sys/device.h> 75#include <sys/device.h>
76#include <sys/errno.h> 76#include <sys/errno.h>
77#include <sys/kernel.h> 77#include <sys/kernel.h>
78#include <sys/mutex.h> 78#include <sys/mutex.h>
79#include <sys/systm.h> 79#include <sys/systm.h>
80 80
81#include <dev/i2c/i2cvar.h> 81#include <dev/i2c/i2cvar.h>
82 82
83#include <dev/i2c/gttwsireg.h> 83#include <dev/i2c/gttwsireg.h>
84#include <dev/i2c/gttwsivar.h> 84#include <dev/i2c/gttwsivar.h>
85 85
86static int gttwsi_send_start(void *v, int flags); 86static int gttwsi_send_start(void *v, int flags);
87static int gttwsi_send_stop(void *v, int flags); 87static int gttwsi_send_stop(void *v, int flags);
88static int gttwsi_initiate_xfer(void *v, i2c_addr_t addr, int flags); 88static int gttwsi_initiate_xfer(void *v, i2c_addr_t addr, int flags);
89static int gttwsi_read_byte(void *v, uint8_t *valp, int flags); 89static int gttwsi_read_byte(void *v, uint8_t *valp, int flags);
90static int gttwsi_write_byte(void *v, uint8_t val, int flags); 90static int gttwsi_write_byte(void *v, uint8_t val, int flags);
91 91
92static int gttwsi_wait(struct gttwsi_softc *, uint32_t, uint32_t, 92static int gttwsi_wait(struct gttwsi_softc *, uint32_t, uint32_t,
93 uint32_t, int); 93 uint32_t, int);
94 94
95static inline uint32_t 95uint32_t
96gttwsi_default_read_4(struct gttwsi_softc *sc, uint32_t reg) 96gttwsi_read_4(struct gttwsi_softc *sc, uint32_t reg)
97{ 97{
98 uint32_t val = bus_space_read_4(sc->sc_bust, sc->sc_bush, reg); 98 const uint32_t val = bus_space_read_4(sc->sc_bust, sc->sc_bush,
 99 sc->sc_regmap[reg]);
99#ifdef TWSI_DEBUG 100#ifdef TWSI_DEBUG
100 printf("I2C:R:%02x:%02x\n", reg, val); 101 printf("I2C:R:[%u]%02x:%02x\n", reg, sc->sc_regmap[reg], val);
101#else 102#else
102 DELAY(TWSI_READ_DELAY); 103 DELAY(TWSI_READ_DELAY);
103#endif 104#endif
104 return val; 105 return val;
105} 106}
106 107
107static inline void 108void
108gttwsi_default_write_4(struct gttwsi_softc *sc, uint32_t reg, uint32_t val) 109gttwsi_write_4(struct gttwsi_softc *sc, uint32_t reg, uint32_t val)
109{ 110{
 111
110 bus_space_write_4(sc->sc_bust, sc->sc_bush, reg, val); 112 bus_space_write_4(sc->sc_bust, sc->sc_bush, reg, val);
111#ifdef TWSI_DEBUG 113#ifdef TWSI_DEBUG
112 printf("I2C:W:%02x:%02x\n", reg, val); 114 printf("I2C:W:[%u]%02x:%02x\n", reg, sc->sc_regmap[reg], val);
113#else 115#else
114 DELAY(TWSI_WRITE_DELAY); 116 DELAY(TWSI_WRITE_DELAY);
115#endif 117#endif
116 return; 
117} 
118 
119static inline uint32_t 
120gttwsi_read_4(struct gttwsi_softc *sc, uint32_t reg) 
121{ 
122 return sc->sc_reg_read(sc, reg); 
123} 
124 
125static inline void 
126gttwsi_write_4(struct gttwsi_softc *sc, uint32_t reg, uint32_t val) 
127{ 
128 return sc->sc_reg_write(sc, reg, val); 
129} 118}
130 119
131/* ARGSUSED */ 120/* ARGSUSED */
132void 121void
133gttwsi_attach_subr(device_t self, bus_space_tag_t iot, bus_space_handle_t ioh) 122gttwsi_attach_subr(device_t self, bus_space_tag_t iot, bus_space_handle_t ioh,
 123 const bus_size_t *regmap)
134{ 124{
135 struct gttwsi_softc * const sc = device_private(self); 125 struct gttwsi_softc * const sc = device_private(self);
136 prop_dictionary_t cfg = device_properties(self); 126 prop_dictionary_t cfg = device_properties(self);
137 127
138 aprint_naive("\n"); 128 aprint_naive("\n");
139 aprint_normal(": Marvell TWSI controller\n"); 129 aprint_normal(": Marvell TWSI controller\n");
140 130
141 sc->sc_dev = self; 131 sc->sc_dev = self;
142 sc->sc_bust = iot; 132 sc->sc_bust = iot;
143 sc->sc_bush = ioh; 133 sc->sc_bush = ioh;
144 134 sc->sc_regmap = regmap;
145 if (sc->sc_reg_read == NULL) 
146 sc->sc_reg_read = gttwsi_default_read_4; 
147 if (sc->sc_reg_write == NULL) 
148 sc->sc_reg_write = gttwsi_default_write_4; 
149 135
150 mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_BIO); 136 mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_BIO);
151 cv_init(&sc->sc_cv, device_xname(self)); 137 cv_init(&sc->sc_cv, device_xname(self));
152 138
153 prop_dictionary_get_bool(cfg, "iflg-rwc", &sc->sc_iflg_rwc); 139 prop_dictionary_get_bool(cfg, "iflg-rwc", &sc->sc_iflg_rwc);
154 140
155 sc->sc_started = false; 141 sc->sc_started = false;
156 iic_tag_init(&sc->sc_i2c); 142 iic_tag_init(&sc->sc_i2c);
157 sc->sc_i2c.ic_cookie = sc; 143 sc->sc_i2c.ic_cookie = sc;
158 sc->sc_i2c.ic_send_start = gttwsi_send_start; 144 sc->sc_i2c.ic_send_start = gttwsi_send_start;
159 sc->sc_i2c.ic_send_stop = gttwsi_send_stop; 145 sc->sc_i2c.ic_send_stop = gttwsi_send_stop;
160 sc->sc_i2c.ic_initiate_xfer = gttwsi_initiate_xfer; 146 sc->sc_i2c.ic_initiate_xfer = gttwsi_initiate_xfer;
161 sc->sc_i2c.ic_read_byte = gttwsi_read_byte; 147 sc->sc_i2c.ic_read_byte = gttwsi_read_byte;
162 sc->sc_i2c.ic_write_byte = gttwsi_write_byte; 148 sc->sc_i2c.ic_write_byte = gttwsi_write_byte;
163 149
164 /* 150 /*
165 * Put the controller into Soft Reset. 151 * Put the controller into Soft Reset.
166 */ 152 */
167 /* reset */ 153 /* reset */
168 gttwsi_write_4(sc, TWSI_SOFTRESET, SOFTRESET_VAL); 154 gttwsi_write_4(sc, TWSI_SOFTRESET, SOFTRESET_VAL);
169 
170} 155}
171 156
172void 157void
173gttwsi_config_children(device_t self) 158gttwsi_config_children(device_t self)
174{ 159{
175 struct gttwsi_softc * const sc = device_private(self); 160 struct gttwsi_softc * const sc = device_private(self);
176 struct i2cbus_attach_args iba; 161 struct i2cbus_attach_args iba;
177 162
178 memset(&iba, 0, sizeof(iba)); 163 memset(&iba, 0, sizeof(iba));
179 iba.iba_tag = &sc->sc_i2c; 164 iba.iba_tag = &sc->sc_i2c;
180 165
181 (void) config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print); 166 (void) config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print);
182} 167}

cvs diff -r1.3 -r1.4 src/sys/dev/i2c/gttwsireg.h (expand / switch to unified diff)

--- src/sys/dev/i2c/gttwsireg.h 2014/09/11 11:14:44 1.3
+++ src/sys/dev/i2c/gttwsireg.h 2020/01/12 17:48:42 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gttwsireg.h,v 1.3 2014/09/11 11:14:44 jmcneill Exp $ */ 1/* $NetBSD: gttwsireg.h,v 1.4 2020/01/12 17:48:42 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Eiji Kawauchi. 4 * Copyright (c) 2008 Eiji Kawauchi.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,47 +17,57 @@ @@ -17,47 +17,57 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27#ifndef _GTTWSIREG_H_ 27#ifndef _GTTWSIREG_H_
28#define _GTTWSIREG_H_ 28#define _GTTWSIREG_H_
29 29
30#include "opt_gttwsi.h" 
31 
32#define GTTWSI_SIZE 0x100 30#define GTTWSI_SIZE 0x100
 31#define GTTWSI_NREGS 7
33 32
34#if defined(GTTWSI_ALLWINNER) 33 /* reg map indices */
35#define TWSI_SLAVEADDR 0x00 34#define TWSI_SLAVEADDR 0
36#define TWSI_EXTEND_SLAVEADDR 0x04 35#define TWSI_EXTEND_SLAVEADDR 1
37#define TWSI_DATA 0x08 36#define TWSI_DATA 2
38#define TWSI_CONTROL 0x0c 37#define TWSI_CONTROL 3
39#define TWSI_STATUS 0x10 38#define TWSI_STATUS 4
40#define TWSI_BAUDRATE 0x14 39#define TWSI_BAUDRATE 5
41#define TWSI_SOFTRESET 0x18 40#define TWSI_SOFTRESET 6
42#else 41
43#define TWSI_SLAVEADDR 0x00 42 /* register offsets for Allwinner implementations */
44#define TWSI_EXTEND_SLAVEADDR 0x10 43#define TWSI_ALLWINNER_SLAVEADDR 0x00
45#define TWSI_DATA 0x04 44#define TWSI_ALLWINNER_EXTEND_SLAVEADDR 0x04
46#define TWSI_CONTROL 0x08 45#define TWSI_ALLWINNER_DATA 0x08
47#define TWSI_STATUS 0x0c /* for read */ 46#define TWSI_ALLWINNER_CONTROL 0x0c
48#define TWSI_BAUDRATE 0x0c /* for write */ 47#define TWSI_ALLWINNER_STATUS 0x10
49#define TWSI_SOFTRESET 0x1c 48#define TWSI_ALLWINNER_BAUDRATE 0x14
50#endif 49#define TWSI_ALLWINNER_SOFTRESET 0x18
 50#define TWSI_ALLWINNER_ENH_FEAT 0x1c
 51#define TWSI_ALLWINNER_LINE_CTRL 0x20
 52
 53 /* register offsets for Marvell implementations */
 54#define TWSI_MARVELL_SLAVEADDR 0x00
 55#define TWSI_MARVELL_EXTEND_SLAVEADDR 0x10
 56#define TWSI_MARVELL_DATA 0x04
 57#define TWSI_MARVELL_CONTROL 0x08
 58#define TWSI_MARVELL_STATUS 0x0c /* for read */
 59#define TWSI_MARVELL_BAUDRATE 0x0c /* for write */
 60#define TWSI_MARVELL_SOFTRESET 0x1c
51 61
52#define SLAVEADDR_GCE_MASK 0x01 62#define SLAVEADDR_GCE_MASK 0x01
53#define SLAVEADDR_SADDR_MASK 0xfe 63#define SLAVEADDR_SADDR_MASK 0xfe
54 64
55#define EXTEND_SLAVEADDR_MASK 0xff 65#define EXTEND_SLAVEADDR_MASK 0xff
56 66
57#define DATA_MASK 0xff 67#define DATA_MASK 0xff
58 68
59#define CONTROL_ACK (1<<2) 69#define CONTROL_ACK (1<<2)
60#define CONTROL_IFLG (1<<3) 70#define CONTROL_IFLG (1<<3)
61#define CONTROL_STOP (1<<4) 71#define CONTROL_STOP (1<<4)
62#define CONTROL_START (1<<5) 72#define CONTROL_START (1<<5)
63#define CONTROL_TWSIEN (1<<6) 73#define CONTROL_TWSIEN (1<<6)

cvs diff -r1.5 -r1.6 src/sys/dev/i2c/gttwsivar.h (expand / switch to unified diff)

--- src/sys/dev/i2c/gttwsivar.h 2019/12/25 14:08:47 1.5
+++ src/sys/dev/i2c/gttwsivar.h 2020/01/12 17:48:42 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gttwsivar.h,v 1.5 2019/12/25 14:08:47 thorpej Exp $ */ 1/* $NetBSD: gttwsivar.h,v 1.6 2020/01/12 17:48:42 thorpej Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Eiji Kawauchi. 3 * Copyright (c) 2008 Eiji Kawauchi.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -78,25 +78,28 @@ @@ -78,25 +78,28 @@
78 78
79#include <dev/i2c/i2cvar.h> 79#include <dev/i2c/i2cvar.h>
80 80
81struct gttwsi_softc { 81struct gttwsi_softc {
82 device_t sc_dev; 82 device_t sc_dev;
83 bus_space_tag_t sc_bust; 83 bus_space_tag_t sc_bust;
84 bus_space_handle_t sc_bush; 84 bus_space_handle_t sc_bush;
85 bool sc_started; 85 bool sc_started;
86 struct i2c_controller sc_i2c; 86 struct i2c_controller sc_i2c;
87 kmutex_t sc_buslock; 87 kmutex_t sc_buslock;
88 kmutex_t sc_mtx; 88 kmutex_t sc_mtx;
89 kcondvar_t sc_cv; 89 kcondvar_t sc_cv;
90 90
91 bool sc_iflg_rwc; 91 const bus_size_t *sc_regmap; /* GTTWSI_NREGS entries */
92 92
93 uint32_t (*sc_reg_read)(struct gttwsi_softc *, uint32_t); 93 bool sc_iflg_rwc;
94 void (*sc_reg_write)(struct gttwsi_softc *, uint32_t, uint32_t); 
95}; 94};
96 95
97void gttwsi_attach_subr(device_t, bus_space_tag_t, bus_space_handle_t); 96void gttwsi_attach_subr(device_t, bus_space_tag_t, bus_space_handle_t,
 97 const bus_size_t *);
98void gttwsi_config_children(device_t); 98void gttwsi_config_children(device_t);
99 99
 100uint32_t gttwsi_read_4(struct gttwsi_softc *, uint32_t);
 101void gttwsi_write_4(struct gttwsi_softc *, uint32_t, uint32_t);
 102
100int gttwsi_intr(void *); 103int gttwsi_intr(void *);
101 104
102#endif /* _DEV_MARVELL_GTTSWI_VAR_H_ */ 105#endif /* _DEV_MARVELL_GTTSWI_VAR_H_ */

cvs diff -r1.11 -r1.12 src/sys/dev/marvell/gttwsi.c (expand / switch to unified diff)

--- src/sys/dev/marvell/gttwsi.c 2013/09/06 00:56:12 1.11
+++ src/sys/dev/marvell/gttwsi.c 2020/01/12 17:48:42 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gttwsi.c,v 1.11 2013/09/06 00:56:12 matt Exp $ */ 1/* $NetBSD: gttwsi.c,v 1.12 2020/01/12 17:48:42 thorpej Exp $ */
2/* 2/*
3 * Copyright (c) 2008 Eiji Kawauchi. 3 * Copyright (c) 2008 Eiji Kawauchi.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -56,47 +56,57 @@ @@ -56,47 +56,57 @@
56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 56 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 57 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 58 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 59 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
60 * OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THE POSSIBILITY OF SUCH DAMAGE.
61 */ 61 */
62//#define TWSI_DEBUG 62//#define TWSI_DEBUG
63 63
64/* 64/*
65 * Marvell Two-Wire Serial Interface (aka I2C) master driver 65 * Marvell Two-Wire Serial Interface (aka I2C) master driver
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: gttwsi.c,v 1.11 2013/09/06 00:56:12 matt Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: gttwsi.c,v 1.12 2020/01/12 17:48:42 thorpej Exp $");
70#include "locators.h" 70#include "locators.h"
71 71
72#include <sys/param.h> 72#include <sys/param.h>
73#include <sys/bus.h> 73#include <sys/bus.h>
74#include <sys/condvar.h> 74#include <sys/condvar.h>
75#include <sys/device.h> 75#include <sys/device.h>
76#include <sys/errno.h> 76#include <sys/errno.h>
77#include <sys/kernel.h> 77#include <sys/kernel.h>
78#include <sys/mutex.h> 78#include <sys/mutex.h>
79#include <sys/systm.h> 79#include <sys/systm.h>
80 80
81#include <machine/cpu.h> 81#include <machine/cpu.h>
82#include <machine/param.h> 82#include <machine/param.h>
83 83
84#include <dev/i2c/i2cvar.h> 84#include <dev/i2c/i2cvar.h>
85#include <dev/i2c/gttwsireg.h> 85#include <dev/i2c/gttwsireg.h>
86#include <dev/i2c/gttwsivar.h> 86#include <dev/i2c/gttwsivar.h>
87 87
88#include <dev/marvell/marvellvar.h> 88#include <dev/marvell/marvellvar.h>
89 89
 90static const bus_size_t marvell_twsi_regmap[GTTWSI_NREGS] = {
 91 [TWSI_SLAVEADDR] = TWSI_MARVELL_SLAVEADDR,
 92 [TWSI_EXTEND_SLAVEADDR] = TWSI_MARVELL_EXTEND_SLAVEADDR,
 93 [TWSI_DATA] = TWSI_MARVELL_DATA,
 94 [TWSI_CONTROL] = TWSI_MARVELL_CONTROL,
 95 [TWSI_STATUS] = TWSI_MARVELL_STATUS,
 96 [TWSI_BAUDRATE] = TWSI_MARVELL_BAUDRATE,
 97 [TWSI_SOFTRESET] = TWSI_MARVELL_SOFTRESET,
 98};
 99
90static int gttwsi_match(device_t, cfdata_t, void *); 100static int gttwsi_match(device_t, cfdata_t, void *);
91static void gttwsi_attach(device_t, device_t, void *); 101static void gttwsi_attach(device_t, device_t, void *);
92 102
93CFATTACH_DECL_NEW(gttwsi_gt, sizeof(struct gttwsi_softc), 103CFATTACH_DECL_NEW(gttwsi_gt, sizeof(struct gttwsi_softc),
94 gttwsi_match, gttwsi_attach, NULL, NULL); 104 gttwsi_match, gttwsi_attach, NULL, NULL);
95CFATTACH_DECL_NEW(gttwsi_mbus, sizeof(struct gttwsi_softc), 105CFATTACH_DECL_NEW(gttwsi_mbus, sizeof(struct gttwsi_softc),
96 gttwsi_match, gttwsi_attach, NULL, NULL); 106 gttwsi_match, gttwsi_attach, NULL, NULL);
97 107
98/* ARGSUSED */ 108/* ARGSUSED */
99static int 109static int
100gttwsi_match(device_t parent, cfdata_t match, void *aux) 110gttwsi_match(device_t parent, cfdata_t match, void *aux)
101{ 111{
102 struct marvell_attach_args *mva = aux; 112 struct marvell_attach_args *mva = aux;
@@ -114,20 +124,20 @@ gttwsi_match(device_t parent, cfdata_t m @@ -114,20 +124,20 @@ gttwsi_match(device_t parent, cfdata_t m
114/* ARGSUSED */ 124/* ARGSUSED */
115static void 125static void
116gttwsi_attach(device_t parent, device_t self, void *args) 126gttwsi_attach(device_t parent, device_t self, void *args)
117{ 127{
118 struct marvell_attach_args *mva = args; 128 struct marvell_attach_args *mva = args;
119 bus_space_handle_t ioh; 129 bus_space_handle_t ioh;
120 130
121 if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset, 131 if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset,
122 mva->mva_size, &ioh)) { 132 mva->mva_size, &ioh)) {
123 aprint_error(": cannot map registers\n"); 133 aprint_error(": cannot map registers\n");
124 return; 134 return;
125 } 135 }
126 136
127 gttwsi_attach_subr(self, mva->mva_iot, ioh); 137 gttwsi_attach_subr(self, mva->mva_iot, ioh, marvell_twsi_regmap);
128 138
129 marvell_intr_establish(mva->mva_irq, IPL_BIO, gttwsi_intr, 139 marvell_intr_establish(mva->mva_irq, IPL_BIO, gttwsi_intr,
130 device_private(self)); 140 device_private(self));
131 141
132 gttwsi_config_children(self); 142 gttwsi_config_children(self);
133} 143}