Beispiel #1
0
//extern int resource_get_level(const char *name);
static void battery_monitor_work_handler( struct work_struct *work )
// ----------------------------------------------------------------------------
// Description    : 
// Input Argument :  
// Return Value   :
{
	int is_full = 0;
	int charge_current_adc;
	struct battery_device_info *di = container_of( work,
							struct battery_device_info,
							battery_monitor_work.work );
	//printk("OPP: %d\n", resource_get_level("vdd1_opp"));
	//printk( KERN_DEBUG "[BR] battery_monitor_work\n" );
#if 0//me open
    
	printk( "[BR] battery monitor [Level:%d, ADC:%d, TEMP.:%d, cable: %d] \n",\
		get_battery_level_ptg(),\
		get_battery_level_adc(),\
		get_system_temperature(TEMP_DEG ),\
		sec_bci.charger.cable_status );
#endif

	//printk("VF: %d\n", _get_t2adc_data_(1));


	/*Monitoring the battery info.*/
	sec_bci.battery.battery_level_ptg = get_battery_level_ptg();
	sec_bci.battery.battery_level_vol= get_battery_level_adc();
	
	if ( device_config->MONITORING_SYSTEM_TEMP )
		sec_bci.battery.battery_temp = get_system_temperature( TEMP_DEG );
	else
		sec_bci.battery.battery_temp = 0;
#if 1 //me add 
	printk( "[BR] monitor BATT.(%d%%, %dmV, %d*)\n", 
			sec_bci.battery.battery_level_ptg,
			sec_bci.battery.battery_level_vol,
			sec_bci.battery.battery_temp );
#endif

	if( !( sec_bci.battery.monitor_field_temp ) 
	 	&& !( sec_bci.battery.monitor_field_rechg_vol ) )
	{
		sec_bci.battery.monitor_duration = MONITOR_DEFAULT_DURATION;
	}
	else
	{
		// Workaround : check status of cabel at this point.
		if ( !_cable_status_now_() )
		{
			_battery_state_change_( STATUS_CATEGORY_ETC, 
						ETC_CABLE_IS_DISCONNECTED, 
						CHARGE_DUR_ACTIVE );

			return;
		}

		if ( sec_bci.charger.is_charging && device_config->MONITORING_CHG_CURRENT )
		// in charging && enable monitor_chg_current
		{
			charge_current_adc = get_charging_current_adc_val();
			is_full = check_full_charge_using_chg_current( charge_current_adc );

			if ( is_full )
			{
//				do_fuelgauge_reset();
				_battery_state_change_( STATUS_CATEGORY_CHARGING, 
							POWER_SUPPLY_STATUS_FULL, 
							CHARGE_DUR_ACTIVE );
			}
			else
				battery_monitor_core( CHARGE_DUR_ACTIVE );
		}
		else
		{
			battery_monitor_core( CHARGE_DUR_ACTIVE );
		}
			
	}


#if 0 
	printk( "[BR] monitor BATT.(%d%%, %dmV, %d*)\n", 
			sec_bci.battery.battery_level_ptg,
			sec_bci.battery.battery_level_vol,
			sec_bci.battery.battery_temp );
#endif

	power_supply_changed( &di->sec_battery );
	power_supply_changed( &di->sec_ac );
	power_supply_changed( &di->sec_usb );


	//schedule_delayed_work( &di->battery_monitor_work, 
				//sec_bci.battery.monitor_duration * HZ );

	cancel_delayed_work( &di->battery_monitor_work );
	queue_delayed_work( sec_bci.sec_battery_workq, 
				&di->battery_monitor_work, 
				sec_bci.battery.monitor_duration * HZ);


}
Beispiel #2
0
static void battery_monitor_work_handler( struct work_struct *work )
{
    int is_full = 0;
    int charge_current_adc;
    struct battery_device_info *di = container_of( work,
                            struct battery_device_info,
                            battery_monitor_work.work );

    #if 0
    printk( "[BM] battery monitor [Level:%d, ADC:%d, TEMP.:%d, cable: %d] \n",\
        get_battery_level_ptg(),\
        get_battery_level_adc(),\
        get_system_temperature(),\
        sec_bci.charger.cable_status );
    #endif

    boot_monitor_count++;
    if(!boot_complete && boot_monitor_count >= 2)
    {
        printk("[BM] boot complete \n");
        boot_complete = true;
    }
	if(sec_bci.charger.rechg_count > 0)
		sec_bci.charger.rechg_count--;


//	printk("[BM] MMC2_DAT0 : %x\n", omap_readw(0x4800215c));

    if ( device_config->MONITORING_SYSTEM_TEMP )
        sec_bci.battery.battery_temp = get_system_temperature( TEMP_DEG );
    else
        sec_bci.battery.battery_temp = 0;

    #if 0
	update_rcomp_by_temperature(sec_bci.battery.battery_temp);
	#endif
	
    /* Monitoring the battery info. */
    sec_bci.battery.battery_level_ptg = get_battery_level_ptg();
    msleep(10);
    sec_bci.battery.battery_level_vol= get_battery_level_adc();

    if( !( sec_bci.battery.monitor_field_temp ) && !( sec_bci.battery.monitor_field_rechg_vol ) )
    {
        sec_bci.battery.monitor_duration = MONITOR_DEFAULT_DURATION;
    }
    else
    {
        // Workaround : check status of cabel at this point.
        if ( !_cable_status_now_() )
        {
            _battery_state_change_( STATUS_CATEGORY_ETC, 
                        ETC_CABLE_IS_DISCONNECTED, 
                        CHARGE_DUR_ACTIVE );
        }

        if ( sec_bci.charger.is_charging && device_config->MONITORING_CHG_CURRENT )
        {
            // in charging && enable monitor_chg_current
            charge_current_adc = get_charging_current_adc_val();
            is_full = check_full_charge_using_chg_current( charge_current_adc );

            if ( is_full )
            {
                _battery_state_change_( STATUS_CATEGORY_CHARGING, 
                            POWER_SUPPLY_STATUS_FULL, 
                            CHARGE_DUR_ACTIVE );
            }
            else
            {
                battery_monitor_core( CHARGE_DUR_ACTIVE );
            }   
        }
        else
        {
            battery_monitor_core( CHARGE_DUR_ACTIVE );
        }
    }

    #if 1 
    printk( "[BM] monitor BATT.(%d%%, %dmV, %d*, count=%d, charging=%d)\n", 
            sec_bci.battery.battery_level_ptg,
            sec_bci.battery.battery_level_vol,
            sec_bci.battery.battery_temp,
            boot_monitor_count,
            sec_bci.charger.is_charging
            );
    #endif
	//printk("[BM] adc 167 -> %d^, adc 198 -> %d^\n", t2adc_to_temperature(927, 0), t2adc_to_temperature(884, 0));

    power_supply_changed( &di->sec_battery );
    power_supply_changed( &di->sec_ac );
    power_supply_changed( &di->sec_usb );

    queue_delayed_work( sec_bci.sec_battery_workq, &di->battery_monitor_work, sec_bci.battery.monitor_duration * HZ);

}
Beispiel #3
0
/*
 * ---===--- MAIN ---===---
 */
