blob: c1020654876e82faa7a9197e2dcca78e503b3b7e [file] [log] [blame]
Ralf Baechlee01402b2005-07-14 15:57:16 +00001/*
Steven J. Hill5792bf62014-01-01 16:35:32 +01002 * 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 *
Ralf Baechlee01402b2005-07-14 15:57:16 +00006 * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved.
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +01007 * Copyright (C) 2013 Imagination Technologies Ltd.
Ralf Baechlee01402b2005-07-14 15:57:16 +00008 */
Vegard Nossum2cc3c0b2008-05-27 17:27:28 +02009#ifndef __ASM_RTLX_H_
Ralf Baechle26009902006-04-05 09:45:45 +010010#define __ASM_RTLX_H_
Ralf Baechlee01402b2005-07-14 15:57:16 +000011
Atsushi Nemoto97dcb822007-01-08 02:14:29 +090012#include <irq.h>
13
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010014#define RTLX_MODULE_NAME "rtlx"
15
Ralf Baechlee01402b2005-07-14 15:57:16 +000016#define LX_NODE_BASE 10
17
Ralf Baechlee01402b2005-07-14 15:57:16 +000018#define MIPS_CPU_RTLX_IRQ 0
19
Ralf Baechle26009902006-04-05 09:45:45 +010020#define RTLX_VERSION 2
Ralf Baechlee01402b2005-07-14 15:57:16 +000021#define RTLX_xID 0x12345600
22#define RTLX_ID (RTLX_xID | RTLX_VERSION)
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010023#define RTLX_BUFFER_SIZE 2048
Ralf Baechlee01402b2005-07-14 15:57:16 +000024#define RTLX_CHANNELS 8
25
Ralf Baechle26009902006-04-05 09:45:45 +010026#define RTLX_CHANNEL_STDIO 0
27#define RTLX_CHANNEL_DBG 1
28#define RTLX_CHANNEL_SYSIO 2
Ralf Baechleafc48412005-10-31 00:30:39 +000029
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010030void rtlx_starting(int vpe);
31void rtlx_stopping(int vpe);
32
33int rtlx_open(int index, int can_sleep);
34int rtlx_release(int index);
35ssize_t rtlx_read(int index, void __user *buff, size_t count);
36ssize_t rtlx_write(int index, const void __user *buffer, size_t count);
37unsigned int rtlx_read_poll(int index, int can_sleep);
38unsigned int rtlx_write_poll(int index);
39
40int __init rtlx_module_init(void);
41void __exit rtlx_module_exit(void);
42
43void _interrupt_sp(void);
44
45extern struct vpe_notifications rtlx_notify;
46extern const struct file_operations rtlx_fops;
47extern void (*aprp_hook)(void);
Ralf Baechle26009902006-04-05 09:45:45 +010048
49enum rtlx_state {
Kevin D. Kissell1928cc82008-04-16 15:32:22 +020050 RTLX_STATE_UNUSED = 0,
Ralf Baechle26009902006-04-05 09:45:45 +010051 RTLX_STATE_INITIALISED,
52 RTLX_STATE_REMOTE_READY,
53 RTLX_STATE_OPENED
54};
55
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010056extern struct chan_waitqueues {
57 wait_queue_head_t rt_queue;
58 wait_queue_head_t lx_queue;
59 atomic_t in_open;
60 struct mutex mutex;
61} channel_wqs[RTLX_CHANNELS];
Ralf Baechleafc48412005-10-31 00:30:39 +000062
Ralf Baechlee01402b2005-07-14 15:57:16 +000063/* each channel supports read and write.
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010064 linux (vpe0) reads lx_buffer and writes rt_buffer
Ralf Baechlee01402b2005-07-14 15:57:16 +000065 SP (vpe1) reads rt_buffer and writes lx_buffer
66*/
Ralf Baechleafc48412005-10-31 00:30:39 +000067struct rtlx_channel {
Ralf Baechle26009902006-04-05 09:45:45 +010068 enum rtlx_state rt_state;
69 enum rtlx_state lx_state;
Ralf Baechlee01402b2005-07-14 15:57:16 +000070
71 int buffer_size;
72
73 /* read and write indexes per buffer */
74 int rt_write, rt_read;
75 char *rt_buffer;
76
77 int lx_write, lx_read;
78 char *lx_buffer;
Ralf Baechleafc48412005-10-31 00:30:39 +000079};
Ralf Baechlee01402b2005-07-14 15:57:16 +000080
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010081extern struct rtlx_info {
Ralf Baechlee01402b2005-07-14 15:57:16 +000082 unsigned long id;
Ralf Baechle26009902006-04-05 09:45:45 +010083 enum rtlx_state state;
Deng-Cheng Zhuda615cf2014-01-01 16:29:03 +010084 int ap_int_pending; /* Status of 0 or 1 for CONFIG_MIPS_CMP only */
Ralf Baechlee01402b2005-07-14 15:57:16 +000085
86 struct rtlx_channel channel[RTLX_CHANNELS];
Deng-Cheng Zhu2c973ef2014-01-01 16:26:46 +010087} *rtlx;
Ralf Baechle26009902006-04-05 09:45:45 +010088#endif /* __ASM_RTLX_H_ */