static ssize_t isDebounce_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count){
   unsigned int temp;
   sscanf(buf, "%du", &temp);                // use a 600-80temp varable for correct int->bool
   gpio_set_debounce(gpioSensor,0);
   isDebounce = temp;
   if(isDebounce) { gpio_set_debounce(gpioSensor, DEBOUNCE_TIME);
      printk(KERN_INFO "COUNT_SENSOR: Debounce on\n");
   }
   else { gpio_set_debounce(gpioSensor, 0);  // set the debounce time to 0
      printk(KERN_INFO "COUNT_SENSOR: Debounce off\n");
   }
   return count;
}
/**
 * mmc_gpio_request_cd - request a gpio for card-detection
 * @host: mmc host
 * @gpio: gpio number requested
 * @debounce: debounce time in microseconds
 *
 * As devm_* managed functions are used in mmc_gpio_request_cd(), client
 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
 * if the requesting and freeing are only needed at probing and unbinding time
 * for once.  However, if client drivers do something special like runtime
 * switching for card-detection, they are responsible for calling
 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
 *
 * If GPIO debouncing is desired, set the debounce parameter to a non-zero
 * value. The caller is responsible for ensuring that the GPIO driver associated
 * with the GPIO supports debouncing, otherwise an error will be returned.
 *
 * Returns zero on success, else an error.
 */
int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
			unsigned int debounce)
{
	struct mmc_gpio *ctx;
	int ret;

	ret = mmc_gpio_alloc(host);
	if (ret < 0)
		return ret;

	ctx = host->slot.handler_priv;

	ret = devm_gpio_request_one(&host->class_dev, gpio, GPIOF_DIR_IN,
				    ctx->cd_label);
	if (ret < 0)
		/*
		 * don't bother freeing memory. It might still get used by other
		 * slot functions, in any case it will be freed, when the device
		 * is destroyed.
		 */
		return ret;

	if (debounce) {
		ret = gpio_set_debounce(gpio, debounce);
		if (ret < 0)
			return ret;
	}

	ctx->override_cd_active_level = true;
	ctx->cd_gpio = gpio_to_desc(gpio);

	return 0;
}
Exemple #3
0
void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
			      struct ads7846_platform_data *board_pdata)
{
	struct spi_board_info *spi_bi = &ads7846_spi_board_info;
	int err;

	if (board_pdata && board_pdata->get_pendown_state) {
		err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
		if (err) {
			pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
			return;
		}
		gpio_export(gpio_pendown, 0);

		if (gpio_debounce)
			gpio_set_debounce(gpio_pendown, gpio_debounce);
	}

	spi_bi->bus_num	= bus_num;
	spi_bi->irq	= OMAP_GPIO_IRQ(gpio_pendown);

	if (board_pdata) {
		board_pdata->gpio_pendown = gpio_pendown;
		spi_bi->platform_data = board_pdata;
	} else {
		ads7846_config.gpio_pendown = gpio_pendown;
	}