int main(int argc, char *argv[])
{
  int iofd;
  int ch;
  unsigned long fan1_info = 0;
  unsigned long fan2_info = 0;
  unsigned long fan3_info = 0;
  signed int system_temp = 0;
  double cpu1_temp = 0;
  double cpu2_temp = 0;
  char io_dev[FILENAME_MAX];

  strcpy(io_dev, "/dev/io");		// FreeBSD default

  /*
   * 'h' and '?' are not listed, to give an error message when used.
   */
  while ( (ch = getopt(argc, argv, "Adf:qt")) != -1 )
  {
    switch (ch)
    {
      case 'A':
        show_all_fans = 1;
        break;
      case 'd':
        debug = 1;
        break;
      case 'f':
        strcpy(io_dev, optarg);
        break;
      case 'q':
        quiet = 1;
        break;
      case 't':
        swap_cpu_temps = 1;
        break;
      case 'h':
      case '?':
      default:
        usage();
    }
  }
  argc -= optind;
  argv += optind;

  /*
   * Open /dev/io for inb() and outb() permissions.
   */
  if ( (iofd = open(io_dev, O_RDWR)) == -1 )
  {
    perror("open() failed");
    exit(1);
  }

  /*
   * Check to see if the vendor ID code returned from the chip matches
   * 0x5CA3 (Winbond chipset).
   */
  if ( (vendor_id = get_vendor_id()) != 0x5CA3 )
  {
    printf("You do not have a Winbond hardware monitoring chipset.\n");
    printf("Your vendor ID code is: 0x%4.4X\n", vendor_id);
    close(iofd);
    exit(1);
  }
  switch ( chip_id = get_chip_id() )
  {
    case 0x10:		strcpy(chip, "W83781D <untested>");	break;
    case 0x20:		strcpy(chip, "W83627HF <untested>");	break;
    case 0x30:		strcpy(chip, "W83782D");		break;
    case 0x40:		strcpy(chip, "W83783S <untested>");	break;
    default:		strcpy(chip, "(unknown)");		break;
  }

  if (!quiet)
  {
    printf("Winbond %s detected (vendor=0x%4.4X, chip=0x%2.2X)\n\n",
      chip, vendor_id, chip_id);
  }

  if (swap_cpu_temps)
  {
    /*
     * Swap CPU1 and CPU2 temperatures; the Abit BP6 has thermistors 1
     * and 2 reversed (hardware bug).
     */
    get_cpu_temperatures(&cpu2_temp, &cpu1_temp);
  }
  else
  {
    get_cpu_temperatures(&cpu1_temp, &cpu2_temp);
  }
  get_fan_statistics(&fan1_info, &fan2_info, &fan3_info);
  get_system_temperature(&system_temp);

  printf("System Temperature\t%3dF (%d.0C)\n",
	 C2F(system_temp), system_temp);
  printf("CPU1 Temperature\t%3dF (%3.01fC)\n",
	 C2F(cpu1_temp), cpu1_temp);
  printf("CPU2 Temperature\t%3dF (%3.01fC)\n",
	 C2F(cpu2_temp), cpu2_temp);
  if (show_all_fans == 1)
  {
    display_fan("FAN1", fan1_info);
    display_fan("FAN2", fan2_info);
    display_fan("FAN3", fan3_info);
  }
  else
  {
    if (fan1_info != 0)		display_fan("FAN1", fan1_info);
    if (fan2_info != 0)		display_fan("FAN2", fan2_info);
    if (fan3_info != 0)		display_fan("FAN3", fan3_info);
  }

  close(iofd);
  exit(0);
}
Beispiel #4
0
                    struct kobj_attribute *attr,
                    const char *buf, size_t size)
{
    int flag;

    sscanf( buf, "%d", &flag );
    printk("[BM] boot complete flag:%d, buf:%s, size:%d\n",flag, buf, size);

    boot_complete = true;

    return size;
}

