annotate include/prussdrv.h @ 556:ce391098f321 prerelease tip

THIS PROJECT HAS MOVED TO https://github.com/BelaPlatform/bela
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 25 Jun 2016 20:21:00 +0100
parents 901d205d1a3c
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 * prussdrv.h
andrewm@15 3 *
andrewm@0 4 * Describes PRUSS userspace driver for Industrial Communications
andrewm@0 5 *
andrewm@15 6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
andrewm@15 7 *
andrewm@15 8 *
andrewm@15 9 * Redistribution and use in source and binary forms, with or without
andrewm@15 10 * modification, are permitted provided that the following conditions
andrewm@0 11 * are met:
andrewm@0 12 *
andrewm@15 13 * Redistributions of source code must retain the above copyright
andrewm@0 14 * notice, this list of conditions and the following disclaimer.
andrewm@0 15 *
andrewm@0 16 * Redistributions in binary form must reproduce the above copyright
andrewm@15 17 * notice, this list of conditions and the following disclaimer in the
andrewm@15 18 * documentation and/or other materials provided with the
andrewm@0 19 * distribution.
andrewm@0 20 *
andrewm@0 21 * Neither the name of Texas Instruments Incorporated nor the names of
andrewm@0 22 * its contributors may be used to endorse or promote products derived
andrewm@0 23 * from this software without specific prior written permission.
andrewm@0 24 *
andrewm@15 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
andrewm@15 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
andrewm@0 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
andrewm@15 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
andrewm@15 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
andrewm@15 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
andrewm@0 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
andrewm@0 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
andrewm@15 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
andrewm@15 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
andrewm@0 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
andrewm@0 36 *
andrewm@0 37 */
andrewm@0 38
andrewm@0 39 /*
andrewm@0 40 * ============================================================================
andrewm@0 41 * Copyright (c) Texas Instruments Inc 2010-11
andrewm@0 42 *
andrewm@0 43 * Use of this software is controlled by the terms and conditions found in the
andrewm@0 44 * license agreement under which this software has been supplied or provided.
andrewm@0 45 * ============================================================================
andrewm@0 46 */
andrewm@0 47
andrewm@0 48 #ifndef _PRUSSDRV_H
andrewm@0 49 #define _PRUSSDRV_H
andrewm@0 50
andrewm@0 51 #include <sys/types.h>
andrewm@0 52
andrewm@0 53 #if defined (__cplusplus)
andrewm@0 54 extern "C" {
andrewm@0 55 #endif
andrewm@0 56
andrewm@0 57 #define NUM_PRU_HOSTIRQS 8
andrewm@0 58 #define NUM_PRU_HOSTS 10
andrewm@0 59 #define NUM_PRU_CHANNELS 10
andrewm@0 60 #define NUM_PRU_SYS_EVTS 64
andrewm@0 61
andrewm@0 62 #define PRUSS0_PRU0_DATARAM 0
andrewm@0 63 #define PRUSS0_PRU1_DATARAM 1
andrewm@0 64 #define PRUSS0_PRU0_IRAM 2
andrewm@0 65 #define PRUSS0_PRU1_IRAM 3
andrewm@0 66
andrewm@15 67 #define PRUSS_V1 1 // AM18XX
andrewm@15 68 #define PRUSS_V2 2 // AM33XX
andrewm@15 69
andrewm@0 70 //Available in AM33xx series - begin
andrewm@0 71 #define PRUSS0_SHARED_DATARAM 4
andrewm@0 72 #define PRUSS0_CFG 5
andrewm@0 73 #define PRUSS0_UART 6
andrewm@0 74 #define PRUSS0_IEP 7
andrewm@0 75 #define PRUSS0_ECAP 8
andrewm@0 76 #define PRUSS0_MII_RT 9
andrewm@0 77 #define PRUSS0_MDIO 10
andrewm@0 78 //Available in AM33xx series - end
andrewm@0 79
andrewm@0 80 #define PRU_EVTOUT_0 0
andrewm@0 81 #define PRU_EVTOUT_1 1
andrewm@0 82 #define PRU_EVTOUT_2 2
andrewm@0 83 #define PRU_EVTOUT_3 3
andrewm@0 84 #define PRU_EVTOUT_4 4
andrewm@0 85 #define PRU_EVTOUT_5 5
andrewm@0 86 #define PRU_EVTOUT_6 6
andrewm@0 87 #define PRU_EVTOUT_7 7
andrewm@0 88
andrewm@0 89 typedef struct __sysevt_to_channel_map {
andrewm@0 90 short sysevt;
andrewm@0 91 short channel;
andrewm@0 92 } tsysevt_to_channel_map;
andrewm@0 93 typedef struct __channel_to_host_map {
andrewm@0 94 short channel;
andrewm@0 95 short host;
andrewm@0 96 } tchannel_to_host_map;
andrewm@0 97 typedef struct __pruss_intc_initdata {
andrewm@0 98 //Enabled SYSEVTs - Range:0..63
andrewm@0 99 //{-1} indicates end of list
andrewm@0 100 char sysevts_enabled[NUM_PRU_SYS_EVTS];
andrewm@0 101 //SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9
andrewm@0 102 //{-1, -1} indicates end of list
andrewm@0 103 tsysevt_to_channel_map sysevt_to_channel_map[NUM_PRU_SYS_EVTS];
andrewm@0 104 //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9
andrewm@0 105 //{-1, -1} indicates end of list
andrewm@0 106 tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS];
andrewm@15 107 //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7}
andrewm@0 108 unsigned int host_enable_bitmask;
andrewm@0 109 } tpruss_intc_initdata;
andrewm@0 110
andrewm@0 111 int prussdrv_init(void);
andrewm@0 112
andrewm@15 113 int prussdrv_open(unsigned int host_interrupt);
andrewm@15 114
andrewm@15 115 /** Return version of PRU. This must be called after prussdrv_open. */
andrewm@15 116 int prussdrv_version();
andrewm@15 117
andrewm@15 118 /** Return string description of PRU version. */
andrewm@15 119 const char* prussdrv_strversion(int version);
andrewm@0 120
andrewm@0 121 int prussdrv_pru_reset(unsigned int prunum);
andrewm@0 122
andrewm@0 123 int prussdrv_pru_disable(unsigned int prunum);
andrewm@0 124
andrewm@0 125 int prussdrv_pru_enable(unsigned int prunum);
andrewm@15 126 int prussdrv_pru_enable_at(unsigned int prunum, size_t addr);
andrewm@0 127
andrewm@0 128 int prussdrv_pru_write_memory(unsigned int pru_ram_id,
andrewm@0 129 unsigned int wordoffset,
andrewm@15 130 const unsigned int *memarea,
andrewm@0 131 unsigned int bytelength);
andrewm@0 132
andrewm@15 133 int prussdrv_pruintc_init(const tpruss_intc_initdata *prussintc_init_data);
andrewm@15 134
andrewm@15 135 /** Find and return the channel a specified event is mapped to.
andrewm@15 136 * Note that this only searches for the first channel mapped and will not
andrewm@15 137 * detect error cases where an event is mapped erroneously to multiple
andrewm@15 138 * channels.
andrewm@15 139 * @return channel-number to which a system event is mapped.
andrewm@15 140 * @return -1 for no mapping found
andrewm@15 141 */
andrewm@15 142 short prussdrv_get_event_to_channel_map( unsigned int eventnum );
andrewm@15 143
andrewm@15 144 /** Find and return the host interrupt line a specified channel is mapped
andrewm@15 145 * to. Note that this only searches for the first host interrupt line
andrewm@15 146 * mapped and will not detect error cases where a channel is mapped
andrewm@15 147 * erroneously to multiple host interrupt lines.
andrewm@15 148 * @return host-interrupt-line to which a channel is mapped.
andrewm@15 149 * @return -1 for no mapping found
andrewm@15 150 */
andrewm@15 151 short prussdrv_get_channel_to_host_map( unsigned int channel );
andrewm@15 152
andrewm@15 153 /** Find and return the host interrupt line a specified event is mapped
andrewm@15 154 * to. This first finds the intermediate channel and then the host.
andrewm@15 155 * @return host-interrupt-line to which a system event is mapped.
andrewm@15 156 * @return -1 for no mapping found
andrewm@15 157 */
andrewm@15 158 short prussdrv_get_event_to_host_map( unsigned int eventnum );
andrewm@0 159
andrewm@0 160 int prussdrv_map_l3mem(void **address);
andrewm@0 161
andrewm@0 162 int prussdrv_map_extmem(void **address);
andrewm@0 163
andrewm@15 164 unsigned int prussdrv_extmem_size(void);
andrewm@15 165
andrewm@0 166 int prussdrv_map_prumem(unsigned int pru_ram_id, void **address);
andrewm@0 167
andrewm@0 168 int prussdrv_map_peripheral_io(unsigned int per_id, void **address);
andrewm@0 169
andrewm@15 170 unsigned int prussdrv_get_phys_addr(const void *address);
andrewm@0 171
andrewm@0 172 void *prussdrv_get_virt_addr(unsigned int phyaddr);
andrewm@0 173
andrewm@15 174 /** Wait for the specified host interrupt.
andrewm@15 175 * @return the number of times the event has happened. */
andrewm@15 176 unsigned int prussdrv_pru_wait_event(unsigned int host_interrupt);
andrewm@15 177
andrewm@15 178 int prussdrv_pru_event_fd(unsigned int host_interrupt);
andrewm@0 179
andrewm@0 180 int prussdrv_pru_send_event(unsigned int eventnum);
andrewm@0 181
andrewm@15 182 /** Clear the specified event and re-enable the host interrupt. */
andrewm@15 183 int prussdrv_pru_clear_event(unsigned int host_interrupt,
andrewm@15 184 unsigned int sysevent);
andrewm@0 185
andrewm@0 186 int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum,
andrewm@15 187 unsigned int host_interrupt,
andrewm@0 188 unsigned int ack_eventnum);
andrewm@0 189
andrewm@0 190 int prussdrv_exit(void);
andrewm@0 191
andrewm@15 192 int prussdrv_exec_program(int prunum, const char *filename);
andrewm@15 193 int prussdrv_exec_program_at(int prunum, const char *filename, size_t addr);
andrewm@0 194
andrewm@15 195 int prussdrv_exec_code(int prunum, const unsigned int *code, int codelen);
andrewm@15 196 int prussdrv_exec_code_at(int prunum, const unsigned int *code, int codelen, size_t addr);
andrewm@15 197 int prussdrv_load_data(int prunum, const unsigned int *code, int codelen);
andrewm@15 198 int prussdrv_load_datafile(int prunum, const char *filename);
andrewm@0 199
andrewm@0 200 #if defined (__cplusplus)
andrewm@0 201 }
andrewm@0 202 #endif
andrewm@0 203 #endif