2 #include <linux/gpio.h>
3 #include <linux/delay.h>
6 #include <plat/gpio-cfg.h>
10 extern struct class *sec_class;
11 struct device *slot_switch_dev;
13 static ssize_t get_slot_switch(struct device *dev, struct device_attribute *attr, char *buf)
17 //return '0' slot path is '||', return '1' slot path is 'X'
18 value = gpio_get_value(GPIO_UIM_SIM_SEL);
19 #if defined(CONFIG_MACH_T0_CHN_CTC)
21 value = (~value & 0x1);
23 printk("Current Slot is %x\n", value);
25 return sprintf(buf, "%d\n", value);
28 static ssize_t set_slot_switch(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
32 sscanf(buf, "%d", &value);
36 #if defined(CONFIG_MACH_T0_CHN_CTC)
38 gpio_set_value(GPIO_UIM_SIM_SEL, 1);
41 gpio_set_value(GPIO_UIM_SIM_SEL, 0);
42 printk("set slot switch to %x\n", gpio_get_value(GPIO_UIM_SIM_SEL));
45 #if defined(CONFIG_MACH_T0_CHN_CTC)
47 gpio_set_value(GPIO_UIM_SIM_SEL, 0);
50 gpio_set_value(GPIO_UIM_SIM_SEL, 1);
51 printk("set slot switch to %x\n", gpio_get_value(GPIO_UIM_SIM_SEL));
54 printk("Enter 0 or 1!!\n");
60 static DEVICE_ATTR(slot_sel, S_IRUGO | S_IWUSR | S_IWGRP,
61 get_slot_switch, set_slot_switch);
63 static int __init slot_switch_manager_init(void)
68 printk("slot_switch_manager_init\n");
70 //initailize uim_sim_switch gpio
71 err = gpio_request(GPIO_UIM_SIM_SEL, "PDA_ACTIVE");
73 pr_err("fail to request gpio %s, gpio %d, errno %d\n",
74 "PDA_ACTIVE", GPIO_UIM_SIM_SEL, err);
76 gpio_direction_output(GPIO_UIM_SIM_SEL, 1);
77 s3c_gpio_setpull(GPIO_UIM_SIM_SEL, S3C_GPIO_PULL_NONE);
78 #if defined(CONFIG_MACH_T0_CHN_CTC)
80 gpio_set_value(GPIO_UIM_SIM_SEL, 1);
83 gpio_set_value(GPIO_UIM_SIM_SEL, 0);
86 //initailize slot switch device
87 slot_switch_dev = device_create(sec_class,
88 NULL, 0, NULL, "slot_switch");
89 if (IS_ERR(slot_switch_dev))
90 pr_err("Failed to create device(switch)!\n");
92 if (device_create_file(slot_switch_dev, &dev_attr_slot_sel) < 0)
93 pr_err("Failed to create device file(%s)!\n",
94 dev_attr_slot_sel.attr.name);
99 static void __exit slot_switch_manager_exit(void)
103 module_init(slot_switch_manager_init);
104 module_exit(slot_switch_manager_exit);
106 MODULE_AUTHOR("SAMSUNG ELECTRONICS CO., LTD");
107 MODULE_DESCRIPTION("Slot Switch");
108 MODULE_LICENSE("GPL");