	spi_register_board_info(&ads7846_spi_board_info, 1);
}
static int vision_spi_mmc_init(struct device *pdev,
			irqreturn_t (*func)(int, void *), void *pdata)
{
	int err;

	err = gpio_request_array(vision_spi_mmc_gpios,
				 ARRAY_SIZE(vision_spi_mmc_gpios));
	if (err)
		return err;

	err = gpio_set_debounce(VISION_SPI_MMC_CD, 1);
	if (err)
		goto exit_err;

	err = request_irq(gpio_to_irq(VISION_SPI_MMC_CD), func,
			IRQ_TYPE_EDGE_BOTH, "mmc_spi:cd", pdata);
	if (err)
		goto exit_err;

	return 0;

exit_err:
	gpio_free_array(vision_spi_mmc_gpios, ARRAY_SIZE(vision_spi_mmc_gpios));
	return err;

}
Exemple #5
0
int wm8350_gpio_config(struct wm8350 *wm8350, int gpio, int dir, int func,
		       int pol, int pull, int invert, int debounce)
{
	/* make sure we never pull up and down at the same time */
	if (pull == WM8350_GPIO_PULL_NONE) {
		if (gpio_set_pull_up(wm8350, gpio, 0))
			goto err;
		if (gpio_set_pull_down(wm8350, gpio, 0))
			goto err;
	} else if (pull == WM8350_GPIO_PULL_UP) {
		if (gpio_set_pull_down(wm8350, gpio, 0))
			goto err;
		if (gpio_set_pull_up(wm8350, gpio, 1))
			goto err;
	} else if (pull == WM8350_GPIO_PULL_DOWN) {
		if (gpio_set_pull_up(wm8350, gpio, 0))
			goto err;
		if (gpio_set_pull_down(wm8350, gpio, 1))
			goto err;
	}

	if (gpio_set_invert(wm8350, gpio, invert))
		goto err;
	if (gpio_set_polarity(wm8350, gpio, pol))
		goto err;
	if (gpio_set_debounce(wm8350, gpio, debounce))
		goto err;
	if (gpio_set_dir(wm8350, gpio, dir))
		goto err;
	return gpio_set_func(wm8350, gpio, func);

err:
	return -EIO;
}
Exemple #6
0
static void ads7846_dev_init(void)
{
	if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
		printk(KERN_ERR "can't get ads7846 pen down GPIO\n");

	gpio_direction_input(OMAP3_EVM_TS_GPIO);
	gpio_set_debounce(OMAP3_EVM_TS_GPIO, 310);
}
Exemple #7
0
int c2k_gpio_set_irq_type(int gpio, unsigned int type)
{
	int irq, level;

	irq = c2k_gpio_to_irq(gpio);
	if (irq < 0)
		return irq;

	level = c2k_gpio_get_value(gpio);

	if (type == IRQ_TYPE_EDGE_BOTH) {
		if (level)
			type = IRQ_TYPE_EDGE_FALLING;
		else
			type = IRQ_TYPE_EDGE_RISING;
	}

	if (type == IRQ_TYPE_LEVEL_MASK) {
		if (level)
			type = IRQ_TYPE_LEVEL_LOW;
		else
			type = IRQ_TYPE_LEVEL_HIGH;
	}
#ifndef CONFIG_EVDO_DT_VIA_SUPPORT
	c2k_irq_set_type(irq, type);
#endif

#if defined(CONFIG_MTK_LEGACY)
	mt_eint_set_hw_debounce(irq, 0);
	switch (type) {
	case IRQ_TYPE_EDGE_RISING:
		mt_eint_set_sens(irq, MT_EDGE_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_HIGH);
		break;
	case IRQ_TYPE_EDGE_FALLING:
		mt_eint_set_sens(irq, MT_EDGE_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_LOW);
		break;
	case IRQ_TYPE_LEVEL_HIGH:
		mt_eint_set_sens(irq, MT_LEVEL_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_HIGH);
		break;
	case IRQ_TYPE_LEVEL_LOW:
		mt_eint_set_sens(irq, MT_LEVEL_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_LOW);
		break;
	default:
		return -EINVAL;
	}
#else
	gpio_set_debounce(gpio, 0);
	irq_set_irq_type(irq, type);
#endif
	/*pr_debug("[C2K]set irq(%d) type(%d) done\n", irq, type); */

	return 0;
}
static void otg_int_init(void)
{
#ifdef ID_PIN_USE_EX_EINT
	int	ret = 0;
#ifndef CONFIG_MTK_FPGA
	#ifdef CONFIG_OF
	#if defined(CONFIG_MTK_LEGACY)
	mt_set_gpio_mode(iddig_pin, iddig_pin_mode);
	mt_set_gpio_dir(iddig_pin, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(iddig_pin, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(iddig_pin, GPIO_PULL_UP);
	#else
	pr_debug("****%s:%d before Init IDDIG KS!!!!!\n", __func__, __LINE__);

	pinctrl_iddig = pinctrl_lookup_state(pinctrl, "iddig_irq_init");
	if (IS_ERR(pinctrl_iddig)) {
		ret = PTR_ERR(pinctrl_iddig);
		dev_err(mtk_musb->controller, "Cannot find usb pinctrl iddig_irq_init\n");
	}

	pinctrl_select_state(pinctrl, pinctrl_iddig);

	pr_debug("****%s:%d end Init IDDIG KS!!!!!\n", __func__, __LINE__);
	#endif
	#else
	mt_set_gpio_mode(GPIO_OTG_IDDIG_EINT_PIN, GPIO_OTG_IDDIG_EINT_PIN_M_IDDIG);
	mt_set_gpio_dir(GPIO_OTG_IDDIG_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_UP);
	#endif
#endif
	#if defined(CONFIG_MTK_LEGACY)
	mt_gpio_set_debounce(IDDIG_EINT_PIN, 64000);
	usb_iddig_number = mt_gpio_to_irq(IDDIG_EINT_PIN);
	pr_debug("USB IDDIG IRQ LINE %d, %d!!\n", IDDIG_EINT_PIN, mt_gpio_to_irq(IDDIG_EINT_PIN));
	ret = request_irq(usb_iddig_number, mt_usb_ext_iddig_int, IRQF_TRIGGER_LOW, "USB_IDDIG", NULL);
	#else
	/*gpio_request(iddig_pin, "USB_IDDIG");*/
	gpio_set_debounce(iddig_pin, 64000);
	usb_iddig_number = mt_gpio_to_irq(iddig_pin);
	ret = request_irq(usb_iddig_number, mt_usb_ext_iddig_int, IRQF_TRIGGER_LOW, "USB_IDDIG", NULL);
	#endif
	if (ret > 0)
		pr_err("USB IDDIG IRQ LINE not available!!\n");
	else
		pr_debug("USB IDDIG IRQ LINE available!!\n");
#else
	u32 phy_id_pull = 0;

	phy_id_pull = __raw_readl(U2PHYDTM1);
	phy_id_pull |= ID_PULL_UP;
	__raw_writel(phy_id_pull, U2PHYDTM1);

	musb_writel(mtk_musb->mregs, USB_L1INTM, IDDIG_INT_STATUS|musb_readl(mtk_musb->mregs, USB_L1INTM));
#endif
}
Exemple #9
0
/**
 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
 *
 * @return - void. If request gpio fails then Flag KERN_ERR.
 */
static void ads7846_dev_init(void)
{
	if (gpio_request(ts_gpio, "ADS7846 pendown") < 0) {
		printk(KERN_ERR "can't get ads746 pen down GPIO\n");
		return;
	}

	gpio_direction_input(ts_gpio);
	gpio_set_debounce(ts_gpio, 310);
}
Exemple #10
0
static int tsc2004_init(void)
{
	int res;

	res = gpio_direction_input(10);

	gpio_set_debounce(10, 7900);

	return 1;
}
static void __init omap3_ads7846_init(void)
{
	if (gpio_request(OMAP3_TS_GPIO, "ads7846_pen_down")) {
		printk(KERN_ERR "Failed to request GPIO %d for "
				"ads7846 pen down IRQ\n", OMAP3_TS_GPIO);
		return;
	}

	gpio_direction_input(OMAP3_TS_GPIO);
	gpio_set_debounce(OMAP3_TS_GPIO, 310);
}
static void synaptics_dev_init(void)
{
	/* Set the ts_gpio pin mux */
	omap_mux_init_signal("gpio_163", OMAP_PIN_INPUT_PULLUP);

	if (gpio_request(OMAP_SYNAPTICS_GPIO, "touch") < 0) {
		printk(KERN_ERR "can't get synaptics pen down GPIO\n");
		return;
	}
	gpio_direction_input(OMAP_SYNAPTICS_GPIO);
	gpio_set_debounce(OMAP_SYNAPTICS_GPIO, 310);
}
static void hub_synaptics_dev_init(void)
{
	/* Set the ts_gpio pin mux */
	omap_mux_init_signal("gpio_35", OMAP_PIN_INPUT);

	if (gpio_request(HUB_TS_I2C_INT_GPIO, "touch") < 0) {
		printk(KERN_ERR "can't get synaptics pen down GPIO\n");
		return;
	}
	gpio_direction_input(HUB_TS_I2C_INT_GPIO);
//	omap_set_gpio_debounce(HUB_TS_I2C_INT_GPIO, 1);
//	omap_set_gpio_debounce_time(HUB_TS_I2C_INT_GPIO, 0xa);
	gpio_set_debounce(HUB_TS_I2C_INT_GPIO, 0xa);
}
/* This function will return:
 *  1) return :  Host gpio interrupt number per customer platform
 *  2) irq_flags_ptr : Type of Host interrupt as Level or Edge
 *
 *  NOTE :
 *  Customer should check his platform definitions
 *  and his Host Interrupt spec
 *  to figure out the proper setting for his platform.
 *  Broadcom provides just reference settings as example.
 *
 */
int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr)
{
	int  host_oob_irq = 0;

#if defined(CUSTOMER_HW2)
	host_oob_irq = wifi_get_irq_number(irq_flags_ptr);
#if defined(BOARD_INTEL)
	if (!wifi_irq_is_fastirq()) {
		if (gpio_request(host_oob_irq, "bcm43xx_irq") < 0) {
			WL_ERROR(("%s: Error on gpio_request bcm43xx_irq: %d\n", __func__, host_oob_irq));
			return 1;
		}
		if (gpio_direction_input(host_oob_irq) < 0) {
			WL_ERROR(("%s: Error on gpio_direction_input\n", __func__));
			return 1;
		}
		if (gpio_set_debounce(host_oob_irq, 0) < 0)
			WL_ERROR(("%s: Error on gpio_set_debounce\n", __func__));
		host_oob_irq = gpio_to_irq(host_oob_irq);
	}
#endif /* BOARD_INTEL */
#else
#if defined(CUSTOM_OOB_GPIO_NUM)
	if (dhd_oob_gpio_num < 0) {
		dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
	}
#endif /* CUSTOMER_OOB_GPIO_NUM */

	if (dhd_oob_gpio_num < 0) {
		WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
		__FUNCTION__));
		return (dhd_oob_gpio_num);
	}

	WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
	         __FUNCTION__, dhd_oob_gpio_num));

