1b22537c6SNicolas Pitre /* 2b22537c6SNicolas Pitre * arch/arm/common/bL_switcher_dummy_if.c -- b.L switcher dummy interface 3b22537c6SNicolas Pitre * 4b22537c6SNicolas Pitre * Created by: Nicolas Pitre, November 2012 5b22537c6SNicolas Pitre * Copyright: (C) 2012-2013 Linaro Limited 6b22537c6SNicolas Pitre * 7b22537c6SNicolas Pitre * Dummy interface to user space for debugging purpose only. 8b22537c6SNicolas Pitre * 9b22537c6SNicolas Pitre * This program is free software; you can redistribute it and/or modify 10b22537c6SNicolas Pitre * it under the terms of the GNU General Public License version 2 as 11b22537c6SNicolas Pitre * published by the Free Software Foundation. 12b22537c6SNicolas Pitre */ 13b22537c6SNicolas Pitre 14b22537c6SNicolas Pitre #include <linux/init.h> 15b22537c6SNicolas Pitre #include <linux/module.h> 16b22537c6SNicolas Pitre #include <linux/fs.h> 17b22537c6SNicolas Pitre #include <linux/miscdevice.h> 18b22537c6SNicolas Pitre #include <asm/uaccess.h> 19b22537c6SNicolas Pitre #include <asm/bL_switcher.h> 20b22537c6SNicolas Pitre 21b22537c6SNicolas Pitre static ssize_t bL_switcher_write(struct file *file, const char __user *buf, 22b22537c6SNicolas Pitre size_t len, loff_t *pos) 23b22537c6SNicolas Pitre { 24b22537c6SNicolas Pitre unsigned char val[3]; 25b22537c6SNicolas Pitre unsigned int cpu, cluster; 26b22537c6SNicolas Pitre int ret; 27b22537c6SNicolas Pitre 28b22537c6SNicolas Pitre pr_debug("%s\n", __func__); 29b22537c6SNicolas Pitre 30b22537c6SNicolas Pitre if (len < 3) 31b22537c6SNicolas Pitre return -EINVAL; 32b22537c6SNicolas Pitre 33b22537c6SNicolas Pitre if (copy_from_user(val, buf, 3)) 34b22537c6SNicolas Pitre return -EFAULT; 35b22537c6SNicolas Pitre 36b22537c6SNicolas Pitre /* format: <cpu#>,<cluster#> */ 37b22537c6SNicolas Pitre if (val[0] < '0' || val[0] > '9' || 38b22537c6SNicolas Pitre val[1] != ',' || 39b22537c6SNicolas Pitre val[2] < '0' || val[2] > '1') 40b22537c6SNicolas Pitre return -EINVAL; 41b22537c6SNicolas Pitre 42b22537c6SNicolas Pitre cpu = val[0] - '0'; 43b22537c6SNicolas Pitre cluster = val[2] - '0'; 44b22537c6SNicolas Pitre ret = bL_switch_request(cpu, cluster); 45b22537c6SNicolas Pitre 46b22537c6SNicolas Pitre return ret ? : len; 47b22537c6SNicolas Pitre } 48b22537c6SNicolas Pitre 49b22537c6SNicolas Pitre static const struct file_operations bL_switcher_fops = { 50b22537c6SNicolas Pitre .write = bL_switcher_write, 51b22537c6SNicolas Pitre .owner = THIS_MODULE, 52b22537c6SNicolas Pitre }; 53b22537c6SNicolas Pitre 54b22537c6SNicolas Pitre static struct miscdevice bL_switcher_device = { 55b22537c6SNicolas Pitre MISC_DYNAMIC_MINOR, 56b22537c6SNicolas Pitre "b.L_switcher", 57b22537c6SNicolas Pitre &bL_switcher_fops 58b22537c6SNicolas Pitre }; 59b22537c6SNicolas Pitre 60b22537c6SNicolas Pitre static int __init bL_switcher_dummy_if_init(void) 61b22537c6SNicolas Pitre { 62b22537c6SNicolas Pitre return misc_register(&bL_switcher_device); 63b22537c6SNicolas Pitre } 64b22537c6SNicolas Pitre 65b22537c6SNicolas Pitre static void __exit bL_switcher_dummy_if_exit(void) 66b22537c6SNicolas Pitre { 67b22537c6SNicolas Pitre misc_deregister(&bL_switcher_device); 68b22537c6SNicolas Pitre } 69b22537c6SNicolas Pitre 70b22537c6SNicolas Pitre module_init(bL_switcher_dummy_if_init); 71b22537c6SNicolas Pitre module_exit(bL_switcher_dummy_if_exit); 72