ofw_iicbus.c (274641) | ofw_iicbus.c (282674) |
---|---|
1/*- 2 * Copyright (c) 2009, Nathan Whitehorn <nwhitehorn@FreeBSD.org> 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 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009, Nathan Whitehorn <nwhitehorn@FreeBSD.org> 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 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_iicbus.c 274641 2014-11-18 01:54:31Z ian $"); | 28__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_iicbus.c 282674 2015-05-09 03:05:44Z loos $"); |
29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/kernel.h> 33#include <sys/libkern.h> 34#include <sys/lock.h> 35#include <sys/module.h> 36#include <sys/mutex.h> --- 8 unchanged lines hidden (view full) --- 45 46/* Methods */ 47static device_probe_t ofw_iicbus_probe; 48static device_attach_t ofw_iicbus_attach; 49static device_t ofw_iicbus_add_child(device_t dev, u_int order, 50 const char *name, int unit); 51static const struct ofw_bus_devinfo *ofw_iicbus_get_devinfo(device_t bus, 52 device_t dev); | 29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/kernel.h> 33#include <sys/libkern.h> 34#include <sys/lock.h> 35#include <sys/module.h> 36#include <sys/mutex.h> --- 8 unchanged lines hidden (view full) --- 45 46/* Methods */ 47static device_probe_t ofw_iicbus_probe; 48static device_attach_t ofw_iicbus_attach; 49static device_t ofw_iicbus_add_child(device_t dev, u_int order, 50 const char *name, int unit); 51static const struct ofw_bus_devinfo *ofw_iicbus_get_devinfo(device_t bus, 52 device_t dev); |
53static struct resource_list *ofw_iicbus_get_resource_list(device_t bus, 54 device_t child); |
|
53 54static device_method_t ofw_iicbus_methods[] = { 55 /* Device interface */ 56 DEVMETHOD(device_probe, ofw_iicbus_probe), 57 DEVMETHOD(device_attach, ofw_iicbus_attach), 58 59 /* Bus interface */ | 55 56static device_method_t ofw_iicbus_methods[] = { 57 /* Device interface */ 58 DEVMETHOD(device_probe, ofw_iicbus_probe), 59 DEVMETHOD(device_attach, ofw_iicbus_attach), 60 61 /* Bus interface */ |
62 DEVMETHOD(bus_get_resource_list, ofw_iicbus_get_resource_list), |
|
60 DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), 61 DEVMETHOD(bus_add_child, ofw_iicbus_add_child), 62 63 /* ofw_bus interface */ 64 DEVMETHOD(ofw_bus_get_devinfo, ofw_iicbus_get_devinfo), 65 DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), 66 DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), 67 DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), 68 DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), 69 DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), 70 71 DEVMETHOD_END 72}; 73 74struct ofw_iicbus_devinfo { | 63 DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), 64 DEVMETHOD(bus_add_child, ofw_iicbus_add_child), 65 66 /* ofw_bus interface */ 67 DEVMETHOD(ofw_bus_get_devinfo, ofw_iicbus_get_devinfo), 68 DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), 69 DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), 70 DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), 71 DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), 72 DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), 73 74 DEVMETHOD_END 75}; 76 77struct ofw_iicbus_devinfo { |
75 struct iicbus_ivar opd_dinfo; | 78 struct iicbus_ivar opd_dinfo; /* Must be the first. */ |
76 struct ofw_bus_devinfo opd_obdinfo; 77}; 78 79static devclass_t ofwiicbus_devclass; 80 81DEFINE_CLASS_1(iicbus, ofw_iicbus_driver, ofw_iicbus_methods, 82 sizeof(struct iicbus_softc), iicbus_driver); 83DRIVER_MODULE(ofw_iicbus, iicbb, ofw_iicbus_driver, ofwiicbus_devclass, 0, 0); --- 64 unchanged lines hidden (view full) --- 148 if (dinfo == NULL) 149 continue; 150 dinfo->opd_dinfo.addr = paddr; 151 if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != 152 0) { 153 free(dinfo, M_DEVBUF); 154 continue; 155 } | 79 struct ofw_bus_devinfo opd_obdinfo; 80}; 81 82static devclass_t ofwiicbus_devclass; 83 84DEFINE_CLASS_1(iicbus, ofw_iicbus_driver, ofw_iicbus_methods, 85 sizeof(struct iicbus_softc), iicbus_driver); 86DRIVER_MODULE(ofw_iicbus, iicbb, ofw_iicbus_driver, ofwiicbus_devclass, 0, 0); --- 64 unchanged lines hidden (view full) --- 151 if (dinfo == NULL) 152 continue; 153 dinfo->opd_dinfo.addr = paddr; 154 if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != 155 0) { 156 free(dinfo, M_DEVBUF); 157 continue; 158 } |
159 |
|
156 childdev = device_add_child(dev, NULL, -1); | 160 childdev = device_add_child(dev, NULL, -1); |
161 resource_list_init(&dinfo->opd_dinfo.rl); 162 ofw_bus_intr_to_rl(childdev, child, &dinfo->opd_dinfo.rl); |
|
157 device_set_ivars(childdev, dinfo); 158 } 159 160 return (bus_generic_attach(dev)); 161} 162 163static device_t 164ofw_iicbus_add_child(device_t dev, u_int order, const char *name, int unit) --- 29 unchanged lines hidden (view full) --- 194static const struct ofw_bus_devinfo * 195ofw_iicbus_get_devinfo(device_t bus, device_t dev) 196{ 197 struct ofw_iicbus_devinfo *dinfo; 198 199 dinfo = device_get_ivars(dev); 200 return (&dinfo->opd_obdinfo); 201} | 163 device_set_ivars(childdev, dinfo); 164 } 165 166 return (bus_generic_attach(dev)); 167} 168 169static device_t 170ofw_iicbus_add_child(device_t dev, u_int order, const char *name, int unit) --- 29 unchanged lines hidden (view full) --- 200static const struct ofw_bus_devinfo * 201ofw_iicbus_get_devinfo(device_t bus, device_t dev) 202{ 203 struct ofw_iicbus_devinfo *dinfo; 204 205 dinfo = device_get_ivars(dev); 206 return (&dinfo->opd_obdinfo); 207} |
208 209static struct resource_list * 210ofw_iicbus_get_resource_list(device_t bus __unused, device_t child) 211{ 212 struct ofw_iicbus_devinfo *devi; 213 214 devi = device_get_ivars(child); 215 return (&devi->opd_dinfo.rl); 216} |
|