FreeBSD/sys/arm/samsung/exynos/chrome_ec.c
/*
 * bus_claim, bus_release
 * both functions used for bus arbitration
 * in multi-master mode
 */
bus_claim, bus_release
both functions used for bus arbitration
in multi-master mode
bus_claim bus_release both functions used for bus arbitration in multi - master mode
static int
bus_claim(struct ec_softc *sc)
{
	device_t gpio_dev;
	int status;
	if (sc->our_gpio == 0 || sc->ec_gpio == 0) {
		device_printf(sc->dev, "i2c arbitrator is not configured\n");
		return (1);
	}
	gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
	if (gpio_dev == NULL) {
		device_printf(sc->dev, "cant find gpio_dev\n");
		return (1);
	}
	GPIO_PIN_SET(gpio_dev, sc->our_gpio, GPIO_PIN_LOW);
	GPIO_PIN_GET(gpio_dev, sc->ec_gpio, &status);
	if (status == 1) {
		return (0);
	}
	return (-1);
}
static int bus_claim ( struct ec_softc * sc ) { device_t gpio_dev ; int status ; if ( sc -> our_gpio == 0 || sc -> ec_gpio == 0 ) { device_printf ( sc -> dev , " \n " ) ; return ( 1 ) ; } gpio_dev = devclass_get_device ( devclass_find ( " " ) , 0 ) ; if ( gpio_dev == NULL ) { device_printf ( sc -> dev , " \n " ) ; return ( 1 ) ; } GPIO_PIN_SET ( gpio_dev , sc -> our_gpio , GPIO_PIN_LOW ) ; GPIO_PIN_GET ( gpio_dev , sc -> ec_gpio , & status ) ; if ( status == 1 ) { return ( 0 ) ; } return ( -1 ) ; }
bus_claim, bus_release
 both functions used for bus arbitration
 in multi-master mode
bus_claim bus_release both functions used for bus arbitration in multi - master mode
/* Say we want the bus */ /* TODO: insert a delay to allow EC to react. */ /* Check EC decision */ /* Okay. We have bus */ /* EC is master */