#if defined CUSTOMER_HW
	host_oob_irq = MSM_GPIO_TO_INT(dhd_oob_gpio_num);
#elif defined CUSTOMER_HW3
	gpio_request(dhd_oob_gpio_num, "oob irq");
	host_oob_irq = gpio_to_irq(dhd_oob_gpio_num);
	gpio_direction_input(dhd_oob_gpio_num);
#endif /* CUSTOMER_HW */
#endif 

	return (host_oob_irq);
}
// 20100619 [email protected] Hub touchscreen [START_LGE]
static void hub_synaptics_dev_init(void)
{
	/* Set the ts_gpio pin mux */
	omap_mux_init_signal("gpio_35", OMAP_PIN_INPUT);

	if (gpio_request(HUB_TS_I2C_INT_GPIO, "touch") < 0) {
		printk(KERN_ERR "can't get synaptics pen down GPIO\n");
		return;
	}
	gpio_direction_input(HUB_TS_I2C_INT_GPIO);
// [email protected] Fix the compilation error in 2.6.35 kernel [START]
//	omap_set_gpio_debounce(HUB_TS_I2C_INT_GPIO, 1);
//	omap_set_gpio_debounce_time(HUB_TS_I2C_INT_GPIO, 0xa);
	gpio_set_debounce(HUB_TS_I2C_INT_GPIO, 0xa);
// [email protected] Fix the compilation error in 2.6.35 kernel [END]
}
Exemple #16
0
static int wizard_tsc2004_init_irq(void)
{
	int ret = 0;

	ret = gpio_request(edm_external_gpio[wizard_tsc2004_gpio_index], "tsc2004-irq");
	if (ret < 0) {
		return ret;
	}

	if (gpio_direction_input(edm_external_gpio[wizard_tsc2004_gpio_index])) {
		return -ENXIO;
	}

	gpio_set_debounce(edm_external_gpio[wizard_tsc2004_gpio_index], 0x13565);
	return ret;
}
Exemple #17
0
/* This function will return:
 *  1) return :  Host gpio interrupt number per customer platform
 *  2) irq_flags_ptr : Type of Host interrupt as Level or Edge
 *
 *  NOTE :
 *  Customer should check his platform definitions
 *  and his Host Interrupt spec
 *  to figure out the proper setting for his platform.
 *  Broadcom provides just reference settings as example.
 *
 */
