Exemple #1
0
static int tda19989_open(struct inode *inode, struct file *filp)
{
	int rc;

	printk(KERN_DEBUG "tda19989_open\n");

	if (gDev == NULL) {
		printk(KERN_ERR "Invalid device\n");
		return -ENODEV;
	}

	mutex_lock(&gDev->mtx);

	gDev->exiting = false;

	gDev->waiter = false;
	init_waitqueue_head(&gDev->int_wait);

	gDev->pwr_enabled = false;
	rc = gpio_request(HDMI_PWR_EN_GPIO_NUM, "HDMI_PWR_EN");
	if (rc < 0) {
		printk(KERN_ERR "tda19989 GPIO Pwr On request error\n");
		rc = -EFAULT;
		goto failed;
	}
	gpio_direction_output(HDMI_PWR_EN_GPIO_NUM, 0);

	gDev->int_enabled = false;
	rc = gpio_request(HDMI_INT_PIN_GPIO_NUM, "HDMI_INT");
	if (rc < 0) {
		printk(KERN_ERR "tda19989 GPIO INT request error\n");
		rc = -EFAULT;
		goto failed_gpio;
	}
	gpio_direction_input(HDMI_INT_PIN_GPIO_NUM);
	set_irq_type(gpio_to_irq(HDMI_INT_PIN_GPIO_NUM),
						IRQ_TYPE_EDGE_FALLING);
	rc = request_irq(gpio_to_irq(HDMI_INT_PIN_GPIO_NUM), hdmi_int_irq,
					IRQF_TRIGGER_FALLING | IRQF_DISABLED,
					DEVICE_NAME, (void *)NULL);
	if (rc != 0) {
		printk(KERN_ERR	"tda19989 req irq err (%d)\n", rc);
		rc = -EFAULT;
		goto failed_irq;
	}
	disable_irq(OMAP_GPIO_IRQ(HDMI_INT_PIN_GPIO_NUM));

#ifdef TDA19989_CEC_AVAILABLE
	gDev->cec_regulator = regulator_get(NULL, "vwlan2");
	if (IS_ERR(gDev->cec_regulator)) {
		printk(KERN_ERR "cec get regulator failed\n");
		rc = -ENODEV;
		goto failed_irq;
	}
#endif

	gDev->cec_use_reg = false;

	gDev->int_occurred = false;

	mutex_unlock(&gDev->mtx);

	return 0;

failed_irq:
	gpio_free(HDMI_INT_PIN_GPIO_NUM);
failed_gpio:
	gpio_free(HDMI_PWR_EN_GPIO_NUM);
failed:
	mutex_unlock(&gDev->mtx);
	return rc;
}
static void __init ap4evb_init(void)
{
	u32 srcr4;
	struct clk *clk;

	sh7372_pinmux_init();

	/* enable SCIFA0 */
	gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
	gpio_request(GPIO_FN_SCIFA0_RXD, NULL);

	/* enable SMSC911X */
	gpio_request(GPIO_FN_CS5A,	NULL);
	gpio_request(GPIO_FN_IRQ6_39,	NULL);

	/* enable Debug switch (S6) */
	gpio_request(GPIO_PORT32, NULL);
	gpio_request(GPIO_PORT33, NULL);
	gpio_request(GPIO_PORT34, NULL);
	gpio_request(GPIO_PORT35, NULL);
	gpio_direction_input(GPIO_PORT32);
	gpio_direction_input(GPIO_PORT33);
	gpio_direction_input(GPIO_PORT34);
	gpio_direction_input(GPIO_PORT35);
	gpio_export(GPIO_PORT32, 0);
	gpio_export(GPIO_PORT33, 0);
	gpio_export(GPIO_PORT34, 0);
	gpio_export(GPIO_PORT35, 0);

	/* SDHI0 */
	gpio_request(GPIO_FN_SDHICD0, NULL);
	gpio_request(GPIO_FN_SDHIWP0, NULL);
	gpio_request(GPIO_FN_SDHICMD0, NULL);
	gpio_request(GPIO_FN_SDHICLK0, NULL);
	gpio_request(GPIO_FN_SDHID0_3, NULL);
	gpio_request(GPIO_FN_SDHID0_2, NULL);
	gpio_request(GPIO_FN_SDHID0_1, NULL);
	gpio_request(GPIO_FN_SDHID0_0, NULL);

	/* SDHI1 */
	gpio_request(GPIO_FN_SDHICMD1, NULL);
	gpio_request(GPIO_FN_SDHICLK1, NULL);
	gpio_request(GPIO_FN_SDHID1_3, NULL);
	gpio_request(GPIO_FN_SDHID1_2, NULL);
	gpio_request(GPIO_FN_SDHID1_1, NULL);
	gpio_request(GPIO_FN_SDHID1_0, NULL);

	/* MMCIF */
	gpio_request(GPIO_FN_MMCD0_0, NULL);
	gpio_request(GPIO_FN_MMCD0_1, NULL);
	gpio_request(GPIO_FN_MMCD0_2, NULL);
	gpio_request(GPIO_FN_MMCD0_3, NULL);
	gpio_request(GPIO_FN_MMCD0_4, NULL);
	gpio_request(GPIO_FN_MMCD0_5, NULL);
	gpio_request(GPIO_FN_MMCD0_6, NULL);
	gpio_request(GPIO_FN_MMCD0_7, NULL);
	gpio_request(GPIO_FN_MMCCMD0, NULL);
	gpio_request(GPIO_FN_MMCCLK0, NULL);

	/* USB enable */
	gpio_request(GPIO_FN_VBUS0_1,    NULL);
	gpio_request(GPIO_FN_IDIN_1_18,  NULL);
	gpio_request(GPIO_FN_PWEN_1_115, NULL);
	gpio_request(GPIO_FN_OVCN_1_114, NULL);
	gpio_request(GPIO_FN_EXTLP_1,    NULL);
	gpio_request(GPIO_FN_OVCN2_1,    NULL);

	/* setup USB phy */
	__raw_writew(0x8a0a, 0xE6058130);	/* USBCR2 */

	/* enable FSI2 */
	gpio_request(GPIO_FN_FSIAIBT,	NULL);
	gpio_request(GPIO_FN_FSIAILR,	NULL);
	gpio_request(GPIO_FN_FSIAISLD,	NULL);
	gpio_request(GPIO_FN_FSIAOSLD,	NULL);
	gpio_request(GPIO_PORT161,	NULL);
	gpio_direction_output(GPIO_PORT161, 0); /* slave */

	gpio_request(GPIO_PORT9, NULL);
	gpio_request(GPIO_PORT10, NULL);
	gpio_no_direction(GPIO_PORT9CR);  /* FSIAOBT needs no direction */
	gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */

	/* set SPU2 clock to 119.6 MHz */
	clk = clk_get(NULL, "spu_clk");
	if (!IS_ERR(clk)) {
		clk_set_rate(clk, clk_round_rate(clk, 119600000));
		clk_put(clk);
	}

	/* change parent of FSI A */
	clk = clk_get(NULL, "fsia_clk");
	if (!IS_ERR(clk)) {
		clk_register(&fsiackcr_clk);
		clk_set_parent(clk, &fsiackcr_clk);
		clk_put(clk);
	}

	/*
	 * set irq priority, to avoid sound chopping
	 * when NFS rootfs is used
	 *  FSI(3) > SMSC911X(2)
	 */
	intc_set_priority(IRQ_FSI, 3);

	i2c_register_board_info(0, i2c0_devices,
				ARRAY_SIZE(i2c0_devices));

	i2c_register_board_info(1, i2c1_devices,
				ARRAY_SIZE(i2c1_devices));

#ifdef CONFIG_AP4EVB_QHD
	/*
	 * QHD
	 */

	/* enable KEYSC */
	gpio_request(GPIO_FN_KEYOUT0, NULL);
	gpio_request(GPIO_FN_KEYOUT1, NULL);
	gpio_request(GPIO_FN_KEYOUT2, NULL);
	gpio_request(GPIO_FN_KEYOUT3, NULL);
	gpio_request(GPIO_FN_KEYOUT4, NULL);
	gpio_request(GPIO_FN_KEYIN0_136, NULL);
	gpio_request(GPIO_FN_KEYIN1_135, NULL);
	gpio_request(GPIO_FN_KEYIN2_134, NULL);
	gpio_request(GPIO_FN_KEYIN3_133, NULL);
	gpio_request(GPIO_FN_KEYIN4,     NULL);

	/* enable TouchScreen */
	set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW);

	tsc_device.irq = IRQ28;
	i2c_register_board_info(1, &tsc_device, 1);

	/* LCDC0 */
	lcdc_info.clock_source			= LCDC_CLK_PERIPHERAL;
	lcdc_info.ch[0].interface_type		= RGB24;
	lcdc_info.ch[0].clock_divider		= 1;
	lcdc_info.ch[0].flags			= LCDC_FLAGS_DWPOL;
	lcdc_info.ch[0].lcd_cfg.name		= "R63302(QHD)";
	lcdc_info.ch[0].lcd_cfg.xres		= 544;
	lcdc_info.ch[0].lcd_cfg.yres		= 961;
	lcdc_info.ch[0].lcd_cfg.left_margin	= 72;
	lcdc_info.ch[0].lcd_cfg.right_margin	= 600;
	lcdc_info.ch[0].lcd_cfg.hsync_len	= 16;
	lcdc_info.ch[0].lcd_cfg.upper_margin	= 8;
	lcdc_info.ch[0].lcd_cfg.lower_margin	= 8;
	lcdc_info.ch[0].lcd_cfg.vsync_len	= 2;
	lcdc_info.ch[0].lcd_cfg.sync		= FB_SYNC_VERT_HIGH_ACT |
						  FB_SYNC_HOR_HIGH_ACT;
	lcdc_info.ch[0].lcd_size_cfg.width	= 44;
	lcdc_info.ch[0].lcd_size_cfg.height	= 79;

	platform_add_devices(qhd_devices, ARRAY_SIZE(qhd_devices));

#else
	/*
	 * WVGA
	 */
	gpio_request(GPIO_FN_LCDD17,   NULL);
	gpio_request(GPIO_FN_LCDD16,   NULL);
	gpio_request(GPIO_FN_LCDD15,   NULL);
	gpio_request(GPIO_FN_LCDD14,   NULL);
	gpio_request(GPIO_FN_LCDD13,   NULL);
	gpio_request(GPIO_FN_LCDD12,   NULL);
	gpio_request(GPIO_FN_LCDD11,   NULL);
	gpio_request(GPIO_FN_LCDD10,   NULL);
	gpio_request(GPIO_FN_LCDD9,    NULL);
	gpio_request(GPIO_FN_LCDD8,    NULL);
	gpio_request(GPIO_FN_LCDD7,    NULL);
	gpio_request(GPIO_FN_LCDD6,    NULL);
	gpio_request(GPIO_FN_LCDD5,    NULL);
	gpio_request(GPIO_FN_LCDD4,    NULL);
	gpio_request(GPIO_FN_LCDD3,    NULL);
	gpio_request(GPIO_FN_LCDD2,    NULL);
	gpio_request(GPIO_FN_LCDD1,    NULL);
	gpio_request(GPIO_FN_LCDD0,    NULL);
	gpio_request(GPIO_FN_LCDDISP,  NULL);
	gpio_request(GPIO_FN_LCDDCK,   NULL);

	gpio_request(GPIO_PORT189, NULL); /* backlight */
	gpio_direction_output(GPIO_PORT189, 1);

	gpio_request(GPIO_PORT151, NULL); /* LCDDON */
	gpio_direction_output(GPIO_PORT151, 1);

	lcdc_info.clock_source			= LCDC_CLK_BUS;
	lcdc_info.ch[0].interface_type		= RGB18;
	lcdc_info.ch[0].clock_divider		= 2;
	lcdc_info.ch[0].flags			= 0;
	lcdc_info.ch[0].lcd_cfg.name		= "WVGA Panel";
	lcdc_info.ch[0].lcd_cfg.xres		= 800;
	lcdc_info.ch[0].lcd_cfg.yres		= 480;
	lcdc_info.ch[0].lcd_cfg.left_margin	= 220;
	lcdc_info.ch[0].lcd_cfg.right_margin	= 110;
	lcdc_info.ch[0].lcd_cfg.hsync_len	= 70;
	lcdc_info.ch[0].lcd_cfg.upper_margin	= 20;
	lcdc_info.ch[0].lcd_cfg.lower_margin	= 5;
	lcdc_info.ch[0].lcd_cfg.vsync_len	= 5;
	lcdc_info.ch[0].lcd_cfg.sync		= 0;
	lcdc_info.ch[0].lcd_size_cfg.width	= 152;
	lcdc_info.ch[0].lcd_size_cfg.height	= 91;

	/* enable TouchScreen */
	set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);

	tsc_device.irq = IRQ7;
	i2c_register_board_info(0, &tsc_device, 1);