__ATTR_SHOW_CALLBACK( show_batt_vol, get_battery_level_adc() )
__ATTR_SHOW_CALLBACK( show_batt_vol_adc, 0 )
__ATTR_SHOW_CALLBACK( show_batt_temp, get_system_temperature( TEMP_DEG ) * 10 )
__ATTR_SHOW_CALLBACK( show_batt_temp_adc, get_system_temperature( TEMP_ADC ) )
__ATTR_SHOW_CALLBACK( show_batt_v_f_adc, 0 )
__ATTR_SHOW_CALLBACK( show_batt_capacity, get_battery_level_ptg() )
__ATTR_SHOW_CALLBACK( do_batt_fuelgauge_reset, do_fuelgauge_reset() )
__ATTR_SHOW_CALLBACK( show_batt_monitor_temp, get_batt_monitor_temp() )
__ATTR_SHOW_CALLBACK( show_batt_temp_check, sec_bci.battery.battery_health)
__ATTR_SHOW_CALLBACK( show_batt_full_check, (sec_bci.charger.charge_status == POWER_SUPPLY_STATUS_FULL)?1:0)
__ATTR_SHOW_CALLBACK( show_charging_source, sec_bci.charger.cable_status )

#ifdef _OMS_FEATURES_
__ATTR_SHOW_CALLBACK( show_batt_vol_toolow, sec_bci.battery.battery_vol_toolow )
static struct kobj_attribute batt_vol_toolow =
    __ATTR( batt_vol_toolow, 0644, show_batt_vol_toolow, NULL );
#endif