int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr)
{
	int  host_oob_irq = 0;

#if defined(CUSTOMER_HW2) || defined(CUSTOMER_HW4)
	host_oob_irq = wifi_platform_get_irq_number(adapter, irq_flags_ptr);
	if (!wifi_platform_irq_is_fastirq(adapter)) {
		if (gpio_request(host_oob_irq, "bcm43xx_irq") < 0) {
			WL_ERROR(("%s: Error on gpio_request bcm43xx_irq: %d\n", __func__, host_oob_irq));
			return -1;
		}
		if (gpio_direction_input(host_oob_irq) < 0) {
			WL_ERROR(("%s: Error on gpio_direction_input\n", __func__));
			return -1;
		}
		if (gpio_set_debounce(host_oob_irq, 0) < 0) {
			WL_ERROR(("%s: Error on gpio_set_debounce\n", __func__));
			return -1;
		}
		dhd_oob_gpio_num = host_oob_irq;
		host_oob_irq = gpio_to_irq(host_oob_irq);
	}
#else
#if defined(CUSTOM_OOB_GPIO_NUM)
	if (dhd_oob_gpio_num < 0) {
		dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
	}
#endif /* CUSTOMER_OOB_GPIO_NUM */

	if (dhd_oob_gpio_num < 0) {
		WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
		__FUNCTION__));
		return (dhd_oob_gpio_num);
	}

	WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
	         __FUNCTION__, dhd_oob_gpio_num));

#if defined CUSTOMER_HW3
	gpio_request(dhd_oob_gpio_num, "oob irq");
	host_oob_irq = gpio_to_irq(dhd_oob_gpio_num);
	gpio_direction_input(dhd_oob_gpio_num);
