示例#1
0
int main(int argc, char **argv) {
	int gpio, val;
	if (argc != 3) {
		fprintf(stderr, "Usage: %s [gpio] [val]\n", argv[0]);
		return 1;
	}

	gpio = strtoul(argv[1], NULL, 0);
	if (gpio < 0 || gpio > 190) {
		fprintf(stderr, "Error: gpio number is out of range (1 .. 190)\n");
		return 1;
	}

	val = strtoul(argv[2], NULL, 0);

	gpio_export(gpio);
	gpio_set_direction(gpio, GPIO_OUT);
	gpio_set_value(gpio, !!val);
	return 0;
}
示例#2
0
main(){
  int i;
  int fd;

  gpio_export(PIN);
  fd = gpio_open(PIN, "direction", O_WRONLY);
  write(fd, "out", 3);
  close(fd);

  fd = gpio_open(PIN, "value", O_WRONLY);
  for(i = 0; i < 5; i++){
    write(fd, "1", 1);
    usleep(50000);
    write(fd, "0", 1);
    usleep(50000);
  }

  close(fd);
  gpio_unexport(PIN);
}
static int smba_backlight_init(struct device *dev)
{
	int ret;

	ret = gpio_request(SMBA9701_BL_ENB, "backlight_enb");
	if (ret < 0)
		return ret;

	ret = gpio_direction_output(SMBA9701_BL_ENB, 1);
	if (ret < 0)
		gpio_free(SMBA9701_BL_ENB);

	// PQI on/off at /sys/bus/gpio/gpio27
	ret = gpio_export(SMBA9701_BL_ENB, 0);
	if(ret < 0)
		gpio_free(SMBA9701_BL_ENB);

	gpio_sysfs_set_active_low(SMBA9701_BL_ENB, 1);
	return ret;
};
示例#4
0
int wifi_configure_gpio(void)
{
	if (gpio_request(oob_gpio, "oob_irq")) {
		DBG_871X("## %s Cannot request GPIO\n", __FUNCTION__);
		return -1;
	}
	gpio_export(oob_gpio, 0);
	if (gpio_direction_input(oob_gpio)) {
		DBG_871X("## %s Cannot set GPIO direction input\n", __FUNCTION__);
		return -1;
	}
	if ((oob_irq = gpio_to_irq(oob_gpio)) < 0) {
		DBG_871X("## %s Cannot convert GPIO to IRQ\n", __FUNCTION__);
		return -1;
	}

	DBG_871X("## %s OOB_IRQ=%d\n", __FUNCTION__, oob_irq);

	return 0;
}
static int __init gpiosensor_init(void){
	int result = 0;
	unsigned long IRQflags = IRQF_TRIGGER_RISING;
	
	printk(KERN_INFO "COUNT_SENSOR: Initializing the Count Sensor LKM\n");
	sprintf(gpioName, "gpio%d", gpioSensor);
	
	gpiosensor_kobj = kobject_create_and_add("gpiosensor", kernel_kobj->parent);
   	if(!gpioSensor){
      	printk(KERN_ALERT "COUNT_SENSOR: failed to create kobject mapping\n");
      	return -ENOMEM;
   	}
   	result = sysfs_create_group(gpiosensor_kobj, &attr_group);
   	if(result) {
      printk(KERN_ALERT "COUNT_SENSOR: failed to create sysfs group\n");
      kobject_put(gpiosensor_kobj);                          
      return result;
   	}
   	getnstimeofday(&ts_last);
	ts_diff = timespec_sub(ts_last, ts_last);

	gpio_request(gpioSensor, "sysfs");
	gpio_direction_input(gpioSensor);
	gpio_set_debounce(gpioSensor, DEBOUNCE_TIME);
	gpio_export(gpioSensor, false);
	
	printk(KERN_INFO "COUNT_SENSOR: The button state is currently: %d\n", gpio_get_value(gpioSensor));
	irqNumber = gpio_to_irq(gpioSensor);
	printk(KERN_INFO "COUNT_SENSOR: The button is mapped to IRQ: %d\n", irqNumber);

	if(!isRising){                           // If the kernel parameter isRising=0 is supplied
      IRQflags = IRQF_TRIGGER_FALLING;      // Set the interrupt to be on the falling edge
   	}
   	
   	result = request_irq(irqNumber,             
                        (irq_handler_t) gpiosensor_irq_handler, 
                        IRQflags,              
                        "gpiosensor_handler",  
                        NULL);    
    return result;
}
struct gpios *new_gpio(unsigned int gpio)
{
    struct gpios *new_gpio;

