arm: tegra: fury: add NCT chip id to /sys
Chun Xu [Wed, 18 Sep 2013 12:54:44 +0000 (20:54 +0800)]
Read

accelerometer_id
charger_id
compass_id
gps_id
gyroscope_id
lcd_id
light_id
touch_id

from NCT into /sys/kernel/tegra_nct/.

Bug 1361476

Change-Id: Ieac5b33cfd0c8dfaae7cc8512a56de9451ff91b7
Signed-off-by: Chun Xu <chunx@nvidia.com>
Reviewed-on: http://git-master/r/276301
Reviewed-on: http://git-master/r/277607
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Kerwin Wan <kerwinw@nvidia.com>
Reviewed-by: Hayden Du <haydend@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit 0677f7650d3007f617cb1da97411d45ecd96282d)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>

arch/arm/mach-tegra/include/mach/nct.h
arch/arm/mach-tegra/nct_sysfs.c

index f6f1889..dc4a8a9 100644 (file)
@@ -42,7 +42,16 @@ enum nct_id_type {
        NCT_ID_RAMDUMP,
        NCT_ID_TEST,
        NCT_ID_BOARD_INFO,
-       NCT_ID_END = NCT_ID_BOARD_INFO,
+       NCT_ID_GPS_ID,
+       NCT_ID_LCD_ID,
+       NCT_ID_ACCELEROMETER_ID,
+       NCT_ID_COMPASS_ID,
+       NCT_ID_GYROSCOPE_ID,
+       NCT_ID_LIGHT_ID,
+       NCT_ID_CHARGER_ID,
+       NCT_ID_TOUCH_ID,
+       NCT_ID_FUELGAUGE_ID,
+       NCT_ID_END = NCT_ID_FUELGAUGE_ID,
        NCT_ID_DISABLED = 0xEEEE,
        NCT_ID_MAX = 0xFFFF
 };
@@ -92,6 +101,15 @@ union nct_item_type {
        struct nct_factory_mode_type    factory_mode;
        struct nct_ramdump_type         ramdump;
        struct nct_board_info_type      board_info;
+       struct nct_lbh_id_type          gps_id;
+       struct nct_lbh_id_type          lcd_id;
+       struct nct_lbh_id_type          accelerometer_id;
+       struct nct_lbh_id_type          compass_id;
+       struct nct_lbh_id_type          gyroscope_id;
+       struct nct_lbh_id_type          light_id;
+       struct nct_lbh_id_type          charger_id;
+       struct nct_lbh_id_type          touch_id;
+       u8      fuelgauge_id[MAX_NCT_DATA_SIZE];
        u8      u8[MAX_NCT_DATA_SIZE];
        u16     u16[MAX_NCT_DATA_SIZE/2];
        u32     u32[MAX_NCT_DATA_SIZE/4];
index 1f71961..0f81689 100644 (file)
@@ -51,6 +51,22 @@ static const struct kobj_attribute cm_id_attr =
        __ATTR(cm_id, 0444, nct_item_show, 0);
 static const struct kobj_attribute lbh_id_attr =
        __ATTR(lbh_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute gps_id_attr =
+       __ATTR(gps_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute lcd_id_attr =
+       __ATTR(lcd_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute accelerometer_id_attr =
+       __ATTR(accelerometer_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute compass_id_attr =
+       __ATTR(compass_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute gyroscope_id_attr =
+       __ATTR(gyroscope_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute light_id_attr =
+       __ATTR(light_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute charger_id_attr =
+       __ATTR(charger_id, 0444, nct_item_show, 0);
+static const struct kobj_attribute touch_id_attr =
+       __ATTR(touch_id, 0444, nct_item_show, 0);
 
 static const struct attribute *nct_item_attrs[] = {
        &serial_number_attr.attr,
@@ -58,6 +74,14 @@ static const struct attribute *nct_item_attrs[] = {
        &bt_addr_attr.attr,
        &cm_id_attr.attr,
        &lbh_id_attr.attr,
+       &gps_id_attr.attr,
+       &lcd_id_attr.attr,
+       &accelerometer_id_attr.attr,
+       &compass_id_attr.attr,
+       &gyroscope_id_attr.attr,
+       &light_id_attr.attr,
+       &charger_id_attr.attr,
+       &touch_id_attr.attr,
        NULL
 };
 
@@ -105,6 +129,46 @@ static ssize_t nct_item_show(struct kobject *kobj,
                if (err < 0)
                        return 0;
                rval = sprintf(buf, "%04d\n", item.lbh_id.id);
+       } else if (attr == &gps_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_GPS_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.gps_id.id);
+       } else if (attr == &lcd_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_LCD_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.lcd_id.id);
+       } else if (attr == &accelerometer_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_ACCELEROMETER_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.accelerometer_id.id);
+       } else if (attr == &compass_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_COMPASS_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.compass_id.id);
+       } else if (attr == &gyroscope_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_GYROSCOPE_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.gyroscope_id.id);
+       } else if (attr == &light_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_LIGHT_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.light_id.id);
+       } else if (attr == &charger_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_CHARGER_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.charger_id.id);
+       } else if (attr == &touch_id_attr) {
+               err = tegra_nct_read_item(NCT_ID_TOUCH_ID, &item);
+               if (err < 0)
+                       return 0;
+               rval = sprintf(buf, "%04d\n", item.touch_id.id);
        }
 
        return rval;