#endif /* CONFIG_AP4EVB_QHD */

	sh7372_add_standard_devices();

	/* HDMI */
	gpio_request(GPIO_FN_HDMI_HPD, NULL);
	gpio_request(GPIO_FN_HDMI_CEC, NULL);

	/* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
#define SRCR4 0xe61580bc
	srcr4 = __raw_readl(SRCR4);
	__raw_writel(srcr4 | (1 << 13), SRCR4);
	udelay(50);
	__raw_writel(srcr4 & ~(1 << 13), SRCR4);

	platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices));
}
Exemple #3
0
static void insert_headset(void)
{
	int hook_key_status = 0;
	int rc = 0;
	unsigned long irq_flags;
	int need_update_path = 0;
	
	gpio_set_value(AUDIO_HEADSET_MIC_SHTDWN_N, 0);
	HEADSET_INFO("Turn on mic en");
	
	
	PM_LOG_EVENT(PM_LOG_ON, PM_LOG_AUTIO_MIC);
	
	msleep(headset_data.debounceDelay2);

	
	if( 1 == gpio_get_value(headset_data.jack_gpio))
	{
		HEADSET_INFO("Headset removed while detection\n");
		return;
	}
	

	hook_key_status = gpio_get_value(headset_data.hook_gpio);
	if ( 1 == hook_key_status )
	{
		
		g_headset_type = HSD_EAR_PHONE;
		
		gpio_set_value(AUDIO_HEADSET_MIC_SHTDWN_N, 1);
		HEADSET_INFO("Turn off mic en");
		
		
		PM_LOG_EVENT(PM_LOG_OFF, PM_LOG_AUTIO_MIC);

		if (headset_data.recover_chk_times > 0)
		{
			headset_data.recover_chk_times--;
			
			HEADSET_INFO("Start recover timer, recover_chk_times = %d", headset_data.recover_chk_times);
			queue_delayed_work(g_detection_work_queue,&cable_ins_det_work, (HZ/10));
		}
	}
	else
	{

		
		msleep(headset_data.debounceDelay1);
		
		if( 1 == gpio_get_value(headset_data.jack_gpio))
		{
			HEADSET_INFO("Headset removed while detection\n");
			return;
		}
		
		
		
		if ( g_headset_type == HSD_EAR_PHONE)
		{
			need_update_path = 1;
		}
		
		g_headset_type = HSD_HEADSET;
		if(1 == need_update_path)
		{
			
			
			
			
			
			HEADSET_INFO("need_update_path = 1, switch audio path to CAD_HW_DEVICE_ID_HEADSET_MIC ");
		}
		
		rc = set_irq_type(headset_data.hook_irq, IRQF_TRIGGER_HIGH);
		if (rc)
			HEADSET_ERR("Set hook key interrupt detection type as rising Fail!!!");
		
		if(HSD_IRQ_DISABLE == headset_data.hook_irq_status)
		{
			local_irq_save(irq_flags);
			
			enable_irq(headset_data.hook_irq);
			headset_data.hook_irq_status = HSD_IRQ_ENABLE;
			set_irq_wake(headset_data.hook_irq, 1);
			local_irq_restore(irq_flags);
		}
	}
	
	HEADSET_INFO("g_headset_type= %d", g_headset_type);
	
	rc = set_irq_type(headset_data.jack_irq, IRQF_TRIGGER_HIGH);
	if (rc)
		HEADSET_ERR(" change IRQ detection type as high active fail!!");

}
Exemple #4
0
static int tda19989_open(struct inode *inode, struct file *filp)
{
    int rc;
    struct res_handle *cec_rhandle;

    printk(KERN_DEBUG "tda19989_open\n");

    cec_rhandle = NULL;

    if (g_dev == NULL) {
        printk(KERN_ERR "Invalid device\n");
        return -ENODEV;
    }

    mutex_lock(&g_dev->mtx);

    /* We only support single open */
    if (g_dev->opened) {
        printk(KERN_ERR "Device already opened\n");
        rc = -EBUSY;
        goto failed;
    }

    g_dev->opened = true;

    g_dev->exiting = false;

    g_dev->waiter = false;
    init_waitqueue_head(&g_dev->int_wait);

    g_dev->pwr_enabled = false;
    rc = gpio_request(g_dev->pwr_en_gpio, "HDMI_PWR_EN");
    if (rc < 0) {
        printk(KERN_ERR "tda19989 GPIO Pwr On request error\n");
        rc = -EFAULT;
        goto failed;
    }
    gpio_direction_output(g_dev->pwr_en_gpio, 0);

    g_dev->int_enabled = false;
    rc = gpio_request(g_dev->int_gpio, "HDMI_INT");
    if (rc < 0) {
        printk(KERN_ERR "tda19989 GPIO INT request error\n");
        rc = -EFAULT;
        goto failed_gpio;
    }
    gpio_direction_input(g_dev->int_gpio);
    set_irq_type(gpio_to_irq(g_dev->int_gpio),
                 IRQ_TYPE_EDGE_FALLING);
    rc = request_irq(gpio_to_irq(g_dev->int_gpio), hdmi_int_irq,
                     IRQF_TRIGGER_FALLING | IRQF_DISABLED,
                     DEVICE_NAME, (void *)NULL);
    if (rc != 0) {
        printk(KERN_ERR	"tda19989 req irq err (%d)\n", rc);
        rc = -EFAULT;
        goto failed_irq;
    }
    disable_irq(OMAP_GPIO_IRQ(g_dev->int_gpio));

    g_dev->cec_in_use = false;
    if (g_dev->cec_reg_name[0] != 0) {
        g_dev->cec_reg = regulator_get(NULL, g_dev->cec_reg_name);
        if (IS_ERR(g_dev->cec_reg)) {
            printk(KERN_ERR "tda19989 cec get regulator failed\n");
            rc = -ENODEV;
            goto failed_irq;
        }
    }

    g_dev->int_occurred = false;

    mutex_unlock(&g_dev->mtx);

    return 0;

failed_irq:
    gpio_free(g_dev->int_gpio);
failed_gpio:
    gpio_free(g_dev->pwr_en_gpio);
failed:
    mutex_unlock(&g_dev->mtx);
    return rc;
}
Exemple #5
0
static int ams397g201_probe(struct device *dev)
{
    int ret = 0;
    struct regulator *r_lcd_1_8v, *r_lcd_3_0v, *r_lcd_1_1v;

   lcd.bl_dev =backlight_device_register("s5p_bl",dev,&lcd,&s5p_bl_ops, NULL);
   lcd.bl_dev->props.max_brightness = 255;
   
   SetLDIEnabledFlag(1);

   //For ESD test panel error
   setup_timer(&polling_timer, polling_ESD_timer_func, 0);
   mod_timer(&polling_timer,
   	jiffies + msecs_to_jiffies(5000));


#ifdef GAMMASET_CONTROL //for 1.9/2.2 gamma control from platform
	gammaset_class = class_create(THIS_MODULE, "gammaset");
	if (IS_ERR(gammaset_class))
		pr_err("Failed to create class(gammaset_class)!\n");

	switch_gammaset_dev = device_create(gammaset_class, NULL, 0, NULL, "switch_gammaset");
	if (IS_ERR(switch_gammaset_dev))
		pr_err("Failed to create device(switch_gammaset_dev)!\n");

	if (device_create_file(switch_gammaset_dev, &dev_attr_gammaset_file_cmd) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_gammaset_file_cmd.attr.name);

	if (device_create_file(switch_gammaset_dev, &dev_attr_lcd_update) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_lcd_update);

#endif

#ifdef ACL_ENABLE //ACL On,Off
	acl_class = class_create(THIS_MODULE, "aclset");
	if (IS_ERR(acl_class))
		pr_err("Failed to create class(acl_class)!\n");

	switch_aclset_dev = device_create(acl_class, NULL, 0, NULL, "switch_aclset");
	if (IS_ERR(switch_aclset_dev))
		pr_err("Failed to create device(switch_aclset_dev)!\n");

	if (device_create_file(switch_aclset_dev, &dev_attr_aclset_file_cmd) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_aclset_file_cmd.attr.name);
#endif   

   
#if 1		
        //TE interrupt pin ( GPF0_1 /GPF0_INT[1] ) enable filter
        s3c_gpio_int_flt(S5PV210_GPA0(0),1);
#define IRQ_TE_INT (IRQ_EINT_GROUP10_BASE+1) /* F0_1 */
	/* irq for TE signal *///sehun_test
	if (request_irq(/*S3C_GPIOINT(F0,1)*/IRQ_TE_INT, ams397g201_te_interrupt, IRQF_TRIGGER_RISING | IRQF_SHARED,
		    "te_signal", dev)) {
		dev_err(dev, "request_irq failed.\n");
		goto err_te_irq;
	}	

	#if 0
		/* irq for ESD signal */
		s3c_gpio_cfgpin(S5PV210_GPH1(2), S3C_GPIO_SFN(0xFF));
		s3c_gpio_setpull(S5PV210_GPH1(2), S3C_GPIO_PULL_DOWN);

		set_irq_type(LCD_ESD_INT, IRQ_TYPE_EDGE_RISING);
	        if( (ret = request_irq(LCD_ESD_INT, ams397g201_esd_irq_handler,IRQF_DISABLED , "LCD_ESD", NULL)) < 0 )
	        {
	            printk("%s, request_irq failed %d, ret= %d\n",__FUNCTION__, LCD_ESD_INT, ret );
	        }

		 disable_irq( LCD_ESD_INT);

	        mdelay(10);
			
		 enable_irq( LCD_ESD_INT);
	 #endif
#endif
	r_lcd_1_8v = regulator_get(dev, "vlcd");
	if (IS_ERR(r_lcd_1_8v)) {
		dev_err(dev, "failed to get regulator vlcd.\n");
		return -EINVAL;
	}

	r_lcd_1_1v = regulator_get(dev, "VMIPI_1.8V");
	if (IS_ERR(r_lcd_1_1v)) {
		dev_err(dev, "failed to get regulator VMIPI_1.8V.\n");
		return -EINVAL;
	}

	regulator_enable(r_lcd_1_1v);

	r_lcd_1_1v = regulator_get(dev, "VMIPI_1.1V");
	if (IS_ERR(r_lcd_1_1v)) {
		dev_err(dev, "failed to get regulator VMIPI_1.1V.\n");
		return -EINVAL;
	}
	regulator_enable(r_lcd_1_1v);

#if 0
	ret = regulator_set_voltage(r_lcd_1_8v, 1800000, 1800000);
	if(ret != 0) {
		printk(KERN_ERR "%s: Cannot set VLCD_1.8V\n", __func__);
		return -EINVAL;
	}

	ret = regulator_enable(r_lcd_1_8v);
	if (ret < 0) {
		printk(KERN_ERR "failed to enable regulator VLCD_1_8v.\n");
		return ret;
	}
#endif
	r_lcd_3_0v = regulator_get(dev, "vcc_lcd");
	if (IS_ERR(r_lcd_3_0v)) {
		dev_err(dev, "failed to get regulator vcc_lcd.\n");
		return -EINVAL;
	}

#if 0
	ret = regulator_set_voltage(r_lcd_3_0v, 3000000, 3000000);
	if(ret != 0) {
		printk(KERN_ERR "%s: Cannot set VLCD_3.0V\n", __func__);
		return -EINVAL;
	}

	ret = regulator_enable(r_lcd_3_0v);
	if (ret < 0) {
		printk(KERN_ERR "failed to enable regulator VLCD_3_0v.\n");
		return ret;
	}
#endif
#if 0 //@@
	/* lcd power on */
	if (ddi_pd->lcd_power_on)
		ddi_pd->lcd_power_on((void *) dev, 1);
	else
		dev_warn(dev, "lcd_power_on func is null.\n");

	mdelay(60);

	/* lcd reset */
	if (ddi_pd->lcd_reset)
		ddi_pd->lcd_reset();
	else
		dev_warn(dev, "lcd_reset func is null.\n");
#endif
	dev_info(dev, "ams397g201 lcd panel driver based on mipi-dsi has been probed.\n");

err_te_irq:

	return 0;
}
Exemple #6
0
static int __init arch_setup(void)
{
	struct clk *clk;

	/* register board specific self-refresh code */
	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
					SUSP_SH_RSTANDBY,
					&ecovec24_sdram_enter_start,
					&ecovec24_sdram_enter_end,
					&ecovec24_sdram_leave_start,
					&ecovec24_sdram_leave_end);

	/* enable STATUS0, STATUS2 and PDSTATUS */
	gpio_request(GPIO_FN_STATUS0, NULL);
	gpio_request(GPIO_FN_STATUS2, NULL);
	gpio_request(GPIO_FN_PDSTATUS, NULL);

	/* enable SCIFA0 */
	gpio_request(GPIO_FN_SCIF0_TXD, NULL);
	gpio_request(GPIO_FN_SCIF0_RXD, NULL);

	/* enable debug LED */
	gpio_request(GPIO_PTG0, NULL);
	gpio_request(GPIO_PTG1, NULL);
	gpio_request(GPIO_PTG2, NULL);
	gpio_request(GPIO_PTG3, NULL);
	gpio_direction_output(GPIO_PTG0, 0);
	gpio_direction_output(GPIO_PTG1, 0);
	gpio_direction_output(GPIO_PTG2, 0);
	gpio_direction_output(GPIO_PTG3, 0);
	__raw_writew((__raw_readw(PORT_HIZA) & ~(0x1 << 1)) , PORT_HIZA);

	/* enable SH-Eth */
	gpio_request(GPIO_PTA1, NULL);
	gpio_direction_output(GPIO_PTA1, 1);
	mdelay(20);

	gpio_request(GPIO_FN_RMII_RXD0,    NULL);
	gpio_request(GPIO_FN_RMII_RXD1,    NULL);
	gpio_request(GPIO_FN_RMII_TXD0,    NULL);
	gpio_request(GPIO_FN_RMII_TXD1,    NULL);
	gpio_request(GPIO_FN_RMII_REF_CLK, NULL);
	gpio_request(GPIO_FN_RMII_TX_EN,   NULL);
	gpio_request(GPIO_FN_RMII_RX_ER,   NULL);
	gpio_request(GPIO_FN_RMII_CRS_DV,  NULL);
	gpio_request(GPIO_FN_MDIO,         NULL);
	gpio_request(GPIO_FN_MDC,          NULL);
	gpio_request(GPIO_FN_LNKSTA,       NULL);

	/* enable USB */
	__raw_writew(0x0000, 0xA4D80000);
	__raw_writew(0x0000, 0xA4D90000);
	gpio_request(GPIO_PTB3,  NULL);
	gpio_request(GPIO_PTB4,  NULL);
	gpio_request(GPIO_PTB5,  NULL);
	gpio_direction_input(GPIO_PTB3);
	gpio_direction_output(GPIO_PTB4, 0);
	gpio_direction_output(GPIO_PTB5, 0);
	__raw_writew(0x0600, 0xa40501d4);
	__raw_writew(0x0600, 0xa4050192);

	if (gpio_get_value(GPIO_PTB3)) {
		printk(KERN_INFO "USB1 function is selected\n");
		usb1_common_device.name = "r8a66597_udc";
	} else {
		printk(KERN_INFO "USB1 host is selected\n");
		usb1_common_device.name = "r8a66597_hcd";
	}

	/* enable LCDC */
	gpio_request(GPIO_FN_LCDD23,   NULL);
	gpio_request(GPIO_FN_LCDD22,   NULL);
	gpio_request(GPIO_FN_LCDD21,   NULL);
	gpio_request(GPIO_FN_LCDD20,   NULL);
	gpio_request(GPIO_FN_LCDD19,   NULL);
	gpio_request(GPIO_FN_LCDD18,   NULL);
	gpio_request(GPIO_FN_LCDD17,   NULL);
	gpio_request(GPIO_FN_LCDD16,   NULL);
	gpio_request(GPIO_FN_LCDD15,   NULL);
	gpio_request(GPIO_FN_LCDD14,   NULL);
	gpio_request(GPIO_FN_LCDD13,   NULL);
	gpio_request(GPIO_FN_LCDD12,   NULL);
	gpio_request(GPIO_FN_LCDD11,   NULL);
	gpio_request(GPIO_FN_LCDD10,   NULL);
	gpio_request(GPIO_FN_LCDD9,    NULL);
	gpio_request(GPIO_FN_LCDD8,    NULL);
	gpio_request(GPIO_FN_LCDD7,    NULL);
	gpio_request(GPIO_FN_LCDD6,    NULL);
	gpio_request(GPIO_FN_LCDD5,    NULL);
	gpio_request(GPIO_FN_LCDD4,    NULL);
	gpio_request(GPIO_FN_LCDD3,    NULL);
	gpio_request(GPIO_FN_LCDD2,    NULL);
	gpio_request(GPIO_FN_LCDD1,    NULL);
	gpio_request(GPIO_FN_LCDD0,    NULL);
	gpio_request(GPIO_FN_LCDDISP,  NULL);
	gpio_request(GPIO_FN_LCDHSYN,  NULL);
	gpio_request(GPIO_FN_LCDDCK,   NULL);
	gpio_request(GPIO_FN_LCDVSYN,  NULL);
	gpio_request(GPIO_FN_LCDDON,   NULL);
	gpio_request(GPIO_FN_LCDLCLK,  NULL);
	__raw_writew((__raw_readw(PORT_HIZA) & ~0x0001), PORT_HIZA);

	gpio_request(GPIO_PTE6, NULL);
	gpio_request(GPIO_PTU1, NULL);
	gpio_request(GPIO_PTR1, NULL);
	gpio_request(GPIO_PTA2, NULL);
	gpio_direction_input(GPIO_PTE6);
	gpio_direction_output(GPIO_PTU1, 0);
	gpio_direction_output(GPIO_PTR1, 0);
	gpio_direction_output(GPIO_PTA2, 0);

	/* I/O buffer drive ability is high */
	__raw_writew((__raw_readw(IODRIVEA) & ~0x00c0) | 0x0080 , IODRIVEA);

	if (gpio_get_value(GPIO_PTE6)) {
		/* DVI */
		lcdc_info.clock_source			= LCDC_CLK_EXTERNAL;
		lcdc_info.ch[0].clock_divider		= 1;
		lcdc_info.ch[0].lcd_cfg			= ecovec_dvi_modes;
		lcdc_info.ch[0].num_cfg			= ARRAY_SIZE(ecovec_dvi_modes);

		gpio_set_value(GPIO_PTA2, 1);
		gpio_set_value(GPIO_PTU1, 1);
	} else {
		/* Panel */
		lcdc_info.clock_source			= LCDC_CLK_PERIPHERAL;
		lcdc_info.ch[0].clock_divider		= 2;
		lcdc_info.ch[0].lcd_cfg			= ecovec_lcd_modes;
		lcdc_info.ch[0].num_cfg			= ARRAY_SIZE(ecovec_lcd_modes);

		gpio_set_value(GPIO_PTR1, 1);

		/* FIXME
		 *
		 * LCDDON control is needed for Panel,
		 * but current sh_mobile_lcdc driver doesn't control it.
		 * It is temporary correspondence
		 */
		gpio_request(GPIO_PTF4, NULL);
		gpio_direction_output(GPIO_PTF4, 1);

		/* enable TouchScreen */
		i2c_register_board_info(0, &ts_i2c_clients, 1);
		set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
	}

	/* enable CEU0 */
	gpio_request(GPIO_FN_VIO0_D15, NULL);
	gpio_request(GPIO_FN_VIO0_D14, NULL);
	gpio_request(GPIO_FN_VIO0_D13, NULL);
	gpio_request(GPIO_FN_VIO0_D12, NULL);
	gpio_request(GPIO_FN_VIO0_D11, NULL);
	gpio_request(GPIO_FN_VIO0_D10, NULL);
	gpio_request(GPIO_FN_VIO0_D9,  NULL);
	gpio_request(GPIO_FN_VIO0_D8,  NULL);
	gpio_request(GPIO_FN_VIO0_D7,  NULL);
	gpio_request(GPIO_FN_VIO0_D6,  NULL);
	gpio_request(GPIO_FN_VIO0_D5,  NULL);
	gpio_request(GPIO_FN_VIO0_D4,  NULL);
	gpio_request(GPIO_FN_VIO0_D3,  NULL);
	gpio_request(GPIO_FN_VIO0_D2,  NULL);
	gpio_request(GPIO_FN_VIO0_D1,  NULL);
	gpio_request(GPIO_FN_VIO0_D0,  NULL);
	gpio_request(GPIO_FN_VIO0_VD,  NULL);
	gpio_request(GPIO_FN_VIO0_CLK, NULL);
	gpio_request(GPIO_FN_VIO0_FLD, NULL);
	gpio_request(GPIO_FN_VIO0_HD,  NULL);
	platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20);

	/* enable CEU1 */
	gpio_request(GPIO_FN_VIO1_D7,  NULL);
	gpio_request(GPIO_FN_VIO1_D6,  NULL);
	gpio_request(GPIO_FN_VIO1_D5,  NULL);
	gpio_request(GPIO_FN_VIO1_D4,  NULL);
	gpio_request(GPIO_FN_VIO1_D3,  NULL);
	gpio_request(GPIO_FN_VIO1_D2,  NULL);
	gpio_request(GPIO_FN_VIO1_D1,  NULL);
	gpio_request(GPIO_FN_VIO1_D0,  NULL);
	gpio_request(GPIO_FN_VIO1_FLD, NULL);
	gpio_request(GPIO_FN_VIO1_HD,  NULL);
	gpio_request(GPIO_FN_VIO1_VD,  NULL);
	gpio_request(GPIO_FN_VIO1_CLK, NULL);
	platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20);

	/* enable KEYSC */
	gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
	gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
	gpio_request(GPIO_FN_KEYOUT3,     NULL);
	gpio_request(GPIO_FN_KEYOUT2,     NULL);
	gpio_request(GPIO_FN_KEYOUT1,     NULL);
	gpio_request(GPIO_FN_KEYOUT0,     NULL);
	gpio_request(GPIO_FN_KEYIN0,      NULL);

	/* enable user debug switch */
	gpio_request(GPIO_PTR0, NULL);
	gpio_request(GPIO_PTR4, NULL);
	gpio_request(GPIO_PTR5, NULL);
	gpio_request(GPIO_PTR6, NULL);
	gpio_direction_input(GPIO_PTR0);
	gpio_direction_input(GPIO_PTR4);
	gpio_direction_input(GPIO_PTR5);
	gpio_direction_input(GPIO_PTR6);