#endif /* CUSTOMER_HW3 */
#endif /* CUSTOMER_HW2 || CUSTOMER_HW4 */

	return (host_oob_irq);
}
Exemple #18
0
static int gpio_keys_setup_key(struct platform_device *pdev,
					 struct input_dev *input,
					 struct gpio_button_data *bdata,
					 const struct gpio_keys_button *button)
{
	int error;

	bdata->input = input;
	bdata->button = button;
	bdata->irq = button->irq;

	if(bdata->irq != M7X_HALL_IRQ_NUM) {
		atomic_set(&bdata->key_pressed, RELEASED);
	} else {
		atomic_set(&bdata->key_pressed, REMOVED);
	}

	mutex_init(&bdata->key_mutex);
	spin_lock_init(&bdata->lock);

	if (button->debounce_interval) {
		error = gpio_set_debounce(button->gpio,
				button->debounce_interval * 1000);
		/* use timer if gpiolib doesn't provide debounce */
		if (error < 0)
			bdata->timer_debounce =
				button->debounce_interval;
	}

	INIT_WORK(&bdata->work, gpio_keys_gpio_work_func);

#ifdef DELAYED_WORK
	INIT_DELAYED_WORK(&bdata->delayed_work, gpio_keys_gpio_delayed_work_func);
#endif
	setup_timer(&bdata->timer,
			    gpio_keys_gpio_timer, (unsigned long)bdata);



		if(bdata->irq != M7X_HALL_IRQ_NUM) {
			input_set_capability(input, button->type ?: EV_KEY, button->code);
		} else {
static int tsc2004_init_irq(void)
{
	int ret = 0;

	ret = gpio_request(GPIO_TSC2004_IRQ, "tsc2004-irq");
	if (ret < 0) {
		printk(KERN_WARNING "failed to request GPIO#%d: %d\n",
				GPIO_TSC2004_IRQ, ret);
		return ret;
	}

	if (gpio_direction_input(GPIO_TSC2004_IRQ)) {
		printk(KERN_WARNING "GPIO#%d cannot be configured as "
				"input\n", GPIO_TSC2004_IRQ);
		return -ENXIO;
	}

	gpio_set_debounce(GPIO_TSC2004_IRQ, 0xa);
	return ret;
}
int dhd_customer_oob_irq_unmap(void)
{
#if defined(CUSTOMER_HW2) || defined(CUSTOMER_HW4)
	int  host_oob_irq = 0;
	long unsigned int irq_flags_ptr;

	host_oob_irq = wifi_get_irq_number(&irq_flags_ptr);
	if (host_oob_irq < 0)
		WL_ERROR(("%s: wifi_get_irq_number returned %d\n",
				__func__, host_oob_irq));
	else {
		if (gpio_set_debounce(host_oob_irq, 1) < 0)
			WL_ERROR(("%s: Error on gpio_set_debounce\n",
				__func__));
		gpio_free(host_oob_irq);
	}
#endif

	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;
}
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2012.03.21]- When added to the board-ku5900-peripherals.c will be rollback.(TBD)
static void hub_synaptics_dev_init(void)
{
	int ret = -1;

	/* Set the ts_gpio pin mux */
//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2012.06.15] - DGMS - Touch not action in cpu-off mode status(OFF MDOE : Wakeup-enable / Input).
	ret = omap_mux_init_signal("gpio_35", OMAP_PIN_INPUT | OMAP_WAKEUP_EN | OMAP_OFFOUT_EN);
//	ret = omap_mux_init_signal("gpio_35", OMAP_PIN_INPUT);
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2012.06.15]- DGMS - Touch not action in cpu-off mode status(OFF MDOE : Wakeup-enable / Input).
	if(ret < 0)
		printk("[%s] omap3_mux_init_signal error [ret = %d]!\n", __func__, ret);

	if (gpio_request(HUB_TS_I2C_INT_GPIO, "touch") < 0) {
		printk(KERN_ERR "can't get synaptics pen down GPIO\n");
		return;
	}
	gpio_direction_input(HUB_TS_I2C_INT_GPIO);
// [email protected] Fix the compilation error in 2.6.35 kernel [START]
	gpio_set_debounce(HUB_TS_I2C_INT_GPIO, 0xa);
// [email protected] Fix the compilation error in 2.6.35 kernel [END]
}
Exemple #23
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;
}
Exemple #24
0
/**
 * @brief Kernel module entry point
 * Sets up all of the GPIOs and the button
 * interrupts
 *
 * @return returns 0 on success, -ENODEV if gpio isn't possible
 */
static int __init kcylon_init(void)
{
	int i, ret = 0;
	mutex_init(&button_level_mutex);
	button_level = 0;
	button_direction = -1;
	printk(KERN_INFO "KCYLON: Initializing kcylon module\n");
	for (i = 0; i < NUM_LEDS; i++) {
		if (!gpio_is_valid(led_pins[i])) {
			printk(KERN_INFO "KCYLON: LED pin %d (GPIO %d) is invalid\n", i + 1, led_pins[i]);
			return -ENODEV;
		}
		gpio_request(led_pins[i], "sysfs");
		gpio_direction_output(led_pins[i], false);
		gpio_export(led_pins[i], false);
	}
	gpio_request(button_pin, "sysfs");
	gpio_direction_input(button_pin);
	gpio_set_debounce(button_pin, 200);
	gpio_export(button_pin, false);

	irq_number = gpio_to_irq(button_pin);
	printk(KERN_INFO "KCYLON: The button %u is mapped to IRQ %d\n", button_pin, irq_number);

	if (request_irq(irq_number, (irq_handler_t) kcylon_irq_handler, IRQF_TRIGGER_RISING, "kcylon_button", NULL)) {
		printk(KERN_INFO "KCYLON: Couldn't create an interrupt handler for irq number %d\n", irq_number);
		ret = -1;
	}

	getnstimeofday(&ts_last);
	ts_diff = timespec_sub(ts_last, ts_last); /* zero out diff */

	task = kthread_run(cylon, NULL, "KCYLON_thread");
	if (IS_ERR(task)) {
		printk(KERN_ALERT "KCYLON: Failed to create the thread\n");
		ret = PTR_ERR(task);
	}
	return ret;
}
Exemple #25
0
/*!
 * This function is called whenever the SPI slave device is detected.
 *
 * @param	spi	the SPI slave device
 *
 * @return 	Returns 0 on SUCCESS and error on FAILURE.
 */
