static unsigned int samsung_gpio_getcfg_2bit(struct samsung_gpio_chip *chip,
					     unsigned int off)
{
	u32 con;

	con = __raw_readl(chip->base);
	con >>= off * 2;
	con &= 3;

	/* this conversion works for IN and OUT as well as special mode */
	return S3C_GPIO_SPECIAL(con);
}
static unsigned samsung_gpio_getcfg_4bit(struct samsung_gpio_chip *chip,
					 unsigned int off)
{
	void __iomem *reg = chip->base;
	unsigned int shift = (off & 7) * 4;
	u32 con;

	if (off < 8 && chip->chip.ngpio > 8)
		reg -= 4;

	con = __raw_readl(reg);
	con >>= shift;
	con &= 0xf;

	/* this conversion works for IN and OUT as well as special mode */
	return S3C_GPIO_SPECIAL(con);
}
static void __init smdkv210_dm9000_set(void)
{
	unsigned int tmp;

	tmp = ((0<<28)|(0<<24)|(5<<16)|(0<<12)|(0<<8)|(0<<4)|(0<<0));
	__raw_writel(tmp, (S5P_SROM_BW+0x18));

	tmp = __raw_readl(S5P_SROM_BW);
	tmp &= ~(0xf << 20);

#ifdef CONFIG_DM9000_16BIT
	tmp |= (0x1 << 20);
#else
	tmp |= (0x2 << 20);
#endif
	__raw_writel(tmp, S5P_SROM_BW);

	/* Set SROM_CSn[5] */	
	tmp = ( __raw_readl(S5P_VA_GPIO+0x2E0) & ~(0xF<<20))|(0x2<<20); 
	/* Write MP0_1CON */	
	s3c_gpio_cfgpin(S5PV210_MP01(0),S3C_GPIO_SPECIAL(tmp));
}
Exemple #4
0
static int headset_switch_probe(struct platform_device *pdev)
{
	struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;
	struct v210_headset_switch_data *switch_data;
	int ret = 0;

	if (!pdata)
		return -EBUSY;

	switch_data = kzalloc(sizeof(struct v210_headset_switch_data), GFP_KERNEL);
	if (!switch_data)
		return -ENOMEM;

	switch_data->sdev.name = pdata->name;
	switch_data->gpio = HP_DETECT_PIN;
	switch_data->ear_jack_gpio = EAR_DETECT_PIN;
	switch_data->name_on = pdata->name_on;
	switch_data->name_off = pdata->name_off;
	switch_data->state_on = pdata->state_on;
	switch_data->state_off = pdata->state_off;
	switch_data->sdev.print_state = headset_switch_print_state;
	switch_data->set_micbias_state=sec_jack_set_micbias_state;
	
    	ret = switch_dev_register(&switch_data->sdev);
	if (ret < 0)
		goto err_switch_dev_register;

	ret = gpio_request(switch_data->gpio, HP_DETEST_IRQ);
	if (ret)
	    printk(KERN_ERR "#### failed to request GPH0-6 ");

	ret = gpio_request(switch_data->ear_jack_gpio, "EAR_DET_GPIO");
	if (ret)
	    printk(KERN_ERR "#### failed to request GPH0-3 ");
#if 0	 //mask 
	gpio_direction_input(switch_data->gpio);
	switch_data->irq = gpio_to_irq(switch_data->gpio);
#else
	#ifndef DOUBLE_IRQ_CHECK	
	 s3c_gpio_cfgpin(switch_data->ear_jack_gpio, S3C_GPIO_INPUT);
	 s3c_gpio_setpull(switch_data->ear_jack_gpio, S3C_GPIO_PULL_UP);
	#else
	s3c_gpio_cfgpin(switch_data->ear_jack_gpio, S3C_GPIO_SPECIAL(0x0f)); //Eint6
	s3c_gpio_setpull(switch_data->ear_jack_gpio, S3C_GPIO_PULL_UP);
	set_irq_type(EAR_ENIT_NUM, IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING);	
	#endif
//	s3c_gpio_cfgpin(switch_data->gpio, S3C_GPIO_INPUT);
	s3c_gpio_cfgpin(switch_data->gpio, S3C_GPIO_SPECIAL(0xf)); //Eint6
	s3c_gpio_setpull(switch_data->gpio, S3C_GPIO_PULL_NONE);
	set_irq_type(ENIT_NUM, IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING);

	switch_data->irq = ENIT_NUM;
	switch_data->ear_jack_irq = EAR_ENIT_NUM;
#endif
	gpio_set_debounce(switch_data->gpio, 100);
	gpio_set_debounce(switch_data->ear_jack_gpio, 143);

	SwitchData=switch_data;

	INIT_WORK(&switch_data->work, headset_switch_work);

	init_timer(&earphone_timer);
	earphone_timer.function = earphone_key_scan;
	 earphone_timer.expires = jiffies + EARPHONE_KEY_DETECT_INTERVAL;
	add_timer(&earphone_timer);

	
	INIT_WORK(&earphone_report_work, report_4pole_earphone);
	
		
	INIT_WORK(&delay_open_micbias, delay_micbias_open);


	ret = request_irq(switch_data->irq ,headset_irq_handler, IRQF_SHARED /*| IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING*/, switch_data->sdev.name, switch_data);
	if(ret < 0)
	{
		printk(KERN_ERR "%s(), IRQ%d not available", __func__, switch_data->irq);
		goto err_request_gpio;
	}

	#ifdef DOUBLE_IRQ_CHECK
	ret = request_irq(switch_data->ear_jack_irq ,headset_irq_handler, IRQF_SHARED, switch_data->sdev.name, switch_data);
	if(ret < 0)
	{
		printk(KERN_ERR "%s(), IRQ%d not available", __func__, switch_data->ear_jack_irq);
		goto err_request_gpio;
	}
	//enable_irq_wake(switch_data->irq);
	#endif
	
	/* Perform initial detection */
	headset_switch_work(&switch_data->work);

	return 0;

err_request_gpio:
    switch_dev_unregister(&switch_data->sdev);
err_switch_dev_register:
	kfree(switch_data);

	return ret;
}