#ifdef CONFIG_MFD_SH_MOBILE_SDHI
	/* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
	gpio_request(GPIO_FN_SDHI0CD,  NULL);
	gpio_request(GPIO_FN_SDHI0WP,  NULL);
	gpio_request(GPIO_FN_SDHI0CMD, NULL);
	gpio_request(GPIO_FN_SDHI0CLK, NULL);
	gpio_request(GPIO_FN_SDHI0D3,  NULL);
	gpio_request(GPIO_FN_SDHI0D2,  NULL);
	gpio_request(GPIO_FN_SDHI0D1,  NULL);
	gpio_request(GPIO_FN_SDHI0D0,  NULL);
	gpio_request(GPIO_PTB6, NULL);
	gpio_direction_output(GPIO_PTB6, 0);

#if !defined(CONFIG_MMC_SH_MMCIF)
	/* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
	gpio_request(GPIO_FN_SDHI1CD,  NULL);
	gpio_request(GPIO_FN_SDHI1WP,  NULL);
	gpio_request(GPIO_FN_SDHI1CMD, NULL);
	gpio_request(GPIO_FN_SDHI1CLK, NULL);
	gpio_request(GPIO_FN_SDHI1D3,  NULL);
	gpio_request(GPIO_FN_SDHI1D2,  NULL);
	gpio_request(GPIO_FN_SDHI1D1,  NULL);
	gpio_request(GPIO_FN_SDHI1D0,  NULL);
	gpio_request(GPIO_PTB7, NULL);
	gpio_direction_output(GPIO_PTB7, 0);

	/* I/O buffer drive ability is high for SDHI1 */
	__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
#endif /* CONFIG_MMC_SH_MMCIF */
#else
	/* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
	gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
	gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
	gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
	gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
	gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
	gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
	gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
	gpio_request(GPIO_PTY6, NULL); /* write protect */
	gpio_direction_input(GPIO_PTY6);
	gpio_request(GPIO_PTY7, NULL); /* card detect */
	gpio_direction_input(GPIO_PTY7);

	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
#endif

	/* enable Video */
	gpio_request(GPIO_PTU2, NULL);
	gpio_direction_output(GPIO_PTU2, 1);

	/* enable Camera */
	gpio_request(GPIO_PTA3, NULL);
	gpio_request(GPIO_PTA4, NULL);
	gpio_direction_output(GPIO_PTA3, 0);
	gpio_direction_output(GPIO_PTA4, 0);

	/* enable FSI */
	gpio_request(GPIO_FN_FSIMCKB,    NULL);
	gpio_request(GPIO_FN_FSIIBSD,    NULL);
	gpio_request(GPIO_FN_FSIOBSD,    NULL);
	gpio_request(GPIO_FN_FSIIBBCK,   NULL);
	gpio_request(GPIO_FN_FSIIBLRCK,  NULL);
	gpio_request(GPIO_FN_FSIOBBCK,   NULL);
	gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
	gpio_request(GPIO_FN_CLKAUDIOBO, NULL);

	/* set SPU2 clock to 83.4 MHz */
	clk = clk_get(NULL, "spu_clk");
	if (!IS_ERR(clk)) {
		clk_set_rate(clk, clk_round_rate(clk, 83333333));
		clk_put(clk);
	}

	/* change parent of FSI B */
	clk = clk_get(NULL, "fsib_clk");
	if (!IS_ERR(clk)) {
		/* 48kHz dummy clock was used to make sure 1/1 divide */
		clk_set_rate(&sh7724_fsimckb_clk, 48000);
		clk_set_parent(clk, &sh7724_fsimckb_clk);
		clk_set_rate(clk, 48000);
		clk_put(clk);
	}

	gpio_request(GPIO_PTU0, NULL);
	gpio_direction_output(GPIO_PTU0, 0);
	mdelay(20);

	/* enable motion sensor */
	gpio_request(GPIO_FN_INTC_IRQ1, NULL);
	gpio_direction_input(GPIO_FN_INTC_IRQ1);

	/* set VPU clock to 166 MHz */
	clk = clk_get(NULL, "vpu_clk");
	if (!IS_ERR(clk)) {
		clk_set_rate(clk, clk_round_rate(clk, 166000000));
		clk_put(clk);
	}

	/* enable IrDA */
	gpio_request(GPIO_FN_IRDA_OUT, NULL);
	gpio_request(GPIO_FN_IRDA_IN,  NULL);
	gpio_request(GPIO_PTU5, NULL);
	gpio_direction_output(GPIO_PTU5, 0);

#if defined(CONFIG_MMC_SH_MMCIF)
	/* enable MMCIF (needs DS2.6,7 set to OFF,ON) */
	gpio_request(GPIO_FN_MMC_D7, NULL);
	gpio_request(GPIO_FN_MMC_D6, NULL);
	gpio_request(GPIO_FN_MMC_D5, NULL);
	gpio_request(GPIO_FN_MMC_D4, NULL);
	gpio_request(GPIO_FN_MMC_D3, NULL);
	gpio_request(GPIO_FN_MMC_D2, NULL);
	gpio_request(GPIO_FN_MMC_D1, NULL);
	gpio_request(GPIO_FN_MMC_D0, NULL);
	gpio_request(GPIO_FN_MMC_CLK, NULL);
	gpio_request(GPIO_FN_MMC_CMD, NULL);
	gpio_request(GPIO_PTB7, NULL);
	gpio_direction_output(GPIO_PTB7, 0);

	/* I/O buffer drive ability is high for MMCIF */
	__raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
#endif

	/* enable I2C device */
	i2c_register_board_info(0, i2c0_devices,
				ARRAY_SIZE(i2c0_devices));

	i2c_register_board_info(1, i2c1_devices,
				ARRAY_SIZE(i2c1_devices));

#if defined(CONFIG_VIDEO_SH_VOU) || defined(CONFIG_VIDEO_SH_VOU_MODULE)
	/* VOU */
	gpio_request(GPIO_FN_DV_D15, NULL);
	gpio_request(GPIO_FN_DV_D14, NULL);
	gpio_request(GPIO_FN_DV_D13, NULL);
	gpio_request(GPIO_FN_DV_D12, NULL);
	gpio_request(GPIO_FN_DV_D11, NULL);
	gpio_request(GPIO_FN_DV_D10, NULL);
	gpio_request(GPIO_FN_DV_D9, NULL);
	gpio_request(GPIO_FN_DV_D8, NULL);
	gpio_request(GPIO_FN_DV_CLKI, NULL);
	gpio_request(GPIO_FN_DV_CLK, NULL);
	gpio_request(GPIO_FN_DV_VSYNC, NULL);
	gpio_request(GPIO_FN_DV_HSYNC, NULL);

	/* AK8813 power / reset sequence */
	gpio_request(GPIO_PTG4, NULL);
	gpio_request(GPIO_PTU3, NULL);
	/* Reset */
	gpio_direction_output(GPIO_PTG4, 0);
	/* Power down */
	gpio_direction_output(GPIO_PTU3, 1);

	udelay(10);

	/* Power up, reset */
	gpio_set_value(GPIO_PTU3, 0);

	udelay(10);

	/* Remove reset */
	gpio_set_value(GPIO_PTG4, 1);
#endif

	return platform_add_devices(ecovec_devices,
				    ARRAY_SIZE(ecovec_devices));
}
Exemple #7
0
static int __devinit xxs1500_pcmcia_probe(struct platform_device *pdev)
{
	struct xxs1500_pcmcia_sock *sock;
	struct resource *r;
	int ret, irq;

	sock = kzalloc(sizeof(struct xxs1500_pcmcia_sock), GFP_KERNEL);
	if (!sock)
		return -ENOMEM;

	ret = -ENODEV;

	/* 36bit PCMCIA Attribute area address */
	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-attr");
	if (!r) {
		dev_err(&pdev->dev, "missing 'pcmcia-attr' resource!\n");
		goto out0;
	}
	sock->phys_attr = r->start;

	/* 36bit PCMCIA Memory area address */
	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-mem");
	if (!r) {
		dev_err(&pdev->dev, "missing 'pcmcia-mem' resource!\n");
		goto out0;
	}
	sock->phys_mem = r->start;

	/* 36bit PCMCIA IO area address */
	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcmcia-io");
	if (!r) {
		dev_err(&pdev->dev, "missing 'pcmcia-io' resource!\n");
		goto out0;
	}
	sock->phys_io = r->start;


	/*
	 * PCMCIA client drivers use the inb/outb macros to access
	 * the IO registers.  Since mips_io_port_base is added
	 * to the access address of the mips implementation of
	 * inb/outb, we need to subtract it here because we want
	 * to access the I/O or MEM address directly, without
	 * going through this "mips_io_port_base" mechanism.
	 */
	sock->virt_io = (void *)(ioremap(sock->phys_io, IO_MAP_SIZE) -
				 mips_io_port_base);

	if (!sock->virt_io) {
		dev_err(&pdev->dev, "cannot remap IO area\n");
		ret = -ENOMEM;
		goto out0;
	}

	sock->socket.ops	= &xxs1500_pcmcia_operations;
	sock->socket.owner	= THIS_MODULE;
	sock->socket.pci_irq	= gpio_to_irq(GPIO_CARDIRQ);
	sock->socket.features	= SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
	sock->socket.map_size	= MEM_MAP_SIZE;
	sock->socket.io_offset	= (unsigned long)sock->virt_io;
	sock->socket.dev.parent	= &pdev->dev;
	sock->socket.resource_ops = &pccard_static_ops;

	platform_set_drvdata(pdev, sock);

	/* setup carddetect irq: use one of the 2 GPIOs as an
	 * edge detector.
	 */
	irq = gpio_to_irq(GPIO_CDA);
	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
	ret = request_irq(irq, cdirq, 0, "pcmcia_carddetect", sock);
	if (ret) {
		dev_err(&pdev->dev, "cannot setup cd irq\n");
		goto out1;
	}

	ret = pcmcia_register_socket(&sock->socket);
	if (ret) {
		dev_err(&pdev->dev, "failed to register\n");
		goto out2;
	}

	printk(KERN_INFO "MyCable XXS1500 PCMCIA socket services\n");

	return 0;

out2:
	free_irq(gpio_to_irq(GPIO_CDA), sock);
out1:
	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
out0:
	kfree(sock);
	return ret;
}
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer)
{
	int out, in;
	int pout;	// multikey
	int key_index;
	int gpio;
	unsigned int irq;
	struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer);
	struct gpio_event_matrix_info *mi = kp->keypad_info;
	unsigned gpio_keypad_flags = mi->flags;
	unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH);

	out = kp->current_output;
	if (out == mi->noutputs) {
		out = 0;
		kp->last_key_state_changed = kp->key_state_changed;
		kp->key_state_changed = 0;
		kp->some_keys_pressed = 0;
	} else {
		key_index = out * mi->ninputs;
		for (in = 0; in < mi->ninputs; in++, key_index++) {
			gpio = mi->input_gpios[in];
			if (gpio_get_value(gpio) ^ !polarity) {
				if (kp->some_keys_pressed < 3)
					kp->some_keys_pressed++;
				kp->key_state_changed |= !__test_and_set_bit(
						key_index, kp->keys_pressed);
			} else
				kp->key_state_changed |= __test_and_clear_bit(
						key_index, kp->keys_pressed);
		}
		gpio = mi->output_gpios[out];
		// multikey
		for( pout = 0; pout < mi->noutputs; pout++ )
		{
                       if( out != pout )
                               gpio_direction_output(mi->output_gpios[pout], !polarity);
		}

		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
			gpio_set_value(gpio, !polarity);
		else
			gpio_direction_input(gpio);
		out++;
	}
	kp->current_output = out;
	if (out < mi->noutputs) {
		gpio = mi->output_gpios[out];
		// multikey
		for( pout = 0; pout < mi->noutputs; pout++ )
                       if( out != pout )
                               gpio_direction_input(mi->output_gpios[pout]);

			
		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
			gpio_set_value(gpio, polarity);
		else
			gpio_direction_output(gpio, polarity);
		hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL);
		return HRTIMER_NORESTART;
	}
	if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) {
		if (kp->key_state_changed) {
			hrtimer_start(&kp->timer, mi->debounce_delay,
				      HRTIMER_MODE_REL);
			return HRTIMER_NORESTART;
		}
		kp->key_state_changed = kp->last_key_state_changed;
	}

