Merge tag 'v3.10.55' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / mssv.c
1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include <linux/init.h>
4 #include <linux/device.h>
5 #include <linux/platform_device.h>
6
7 extern u32 PTP_INIT_01_API(void);
8
9 static ssize_t track_vsram_show(struct device_driver *driver, char *buf)
10 {
11 return 0;
12 }
13
14 static ssize_t track_vsram_store(struct device_driver *driver, const char *buf, size_t count)
15 {
16 return count;
17 }
18
19 DRIVER_ATTR(track_vsram, 0644, track_vsram_show, track_vsram_store);
20
21 static ssize_t ptp_od_show(struct device_driver *driver, char *buf)
22 {
23 volatile u32 *clc_temp_p;
24 u32 val;
25
26 clc_temp_p = (volatile u32 *)PTP_INIT_01_API();
27
28 if (clc_temp_p) {
29 /* only need bit 31 ~ bit 16 of the read data*/
30 val = clc_temp_p[0];
31 val >>= 16;
32 val &= 0x0000FFFF;
33
34 return snprintf(buf, PAGE_SIZE, "0x%x\n", val);
35 } else {
36 return snprintf(buf, PAGE_SIZE, "Not support PTP-OD\n");
37 }
38 }
39
40 static ssize_t ptp_od_store(struct device_driver *driver, const char *buf, size_t count)
41 {
42 return count;
43 }
44
45 DRIVER_ATTR(ptp_od, 0644, ptp_od_show, ptp_od_store);
46
47 static ssize_t chip_id_show(struct device_driver *driver, char *buf)
48 {
49 return snprintf(buf, PAGE_SIZE, "0x%x\n", *(volatile u32 *)0xF0009070);
50 }
51
52 static ssize_t chip_id_store(struct device_driver *driver, const char *buf, size_t count)
53 {
54 return count;
55 }
56
57 DRIVER_ATTR(chip_id, 0644, chip_id_show, chip_id_store);
58
59 struct mssv_driver
60 {
61 struct device_driver driver;
62 const struct platform_device_id *id_table;
63 };
64
65 static struct mssv_driver mssv_driver =
66 {
67 .driver =
68 {
69 .name = "mssv",
70 .bus = &platform_bus_type,
71 .owner = THIS_MODULE,
72 },
73 .id_table = NULL,
74 };
75
76 int mssv_init(void)
77 {
78 int ret;
79
80 ret = driver_register(&mssv_driver.driver);
81 if (ret) {
82 printk("Fail to register mssv_driver\n");
83 return ret;
84 }
85
86 ret = driver_create_file(&mssv_driver.driver, &driver_attr_track_vsram);
87 if (ret) {
88 printk("Fail to create mssv_driver sysfs files\n");
89 return ret;
90 }
91
92 ret = driver_create_file(&mssv_driver.driver, &driver_attr_ptp_od);
93 if (ret) {
94 printk("Fail to create mssv_driver sysfs files\n");
95 return ret;
96 }
97
98 ret = driver_create_file(&mssv_driver.driver, &driver_attr_chip_id);
99 if (ret) {
100 printk("Fail to create mssv_driver sysfs files\n");
101 return ret;
102 }
103
104 return 0;
105 }
106
107 arch_initcall(mssv_init);