andrewm@0: /* andrewm@0: * prussdrv.h andrewm@15: * andrewm@0: * Describes PRUSS userspace driver for Industrial Communications andrewm@0: * andrewm@15: * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ andrewm@15: * andrewm@15: * andrewm@15: * Redistribution and use in source and binary forms, with or without andrewm@15: * modification, are permitted provided that the following conditions andrewm@0: * are met: andrewm@0: * andrewm@15: * Redistributions of source code must retain the above copyright andrewm@0: * notice, this list of conditions and the following disclaimer. andrewm@0: * andrewm@0: * Redistributions in binary form must reproduce the above copyright andrewm@15: * notice, this list of conditions and the following disclaimer in the andrewm@15: * documentation and/or other materials provided with the andrewm@0: * distribution. andrewm@0: * andrewm@0: * Neither the name of Texas Instruments Incorporated nor the names of andrewm@0: * its contributors may be used to endorse or promote products derived andrewm@0: * from this software without specific prior written permission. andrewm@0: * andrewm@15: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS andrewm@15: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT andrewm@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR andrewm@15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT andrewm@15: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, andrewm@15: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT andrewm@0: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, andrewm@0: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY andrewm@15: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT andrewm@15: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE andrewm@0: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. andrewm@0: * andrewm@0: */ andrewm@0: andrewm@0: /* andrewm@0: * ============================================================================ andrewm@0: * Copyright (c) Texas Instruments Inc 2010-11 andrewm@0: * andrewm@0: * Use of this software is controlled by the terms and conditions found in the andrewm@0: * license agreement under which this software has been supplied or provided. andrewm@0: * ============================================================================ andrewm@0: */ andrewm@0: andrewm@0: #ifndef _PRUSSDRV_H andrewm@0: #define _PRUSSDRV_H andrewm@0: andrewm@0: #include andrewm@0: andrewm@0: #if defined (__cplusplus) andrewm@0: extern "C" { andrewm@0: #endif andrewm@0: andrewm@0: #define NUM_PRU_HOSTIRQS 8 andrewm@0: #define NUM_PRU_HOSTS 10 andrewm@0: #define NUM_PRU_CHANNELS 10 andrewm@0: #define NUM_PRU_SYS_EVTS 64 andrewm@0: andrewm@0: #define PRUSS0_PRU0_DATARAM 0 andrewm@0: #define PRUSS0_PRU1_DATARAM 1 andrewm@0: #define PRUSS0_PRU0_IRAM 2 andrewm@0: #define PRUSS0_PRU1_IRAM 3 andrewm@0: andrewm@15: #define PRUSS_V1 1 // AM18XX andrewm@15: #define PRUSS_V2 2 // AM33XX andrewm@15: andrewm@0: //Available in AM33xx series - begin andrewm@0: #define PRUSS0_SHARED_DATARAM 4 andrewm@0: #define PRUSS0_CFG 5 andrewm@0: #define PRUSS0_UART 6 andrewm@0: #define PRUSS0_IEP 7 andrewm@0: #define PRUSS0_ECAP 8 andrewm@0: #define PRUSS0_MII_RT 9 andrewm@0: #define PRUSS0_MDIO 10 andrewm@0: //Available in AM33xx series - end andrewm@0: andrewm@0: #define PRU_EVTOUT_0 0 andrewm@0: #define PRU_EVTOUT_1 1 andrewm@0: #define PRU_EVTOUT_2 2 andrewm@0: #define PRU_EVTOUT_3 3 andrewm@0: #define PRU_EVTOUT_4 4 andrewm@0: #define PRU_EVTOUT_5 5 andrewm@0: #define PRU_EVTOUT_6 6 andrewm@0: #define PRU_EVTOUT_7 7 andrewm@0: andrewm@0: typedef struct __sysevt_to_channel_map { andrewm@0: short sysevt; andrewm@0: short channel; andrewm@0: } tsysevt_to_channel_map; andrewm@0: typedef struct __channel_to_host_map { andrewm@0: short channel; andrewm@0: short host; andrewm@0: } tchannel_to_host_map; andrewm@0: typedef struct __pruss_intc_initdata { andrewm@0: //Enabled SYSEVTs - Range:0..63 andrewm@0: //{-1} indicates end of list andrewm@0: char sysevts_enabled[NUM_PRU_SYS_EVTS]; andrewm@0: //SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9 andrewm@0: //{-1, -1} indicates end of list andrewm@0: tsysevt_to_channel_map sysevt_to_channel_map[NUM_PRU_SYS_EVTS]; andrewm@0: //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9 andrewm@0: //{-1, -1} indicates end of list andrewm@0: tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS]; andrewm@15: //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7} andrewm@0: unsigned int host_enable_bitmask; andrewm@0: } tpruss_intc_initdata; andrewm@0: andrewm@0: int prussdrv_init(void); andrewm@0: andrewm@15: int prussdrv_open(unsigned int host_interrupt); andrewm@15: andrewm@15: /** Return version of PRU. This must be called after prussdrv_open. */ andrewm@15: int prussdrv_version(); andrewm@15: andrewm@15: /** Return string description of PRU version. */ andrewm@15: const char* prussdrv_strversion(int version); andrewm@0: andrewm@0: int prussdrv_pru_reset(unsigned int prunum); andrewm@0: andrewm@0: int prussdrv_pru_disable(unsigned int prunum); andrewm@0: andrewm@0: int prussdrv_pru_enable(unsigned int prunum); andrewm@15: int prussdrv_pru_enable_at(unsigned int prunum, size_t addr); andrewm@0: andrewm@0: int prussdrv_pru_write_memory(unsigned int pru_ram_id, andrewm@0: unsigned int wordoffset, andrewm@15: const unsigned int *memarea, andrewm@0: unsigned int bytelength); andrewm@0: andrewm@15: int prussdrv_pruintc_init(const tpruss_intc_initdata *prussintc_init_data); andrewm@15: andrewm@15: /** Find and return the channel a specified event is mapped to. andrewm@15: * Note that this only searches for the first channel mapped and will not andrewm@15: * detect error cases where an event is mapped erroneously to multiple andrewm@15: * channels. andrewm@15: * @return channel-number to which a system event is mapped. andrewm@15: * @return -1 for no mapping found andrewm@15: */ andrewm@15: short prussdrv_get_event_to_channel_map( unsigned int eventnum ); andrewm@15: andrewm@15: /** Find and return the host interrupt line a specified channel is mapped andrewm@15: * to. Note that this only searches for the first host interrupt line andrewm@15: * mapped and will not detect error cases where a channel is mapped andrewm@15: * erroneously to multiple host interrupt lines. andrewm@15: * @return host-interrupt-line to which a channel is mapped. andrewm@15: * @return -1 for no mapping found andrewm@15: */ andrewm@15: short prussdrv_get_channel_to_host_map( unsigned int channel ); andrewm@15: andrewm@15: /** Find and return the host interrupt line a specified event is mapped andrewm@15: * to. This first finds the intermediate channel and then the host. andrewm@15: * @return host-interrupt-line to which a system event is mapped. andrewm@15: * @return -1 for no mapping found andrewm@15: */ andrewm@15: short prussdrv_get_event_to_host_map( unsigned int eventnum ); andrewm@0: andrewm@0: int prussdrv_map_l3mem(void **address); andrewm@0: andrewm@0: int prussdrv_map_extmem(void **address); andrewm@0: andrewm@15: unsigned int prussdrv_extmem_size(void); andrewm@15: andrewm@0: int prussdrv_map_prumem(unsigned int pru_ram_id, void **address); andrewm@0: andrewm@0: int prussdrv_map_peripheral_io(unsigned int per_id, void **address); andrewm@0: andrewm@15: unsigned int prussdrv_get_phys_addr(const void *address); andrewm@0: andrewm@0: void *prussdrv_get_virt_addr(unsigned int phyaddr); andrewm@0: andrewm@15: /** Wait for the specified host interrupt. andrewm@15: * @return the number of times the event has happened. */ andrewm@15: unsigned int prussdrv_pru_wait_event(unsigned int host_interrupt); andrewm@15: andrewm@15: int prussdrv_pru_event_fd(unsigned int host_interrupt); andrewm@0: andrewm@0: int prussdrv_pru_send_event(unsigned int eventnum); andrewm@0: andrewm@15: /** Clear the specified event and re-enable the host interrupt. */ andrewm@15: int prussdrv_pru_clear_event(unsigned int host_interrupt, andrewm@15: unsigned int sysevent); andrewm@0: andrewm@0: int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum, andrewm@15: unsigned int host_interrupt, andrewm@0: unsigned int ack_eventnum); andrewm@0: andrewm@0: int prussdrv_exit(void); andrewm@0: andrewm@15: int prussdrv_exec_program(int prunum, const char *filename); andrewm@15: int prussdrv_exec_program_at(int prunum, const char *filename, size_t addr); andrewm@0: andrewm@15: int prussdrv_exec_code(int prunum, const unsigned int *code, int codelen); andrewm@15: int prussdrv_exec_code_at(int prunum, const unsigned int *code, int codelen, size_t addr); andrewm@15: int prussdrv_load_data(int prunum, const unsigned int *code, int codelen); andrewm@15: int prussdrv_load_datafile(int prunum, const char *filename); andrewm@0: andrewm@0: #if defined (__cplusplus) andrewm@0: } andrewm@0: #endif andrewm@0: #endif