#if defined(CONFIG_MACH_COOPER_BASE_KOR)
    if(long_key_state == LONG_KEY_CHECK_ACTIVE)
    {
      if(key_press_count++ > MAX_KEY_PRESS_COUNT)
      {
  			gpio_set_value(GPIO_KEY_SCAN, 0);  // kbc0
          gpio_direction_output(GPIO_KEY_SCAN, 0);

#if defined(CONFIG_MACH_JUNO_SKT) || defined(CONFIG_MACH_JUNO_KT)
 			gpio_set_value(GPIO_KEY_SCAN1, 0);  // kbc1
          gpio_direction_output(GPIO_KEY_SCAN1, 0);
#endif
          
          if(!gpio_get_value(GPIO_VOLUME_UP) && !gpio_get_value(GPIO_VOLUME_DOWN))
          {
              irq = gpio_to_irq(GPIO_VOLUME_UP);    			
              set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH);          
              irq = gpio_to_irq(GPIO_VOLUME_DOWN);    			
              set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH);
          }
          else if (!gpio_get_value(GPIO_VOLUME_UP)) // volume-up
          {
              irq = gpio_to_irq(GPIO_VOLUME_UP);    			
              set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH);
          }
          else if(!gpio_get_value(GPIO_VOLUME_DOWN))  // volume-down
          {
              irq = gpio_to_irq(GPIO_VOLUME_DOWN);    			
              set_irq_type(irq , IRQ_TYPE_LEVEL_HIGH);
          }    

      	   for (in = 0; in < mi->ninputs; in++)
      		  enable_irq(gpio_to_irq(mi->input_gpios[in]));
      	   wake_unlock(&kp->wake_lock);

      	   key_press_count = 0;
      	   long_key_state = LONG_KEY_PRESSED;
        
      	   return HRTIMER_NORESTART;        
      }
    }