static int __devinit lcd_probe(struct device *dev)
{
	int ret = 0;
	int i;
	struct mxc_lcd_platform_data *plat = dev->platform_data;

	ch7036_VGA_enable(1);

	for (i = 0; i < num_registered_fb; i++) {
		if (strcmp(registered_fb[i]->fix.id, "DISP3 BG - DI1") == 0) {
			ret = lcd_init();
			if (ret < 0)
				goto err;
			//lcd_init_fb(registered_fb[i]);
			fb_show_logo(registered_fb[i], 0);
			//lcd_poweron(registered_fb[i]);
		}
	}

	fb_register_client(&nb);
	
	// -> [Walker Chen], 2014/01/29 - VGA reboot
	kthread_run(vga_reboot_thread, NULL, "VGA reboot");

	vga_gpio = irq_to_gpio(ch7036_client->irq);
	gpio_set_debounce( vga_gpio , 1000 ); //1000ms	
	irq_set_irq_wake( ch7036_client->irq , 1 );
	ret = request_irq(ch7036_client->irq, vga_reboot_interrupt,
			IRQF_TRIGGER_FALLING,
			 "ch7036 VGA_in", ch7036_client);
	enable_irq_wake(ch7036_client->irq);
	// <- End.
	
	return 0;
err:
	return ret;
}
/** @brief The LKM initialization function
 *  The static keyword restricts the visibility of the function to within this C file. The __init
 *  macro means that for a built-in driver (not a LKM) the function is only used at initialization
 *  time and that it can be discarded and its memory freed up after that point. In this example this
 *  function sets up the GPIOs and the IRQ
 *  @return returns 0 if successful
 */
