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 265810 2014-05-10 08:10:01Z rpaulo $");
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 /* First we _must_ activate the H/W */
1080 err = ti_i2c_activate(dev);
1081 if (err) {
1082 device_printf(dev, "ti_i2c_activate failed\n");
1083 goto out;
1084 }
1085
1086 /* XXXOMAP3: FIXME get proper revision here */
1087 /* Read the version number of the I2C module */
1088 sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_HI) & 0xff;
1089
1090 device_printf(dev, "I2C revision %d.%d\n", sc->sc_rev >> 4,
1091 sc->sc_rev & 0xf);
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 265810 2014-05-10 08:10:01Z rpaulo $");
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 /* First we _must_ activate the H/W */
1080 err = ti_i2c_activate(dev);
1081 if (err) {
1082 device_printf(dev, "ti_i2c_activate failed\n");
1083 goto out;
1084 }
1085
1086 /* XXXOMAP3: FIXME get proper revision here */
1087 /* Read the version number of the I2C module */
1088 sc->sc_rev = ti_i2c_read_2(sc, I2C_REG_REVNB_HI) & 0xff;
1089
1090 device_printf(dev, "I2C revision %d.%d\n", sc->sc_rev >> 4,
1091 sc->sc_rev & 0xf);
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 ---