#endif

	if (kp->key_state_changed) {
		if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS)
			remove_phantom_keys(kp);
		key_index = 0;
		for (out = 0; out < mi->noutputs; out++)
			for (in = 0; in < mi->ninputs; in++, key_index++)
				report_key(kp, key_index, out, in);
	}
	if (!kp->use_irq || kp->some_keys_pressed) {
		hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL);
		return HRTIMER_NORESTART;
	}

	/* No keys are pressed, reenable interrupt */
	for (out = 0; out < mi->noutputs; out++) {
		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
			gpio_set_value(mi->output_gpios[out], polarity);
		else
			gpio_direction_output(mi->output_gpios[out], polarity);
	}
	for (in = 0; in < mi->ninputs; in++)
		enable_irq(gpio_to_irq(mi->input_gpios[in]));
	wake_unlock(&kp->wake_lock);
	return HRTIMER_NORESTART;
}
static int gpio_keypad_request_irqs(struct gpio_kp *kp)
{
	int i;
	int err;
	unsigned int irq;
	unsigned long request_flags;
	struct gpio_event_matrix_info *mi = kp->keypad_info;

	switch (mi->flags & (GPIOKPF_ACTIVE_HIGH|GPIOKPF_LEVEL_TRIGGERED_IRQ)) {
	default:
		request_flags = IRQF_TRIGGER_FALLING;
		break;
	case GPIOKPF_ACTIVE_HIGH:
		request_flags = IRQF_TRIGGER_RISING;
		break;
	case GPIOKPF_LEVEL_TRIGGERED_IRQ:
		request_flags = IRQF_TRIGGER_LOW;
		break;
	case GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_ACTIVE_HIGH:
		request_flags = IRQF_TRIGGER_HIGH;
		break;
	}

	for (i = 0; i < mi->ninputs; i++) {
		err = irq = gpio_to_irq(mi->input_gpios[i]);
		if (err < 0)
			goto err_gpio_get_irq_num_failed;

#if !defined(CONFIG_MACH_COOPER_BASE_KOR) && (defined(CONFIG_MACH_COOPER) || defined(CONFIG_MACH_BENI) || defined(CONFIG_MACH_TASS))
		switch(mi->input_gpios[i])
		{
			case 41:
				Volume_Up_irq = irq;
				break;
				
			case 42:
				Volume_Down_irq = irq;
				break;
		}
#endif		
#if defined(CONFIG_MACH_LUCAS)
		switch(mi->input_gpios[i])
		{
			case 3:
				Volume_Up_irq = irq;
				Volume_Down_irq = irq;
				break;
		}
#endif		
		err = request_irq(irq, gpio_keypad_irq_handler, request_flags,
				  "gpio_kp", kp);
		if (err) {
			pr_err("gpiomatrix: request_irq failed for input %d, "
				"irq %d\n", mi->input_gpios[i], irq);
			goto err_request_irq_failed;
		}
#if !defined(CONFIG_MACH_LUCAS) || !defined(CONFIG_MACH_CALLISTO)/*&& !defined(CONFIG_MACH_TASS) */
//#ifndef CONFIG_MACH_LUCAS
		err = set_irq_wake(irq, 1);
		if (err) {
			pr_err("gpiomatrix: set_irq_wake failed for input %d, "
				"irq %d\n", mi->input_gpios[i], irq);
		}
#endif		
		disable_irq(irq);
		if (kp->disabled_irq) {
			kp->disabled_irq = 0;
			enable_irq(irq);
		}
	}
/*
#if defined(CONFIG_MACH_TASS) 
	err = set_irq_wake(gpio_to_irq(GPIO_KBC0), 1);
	if (err) 
	{
		pr_err("gpiomatrix: set_irq_wake failed for input %d, "	"irq %d\n", GPIO_KBC0, irq);
	}
#endif
*/
#if defined (CONFIG_MACH_LUCAS)
	err = set_irq_wake(gpio_to_irq(GPIO_KBR6), 1);
	if (err) 
	{
		pr_err("gpiomatrix: set_irq_wake failed for input %d, "	"irq %d\n", mi->input_gpios[i], irq);
	}
#elif defined (CONFIG_MACH_CALLISTO)
	err = set_irq_wake(gpio_to_irq(GPIO_KBR5), 1);	// hsil
	err = set_irq_wake(gpio_to_irq(GPIO_KBR6), 1);	// hsil
	err = set_irq_wake(gpio_to_irq(GPIO_VOL_UP), 1);	// hsil
#endif
	
//#ifndef CONFIG_MACH_LUCAS
#if defined (CONFIG_MACH_CALLISTO)
	// hsil
	set_irq_type(gpio_to_irq(GPIO_SLIDE), IRQ_TYPE_EDGE_BOTH);
	err = request_irq(gpio_to_irq(GPIO_SLIDE), slide_int_handler, IRQF_DISABLED, "slide_kp", kp);
	if (err)
	{
		printk("[SLIDE] request_irq failed for slide\n");
		goto err_request_irq_failed;
	}
	
	err = set_irq_wake(gpio_to_irq(GPIO_SLIDE), 1);
	if (err) 
		printk("[SLIDE] register wakeup source failed\n");
#else
	// for COOPER
	err = irq = gpio_to_irq(GPIO_POWERKEY);
	if (err < 0)
		goto err_gpio_get_irq_num_failed;
	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
	err = request_irq(irq, gpiokey_irq_handler, IRQF_DISABLED, "gpio_key", kp);
	if (err)
	{
		printk("[PWRKEY] request_irq failed for slide\n");
		goto err_request_irq_failed;
	}
	
	err = set_irq_wake(irq, 1);
	if (err) 
		printk("[PWRKEY] register wakeup source failed\n");

#if AUTO_POWER_ON_OFF_FLAG
	init_timer(&poweroff_keypad_timer);
	poweroff_keypad_timer.function = poweroff_keypad_timer_handler;
	poweroff_keypad_timer.data = (unsigned long)kp;
	poweroff_keypad_timer.expires = jiffies + 60*HZ;

	add_timer(&poweroff_keypad_timer);
#endif
#endif
	return 0;

	for (i = mi->noutputs - 1; i >= 0; i--) {
		free_irq(gpio_to_irq(mi->input_gpios[i]), kp);
err_request_irq_failed:
err_gpio_get_irq_num_failed:
		;
	}
	return err;
}
Exemple #10
0
void *smsspiphy_init(void *context,
	void (*smsspi_interruptHandler) (void *), void *intr_context)
{
  struct spiphy_dev_s *spiphy_dev;
  int ret;

  smsmdtv_dev = 0;

	spiphy_dev = kmalloc(sizeof(struct spiphy_dev_s), GFP_KERNEL);
	if (spiphy_dev == 0) {
		sms_err("malloc for spi_dev failed");
		goto err_malloc;
	}
	spiphy_dev->interruptHandler = smsspi_interruptHandler;
	spiphy_dev->intr_context     = intr_context;

  ret = spi_register_driver(&smsmdtv_driver);

	if (ret < 0 || smsmdtv_dev == 0) {
		sms_info("Cann't get SPI device\n");
		goto err_register;
  }

	spiphy_dev->dev      = smsmdtv_dev;


  /*spi_loop_test(slave);*/

  spiphy_dev->irq = gpio_to_irq(SMS_IRQ_GPIO);

  set_irq_type(spiphy_dev->irq, IRQ_TYPE_EDGE_RISING);
	ret = request_irq(spiphy_dev->irq, spibus_interrupt, \
		IRQF_TRIGGER_RISING|IRQF_DISABLED, "smsmdtv", spiphy_dev);

	if (ret < 0) {
		sms_info("Unable to request irq %d", ret);
		goto err_irq;
	}

	/* interrupt disable */
	disable_irq(gpio_to_irq(SMS_IRQ_GPIO));
	smsmdtv_int_enable_flag = INTERRUPT_DISABLE;
	printk(KERN_INFO "smsspiphy_init(): disable_irq\n");

	spiphy_dev->txpad = dma_alloc_coherent(NULL, TX_BUFFER_SIZE,
			&spiphy_dev->txpad_phy_addr,
			GFP_KERNEL|GFP_DMA);
	if (!spiphy_dev->txpad) {
    ret = -ENOMEM;
    goto err_txpad;
	}
  memset(spiphy_dev->txpad, 0xFF, TX_BUFFER_SIZE);


	PDEBUG("exiting\n");
	return spiphy_dev;

err_txpad:
  free_irq(spiphy_dev->irq, spiphy_dev);
err_irq:
  gpio_free(SMS_IRQ_GPIO);
  spi_unregister_driver(&smsmdtv_driver);
err_register:
  kfree(spiphy_dev);
err_malloc:
	return 0;
}
Exemple #11
0
int pollux_sdi_probe1(void)
{
	struct mmc_host 	*mmc;
	struct pollux_sdi_host 	*host;
	int ret = 0;
	struct resource *res;


	/* 
	 * Allocate memory space for host specific data structure 
	 */
	dprintk("sdi: 1\n");
	mmc = mmc_alloc_host(sizeof(struct pollux_sdi_host), &pbdev->dev);
	if (!mmc) {
		ret = -ENOMEM;
		goto probe_out;
	}
	
	printk(KERN_INFO "======================mmc: %p, private: %p, sizeof(private) = %d\n", mmc, &(mmc->private), sizeof(mmc->private) );


	/*
	 * Set host specific pointer to allocated space
	 */
	dprintk("sdi: 2\n");
	host = mmc_priv(mmc);
	
	printk(KERN_INFO "==================host: %p\n", host);


	/* 
	 * Initialize host specific data
	 */
	dprintk("sdi: 3\n");
	/* Set value of mmc structure */
	mmc->ops			= &pollux_sdi_ops;
	mmc->f_min			=   400000;
	mmc->f_max			= 33000000;
	mmc->caps			= MMC_CAP_4_BIT_DATA;	
		/*
		 * Set the maximum segment size.  Since we aren't doing DMA
		 * we are only limited by the data length register.
		 */
	mmc->max_seg_size	= 64 * 512;
	mmc->max_phys_segs	= 1;
	mmc->max_blk_size   = 2048;
	mmc->max_blk_count  = 64;
	mmc->ocr_avail = MMC_VDD_32_33;

	spin_lock_init( &host->complete_lock );

	/* 
	 * Set host specific structure 
	 */
	host->mmc				= mmc;
	host->dma				= 0;
	host->size				= 0;
	host->irq_cd			= 0;
	host->cd_state			= 0;
	host->clock				= 0;
	host->cd_state			= SD_INSERTED;
	host->readonly			= 0;
	host->bus_width 		= 0;
	
#if 0	
	aprintk("pdev.id = %d\n", pdev->id);
	host->channel           = 0; // sdmmc channel 0로 일단 세팅 
#else
	aprintk("pdev.id = %d\n", pbdev->id);
	host->channel           = pbdev->id; // sdmmc channel 0로 일단 세팅 
#endif	
	
	if( host->channel == 0 )
		strcpy(host->hname, POLLUX_SDI0_NAME);
	else
		strcpy(host->hname, POLLUX_SDI1_NAME);
	
	res = platform_get_resource(pbdev, IORESOURCE_MEM, 0); // MEM resource #0, Virtual memory of sdmmc base address
	if( res == 0 )
	{
		printk("POLLUX_SDI: error......get memory base resources\n");
		ret = -EINVAL;
		goto probe_out;
	}
	host->baseaddr = (u32)res->start;
	

	res = platform_get_resource(pbdev, IORESOURCE_IO, 0); // IO resource #0, card detection gpio number
	if( res == 0 )
	{
		printk("POLLUX_SDI: error......get resources 2\n");
		ret = -EINVAL;
		goto probe_out;
	}
	gprintk("cd gpio = %d\n", res->start );
	host->cdpin = (int)res->start;
	
	
	res = platform_get_resource(pbdev, IORESOURCE_IO, 1); // IO resource #1, write protection gpio number
	if( res == 0 )
	{
		printk("POLLUX_SDI: error......get resources 3\n");
		ret = -EINVAL;
		goto probe_out;
	}
	gprintk("wp gpio = %d\n", res->start );
	host->wppin = (int)res->start;


	/*
	 * Get SD/MMC controller IRQ
	 */
	dprintk("sdi: 5 \n");	
	host->irq = platform_get_irq(pbdev, 0);
	if (host->irq == 0) 
	{
		printk(KERN_INFO "failed to get interrupt resouce.\n");
		ret = -EINVAL;
		goto probe_out;
	}
	
	/*
	 * Initialize GPIO prototype.
	 * GPIO pin is used for card detection and write protection state detection 
	 */
	host->irq_cd = platform_get_irq(pbdev, 1);
	aprintk("SDI___________________IRQ_CD = %d\n", host->irq_cd );
	if( host->irq_cd == 0 ) 
	{
		printk(KERN_INFO "failed to get card detection interrupt resource.\n");
		ret = -EINVAL;
		goto probe_out;
	}


	/*
	 * Initialize SD controller prototype  from sdmmc.cpp of wince bsp
	 */
	
	MES_SDHC_Initialize(); //mes_sdhc.c 의 해당 레지스터 block 초기화 루틴, 두번 호출이 안되도록 세팅이 되어 있음.
	
#if 1	
	/*
	 * Initialize MP2530F SDI
	 */
	ret = sdmmc_init(host);
	if(ret != 0)
	{
		ret = -EINVAL;
		goto probe_out;
	}
#endif	

//return 0; // ghcstop for debugging



	/*
	 * Register handler for host interupt
	 */
	dprintk("sdi: 6 - SD IRQ number is %d\n", host->irq);
	if(request_irq(host->irq, pollux_sdi_irq, 0, POLLUX_SDI0_NAME, host)) 
	{
		printk(KERN_INFO "failed to request sdi interrupt.\n");
		ret = -ENOENT;
		goto probe_out;
	}


	/*
	 * Read current card state 
	 */

	host->readonly =  pollux_gpio_getpin(host->wppin); // low면 write protected, high면 write enable ==> low active
	host->cd_state = !pollux_gpio_getpin(host->cdpin); // low면 Inserted, high면 ejected. ==> 그러므로 !로 뒤집음
	
	
	gprintk("host->readonly = %d, host->cd_state = %d, pollux_get_gpio_func(host->cdpin) = %d\n", host->readonly, host->cd_state, pollux_get_gpio_func(host->cdpin) );

	/*
	 * Register interrupt handler for card detection 
	 */
	INIT_WORK(&host->card_detect_work, pollux_sdi_card_detect);
#if 1
	if( host->cd_state ) // inserted
		set_irq_type(host->irq_cd, IRQT_RISING);
	else
		set_irq_type( host->irq_cd, IRQT_FALLING);
		
		
	//if(request_irq(host->irq_cd, pollux_sdi_irq_cd, 0, POLLUX_SDI0_NAME, host)) 
	if(request_irq(host->irq_cd, pollux_sdi_irq_cd, 0, host->hname, host)) 
	{
		printk(KERN_WARNING "failed to request card detect interrupt.\n" );
		ret = -ENOENT;
		goto probe_free_irq;
	}
#endif


	/*
	 * Register MP2530F host driver
	 */
	dprintk("sdi: 8\n");
	if((ret = mmc_add_host(mmc)))
	{
		printk(KERN_INFO "failed to add mmc host.\n");
		goto free_resource;
	}

	platform_set_drvdata(pbdev, mmc);

	printk(KERN_INFO "initialization done.\n");
	
	
	//mmc_detect_change(host->mmc, 100); // number of jiffies to wait before queueing	

	return ret;

free_resource:
    free_irq(host->irq_cd, host);	/* unregister card detection interrupt handler */

probe_free_irq:
 	free_irq(host->irq, host);	/* unregister host controller interrupt handler */

probe_out:
	return ret;
}
static int __init pnx_gpio_probe(struct platform_device *pdev)
{
	int i,j;
	int gpio = 0;
	struct gpio_bank *bank;
	struct gpio_data *data = pdev->dev.platform_data;
	unsigned long flags;

	initialized = 1;

	printk(KERN_INFO "PNX GPIO\n");
	gpio_bank_desc = data->gpio_bank_desc;
	gpio_bank_count = data->nb_banks;

	for (i = 0; i < gpio_bank_count; i++) {
		int gpio_count = 32; /* 32 GPIO per bank */
		bank = &gpio_bank_desc[i];
		bank->reserved_map = 0; /* must always be initialized */
		spin_lock_init(&bank->lock);

		/* check if bank is managed by PNX GPIO driver */
		if ((bank->gpio_base != 0) && (bank->mux_base != 0)) {
		bank->chip.request = pnx_gpio_acquire;
		bank->chip.free = pnx_gpio_release;
		bank->chip.direction_input = gpio_input;
		bank->chip.get = gpio_get;
		bank->chip.direction_output = gpio_output;
		bank->chip.set = gpio_set;
		bank->chip.to_irq = gpio_2irq;
		bank->chip.label = "gpio";
		bank->chip.base = gpio;

		bank->chip.ngpio = gpio_count;

		gpiochip_add(&bank->chip);
		}
		gpio += gpio_count;
	}

#ifdef CONFIG_MODEM_BLACK_BOX
	/* set init value */
	printk(KERN_INFO "PNX GPIO initialize SCON\n");

	/* configure MUX and PAD settings */
	for (i = 0; i< SCON_REGISTER_NB; i++)
		__raw_writel(pnx_scon_init_config[i].scon_reg_value,
			     pnx_scon_init_config[i].scon_reg_addr);

	/* configure GPIO direction and value */
	for (i=0; i < gpio_to_configure; i++) {
		int index;

		bank = get_gpio_bank(pnx_gpio_init_config[i].gpio);
		index = get_gpio_index(pnx_gpio_init_config[i].gpio);
		_set_gpio_direction(bank, index, pnx_gpio_init_config[i].dir);
		_write_gpio_pin(bank, index, pnx_gpio_init_config[i].value);
	}

	/* reserve GPIO used by Modem */
	for (i = 0; i < pnx_modem_gpio_reserved_nb; i++) {
		int index;

		bank = get_gpio_bank(pnx_modem_gpio_reserved[i]);
		index = get_gpio_index(pnx_modem_gpio_reserved[i]);
		bank->reserved_map |= (1 << index);
	}

	/* configure EXTINT used by modem */
	for (i = 0; i< pnx_modem_extint_nb; i++)
		__raw_writel(pnx_extint_init_config[i].reg_value,
			     pnx_extint_init_config[i].reg_addr);

	printk(KERN_INFO "PNX GPIO Driver\n");
#endif

	/* for extint */
	for (j = IRQ_COUNT; j < IRQ_COUNT + NR_EXTINT; j++) {
		set_irq_chip(j, &gpio_irq_chip);
		set_irq_handler(j, handle_simple_irq);
		set_irq_flags(j, IRQF_VALID);
	}

	hw_raw_local_irq_save ( flags );
	/* mask all EXT IRQ sources before registring handler */
	/* read status */
	j = __raw_readl(EXTINT_STATUS_REG) & __raw_readl(EXTINT_ENABLE3_REG);
	/* clear IRQ source(s)*/
	__raw_writel(j, EXTINT_STATUS_REG);

	__raw_writel(0, EXTINT_ENABLE3_REG);

	/* set irq in low level */
	set_irq_type(IRQ_EXTINT3, IRQF_TRIGGER_LOW);

	/* chained GPIO-IRQ on EXTINT3 */
	set_irq_chained_handler(IRQ_EXTINT3, gpio_irq_handler);
	hw_raw_local_irq_restore ( flags );

	return 0;
}
Exemple #13
0
static int __devinit wl1271_probe(struct sdio_func *func,
				  const struct sdio_device_id *id)
{
	struct ieee80211_hw *hw;
	const struct wl12xx_platform_data *wlan_data;
	struct wl1271 *wl;
	int ret;

	/* We are only able to handle the wlan function */
	if (func->num != 0x02)
		return -ENODEV;

	hw = wl1271_alloc_hw();
	if (IS_ERR(hw))
		return PTR_ERR(hw);

	wl = hw->priv;

	wl->if_priv = func;
	wl->if_ops = &sdio_ops;

	/* Grab access to FN0 for ELP reg. */
	func->card->quirks |= MMC_QUIRK_LENIENT_FN0;

	wlan_data = wl12xx_get_platform_data();
	if (IS_ERR(wlan_data)) {
		ret = PTR_ERR(wlan_data);
		wl1271_error("missing wlan platform data: %d", ret);
		goto out_free;
	}

	wl->irq = wlan_data->irq;
	wl->ref_clock = wlan_data->board_ref_clock;

	ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
	if (ret < 0) {
		wl1271_error("request_irq() failed: %d", ret);
		goto out_free;
	}

	set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);

	disable_irq(wl->irq);

	ret = wl1271_init_ieee80211(wl);
	if (ret)
		goto out_irq;

	ret = wl1271_register_hw(wl);
	if (ret)
		goto out_irq;

	sdio_set_drvdata(func, wl);

	/* Tell PM core that we don't need the card to be powered now */
	pm_runtime_put_noidle(&func->dev);

	wl1271_notice("initialized");

	return 0;

 out_irq:
	free_irq(wl->irq, wl);


 out_free:
	wl1271_free_hw(wl);

	return ret;
}
Exemple #14
0
static int __devinit stm_rtc_probe(struct platform_device *pdev)
{
	struct stm_plat_rtc_lpc *plat_data;
	struct stm_rtc *rtc;
	struct resource *res;
	int size;
	int ret = 0;
	struct rtc_time tm_check;

	rtc = kzalloc(sizeof(struct stm_rtc), GFP_KERNEL);
	if (unlikely(!rtc))
		return -ENOMEM;

	spin_lock_init(&rtc->lock);
	plat_data = pdev->dev.platform_data;
	if (unlikely(plat_data == NULL)) {
		dev_err(&pdev->dev, "No platform data\n");
		ret = -ENOENT;
		goto err_badres;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (unlikely(res == NULL)) {
		dev_err(&pdev->dev, "No IO resource\n");
		ret = -ENOENT;
		goto err_badres;
	}

	size = res->end - res->start + 1;
	rtc->res = request_mem_region(res->start, size, pdev->name);
	if (!rtc->res) {
		ret = -EBUSY;
		goto err_badres;
	}

	rtc->ioaddr = ioremap_nocache(res->start, size);
	if (!rtc->ioaddr) {
		ret = -EINVAL;
		goto err_badmap;
	}

	if (plat_data->clk_id)
		rtc->clk = clk_get(&pdev->dev, plat_data->clk_id);
	else
		rtc->clk = clk_get(&pdev->dev, "lpc_clk");
	if (IS_ERR(rtc->clk)) {
		pr_err("clk lpc_clk not found\n");
		ret = PTR_ERR(rtc->clk);
		goto err_badreg;
	}
	clk_enable(rtc->clk);

	if (plat_data->force_clk_rate)
		clk_set_rate(rtc->clk, plat_data->force_clk_rate);

	pr_debug("%s: is using clk: %s @ %lu\n",
		DRV_NAME, rtc->clk->name, clk_get_rate(rtc->clk));

	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (!res) {
		pr_err("%s Request irq %d not done\n",
			__func__, res->start);
		return -ENODEV;
	}

	rtc->irq = res->start;
	set_irq_type(rtc->irq, plat_data->irq_edge_level);
	enable_irq_wake(rtc->irq);
	if (devm_request_irq(&pdev->dev, rtc->irq, stm_rtc_irq,
		IRQF_DISABLED, DRV_NAME, rtc) < 0){
		pr_err("%s: Request irq not done\n", __func__);
		return -ENODEV;
	}
	disable_irq(rtc->irq);

	device_set_wakeup_capable(&pdev->dev, 1);

	platform_set_drvdata(pdev, rtc);

	/*
	 * The RTC-LPC is able to manage date.year > 2038
	 * but currently the kernel can not manage this date!
	 * If the RTC-LPC has a date.year > 2038 then
	 * it's set to the epoch "Jan 1st 2000"
	 */
	stm_rtc_read_time(&pdev->dev, &tm_check);

	if (tm_check.tm_year >=  (2038 - 1900)) {
		memset(&tm_check, 0, sizeof(tm_check));
		tm_check.tm_year = 100;
		/*
		 * FIXME:
		 *   the 'tm_check.tm_mday' should be set to zero but the func-
		 *   tions rtc_tm_to_time and rtc_time_to_time aren't coherent.
		 */
		tm_check.tm_mday = 1;
		stm_rtc_set_time(&pdev->dev, &tm_check);
	}

	rtc->rtc_dev = rtc_device_register(DRV_NAME, &pdev->dev,
					   &stm_rtc_ops, THIS_MODULE);
	if (IS_ERR(rtc->rtc_dev)) {
		ret = PTR_ERR(rtc->rtc_dev);
		goto err_badreg;
	}

	return ret;

err_badreg:
	iounmap(rtc->ioaddr);
err_badmap:
	release_resource(rtc->res);
err_badres:
	kfree(rtc);

	platform_set_drvdata(pdev, NULL);
	return ret;
}
void universal_sdhci2_cfg_ext_cd(void)
{
	printk(KERN_DEBUG "Universal :SD Detect configuration\n");
	s3c_gpio_setpull(S5PV210_GPH3(4), S3C_GPIO_PULL_NONE);
	set_irq_type(IRQ_EINT(28), IRQ_TYPE_EDGE_BOTH);
}
Exemple #16
0
static int __devinit nas_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
	struct ts_nas *ts;
	struct nas_platform_data *pdata = pdata = client->dev.platform_data;
	struct input_dev *input_dev;
	int err;
	
	if (!pdata) {
		dev_err(&client->dev, "platform data is required!\n");
		return -EINVAL;
	}

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
		return -EIO;

	ts = kzalloc(sizeof(struct ts_nas), GFP_KERNEL);
	input_dev = input_allocate_device();
	if (!ts || !input_dev) {
		err = -ENOMEM;
		goto err_free_mem;
	}

	ts->client = client;
	ts->irq = client->irq;
	ts->input = input_dev;
	ts->status =0 ;// fjp add by 2010-9-30
	ts->pendown = 0; // fjp add by 2010-10-06

	ts->wq = create_rt_workqueue("nas_wq");
	INIT_DELAYED_WORK(&ts->work, nas_work);
	
#ifdef	CHECK_STATUS
	ts->wq1 = create_rt_workqueue("nas_wq1");
	INIT_DELAYED_WORK(&ts->work1, nas_status_check_work);
#endif	
	ts->model             = pdata->model;

	snprintf(ts->phys, sizeof(ts->phys),
		 "%s/input0", dev_name(&client->dev));

	input_dev->name = "nas Touchscreen";
	input_dev->phys = ts->phys;
	input_dev->id.bustype = BUS_I2C;

	ts->has_relative_report = 0;
	input_dev->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY)|BIT_MASK(EV_SYN);
	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	input_dev->keybit[BIT_WORD(BTN_2)] = BIT_MASK(BTN_2); //jaocbchen for dual
