forked from Xilinx/u-boot-xlnx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm: socfpga: fpga: Add SoCFPGA FPGA programming interface
Add code necessary to program the FPGA part of SoCFPGA from U-Boot with an RBF blob. This patch also integrates the code into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command. Signed-off-by: Pavel Machek <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Cc: Chin Liang See <[email protected]> Cc: Dinh Nguyen <[email protected]> Cc: Albert Aribaud <[email protected]> Cc: Tom Rini <[email protected]> Cc: Wolfgang Denk <[email protected]> Cc: Pavel Machek <[email protected]> V2: Move the not-CPU specific stuff into drivers/fpga/ and base this on the cleaned up altera FPGA support.
- Loading branch information
Pavel Machek
authored and
Marek Vasut
committed
Oct 6, 2014
1 parent
604364e
commit 230fe9b
Showing
8 changed files
with
504 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (C) 2012 Altera Corporation <www.altera.com> | ||
* All rights reserved. | ||
* | ||
* This file contains only support functions used also by the SoCFPGA | ||
* platform code, the real meat is located in drivers/fpga/socfpga.c . | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#include <common.h> | ||
#include <asm/io.h> | ||
#include <asm/errno.h> | ||
#include <asm/arch/fpga_manager.h> | ||
#include <asm/arch/reset_manager.h> | ||
#include <asm/arch/system_manager.h> | ||
|
||
DECLARE_GLOBAL_DATA_PTR; | ||
|
||
/* Timeout count */ | ||
#define FPGA_TIMEOUT_CNT 0x1000000 | ||
|
||
static struct socfpga_fpga_manager *fpgamgr_regs = | ||
(struct socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS; | ||
|
||
/* Check whether FPGA Init_Done signal is high */ | ||
static int is_fpgamgr_initdone_high(void) | ||
{ | ||
unsigned long val; | ||
|
||
val = readl(&fpgamgr_regs->gpio_ext_porta); | ||
return val & FPGAMGRREGS_MON_GPIO_EXT_PORTA_ID_MASK; | ||
} | ||
|
||
/* Get the FPGA mode */ | ||
int fpgamgr_get_mode(void) | ||
{ | ||
unsigned long val; | ||
|
||
val = readl(&fpgamgr_regs->stat); | ||
return val & FPGAMGRREGS_STAT_MODE_MASK; | ||
} | ||
|
||
/* Check whether FPGA is ready to be accessed */ | ||
int fpgamgr_test_fpga_ready(void) | ||
{ | ||
/* Check for init done signal */ | ||
if (!is_fpgamgr_initdone_high()) | ||
return 0; | ||
|
||
/* Check again to avoid false glitches */ | ||
if (!is_fpgamgr_initdone_high()) | ||
return 0; | ||
|
||
if (fpgamgr_get_mode() != FPGAMGRREGS_MODE_USERMODE) | ||
return 0; | ||
|
||
return 1; | ||
} | ||
|
||
/* Poll until FPGA is ready to be accessed or timeout occurred */ | ||
int fpgamgr_poll_fpga_ready(void) | ||
{ | ||
unsigned long i; | ||
|
||
/* If FPGA is blank, wait till WD invoke warm reset */ | ||
for (i = 0; i < FPGA_TIMEOUT_CNT; i++) { | ||
/* check for init done signal */ | ||
if (!is_fpgamgr_initdone_high()) | ||
continue; | ||
/* check again to avoid false glitches */ | ||
if (!is_fpgamgr_initdone_high()) | ||
continue; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2012 Altera Corporation <www.altera.com> | ||
* All rights reserved. | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef _FPGA_MANAGER_H_ | ||
#define _FPGA_MANAGER_H_ | ||
|
||
#include <altera.h> | ||
|
||
struct socfpga_fpga_manager { | ||
/* FPGA Manager Module */ | ||
u32 stat; /* 0x00 */ | ||
u32 ctrl; | ||
u32 dclkcnt; | ||
u32 dclkstat; | ||
u32 gpo; /* 0x10 */ | ||
u32 gpi; | ||
u32 misci; /* 0x18 */ | ||
u32 _pad_0x1c_0x82c[517]; | ||
|
||
/* Configuration Monitor (MON) Registers */ | ||
u32 gpio_inten; /* 0x830 */ | ||
u32 gpio_intmask; | ||
u32 gpio_inttype_level; | ||
u32 gpio_int_polarity; | ||
u32 gpio_intstatus; /* 0x840 */ | ||
u32 gpio_raw_intstatus; | ||
u32 _pad_0x848; | ||
u32 gpio_porta_eoi; | ||
u32 gpio_ext_porta; /* 0x850 */ | ||
u32 _pad_0x854_0x85c[3]; | ||
u32 gpio_1s_sync; /* 0x860 */ | ||
u32 _pad_0x864_0x868[2]; | ||
u32 gpio_ver_id_code; | ||
u32 gpio_config_reg2; /* 0x870 */ | ||
u32 gpio_config_reg1; | ||
}; | ||
|
||
#define FPGAMGRREGS_STAT_MODE_MASK 0x7 | ||
#define FPGAMGRREGS_STAT_MSEL_MASK 0xf8 | ||
#define FPGAMGRREGS_STAT_MSEL_LSB 3 | ||
|
||
#define FPGAMGRREGS_CTRL_CFGWDTH_MASK 0x200 | ||
#define FPGAMGRREGS_CTRL_AXICFGEN_MASK 0x100 | ||
#define FPGAMGRREGS_CTRL_NCONFIGPULL_MASK 0x4 | ||
#define FPGAMGRREGS_CTRL_NCE_MASK 0x2 | ||
#define FPGAMGRREGS_CTRL_EN_MASK 0x1 | ||
#define FPGAMGRREGS_CTRL_CDRATIO_LSB 6 | ||
|
||
#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_CRC_MASK 0x8 | ||
#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_ID_MASK 0x4 | ||
#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_CD_MASK 0x2 | ||
#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_NS_MASK 0x1 | ||
|
||
/* FPGA Mode */ | ||
#define FPGAMGRREGS_MODE_FPGAOFF 0x0 | ||
#define FPGAMGRREGS_MODE_RESETPHASE 0x1 | ||
#define FPGAMGRREGS_MODE_CFGPHASE 0x2 | ||
#define FPGAMGRREGS_MODE_INITPHASE 0x3 | ||
#define FPGAMGRREGS_MODE_USERMODE 0x4 | ||
#define FPGAMGRREGS_MODE_UNKNOWN 0x5 | ||
|
||
/* FPGA CD Ratio Value */ | ||
#define CDRATIO_x1 0x0 | ||
#define CDRATIO_x2 0x1 | ||
#define CDRATIO_x4 0x2 | ||
#define CDRATIO_x8 0x3 | ||
|
||
/* SoCFPGA support functions */ | ||
int fpgamgr_test_fpga_ready(void); | ||
int fpgamgr_poll_fpga_ready(void); | ||
int fpgamgr_get_mode(void); | ||
|
||
#endif /* _FPGA_MANAGER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.