media:platform:tegra:fuse id for ar0261
Amey Asgaonkar [Fri, 30 Aug 2013 02:20:44 +0000 (19:20 -0700)]
adds code for reading fuse id for ar0261.

Bug 1330898

Change-Id: Iad27adafe34e1d0ed6165b1f8ae9c7d257beef11
Signed-off-by: Amey Asgaonkar <aasgaonkar@nvidia.com>
Reviewed-on: http://git-master/r/268282
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/media/platform/tegra/ar0261.c
include/media/ar0261.h

index d5f1113..6744071 100644 (file)
@@ -680,19 +680,32 @@ ar0261_set_group_hold(struct ar0261_info *info, struct ar0261_ae *ae)
 static int ar0261_get_sensor_id(struct ar0261_info *info)
 {
        int ret = 0;
-       int i;
-       u16 bak = 0;
+       int i = 0;
+       u16 store = 0;
 
+       pr_info("%s\n", __func__);
        if (info->sensor_data.fuse_id_size)
                return 0;
 
-       /*
-        * TBD 1: If the sensor does not have power at this point
-        * Need to supply the power, e.g. by calling power on function
-        */
-       /*TODO: add code for reading fuse id.*/
+       ret |= ar0261_write_reg(info->i2c_client, 0x301A, 0x0210);
+       ret |= ar0261_write_reg(info->i2c_client, 0x3054, 0x0500);
+       ret |= ar0261_write_reg(info->i2c_client, 0x3052, 0x0000);
+       ret |= ar0261_write_reg(info->i2c_client, 0x304A, 0x0400);
+       ret |= ar0261_write_reg(info->i2c_client, 0x304C, 0x02FF);
+       ret |= ar0261_write_reg(info->i2c_client, 0x304A, 0x0410);
 
-       return 0;
+       msleep_range(10);
+
+       for (i = 0; i < 16; i += 2) {
+               ret |= ar0261_read_reg(info->i2c_client, 0x3804 + i, &store);
+               info->sensor_data.fuse_id[i] = store;
+               info->sensor_data.fuse_id[i+1] = store >> 8;
+       }
+
+       if (!ret)
+               info->sensor_data.fuse_id_size = i;
+
+       return ret;
 }
 
 static void ar0261_mclk_disable(struct ar0261_info *info)
index 678dd0e..e12bfa0 100644 (file)
@@ -51,7 +51,7 @@ struct ar0261_ae {
 
 struct ar0261_sensordata {
        __u32 fuse_id_size;
-       __u16 fuse_id[16];
+       __u8 fuse_id[16];
 };
 
 #ifdef __KERNEL__