2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
7 * Copyright (C) 2013 Imagination Technologies Ltd.
9 #include <linux/device.h>
11 #include <linux/err.h>
12 #include <linux/wait.h>
13 #include <linux/sched.h>
14 #include <linux/smp.h>
16 #include <asm/mips_mt.h>
22 static void rtlx_interrupt(void)
25 struct rtlx_info
*info
;
26 struct rtlx_info
**p
= vpe_get_shared(aprp_cpu_index());
28 if (p
== NULL
|| *p
== NULL
)
33 if (info
->ap_int_pending
== 1 && smp_processor_id() == 0) {
34 for (i
= 0; i
< RTLX_CHANNELS
; i
++) {
35 wake_up(&channel_wqs
[i
].lx_queue
);
36 wake_up(&channel_wqs
[i
].rt_queue
);
38 info
->ap_int_pending
= 0;
42 void _interrupt_sp(void)
44 smp_send_reschedule(aprp_cpu_index());
47 int __init
rtlx_module_init(void)
52 if (!cpu_has_mipsmt
) {
53 pr_warn("VPE loader: not a MIPS MT capable processor\n");
57 if (num_possible_cpus() - aprp_cpu_index() < 1) {
58 pr_warn("No TCs reserved for AP/SP, not initializing RTLX.\n"
59 "Pass maxcpus=<n> argument as kernel argument\n");
64 major
= register_chrdev(0, RTLX_MODULE_NAME
, &rtlx_fops
);
66 pr_err("rtlx_module_init: unable to register device\n");
70 /* initialise the wait queues */
71 for (i
= 0; i
< RTLX_CHANNELS
; i
++) {
72 init_waitqueue_head(&channel_wqs
[i
].rt_queue
);
73 init_waitqueue_head(&channel_wqs
[i
].lx_queue
);
74 atomic_set(&channel_wqs
[i
].in_open
, 0);
75 mutex_init(&channel_wqs
[i
].mutex
);
77 dev
= device_create(mt_class
, NULL
, MKDEV(major
, i
), NULL
,
78 "%s%d", RTLX_MODULE_NAME
, i
);
81 device_destroy(mt_class
, MKDEV(major
, i
));
88 /* set up notifiers */
89 rtlx_notify
.start
= rtlx_starting
;
90 rtlx_notify
.stop
= rtlx_stopping
;
91 vpe_notify(aprp_cpu_index(), &rtlx_notify
);
94 aprp_hook
= rtlx_interrupt
;
96 pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
104 for (i
= 0; i
< RTLX_CHANNELS
; i
++)
105 device_destroy(mt_class
, MKDEV(major
, i
));
107 unregister_chrdev(major
, RTLX_MODULE_NAME
);
112 void __exit
rtlx_module_exit(void)
116 for (i
= 0; i
< RTLX_CHANNELS
; i
++)
117 device_destroy(mt_class
, MKDEV(major
, i
));
119 unregister_chrdev(major
, RTLX_MODULE_NAME
);