Example #1
0
/**
 * @brief Hardware de-initialization
 *
 * The function will restore original pinshare value and deactivate GPIO pins.
 *
 * @param dev pointer to structure of device data
 * @return 0 on success, negative errno on error
 */
static int tsb_spi_hw_deinit(struct device *dev) {
    struct tsb_spi_info *info = NULL;
    uint32_t pinshare = 0;
    int i = 0;

    /* check input parameters */
    if (!dev || !device_get_private(dev)) {
        return -EINVAL;
    }

    info = device_get_private(dev);

    /* release GPIO pins */
    for (i = 0; i < info->caps.csnum; i++) {
        gpio_deactivate(info->chipselect[i]);
    }
    gpio_deactivate(SPI_SDO);
    gpio_deactivate(SPI_SDI);
    gpio_deactivate(SPI_SCK);

    /* restore pinshare#5 setting */
    pinshare = tsb_get_pinshare() & TSB_PIN_GPIO10; /* current setting */
    if ((info->pinshare & TSB_PIN_GPIO10)) {
        if (!pinshare) {
            tsb_set_pinshare(TSB_PIN_GPIO10);
        }
    } else {
        if (pinshare) {
            tsb_clr_pinshare(TSB_PIN_GPIO10);
        }
    }
    return 0;
}
Example #2
0
int ara_key_enable(const struct ara_board_info *info,
                   int (*longpress_callback)(void *priv), bool enable)
{
    if (enable) {
        if (!info->ara_key_configured) {
            dbg_error("%s: no ara key gpio defined\n", __func__);
            return -EINVAL;
        }

        the_ara_key.longpress_callback = longpress_callback;
        the_ara_key.db.gpio = info->ara_key_gpio;
	the_ara_key.db.ms = ARA_KEY_DEBOUNCE_TIME_MS;
        the_ara_key.db.isr = ara_key_irqhandler;
        the_ara_key.db.db_state = DB_ST_INVALID;
        the_ara_key.rising_edge = info->ara_key_rising_edge;

        gpio_activate(info->ara_key_gpio);
        gpio_direction_in(info->ara_key_gpio);
        gpio_irq_mask(info->ara_key_gpio);
        gpio_irq_settriggering(info->ara_key_gpio, IRQ_TYPE_EDGE_BOTH);
        gpio_irq_attach(info->ara_key_gpio, ara_key_irqhandler);
    } else {
        gpio_irq_mask(info->ara_key_gpio);
        gpio_deactivate(info->ara_key_gpio);
    }

    return OK;
}
Example #3
0
static uint8_t gb_vibrator_vibrator_off(struct gb_operation *operation)
{
    // Deactivate the GPIO line, somehow.

    gpio_activate(GB_VIBRATOR_DUMMY_GPIO);
    gpio_set_value(GB_VIBRATOR_DUMMY_GPIO, 0);
    gpio_deactivate(GB_VIBRATOR_DUMMY_GPIO);

    return GB_OP_SUCCESS;
}
Example #4
0
static uint8_t gb_vibrator_vibrator_on(struct gb_operation *operation)
{
    struct gb_vibrator_on_request *request =
            gb_operation_get_request_payload(operation);

    if (gb_operation_get_request_payload_size(operation) < sizeof(*request)) {
        gb_error("dropping short message\n");
        return GB_OP_INVALID;
    }

    gpio_activate(GB_VIBRATOR_DUMMY_GPIO);
    gpio_set_value(GB_VIBRATOR_DUMMY_GPIO, 1);

    usleep(le16_to_cpu(request->timeout_ms));

    gpio_deactivate(GB_VIBRATOR_DUMMY_GPIO);

    return GB_OP_SUCCESS;
}
Example #5
0
/**
 * Deinit the USB3813 hub
 *
 * Deactivate the GPIO line
 *
 * @param dev Device
 */
static void usb3813_close(struct device *dev)
{
    gpio_deactivate(HUB_LINE_N_RESET);
}