Beispiel #1
0
/*
 * echo bank_address > ECRom , for EC ROM read
 * echo bank_address_data > ECRom , for EC ROM write
 */
static ssize_t ECRom_store(struct kobject *kobj, struct kobj_attribute *attr, const char * buf, size_t n)
{
	u8  val8_0, val8_1;
	u16 val16_bank, val16_address, val16_address_data;

	if(n == 7)    //write data to EC ROM
	{
		val8_0 = TransformCharToByte(buf,4);     //data
		val8_1 = TransformCharToByte(buf,2);     //address
		val16_address_data = TransformToWord(val8_0, val8_1);
		val8_0 = TransformCharToByte(buf,0);     //Rom Bank number
		val16_bank = TransformToWord(val8_0, 0);
		i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x75,val16_bank);   //write bank
		i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x76,val16_address_data);   //write address_data
	}
	else if(n == 5)    //write address for EC ROM read
	{
		val8_0 = TransformCharToByte(buf,2);     //address
		val8_1 = TransformCharToByte(buf,0);     //Rom Bank number
		val16_address = TransformToWord(val8_0, 0);
		val16_bank = TransformToWord(val8_1, 0);
		i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x75,val16_bank);
		i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x77,val16_address);
	}

	msleep(10);

	return n;
}
Beispiel #2
0
//echo addresshbyte_addresslbyte_val > ECWrite
static ssize_t ECWrite_store(struct kobject *kobj, struct kobj_attribute *attr, const char * buf, size_t n)
{
	u8  val8_0, val8_1;
	u16 val16;
	val8_0 = TransformCharToByte(buf,2);
	val8_1 = TransformCharToByte(buf,0);
	val16 = TransformToWord(val8_0, val8_1);
	i2c_smbus_write_word_data_retry(EC_Bat_device->client,0xF0,val16);   //write address
	val8_1 = 0;
	val8_0 = TransformCharToByte(buf,4);
	val16 = TransformToWord(val8_0, val8_1);
	i2c_smbus_write_word_data_retry(EC_Bat_device->client,0xF2,val16);   //write value 00xx
	return n;
}
Beispiel #3
0
//echo cmd_val16 > ECflashwrite
static ssize_t ECflashwrite_store(struct kobject *kobj, struct kobj_attribute *attr, const char * buf, size_t n)
{
	u16 val16;
	val16 = TransformToWord(buf[2], buf[1]);
	i2c_smbus_write_word_data_retry(EC_Bat_device->client, buf[0], val16);

	return n;
}
Beispiel #4
0
static ssize_t ManufactureDate_store(struct kobject *kobj, struct kobj_attribute *attr, const char * buf, size_t n)
{
	u8  val8_0, val8_1;
	u16 val16;

	val8_0 = TransformCharToByte(buf,6);
	val8_1 = TransformCharToByte(buf,4);
	val16 = TransformToWord(val8_0, val8_1);
	i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x6f,val16);
	msleep(10);

	val8_0 = TransformCharToByte(buf,2);
	val8_1 = TransformCharToByte(buf,0);
	val16 = TransformToWord(val8_0, val8_1);
	i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x6f,val16);
	msleep(10);

	return n;
}
Beispiel #5
0
static ssize_t BTMAC_store(struct kobject *kobj, struct kobj_attribute *attr, const char * buf, size_t n)
{
	u8  val8_0, val8_1;
	u16 val16;
	int i;

	for(i=0;i<=2;i++)
	{
		val8_0 = TransformCharToByte(buf,10-4*i);
		val8_1 = TransformCharToByte(buf,8-4*i);
		val16 = TransformToWord(val8_0, val8_1);
		i2c_smbus_write_word_data_retry(EC_Bat_device->client,0x63,val16);
		msleep(10);
	}

	return n;
}