예제 #1
0
static int
octeon_gpio_pin_toggle(device_t dev, uint32_t pin)
{
    int i;
    uint64_t state;
    struct octeon_gpio_softc *sc = device_get_softc(dev);

    for (i = 0; i < sc->gpio_npins; i++) {
        if (sc->gpio_pins[i].gp_pin == pin)
            break;
    }

    if (i >= sc->gpio_npins)
        return (EINVAL);

    GPIO_LOCK(sc);
    /*
     * XXX: Need to check if read returns actual state of output
     * pins or we need to keep this information by ourself
     */
    state = cvmx_gpio_read();
    if (state & (1 << pin))
        cvmx_gpio_clear(1 << pin);
    else
        cvmx_gpio_set(1 << pin);
    GPIO_UNLOCK(sc);

    return (0);
}
예제 #2
0
/**
 * Resets the CF card using GPIO for reset.  If no GPIO line is defined for
 * reset then this does nothing.
 */
void ide_set_reset(int reset)
{
#ifdef OCTEON_CF_RESET_GPIO
	if (reset) {
		cvmx_gpio_cfg(OCTEON_CF_RESET_GPIO, 1);
		cvmx_gpio_clear((1ull << OCTEON_CF_RESET_GPIO));

	} else {
		cvmx_gpio_set((1ull << OCTEON_CF_RESET_GPIO));
	}
	CVMX_SYNC;
#endif
}
예제 #3
0
static int
octeon_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
{
    struct octeon_gpio_softc *sc = device_get_softc(dev);
    int i;

    for (i = 0; i < sc->gpio_npins; i++) {
        if (sc->gpio_pins[i].gp_pin == pin)
            break;
    }

    if (i >= sc->gpio_npins)
        return (EINVAL);

    GPIO_LOCK(sc);
    if (value)
        cvmx_gpio_set(1 << pin);
    else
        cvmx_gpio_clear(1 << pin);
    GPIO_UNLOCK(sc);

    return (0);
}