Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Rich Ireland, Enterasys Networks, rireland@enterasys.com. |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <fpga.h> |
| 8 | |
| 9 | #ifndef _ALTERA_H_ |
| 10 | #define _ALTERA_H_ |
| 11 | |
Stefan Roese | d919d72 | 2016-02-12 13:48:02 +0100 | [diff] [blame] | 12 | /* |
| 13 | * For the StratixV FPGA programming via SPI, the following |
| 14 | * information is coded in the 32bit cookie: |
| 15 | * Bit 31 ... Bit 0 |
| 16 | * SPI-Bus | SPI-Dev | Config-Pin | Done-Pin |
| 17 | */ |
| 18 | #define FPGA_COOKIE(bus, dev, config, done) \ |
| 19 | (((bus) << 24) | ((dev) << 16) | ((config) << 8) | (done)) |
| 20 | #define COOKIE2SPI_BUS(c) (((c) >> 24) & 0xff) |
| 21 | #define COOKIE2SPI_DEV(c) (((c) >> 16) & 0xff) |
| 22 | #define COOKIE2CONFIG(c) (((c) >> 8) & 0xff) |
| 23 | #define COOKIE2DONE(c) ((c) & 0xff) |
| 24 | |
Marek Vasut | b2f6e13 | 2014-09-16 20:48:33 +0200 | [diff] [blame] | 25 | enum altera_iface { |
| 26 | /* insert all new types after this */ |
| 27 | min_altera_iface_type, |
| 28 | /* serial data and external clock */ |
| 29 | passive_serial, |
| 30 | /* parallel data */ |
| 31 | passive_parallel_synchronous, |
| 32 | /* parallel data */ |
| 33 | passive_parallel_asynchronous, |
| 34 | /* serial data w/ internal clock (not used) */ |
| 35 | passive_serial_asynchronous, |
| 36 | /* jtag/tap serial (not used ) */ |
| 37 | altera_jtag_mode, |
| 38 | /* fast passive parallel (FPP) */ |
| 39 | fast_passive_parallel, |
| 40 | /* fast passive parallel with security (FPPS) */ |
| 41 | fast_passive_parallel_security, |
| 42 | /* insert all new types before this */ |
| 43 | max_altera_iface_type, |
| 44 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 45 | |
Marek Vasut | b2f6e13 | 2014-09-16 20:48:33 +0200 | [diff] [blame] | 46 | enum altera_family { |
| 47 | /* insert all new types after this */ |
| 48 | min_altera_type, |
| 49 | /* ACEX1K Family */ |
| 50 | Altera_ACEX1K, |
| 51 | /* CYCLONII Family */ |
| 52 | Altera_CYC2, |
| 53 | /* StratixII Family */ |
| 54 | Altera_StratixII, |
Stefan Roese | d919d72 | 2016-02-12 13:48:02 +0100 | [diff] [blame] | 55 | /* StratixV Family */ |
| 56 | Altera_StratixV, |
Pavel Machek | c721380 | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 57 | /* SoCFPGA Family */ |
| 58 | Altera_SoCFPGA, |
Marek Vasut | b2f6e13 | 2014-09-16 20:48:33 +0200 | [diff] [blame] | 59 | |
| 60 | /* Add new models here */ |
| 61 | |
| 62 | /* insert all new types before this */ |
| 63 | max_altera_type, |
| 64 | }; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 65 | |
Marek Vasut | b2f6e13 | 2014-09-16 20:48:33 +0200 | [diff] [blame] | 66 | typedef struct { |
| 67 | /* part type */ |
| 68 | enum altera_family family; |
| 69 | /* interface type */ |
| 70 | enum altera_iface iface; |
| 71 | /* bytes of data part can accept */ |
| 72 | size_t size; |
| 73 | /* interface function table */ |
| 74 | void *iface_fns; |
| 75 | /* base interface address */ |
| 76 | void *base; |
| 77 | /* implementation specific cookie */ |
| 78 | int cookie; |
| 79 | } Altera_desc; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 80 | |
wdenk | 9b7f384 | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 81 | /* Generic Altera Functions |
| 82 | *********************************************************************/ |
Wolfgang Denk | 74f9b38 | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 83 | extern int altera_load(Altera_desc *desc, const void *image, size_t size); |
| 84 | extern int altera_dump(Altera_desc *desc, const void *buf, size_t bsize); |
| 85 | extern int altera_info(Altera_desc *desc); |
wdenk | 9b7f384 | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 86 | |
| 87 | /* Board specific implementation specific function types |
| 88 | *********************************************************************/ |
| 89 | typedef int (*Altera_pre_fn)( int cookie ); |
| 90 | typedef int (*Altera_config_fn)( int assert_config, int flush, int cookie ); |
| 91 | typedef int (*Altera_status_fn)( int cookie ); |
| 92 | typedef int (*Altera_done_fn)( int cookie ); |
| 93 | typedef int (*Altera_clk_fn)( int assert_clk, int flush, int cookie ); |
| 94 | typedef int (*Altera_data_fn)( int assert_data, int flush, int cookie ); |
Wolfgang Denk | 74f9b38 | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 95 | typedef int(*Altera_write_fn)(const void *buf, size_t len, int flush, int cookie); |
wdenk | 9b7f384 | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 96 | typedef int (*Altera_abort_fn)( int cookie ); |
| 97 | typedef int (*Altera_post_fn)( int cookie ); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 98 | |
eran liberty | 4c373a9 | 2008-03-27 00:50:49 +0100 | [diff] [blame] | 99 | typedef struct { |
| 100 | Altera_pre_fn pre; |
| 101 | Altera_config_fn config; |
| 102 | Altera_status_fn status; |
| 103 | Altera_done_fn done; |
| 104 | Altera_clk_fn clk; |
| 105 | Altera_data_fn data; |
Stefan Roese | d919d72 | 2016-02-12 13:48:02 +0100 | [diff] [blame] | 106 | Altera_write_fn write; |
eran liberty | 4c373a9 | 2008-03-27 00:50:49 +0100 | [diff] [blame] | 107 | Altera_abort_fn abort; |
| 108 | Altera_post_fn post; |
| 109 | } altera_board_specific_func; |
| 110 | |
Pavel Machek | c721380 | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 111 | #ifdef CONFIG_FPGA_SOCFPGA |
| 112 | int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size); |
| 113 | #endif |
| 114 | |
Stefan Roese | d919d72 | 2016-02-12 13:48:02 +0100 | [diff] [blame] | 115 | #ifdef CONFIG_FPGA_STRATIX_V |
| 116 | int stratixv_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size); |
| 117 | #endif |
| 118 | |
wdenk | 9b7f384 | 2003-10-09 20:09:04 +0000 | [diff] [blame] | 119 | #endif /* _ALTERA_H_ */ |