1/*-
2 * Copyright (c) 2011
3 * Ben Gray <ben.r.gray@gmail.com>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
--- 31 unchanged lines hidden (view full) ---
40 *
41 *
42 * WARNING: This driver uses mtx_sleep and interrupts to perform transactions,
43 * which means you can't do a transaction during startup before the interrupts
44 * have been enabled. Hint - the freebsd function config_intrhook_establish().
45 */
46
47#include <sys/cdefs.h>
48__FBSDID("$FreeBSD: stable/10/sys/arm/ti/ti_i2c.c 239281 2012-08-15 06:31:32Z gonzo $");
49
50#include <sys/param.h>
51#include <sys/systm.h>
52#include <sys/bus.h>
53#include <sys/conf.h>
54#include <sys/kernel.h>
55#include <sys/lock.h>
56#include <sys/mbuf.h>
--- 1014 unchanged lines hidden (view full) ---
1071 rid = 0;
1072 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
1073 RF_ACTIVE | RF_SHAREABLE);
1074 if (sc->sc_irq_res == NULL) {
1075 err = ENOMEM;
1076 goto out;
1077 }
1078
1079 /* XXXOMAP3: FIXME get proper revision here */
1080 /* First read the version number of the I2C module */
1081 sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_HI) & 0xff;
1082
1083 device_printf(dev, "I2C revision %d.%d\n", sc->sc_rev >> 4,
1084 sc->sc_rev & 0xf);
1085
1086 /* Activate the H/W */
1087 err = ti_i2c_activate(dev);
1088 if (err) {
1089 device_printf(dev, "ti_i2c_activate failed\n");
1090 goto out;
1091 }
1092
1093 /* activate the interrupt */
1094 err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
1095 NULL, ti_i2c_intr, sc, &sc->sc_irq_h);
1096 if (err)
1097 goto out;
1098
1099 /* Attach to the iicbus */
1100 if ((sc->sc_iicbus = device_add_child(dev, "iicbus", -1)) == NULL)
--- 79 unchanged lines hidden ---
2 * Copyright (c) 2011
3 * Ben Gray <ben.r.gray@gmail.com>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
--- 31 unchanged lines hidden (view full) ---
40 *
41 *
42 * WARNING: This driver uses mtx_sleep and interrupts to perform transactions,
43 * which means you can't do a transaction during startup before the interrupts
44 * have been enabled. Hint - the freebsd function config_intrhook_establish().
45 */
46
47#include <sys/cdefs.h>
48__FBSDID("$FreeBSD: stable/10/sys/arm/ti/ti_i2c.c 239281 2012-08-15 06:31:32Z gonzo $");
49
50#include <sys/param.h>
51#include <sys/systm.h>
52#include <sys/bus.h>
53#include <sys/conf.h>
54#include <sys/kernel.h>
55#include <sys/lock.h>
56#include <sys/mbuf.h>
--- 1014 unchanged lines hidden (view full) ---
1071 rid = 0;
1072 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
1073 RF_ACTIVE | RF_SHAREABLE);
1074 if (sc->sc_irq_res == NULL) {
1075 err = ENOMEM;
1076 goto out;
1077 }
1078
1079 /* XXXOMAP3: FIXME get proper revision here */
1080 /* First read the version number of the I2C module */
1081 sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_HI) & 0xff;
1082
1083 device_printf(dev, "I2C revision %d.%d\n", sc->sc_rev >> 4,
1084 sc->sc_rev & 0xf);
1085
1086 /* Activate the H/W */
1087 err = ti_i2c_activate(dev);
1088 if (err) {
1089 device_printf(dev, "ti_i2c_activate failed\n");
1090 goto out;
1091 }
1092
1093 /* activate the interrupt */
1094 err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
1095 NULL, ti_i2c_intr, sc, &sc->sc_irq_h);
1096 if (err)
1097 goto out;
1098
1099 /* Attach to the iicbus */
1100 if ((sc->sc_iicbus = device_add_child(dev, "iicbus", -1)) == NULL)
--- 79 unchanged lines hidden ---