Fri Sep 22 04:00:58 2017 UTC ()
direct configure i2c devices


(macallan)
diff -r1.21 -r1.22 src/sys/arch/macppc/dev/cuda.c

cvs diff -r1.21 -r1.22 src/sys/arch/macppc/dev/cuda.c (expand / switch to unified diff)

--- src/sys/arch/macppc/dev/cuda.c 2016/02/14 19:54:20 1.21
+++ src/sys/arch/macppc/dev/cuda.c 2017/09/22 04:00:58 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cuda.c,v 1.21 2016/02/14 19:54:20 chs Exp $ */ 1/* $NetBSD: cuda.c,v 1.22 2017/09/22 04:00:58 macallan Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Michael Lorenz 4 * Copyright (c) 2006 Michael Lorenz
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,27 +17,27 @@ @@ -17,27 +17,27 @@
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 <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.21 2016/02/14 19:54:20 chs Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.22 2017/09/22 04:00:58 macallan Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/kernel.h> 34#include <sys/kernel.h>
35#include <sys/device.h> 35#include <sys/device.h>
36#include <sys/proc.h> 36#include <sys/proc.h>
37#include <sys/mutex.h> 37#include <sys/mutex.h>
38 38
39#include <sys/bus.h> 39#include <sys/bus.h>
40#include <machine/autoconf.h> 40#include <machine/autoconf.h>
41#include <machine/pio.h> 41#include <machine/pio.h>
42#include <dev/clock_subr.h> 42#include <dev/clock_subr.h>
43#include <dev/i2c/i2cvar.h> 43#include <dev/i2c/i2cvar.h>
@@ -165,26 +165,29 @@ cuda_match(device_t parent, struct cfdat @@ -165,26 +165,29 @@ cuda_match(device_t parent, struct cfdat
165 return 10; /* beat adb* at obio? */ 165 return 10; /* beat adb* at obio? */
166 } 166 }
167  167
168 return 0; 168 return 0;
169} 169}
170 170
171static void 171static void
172cuda_attach(device_t parent, device_t self, void *aux) 172cuda_attach(device_t parent, device_t self, void *aux)
173{ 173{
174 struct confargs *ca = aux; 174 struct confargs *ca = aux;
175 struct cuda_softc *sc = device_private(self); 175 struct cuda_softc *sc = device_private(self);
176 struct i2cbus_attach_args iba; 176 struct i2cbus_attach_args iba;
177 static struct cuda_attach_args caa; 177 static struct cuda_attach_args caa;
 178 prop_dictionary_t dict = device_properties(self);
 179 prop_dictionary_t dev;
 180 prop_array_t cfg;
178 int irq = ca->ca_intr[0]; 181 int irq = ca->ca_intr[0];
179 int node, i, child; 182 int node, i, child;
180 char name[32]; 183 char name[32];
181 184
182 sc->sc_dev = self; 185 sc->sc_dev = self;
183 node = of_getnode_byname(OF_parent(ca->ca_node), "extint-gpio1"); 186 node = of_getnode_byname(OF_parent(ca->ca_node), "extint-gpio1");
184 if (node) 187 if (node)
185 OF_getprop(node, "interrupts", &irq, 4); 188 OF_getprop(node, "interrupts", &irq, 4);
186 189
187 aprint_normal(" irq %d", irq); 190 aprint_normal(" irq %d", irq);
188 191
189 sc->sc_node = ca->ca_node; 192 sc->sc_node = ca->ca_node;
190 sc->sc_memt = ca->ca_tag; 193 sc->sc_memt = ca->ca_tag;
@@ -240,26 +243,50 @@ cuda_attach(device_t parent, device_t se @@ -240,26 +243,50 @@ cuda_attach(device_t parent, device_t se
240 sc->sc_todr.cookie = sc; 243 sc->sc_todr.cookie = sc;
241 todr_attach(&sc->sc_todr); 244 todr_attach(&sc->sc_todr);
242 }  245 }
243 child = OF_peer(child); 246 child = OF_peer(child);
244 } 247 }
245 248
246 caa.cookie = sc; 249 caa.cookie = sc;
247 caa.set_handler = cuda_set_handler; 250 caa.set_handler = cuda_set_handler;
248 caa.send = cuda_send; 251 caa.send = cuda_send;
249 caa.poll = cuda_poll; 252 caa.poll = cuda_poll;
250#if notyet 253#if notyet
251 config_found(self, &caa, cuda_print); 254 config_found(self, &caa, cuda_print);
252#endif 255#endif
 256 cfg = prop_array_create();
 257 prop_dictionary_set(dict, "i2c-child-devices", cfg);
 258 prop_object_release(cfg);
 259
 260 /* we don't have OF nodes for i2c devices so we have to make our own */
 261
 262 node = OF_finddevice("/valkyrie");
 263 if (node != -1) {
 264 dev = prop_dictionary_create();
 265 prop_dictionary_set_cstring(dev, "name", "videopll");
 266 prop_dictionary_set_uint32(dev, "addr", 0x50);
 267 prop_array_add(cfg, dev);
 268 prop_object_release(dev);
 269 }
 270
 271 node = OF_finddevice("/perch");
 272 if (node != -1) {
 273 dev = prop_dictionary_create();
 274 prop_dictionary_set_cstring(dev, "name", "sgsmix");
 275 prop_dictionary_set_uint32(dev, "addr", 0x8a);
 276 prop_array_add(cfg, dev);
 277 prop_object_release(dev);
 278 }
 279
253 mutex_init(&sc->sc_buslock, MUTEX_DEFAULT, IPL_NONE); 280 mutex_init(&sc->sc_buslock, MUTEX_DEFAULT, IPL_NONE);
254 memset(&iba, 0, sizeof(iba)); 281 memset(&iba, 0, sizeof(iba));
255 iba.iba_tag = &sc->sc_i2c; 282 iba.iba_tag = &sc->sc_i2c;
256 sc->sc_i2c.ic_cookie = sc; 283 sc->sc_i2c.ic_cookie = sc;
257 sc->sc_i2c.ic_acquire_bus = cuda_i2c_acquire_bus; 284 sc->sc_i2c.ic_acquire_bus = cuda_i2c_acquire_bus;
258 sc->sc_i2c.ic_release_bus = cuda_i2c_release_bus; 285 sc->sc_i2c.ic_release_bus = cuda_i2c_release_bus;
259 sc->sc_i2c.ic_send_start = NULL; 286 sc->sc_i2c.ic_send_start = NULL;
260 sc->sc_i2c.ic_send_stop = NULL; 287 sc->sc_i2c.ic_send_stop = NULL;
261 sc->sc_i2c.ic_initiate_xfer = NULL; 288 sc->sc_i2c.ic_initiate_xfer = NULL;
262 sc->sc_i2c.ic_read_byte = NULL; 289 sc->sc_i2c.ic_read_byte = NULL;
263 sc->sc_i2c.ic_write_byte = NULL; 290 sc->sc_i2c.ic_write_byte = NULL;
264 sc->sc_i2c.ic_exec = cuda_i2c_exec; 291 sc->sc_i2c.ic_exec = cuda_i2c_exec;
265 config_found_ia(self, "i2cbus", &iba, iicbus_print); 292 config_found_ia(self, "i2cbus", &iba, iicbus_print);