diff options
author | codeworkx <codeworkx@cyanogenmod.com> | 2012-09-22 09:48:20 +0200 |
---|---|---|
committer | codeworkx <codeworkx@cyanogenmod.com> | 2012-09-22 14:02:16 +0200 |
commit | 2489007e7d740ccbc3e0a202914e243ad5178787 (patch) | |
tree | b8e6380ea7b1da63474ad68a5dba997e01146043 /drivers/misc/tzic.c | |
parent | 5f67568eb31e3a813c7c52461dcf66ade15fc2e7 (diff) | |
download | kernel_samsung_smdk4412-2489007e7d740ccbc3e0a202914e243ad5178787.zip kernel_samsung_smdk4412-2489007e7d740ccbc3e0a202914e243ad5178787.tar.gz kernel_samsung_smdk4412-2489007e7d740ccbc3e0a202914e243ad5178787.tar.bz2 |
merge opensource jb u5
Change-Id: I1aaec157aa196f3448eff8636134fce89a814cf2
Diffstat (limited to 'drivers/misc/tzic.c')
-rw-r--r-- | drivers/misc/tzic.c | 109 |
1 files changed, 79 insertions, 30 deletions
diff --git a/drivers/misc/tzic.c b/drivers/misc/tzic.c index 93e25bd..e1da409 100644 --- a/drivers/misc/tzic.c +++ b/drivers/misc/tzic.c @@ -50,15 +50,60 @@ u32 exynos_smc1(u32 cmd, u32 arg1, u32 arg2, u32 arg3) return reg0; } +#if defined(CONFIG_FELICA) +int exynos_smc_read_oemflag(u32 ctrl_word, u32 *val) +{ + register u32 reg0 __asm__("r0"); + register u32 reg1 __asm__("r1"); + register u32 reg2 __asm__("r2"); + register u32 reg3 __asm__("r3"); + u32 idx = 0; + + for (idx = 0; reg2 != ctrl_word; idx++) { + reg0 = -202; + reg1 = 1; + reg2 = idx; + + __asm__ volatile ( + ".arch_extension sec\n" + "smc 0\n" + :"+r" (reg0), "+r"(reg1), + "+r"(reg2), "+r"(reg3) + ); + if (reg1) + return -1; + } + + reg0 = -202; + reg1 = 1; + reg2 = idx; + + __asm__ volatile ( + ".arch_extension sec\n" + "smc 0\n" + :"+r" (reg0), "+r"(reg1), "+r"(reg2), + "+r"(reg3) + ); + if (reg1) + return -1; + + *val = reg2; + + return 0; +} +#endif + static DEFINE_MUTEX(tzic_mutex); static struct class *driver_class; static dev_t tzic_device_no; static struct cdev tzic_cdev; #define LOG printk +#define TZIC_IOC_MAGIC 0x9E +#define TZIC_IOCTL_SET_FUSE_REQ _IO(TZIC_IOC_MAGIC, 1) +#define TZIC_IOCTL_GET_FUSE_REQ _IOR(TZIC_IOC_MAGIC, 0, unsigned int) -static long tzic_ioctl(struct file *file, unsigned cmd, - unsigned long arg) +static long tzic_ioctl(struct file *file, unsigned cmd, unsigned long arg) { int ret = 0; @@ -68,9 +113,20 @@ static long tzic_ioctl(struct file *file, unsigned cmd, return -1; } - LOG(KERN_INFO "set_fuse"); - exynos_smc1(SMC_CMD_STORE_BINFO, 0x80010001, 0, 0); - exynos_smc1(SMC_CMD_STORE_BINFO, 0x00000001, 0, 0); + if (cmd == TZIC_IOCTL_SET_FUSE_REQ) { + LOG(KERN_INFO "set_fuse"); + exynos_smc1(SMC_CMD_STORE_BINFO, 0x80010001, 0, 0); + exynos_smc1(SMC_CMD_STORE_BINFO, 0x00000001, 0, 0); + } else if (cmd == TZIC_IOCTL_GET_FUSE_REQ) { + LOG(KERN_INFO "get_fuse"); +#if defined(CONFIG_FELICA) + exynos_smc_read_oemflag(0x80010001, (u32 *) arg); +#else + LOG(KERN_INFO "get_fuse not supported : CONFIG_FELICA"); +#endif + } else { + LOG(KERN_INFO "command error"); + } gotoAllCpu(); @@ -101,7 +157,7 @@ static int __init tzic_init(void) } class_dev = device_create(driver_class, NULL, tzic_device_no, NULL, - TZIC_DEV); + TZIC_DEV); if (!class_dev) { LOG(KERN_INFO "class_device_create failed %d", rc); rc = -ENOMEM; @@ -119,11 +175,11 @@ static int __init tzic_init(void) return 0; -class_device_destroy: + class_device_destroy: device_destroy(driver_class, tzic_device_no); -class_destroy: + class_destroy: class_destroy(driver_class); -unregister_chrdev_region: + unregister_chrdev_region: unregister_chrdev_region(tzic_device_no, 1); return rc; } @@ -137,42 +193,36 @@ static void __exit tzic_exit(void) static int gotoCpu0(void) { - int ret = 0; - struct cpumask mask = CPU_MASK_CPU0; + int ret = 0; + struct cpumask mask = CPU_MASK_CPU0; LOG(KERN_INFO "System has %d CPU's, we are on CPU #%d\n" - "\tBinding this process to CPU #0.\n" - "\tactive mask is %lx, setting it to mask=%lx\n", - nr_cpu_ids, - raw_smp_processor_id(), - cpu_active_mask->bits[0], - mask.bits[0]); + "\tBinding this process to CPU #0.\n" + "\tactive mask is %lx, setting it to mask=%lx\n", + nr_cpu_ids, + raw_smp_processor_id(), cpu_active_mask->bits[0], mask.bits[0]); ret = set_cpus_allowed_ptr(current, &mask); if (0 != ret) LOG(KERN_INFO "set_cpus_allowed_ptr=%d.\n", ret); - LOG(KERN_INFO "And now we are on CPU #%d", - raw_smp_processor_id()); + LOG(KERN_INFO "And now we are on CPU #%d", raw_smp_processor_id()); return ret; } static int gotoAllCpu(void) { - int ret = 0; - struct cpumask mask = CPU_MASK_ALL; + int ret = 0; + struct cpumask mask = CPU_MASK_ALL; LOG(KERN_INFO "System has %d CPU's, we are on CPU #%d\n" - "\tBinding this process to CPU #0.\n" - "\tactive mask is %lx, setting it to mask=%lx\n", - nr_cpu_ids, - raw_smp_processor_id(), - cpu_active_mask->bits[0], - mask.bits[0]); + "\tBinding this process to CPU #0.\n" + "\tactive mask is %lx, setting it to mask=%lx\n", + nr_cpu_ids, + raw_smp_processor_id(), cpu_active_mask->bits[0], mask.bits[0]); ret = set_cpus_allowed_ptr(current, &mask); if (0 != ret) LOG(KERN_INFO "set_cpus_allowed_ptr=%d.\n", ret); - LOG(KERN_INFO "And now we are on CPU #%d", - raw_smp_processor_id()); + LOG(KERN_INFO "And now we are on CPU #%d", raw_smp_processor_id()); return ret; } @@ -183,4 +233,3 @@ MODULE_VERSION("1.00"); module_init(tzic_init); module_exit(tzic_exit); - |