aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ti-st
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/ti-st')
-rw-r--r--drivers/staging/ti-st/st_kim.c40
-rw-r--r--drivers/staging/ti-st/st_kim.h11
2 files changed, 46 insertions, 5 deletions
diff --git a/drivers/staging/ti-st/st_kim.c b/drivers/staging/ti-st/st_kim.c
index cfba5f88abe..d015ad3c460 100644
--- a/drivers/staging/ti-st/st_kim.c
+++ b/drivers/staging/ti-st/st_kim.c
@@ -56,12 +56,13 @@ static struct platform_driver kim_platform_driver = {
56}; 56};
57 57
58static ssize_t show_pid(struct device *dev, struct device_attribute 58static ssize_t show_pid(struct device *dev, struct device_attribute
59 *attr, char *buf); 59 *attr, char *buf);
60static ssize_t store_pid(struct device *dev, struct device_attribute 60static ssize_t store_pid(struct device *dev, struct device_attribute
61 *devattr, char *buf, size_t count); 61 *devattr, char *buf, size_t count);
62static ssize_t show_list(struct device *dev, struct device_attribute 62static ssize_t show_list(struct device *dev, struct device_attribute
63 *attr, char *buf); 63 *attr, char *buf);
64 64static ssize_t show_version(struct device *dev, struct device_attribute
65 *attr, char *buf);
65/* structures specific for sysfs entries */ 66/* structures specific for sysfs entries */
66static struct kobj_attribute pid_attr = 67static struct kobj_attribute pid_attr =
67__ATTR(pid, 0644, (void *)show_pid, (void *)store_pid); 68__ATTR(pid, 0644, (void *)show_pid, (void *)store_pid);
@@ -69,10 +70,14 @@ __ATTR(pid, 0644, (void *)show_pid, (void *)store_pid);
69static struct kobj_attribute list_protocols = 70static struct kobj_attribute list_protocols =
70__ATTR(protocols, 0444, (void *)show_list, NULL); 71__ATTR(protocols, 0444, (void *)show_list, NULL);
71 72
73static struct kobj_attribute chip_version =
74__ATTR(version, 0444, (void *)show_version, NULL);
75
72static struct attribute *uim_attrs[] = { 76static struct attribute *uim_attrs[] = {
73 &pid_attr.attr, 77 &pid_attr.attr,
74 /* add more debug sysfs entries */ 78 /* add more debug sysfs entries */
75 &list_protocols.attr, 79 &list_protocols.attr,
80 &chip_version.attr,
76 NULL, 81 NULL,
77}; 82};
78 83
@@ -251,7 +256,8 @@ static long read_local_version(char *bts_scr_name)
251 } 256 }
252 257
253 version = 258 version =
254 MAKEWORD(kim_gdata->resp_buffer[13], kim_gdata->resp_buffer[14]); 259 MAKEWORD(kim_gdata->resp_buffer[13],
260 kim_gdata->resp_buffer[14]);
255 chip = (version & 0x7C00) >> 10; 261 chip = (version & 0x7C00) >> 10;
256 min_ver = (version & 0x007F); 262 min_ver = (version & 0x007F);
257 maj_ver = (version & 0x0380) >> 7; 263 maj_ver = (version & 0x0380) >> 7;
@@ -260,6 +266,13 @@ static long read_local_version(char *bts_scr_name)
260 maj_ver |= 0x0008; 266 maj_ver |= 0x0008;
261 267
262 sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver); 268 sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver);
269
270 /* to be accessed later via sysfs entry */
271 kim_gdata->version.full = version;
272 kim_gdata->version.chip = chip;
273 kim_gdata->version.maj_ver = maj_ver;
274 kim_gdata->version.min_ver = min_ver;
275
263 pr_info("%s", bts_scr_name); 276 pr_info("%s", bts_scr_name);
264 return ST_SUCCESS; 277 return ST_SUCCESS;
265} 278}
@@ -516,6 +529,16 @@ long st_kim_stop(void)
516 529
517/**********************************************************************/ 530/**********************************************************************/
518/* functions called from subsystems */ 531/* functions called from subsystems */
532/* called when sysfs entry is read from */
533
534static ssize_t show_version(struct device *dev, struct device_attribute
535 *attr, char *buf)
536{
537 sprintf(buf, "%04X %d.%d.%d", kim_gdata->version.full,
538 kim_gdata->version.chip, kim_gdata->version.maj_ver,
539 kim_gdata->version.min_ver);
540 return strlen(buf);
541}
519 542
520/* called when sysfs entry is written to */ 543/* called when sysfs entry is written to */
521static ssize_t store_pid(struct device *dev, struct device_attribute 544static ssize_t store_pid(struct device *dev, struct device_attribute
@@ -656,6 +679,12 @@ static int kim_probe(struct platform_device *pdev)
656 } 679 }
657 pr_info("rfkill entry created for %ld", gpios[proto]); 680 pr_info("rfkill entry created for %ld", gpios[proto]);
658 } 681 }
682
683 if (sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp)) {
684 pr_err(" sysfs entry creation failed");
685 return -1;
686 }
687 pr_info(" sysfs entries created ");
659 return ST_SUCCESS; 688 return ST_SUCCESS;
660} 689}
661 690
@@ -676,6 +705,7 @@ static int kim_remove(struct platform_device *pdev)
676 kim_gdata->rfkill[proto] = NULL; 705 kim_gdata->rfkill[proto] = NULL;
677 } 706 }
678 pr_info("kim: GPIO Freed"); 707 pr_info("kim: GPIO Freed");
708 sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp);
679 kim_gdata->kim_pdev = NULL; 709 kim_gdata->kim_pdev = NULL;
680 st_core_exit(kim_gdata->core_data); 710 st_core_exit(kim_gdata->core_data);
681 return ST_SUCCESS; 711 return ST_SUCCESS;
diff --git a/drivers/staging/ti-st/st_kim.h b/drivers/staging/ti-st/st_kim.h
index 49c42aedb45..a5ea8d7c680 100644
--- a/drivers/staging/ti-st/st_kim.h
+++ b/drivers/staging/ti-st/st_kim.h
@@ -48,6 +48,16 @@
48 * devices are created for the 3 gpios 48 * devices are created for the 3 gpios
49 * that ST has requested 49 * that ST has requested
50 */ 50 */
51
52/* chip version storage
53 */
54struct chip_version {
55 unsigned short full;
56 unsigned short chip;
57 unsigned short min_ver;
58 unsigned short maj_ver;
59};
60
51/* 61/*
52 * header file for ST provided by KIM 62 * header file for ST provided by KIM
53 */ 63 */
@@ -66,6 +76,7 @@ struct kim_data_s {
66 struct rfkill *rfkill[ST_MAX]; 76 struct rfkill *rfkill[ST_MAX];
67 enum proto_type rf_protos[ST_MAX]; 77 enum proto_type rf_protos[ST_MAX];
68 struct st_data_s *core_data; 78 struct st_data_s *core_data;
79 struct chip_version version;
69}; 80};
70 81
71long st_kim_start(void); 82long st_kim_start(void);