{ .frequency = CPUFREQ_TABLE_END },
};
+#define BAT_LOW RK29_PIN4_PA2
+#define POWER_ON_PIN RK29_PIN4_PA4
static void __init machine_rk29_board_init(void)
{
+ int val =0;
+ gpio_request(BAT_LOW, NULL);
+ gpio_direction_input(BAT_LOW);
+ val = gpio_get_value(BAT_LOW);
+ if (val == 0){
+ printk("no battery, no power up\n");
+ gpio_request(POWER_ON_PIN, "poweronpin");
+ gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
+ while(1){
+ gpio_set_value(POWER_ON_PIN, GPIO_LOW);
+ mdelay(100);
+ }
+ }
+ gpio_free(BAT_LOW);
rk29_board_iomux_init();
board_power_init();
#define BQ27500_FLAG_OTC BIT(15)
#define BQ27510_SPEED 100 * 1000
+#define POWER_ON_PIN RK29_PIN4_PA4
+
+#define BAT_LOW RK29_PIN4_PA2
+
+
int virtual_battery_enable = 0;
extern int dwc_vbus_status(void);
static void bq27541_set(void);
* Return the battery temperature in tenths of degree Celsius
* Or < 0 if something fails.
*/
+
+
static int bq27541_battery_temperature(struct bq27541_device_info *di)
{
int ret;
temp = get_unaligned_le16(buf);
temp = temp - 2731; //K
DBG("Enter:%s %d--temp = %d\n",__FUNCTION__,__LINE__,temp);
+
+// rk29_pm_power_off();
return temp;
}
ret = bq27541_read(di->client,BQ27x00_REG_VOLT,buf,2);
if (ret<0) {
dev_err(di->dev, "error reading voltage\n");
+ printk("vol smaller then 3.4V, shutdown");
+// gpio_set_value(POWER_ON_PIN, GPIO_LOW);
return ret;
}
volt = get_unaligned_le16(buf);
}else{
volt = volt * 1000;
}
+
+
+ if ((volt <= 3400000) && (volt > 0)){
+ printk("vol smaller then 3.4V, shutdown");
+ while(1){
+ gpio_set_value(POWER_ON_PIN, GPIO_LOW);
+ mdelay(100);
+ }
+ }
+
+
DBG("Enter:%s %d--volt = %d\n",__FUNCTION__,__LINE__,volt);
return volt;
}
union power_supply_propval *val)
{
int ret = 0;
+ int vals=0;
+
struct bq27541_device_info *di = to_bq27541_device_info(psy);
DBG("Enter:%s %d psp= %d\n",__FUNCTION__,__LINE__,psp);
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
case POWER_SUPPLY_PROP_PRESENT:
val->intval = bq27541_battery_voltage(di);
- if (psp == POWER_SUPPLY_PROP_PRESENT)
+ if (psp == POWER_SUPPLY_PROP_PRESENT){
val->intval = val->intval <= 0 ? 0 : 1;
+ }
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
val->intval = bq27541_battery_current(di);
struct bq27541_device_info *di;
int retval = 0;
struct bq27541_platform_data *pdata;
+ int val =0;
+
+// gpio_request(BAT_LOW, NULL);
+// gpio_direction_input(BAT_LOW);
+ gpio_request(POWER_ON_PIN, "poweronpin");
+ gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
+/*
+ val = gpio_get_value(BAT_LOW);
+ if (val == 0){
+ printk("no battery, shutdown\n");
+ while(1){
+ gpio_set_value(POWER_ON_PIN, GPIO_LOW);
+ mdelay(100);
+ }
+ return 0;
+ }
+
+*/
DBG("********** bq27541_battery_probe************** ");
pdata = client->dev.platform_data;
pdata->init_dc_check_pin( );
bq27541_powersupply_init(di);
+
+
retval = power_supply_register(&client->dev, &di->bat);
if (retval) {
static int __init bq27541_battery_init(void)
{
int ret;
+
struct proc_dir_entry * battery_proc_entry;
ret = i2c_add_driver(&bq27541_battery_driver);
printk(KERN_ERR "Unable to register BQ27541 driver\n");
battery_proc_entry = proc_create("driver/power",0777,NULL,&battery_proc_fops);
+
return ret;
}
-module_init(bq27541_battery_init);
+
+//module_init(bq27541_battery_init);
+fs_initcall(bq27541_battery_init);
+//arch_initcall(bq27541_battery_init);
static void __exit bq27541_battery_exit(void)
{