Esempio n. 1
0
/*******************************************************
 * Routine: misc_init_r
 * Description: Init ethernet (done here so udelay works)
 ********************************************************/
int misc_init_r(void)
{
#ifdef CONFIG_DRIVER_OMAP34XX_I2C

	unsigned char data;

	i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
	twl4030_power_reset_init();
	/* see if we need to activate the power button startup */
	char *s = getenv("pbboot");
	if (s) {
		/* figure out why we have booted */
		i2c_read(0x4b, 0x3a, 1, &data, 1);

		/* if status is non-zero, we didn't transition
		 * from WAIT_ON state
		 */
		if (data) {
			printf("Transitioning to Wait State (%x)\n", data);

			/* clear status */
			data = 0;
			i2c_write(0x4b, 0x3a, 1, &data, 1);

			/* put PM into WAIT_ON state */
			data = 0x01;
			i2c_write(0x4b, 0x46, 1, &data, 1);

			/* no return - wait for power shutdown */
			while (1) {;}
		}
		printf("Transitioning to Active State (%x)\n", data);

		/* turn on long pwr button press reset*/
		data = 0x40;
		i2c_write(0x4b, 0x46, 1, &data, 1);
		printf("Power Button Active\n");
	}
#endif
//&*&*&*20101201_Peter ++
	twl4030_usb_init();
	twl4030_keypad_init();
	twl4030_madc_init();
	twl4030_vadc_onoff(1);
//&*&*&*20101201_Peter --
	dieid_num_r();

	return (0);
}
Esempio n. 2
0
int checkboard(void)
{
	unsigned int ADCVaule = twl4030_get_ADCIN0_voltage();
	twl4030_vadc_onoff(0);
	g_BoardID = GetHardwareID(ADCVaule);	
	switch(g_BoardID)
	{
		case BOARD_ID_EVB:
	  case BOARD_ID_PRO:  printf("Board: PROTOTYPE (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_EVT1: printf("Board: EVT1 (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_EVT2: printf("Board: EVT2 (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_EVT3: printf("Board: EVT3 (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_DVT1: printf("Board: DVT1 (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_DVT2: printf("Board: DVT2 (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_PVT:  printf("Board: PVT (ADC=%dmV)\n", ADCVaule); break;
		case BOARD_ID_MP:   printf("Board: MP (ADC=%dmV)\n", ADCVaule); break;
		default:            printf("Board: OMAP3621\n"); break;
	}
	
	return (0);
}
Esempio n. 3
0
void off_mode_charging( void )
{
	int bootup_reason = BOOTUP_UNKNOWN;
#if CONFIG_MAX17043_GAUGE
	union power_supply_propval BatteryVol = {0,};
	union power_supply_propval BatteryCap = {0,};
	int model_count = 0;
#elif CONFIG_TWL4030_MADC_VBAT
	int BatteryCap = 0, BatteryVol = 0;
#endif

#ifdef CONFIG_DISCHARGING_EXPERIMENTATION
	int quick_once = 1;
#endif

#if CONFIG_MAX17043_GAUGE
	select_bus(1, 100);	
	off_mode_charging_info.write_model_false = max17043_write_custom_model();
	mdelay(500);
	//#ifndef CONFIG_DISCHARGING_EXPERIMENTATION
	//if(!off_mode_charging_info.write_model_false)
	//{
		//max17043_quick_start();
		//mdelay(1000);	
	//}
	//#endif
#elif CONFIG_TWL4030_MADC_VBAT
	twl4030_vadc_onoff(1);
	twl4030_madc_init();
#endif

	bootup_reason = off_mode_charging_info.bootup_reason;
	
	while (1)
	{
#if CONFIG_MAX17043_GAUGE
		// select I2C2
		select_bus(1, 100);	
		ds278x_battery_get_property(POWER_SUPPLY_PROP_VOLTAGE_NOW, &BatteryVol);
		ds278x_battery_get_property(POWER_SUPPLY_PROP_CAPACITY, &BatteryCap);
		if (off_mode_charging_info.write_model_false)
		{
			model_count++;
			if ((model_count%2) == 0)
			{
				off_mode_charging_info.write_model_false = off_mode_custom_model_retry();
			}
		}
#elif CONFIG_TWL4030_MADC_VBAT
		BatteryVol = twl4030_get_battery_voltage();
		printf("**** Off Mode Charging(from MADC) *****\n");
		printf("****      VOLTAGE: %d   ********\n", BatteryVol);
		printf("****  End Of Off Mode Charging  ****\n");
#endif
		//mdelay(1000);
		// select I2C1
		select_bus(0, 100);		

		off_mode_charging_info.cable_exist = dc_ok_detect();
		#ifdef CONFIG_DISCHARGING_EXPERIMENTATION
		off_mode_charging_info.cable_exist = 0;
		#endif

		if ((twl4030_bootup_reason_get() & BOOTUP_POWER_KEY) || (bootup_reason & BOOTUP_POWER_KEY))
		{

//&*&*&*HC1_20110503, Adjust long press time (ref. bsp spec v0.6)
//&*&*&*HC1_20110428, enable pwr key long press function 
#if CONFIG_PWRKEY_LONGPRESS
			if ((bootup_reason != BOOTUP_POWER_KEY) && (!pwrkey_press_check(PWRKEY_PRESS_TIME_CHARGING, bootup_reason)))
			{
				bootup_reason = BOOTUP_UNKNOWN;
				continue;		
			}
#endif // CONFIG_PWRKEY_LONGPRESS			
//&*&*&*HC2_20110428, enable pwr key long press function 
//&*&*&*HC2_20110503, Adjust long press time (ref. bsp spec v0.6)

#if (defined(CONFIG_TWL4030_MADC_VBAT) || defined(CONFIG_MAX17043_GAUGE))
			//&*&*&*AL1_20110528, different voltage between cable exist and not.
			
#if CONFIG_MAX17043_GAUGE
			if((BatteryVol.intval < POWER_ON_VOLTAGE_NO_CABLE) && (off_mode_charging_info.cable_exist == 1))
			{
				bootup_reason = BOOTUP_UNKNOWN;
				#if CONFIG_KEY_LIGHT_NOTIFICATION
				key_light_flash(3);
				#endif // CONFIG_KEY_LIGHT_NOTIFICATION
				printf("Battery voltage < 3.5V with no cable, can't boot up !!!\n");
			}	
			else if((off_mode_charging_info.CableInType == CABLE_AC) && (off_mode_charging_info.cable_exist == 0))
			{
				if(BatteryVol.intval < POWER_ON_VOLTAGE_WITH_AC_CABLE)
				{
					bootup_reason = BOOTUP_UNKNOWN;
					#if CONFIG_KEY_LIGHT_NOTIFICATION
					key_light_flash(3);
					#endif // CONFIG_KEY_LIGHT_NOTIFICATION
					printf("Battery voltage < 3.3V with AC cable, can't boot up !!!\n");
				}
				else
					break;
			}
			else if((off_mode_charging_info.CableInType == CABLE_USB) && (off_mode_charging_info.cable_exist == 0))
			{
				if(BatteryVol.intval < POWER_ON_VOLTAGE_WITH_USB_CABLE)
				{
					bootup_reason = BOOTUP_UNKNOWN;
					#if CONFIG_KEY_LIGHT_NOTIFICATION
					key_light_flash(3);
					#endif // CONFIG_KEY_LIGHT_NOTIFICATION
					printf("Battery voltage < 3.5V with USB cable, can't boot up !!!\n");
				}
				else
					break;
			}
			//&*&*&*AL2_20110528, different voltage between cable exist and not.
#elif CONFIG_TWL4030_MADC_VBAT
			if(BatteryVol < POWER_ON_VOLTAGE)
			{
				bootup_reason = BOOTUP_UNKNOWN;
				printf("Battery voltage < 3.6V with no cable, can't boot up !!!\n");
			}	
#endif
			else
			{
				#if CONFIG_KEY_LIGHT_NOTIFICATION
				 // power on, keep key light on
				key_light_flash(0);
				#endif // CONFIG_KEY_LIGHT_NOTIFICATION
				break;
			}	
#else
			printf("No battery voltage checking implementation! !!\n");
			break;
#endif
//&*&*&*HC2_20110103, enable the battery check
//&*&*&*HC2_20101230, disable the battery check
		}
		if(off_mode_charging_info.cable_exist == 1)
		{
			printf("Not a vaild long press !!! Please press and hold pwr key more than 1 sec.\n");
			twl4030_poweroff();
			break;
		}
		else
		{

			if (off_mode_charging_info.CableInType == CABLE_UNKNOW)
			{
				off_mode_charging_info.CableInType = twl4030_get_cable_type();
				if(off_mode_charging_info.CableInType == USB_EVENT_VBUS)
				{
					off_mode_charging_info.CableInType = CABLE_USB;
					printf("\n **** USB Cable: Start 500mA**** \n");
				}
				else
				{
					off_mode_charging_info.CableInType = CABLE_AC;
					printf("\n **** AC Cable: Start 1500mA**** \n");
				}
				
				#if CONFIG_CHARGING_REDUCE_SYS_LOAD
				pre_charging_configure();			
				change_cpu_freq(0);
				change_mem_freq(0);		
				off_mode_charging_info.enter_reduce_frequencce = 1;
				#endif //CHARGING_REDUCE_SYS_LOAD
			}
			if(off_mode_charging_info.CableInType == CABLE_AC)
				charging_mode(CHARGING_START_1000MA);
			else
				charging_mode(CHARGING_START_500MA);
		}

		#ifdef CONFIG_MAX17043_DEBUG_MESSAGE_FORMAT
		select_bus(1, 100);
		max1704x_register_dump();
		mdelay(5000);
		#endif

		mdelay(1000);

		// control charging LED
		off_mode_charging_info.is_charging_complete = chg_status_detect();
		charging_led_notification(off_mode_charging_info.is_charging_complete, BatteryCap.intval);
		off_mode_charging_info.charging_fault = chg_fault_detect();

		/* wait for redeuce frequence to get accurate capacity */
		#ifdef CONFIG_DISCHARGING_EXPERIMENTATION
		if(!off_mode_charging_info.write_model_false && quick_once)
		{
			select_bus(1, 100);
			max17043_quick_start();
			mdelay(1000);	
			quick_once = 0;
		}
		//if(BatteryCap.intval == 2)
		//{
			//select_bus(0, 100);
			//twl4030_poweroff();
			//break;
		//}
		#endif

		if(off_mode_charging_info.charging_fault == 0)
		{
			printf("\n **** charging_fault:%d, charging time out, re-toggle CEN pin.***** \n", off_mode_charging_info.charging_fault);
			charging_mode(CHARGING_STOP);
		}
		
		printf("\n");
	}	
}