Adds Extricom EXSW6000 board
PATCH 2/2 Adds Extricom EXSW6000 board
Signed-off-by Eran Liberty <[email protected]>
extricom/exsw6000/fpga.c +178 -0
@@ -0,0 +1,178 @@ +/* +* (C) Copyright 2007 +* Eran Liberty, Extricom, eran.liberty at gmail.com +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#include <common.h> +#include <asm/global_data.h> +#include "fpga.h" +#include <fpga.h> +#include <altera.h> +#include <stratixII.h> + +DECLARE_GLOBAL_DATA_PTR ; + +#define CONF_MASK 0x0040 +#define DCLK_MASK 0x0080 + +int Exsw6000_stratixII_fpp_pre_fn (int cookie); +int Exsw6000_stratixII_fpp_config_fn (int assert_config,int flush,int cookie); +int Exsw6000_stratixII_fpp_status_fn (int cookie); +int Exsw6000_stratixII_fpp_done_fn (int cookie); +int Exsw6000_stratixII_fpp_clk_fn (int assert_clk,int flush,int cookie); +int Exsw6000_stratixII_fpp_data_fn (int assert_data,int flush,int cookie); +int Exsw6000_stratixII_fpp_abort_fn (int cookie); +int Exsw6000_stratixII_fpp_post_fn (int cookie); + +altera_board_specific_func fpp_func = { + Exsw6000_stratixII_fpp_pre_fn, + Exsw6000_stratixII_fpp_config_fn, + Exsw6000_stratixII_fpp_status_fn, + Exsw6000_stratixII_fpp_done_fn, + Exsw6000_stratixII_fpp_clk_fn, + Exsw6000_stratixII_fpp_data_fn, + Exsw6000_stratixII_fpp_abort_fn, + Exsw6000_stratixII_fpp_post_fn, +}; + +Altera_desc altera_desc_tab[] = { + { + Altera_StratixII,/* part type */ + fast_passive_parallel_security,/* interface type */ +1 ,/* bytes of data part can accept */ + (void *)(&fpp_func),/* interface function table */ +0L ,/* base interface address */ +0 /* implementation specific cookie */ + } +}; + +u16 data; + +static inline void setbit (int *addr,int bit,int val) +{ + *addr = ((*addr & ~(1 << (31 - bit))) | (val << (31 - bit))); +} + +static inline int getbit (int val,int bit) +{ +return ((val >> (31 - bit)) &1 ); +} + +void exsw6000_fpga_init () +{ +/* 1. init fpga generic module */ +fpga_init (gd->reloc_off); + +/* 2. Create and add our FPGA modules */ +fpga_add (fpga_altera, &altera_desc_tab[0 ]); +} + +static void update (void ); + +static void update () +{ +u16 *fpga_base = (u16 *) (CONFIG_FPGA_BASE ); + *fpga_base = data; +} + +int Exsw6000_stratixII_fpp_pre_fn (int cookie) +{ +/* Enables TSEC2_RX[7:0] for use as general-purpose input */ +setbit (&(((immap_t *)CFG_IMMR )->im_gur.gpiocr),7 ,1 ); + +/* Disable Tsec2 */ +setbit (&(((immap_t *)CFG_IMMR )->im_gur.devdisr),25 ,1 ); + + data =0 ; + +return FPGA_SUCCESS ; +} + +int Exsw6000_stratixII_fpp_config_fn (int assert_config,int flush,int cookie) +{ + +if (assert_config) { + data |=CONF_MASK ; + }else { + data &= ~CONF_MASK ; + } +if (flush) { +update (); + } +return FPGA_SUCCESS ; +} + +int Exsw6000_stratixII_fpp_status_fn (int cookie) +{ +return getbit (((immap_t *)CFG_IMMR )->im_gur.gpindr,1 ); +} + +int Exsw6000_stratixII_fpp_done_fn (int cookie) +{ +return getbit (((immap_t *)CFG_IMMR )->im_gur.gpindr,0 ); +} + +int Exsw6000_stratixII_fpp_clk_fn (int assert_clk,int flush,int cookie) +{ +if (assert_clk) { + data |=DCLK_MASK ; + }else { + data &= ~DCLK_MASK ; + } +if (flush) { +update (); + } + +return FPGA_SUCCESS ; +} + +int Exsw6000_stratixII_fpp_data_fn (int new_data,int flush,int cookie) +{ + new_data = + ((new_data &0x80 ) >>7 ) | + ((new_data &0x40 ) >>5 ) | + ((new_data &0x20 ) >>3 ) | + ((new_data &0x10 ) >>1 ) | + ((new_data &0x08 ) <<1 ) | + ((new_data &0x04 ) <<3 ) | + ((new_data &0x02 ) <<5 ) | + ((new_data &0x01 ) <<7 ); + + data = (data &0x00FF ) | (new_data <<8 &0xFF00 ); + +if (flush) { +update (); + } + +return FPGA_SUCCESS ; +} + +int Exsw6000_stratixII_fpp_abort_fn (int cookie) +{ +return Exsw6000_stratixII_fpp_post_fn (cookie); +} + +int Exsw6000_stratixII_fpp_post_fn (int cookie) +{ +setbit (&(((immap_t *)CFG_IMMR )->im_gur.devdisr),25 ,0 ); +setbit (&(((immap_t *)CFG_IMMR )->im_gur.gpiocr),7 ,0 ); +return FPGA_SUCCESS ; +}
extricom/exsw6000/ft_board.c +77 -0
77 lines not on this page · raw message
extricom/exsw6000/init.S +260 -0
260 lines not on this page · raw message
extricom/exsw6000/u-boot.lds +153 -0
153 lines not on this page · raw message
extricom/exsw6000/fpga.h +29 -0
@@ -0,0 +1,29 @@ +/* +* (C) Copyright 2007 +* Eran Liberty, Extricom, eran.liberty at gmail.com +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#ifndef _EXSW6000_FPGA_H_ +#define _EXSW6000_FPGA_H_ + +void exsw6000_fpga_init (void ); + +#endif /* _EXSW6000_FPGA_H_ */