static int max17040_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { dbg_func_in(); switch (psp) { case POWER_SUPPLY_PROP_VOLTAGE_NOW: if(max17040_data.i2c_state_vol) val->intval = max17040_data.prev_voltage*1000; //2011.05.16 leecy add for battery Info else val->intval = max17040_data.vcell*1000; //2011.05.16 leecy add for battery Info //pr_info("[SKY CHG] %s max17040_get_property= %d V\n", // __func__,val->intval); break; case POWER_SUPPLY_PROP_CAPACITY: if(max17040_data.i2c_state) val->intval = max17040_data.prev_soc; else val->intval = max17040_data.soc; //pr_info("[SKY CHG] %s max17040_get_property= %d Pro\n", // __func__,val->intval); break; default: return -EINVAL; } dbg_func_out(); return 0; }
static int yas_acc_resume(struct i2c_client *client) { struct yas_acc_private_data *data = i2c_get_clientdata(client); struct yas_acc_driver *driver = data->driver; int delay; dbg_func_in(); #ifdef POWER_ON_OFF geomagnetic_set_power(1); #endif #ifndef PANTECH_AVOID_DEADLOCK mutex_lock(&data->data_mutex); #endif dbg("%s : data->suspend = %d / data->suspend_enable = %d / delay = %d\n", __func__, data->suspend, yas_acc_get_enable(driver), yas_acc_get_delay(driver)); if (data->suspend == 1) { if (data->suspend_enable) { delay = yas_acc_get_delay(driver); #ifndef PANTECH_AVOID_DEADLOCK schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); #endif yas_acc_set_enable(driver, 1); } } data->suspend = 0; #ifndef PANTECH_AVOID_DEADLOCK mutex_unlock(&data->data_mutex); #endif dbg_func_out(); return 0; }
static void sensor_set_enable(struct device *dev, int enable) { struct input_dev *inputdev = to_input_dev(dev); struct sensor_data *sensordata = input_get_drvdata(inputdev); int delay = atomic_read(&sensordata->delay); dbg_func_in(); mutex_lock(&sensordata->enable_mutex); if (enable) { /* enable if state will be changed */ if (!atomic_cmpxchg(&sensordata->enable, 0, 1)) { sensordata->status = apds9900_control_enable(APDS9900_TYPE_PROXIMITY, true) ? 0 : 1; if(sensordata->status) { schedule_delayed_work(&sensordata->work, delay_to_jiffies(delay) + 1); } } } else { /* disable if state will be changed */ if (atomic_cmpxchg(&sensordata->enable, 1, 0) && sensordata->status) { if(sensordata->status) { cancel_delayed_work_sync(&sensordata->work); sensordata->status = apds9900_control_enable(APDS9900_TYPE_PROXIMITY, false) ? 0 : 1; } } } atomic_set(&sensordata->enable, enable); mutex_unlock(&sensordata->enable_mutex); dbg_func_out(); }
static int yas_acc_set_enable(struct yas_acc_driver *driver, int enable) { struct yas_acc_private_data *data = yas_acc_get_data(); int delay = driver->get_delay(); dbg_func_in(); dbg("%s : enable=%d, delay=%d\n", __func__, enable, delay); #ifndef PANTECH_AVOID_DEADLOCK if (yas_acc_ischg_enable(driver, enable)) { #endif if (enable) { driver->set_enable(enable); schedule_delayed_work(&data->work, delay_to_jiffies(delay) + 1); dbg("%s : schedule_delayed_work(&data->work, %d)\n", __func__, delay); } else { cancel_delayed_work_sync(&data->work); dbg("%s : cancel_delayed_work_sync\n", __func__); driver->set_enable(enable); } #ifndef PANTECH_AVOID_DEADLOCK } #endif dbg_func_out(); return 0; }
static void sensor_work_func(struct work_struct *work) { struct sensor_data *sensordata = container_of((struct delayed_work *)work, struct sensor_data, work); axes_t val; unsigned long delay; dbg_func_in(); if(input_pdev == NULL) { cancel_delayed_work_sync(&sensordata->work); } else { sensor_measure(sensordata, &val); #if AT1_BDVER_GE(AT1_WS20) //hhs veeapp read function add 20110316 val_backup.x = val.x; val_backup.y = val.y; val_backup.z = val.z; #endif input_report_abs(input_pdev, ABS_X, (int)val.x); input_report_abs(input_pdev, ABS_Y, (int)val.y); input_report_abs(input_pdev, ABS_Z, (int)val.z); input_sync(input_pdev); mutex_lock(&sensordata->data_mutex); sensordata->lastval = val; mutex_unlock(&sensordata->data_mutex); delay = delay_to_jiffies(atomic_read(&sensordata->delay)); schedule_delayed_work(&sensordata->work, delay); } dbg_func_out(); }
static int geomagnetic_suspend(struct i2c_client *client, pm_message_t mesg) { struct geomagnetic_data *data = i2c_get_clientdata(client); dbg_func_in(); dbg("%s : data->enable = %d\n", __func__, atomic_read(&data->enable)); if (atomic_read(&data->enable)) { dbg("%s : cancel_delayed_work_sync(&data->work);", __func__); cancel_delayed_work_sync(&data->work); } #if DEBUG data->suspend = 1; #endif #ifdef POWER_ON_OFF //p12911 : ef33s sensor patch geomagnetic_set_power(0); #endif dbg_func_out(); return 0; }
static int yas_acc_suspend(struct i2c_client *client, pm_message_t mesg) { struct yas_acc_private_data *data = i2c_get_clientdata(client); struct yas_acc_driver *driver = data->driver; dbg_func_in(); dbg("%s : data->suspend = %d / data->suspend_enable = %d\n", __func__, data->suspend, yas_acc_get_enable(driver)); #ifndef PANTECH_AVOID_DEADLOCK mutex_lock(&data->data_mutex); #endif if (data->suspend == 0) { data->suspend_enable = yas_acc_get_enable(driver); if (data->suspend_enable) { #ifndef PANTECH_AVOID_DEADLOCK cancel_delayed_work_sync(&data->work); #endif yas_acc_set_enable(driver, 0); } } data->suspend = 1; #ifndef PANTECH_AVOID_DEADLOCK mutex_unlock(&data->data_mutex); #endif #ifdef POWER_ON_OFF geomagnetic_set_power(0); #endif dbg_func_out(); return 0; }
static void sensor_work_func(struct work_struct *work) { struct sensor_data *sensordata = container_of((struct delayed_work *)work, struct sensor_data, work); axes_t val; unsigned long delay; dbg_func_in(); if(input_pdev == NULL) { cancel_delayed_work_sync(&sensordata->work); } else { sensor_measure(sensordata, &val); input_report_abs(input_pdev, ABS_X, (int)val.x); input_report_abs(input_pdev, ABS_Y, (int)val.y); input_report_abs(input_pdev, ABS_Z, (int)val.z); input_sync(input_pdev); mutex_lock(&sensordata->data_mutex); sensordata->lastval = val; mutex_unlock(&sensordata->data_mutex); delay = delay_to_jiffies(atomic_read(&sensordata->delay)); schedule_delayed_work(&sensordata->work, delay); } dbg_func_out(); }
static void max17040_get_vcell(void) { u8 msb; u8 lsb; int avalue=0; int voltage=0; dbg_func_in(); msb = max17040_read_reg(MAX17040_VCELL_MSB); lsb = max17040_read_reg(MAX17040_VCELL_LSB); //check i2c error if(msb<0 ||lsb <0) { max17040_data.i2c_state_vol =1; } else { max17040_data.i2c_state_vol =0; max17040_data.prev_voltage=max17040_data.vcell; } voltage=(msb<<4)|((lsb&0xf0)>>4); avalue=(voltage*125)/100; // sleep_dbg(" MSB [%d] : LSB [%d] : LOW VOLTAGE [%d] : VOLTAGE_NOW [%d]\n",msb,lsb,voltage,avalue); /* ps2 team shs : voltage changes but the event is not sent. //temp code if(avalue!=max17040_data.vcell) max17040_data.event=Events; */ mutex_lock(&max17040_data.data_mutex); max17040_data.vcell = avalue; mutex_unlock(&max17040_data.data_mutex); dbg_func_out(); }
static void sensor_set_enable(struct device *dev, int enable) { struct input_dev *inputdev = to_input_dev(dev); struct sensor_data *sensordata = input_get_drvdata(inputdev); int delay = atomic_read(&sensordata->delay); dbg_func_in(); mutex_lock(&sensordata->enable_mutex); if (enable) { /* enable if state will be changed */ if (!atomic_cmpxchg(&sensordata->enable, 0, 1)) { l3g4200d_control_enable(1); schedule_delayed_work(&sensordata->work, delay_to_jiffies(delay) + 1); } } else { /* disable if state will be changed */ if (atomic_cmpxchg(&sensordata->enable, 1, 0)) { cancel_delayed_work_sync(&sensordata->work); l3g4200d_control_enable(0); } } atomic_set(&sensordata->enable, enable); mutex_unlock(&sensordata->enable_mutex); dbg_func_out(); }
static int geomagnetic_resume(struct i2c_client *client) { struct geomagnetic_data *data = i2c_get_clientdata(client); dbg_func_in(); dbg("%s : data->enable = %d\n", __func__, atomic_read(&data->enable)); #ifdef POWER_ON_OFF geomagnetic_set_power(1); #endif if (atomic_read(&data->enable)) { schedule_delayed_work(&data->work, 0); dbg("%s : schedule_delayed_work(&data->work, 0);", __func__); } #if DEBUG data->suspend = 0; #endif dbg_func_out(); return 0; }
static int yas529_misc_release(struct inode *inode, struct file *file) { dbg_func_in(); file->private_data = (void*)NULL; module_put(THIS_MODULE); dbg_func_out(); return 0; }
static irqreturn_t Earjack_Det_handler(int irq, void *dev_id) { dbg_func_in(); disable_irq_nosync(gpio_to_irq(EARJACK_DET)); wake_lock(&earjack_wake_lock); schedule_delayed_work(&earjack_work, 10); // after 100ms start function of earjack_detect_func dbg_func_out(); return IRQ_HANDLED; }
int max17040_get_voltage(void) { dbg_func_in(); if(max17040_data.i2c_state_vol) return max17040_data.prev_voltage; else return max17040_data.vcell; dbg_func_out(); }
static ssize_t max17040_store_flag(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { u8 scale = (u8)simple_strtoul(buf, NULL, 10); dbg_func_in(); dbg("max17040_store_flag => [%d]\n",scale); atomic_set(&max17040_data.set_test, scale); dbg_func_out(); return count; }
//ps2 team shs : depend on normal mode wake lock void max17040_prevent_suspend(void) { dbg_func_in(); if(!max17040_wake_state) { wake_lock(&max17040_data.work_wake_lock); max17040_wake_state=1; } dbg_func_out(); }
static int max17040_resume(struct i2c_client *client) { dbg_func_in(); if (max17040_data.slow_poll) { schedule_delayed_work(&max17040_data.work, 0); sleep_dbg("[RESUME] CONFIG FAST_POLL [The alarm is set for [%d] seconds]\n",FAST_POLL); } dbg_func_out(); return 0; }
static int sensor_resume(struct platform_device *pdev) { dbg_func_in(); /* implement resume of the sensor */ dbg_func_out(); return 0; }
static int sensor_suspend(struct platform_device *pdev, pm_message_t state) { dbg_func_in(); /* implement suspend of the sensor */ dbg_func_out(); return 0; }
static ssize_t sensor_readabs_show(struct device *dev, struct device_attribute *attr, char *buf) { dbg_func_in(); dbg("%s : enable = %d\n", __func__, val_backup.x); dbg_func_out(); return sprintf(buf, "%d\n", val_backup.x); }
static int __devinit yas529_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct yas529_data_type *dd; int rc; dbg_func_in(); if(yas529_data) { dev_err(&client->dev, "yas529_i2c_probe error\n"); rc = -EPERM; goto probe_exit; } dd = kzalloc (sizeof(struct yas529_data_type),GFP_KERNEL); if(!dd) { rc = -ENOMEM; goto probe_exit; } yas529_data = dd; i2c_set_clientdata(client, dd); dd->pClient = client; rc = misc_register(&yas529_misc_device); if (rc) { printk(KERN_ERR "yas529 : misc_register failed.\n"); goto probe_free_exit; } yas529_data->pClient->addr = YAS529_SLAVE_ADDR; dbg_func_out(); return 0; probe_free_exit: yas529_data = NULL; i2c_set_clientdata(client, NULL); probe_exit: dbg_func_out(); return rc; }
static void __exit sensor_exit(void) { dbg_func_in(); platform_driver_unregister(&sensor_driver); platform_device_unregister(sensor_pdev); dbg_func_out(); }
static void max17040_quick_get_soc(void) { u8 msb=0; u8 lsb=0; int avalue=0; //unsigned long quick_soc; int i=0; bool completed = false; dbg_func_in(); while (!completed) { msb = max17040_read_reg(MAX17040_SOC_MSB); lsb = max17040_read_reg(MAX17040_SOC_LSB); if(msb < 0 || lsb < 0) { for(i=0;i<MAX_READ;i++) { msb = max17040_read_reg(MAX17040_SOC_MSB); lsb = max17040_read_reg(MAX17040_SOC_LSB); if(msb < 0 || lsb <0) { continue; } else break; } } /*//description read i2c data [msb=20,lsb=10] avalue=20*1000+(10*1000)/256 */ avalue=SKY_MULT_1000(msb)+(SKY_MULT_1000(lsb)/SKY_SOC_LSB); //Ajdusted soc%=(SOC%-EMPTY)/(FULL-EMPTY)*100 //logic code sleep_dbg("MAX17040_QUICK Adjusted SOC MSB [%d] : LSB [%d] : Adjusted SOC [%d] :Try Count [%d]\n",msb,lsb,avalue,i); if(i>=MAX_READ-1 || msb < 0 || lsb <0 ) { //Battery Bug Fixing Coded by Illustrious by Proto printk("Re-running to check Battery SoC!!!\n"); i = 0; continue; } else { mutex_lock(&max17040_data.data_mutex); max17040_data.quick_data.soc_msb=msb; max17040_data.quick_data.soc_lsb=lsb; max17040_data.quick_data.quick_soc=avalue; mutex_unlock(&max17040_data.data_mutex); completed = true; break; } } dbg_func_out(); }
void max17040_allow_suspend(void) { dbg_func_in(); if(max17040_wake_state) { wake_unlock(&max17040_data.work_wake_lock); max17040_wake_state=0; } dbg_func_out(); }
static void max17040_program_alarm_set(struct max17040_chip *di, int seconds) { ktime_t low_interval = ktime_set(seconds - 10, 0); ktime_t slack = ktime_set(20, 0); ktime_t next; ktime_t finish; dbg_func_in(); next = ktime_add(di->last_poll, low_interval); finish=ktime_add(next, slack); alarm_start_range(&di->alarm, next, finish); dbg_func_out(); }
static int yas529_misc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; unsigned long reg; int rc = 0; dbg_func_in(); dbg("ioctl cmd = %d / arg = %d\n", cmd, arg); switch (cmd) { case 0x706: yas529_data->pClient->addr = arg; dbg_func_out(); return 0; } dbg_func_out(); return 0; }
static void max_battery_alarm_callback(struct alarm *alarm) { struct max17040_chip *di = container_of(alarm, struct max17040_chip, alarm); dbg_func_in(); sleep_dbg("MAX17040_ALARM_CALLBACK CALL.\n"); /*enable wake_lock*/ max17040_prevent_suspend(); /*schdule workqueue*/ queue_work(di->monitor_wqueue, &di->monitor_work); dbg_func_out(); }
static int __init sensor_init(void) { dbg_func_in(); sensor_pdev = platform_device_register_simple(SENSOR_INPUTDEV_NAME, 0, NULL, 0); if (IS_ERR(sensor_pdev)) { return -1; } dbg_func_out(); return platform_driver_register(&sensor_driver); }
// Remove Driver static int __devexit pantech_earjack_remove(struct platform_device *pdev) { struct pantech_earjack *earjack = platform_get_drvdata(pdev); dbg_func_in(); input_unregister_device(earjack->ipdev); switch_dev_unregister(&earjack->sdev); kfree(earjack); wake_lock_destroy(&earjack_wake_lock); wake_lock_destroy(&remotekey_wake_lock); dbg_func_out(); return 0; }
static int adc_value_to_key(void) // detect key sensing { int nAdcValue = 0; int i; dbg_func_in(); check_analog_mpp(CHANNEL_ADC_HDSET,&nAdcValue); // read analog input mpp_3 dbg("analog intput mpp_03 value : %d\n", nAdcValue); for( i = 1; i< ARR_SIZE( remotekey_type); i++ ) { if( nAdcValue >= remotekey_type[i].min && nAdcValue <= remotekey_type[i].max ) { // Check if car_kit earjack->car_kit = 0; if(i == ARR_SIZE(remotekey_type)-1 ) earjack->car_kit = 1; // Return key index dbg_func_out(); return i; } } // No Key, return 0 dbg_func_out(); return 0; }