comparison include/prussdrv.h @ 0:8a575ba3ab52

Initial commit.
author andrewm
date Fri, 31 Oct 2014 19:10:17 +0100
parents
children 901d205d1a3c
comparison
equal deleted inserted replaced
-1:000000000000 0:8a575ba3ab52
1 /*
2 * prussdrv.h
3 *
4 * Describes PRUSS userspace driver for Industrial Communications
5 *
6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7 *
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the
19 * distribution.
20 *
21 * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
38
39 /*
40 * ============================================================================
41 * Copyright (c) Texas Instruments Inc 2010-11
42 *
43 * Use of this software is controlled by the terms and conditions found in the
44 * license agreement under which this software has been supplied or provided.
45 * ============================================================================
46 */
47
48 #ifndef _PRUSSDRV_H
49 #define _PRUSSDRV_H
50
51 #include <sys/types.h>
52 #include <pthread.h>
53
54 #if defined (__cplusplus)
55 extern "C" {
56 #endif
57
58 #define NUM_PRU_HOSTIRQS 8
59 #define NUM_PRU_HOSTS 10
60 #define NUM_PRU_CHANNELS 10
61 #define NUM_PRU_SYS_EVTS 64
62
63 #define PRUSS0_PRU0_DATARAM 0
64 #define PRUSS0_PRU1_DATARAM 1
65 #define PRUSS0_PRU0_IRAM 2
66 #define PRUSS0_PRU1_IRAM 3
67
68 //Available in AM33xx series - begin
69 #define PRUSS0_SHARED_DATARAM 4
70 #define PRUSS0_CFG 5
71 #define PRUSS0_UART 6
72 #define PRUSS0_IEP 7
73 #define PRUSS0_ECAP 8
74 #define PRUSS0_MII_RT 9
75 #define PRUSS0_MDIO 10
76 //Available in AM33xx series - end
77
78 #define PRU_EVTOUT_0 0
79 #define PRU_EVTOUT_1 1
80 #define PRU_EVTOUT_2 2
81 #define PRU_EVTOUT_3 3
82 #define PRU_EVTOUT_4 4
83 #define PRU_EVTOUT_5 5
84 #define PRU_EVTOUT_6 6
85 #define PRU_EVTOUT_7 7
86
87 typedef void *(*prussdrv_function_handler) (void *);
88 typedef struct __sysevt_to_channel_map {
89 short sysevt;
90 short channel;
91 } tsysevt_to_channel_map;
92 typedef struct __channel_to_host_map {
93 short channel;
94 short host;
95 } tchannel_to_host_map;
96 typedef struct __pruss_intc_initdata {
97 //Enabled SYSEVTs - Range:0..63
98 //{-1} indicates end of list
99 char sysevts_enabled[NUM_PRU_SYS_EVTS];
100 //SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9
101 //{-1, -1} indicates end of list
102 tsysevt_to_channel_map sysevt_to_channel_map[NUM_PRU_SYS_EVTS];
103 //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9
104 //{-1, -1} indicates end of list
105 tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS];
106 //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7)
107 unsigned int host_enable_bitmask;
108 } tpruss_intc_initdata;
109
110 int prussdrv_init(void);
111
112 int prussdrv_open(unsigned int pru_evtout_num);
113
114 int prussdrv_pru_reset(unsigned int prunum);
115
116 int prussdrv_pru_disable(unsigned int prunum);
117
118 int prussdrv_pru_enable(unsigned int prunum);
119
120 int prussdrv_pru_write_memory(unsigned int pru_ram_id,
121 unsigned int wordoffset,
122 unsigned int *memarea,
123 unsigned int bytelength);
124
125 int prussdrv_pruintc_init(tpruss_intc_initdata * prussintc_init_data);
126
127 int prussdrv_map_l3mem(void **address);
128
129 int prussdrv_map_extmem(void **address);
130
131 int prussdrv_map_prumem(unsigned int pru_ram_id, void **address);
132
133 int prussdrv_map_peripheral_io(unsigned int per_id, void **address);
134
135 unsigned int prussdrv_get_phys_addr(void *address);
136
137 void *prussdrv_get_virt_addr(unsigned int phyaddr);
138
139 int prussdrv_pru_wait_event(unsigned int pru_evtout_num);
140
141 int prussdrv_pru_send_event(unsigned int eventnum);
142
143 int prussdrv_pru_clear_event(unsigned int eventnum);
144
145 int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum,
146 unsigned int pru_evtout_num,
147 unsigned int ack_eventnum);
148
149 int prussdrv_exit(void);
150
151 int prussdrv_exec_program(int prunum, char *filename);
152
153 int prussdrv_start_irqthread(unsigned int pru_evtout_num, int priority,
154 prussdrv_function_handler irqhandler);
155
156
157 #if defined (__cplusplus)
158 }
159 #endif
160 #endif