    new_gpio = malloc(sizeof(struct gpios));
    if (new_gpio == 0) {
        return NULL;  // out of memory
    }

    new_gpio->gpio = gpio;
    if (gpio_export(gpio) != 0) {
        free(new_gpio);
        return NULL;
    }
    new_gpio->exported = 1;

    if (gpio_set_direction(gpio,1) != 0) { // 1==input
        free(new_gpio);
        return NULL;
    }

    if ((new_gpio->value_fd = open_value_file(gpio)) == -1) {
        gpio_unexport(gpio);
        free(new_gpio);
        return NULL;
    }

    new_gpio->initial_thread = 1;
    new_gpio->initial_wait = 1;
    new_gpio->bouncetime = -666;
    new_gpio->lastcall = 0;
    new_gpio->thread_added = 0;

    if (gpio_list == NULL) {
        new_gpio->next = NULL;
    } else {
        new_gpio->next = gpio_list;
    }
    gpio_list = new_gpio;
    return new_gpio;
}
static int init_camera_gpio(void)
{
	int i, ret;

	for (i = 0; i < ARRAY_SIZE(tegra_camera_gpio_keys); i++) {
		tegra_gpio_enable(tegra_camera_gpio_keys[i].gpio);
		ret = gpio_request(tegra_camera_gpio_keys[i].gpio,
				tegra_camera_gpio_keys[i].name);
		if (ret < 0) {
			pr_err("%s: gpio_request failed for gpio #%d (%s)\n",
				__func__, tegra_camera_gpio_keys[i].gpio,
				tegra_camera_gpio_keys[i].name);
			continue;
		}
		gpio_direction_output(tegra_camera_gpio_keys[i].gpio,
				tegra_camera_gpio_keys[i].enabled);
		gpio_export(tegra_camera_gpio_keys[i].gpio, false);
	}

	return 0;
}
示例#8
0
/* PCA9557 */
static int mxt_td60_pca9557_setup(struct i2c_client *client,
				unsigned gpio_base, unsigned ngpio,
				void *context)
{
	static int mxt_td60_gpio_value[] = {
		-1, -1, -1, -1, -1, -1, -1, 1
	};
	int n;

	for (n = 0; n < ARRAY_SIZE(mxt_td60_gpio_value); ++n) {
		gpio_request(gpio_base + n, "MXT_TD60 GPIO Exp");
		if (mxt_td60_gpio_value[n] < 0)
			gpio_direction_input(gpio_base + n);
		else
			gpio_direction_output(gpio_base + n,
						mxt_td60_gpio_value[n]);
		gpio_export(gpio_base + n, 0);
	}

	return 0;
}
示例#9
0
static int __init wandqc_init(void) {
    int i;
    gpio_free(WANDQC_TSC2046_IRQ);

    gpio_request(WANDQC_TSC2046_IRQ,  "WANDQC_TSC2046_IRQ");
    gpio_direction_input(WANDQC_TSC2046_IRQ);
    gpio_export(WANDQC_TSC2046_IRQ, 0);
    gpio_set_debounce(WANDQC_TSC2046_IRQ, 0xa);

    wandqc_tsc2046_spi_data.irq = gpio_to_irq(WANDQC_TSC2046_IRQ);
    wandqc_tsc2046_spi_data.bus_num = edm_spi[0];
    spi_register_board_info(&wandqc_tsc2046_spi_data, 1);

    wandqc_spidev_data.bus_num = edm_spi[0];
    spi_register_board_info(&wandqc_spidev_data, 1);

    for (i=0; i<EDM_N_EXTERNAL_GPIO; i++)
        if (edm_external_gpio[i] != WANDQC_TSC2046_IRQ)
            gpio_direction_output(edm_external_gpio[i], 1);
    return 0;
}
示例#10
0
static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
				 unsigned ngpio)
{
	int wlan_rst = gpio + 2;

	if (gpio_request_one(wlan_rst, GPIOF_OUT_INIT_HIGH, "WLAN RST") == 0) {
		gpio_export(wlan_rst, 0);
		udelay(10);
		gpio_set_value_cansleep(wlan_rst, 0);
		udelay(10);
		gpio_set_value_cansleep(wlan_rst, 1);
	} else {
		pr_err("CM-T35: could not obtain gpio for WiFi reset\n");
	}

	/* gpio + 0 is "mmc0_cd" (input/IRQ) */
	mmc[0].gpio_cd = gpio + 0;
	omap_hsmmc_late_init(mmc);

	return 0;
}
static int baseband_init(void)
{
	int ret;

	ret = gpio_request_array(modem_gpios, ARRAY_SIZE(modem_gpios));
	if (ret)
		return ret;

	/* enable pull-up for ULPI STP */
	tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_ULPI_STP,
				    TEGRA_PUPD_PULL_UP);

	/* enable pull-up for MDM2AP_ACK2 */
	tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_GPIO_PV0,
				    TEGRA_PUPD_PULL_UP);

	/* export GPIO for user space access through sysfs */
	gpio_export(MODEM_PWR_ON, false);

	return 0;
}
示例#12
0
/*
 * Perform GPIO initialization
 */
