static ssize_t mma7660_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned long data; int error; error = strict_strtoul(buf, 10, &data); if(error) { pr_err("%s strict_strtoul error\n", __FUNCTION__); goto exit; } if(data) { error = i2c_smbus_write_byte_data(mma7660_i2c_client, MMA7660_MODE, MK_MMA7660_MODE(0, 1, 0, 0, 0, 0, 1)); assert(error==0); } else { error = i2c_smbus_write_byte_data(mma7660_i2c_client, MMA7660_MODE, MK_MMA7660_MODE(0, 0, 0, 0, 0, 0, 0)); assert(error==0); } return count; exit: return error; }
/* * Initialization function */ static int mma7660_init_client(struct i2c_client *client) { int result; mma7660_i2c_client = client; if(0) { /* * Probe the device. We try to set the device to Test Mode and then to * write & verify XYZ registers */ result = i2c_smbus_write_byte_data(client, MMA7660_MODE,MK_MMA7660_MODE(0, 0, 0, 0, 0, 1, 0)); assert(result==0); mdelay(MODE_CHANGE_DELAY_MS); result = i2c_smbus_write_byte_data(client, MMA7660_XOUT, 0x2a); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_YOUT, 0x15); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_ZOUT, 0x3f); assert(result==0); result = i2c_smbus_read_byte_data(client, MMA7660_XOUT); result= i2c_smbus_read_byte_data(client, MMA7660_YOUT); result= i2c_smbus_read_byte_data(client, MMA7660_ZOUT); assert(result=0x3f); } // Enable Orientation Detection Logic result = i2c_smbus_write_byte_data(client, MMA7660_MODE, MK_MMA7660_MODE(0, 0, 0, 0, 0, 0, 0)); //enter standby assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_SR, MK_MMA7660_SR(2, 2, 1)); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_INTSU, MK_MMA7660_INTSU(0, 0, 0, 0, 1, 0, 1, 1)); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_SPCNT, 0xA0); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_MODE, MK_MMA7660_MODE(0, 1, 0, 0, 0, 0, 1)); assert(result==0); mdelay(MODE_CHANGE_DELAY_MS); return result; }
int mma7660_enter_resume(void) { printk("%s %s %d \n",__FILE__,__func__,__LINE__); bNeedResume = false; i2c_smbus_write_byte_data(mma7660_i2c_client, MMA7660_MODE, MK_MMA7660_MODE(0, 1, 0, 0, 0, 0, 1)); return 0; }
static int mma7660_late_resume(struct early_suspend *h) { int result; printk(KERN_INFO "mma7660 late resume\n"); mma7660_data.suspend_indator = 0; result = i2c_smbus_write_byte_data(mma7660_i2c_client, MMA7660_MODE, MK_MMA7660_MODE(0, 1, 0, 0, 0, 0, 1)); assert(result==0); return result; }
static int mma7660_suspend(struct i2c_client *client, pm_message_t mesg) { int result; //printk("%s %s %d \n",__FILE__,__func__,__LINE__); result = i2c_smbus_write_byte_data(client, MMA7660_MODE, MK_MMA7660_MODE(0, 0, 0, 0, 0, 0, 0)); assert(result==0); bsuspend=true; return result; }
static int __devexit mma7660_remove(struct i2c_client *client) { int result; result = i2c_smbus_write_byte_data(client,MMA7660_MODE, MK_MMA7660_MODE(0, 0, 0, 0, 0, 0, 0)); assert(result==0); hwmon_device_unregister(hwmon_dev); return result; }
static int __devexit mma7660_remove(struct i2c_client *client) { int result; result = i2c_smbus_write_byte_data(client,MMA7660_MODE, MK_MMA7660_MODE(0, 0, 0, 0, 0, 0, 0)); assert(result==0); //free_irq(plat_data->irq, NULL); sysfs_remove_group(&client->dev.kobj, &mma7660_group); hwmon_device_unregister(hwmon_dev); return result; }
static int mma7660_resume(struct i2c_client *client) { int result; //printk("%s %s %d \n",__FILE__,__func__,__LINE__); bsuspend=false; if(!bNeedResume){ result = i2c_smbus_write_byte_data(client, MMA7660_MODE, MK_MMA7660_MODE(0, 1, 0, 0, 0, 0, 1)); assert(result==0); return result; }else{ return 0; } }
static int mma7660_init_client(struct i2c_client *client) { int result; mma7660_i2c_client = client; //plat_data = (struct mxc_mma7660_platform_data *)client->dev.platform_data; //assert(plat_data); if(0) { /* * Probe the device. We try to set the device to Test Mode and then to * write & verify XYZ registers */ result = i2c_smbus_write_byte_data(client, MMA7660_MODE,MK_MMA7660_MODE(0, 0, 0, 0, 0, 1, 0)); assert(result==0); mdelay(MODE_CHANGE_DELAY_MS); result = i2c_smbus_write_byte_data(client, MMA7660_XOUT, 0x2a); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_YOUT, 0x15); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_ZOUT, 0x3f); assert(result==0); result = i2c_smbus_read_byte_data(client, MMA7660_XOUT); result= i2c_smbus_read_byte_data(client, MMA7660_YOUT); result= i2c_smbus_read_byte_data(client, MMA7660_ZOUT); assert(result=0x3f); } // Enable Orientation Detection Logic result = i2c_smbus_write_byte_data(client, MMA7660_MODE, MK_MMA7660_MODE(0, 0, 0, 0, 0, 0, 0)); //enter standby assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_SR, MK_MMA7660_SR(2, 2, 1)); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_INTSU, MK_MMA7660_INTSU(0, 0, 0, 0, 1, 0, 1, 1)); //if(result){ //printk("======================result =%d\n",result);} //else{ //printk("***************************************result =%d\n",result);} assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_SPCNT, 0xA0); assert(result==0); result = i2c_smbus_write_byte_data(client, MMA7660_MODE, MK_MMA7660_MODE(0, 1, 0, 0, 0, 0, 1)); assert(result==0); // MMA7660's INT is connected to imx51 EVK's GPIO4_17 // We install interrupt handler here /*assert(plat_data->irq); result = request_irq(plat_data->irq, mmx7660_irq_handler, IRQF_TRIGGER_FALLING , MMA7660_DRV_NAME, NULL); assert(result==0);*/ mdelay(MODE_CHANGE_DELAY_MS); { u8 tilt; mma7660_read_tilt(&tilt); orientation = tilt&0x1f; } return result; }