#if	0
	input_set_abs_params(input_dev, ABS_X, 0, CONFIG_HANNSTAR_MAX_X, 0, 0);
	input_set_abs_params(input_dev, ABS_Y, 0, CONFIG_HANNSTAR_MAX_Y, 0, 0);
	input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
	input_set_abs_params(input_dev, ABS_TOOL_WIDTH, 0, 15, 0, 0);
	input_set_abs_params(input_dev, ABS_HAT0X, 0, CONFIG_HANNSTAR_MAX_X, 0, 0);
	input_set_abs_params(input_dev, ABS_HAT0Y, 0, CONFIG_HANNSTAR_MAX_Y, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_POSITION_X,0, CONFIG_HANNSTAR_MAX_X, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, CONFIG_HANNSTAR_MAX_Y, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, 10, 0, 0);   
#else
	input_set_abs_params(input_dev, ABS_X, 0, TOUCH_REPORT_X_MAX, 0, 0);
	input_set_abs_params(input_dev, ABS_Y, 0, TOUCH_REPORT_Y_MAX, 0, 0);
	input_set_abs_params(input_dev, ABS_PRESSURE, 0, 1, 0, 0);
	input_set_abs_params(input_dev, ABS_HAT0X, 0, TOUCH_REPORT_X_MAX, 0, 0);
	input_set_abs_params(input_dev, ABS_HAT0Y, 0, TOUCH_REPORT_Y_MAX, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, TOUCH_REPORT_X_MAX, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, TOUCH_REPORT_Y_MAX, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);
#endif
	if (pdata->init_platform_hw)
		pdata->init_platform_hw();

	if (!ts->irq) {
		dev_dbg(&ts->client->dev, "no IRQ?\n");
		return -ENODEV;
	}else{
		ts->irq = gpio_to_irq(ts->irq);
	}
//miaozh modify
	err = request_irq(ts->irq, nas_irq, GPIOEdgelFalling,
			client->dev.driver->name, ts);
//	err = request_irq(ts->irq, nas_irq, 0,
//			client->dev.driver->name, ts);
	
	if (err < 0) {
		dev_err(&client->dev, "irq %d busy?\n", ts->irq);
		goto err_free_mem;
	}
	
	if (err < 0)
		goto err_free_irq;
#if 0
	err = set_irq_type(ts->irq,IRQ_TYPE_LEVEL_LOW);
	if (err < 0) {
		dev_err(&client->dev, "irq %d busy?\n", ts->irq);
		goto err_free_mem;
	}
	if (err < 0)
		goto err_free_irq;
#endif
	err = input_register_device(input_dev);
	if (err)
		goto err_free_irq;

	i2c_set_clientdata(client, ts);

	nas_check_firmwork(ts);
	
	nas_tp_debug_ctl_entry = create_proc_entry("nas_tp_debug_ctl", 0644, NULL);
	if (nas_tp_debug_ctl_entry) {
		nas_tp_debug_ctl_entry->read_proc = NULL;
		nas_tp_debug_ctl_entry->write_proc = nas_tp_debug_ctl;
	}
#ifdef CONFIG_HAS_EARLYSUSPEND
	register_early_suspend(&nastech_early_suspend);
#endif

#ifdef	CHECK_STATUS
	setup_timer(&ts->status_check_timer, nas_status_check_timer, (unsigned long)ts);
	ts->status_check_timer.expires  = jiffies + msecs_to_jiffies(1000);
	add_timer(&ts->status_check_timer);
#endif	
	return 0;

 err_free_irq:
	nas_free_irq(ts);
	if (pdata->exit_platform_hw)
		pdata->exit_platform_hw();
 err_free_mem:
	input_free_device(input_dev);
	kfree(ts);
	return err;
}
Exemple #17
0
static int __devinit ezx_pcap_probe(struct spi_device *spi)
{
	struct pcap_platform_data *pdata = spi->dev.platform_data;
	struct pcap_chip *pcap;
	int i, adc_irq;
	int ret = -ENODEV;

	/* platform data is required */
	if (!pdata)
		goto ret;

	pcap = kzalloc(sizeof(*pcap), GFP_KERNEL);
	if (!pcap) {
		ret = -ENOMEM;
		goto ret;
	}

	mutex_init(&pcap->io_mutex);
	mutex_init(&pcap->adc_mutex);
	INIT_WORK(&pcap->isr_work, pcap_isr_work);
	INIT_WORK(&pcap->msr_work, pcap_msr_work);
	dev_set_drvdata(&spi->dev, pcap);

	/* setup spi */
	spi->bits_per_word = 32;
	spi->mode = SPI_MODE_0 | (pdata->config & PCAP_CS_AH ? SPI_CS_HIGH : 0);
	ret = spi_setup(spi);
	if (ret)
		goto free_pcap;

	pcap->spi = spi;

	/* setup irq */
	pcap->irq_base = pdata->irq_base;
	pcap->workqueue = create_singlethread_workqueue("pcapd");
	if (!pcap->workqueue) {
		dev_err(&spi->dev, "cant create pcap thread\n");
		goto free_pcap;
	}

	/* redirect interrupts to AP, except adcdone2 */
	if (!(pdata->config & PCAP_SECOND_PORT))
		ezx_pcap_write(pcap, PCAP_REG_INT_SEL,
					(1 << PCAP_IRQ_ADCDONE2));

	/* setup irq chip */
	for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) {
		set_irq_chip_and_handler(i, &pcap_irq_chip, handle_simple_irq);
		set_irq_chip_data(i, pcap);
#ifdef CONFIG_ARM
		set_irq_flags(i, IRQF_VALID);
#else
		set_irq_noprobe(i);
#endif
	}

	/* mask/ack all PCAP interrupts */
	ezx_pcap_write(pcap, PCAP_REG_MSR, PCAP_MASK_ALL_INTERRUPT);
	ezx_pcap_write(pcap, PCAP_REG_ISR, PCAP_CLEAR_INTERRUPT_REGISTER);
	pcap->msr = PCAP_MASK_ALL_INTERRUPT;

	set_irq_type(spi->irq, IRQ_TYPE_EDGE_RISING);
	set_irq_data(spi->irq, pcap);
	set_irq_chained_handler(spi->irq, pcap_irq_handler);
	set_irq_wake(spi->irq, 1);

	/* ADC */
	adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ?
					PCAP_IRQ_ADCDONE2 : PCAP_IRQ_ADCDONE);

	ret = request_irq(adc_irq, pcap_adc_irq, 0, "ADC", pcap);
	if (ret)
		goto free_irqchip;

	/* setup subdevs */
	for (i = 0; i < pdata->num_subdevs; i++) {
		ret = pcap_add_subdev(pcap, &pdata->subdevs[i]);
		if (ret)
			goto remove_subdevs;
	}

	/* board specific quirks */
	if (pdata->init)
		pdata->init(pcap);

	return 0;

remove_subdevs:
	device_for_each_child(&spi->dev, NULL, pcap_remove_subdev);
/* free_adc: */
	free_irq(adc_irq, pcap);
free_irqchip:
	for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++)
		set_irq_chip_and_handler(i, NULL, NULL);
/* destroy_workqueue: */
	destroy_workqueue(pcap->workqueue);
free_pcap:
	kfree(pcap);
ret:
	return ret;
}
Exemple #18
0
static int asic2_probe(struct platform_device *pdev)
{
	int rc;
	struct asic2_platform_data *pdata = pdev->dev.platform_data;
	struct asic2_data *asic;

	asic = kmalloc(sizeof (struct asic2_data), GFP_KERNEL);
	if (!asic)
		goto enomem3;

	memset(asic, 0, sizeof (*asic));
	pdev->dev.driver_data = asic;

	asic->irq_base = pdata->irq_base;
	if (!asic->irq_base) {
		printk ("asic2: uninitialized irq_base!\n");
		goto enomem1;
	}

	asic->mapping = ioremap((unsigned long)pdev->resource[0].start, IPAQ_ASIC2_MAP_SIZE);
	if (!asic->mapping) {
		printk ("asic2: couldn't ioremap\n");
		goto enomem1;
	}
	spin_lock_init(&asic->gpio_lock);
	spin_lock_init(&asic->clock_lock);
	asic->clock_ex1 = asic->clock_ex2 = 0;
	asic2_irq_init(asic);

	asic->irq_nr = pdev->resource[1].start;

	printk ("%s: using irq %d-%d on irq %d\n", pdev->name, asic->irq_base,
		asic->irq_base + ASIC2_NR_IRQS - 1, asic->irq_nr);

	set_irq_chained_handler(asic->irq_nr, asic2_irq_demux);
	set_irq_type(asic->irq_nr, IRQT_RISING);
	set_irq_data(asic->irq_nr, asic);

	__asic2_write_register(asic, IPAQ_ASIC2_CLOCK_Enable, ASIC2_CLOCK_EX0);	/* 32 kHz crystal on */
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_ClockPrescale, ASIC2_INTCPS_SET);
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_ClockPrescale,
			       ASIC2_INTCPS_CPS(0x0e) | ASIC2_INTCPS_SET);
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_TimerSet, 1);
	__asic2_write_register(asic, IPAQ_ASIC2_INTR_MaskAndFlag, ASIC2_INTMASK_GLOBAL
				| ASIC2_INTMASK_UART_0 | ASIC2_INTMASK_UART_1 | ASIC2_INTMASK_TIMER);

	/* Set up GPIO */
	__asic2_write_register(asic, IPAQ_ASIC2_GPIOPIOD, GPIO2_IN_Y1_N | GPIO2_IN_X1_N);
	__asic2_write_register(asic, IPAQ_ASIC2_GPOBFSTAT, GPIO2_IN_Y1_N | GPIO2_IN_X1_N);
	__asic2_write_register(asic, IPAQ_ASIC2_GPIODIR, GPIO2_PEN_IRQ | GPIO2_SD_DETECT
				| GPIO2_EAR_IN_N | GPIO2_USB_DETECT_N | GPIO2_SD_CON_SLT);

	asic->ndevices = ARRAY_SIZE(asic2_blocks);
	asic->devices = soc_add_devices(pdev, asic2_blocks,
					ARRAY_SIZE(asic2_blocks),
					&pdev->resource[0], 0, asic->irq_base);
	if (!asic->devices)
		goto enomem;

	if (pdata && pdata->num_child_devs != 0) {
		int i;
		for (i = 0; i < pdata->num_child_devs; i++) {
			pdata->child_devs[i]->dev.parent = &pdev->dev;
			platform_device_register(pdata->child_devs[i]);
		}
	}

	return 0;

 enomem:
	rc = -ENOMEM;
 error:
	asic2_remove(pdev);
	return rc;
 enomem1:
	kfree(asic);
 enomem3:
	return -ENOMEM;
}
Exemple #19
0
/*
 * HPD interrupt handler
 *
 * Handles interrupt requests from HPD hardware.
 * Handler changes value of internal variable and notifies waiting thread.
 */
irqreturn_t s5p_hpd_irq_handler(int irq)
{
#ifdef USEEXTINT
	spin_lock_irq(&hpd_struct.lock);

	if (gpio_get_value(S5PV2XX_GPH1(5)))
		atomic_set(&hpd_struct.state, HPD_HI);
	else
		atomic_set(&hpd_struct.state, HPD_LO);

	if (atomic_read(&hpd_struct.state))
		set_irq_type(IRQ_EINT13, IRQ_TYPE_LEVEL_LOW);
	else
		set_irq_type(IRQ_EINT13, IRQ_TYPE_LEVEL_HIGH);

	spin_unlock_irq(&hpd_struct.lock);

	HPDIFPRINTK("hpd_status = %d\n", atomic_read(&hpd_struct.state));
#else
	u8 flag;
	int ret = IRQ_HANDLED;

	/* read flag register */
	flag = s5p_hdmi_get_interrupts();

	/* is this our interrupt? */

	if (!(flag & (1 << HDMI_IRQ_HPD_PLUG | 1 << HDMI_IRQ_HPD_UNPLUG))) {
		ret = IRQ_NONE;
		goto out;
	}

	/* workaround: ignore HPD IRQ caused by reseting HDCP engine */
	if (s5p_hdmi_get_swhpd_status()) {
		s5p_hdmi_swhpd_disable();
		/* clear pending bit */
		s5p_hdmi_clear_pending(HDMI_IRQ_HPD_UNPLUG);
		s5p_hdmi_clear_pending(HDMI_IRQ_HPD_PLUG);
		ret = IRQ_HANDLED;
		goto out;
	}

	if (flag == (1 << HDMI_IRQ_HPD_PLUG | 1 << HDMI_IRQ_HPD_UNPLUG)) {
		HPDIFPRINTK("HPD_HI && HPD_LO\n");

		if (last_hpd_state == HPD_HI && s5p_hdmi_get_hpd_status())
			flag = 1 << HDMI_IRQ_HPD_UNPLUG;
		else
			flag = 1 << HDMI_IRQ_HPD_PLUG;
	}

	if (flag & (1 << HDMI_IRQ_HPD_PLUG)) {
		HPDIFPRINTK("HPD_HI\n");
		/* clear pending bit */
		s5p_hdmi_clear_pending(HDMI_IRQ_HPD_PLUG);
		s5p_hdmi_clear_pending(HDMI_IRQ_HPD_UNPLUG);
		atomic_set(&hpd_struct.state, HPD_HI);
		/* workaround: enable HDMI_IRQ_HPD_UNPLUG interrupt */
		s5p_hdmi_disable_interrupts(HDMI_IRQ_HPD_PLUG);
		s5p_hdmi_enable_interrupts(HDMI_IRQ_HPD_UNPLUG);
		last_hpd_state = HPD_HI;
		wake_up_interruptible(&hpd_struct.waitq);
	} else if (flag & (1 << HDMI_IRQ_HPD_UNPLUG)) {
		HPDIFPRINTK("HPD_LO\n");
		/* clear pending bit */
		s5p_hdmi_clear_pending(HDMI_IRQ_HPD_PLUG);
		s5p_hdmi_clear_pending(HDMI_IRQ_HPD_UNPLUG);
		atomic_set(&hpd_struct.state, HPD_LO);
		/* workaround: disable HDMI_IRQ_HPD_UNPLUG interrupt */
		last_hpd_state = HPD_LO;
		s5p_hdmi_disable_interrupts(HDMI_IRQ_HPD_UNPLUG);
		s5p_hdmi_enable_interrupts(HDMI_IRQ_HPD_PLUG);
		wake_up_interruptible(&hpd_struct.waitq);
	}

#endif

out:
	return IRQ_HANDLED;
}
Exemple #20
0
static void __init gta02_machine_init(void)
{
	int rc;

	/* set the panic callback to make AUX blink fast */
	panic_blink = gta02_panic_blink;

	switch (S3C_SYSTEM_REV_ATAG) {
	case GTA02v6_SYSTEM_REV:
		/* we need push-pull interrupt from motion sensors */
		lis302_pdata_top.open_drain = 0;
		lis302_pdata_bottom.open_drain = 0;
		break;
	default:
		break;
	}

	spin_lock_init(&motion_irq_lock);

#ifdef CONFIG_CHARGER_PCF50633
	INIT_DELAYED_WORK(&gta02_charger_work, gta02_charger_worker);
#endif

	/* Glamo chip select optimization */
/*	 *((u32 *)(S3C2410_MEMREG(((1 + 1) << 2)))) = 0x1280; */

	/* do not force soft ecc if we are asked to use hardware_ecc */
	if (hardware_ecc_str[0] == '1')
		gta02_nand_info.software_ecc = 0;

	s3c_device_usb.dev.platform_data = &gta02_usb_info;
	s3c_device_nand.dev.platform_data = &gta02_nand_info;
	s3c_device_sdi.dev.platform_data = &gta02_s3c_mmc_cfg;

	/* acc sensor chip selects */
	s3c2410_gpio_setpin(S3C2410_GPD12, 1);
	s3c2410_gpio_cfgpin(S3C2410_GPD12, S3C2410_GPIO_OUTPUT);
	s3c2410_gpio_setpin(S3C2410_GPD13, 1);
	s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPIO_OUTPUT);

	s3c24xx_udc_set_platdata(&gta02_udc_cfg);
	s3c_i2c0_set_platdata(NULL);
	set_s3c2410ts_info(&gta02_ts_cfg);
	
	mangle_glamo_res_by_system_rev();

	i2c_register_board_info(0, gta02_i2c_devs, ARRAY_SIZE(gta02_i2c_devs));
	spi_register_board_info(gta02_spi_board_info,
				ARRAY_SIZE(gta02_spi_board_info));

