1 #include <linux/init.h>
2 #include <linux/module.h>
3 #include <linux/kernel.h>
5 #include <linux/errno.h>
6 #include <linux/fcntl.h>
7 #include <linux/slab.h>
8 #include <linux/platform_device.h>
9 #include <linux/miscdevice.h>
10 #include <linux/device.h>
11 #include <linux/cdev.h>
12 #include <linux/sched.h>
13 #include <linux/spinlock.h>
15 unsigned int samsung_fota_config=0;
16 unsigned int samsung_fus_config=0;
17 unsigned int samsung_rtl_config=0;
19 static struct samsung_boot_mode_context {
21 } samsung_boot_mode_cxt;
25 samsung_fota_config_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
27 if(NULL == buf || count == 0 || count > PAGE_SIZE)
30 if (strstr(buf, "fota_disable") != NULL) {
31 samsung_fota_config=0;
33 else if(strstr(buf, "fota_enable") != NULL) {
34 samsung_fota_config=1;
41 samsung_fota_config_show(struct device *dev, struct device_attribute *attr, char *buf)
43 return sprintf(buf, "%d\n", samsung_fota_config);
46 // Firmware update service
48 samsung_fus_config_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
50 if(NULL == buf || count == 0 || count > PAGE_SIZE)
53 if (strstr(buf, "fus_disable")!= NULL) {
56 else if(strstr(buf, "fus_enable") != NULL) {
64 samsung_fus_config_show(struct device *dev, struct device_attribute *attr, char *buf)
66 return sprintf(buf, "%d\n", samsung_fus_config);
71 samsung_rtl_config_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
73 if(NULL == buf || count == 0 || count > PAGE_SIZE)
76 if (strstr(buf, "rtl_disable")!= NULL) {
79 else if(strstr(buf, "rtl_enable") != NULL) {
87 samsung_rtl_config_show(struct device *dev, struct device_attribute *attr, char *buf)
89 return sprintf(buf, "%d\n", samsung_rtl_config);
93 static DEVICE_ATTR(samsung_fota_config, S_IRUGO | S_IWUSR, samsung_fota_config_show, samsung_fota_config_store);
94 static DEVICE_ATTR(samsung_fus_config, S_IRUGO | S_IWUSR, samsung_fus_config_show, samsung_fus_config_store);
95 static DEVICE_ATTR(samsung_rtl_config, S_IRUGO | S_IWUSR, samsung_rtl_config_show, samsung_rtl_config_store);
97 static struct attribute *samsung_boot_mode_attrs[] = {
98 &dev_attr_samsung_fota_config.attr,
99 &dev_attr_samsung_fus_config.attr,
100 &dev_attr_samsung_rtl_config.attr,
104 static const struct attribute_group samsung_boot_mode_attr_group = {
105 .attrs = samsung_boot_mode_attrs,
109 static struct file_operations samsung_boot_mode_fops =
111 .owner = THIS_MODULE,
114 static struct miscdevice samsung_boot_mode_device = {
115 .minor = MISC_DYNAMIC_MINOR,
116 .name = "samsung_boot_mode",
117 .fops = &samsung_boot_mode_fops,
121 * The functions for inserting/removing us as a module.
124 static int __devinit samsung_boot_mode_probe(struct platform_device *pdev)
126 struct samsung_boot_mode_context *cxt = &samsung_boot_mode_cxt;
128 ret = misc_register(&samsung_boot_mode_device);
130 printk("samsung_boot_mode_device register failed\n");
134 ret = sysfs_create_group(&pdev->dev.kobj, &samsung_boot_mode_attr_group);
136 printk("samsung_boot_mode sysfs_create_group failed\n");
140 printk("samsung_boot_mode init done \n");
144 misc_deregister(&samsung_boot_mode_device);
149 static int __devexit samsung_boot_mode_remove(struct platform_device *pdev)
151 sysfs_remove_group(&pdev->dev.kobj, &samsung_boot_mode_attr_group);
152 misc_deregister(&samsung_boot_mode_device);
153 printk("samsung_boot_mode_exit done\n");
158 static struct platform_driver samsung_boot_mode_driver = {
159 .probe = samsung_boot_mode_probe,
160 .remove = __devexit_p(samsung_boot_mode_remove),
162 .owner = THIS_MODULE,
163 .name = "s3c_samsung_boot_mode",
167 int __init samsung_boot_mode_init(void)
169 printk("Samsung Boot Mode Setting Driver\n");
170 return platform_driver_register(&samsung_boot_mode_driver);
173 void __exit samsung_boot_mode_exit(void)
175 platform_driver_unregister(&samsung_boot_mode_driver);
178 module_init(samsung_boot_mode_init);
179 module_exit(samsung_boot_mode_exit);
181 MODULE_AUTHOR("Yeongil Jang <yg0577.jang@samsung.com>");
182 MODULE_DESCRIPTION("Virtual driver for changing booting mode");
183 MODULE_LICENSE("GPL");