1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/device.h>
16#include <linux/fs.h>
17#include <linux/kernel.h>
18#include <linux/miscdevice.h>
19#include <linux/module.h>
20
21#define CMD_COREB_START _IO('b', 0)
22#define CMD_COREB_STOP _IO('b', 1)
23#define CMD_COREB_RESET _IO('b', 2)
24
25static long
26coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
27{
28 int ret = 0;
29
30 switch (cmd) {
31 case CMD_COREB_START:
32 bfin_write_SYSCR(bfin_read_SYSCR() & ~0x0020);
33 break;
34 case CMD_COREB_STOP:
35 bfin_write_SYSCR(bfin_read_SYSCR() | 0x0020);
36 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
37 break;
38 case CMD_COREB_RESET:
39 bfin_write_SICB_SYSCR(bfin_read_SICB_SYSCR() | 0x0080);
40 break;
41 default:
42 ret = -EINVAL;
43 break;
44 }
45
46 CSYNC();
47
48 return ret;
49}
50
51static const struct file_operations coreb_fops = {
52 .owner = THIS_MODULE,
53 .unlocked_ioctl = coreb_ioctl,
54 .llseek = noop_llseek,
55};
56
57static struct miscdevice coreb_dev = {
58 .minor = MISC_DYNAMIC_MINOR,
59 .name = "coreb",
60 .fops = &coreb_fops,
61};
62
63static int __init bf561_coreb_init(void)
64{
65 return misc_register(&coreb_dev);
66}
67module_init(bf561_coreb_init);
68
69static void __exit bf561_coreb_exit(void)
70{
71 misc_deregister(&coreb_dev);
72}
73module_exit(bf561_coreb_exit);
74
75MODULE_AUTHOR("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>");
76MODULE_DESCRIPTION("BF561 Core B Support");
77MODULE_LICENSE("GPL");
78