#ifdef CONFIG_CHARGER_PCF50633
	mangle_pmu_pdata_by_system_rev();
#endif

	platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));

	s3c_pm_init();

	/* Make sure the modem can wake us up */
	set_irq_type(GTA02_IRQ_MODEM, IRQ_TYPE_EDGE_RISING);
	rc = request_irq(GTA02_IRQ_MODEM, gta02_modem_irq, IRQF_DISABLED,
			 "modem", NULL);
	if (rc < 0)
		printk(KERN_ERR "GTA02: can't request GSM modem wakeup IRQ\n");
	enable_irq_wake(GTA02_IRQ_MODEM);

	/* Make sure the wifi module can wake us up*/
	set_irq_type(GTA02_IRQ_WLAN_GPIO1, IRQ_TYPE_EDGE_RISING);
	rc = request_irq(GTA02_IRQ_WLAN_GPIO1, ar6000_wow_irq, IRQF_DISABLED,
			"ar6000", NULL);

	if (rc < 0)
		printk(KERN_ERR "GTA02: can't request ar6k wakeup IRQ\n");
	enable_irq_wake(GTA02_IRQ_WLAN_GPIO1);

	pm_power_off = gta02_poweroff;

	/* Register the HDQ and vibrator as children of pwm device */
#ifdef CONFIG_HDQ_GPIO_BITBANG
	gta02_hdq_device.dev.parent = &s3c24xx_pwm_device.dev;
	platform_device_register(&gta02_hdq_device);
#endif
#ifdef CONFIG_LEDS_GTA02_VIBRATOR
	gta02_vibrator_dev.dev.parent = &s3c24xx_pwm_device.dev; 
	platform_device_register(&gta02_vibrator_dev);
#endif
}
Exemple #21
0
static int __devinit charger_probe( struct platform_device *pdev )
// ----------------------------------------------------------------------------
// Description    : probe function for charger driver.
// Input Argument : 
// Return Value   : 
{

	int ret = 0;
	int irq = 0;
	struct charger_driver_info *di;
	
	printk( "[TA] Charger probe...\n" );

	sec_bci = get_sec_bci();

	di = kzalloc( sizeof(*di), GFP_KERNEL );
	if (!di)
		return -ENOMEM;

	platform_set_drvdata( pdev, di );
	di->dev = &pdev->dev;
	device_config = pdev->dev.platform_data;

	/* printk( "%d, %d, %d\n ",
			device_config->VF_CHECK_USING_ADC,
			device_config->VF_ADC_PORT,
			device_config->SUPPORT_CHG_ING_IRQ);*/

	this_dev = &pdev->dev; 

	/*Init Work*/
	INIT_DELAYED_WORK( &di->cable_detection_work, cable_detection_work_handler );
	INIT_DELAYED_WORK( &di->full_charge_work, full_charge_work_handler );

// [ USE_REGULATOR
	di->usb3v1 = regulator_get( &pdev->dev, "usb3v1" );
	if( IS_ERR( di->usb3v1 ) )
		goto fail_regulator1;

	di->usb1v8 = regulator_get( &pdev->dev, "usb1v8" );
	if( IS_ERR( di->usb1v8 ) )
		goto fail_regulator2;

	di->usb1v5 = regulator_get( &pdev->dev, "usb1v5" );
	if( IS_ERR( di->usb1v5 ) )
		goto fail_regulator3;
// ]

	/*Request charger interface interruption*/

#ifndef CONFIG_USB_SWITCH_FSA9480
#ifdef USE_DISABLE_CONN_IRQ
#ifdef MANAGE_CONN_IRQ
	is_enabling_conn_irq = false;
#endif
#endif

	KUSB_CONN_IRQ = platform_get_irq( pdev, 0 );
	if ( KUSB_CONN_IRQ ) // if this irq was null, we use ta_nconnected gpio to detect cable.
	{
		set_irq_type( KUSB_CONN_IRQ, IRQ_TYPE_EDGE_BOTH );
		ret = request_irq( KUSB_CONN_IRQ, cable_detection_isr, 
				IRQF_DISABLED | IRQF_SHARED, pdev->name, di );
		if ( ret )
		{
			printk( "[TA] 1. could not request irq %d, status %d\n", KUSB_CONN_IRQ, ret );
			goto usb_irq_fail;
		}
#ifdef USE_DISABLE_CONN_IRQ
		disable_irq( KUSB_CONN_IRQ );
#endif
	}
	else
#endif
	{
		sec_bci->charger.use_ta_nconnected_irq = true;
	}

	KTA_NCONN_IRQ = platform_get_irq( pdev, 1 );

	if ( sec_bci->charger.use_ta_nconnected_irq )
		KTA_NCONN_GPIO = irq_to_gpio( KTA_NCONN_IRQ );

#ifndef CONFIG_USB_SWITCH_FSA9480
#ifdef USE_IRQ_LEVEL_TRIGGER
	if(KTA_NCONN_GPIO) {
		if ( gpio_get_value( KTA_NCONN_GPIO ) )
			set_irq_type( KTA_NCONN_IRQ, IRQ_TYPE_LEVEL_LOW );
		else
			set_irq_type( KTA_NCONN_IRQ, IRQ_TYPE_LEVEL_HIGH );
	}
#else
	set_irq_type( KTA_NCONN_IRQ, IRQ_TYPE_EDGE_BOTH );
#endif

	ret = request_irq( KTA_NCONN_IRQ, cable_detection_isr, IRQF_DISABLED, pdev->name, di );
	if ( ret )
	{
		printk( "[TA] 2. could not request irq %d, status %d\n", KTA_NCONN_IRQ, ret );
		goto ta_irq_fail;
	}

#ifdef USE_DISABLE_CONN_IRQ
	disable_irq( KTA_NCONN_IRQ );
#endif
#endif

	KCHG_ING_IRQ = platform_get_irq( pdev, 2 );
	KCHG_ING_GPIO = irq_to_gpio( KCHG_ING_IRQ );
	printk( "[TA] CHG_ING IRQ : %d \n", KCHG_ING_IRQ );
	printk( "[TA] CHG_ING GPIO : %d \n", KCHG_ING_GPIO );

	if ( device_config->SUPPORT_CHG_ING_IRQ )
	{
		ret = request_irq( KCHG_ING_IRQ, full_charge_isr, IRQF_DISABLED, pdev->name, di ); 
		set_irq_type( KCHG_ING_IRQ, IRQ_TYPE_EDGE_RISING );
		if ( ret )
		{
			printk( "[TA] 3. could not request irq2 %d, status %d\n",
				IH_USBIC_BASE, ret );
			goto chg_full_irq_fail;
		}
		disable_irq( KCHG_ING_IRQ );
	}

	KCHG_EN_GPIO = irq_to_gpio( platform_get_irq( pdev, 3 ) );
	printk( "[TA] CHG_EN GPIO : %d \n", KCHG_EN_GPIO );

	/*disable CHE_EN*/
	disable_charging( CHARGE_DUR_ACTIVE );

#ifdef CONFIG_USB_SWITCH_FSA9480
	di->callbacks.set_cable = charger_set_cable;
	if (device_config->register_callbacks)
		device_config->register_callbacks(&di->callbacks);
#endif

	//schedule_delayed_work( &di->cable_detection_work, 5*HZ );
	queue_delayed_work( sec_bci->sec_battery_workq, &di->cable_detection_work, HZ );

	return 0;


chg_full_irq_fail:
	irq = platform_get_irq( pdev, 1 );
	free_irq( irq, di );

ta_irq_fail:
	irq = platform_get_irq( pdev, 0 );
	free_irq( irq, di );

usb_irq_fail:
// [ USE_REGULATOR
	regulator_put( di->usb1v5 );
	di->usb1v5 = NULL;

fail_regulator3:
	regulator_put( di->usb1v8 );
	di->usb1v8 = NULL;

fail_regulator2:
	regulator_put( di->usb3v1 );
	di->usb3v1 = NULL;

fail_regulator1:
// ]
	kfree(di);

	return ret;
}
static void modemctl_cfg_gpio( void )
{
	int err = 0;
	
	unsigned gpio_cp_rst = mdmctl_data.gpio_cp_reset;
	unsigned gpio_pda_active = mdmctl_data.gpio_pda_active;
	unsigned gpio_phone_active = mdmctl_data.gpio_phone_active;
	unsigned gpio_reset_req_n = mdmctl_data.gpio_reset_req_n;
	
#if ( defined( CONFIG_MACH_SAMSUNG_LATONA ) && ( CONFIG_SAMSUNG_REL_HW_REV >= 2 ) )
	unsigned gpio_con_cp_sel = mdmctl_data.gpio_con_cp_sel;
#endif // HW Rev 02

	// Mux Setting -> mux_xxxx_rxx.c

	gpio_free( gpio_cp_rst );
	err = gpio_request( gpio_cp_rst, "CP_RST" );
	if( err ) {
		printk( "modemctl_cfg_gpio - fail to request gpio %s : %d\n", "CP_RST", err );
	}
	else {
		gpio_direction_output( gpio_cp_rst, 1 );
	}

	gpio_free( gpio_pda_active );
	err = gpio_request( gpio_pda_active, "PDA_ACTIVE" );
	if( err ) {
		printk( "modemctl_cfg_gpio - fail to request gpio %s : %d\n", "PDA_ACTIVE", err );
	}
	else {
		gpio_direction_output( gpio_pda_active, 0 );
	}

	gpio_free( gpio_phone_active );
	err = gpio_request( gpio_phone_active, "PHONE_ACTIVE" );
	if( err ) {
		printk( "modemctl_cfg_gpio - fail to request gpio %s : %d\n", "PHONE_ACTIVE", err );
	}
	else {
		gpio_direction_input( gpio_phone_active );
	}

	gpio_free( gpio_reset_req_n );
	err = gpio_request( gpio_reset_req_n, "RESET_REQ_N" );
	if( err ) {
		printk( "modemctl_cfg_gpio - fail to request gpio %s : %d\n", "RESET_REQ_N", err );
	}
	else {
		gpio_direction_output( gpio_reset_req_n, 0 );
	}

#if ( defined( CONFIG_MACH_SAMSUNG_LATONA ) && ( CONFIG_SAMSUNG_REL_HW_REV >= 2 ) )
	gpio_free( gpio_con_cp_sel );
	err = gpio_request( gpio_con_cp_sel, "CON_CP_SEL" );
	if( err ) {
		printk( "modemctl_cfg_gpio - fail to request gpio %s : %d\n", "CON_CP_SEL", err );
	}
	else {
		gpio_direction_output( gpio_con_cp_sel, 0 );
	}
#endif // HW Rev 02
	
	set_irq_type( OMAP_GPIO_IRQ( OMAP_GPIO_PHONE_ACTIVE ), IRQ_TYPE_EDGE_BOTH );

	//set_irq_type( gpio_sim_ndetect, IRQ_TYPE_EDGE_BOTH );
}
static int wl1251_sdio_probe(struct sdio_func *func,
			     const struct sdio_device_id *id)
{
	int ret;
	struct wl1251 *wl;
	struct ieee80211_hw *hw;

	hw = wl1251_alloc_hw();
	if (IS_ERR(hw))
		return PTR_ERR(hw);

	wl = hw->priv;

	sdio_claim_host(func);
	ret = sdio_enable_func(func);
	if (ret)
		goto release;

	sdio_set_block_size(func, 512);
	sdio_release_host(func);

	SET_IEEE80211_DEV(hw, &func->dev);
	wl->if_priv = func;
	wl->if_ops = &wl1251_sdio_ops;
	wl->set_power = wl1251_sdio_set_power;

	if (wl12xx_board_data != NULL) {
		wl->set_power = wl12xx_board_data->set_power;
		wl->irq = wl12xx_board_data->irq;
		wl->use_eeprom = wl12xx_board_data->use_eeprom;
	}

	if (wl->irq) {
		ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl);
		if (ret < 0) {
			wl1251_error("request_irq() failed: %d", ret);
			goto disable;
		}

		set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
		disable_irq(wl->irq);

		wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
		wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;

		wl1251_info("using dedicated interrupt line");
	} else {
		wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
		wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;

		wl1251_info("using SDIO interrupt");
	}

	ret = wl1251_init_ieee80211(wl);
	if (ret)
		goto out_free_irq;

	sdio_set_drvdata(func, wl);
	return ret;

out_free_irq:
	if (wl->irq)
		free_irq(wl->irq, wl);
disable:
	sdio_claim_host(func);
	sdio_disable_func(func);
