pcf_ebus.c (167753) | pcf_ebus.c (181303) |
---|---|
1/*- 2 * Copyright (c) 2004 Marius Strobl, Joerg Wunsch 3 * 4 * derived from sys/i386/isa/pcf.c which is: 5 * 6 * Copyright (c) 1998 Nicolas Souchu, Marc Bouget 7 * All rights reserved. 8 * --- 14 unchanged lines hidden (view full) --- 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004 Marius Strobl, Joerg Wunsch 3 * 4 * derived from sys/i386/isa/pcf.c which is: 5 * 6 * Copyright (c) 1998 Nicolas Souchu, Marc Bouget 7 * All rights reserved. 8 * --- 14 unchanged lines hidden (view full) --- 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/pcf/pcf_ebus.c 167753 2007-03-21 03:38:37Z nyan $"); | 31__FBSDID("$FreeBSD: head/sys/dev/pcf/pcf_ebus.c 181303 2008-08-04 20:46:15Z jhb $"); |
32 33/* 34 * Device specific driver for the EBus i2c devices found on some sun4u 35 * systems. On systems not having a boot-bus controller the i2c devices 36 * are PCF8584. 37 * 38 * Known onboard slave devices on the primary bus are: 39 * --- 19 unchanged lines hidden (view full) --- 59 * 0xa0 AT24C01A hostid 60 * 61 * For AXmp, CP1400 and CP1500 these are described in more detail in: 62 * http://www.sun.com/oem/products/manuals/805-7581-04.pdf 63 * 64 */ 65 66#include <sys/param.h> | 32 33/* 34 * Device specific driver for the EBus i2c devices found on some sun4u 35 * systems. On systems not having a boot-bus controller the i2c devices 36 * are PCF8584. 37 * 38 * Known onboard slave devices on the primary bus are: 39 * --- 19 unchanged lines hidden (view full) --- 59 * 0xa0 AT24C01A hostid 60 * 61 * For AXmp, CP1400 and CP1500 these are described in more detail in: 62 * http://www.sun.com/oem/products/manuals/805-7581-04.pdf 63 * 64 */ 65 66#include <sys/param.h> |
67#include <sys/systm.h> | |
68#include <sys/bus.h> | 67#include <sys/bus.h> |
68#include <sys/lock.h> |
|
69#include <sys/kernel.h> 70#include <sys/module.h> | 69#include <sys/kernel.h> 70#include <sys/module.h> |
71#include <sys/mutex.h> |
|
71#include <sys/resource.h> | 72#include <sys/resource.h> |
73#include <sys/systm.h> |
|
72 73#include <dev/ofw/ofw_bus.h> 74#include <dev/ofw/openfirm.h> 75 76#include <machine/bus.h> 77#include <machine/resource.h> 78 79#include <sys/rman.h> --- 57 unchanged lines hidden (view full) --- 137pcf_ebus_attach(device_t dev) 138{ 139 struct pcf_softc *sc; 140 int rv = ENXIO; 141 phandle_t node; 142 uint64_t own_addr; 143 144 sc = DEVTOSOFTC(dev); | 74 75#include <dev/ofw/ofw_bus.h> 76#include <dev/ofw/openfirm.h> 77 78#include <machine/bus.h> 79#include <machine/resource.h> 80 81#include <sys/rman.h> --- 57 unchanged lines hidden (view full) --- 139pcf_ebus_attach(device_t dev) 140{ 141 struct pcf_softc *sc; 142 int rv = ENXIO; 143 phandle_t node; 144 uint64_t own_addr; 145 146 sc = DEVTOSOFTC(dev); |
145 bzero(sc, sizeof(struct pcf_softc)); | 147 mtx_init(&sc->pcf_lock, device_get_nameunit(dev), "pcf", MTX_DEF); |
146 147 /* get OFW node of the pcf */ 148 if ((node = ofw_bus_get_node(dev)) <= 0) { 149 device_printf(dev, "cannot get OFW node\n"); 150 goto error; 151 } 152 153 /* IO port is mandatory */ 154 sc->res_ioport = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 155 &sc->rid_ioport, RF_ACTIVE); 156 if (sc->res_ioport == 0) { 157 device_printf(dev, "cannot reserve I/O port range\n"); 158 goto error; 159 } | 148 149 /* get OFW node of the pcf */ 150 if ((node = ofw_bus_get_node(dev)) <= 0) { 151 device_printf(dev, "cannot get OFW node\n"); 152 goto error; 153 } 154 155 /* IO port is mandatory */ 156 sc->res_ioport = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 157 &sc->rid_ioport, RF_ACTIVE); 158 if (sc->res_ioport == 0) { 159 device_printf(dev, "cannot reserve I/O port range\n"); 160 goto error; 161 } |
160 sc->bt_ioport = rman_get_bustag(sc->res_ioport); 161 sc->bh_ioport = rman_get_bushandle(sc->res_ioport); | |
162 163 sc->pcf_flags = device_get_flags(dev); 164 165 /* 166 * XXX use poll-mode property? 167 */ 168 if (!(sc->pcf_flags & IIC_POLLED)) { 169 sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, --- 44 unchanged lines hidden (view full) --- 214 if (sc->res_irq != 0) { 215 bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, 216 sc->res_irq); 217 } 218 if (sc->res_ioport != 0) { 219 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, 220 sc->res_ioport); 221 } | 162 163 sc->pcf_flags = device_get_flags(dev); 164 165 /* 166 * XXX use poll-mode property? 167 */ 168 if (!(sc->pcf_flags & IIC_POLLED)) { 169 sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, --- 44 unchanged lines hidden (view full) --- 214 if (sc->res_irq != 0) { 215 bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, 216 sc->res_irq); 217 } 218 if (sc->res_ioport != 0) { 219 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, 220 sc->res_ioport); 221 } |
222 mtx_destroy(&sc->pcf_lock); |
|
222 return (rv); 223} 224 225static int 226pcf_ebus_detach(device_t dev) 227{ 228 struct pcf_softc *sc; 229 int rv; --- 10 unchanged lines hidden (view full) --- 240 bus_teardown_intr(dev, sc->res_irq, 241 sc->intr_cookie); 242 bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, 243 sc->res_irq); 244 } 245 246 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, 247 sc->res_ioport); | 223 return (rv); 224} 225 226static int 227pcf_ebus_detach(device_t dev) 228{ 229 struct pcf_softc *sc; 230 int rv; --- 10 unchanged lines hidden (view full) --- 241 bus_teardown_intr(dev, sc->res_irq, 242 sc->intr_cookie); 243 bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, 244 sc->res_irq); 245 } 246 247 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, 248 sc->res_ioport); |
249 mtx_destroy(&sc->pcf_lock); |
|
248 249 return (0); 250} 251 252DRIVER_MODULE(pcf_ebus, ebus, pcf_ebus_driver, pcf_ebus_devclass, 0, 0); 253MODULE_DEPEND(pcf_ebus, iicbus, PCF_MINVER, PCF_PREFVER, PCF_MAXVER); 254MODULE_VERSION(pcf_ebus, PCF_MODVER); | 250 251 return (0); 252} 253 254DRIVER_MODULE(pcf_ebus, ebus, pcf_ebus_driver, pcf_ebus_devclass, 0, 0); 255MODULE_DEPEND(pcf_ebus, iicbus, PCF_MINVER, PCF_PREFVER, PCF_MAXVER); 256MODULE_VERSION(pcf_ebus, PCF_MODVER); |