Skip to content

Commit da615cf

Browse files
dczhuralfbaechle
authored andcommitted
MIPS: APRP: Add RTLX API support for CMP platforms.
This patch adds RTLX API support for platforms having a CMP. Signed-off-by: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com> Signed-off-by: Steven J. Hill <Steven.Hill@imgtec.com> Reviewed-by: Qais Yousef <Qais.Yousef@imgtec.com> Patchwork: http://patchwork.linux-mips.org/patch/6095/ Reviewed-by: John Crispin <blogic@openwrt.org>
1 parent 2c973ef commit da615cf

4 files changed

Lines changed: 123 additions & 0 deletions

File tree

‎arch/mips/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,11 @@ config MIPS_VPE_APSP_API
19561956
depends on MIPS_VPE_LOADER
19571957
help
19581958

1959+
config MIPS_VPE_APSP_API_CMP
1960+
bool
1961+
default "y"
1962+
depends on MIPS_VPE_APSP_API && MIPS_CMP
1963+
19591964
config MIPS_VPE_APSP_API_MT
19601965
bool
19611966
default "y"

‎arch/mips/include/asm/rtlx.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct rtlx_channel {
7878
extern struct rtlx_info {
7979
unsigned long id;
8080
enum rtlx_state state;
81+
int ap_int_pending; /* Status of 0 or 1 for CONFIG_MIPS_CMP only */
8182

8283
struct rtlx_channel channel[RTLX_CHANNELS];
8384
} *rtlx;

‎arch/mips/kernel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o
5959
obj-$(CONFIG_MIPS_VPE_LOADER_CMP) += vpe-cmp.o
6060
obj-$(CONFIG_MIPS_VPE_LOADER_MT) += vpe-mt.o
6161
obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
62+
obj-$(CONFIG_MIPS_VPE_APSP_API_CMP) += rtlx-cmp.o
6263
obj-$(CONFIG_MIPS_VPE_APSP_API_MT) += rtlx-mt.o
6364

6465
obj-$(CONFIG_I8259) += i8259.o

‎arch/mips/kernel/rtlx-cmp.c‎

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
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
4+
* for more details.
5+
*
6+
* Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
7+
* Copyright (C) 2013 Imagination Technologies Ltd.
8+
*/
9+
#include <linux/device.h>
10+
#include <linux/fs.h>
11+
#include <linux/err.h>
12+
#include <linux/wait.h>
13+
#include <linux/sched.h>
14+
#include <linux/smp.h>
15+
16+
#include <asm/mips_mt.h>
17+
#include <asm/vpe.h>
18+
#include <asm/rtlx.h>
19+
20+
static int major;
21+
22+
static void rtlx_interrupt(void)
23+
{
24+
int i;
25+
struct rtlx_info *info;
26+
struct rtlx_info **p = vpe_get_shared(aprp_cpu_index());
27+
28+
if (p == NULL || *p == NULL)
29+
return;
30+
31+
info = *p;
32+
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);
37+
}
38+
info->ap_int_pending = 0;
39+
}
40+
}
41+
42+
void _interrupt_sp(void)
43+
{
44+
smp_send_reschedule(aprp_cpu_index());
45+
}
46+
47+
int __init rtlx_module_init(void)
48+
{
49+
struct device *dev;
50+
int i, err;
51+
52+
if (!cpu_has_mipsmt) {
53+
pr_warn("VPE loader: not a MIPS MT capable processor\n");
54+
return -ENODEV;
55+
}
56+
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");
60+
61+
return -ENODEV;
62+
}
63+
64+
major = register_chrdev(0, RTLX_MODULE_NAME, &rtlx_fops);
65+
if (major < 0) {
66+
pr_err("rtlx_module_init: unable to register device\n");
67+
return major;
68+
}
69+
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);
76+
77+
dev = device_create(mt_class, NULL, MKDEV(major, i), NULL,
78+
"%s%d", RTLX_MODULE_NAME, i);
79+
if (IS_ERR(dev)) {
80+
err = PTR_ERR(dev);
81+
goto out_chrdev;
82+
}
83+
}
84+
85+
/* set up notifiers */
86+
rtlx_notify.start = rtlx_starting;
87+
rtlx_notify.stop = rtlx_stopping;
88+
vpe_notify(aprp_cpu_index(), &rtlx_notify);
89+
90+
if (cpu_has_vint) {
91+
aprp_hook = rtlx_interrupt;
92+
} else {
93+
pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
94+
err = -ENODEV;
95+
goto out_class;
96+
}
97+
98+
return 0;
99+
100+
out_class:
101+
for (i = 0; i < RTLX_CHANNELS; i++)
102+
device_destroy(mt_class, MKDEV(major, i));
103+
out_chrdev:
104+
unregister_chrdev(major, RTLX_MODULE_NAME);
105+
106+
return err;
107+
}
108+
109+
void __exit rtlx_module_exit(void)
110+
{
111+
int i;
112+
113+
for (i = 0; i < RTLX_CHANNELS; i++)
114+
device_destroy(mt_class, MKDEV(major, i));
115+
unregister_chrdev(major, RTLX_MODULE_NAME);
116+
}

0 commit comments

Comments
 (0)