andrewm@0: /* andrewm@0: * prussdrv.h andrewm@0: * andrewm@0: * Describes PRUSS userspace driver for Industrial Communications andrewm@0: * andrewm@0: * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ andrewm@0: * andrewm@0: * andrewm@0: * Redistribution and use in source and binary forms, with or without andrewm@0: * modification, are permitted provided that the following conditions andrewm@0: * are met: andrewm@0: * andrewm@0: * 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@0: * notice, this list of conditions and the following disclaimer in the andrewm@0: * 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@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS andrewm@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT andrewm@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR andrewm@0: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT andrewm@0: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, andrewm@0: * 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@0: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT andrewm@0: * (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: #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@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 void *(*prussdrv_function_handler) (void *); 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@0: //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@0: int prussdrv_open(unsigned int pru_evtout_num); 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@0: andrewm@0: int prussdrv_pru_write_memory(unsigned int pru_ram_id, andrewm@0: unsigned int wordoffset, andrewm@0: unsigned int *memarea, andrewm@0: unsigned int bytelength); andrewm@0: andrewm@0: int prussdrv_pruintc_init(tpruss_intc_initdata * prussintc_init_data); andrewm@0: andrewm@0: int prussdrv_map_l3mem(void **address); andrewm@0: andrewm@0: int prussdrv_map_extmem(void **address); andrewm@0: 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@0: unsigned int prussdrv_get_phys_addr(void *address); andrewm@0: andrewm@0: void *prussdrv_get_virt_addr(unsigned int phyaddr); andrewm@0: andrewm@0: int prussdrv_pru_wait_event(unsigned int pru_evtout_num); andrewm@0: andrewm@0: int prussdrv_pru_send_event(unsigned int eventnum); andrewm@0: andrewm@0: int prussdrv_pru_clear_event(unsigned int eventnum); andrewm@0: andrewm@0: int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum, andrewm@0: unsigned int pru_evtout_num, andrewm@0: unsigned int ack_eventnum); andrewm@0: andrewm@0: int prussdrv_exit(void); andrewm@0: andrewm@0: int prussdrv_exec_program(int prunum, char *filename); andrewm@0: andrewm@0: int prussdrv_start_irqthread(unsigned int pru_evtout_num, int priority, andrewm@0: prussdrv_function_handler irqhandler); andrewm@0: andrewm@0: andrewm@0: #if defined (__cplusplus) andrewm@0: } andrewm@0: #endif andrewm@0: #endif