static int cc2530_gpio_init(void)
{
	int ret;
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
		ret = gpio_export(gpios[i]);
		if (ret) {
			fprintf(stderr, "failed to export %d\n", gpios[i]);
			return ret;
		}

		ret = gpio_set_direction(gpios[i], GPIO_DIRECTION_OUT);
		if (ret) {
			fprintf(stderr, "failed to set direction on %d\n", gpios[i]);
			return ret;
		}
	}

	return 0;
}
示例#13
0
static int acs5k_pca9555_setup(struct i2c_client *client,
			       unsigned gpio_base, unsigned ngpio,
			       void *context)
{
	static int acs5k_gpio_value[] = {
		-1, -1, -1, -1, -1, -1, -1, 0, 1, 1, -1, 0, 1, 0, -1, -1
	};
	int n;

	for (n = 0; n < ARRAY_SIZE(acs5k_gpio_value); ++n) {
		gpio_request(gpio_base + n, "ACS-5000 GPIO Expander");
		if (acs5k_gpio_value[n] < 0)
			gpio_direction_input(gpio_base + n);
		else
			gpio_direction_output(gpio_base + n,
					      acs5k_gpio_value[n]);
		gpio_export(gpio_base + n, 0); /* Export, direction locked down */
	}

	return 0;
}
示例#14
0
static int uart_switch_init(void)
{
	int ret, val;

	ret = gpio_request(GPIO_UART_SEL, "UART_SEL");
	if (ret < 0) {
		pr_err("Failed to request GPIO_UART_SEL!\n");
		return -ENODEV;
	}
	s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE);
	val = gpio_get_value(GPIO_UART_SEL);
	pr_info("##MUIC [ %s ]- func : %s !! val:-%d-\n", __FILE__, __func__,
		val);
	gpio_direction_output(GPIO_UART_SEL, val);

	gpio_export(GPIO_UART_SEL, 1);

	gpio_export_link(switch_dev, "uart_sel", GPIO_UART_SEL);

	return 0;
}
示例#15
0
static int __init gps_bcm4752_init(void)
{
	int ret = 0;
	const char *gps_node = "samsung,exynos-bcm4752";

	struct device_node *root_node = NULL;

	gps_dev = sec_device_create(NULL, "gps");
	BUG_ON(!gps_dev);

	root_node = of_find_compatible_node(NULL, NULL, gps_node);
	if (!root_node) {
		WARN(1, "failed to get device node of bcm4752\n");
		ret = -ENODEV;
		goto err_sec_device_create;
	}


	gps_pwr_on = of_get_gpio(root_node, 0);
	if (!gpio_is_valid(gps_pwr_on)) {
		WARN(1, "Invalied gpio pin : %d\n", gps_pwr_on);
		ret = -ENODEV;
		goto err_sec_device_create;
	}

	if (gpio_request(gps_pwr_on, "GPS_PWR_EN")) {
		WARN(1, "fail to request gpio(GPS_PWR_EN)\n");
		ret = -ENODEV;
		goto err_sec_device_create;
	}
	gpio_direction_output(gps_pwr_on, 0);
	gpio_export(gps_pwr_on, 1);
	gpio_export_link(gps_dev, "GPS_PWR_EN", gps_pwr_on);

	return 0;

err_sec_device_create:
	sec_device_destroy(gps_dev->devt);
	return ret;
}
static int whistler_camera_init(void)
{
	tegra_gpio_enable(CAMERA1_PWDN_GPIO);
	gpio_request(CAMERA1_PWDN_GPIO, "camera1_powerdown");
	gpio_direction_output(CAMERA1_PWDN_GPIO, 0);
	gpio_export(CAMERA1_PWDN_GPIO, false);

	tegra_gpio_enable(CAMERA1_RESET_GPIO);
	gpio_request(CAMERA1_RESET_GPIO, "camera1_reset");
	gpio_direction_output(CAMERA1_RESET_GPIO, 0);
	gpio_export(CAMERA1_RESET_GPIO, false);

	tegra_gpio_enable(CAMERA2_PWDN_GPIO);
	gpio_request(CAMERA2_PWDN_GPIO, "camera2_powerdown");
	gpio_direction_output(CAMERA2_PWDN_GPIO, 0);
	gpio_export(CAMERA2_PWDN_GPIO, false);

	tegra_gpio_enable(CAMERA2_RESET_GPIO);
	gpio_request(CAMERA2_RESET_GPIO, "camera2_reset");
	gpio_direction_output(CAMERA2_RESET_GPIO, 0);
	gpio_export(CAMERA2_RESET_GPIO, false);

	tegra_gpio_enable(CAMERA_AF_PD_GPIO);
	gpio_request(CAMERA_AF_PD_GPIO, "camera_autofocus");
	gpio_direction_output(CAMERA_AF_PD_GPIO, 0);
	gpio_export(CAMERA_AF_PD_GPIO, false);

	tegra_gpio_enable(CAMERA_FLASH_EN1_GPIO);
	gpio_request(CAMERA_FLASH_EN1_GPIO, "camera_flash_en1");
	gpio_direction_output(CAMERA_FLASH_EN1_GPIO, 0);
	gpio_export(CAMERA_FLASH_EN1_GPIO, false);

	tegra_gpio_enable(CAMERA_FLASH_EN2_GPIO);
	gpio_request(CAMERA_FLASH_EN2_GPIO, "camera_flash_en2");
	gpio_direction_output(CAMERA_FLASH_EN2_GPIO, 0);
	gpio_export(CAMERA_FLASH_EN2_GPIO, false);

	gpio_set_value(CAMERA1_PWDN_GPIO, 1);
	mdelay(5);

	return 0;
}
示例#17
0
static inline void igep_leds_init(void)
{
	int i;

	if (machine_is_igep0020()) {
		igep_gpio_leds[0].gpio = IGEP2_GPIO_LED0_RED;
		igep_gpio_leds[1].gpio = IGEP2_GPIO_LED0_GREEN;
		igep_gpio_leds[2].gpio = IGEP2_GPIO_LED1_RED;
	} else {
		igep_gpio_leds[0].gpio = IGEP3_GPIO_LED0_RED;
		igep_gpio_leds[1].gpio = IGEP3_GPIO_LED0_GREEN;
		igep_gpio_leds[2].gpio = IGEP3_GPIO_LED1_RED;
	}

	if (gpio_request_array(igep_gpio_leds, ARRAY_SIZE(igep_gpio_leds))) {
		pr_warning("IGEP v2: Could not obtain leds gpios\n");
		return;
	}

	for (i = 0; i < ARRAY_SIZE(igep_gpio_leds); i++)
		gpio_export(igep_gpio_leds[i].gpio, 0);
}
示例#18
0
static void __init cm_t35_init_smsc911x(void)
{
	unsigned long cs_mem_base;

	if (gpmc_cs_request(CM_T35_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
		pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
		return;
	}

	cm_t35_smsc911x_resources[0].start = cs_mem_base + 0x0;
	cm_t35_smsc911x_resources[0].end   = cs_mem_base + 0xff;

	if ((gpio_request(CM_T35_SMSC911X_GPIO, "CM ETH IRQ") == 0) &&
	    (gpio_direction_input(CM_T35_SMSC911X_GPIO) == 0)) {
		gpio_export(CM_T35_SMSC911X_GPIO, 0);
	} else {
		pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
		return;
	}

	platform_device_register(&cm_t35_smsc911x_device);
}
示例#19
0
void pinMode(PIN pin, unsigned int value) {
  unsigned gpio;
  const Pair* pair;

  pair  = get_pair_with_key(pin.def, pin.no, "gpio");
  gpio = atoi(pair->value);
  
  //printf("pinMode GPIO:%d as %s\n",gpio, (INPUT) ? "INPUT" : "OUTPUT");

  if (value == INPUT) {
    // mux mode 0x27
    gpio_mux(&pin,  (_MUX_0 | _MUX_1 | _MUX_2 | _MUX_RECEIVER_ENABLE));
  }
  else {
    // mux mode 0x7
    gpio_mux(&pin, (_MUX_0 | _MUX_1 | _MUX_2));
  }

  gpio_export(gpio);
  gpio_set_direction(gpio, value);

}
示例#20
0
void *ledTask(void *ptr)
{
	printf("ledTask started\n");

	if (gpio_export(OUT_GPIO) != RET_OK) {
		printf("ledTask > gpio not found\n");
		return;
	}
	if (gpio_set_direction(OUT_GPIO, DIR_OUT) != RET_OK) {
		printf("ledTask > gpio dir set fail\n");
		return;
	}

	while(1) {
	    if (s_bfStart) { 
			gpio_set_value(OUT_GPIO, 1);
		} else {
			gpio_set_value(OUT_GPIO, 0);
		}
		usleep(100000);
	}
}
static int yuv_sensor2031_power_on(void)
{
	int i, ret;

	pr_info("[ MT9D115 ] _____  %s  _____\n", __func__);  // Carl test

	for (i = 0; i < ARRAY_SIZE(yuv_sensor2031_gpio_keys); i++) {
		tegra_gpio_enable(yuv_sensor2031_gpio_keys[i].gpio);
		ret = gpio_request(yuv_sensor2031_gpio_keys[i].gpio,
				yuv_sensor2031_gpio_keys[i].name);
		if (ret < 0) {
			pr_err("%s: gpio_request failed for gpio #%d\n",
				__func__, i);
			goto fail;
		}
	}

	gpio_direction_output(YUV_AP5140_PWDN_GPIO, 1);  //for camera switch LED

	gpio_direction_output(YUV_AP2031_OE_GPIO, 0);
	gpio_direction_output(YUV_AP2031_RST_GPIO, 1);
	msleep(1);
	gpio_direction_output(CAMERA_POWER_GPIO, 1);
	msleep(1);
	gpio_direction_output(YUV_AP2031_RST_GPIO, 0);
	msleep(1);
	gpio_direction_output(YUV_AP2031_RST_GPIO, 1);

	for (i = 0; i < ARRAY_SIZE(yuv_sensor2031_gpio_keys); i++) {
		gpio_export(yuv_sensor2031_gpio_keys[i].gpio, false);
	}

	return 0;

fail:
	while (i--)
		gpio_free(yuv_sensor2031_gpio_keys[i].gpio);
	return ret;
}
示例#22
0
static int igep_twl_gpio_setup(struct device *dev,
		unsigned gpio, unsigned ngpio)
{
	int ret;

	/* gpio + 0 is "mmc0_cd" (input/IRQ) */
	mmc[0].gpio_cd = gpio + 0;
	omap_hsmmc_late_init(mmc);

	/* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
	ret = gpio_request_one(gpio + TWL4030_GPIO_MAX + 1, GPIOF_OUT_INIT_HIGH,
			       "gpio-led:green:d1");
	if (ret == 0)
		gpio_export(gpio + TWL4030_GPIO_MAX + 1, 0);
	else
		pr_warning("IGEP: Could not obtain gpio GPIO_LED1_GREEN\n");
#else
	igep_gpio_leds[3].gpio = gpio + TWL4030_GPIO_MAX + 1;
#endif

	if (machine_is_igep0030())
		return 0;

	/*
	 * REVISIT: need ehci-omap hooks for external VBUS
	 * power switch and overcurrent detect
	 */
	igep2_twl_gpios[0].gpio = gpio + 1;

	/* TWL4030_GPIO_MAX + 0 == ledA, GPIO_USBH_CPEN (out, active low) */
	igep2_twl_gpios[1].gpio = gpio + TWL4030_GPIO_MAX;

	ret = gpio_request_array(igep2_twl_gpios, ARRAY_SIZE(igep2_twl_gpios));
	if (ret < 0)
		pr_err("IGEP2: Could not obtain gpio for USBH_CPEN");

	return 0;
};
示例#23
0
static int mx53_ard_max7310_setup(struct i2c_client *client,
			       unsigned gpio_base, unsigned ngpio,
			       void *context)
{
	static int max7310_gpio_value[] = {
		1, 1, 1, 1, 0, 0, 0, 0,
	};
	int n;

	for (n = 0; n < ARRAY_SIZE(max7310_gpio_value); ++n) {
		gpio_request(gpio_base + n, "MAX7310 GPIO Expander");
		if (max7310_gpio_value[n] < 0)
			gpio_direction_input(gpio_base + n);
		else
			gpio_direction_output(gpio_base + n,
					      max7310_gpio_value[n]);
		/* Export, direction locked down */
		gpio_export(gpio_base + n, 0);
	}

	return 0;
}
示例#24
0
int main(int argc, char *argv[]) {
  parse_options(argc, argv);

  gpio_export(options.gpioNr);
  gpio_direction(options.gpioNr, options.operation);

  if (options.operation == GPIO_GET) {
    int val;
    int i; for(i = 0; i < options.repeat; ++i) {
      val = gpio_get(options.gpioNr);
    }
    printf("%d\n", val);
  } else {
    int i; for(i = 0; i < options.repeat; ++i) {
      gpio_set(options.gpioNr, options.value);
    }
  }

  gpio_unexport(options.gpioNr);

  return 0;
}
示例#25
0
static int c55_ctrl_gpio_setup(struct c55_ctrl_data *cdata, struct device *dev)
{
	int i;

	if (of_gpio_count(dev->of_node) != NUM_GPIOS) {
		dev_err(dev, "%s: gpio count is not %d.\n", __func__, NUM_GPIOS);
		return -EINVAL;
	}

	for (i = 0; i < NUM_GPIOS; i++) {
		enum of_gpio_flags flags;
		int gpio;

		gpio = of_get_gpio_flags(dev->of_node, i, &flags);
		if (gpio < 0) {
			pr_err("%s: of_get_gpio failed: %d\n", __func__, gpio);
			return gpio;
		}

		gpio_request(gpio, gpio_labels[i]);

		gpio_export(gpio, false);
		gpio_export_link(dev, gpio_labels[i], gpio);

		if ((flags & GPIOF_IN) == GPIOF_IN) {
			gpio_direction_input(gpio);
			c55_ctrl_int_setup(cdata, gpio);
		} else {
			cdata->ap_c55_int_gpio = gpio;
			if ((flags & GPIOF_OUT_INIT_HIGH) == GPIOF_OUT_INIT_HIGH)
				gpio_direction_output(gpio, 1);
			else
				gpio_direction_output(gpio, 0);
		}
	}

	return 0;
}
示例#26
0
static int evm_sw_setup(struct i2c_client *client, int gpio,
			unsigned ngpio, void *c)
{
	int status;
	int i;
	char label[10];

	for (i = 0; i < 4; ++i) {
		snprintf(label, 10, "user_sw%d", i);
		status = gpio_request(gpio, label);
		if (status)
			goto out_free;
		evm_sw_gpio[i] = gpio++;

		status = gpio_direction_input(evm_sw_gpio[i]);
		if (status) {
			gpio_free(evm_sw_gpio[i]);
			evm_sw_gpio[i] = -EINVAL;
			goto out_free;
		}

		status = gpio_export(evm_sw_gpio[i], 0);
		if (status) {
			gpio_free(evm_sw_gpio[i]);
			evm_sw_gpio[i] = -EINVAL;
			goto out_free;
		}
	}
	return status;
out_free:
	for (i = 0; i < 4; ++i) {
		if (evm_sw_gpio[i] != -EINVAL) {
			gpio_free(evm_sw_gpio[i]);
			evm_sw_gpio[i] = -EINVAL;
		}
	}
	return status;
}
示例#27
0
static int __init power_on_init(void)
{	
	printk(KERN_INFO "power_on_init!!!\n");
	int ret;
	if( (gpio_request(POWER_ON_OFF, "POWER_ON_OFF") == 0) &&
		(gpio_direction_output(POWER_ON_OFF, 1) == 0))
	{
		gpio_export(POWER_ON_OFF, 0);	
		//printk(KERN_INFO "POWER_ON_OFF = [%d]!!!\n", gpio_get_value(POWER_ON_OFF));
		gpio_set_value(POWER_ON_OFF, 1);
		if( gpio_get_value(POWER_ON_OFF) == 0)
		{
			printk(KERN_ERR "can't set POWER_ON_OFF = 1\n");
		}
	}
	else{
		printk(KERN_ERR "cluld not obtain gpio for 'POWER_ON_OFF'\n");
	}
//	printk(KERN_INFO "POWER_ON_OFF = [%d]!!!\n", gpio_get_value(POWER_ON_OFF));

	/* set power_det interrupt */
	s3c_gpio_cfgpin(POWER_DET, S3C_GPIO_SFN(2));
	/* set power_det pull none */
	s3c_gpio_setpull(POWER_DET, S3C_GPIO_PULL_NONE);
	/* set power_det irq both */
	set_irq_type(POWER_DET, IRQ_TYPE_EDGE_BOTH);

	ret = request_irq(IRQ_POWER_ON_OFF, power_off_int, IRQF_DISABLED | IRQ_TYPE_EDGE_BOTH, "power_on_off", NULL);
	if(ret < 0)
	{
		printk(KERN_ERR "request_irq IRQ_POWER_ON_OFF failed !!!\n");
	}
	else if(ret == 0)
	{
		printk(KERN_ERR "request_irq IRQ_POWER_ON_OFF successed !!!\n");
	}
	return 0;
}
示例#28
0
static void __init cm_t35_init_smsc911x(struct platform_device *dev,
					int cs, int irq_gpio)
{
	unsigned long cs_mem_base;

	if (gpmc_cs_request(cs, SZ_16M, &cs_mem_base) < 0) {
		pr_err("CM-T35: Failed request for GPMC mem for smsc911x\n");
		return;
	}

	dev->resource[0].start = cs_mem_base + 0x0;
	dev->resource[0].end   = cs_mem_base + 0xff;

	if ((gpio_request(irq_gpio, "ETH IRQ") == 0) &&
	    (gpio_direction_input(irq_gpio) == 0)) {
		gpio_export(irq_gpio, 0);
	} else {
		pr_err("CM-T35: could not obtain gpio for SMSC911X IRQ\n");
		return;
	}

	platform_device_register(dev);
}
/****************************************************************
* Initialize IO
****************************************************************/
void initIO(){
	char gpio30[] = "gpmc_wait0";
	char gpio31[] = "gpmc_wpn";
	char gpio48[] = "gpmc_a0";
	char gpio5[] = "spi0_cs0";

	int i;

	//Set pin mux in gpio output mode for controllers
#ifdef SET_PIN_MUX
mode_gpio_out(gpio30);
	mode_gpio_out(gpio31);
	mode_gpio_out(gpio48);
	mode_gpio_out(gpio5);
#endif

	//Export gpios and set up output direction for controllers
	for (i = 0; i < 4; i++){
		gpio_export(controller[i]);
		gpio_set_direction(controller[i], 1);
	}
	
}
示例#30
0
static inline void __init igep2_init_smsc911x(void)
{
	unsigned long cs_mem_base;

	if (gpmc_cs_request(IGEP2_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
		pr_err("IGEP v2: Failed request for GPMC mem for smsc911x\n");
		gpmc_cs_free(IGEP2_SMSC911X_CS);
		return;
	}

	igep2_smsc911x_resources[0].start = cs_mem_base + 0x0;
	igep2_smsc911x_resources[0].end   = cs_mem_base + 0xff;

	if ((gpio_request(IGEP2_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
	    (gpio_direction_input(IGEP2_SMSC911X_GPIO) == 0)) {
		gpio_export(IGEP2_SMSC911X_GPIO, 0);
	} else {
		pr_err("IGEP v2: Could not obtain gpio for for SMSC911X IRQ\n");
		return;
	}

	platform_device_register(&igep2_smsc911x_device);
}