release:
	sdio_release_host(func);
	wl1251_free_hw(wl);
	return ret;
}
static int __devinit wl1271_probe(struct sdio_func *func,
				  const struct sdio_device_id *id)
{
	struct ieee80211_hw *hw;
	struct wl1271 *wl;
	int ret;

	/* We are only able to handle the wlan function */
	if (func->num != 0x02)
		return -ENODEV;

	hw = wl1271_alloc_hw();
	if (IS_ERR(hw))
		return PTR_ERR(hw);

	wl = hw->priv;

	wl->if_priv = func;
	wl->if_ops = &sdio_ops;

	/* Grab access to FN0 for ELP reg. */
	func->card->quirks |= MMC_QUIRK_LENIENT_FN0;

	wl->irq = gpio_to_irq(RX71_WL1271_IRQ_GPIO);
	if (wl->irq < 0) {
		ret = wl->irq;
		wl1271_error("could not get irq!");
		goto out_free;
	}

	ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
	if (ret < 0) {
		wl1271_error("request_irq() failed: %d", ret);
		goto out_free;
	}

	set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);

	disable_irq(wl->irq);

	ret = wl1271_init_ieee80211(wl);
	if (ret)
		goto out_irq;

	ret = wl1271_register_hw(wl);
	if (ret)
		goto out_irq;

	sdio_set_drvdata(func, wl);

	wl1271_notice("initialized");

	return 0;

 out_irq:
	free_irq(wl->irq, wl);


 out_free:
	wl1271_free_hw(wl);

	return ret;
}
Exemple #25
0
int __init ags04_driver_init(void)
{
	int ret = 0;
	unsigned int val = 0;
	trace_in() ;

	/*Initilize the ags04 dev mutex*/
	ags04_dev_mutex_init();

	/*Add the i2c driver*/
	if ( (ret = ags04_i2c_drv_init() < 0) ) 
	{
		printk(KERN_ERR "%s, ags04_i2c_drv_init failed, ret= %d\n", __FUNCTION__, ret );
		goto MISC_IRQ_DREG;
	}

	/* gpiot setting */
	s3c_gpio_setpull(GPIO_GRIP_INT, S3C_GPIO_PULL_UP); 

#if 1
	/*Add the input device driver*/
	input_dev= input_allocate_device() ;

	if( !input_dev ) {
		printk( "%s, Input_allocate_deivce failed!, ret= %d\n",	__FUNCTION__, ret ) ;
		return -ENODEV ;
	}

	//set_bit( EV_KEY, input_dev->evbit ) ;

	input_set_capability(input_dev, EV_KEY, ags_code[0]);
	input_set_capability(input_dev, EV_KEY, ags_code[1]);
	input_set_capability(input_dev, EV_KEY, ags_code[2]);
	input_set_capability(input_dev, EV_KEY, ags_code[3]);


	input_dev->name= "grip_sensor" ;

	ret= input_register_device( input_dev ) ;
	if( ret ) {
		printk( "%s, Unable to register Input device: %s, ret= %d\n", __FUNCTION__,  input_dev->name, ret ) ;
		return ret ;
	}
#endif

	/*misc device registration*/
	if( (ret = misc_register(&ags04_misc_device)) < 0 )
	{
		printk(KERN_ERR "%s, ags04_driver_init misc_register failed, ret= %d\n", __FUNCTION__, ret );
		goto MISC_DREG;
	}

	INIT_WORK(&ags04_ws, (void (*)(struct work_struct*))ags04_dev_work_func ) ;

	/* set sysfs for light sensor */

	gripsensor_class = class_create(THIS_MODULE, "grip_sensor");
	if (IS_ERR(gripsensor_class))
		pr_err("Failed to create class(grip_sensor)!\n");

	switch_cmd = device_create(gripsensor_class, NULL, 0, NULL, "switch");
	if (IS_ERR(switch_cmd))
		pr_err("Failed to create device(switch_cmd_dev)!\n");

	if (device_create_file(switch_cmd, &dev_attr_grip_read_cnt) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_grip_read_cnt.attr.name);

#if 0
	/*set interrupt service routine*/
	set_irq_type ( GRIP_IRQ, IRQ_TYPE_EDGE_FALLING );
	enable_irq_wake ( GRIP_IRQ );
#if 0
	if( (ret = request_irq(GRIP_IRQ, ags04_isr,0 , "ags04", (void *)NULL)) < 0 )
	{
		printk("%s, request_irq failed %d, ret= %d\n",__FUNCTION__, GRIP_IRQ, ret );
	}
#endif
	GRIP_INT_GPIO= GRIP_IRQ;
	printk(KERN_DEBUG "%s, GRIP_INT_GPIO: %d\n",__FUNCTION__, GRIP_IRQ ) ;
#else

	if (gpio_request(GPIO_GRIP_INT,"grip_gpio")) {
		printk("gpio request failure %d\n", GPIO_GRIP_INT);
		return -ENODEV;
	}

	GRIP_IRQ = gpio_to_irq( GPIO_GRIP_INT);

	/*set interrupt service routine*/
	set_irq_type ( GRIP_IRQ, IRQ_TYPE_EDGE_FALLING );
	enable_irq_wake ( GRIP_IRQ );		

	ret = request_threaded_irq(GRIP_IRQ, NULL,
			ags04_isr,
			IRQ_TYPE_EDGE_FALLING, "ags04", NULL);
	if (ret) {
		pr_err("%s : Failed to request_irq IRQ-%d err-%d\n", __func__,GRIP_IRQ,ret);
	}

	GRIP_INT_GPIO= GRIP_IRQ;
	printk(KERN_DEBUG "%s, GRIP_INT_GPIO: %d\n",__FUNCTION__, GRIP_IRQ ) ;

#endif

	ags04_disable_int() ;

	udelay( 500 ) ;

	ags04_enable_int() ;

	/* wake lock init */
	wake_lock_init(&ags_wake_lock, WAKE_LOCK_SUSPEND, "ags_wake_lock");

	trace_out() ;
	return ret;

MISC_IRQ_DREG:
	/*
	   free_irq(ags04_IRQ, (void *)NULL);
	 */

MISC_DREG:
	misc_deregister(&ags04_misc_device);

	trace_out() ;
	return ret; 
}
Exemple #26
0
/**
 * retu_probe - Probe for Retu ASIC
 * @dev: the Retu device
 *
 * Probe for the Retu ASIC and allocate memory
 * for its device-struct if found
 */
static int __devinit retu_probe(struct device *dev)
{
	const struct omap_em_asic_bb5_config * em_asic_config;
	int rev, ret;

	/* Prepare tasklet */
	tasklet_init(&retu_tasklet, retu_tasklet_handler, 0);

	em_asic_config = omap_get_config(OMAP_TAG_EM_ASIC_BB5,
					 struct omap_em_asic_bb5_config);
	if (em_asic_config == NULL) {
		printk(KERN_ERR PFX "Unable to retrieve config data\n");
		return -ENODATA;
	}

	retu_irq_pin = em_asic_config->retu_irq_gpio;

	if ((ret = omap_request_gpio(retu_irq_pin)) < 0) {
		printk(KERN_ERR PFX "Unable to reserve IRQ GPIO\n");
		return ret;
	}

	/* Set the pin as input */
	omap_set_gpio_direction(retu_irq_pin, 1);

	/* Rising edge triggers the IRQ */
	set_irq_type(OMAP_GPIO_IRQ(retu_irq_pin), IRQT_RISING);

	retu_initialized = 1;

	rev = retu_read_reg(RETU_REG_ASICR) & 0xff;
	if (rev & (1 << 7))
		retu_is_vilma = 1;

	printk(KERN_INFO "%s v%d.%d found\n", retu_is_vilma ? "Vilma" : "Retu",
	       (rev >> 4) & 0x07, rev & 0x0f);

	/* Mask all RETU interrupts */
	retu_write_reg(RETU_REG_IMR, 0xffff);

	ret = request_irq(OMAP_GPIO_IRQ(retu_irq_pin), retu_irq_handler, 0,
			  "retu", 0);

	if (ret < 0) {
		printk(KERN_ERR PFX "Unable to register IRQ handler\n");
		omap_free_gpio(retu_irq_pin);
		return ret;
	}

	/* Register power off function */
	pm_power_off = retu_power_off;

#ifdef CONFIG_CBUS_RETU_USER
	/* Initialize user-space interface */
	if (retu_user_init() < 0) {
		printk(KERN_ERR "Unable to initialize driver\n");
		free_irq(OMAP_GPIO_IRQ(retu_irq_pin), 0);
		omap_free_gpio(retu_irq_pin);
		return ret;
	}
#endif

	return 0;
}
static int __init hs_probe(struct platform_device *pdev)
{
	int result = 0;
	mic.hsmajor = 0;
	mic.headset_state = 0;
	mic.hsbtime.tv.sec = 0;
	mic.hsbtime.tv.nsec = 0;
	mic.headset_pd = NULL;
	mic.check_count = 0;

#ifdef CONFIG_SWITCH
	result = hs_switchinit(&mic);
	if (result < 0)
		return result;
#endif

	result = hs_inputdev(&mic);
	if (result < 0)
		goto err;

	result = register_chrdev(mic.hsmajor, "BrcmHeadset", &hs_fops);
	if(result < 0)
		goto err1;
	else if(result > 0 && (mic.hsmajor == 0))    /* this is for dynamic major */
		mic.hsmajor = result;

	wake_lock_init(&mic.det_wake_lock, WAKE_LOCK_SUSPEND, "sec_jack_det");
	INIT_DELAYED_WORK(&(mic.imsi_work), getIMSI_work_func);

	/* check if platform data is defined for a particular board variant */
	if (pdev->dev.platform_data)
	{
		mic.headset_pd = pdev->dev.platform_data;

		KEY_PRESS_THRESHOLD = mic.headset_pd->key_press_threshold;
		KEY_3POLE_THRESHOLD = mic.headset_pd->key_3pole_threshold;
		KEY1_THRESHOLD_L = mic.headset_pd->key1_threshold_l;
		KEY1_THRESHOLD_U = mic.headset_pd->key1_threshold_u;
		KEY2_THRESHOLD_L = mic.headset_pd->key2_threshold_l;
		KEY2_THRESHOLD_U = mic.headset_pd->key2_threshold_u;
		KEY3_THRESHOLD_L = mic.headset_pd->key3_threshold_l;
		KEY3_THRESHOLD_U = mic.headset_pd->key3_threshold_u;

		if (mic.headset_pd->hsgpio == NULL)
			mic.hsirq = mic.headset_pd->hsirq;
		else
		{
			setup_timer(&mic.timer, gpio_jack_timer, (unsigned long)&mic); // timer register. 

			if (gpio_request(mic.headset_pd->hsgpio, "headset detect") < 0)
			{
				printk("%s: Could not reserve headset signal GPIO!\n", __func__);
				goto err2;
			}
			gpio_direction_input(mic.headset_pd->hsgpio);
			bcm_gpio_set_db_val(mic.headset_pd->hsgpio, 0x7);
			mic.hsirq = gpio_to_irq(mic.headset_pd->hsgpio);
		}
		mic.hsbirq = mic.headset_pd->hsbirq;
	}
	else
	{
		mic.hsirq = platform_get_irq(pdev, 0);
		mic.hsbirq = platform_get_irq(pdev, 1);
	}

	printk("%s: HS irq %d\n", __func__, mic.hsirq);
	printk("%s: HSB irq %d\n", __func__, mic.hsbirq);
	result = request_irq(mic.hsbirq, hs_buttonisr,  IRQF_NO_SUSPEND, "BrcmHeadsetButton",  (void *) NULL);
	mic.hsbst = DISABLE;

	if(result < 0)
		goto err2;

	result = request_irq(mic.hsirq, hs_isr,(IRQF_DISABLED | IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND), "BrcmHeadset",  &mic);
	if(result < 0)
	{
		free_irq(mic.hsbirq, &mic);
		goto err2;
	}

	printk("%s: BrcmHeadset: module inserted >>>> . Major number is = %d\n", __func__, mic.hsmajor);

	/* Set the ANACR2 bit for mic power down */
	board_sysconfig(SYSCFG_AUXMIC, SYSCFG_INIT);
	board_sysconfig(SYSCFG_HEADSET, SYSCFG_INIT);

	/*Fix the audio path is wrong when headset already plugged in the device  then boot device case.*/
	if (mic.headset_pd->hsgpio != NULL)
	{
		mic.headset_pd->check_hs_state(&mic.headset_state);
		printk("%s: headset_state:%d\n", __func__, mic.headset_state); 
		set_irq_type(mic.hsirq, (mic.headset_state) ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING);
		schedule_work(&(mic.switch_data.work));
		schedule_delayed_work(&(mic.imsi_work), GET_IMSI_REF_TIME);
	}

	return 0;

err2:   unregister_chrdev(mic.hsmajor,"BrcmHeadset");
	if(mic.headset_pd->hsgpio)
		del_timer_sync(&mic.timer);
err1:   hs_unreginputdev(&mic);
err:    hs_unregsysfs(&mic);
	return result;
}
Exemple #28
0
 int __init Si4709_driver_init(void)
{
    int ret = 0;
	
		
    debug("Si4709_driver_init called");  

    /*Initialize the Si4709 dev mutex*/
    Si4709_dev_mutex_init();

	  
    /*misc device registration*/
    if( (ret = misc_register(&Si4709_misc_device)) < 0 )
    {
        error("Si4709_driver_init misc_register failed");
        return ret; 	  	
    }

   s3c_gpio_cfgpin(GPIO_FM_INT, S3C_GPIO_SFN(0xF));
   s3c_gpio_setpull(GPIO_FM_INT, S3C_GPIO_PULL_NONE);

	set_irq_type(FM_IRQ_INT, IRQ_TYPE_EDGE_FALLING);    
	
   /*KGVS: Configuring the GPIO_FM_INT in mach-jupiter.c*/
	if( (ret = request_irq(FM_IRQ_INT, Si4709_isr, IRQF_DISABLED , "Si4709", NULL )) )
	{
        error("Si4709_driver_init request_irq failed %d", GPIO_FM_INT);
        goto MISC_DREG;
	} 
	else
		debug("Si4709_driver_init request_irq success %d", GPIO_FM_INT);						

	if (gpio_is_valid(FM_RESET)) {
		if (gpio_request(FM_RESET, "GPJ2")) 
			printk(KERN_ERR "Failed to request FM_RESET!\n");
		gpio_direction_output(FM_RESET, GPIO_LEVEL_LOW);
	}
	
	/*VNVS: 13-OCT'09---- Initially Pulling the interrupt pin HIGH as the FM Radio device gives 5ms low pulse*/
	s3c_gpio_setpull(GPIO_FM_INT, S3C_GPIO_PULL_UP);
	
    /****Resetting the device****/
	gpio_set_value(FM_RESET, GPIO_LEVEL_LOW);	
	gpio_set_value(FM_RESET, GPIO_LEVEL_HIGH);	
	/*VNVS: 13-OCT'09---- Freeing the FM_RESET pin*/
	gpio_free(FM_RESET);	

    /*Add the i2c driver*/
    if ( (ret = Si4709_i2c_drv_init() < 0) ) 
    {
         goto MISC_IRQ_DREG;
    }

    init_waitqueue_head(&Si4709_waitq);

    debug("Si4709_driver_init successful");  
	
    return ret;

MISC_IRQ_DREG:
    free_irq(FM_IRQ_INT, NULL);  
MISC_DREG:
    misc_deregister(&Si4709_misc_device);
		
    return ret; 
}
Exemple #29
0
static int __devinit wl1251_spi_probe(struct spi_device *spi)
{
	struct wl12xx_platform_data *pdata;
	struct ieee80211_hw *hw;
	struct wl1251 *wl;
	int ret;

	pdata = spi->dev.platform_data;
	if (!pdata) {
		wl1251_error("no platform data");
		return -ENODEV;
	}

	hw = wl1251_alloc_hw();
	if (IS_ERR(hw))
		return PTR_ERR(hw);

	wl = hw->priv;

	SET_IEEE80211_DEV(hw, &spi->dev);
	dev_set_drvdata(&spi->dev, wl);
	wl->if_priv = spi;
	wl->if_ops = &wl1251_spi_ops;

	/* This is the only SPI value that we need to set here, the rest
	 * comes from the board-peripherals file */
	spi->bits_per_word = 32;

	ret = spi_setup(spi);
	if (ret < 0) {
		wl1251_error("spi_setup failed");
		goto out_free;
	}

	wl->set_power = pdata->set_power;
	if (!wl->set_power) {
		wl1251_error("set power function missing in platform data");
		return -ENODEV;
	}

	wl->irq = spi->irq;
	if (wl->irq < 0) {
		wl1251_error("irq missing in platform data");
		return -ENODEV;
	}

	wl->use_eeprom = pdata->use_eeprom;

	ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl);
	if (ret < 0) {
		wl1251_error("request_irq() failed: %d", ret);
		goto out_free;
	}

	set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);

	disable_irq(wl->irq);

	ret = wl1251_init_ieee80211(wl);
	if (ret)
		goto out_irq;

	return 0;

 out_irq:
	free_irq(wl->irq, wl);

 out_free:
	ieee80211_free_hw(hw);

	return ret;
}
Exemple #30
0
static void __init cerf_init_irq(void)
{
	sa1100_init_irq();
	set_irq_type(CERF_ETH_IRQ, IRQT_RISING);
}