iicbus.c (157827) | iicbus.c (160372) |
---|---|
1/*- 2 * Copyright (c) 1998, 2001 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998, 2001 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iicbus.c 157827 2006-04-17 22:33:42Z jmg $"); | 28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iicbus.c 160372 2006-07-14 23:15:06Z imp $"); |
29 30/* 31 * Autoconfiguration and support routines for the Philips serial I2C bus 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/module.h> 38#include <sys/bus.h> 39 40 41#include <dev/iicbus/iiconf.h> 42#include <dev/iicbus/iicbus.h> 43 44#include "iicbus_if.h" 45 46#define DEVTOIICBUS(dev) ((struct iicbus_device*)device_get_ivars(dev)) 47 | 29 30/* 31 * Autoconfiguration and support routines for the Philips serial I2C bus 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/module.h> 38#include <sys/bus.h> 39 40 41#include <dev/iicbus/iiconf.h> 42#include <dev/iicbus/iicbus.h> 43 44#include "iicbus_if.h" 45 46#define DEVTOIICBUS(dev) ((struct iicbus_device*)device_get_ivars(dev)) 47 |
48static devclass_t iicbus_devclass; | 48devclass_t iicbus_devclass; |
49 50/* See comments below for why auto-scanning is a bad idea. */ 51#define SCAN_IICBUS 0 52 53/* 54 * Device methods 55 */ 56static int iicbus_probe(device_t); --- 10 unchanged lines hidden (view full) --- 67 /* bus interface */ 68 DEVMETHOD(bus_add_child, iicbus_add_child), 69 DEVMETHOD(bus_driver_added, bus_generic_driver_added), 70 DEVMETHOD(bus_print_child, bus_generic_print_child), 71 72 { 0, 0 } 73}; 74 | 49 50/* See comments below for why auto-scanning is a bad idea. */ 51#define SCAN_IICBUS 0 52 53/* 54 * Device methods 55 */ 56static int iicbus_probe(device_t); --- 10 unchanged lines hidden (view full) --- 67 /* bus interface */ 68 DEVMETHOD(bus_add_child, iicbus_add_child), 69 DEVMETHOD(bus_driver_added, bus_generic_driver_added), 70 DEVMETHOD(bus_print_child, bus_generic_print_child), 71 72 { 0, 0 } 73}; 74 |
75static driver_t iicbus_driver = { | 75driver_t iicbus_driver = { |
76 "iicbus", 77 iicbus_methods, 78 sizeof(struct iicbus_softc), 79}; 80 81static int 82iicbus_probe(device_t dev) 83{ | 76 "iicbus", 77 iicbus_methods, 78 sizeof(struct iicbus_softc), 79}; 80 81static int 82iicbus_probe(device_t dev) 83{ |
84 device_set_desc(dev, "Philips I2C bus"); | |
85 | 84 |
85 device_set_desc(dev, "Philips I2C bus"); |
|
86 return (0); 87} 88 89#if SCAN_IICBUS 90static int 91iic_probe_device(device_t dev, u_char addr) 92{ 93 int count; --- 40 unchanged lines hidden (view full) --- 134 for (addr = 16; addr < 240; addr++) { 135 if (iic_probe_device(dev, (u_char)addr)) { 136 printf(" <%x>", addr); 137 } 138 } 139 printf("\n"); 140#endif 141 | 86 return (0); 87} 88 89#if SCAN_IICBUS 90static int 91iic_probe_device(device_t dev, u_char addr) 92{ 93 int count; --- 40 unchanged lines hidden (view full) --- 134 for (addr = 16; addr < 240; addr++) { 135 if (iic_probe_device(dev, (u_char)addr)) { 136 printf(" <%x>", addr); 137 } 138 } 139 printf("\n"); 140#endif 141 |
142 /* attach any known device */ | |
143 device_add_child(dev, "ic", -1); | 142 device_add_child(dev, "ic", -1); |
144 device_add_child(dev, "iic", -1); | |
145 device_add_child(dev, "iicsmb", -1); | 143 device_add_child(dev, "iicsmb", -1); |
146 | 144#if 0 145 /* attach any known device */ 146 device_add_child(dev, "iic", -1); 147#endif |
147 bus_generic_attach(dev); | 148 bus_generic_attach(dev); |
148 | |
149 return (0); 150} 151 152static int 153iicbus_detach(device_t dev) 154{ | 149 return (0); 150} 151 152static int 153iicbus_detach(device_t dev) 154{ |
155 |
|
155 iicbus_reset(dev, IIC_FASTEST, 0, NULL); | 156 iicbus_reset(dev, IIC_FASTEST, 0, NULL); |
156 | |
157 bus_generic_detach(dev); | 157 bus_generic_detach(dev); |
158 | |
159 return (0); 160} 161 162static int 163iicbus_add_child(device_t dev, int order, const char *name, int unit) 164{ | 158 return (0); 159} 160 161static int 162iicbus_add_child(device_t dev, int order, const char *name, int unit) 163{ |
165 device_add_child_ordered(dev, order, name, unit); | |
166 | 164 |
165 device_add_child_ordered(dev, order, name, unit); |
|
167 bus_generic_attach(dev); | 166 bus_generic_attach(dev); |
168 | |
169 return (0); 170} 171 172int 173iicbus_generic_intr(device_t dev, int event, char *buf) 174{ | 167 return (0); 168} 169 170int 171iicbus_generic_intr(device_t dev, int event, char *buf) 172{ |
173 |
|
175 return (0); 176} 177 178int 179iicbus_null_callback(device_t dev, int index, caddr_t data) 180{ | 174 return (0); 175} 176 177int 178iicbus_null_callback(device_t dev, int index, caddr_t data) 179{ |
180 |
|
181 return (0); 182} 183 184int 185iicbus_null_repeated_start(device_t dev, u_char addr) 186{ | 181 return (0); 182} 183 184int 185iicbus_null_repeated_start(device_t dev, u_char addr) 186{ |
187 |
|
187 return (IIC_ENOTSUPP); 188} 189 190DRIVER_MODULE(iicbus, envctrl, iicbus_driver, iicbus_devclass, 0, 0); 191DRIVER_MODULE(iicbus, iicbb, iicbus_driver, iicbus_devclass, 0, 0); 192MODULE_VERSION(iicbus, IICBUS_MODVER); | 188 return (IIC_ENOTSUPP); 189} 190 191DRIVER_MODULE(iicbus, envctrl, iicbus_driver, iicbus_devclass, 0, 0); 192DRIVER_MODULE(iicbus, iicbb, iicbus_driver, iicbus_devclass, 0, 0); 193MODULE_VERSION(iicbus, IICBUS_MODVER); |