static int __init ebbgpio_init(void) {
    int result = 0;
    printk(KERN_INFO "GPIO_TEST: Initializing the GPIO_TEST LKM\n");
    // Is the GPIO a valid GPIO number (e.g., the BBB has 4x32 but not all available)
    if (!gpio_is_valid(gpioLED)) {
        printk(KERN_INFO "GPIO_TEST: invalid LED GPIO\n");
        return -ENODEV;
    }
    // Going to set up the LED. It is a GPIO in output mode and will be on by default
    ledOn = true;
    gpio_request(gpioLED, "sysfs");          // gpioLED is hardcoded to 49, request it
    gpio_direction_output(gpioLED, ledOn);   // Set the gpio to be in output mode and on
// gpio_set_value(gpioLED, ledOn);          // Not required as set by line above (here for reference)
    gpio_export(gpioLED, false);             // Causes gpio49 to appear in /sys/class/gpio
    // the bool argument prevents the direction from being changed
    gpio_request(gpioButton, "sysfs");       // Set up the gpioButton
    gpio_direction_input(gpioButton);        // Set the button GPIO to be an input
    gpio_set_debounce(gpioButton, 200);      // Debounce the button with a delay of 200ms
    gpio_export(gpioButton, false);          // Causes gpio115 to appear in /sys/class/gpio
    // the bool argument prevents the direction from being changed
    // Perform a quick test to see that the button is working as expected on LKM load
    printk(KERN_INFO "GPIO_TEST: The button state is currently: %d\n", gpio_get_value(gpioButton));

    // GPIO numbers and IRQ numbers are not the same! This function performs the mapping for us
    irqNumber = gpio_to_irq(gpioButton);
    printk(KERN_INFO "GPIO_TEST: The button is mapped to IRQ: %d\n", irqNumber);

    // This next call requests an interrupt line
    result = request_irq(irqNumber,             // The interrupt number requested
                         (irq_handler_t) ebbgpio_irq_handler, // The pointer to the handler function below
                         IRQF_TRIGGER_RISING,   // Interrupt on rising edge (button press, not release)
                         "ebb_gpio_handler",    // Used in /proc/interrupts to identify the owner
                         NULL);                 // The *dev_id for shared interrupt lines, NULL is okay

    printk(KERN_INFO "GPIO_TEST: The interrupt request result is: %d\n", result);
    return result;
}
Exemple #27
0
static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
					 struct input_dev *input,
					 struct gpio_button_data *bdata,
					 const struct gpio_keys_button *button)
{
	const char *desc = button->desc ? button->desc : "gpio_keys";
	struct device *dev = &pdev->dev;
	irq_handler_t isr;
	unsigned long irqflags;
	int irq, error;

	bdata->input = input;
	bdata->button = button;
	spin_lock_init(&bdata->lock);

	if (gpio_is_valid(button->gpio)) {

		error = gpio_request(button->gpio, desc);
		if (error < 0) {
			dev_err(dev, "Failed to request GPIO %d, error %d\n",
				button->gpio, error);
			return error;
		}

		error = gpio_direction_input(button->gpio);
		if (error < 0) {
			dev_err(dev,
				"Failed to configure direction for GPIO %d, error %d\n",
				button->gpio, error);
			goto fail;
		}

		if (button->debounce_interval) {
			error = gpio_set_debounce(button->gpio,
					button->debounce_interval * 1000);
			/* use timer if gpiolib doesn't provide debounce */
			if (error < 0)
				bdata->timer_debounce =
						button->debounce_interval;
		}

		irq = gpio_to_irq(button->gpio);
		if (irq < 0) {
			error = irq;
			dev_err(dev,
				"Unable to get irq number for GPIO %d, error %d\n",
				button->gpio, error);
			goto fail;
		}
		bdata->irq = irq;

		INIT_WORK(&bdata->work, gpio_keys_gpio_work_func);
		setup_timer(&bdata->timer,
			    gpio_keys_gpio_timer, (unsigned long)bdata);

		isr = gpio_keys_gpio_isr;
		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;

	} else {
		if (!button->irq) {
			dev_err(dev, "No IRQ specified\n");
			return -EINVAL;
		}
		bdata->irq = button->irq;

		if (button->type && button->type != EV_KEY) {
			dev_err(dev, "Only EV_KEY allowed for IRQ buttons.\n");
			return -EINVAL;
		}

		bdata->timer_debounce = button->debounce_interval;
		setup_timer(&bdata->timer,
			    gpio_keys_irq_timer, (unsigned long)bdata);

		isr = gpio_keys_irq_isr;
		irqflags = 0;
	}

	input_set_capability(input, button->type ?: EV_KEY, button->code);

	/*
	 * If platform has specified that the button can be disabled,
	 * we don't want it to share the interrupt line.
	 */
	if (!button->can_disable)
		irqflags |= IRQF_SHARED;

	error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata);
	if (error < 0) {
		dev_err(dev, "Unable to claim irq %d; error %d\n",
			bdata->irq, error);
		goto fail;
	}

	return 0;

fail:
	if (gpio_is_valid(button->gpio))
		gpio_free(button->gpio);

	return error;
}
Exemple #28
0
static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
					 struct gpio_button_data *bdata,
					 struct gpio_keys_button *button)
{
	char *desc = button->desc ? button->desc : "gpio_keys";
	struct device *dev = &pdev->dev;
	unsigned long irqflags;
	int irq, error;

	setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata);
	INIT_WORK(&bdata->work, gpio_keys_work_func);

	error = gpio_request(button->gpio, desc);
	if (error < 0) {
		dev_err(dev, "failed to request GPIO %d, error %d\n",
			button->gpio, error);
		goto fail2;
	}

	error = gpio_direction_input(button->gpio);
	if (error < 0) {
		dev_err(dev, "failed to configure"
			" direction for GPIO %d, error %d\n",
			button->gpio, error);
		goto fail3;
	}

	if (button->debounce_interval) {
		error = gpio_set_debounce(button->gpio,
					  button->debounce_interval * 1000);
		/* use timer if gpiolib doesn't provide debounce */
		if (error < 0)
			bdata->timer_debounce = button->debounce_interval;
	}

	irq = gpio_to_irq(button->gpio);
	if (irq < 0) {
		error = irq;
		dev_err(dev, "Unable to get irq number for GPIO %d, error %d\n",
			button->gpio, error);
		goto fail3;
	}

	irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
	/*
	 * If platform has specified that the button can be disabled,
	 * we don't want it to share the interrupt line.
	 */
	if (!button->can_disable)
		irqflags |= IRQF_SHARED;

	error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
	if (error) {
		dev_err(dev, "Unable to claim irq %d; error %d\n",
			irq, error);
		goto fail3;
	}

	return 0;

fail3:
	gpio_free(button->gpio);
