static int __devinit adcfg_probe(struct platform_device* pdev)
{
    printk("[ADCFG] %s\n", __func__);

    sec_bci = get_sec_bci();

    adcfg_workq = create_workqueue("ADCFGWORKQ");

    INIT_DELAYED_WORK(&adcfg_work, adcfg_work_handler);

    queue_delayed_work(adcfg_workq, &adcfg_work, 0);

    return 0;
}
Example #2
0
static int __devinit charger_probe(struct platform_device *pdev)
{

	int ret = 0;
	int irq = 0;
	u8 state = 0;

	struct charger_device_info *di;

	printk( KERN_INFO "[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;

#if 0
	printk( KERN_INFO "[TA] %d, %d, %d\n ",
	       device_config->VF_CHECK_USING_ADC,
	       device_config->VF_ADC_PORT, 
		   device_config->SUPPORT_CHG_ING_IRQ);
#endif

	this_dev = &pdev->dev;

	di->stat1 = 0x80;

	/*Init Work */
	INIT_DELAYED_WORK(&di->twl6030charger_ctrl_work,
					  twl6030charger_ctrl_work_handler);

	INIT_DELAYED_WORK(&di->twl6030charger_fault_work,
					  twl6030charger_fault_work_handler);

	INIT_DELAYED_WORK(&di->bat_removal_detection_work,
			  bat_removal_detection_work_handler);

	// Refer board_init_battery for checking resources

	CTRL_INT_IRQ = platform_get_irq(pdev,0);
	
	ret = request_threaded_irq(CTRL_INT_IRQ, NULL, twl6030charger_ctrl_isr, 
							   0,
							   pdev->name, di);
	if (ret) {
		dev_err(di->dev, "[TA] 1. could not request irq %d, status %d\n",
			CTRL_INT_IRQ, ret);
		goto ctrl_int_irq_fail;
	}

	CHARGERFAULT_INTR_IRQ = platform_get_irq(pdev,1);
	
	ret = request_threaded_irq(CHARGERFAULT_INTR_IRQ, NULL, twl6030charger_fault_isr, 
							   0,
							   pdev->name, di);

	if (ret) {
		dev_err(di->dev, "[TA] 2. could not request irq %d, status %d\n",
			CHARGERFAULT_INTR_IRQ, ret);
		goto chargerfault_irq_fail;
	}

	BAT_REMOVAL_IRQ = platform_get_irq(pdev, 2);
	ret =
		request_irq(BAT_REMOVAL_IRQ, bat_removal_detection_isr,
			    IRQF_DISABLED, pdev->name, di);
	if (ret) {
		dev_err(di->dev, "[TA] 3. could not request irq %d, status %d\n",
			BAT_REMOVAL_IRQ, ret);
		goto bat_removal_irq_fail;
	}
	set_irq_type(BAT_REMOVAL_IRQ, IRQ_TYPE_EDGE_BOTH);

	/* initialize for USB charging */

	/* MAX Charger Voltage/Current limit was set in the Bootloader */
	/* Please find the related code in the sbl_board_charger.c */

	/* twl6030_config_limit1_reg(di, MAX_CHARGER_VOLTAGE); */
	/* twl6030_config_limit2_reg(di, MAX_CHARGER_CURRENT); */
	
	twl_i2c_write_u8(TWL6030_MODULE_CHARGER, MBAT_TEMP,
			 CONTROLLER_INT_MASK);
	twl_i2c_write_u8(TWL6030_MODULE_CHARGER, MASK_MCHARGERUSB_THMREG,
			 CHARGERUSB_INT_MASK);
		
	twl_i2c_read_u8(TWL6030_MODULE_CHARGER, &state,
			CHARGERUSB_CTRL1);
	state |= TERM;
	twl_i2c_write_u8(TWL6030_MODULE_CHARGER, state,
			 CHARGERUSB_CTRL1);

	twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK,
						REG_INT_MSK_LINE_C);
	twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK,
						REG_INT_MSK_STS_C);
	twl6030_interrupt_unmask(TWL6030_CHARGER_FAULT_INT_MASK,
						REG_INT_MSK_LINE_C);
	twl6030_interrupt_unmask(TWL6030_CHARGER_FAULT_INT_MASK,
						REG_INT_MSK_STS_C);


	queue_delayed_work(sec_bci->sec_battery_workq,
			   &di->twl6030charger_ctrl_work,HZ);

	return 0;


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

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

ctrl_int_irq_fail:


	kfree(di);

	return ret;
}
Example #3
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;
}