annotate include/prussdrv.h @ 12:a6beeba3a648

Initial support for higher matrix sample rates by reducing the number of channels. Input not tested yet, and not all examples updated to new format.
author andrewm
date Thu, 22 Jan 2015 19:00:22 +0000
parents 8a575ba3ab52
children 901d205d1a3c
rev   line source
andrewm@0 1 /*
andrewm@0 2 * prussdrv.h
andrewm@0 3 *
andrewm@0 4 * Describes PRUSS userspace driver for Industrial Communications
andrewm@0 5 *
andrewm@0 6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
andrewm@0 7 *
andrewm@0 8 *
andrewm@0 9 * Redistribution and use in source and binary forms, with or without
andrewm@0 10 * modification, are permitted provided that the following conditions
andrewm@0 11 * are met:
andrewm@0 12 *
andrewm@0 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@0 17 * notice, this list of conditions and the following disclaimer in the
andrewm@0 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@0 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
andrewm@0 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@0 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
andrewm@0 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
andrewm@0 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@0 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
andrewm@0 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 #include <pthread.h>
andrewm@0 53
andrewm@0 54 #if defined (__cplusplus)
andrewm@0 55 extern "C" {
andrewm@0 56 #endif
andrewm@0 57
andrewm@0 58 #define NUM_PRU_HOSTIRQS 8
andrewm@0 59 #define NUM_PRU_HOSTS 10
andrewm@0 60 #define NUM_PRU_CHANNELS 10
andrewm@0 61 #define NUM_PRU_SYS_EVTS 64
andrewm@0 62
andrewm@0 63 #define PRUSS0_PRU0_DATARAM 0
andrewm@0 64 #define PRUSS0_PRU1_DATARAM 1
andrewm@0 65 #define PRUSS0_PRU0_IRAM 2
andrewm@0 66 #define PRUSS0_PRU1_IRAM 3
andrewm@0 67
andrewm@0 68 //Available in AM33xx series - begin
andrewm@0 69 #define PRUSS0_SHARED_DATARAM 4
andrewm@0 70 #define PRUSS0_CFG 5
andrewm@0 71 #define PRUSS0_UART 6
andrewm@0 72 #define PRUSS0_IEP 7
andrewm@0 73 #define PRUSS0_ECAP 8
andrewm@0 74 #define PRUSS0_MII_RT 9
andrewm@0 75 #define PRUSS0_MDIO 10
andrewm@0 76 //Available in AM33xx series - end
andrewm@0 77
andrewm@0 78 #define PRU_EVTOUT_0 0
andrewm@0 79 #define PRU_EVTOUT_1 1
andrewm@0 80 #define PRU_EVTOUT_2 2
andrewm@0 81 #define PRU_EVTOUT_3 3
andrewm@0 82 #define PRU_EVTOUT_4 4
andrewm@0 83 #define PRU_EVTOUT_5 5
andrewm@0 84 #define PRU_EVTOUT_6 6
andrewm@0 85 #define PRU_EVTOUT_7 7
andrewm@0 86
andrewm@0 87 typedef void *(*prussdrv_function_handler) (void *);
andrewm@0 88 typedef struct __sysevt_to_channel_map {
andrewm@0 89 short sysevt;
andrewm@0 90 short channel;
andrewm@0 91 } tsysevt_to_channel_map;
andrewm@0 92 typedef struct __channel_to_host_map {
andrewm@0 93 short channel;
andrewm@0 94 short host;
andrewm@0 95 } tchannel_to_host_map;
andrewm@0 96 typedef struct __pruss_intc_initdata {
andrewm@0 97 //Enabled SYSEVTs - Range:0..63
andrewm@0 98 //{-1} indicates end of list
andrewm@0 99 char sysevts_enabled[NUM_PRU_SYS_EVTS];
andrewm@0 100 //SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9
andrewm@0 101 //{-1, -1} indicates end of list
andrewm@0 102 tsysevt_to_channel_map sysevt_to_channel_map[NUM_PRU_SYS_EVTS];
andrewm@0 103 //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9
andrewm@0 104 //{-1, -1} indicates end of list
andrewm@0 105 tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS];
andrewm@0 106 //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7)
andrewm@0 107 unsigned int host_enable_bitmask;
andrewm@0 108 } tpruss_intc_initdata;
andrewm@0 109
andrewm@0 110 int prussdrv_init(void);
andrewm@0 111
andrewm@0 112 int prussdrv_open(unsigned int pru_evtout_num);
andrewm@0 113
andrewm@0 114 int prussdrv_pru_reset(unsigned int prunum);
andrewm@0 115
andrewm@0 116 int prussdrv_pru_disable(unsigned int prunum);
andrewm@0 117
andrewm@0 118 int prussdrv_pru_enable(unsigned int prunum);
andrewm@0 119
andrewm@0 120 int prussdrv_pru_write_memory(unsigned int pru_ram_id,
andrewm@0 121 unsigned int wordoffset,
andrewm@0 122 unsigned int *memarea,
andrewm@0 123 unsigned int bytelength);
andrewm@0 124
andrewm@0 125 int prussdrv_pruintc_init(tpruss_intc_initdata * prussintc_init_data);
andrewm@0 126
andrewm@0 127 int prussdrv_map_l3mem(void **address);
andrewm@0 128
andrewm@0 129 int prussdrv_map_extmem(void **address);
andrewm@0 130
andrewm@0 131 int prussdrv_map_prumem(unsigned int pru_ram_id, void **address);
andrewm@0 132
andrewm@0 133 int prussdrv_map_peripheral_io(unsigned int per_id, void **address);
andrewm@0 134
andrewm@0 135 unsigned int prussdrv_get_phys_addr(void *address);
andrewm@0 136
andrewm@0 137 void *prussdrv_get_virt_addr(unsigned int phyaddr);
andrewm@0 138
andrewm@0 139 int prussdrv_pru_wait_event(unsigned int pru_evtout_num);
andrewm@0 140
andrewm@0 141 int prussdrv_pru_send_event(unsigned int eventnum);
andrewm@0 142
andrewm@0 143 int prussdrv_pru_clear_event(unsigned int eventnum);
andrewm@0 144
andrewm@0 145 int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum,
andrewm@0 146 unsigned int pru_evtout_num,
andrewm@0 147 unsigned int ack_eventnum);
andrewm@0 148
andrewm@0 149 int prussdrv_exit(void);
andrewm@0 150
andrewm@0 151 int prussdrv_exec_program(int prunum, char *filename);
andrewm@0 152
andrewm@0 153 int prussdrv_start_irqthread(unsigned int pru_evtout_num, int priority,
andrewm@0 154 prussdrv_function_handler irqhandler);
andrewm@0 155
andrewm@0 156
andrewm@0 157 #if defined (__cplusplus)
andrewm@0 158 }
andrewm@0 159 #endif
andrewm@0 160 #endif