fail2:
	return error;
}
Exemple #29
0
static int gpio_keys_setup_key(struct platform_device *pdev,
				struct input_dev *input,
				struct gpio_button_data *bdata,
				const struct gpio_keys_button *button)
{
	const char *desc = button->desc ? button->desc : "gpio_keys";
	struct device *dev = &pdev->dev;
	irq_handler_t isr;
	unsigned long irqflags;
	int irq;
	int error;

	bdata->input = input;
	bdata->button = button;
	spin_lock_init(&bdata->lock);

	if (gpio_is_valid(button->gpio)) {

		error = devm_gpio_request_one(&pdev->dev, button->gpio,
					      GPIOF_IN, desc);
		if (error < 0) {
			dev_err(dev, "Failed to request GPIO %d, error %d\n",
				button->gpio, error);
			return error;
		}

		if (button->debounce_interval) {
			error = gpio_set_debounce(button->gpio,
					button->debounce_interval * 1000);
			/* use timer if gpiolib doesn't provide debounce */
			if (error < 0)
				bdata->software_debounce =
						button->debounce_interval;
		}

		if (button->irq) {
			bdata->irq = button->irq;
		} else {
			irq = gpio_to_irq(button->gpio);
			if (irq < 0) {
				error = irq;
				dev_err(dev,
					"Unable to get irq number for GPIO %d, error %d\n",
					button->gpio, error);
				return error;
			}
			bdata->irq = irq;
		}

		INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func);

		isr = gpio_keys_gpio_isr;
		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;

	} else {
		if (!button->irq) {
			dev_err(dev, "No IRQ specified\n");
			return -EINVAL;
		}
		bdata->irq = button->irq;

		if (button->type && button->type != EV_KEY) {
			dev_err(dev, "Only EV_KEY allowed for IRQ buttons.\n");
			return -EINVAL;
		}

		bdata->release_delay = button->debounce_interval;
		setup_timer(&bdata->release_timer,
			    gpio_keys_irq_timer, (unsigned long)bdata);

		isr = gpio_keys_irq_isr;
		irqflags = 0;
	}

	input_set_capability(input, button->type ?: EV_KEY, button->code);

	/*
	 * Install custom action to cancel release timer and
	 * workqueue item.
	 */
	error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata);
	if (error) {
		dev_err(&pdev->dev,
			"failed to register quiesce action, error: %d\n",
			error);
		return error;
	}

	/*
	 * If platform has specified that the button can be disabled,
	 * we don't want it to share the interrupt line.
	 */
	if (!button->can_disable)
		irqflags |= IRQF_SHARED;

	error = devm_request_any_context_irq(&pdev->dev, bdata->irq,
					     isr, irqflags, desc, bdata);
	if (error < 0) {
		dev_err(dev, "Unable to claim irq %d; error %d\n",
			bdata->irq, error);
		return error;
	}

	return 0;
}
static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
					 struct gpio_button_data *bdata,
					 struct gpio_keys_button *button)
{
	const char *desc = button->desc ? button->desc : "gpio_keys";
	struct device *dev = &pdev->dev;
	unsigned long irqflags;
	int irq, error;

	setup_timer(&bdata->timer, gpio_keys_timer, (unsigned long)bdata);
	INIT_WORK(&bdata->work, gpio_keys_work_func);

	error = gpio_request(button->gpio, desc);
	if (error < 0) {
		dev_err(dev, "failed to request GPIO %d, error %d\n",
			button->gpio, error);
		goto fail2;
	}

	error = gpio_direction_input(button->gpio);
	if (error < 0) {
		dev_err(dev, "failed to configure"
			" direction for GPIO %d, error %d\n",
			button->gpio, error);
		goto fail3;
	}

	if (button->debounce_interval) {
		error = gpio_set_debounce(button->gpio,
					  button->debounce_interval * 1000);
		/* use timer if gpiolib doesn't provide debounce */
		if (error < 0)
			bdata->timer_debounce = button->debounce_interval;
	}

	irq = gpio_to_irq(button->gpio);
	if (irq < 0) {
		error = irq;
		dev_err(dev, "Unable to get irq number for GPIO %d, error %d\n",
			button->gpio, error);
		goto fail3;
	}

	irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
	/*
	 * If platform has specified that the button can be disabled,
	 * we don't want it to share the interrupt line.
	 */
	if (!button->can_disable)
		irqflags |= IRQF_SHARED;
	/*
	 * Resume power key early during syscore instead of at device
	 * resume time.
	 * Some platform like Android need to konw the power key is pressed
	 * then to reume the other devcies
	 */
	if (button->wakeup)
		irqflags |= IRQF_NO_SUSPEND | IRQF_EARLY_RESUME;

	error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
	if (error < 0) {
		dev_err(dev, "Unable to claim irq %d; error %d\n",
			irq, error);
		goto fail3;
	}

	return 0;

fail3:
	gpio_free(button->gpio);
fail2:
	return error;
}