twl4030.c revision 1.3 1 1.3 jmcneill /* $NetBSD: twl4030.c,v 1.3 2019/11/03 09:34:09 jmcneill Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2019 Jared McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 jmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 jmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 jmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 jmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 jmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 jmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 jmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 jmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 jmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 jmcneill * POSSIBILITY OF SUCH DAMAGE.
27 1.1 jmcneill */
28 1.1 jmcneill
29 1.3 jmcneill #include "opt_fdt.h"
30 1.3 jmcneill
31 1.1 jmcneill #include <sys/cdefs.h>
32 1.3 jmcneill __KERNEL_RCSID(0, "$NetBSD: twl4030.c,v 1.3 2019/11/03 09:34:09 jmcneill Exp $");
33 1.1 jmcneill
34 1.1 jmcneill #include <sys/param.h>
35 1.1 jmcneill #include <sys/systm.h>
36 1.1 jmcneill #include <sys/kernel.h>
37 1.1 jmcneill #include <sys/device.h>
38 1.1 jmcneill #include <sys/conf.h>
39 1.1 jmcneill #include <sys/bus.h>
40 1.1 jmcneill #include <sys/kmem.h>
41 1.1 jmcneill #include <sys/gpio.h>
42 1.1 jmcneill
43 1.1 jmcneill #include <dev/i2c/i2cvar.h>
44 1.1 jmcneill
45 1.1 jmcneill #include <dev/fdt/fdtvar.h>
46 1.1 jmcneill
47 1.1 jmcneill #define TWL_PIN_COUNT 16
48 1.1 jmcneill
49 1.1 jmcneill /* TWL4030 is a multi-function IC. Each module is at a separate I2C address */
50 1.1 jmcneill #define ADDR_USB 0x00
51 1.1 jmcneill #define ADDR_INT 0x01
52 1.1 jmcneill #define ADDR_AUX 0x02
53 1.1 jmcneill #define ADDR_POWER 0x03
54 1.1 jmcneill
55 1.2 jmcneill /* INTBR registers */
56 1.2 jmcneill #define IDCODE_7_0 0x85
57 1.2 jmcneill #define IDCODE_15_8 0x86
58 1.2 jmcneill #define IDCODE_23_16 0x87
59 1.2 jmcneill #define IDCODE_31_24 0x88
60 1.2 jmcneill
61 1.1 jmcneill /* GPIO registers */
62 1.1 jmcneill #define GPIOBASE 0x98
63 1.1 jmcneill #define GPIODATAIN(pin) (GPIOBASE + 0x00 + (pin) / 8)
64 1.1 jmcneill #define GPIODATADIR(pin) (GPIOBASE + 0x03 + (pin) / 8)
65 1.1 jmcneill #define CLEARGPIODATAOUT(pin) (GPIOBASE + 0x09 + (pin) / 8)
66 1.1 jmcneill #define SETGPIODATAOUT(pin) (GPIOBASE + 0x0c + (pin) / 8)
67 1.1 jmcneill #define PIN_BIT(pin) __BIT((pin) % 8)
68 1.1 jmcneill #define GPIOPUPDCTR(pin) (GPIOBASE + 0x13 + (n) / 4)
69 1.1 jmcneill #define PUPD_BITS(pin) __BITS((pin) % 4 + 1, (pin) % 4)
70 1.1 jmcneill
71 1.2 jmcneill /* POWER registers */
72 1.2 jmcneill #define SECONDS_REG 0x1c
73 1.2 jmcneill #define MINUTES_REG 0x1d
74 1.2 jmcneill #define HOURS_REG 0x1e
75 1.2 jmcneill #define DAYS_REG 0x1f
76 1.2 jmcneill #define MONTHS_REG 0x20
77 1.2 jmcneill #define YEARS_REG 0x21
78 1.2 jmcneill #define WEEKS_REG 0x22
79 1.2 jmcneill #define RTC_CTRL_REG 0x29
80 1.2 jmcneill #define GET_TIME __BIT(6)
81 1.2 jmcneill #define STOP_RTC __BIT(0)
82 1.2 jmcneill
83 1.1 jmcneill struct twl_softc {
84 1.1 jmcneill device_t sc_dev;
85 1.1 jmcneill i2c_tag_t sc_i2c;
86 1.1 jmcneill i2c_addr_t sc_addr;
87 1.1 jmcneill int sc_phandle;
88 1.1 jmcneill
89 1.1 jmcneill int sc_npins;
90 1.2 jmcneill
91 1.2 jmcneill struct todr_chip_handle sc_todr;
92 1.1 jmcneill };
93 1.1 jmcneill
94 1.1 jmcneill struct twl_pin {
95 1.1 jmcneill struct twl_softc *pin_sc;
96 1.1 jmcneill int pin_num;
97 1.1 jmcneill int pin_flags;
98 1.1 jmcneill bool pin_actlo;
99 1.1 jmcneill };
100 1.1 jmcneill
101 1.1 jmcneill static const struct device_compatible_entry compat_data[] = {
102 1.1 jmcneill { "ti,twl4030", 0 },
103 1.1 jmcneill { NULL, 0 }
104 1.1 jmcneill };
105 1.1 jmcneill
106 1.3 jmcneill #ifdef FDT
107 1.2 jmcneill static const char * const rtc_compatible[] = { "ti,twl4030-rtc", NULL };
108 1.1 jmcneill static const char * const gpio_compatible[] = { "ti,twl4030-gpio", NULL };
109 1.3 jmcneill #endif
110 1.1 jmcneill
111 1.1 jmcneill static uint8_t
112 1.1 jmcneill twl_read(struct twl_softc *sc, uint8_t mod, uint8_t reg, int flags)
113 1.1 jmcneill {
114 1.1 jmcneill uint8_t val = 0;
115 1.1 jmcneill int error;
116 1.1 jmcneill
117 1.1 jmcneill error = iic_exec(sc->sc_i2c, I2C_OP_READ_WITH_STOP, sc->sc_addr + mod,
118 1.1 jmcneill ®, 1, &val, 1, flags);
119 1.1 jmcneill if (error != 0)
120 1.1 jmcneill aprint_error_dev(sc->sc_dev, "error reading reg %#x: %d\n", reg, error);
121 1.1 jmcneill
122 1.1 jmcneill return val;
123 1.1 jmcneill }
124 1.1 jmcneill
125 1.1 jmcneill static void
126 1.1 jmcneill twl_write(struct twl_softc *sc, uint8_t mod, uint8_t reg, uint8_t val, int flags)
127 1.1 jmcneill {
128 1.1 jmcneill uint8_t buf[2];
129 1.1 jmcneill int error;
130 1.1 jmcneill
131 1.1 jmcneill buf[0] = reg;
132 1.1 jmcneill buf[1] = val;
133 1.1 jmcneill
134 1.1 jmcneill error = iic_exec(sc->sc_i2c, I2C_OP_WRITE_WITH_STOP, sc->sc_addr + mod,
135 1.1 jmcneill NULL, 0, buf, 2, flags);
136 1.1 jmcneill if (error != 0)
137 1.1 jmcneill aprint_error_dev(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
138 1.1 jmcneill }
139 1.1 jmcneill
140 1.1 jmcneill #define I2C_LOCK(sc) iic_acquire_bus((sc)->sc_i2c, I2C_F_POLL)
141 1.1 jmcneill #define I2C_UNLOCK(sc) iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
142 1.1 jmcneill
143 1.1 jmcneill #define INT_READ(sc, reg) twl_read((sc), ADDR_INT, (reg), I2C_F_POLL)
144 1.1 jmcneill #define INT_WRITE(sc, reg, val) twl_write((sc), ADDR_INT, (reg), (val), I2C_F_POLL)
145 1.1 jmcneill
146 1.2 jmcneill #define POWER_READ(sc, reg) twl_read((sc), ADDR_POWER, (reg), I2C_F_POLL)
147 1.2 jmcneill #define POWER_WRITE(sc, reg, val) twl_write((sc), ADDR_POWER, (reg), (val), I2C_F_POLL)
148 1.2 jmcneill
149 1.2 jmcneill static void
150 1.2 jmcneill twl_rtc_enable(struct twl_softc *sc, bool onoff)
151 1.2 jmcneill {
152 1.2 jmcneill uint8_t rtc_ctrl;
153 1.2 jmcneill
154 1.2 jmcneill rtc_ctrl = POWER_READ(sc, RTC_CTRL_REG);
155 1.2 jmcneill if (onoff)
156 1.2 jmcneill rtc_ctrl |= STOP_RTC; /* 1: RTC is running */
157 1.2 jmcneill else
158 1.2 jmcneill rtc_ctrl &= ~STOP_RTC; /* 0: RTC is frozen */
159 1.2 jmcneill POWER_WRITE(sc, RTC_CTRL_REG, rtc_ctrl);
160 1.2 jmcneill }
161 1.2 jmcneill
162 1.2 jmcneill static int
163 1.2 jmcneill twl_rtc_gettime(todr_chip_handle_t tch, struct clock_ymdhms *dt)
164 1.2 jmcneill {
165 1.2 jmcneill struct twl_softc *sc = tch->cookie;
166 1.2 jmcneill uint8_t seconds_reg, minutes_reg, hours_reg,
167 1.2 jmcneill days_reg, months_reg, years_reg, weeks_reg;
168 1.2 jmcneill
169 1.2 jmcneill iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
170 1.2 jmcneill seconds_reg = POWER_READ(sc, SECONDS_REG);
171 1.2 jmcneill minutes_reg = POWER_READ(sc, MINUTES_REG);
172 1.2 jmcneill hours_reg = POWER_READ(sc, HOURS_REG);
173 1.2 jmcneill days_reg = POWER_READ(sc, DAYS_REG);
174 1.2 jmcneill months_reg = POWER_READ(sc, MONTHS_REG);
175 1.2 jmcneill years_reg = POWER_READ(sc, YEARS_REG);
176 1.2 jmcneill weeks_reg = POWER_READ(sc, WEEKS_REG);
177 1.2 jmcneill iic_release_bus(sc->sc_i2c, I2C_F_POLL);
178 1.2 jmcneill
179 1.2 jmcneill dt->dt_sec = bcdtobin(seconds_reg);
180 1.2 jmcneill dt->dt_min = bcdtobin(minutes_reg);
181 1.2 jmcneill dt->dt_hour = bcdtobin(hours_reg);
182 1.2 jmcneill dt->dt_day = bcdtobin(days_reg);
183 1.2 jmcneill dt->dt_mon = bcdtobin(months_reg);
184 1.2 jmcneill dt->dt_year = bcdtobin(years_reg) + 2000;
185 1.2 jmcneill dt->dt_wday = bcdtobin(weeks_reg);
186 1.2 jmcneill
187 1.2 jmcneill return 0;
188 1.2 jmcneill }
189 1.2 jmcneill
190 1.2 jmcneill static int
191 1.2 jmcneill twl_rtc_settime(todr_chip_handle_t tch, struct clock_ymdhms *dt)
192 1.2 jmcneill {
193 1.2 jmcneill struct twl_softc *sc = tch->cookie;
194 1.2 jmcneill
195 1.2 jmcneill iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
196 1.2 jmcneill twl_rtc_enable(sc, false);
197 1.2 jmcneill POWER_WRITE(sc, SECONDS_REG, bintobcd(dt->dt_sec));
198 1.2 jmcneill POWER_WRITE(sc, MINUTES_REG, bintobcd(dt->dt_min));
199 1.2 jmcneill POWER_WRITE(sc, HOURS_REG, bintobcd(dt->dt_hour));
200 1.2 jmcneill POWER_WRITE(sc, DAYS_REG, bintobcd(dt->dt_day));
201 1.2 jmcneill POWER_WRITE(sc, MONTHS_REG, bintobcd(dt->dt_mon));
202 1.2 jmcneill POWER_WRITE(sc, YEARS_REG, bintobcd(dt->dt_year % 100));
203 1.2 jmcneill POWER_WRITE(sc, WEEKS_REG, bintobcd(dt->dt_wday));
204 1.2 jmcneill twl_rtc_enable(sc, true);
205 1.2 jmcneill iic_release_bus(sc->sc_i2c, I2C_F_POLL);
206 1.2 jmcneill
207 1.2 jmcneill return 0;
208 1.2 jmcneill }
209 1.2 jmcneill
210 1.3 jmcneill #ifdef FDT
211 1.1 jmcneill static int
212 1.1 jmcneill twl_gpio_config(struct twl_softc *sc, int pin, int flags)
213 1.1 jmcneill {
214 1.1 jmcneill uint8_t dir;
215 1.1 jmcneill
216 1.1 jmcneill KASSERT(pin >= 0 && pin < sc->sc_npins);
217 1.1 jmcneill
218 1.1 jmcneill dir = INT_READ(sc, GPIODATADIR(pin));
219 1.1 jmcneill
220 1.1 jmcneill switch (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
221 1.1 jmcneill case GPIO_PIN_INPUT:
222 1.1 jmcneill dir &= ~PIN_BIT(pin);
223 1.1 jmcneill break;
224 1.1 jmcneill case GPIO_PIN_OUTPUT:
225 1.1 jmcneill dir |= PIN_BIT(pin);
226 1.1 jmcneill break;
227 1.1 jmcneill default:
228 1.1 jmcneill return EINVAL;
229 1.1 jmcneill }
230 1.1 jmcneill
231 1.1 jmcneill INT_WRITE(sc, GPIODATADIR(pin), dir);
232 1.1 jmcneill
233 1.1 jmcneill return 0;
234 1.1 jmcneill }
235 1.1 jmcneill
236 1.1 jmcneill static void *
237 1.1 jmcneill twl_gpio_acquire(device_t dev, const void *data, size_t len, int flags)
238 1.1 jmcneill {
239 1.1 jmcneill struct twl_softc * const sc = device_private(dev);
240 1.1 jmcneill struct twl_pin *gpin;
241 1.1 jmcneill const u_int *gpio = data;
242 1.1 jmcneill int error;
243 1.1 jmcneill
244 1.1 jmcneill if (len != 12)
245 1.1 jmcneill return NULL;
246 1.1 jmcneill
247 1.1 jmcneill const uint8_t pin = be32toh(gpio[1]) & 0xff;
248 1.1 jmcneill const bool actlo = (be32toh(gpio[2]) & __BIT(0)) != 0;
249 1.1 jmcneill
250 1.1 jmcneill if (pin >= sc->sc_npins)
251 1.1 jmcneill return NULL;
252 1.1 jmcneill
253 1.1 jmcneill I2C_LOCK(sc);
254 1.1 jmcneill error = twl_gpio_config(sc, pin, flags);
255 1.1 jmcneill I2C_UNLOCK(sc);
256 1.1 jmcneill
257 1.1 jmcneill if (error != 0) {
258 1.1 jmcneill device_printf(dev, "bad pin %d config %#x\n", pin, flags);
259 1.1 jmcneill return NULL;
260 1.1 jmcneill }
261 1.1 jmcneill
262 1.1 jmcneill gpin = kmem_zalloc(sizeof(*gpin), KM_SLEEP);
263 1.1 jmcneill gpin->pin_sc = sc;
264 1.1 jmcneill gpin->pin_num = pin;
265 1.1 jmcneill gpin->pin_flags = flags;
266 1.1 jmcneill gpin->pin_actlo = actlo;
267 1.1 jmcneill
268 1.1 jmcneill return gpin;
269 1.1 jmcneill }
270 1.1 jmcneill
271 1.1 jmcneill static void
272 1.1 jmcneill twl_gpio_release(device_t dev, void *priv)
273 1.1 jmcneill {
274 1.1 jmcneill struct twl_softc * const sc = device_private(dev);
275 1.1 jmcneill struct twl_pin *gpin = priv;
276 1.1 jmcneill
277 1.1 jmcneill I2C_LOCK(sc);
278 1.1 jmcneill twl_gpio_config(sc, gpin->pin_num, GPIO_PIN_INPUT);
279 1.1 jmcneill I2C_UNLOCK(sc);
280 1.1 jmcneill
281 1.1 jmcneill kmem_free(gpin, sizeof(*gpin));
282 1.1 jmcneill }
283 1.1 jmcneill
284 1.1 jmcneill static int
285 1.1 jmcneill twl_gpio_read(device_t dev, void *priv, bool raw)
286 1.1 jmcneill {
287 1.1 jmcneill struct twl_softc * const sc = device_private(dev);
288 1.1 jmcneill struct twl_pin *gpin = priv;
289 1.1 jmcneill uint8_t gpio;
290 1.1 jmcneill int val;
291 1.1 jmcneill
292 1.1 jmcneill I2C_LOCK(sc);
293 1.1 jmcneill gpio = INT_READ(sc, GPIODATAIN(gpin->pin_num));
294 1.1 jmcneill I2C_UNLOCK(sc);
295 1.1 jmcneill
296 1.1 jmcneill val = __SHIFTOUT(gpio, PIN_BIT(gpin->pin_num));
297 1.1 jmcneill if (!raw && gpin->pin_actlo)
298 1.1 jmcneill val = !val;
299 1.1 jmcneill
300 1.1 jmcneill return val;
301 1.1 jmcneill }
302 1.1 jmcneill
303 1.1 jmcneill static void
304 1.1 jmcneill twl_gpio_write(device_t dev, void *priv, int val, bool raw)
305 1.1 jmcneill {
306 1.1 jmcneill struct twl_softc * const sc = device_private(dev);
307 1.1 jmcneill struct twl_pin *gpin = priv;
308 1.1 jmcneill
309 1.1 jmcneill if (!raw && gpin->pin_actlo)
310 1.1 jmcneill val = !val;
311 1.1 jmcneill
312 1.1 jmcneill I2C_LOCK(sc);
313 1.1 jmcneill if (val)
314 1.1 jmcneill INT_WRITE(sc, SETGPIODATAOUT(gpin->pin_num), PIN_BIT(gpin->pin_num));
315 1.1 jmcneill else
316 1.1 jmcneill INT_WRITE(sc, CLEARGPIODATAOUT(gpin->pin_num), PIN_BIT(gpin->pin_num));
317 1.1 jmcneill I2C_UNLOCK(sc);
318 1.1 jmcneill }
319 1.1 jmcneill
320 1.1 jmcneill static struct fdtbus_gpio_controller_func twl_gpio_funcs = {
321 1.1 jmcneill .acquire = twl_gpio_acquire,
322 1.1 jmcneill .release = twl_gpio_release,
323 1.1 jmcneill .read = twl_gpio_read,
324 1.1 jmcneill .write = twl_gpio_write,
325 1.1 jmcneill };
326 1.3 jmcneill #endif /* !FDT */
327 1.1 jmcneill
328 1.1 jmcneill static void
329 1.2 jmcneill twl_rtc_attach(struct twl_softc *sc, const int phandle)
330 1.2 jmcneill {
331 1.2 jmcneill iic_acquire_bus(sc->sc_i2c, I2C_F_POLL);
332 1.2 jmcneill twl_rtc_enable(sc, true);
333 1.2 jmcneill iic_release_bus(sc->sc_i2c, I2C_F_POLL);
334 1.2 jmcneill
335 1.2 jmcneill sc->sc_todr.todr_gettime_ymdhms = twl_rtc_gettime;
336 1.2 jmcneill sc->sc_todr.todr_settime_ymdhms = twl_rtc_settime;
337 1.2 jmcneill sc->sc_todr.cookie = sc;
338 1.3 jmcneill #ifdef FDT
339 1.2 jmcneill fdtbus_todr_attach(sc->sc_dev, phandle, &sc->sc_todr);
340 1.3 jmcneill #else
341 1.3 jmcneill todr_attach(&sc->sc_todr);
342 1.3 jmcneill #endif
343 1.2 jmcneill }
344 1.2 jmcneill
345 1.2 jmcneill static void
346 1.1 jmcneill twl_gpio_attach(struct twl_softc *sc, const int phandle)
347 1.1 jmcneill {
348 1.3 jmcneill #ifdef FDT
349 1.1 jmcneill fdtbus_register_gpio_controller(sc->sc_dev, phandle, &twl_gpio_funcs);
350 1.3 jmcneill #endif
351 1.1 jmcneill }
352 1.1 jmcneill
353 1.1 jmcneill static int
354 1.1 jmcneill twl_match(device_t parent, cfdata_t match, void *aux)
355 1.1 jmcneill {
356 1.1 jmcneill struct i2c_attach_args *ia = aux;
357 1.1 jmcneill int match_result;
358 1.1 jmcneill
359 1.1 jmcneill if (iic_use_direct_match(ia, match, compat_data, &match_result))
360 1.1 jmcneill return match_result;
361 1.1 jmcneill
362 1.3 jmcneill if (ia->ia_addr == 0x48)
363 1.3 jmcneill return I2C_MATCH_ADDRESS_ONLY;
364 1.3 jmcneill
365 1.1 jmcneill return 0;
366 1.1 jmcneill }
367 1.1 jmcneill
368 1.1 jmcneill static void
369 1.1 jmcneill twl_attach(device_t parent, device_t self, void *aux)
370 1.1 jmcneill {
371 1.1 jmcneill struct twl_softc * const sc = device_private(self);
372 1.1 jmcneill struct i2c_attach_args *ia = aux;
373 1.2 jmcneill uint32_t idcode;
374 1.1 jmcneill
375 1.1 jmcneill sc->sc_dev = self;
376 1.1 jmcneill sc->sc_i2c = ia->ia_tag;
377 1.1 jmcneill sc->sc_addr = ia->ia_addr;
378 1.1 jmcneill sc->sc_phandle = ia->ia_cookie;
379 1.1 jmcneill sc->sc_npins = TWL_PIN_COUNT;
380 1.1 jmcneill
381 1.1 jmcneill aprint_naive("\n");
382 1.1 jmcneill aprint_normal(": TWL4030");
383 1.1 jmcneill
384 1.3 jmcneill #ifdef FDT
385 1.3 jmcneill for (int child = OF_child(sc->sc_phandle); child; child = OF_peer(child)) {
386 1.1 jmcneill if (of_match_compatible(child, gpio_compatible)) {
387 1.1 jmcneill aprint_normal(", GPIO");
388 1.1 jmcneill twl_gpio_attach(sc, child);
389 1.2 jmcneill } else if (of_match_compatible(child, rtc_compatible)) {
390 1.2 jmcneill aprint_normal(", RTC");
391 1.2 jmcneill twl_rtc_attach(sc, child);
392 1.1 jmcneill }
393 1.1 jmcneill }
394 1.3 jmcneill #else
395 1.3 jmcneill aprint_normal("\n");
396 1.3 jmcneill twl_gpio_attach(sc, -1);
397 1.3 jmcneill twl_rtc_attach(sc, -1);
398 1.3 jmcneill #endif
399 1.2 jmcneill
400 1.2 jmcneill I2C_LOCK(sc);
401 1.2 jmcneill idcode = INT_READ(sc, IDCODE_7_0);
402 1.2 jmcneill idcode |= (uint32_t)INT_READ(sc, IDCODE_15_8) << 8;
403 1.2 jmcneill idcode |= (uint32_t)INT_READ(sc, IDCODE_23_16) << 16;
404 1.2 jmcneill idcode |= (uint32_t)INT_READ(sc, IDCODE_31_24) << 24;
405 1.2 jmcneill I2C_UNLOCK(sc);
406 1.2 jmcneill
407 1.2 jmcneill aprint_normal(", IDCODE 0x%08x\n", idcode);
408 1.1 jmcneill }
409 1.1 jmcneill
410 1.1 jmcneill CFATTACH_DECL_NEW(twl, sizeof(struct twl_softc),
411 1.1 jmcneill twl_match, twl_attach, NULL, NULL);
412