All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chee, Tien Fong <tien.fong.chee@intel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/5] arm: socfpga: Restructure FPGA driver in the preparation to support A10.
Date: Fri, 12 May 2017 03:45:13 +0000	[thread overview]
Message-ID: <1494560712.6027.12.camel@intel.com> (raw)
In-Reply-To: <2ba11ed9-426c-96af-d97b-bda7858e1c9e@denx.de>

On Kha, 2017-05-11 at 14:03 +0200, Marek Vasut wrote:
> On 05/11/2017 11:25 AM, tien.fong.chee at intel.com wrote:
> > 
> > From: Tien Fong Chee <tien.fong.chee@intel.com>
> > 
> > Move FPGA driver which is Gen5 specific code into Gen5 driver file
> > and keeping common FPGA driver intact. All the changes are still
> > keeping
> > in driver/fpga/ and no functional change. Subsequent patch would
> > move
> > header files into include/intel_socfpga and FPGA manager driver
> > from
> > arch/arm into driver/fpga/ .
> > 
> > Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
> > ---
> >  arch/arm/mach-socfpga/Makefile                     |   2 +-
> >  arch/arm/mach-socfpga/include/mach/fpga_manager.h  |  70 ++----
> >  .../mach/{fpga_manager.h => fpga_manager_gen5.h}   |  69 +++---
> >  drivers/Makefile                                   |   1 +
> >  drivers/fpga/Makefile                              |   1 +
> >  drivers/fpga/socfpga.c                             | 243 +------
> > --------------
> >  drivers/fpga/{socfpga.c => socfpga_gen5.c}         |  57 +----
> >  7 files changed, 53 insertions(+), 390 deletions(-)
> >  copy arch/arm/mach-socfpga/include/mach/{fpga_manager.h =>
> > fpga_manager_gen5.h} (57%)
> >  copy drivers/fpga/{socfpga.c => socfpga_gen5.c} (82%)
> > 
> > diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-
> > socfpga/Makefile
> > index 41b779c..286bfef 100644
> > --- a/arch/arm/mach-socfpga/Makefile
> > +++ b/arch/arm/mach-socfpga/Makefile
> > @@ -9,7 +9,6 @@
> >  
> >  obj-y	+= board.o
> >  obj-y	+= clock_manager.o
> > -obj-y	+= fpga_manager.o
> >  obj-y	+= misc.o
> >  obj-y	+= reset_manager.o
> >  obj-y	+= timer.o
> > @@ -21,6 +20,7 @@ obj-y	+= reset_manager_gen5.o
> >  obj-y	+= scan_manager.o
> >  obj-y	+= system_manager_gen5.o
> >  obj-y	+= wrap_pll_config.o
> > +obj-y	+= fpga_manager.o
> >  endif
> >  
> >  ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
> > diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager.h
> > b/arch/arm/mach-socfpga/include/mach/fpga_manager.h
> > index a077e22..f259854 100644
> > --- a/arch/arm/mach-socfpga/include/mach/fpga_manager.h
> > +++ b/arch/arm/mach-socfpga/include/mach/fpga_manager.h
> > @@ -1,5 +1,5 @@
> >  /*
> > - * Copyright (C) 2012 Altera Corporation <www.altera.com>
> > + * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
> >   * All rights reserved.
> >   *
> >   * SPDX-License-Identifier:    BSD-3-Clause
> > @@ -10,58 +10,9 @@
> >  
> >  #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
> > +#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
> > +#include <asm/arch/fpga_manager_gen5.h>
> > +#endif
> >  
> >  /* FPGA CD Ratio Value */
> >  #define CDRATIO_x1				0x0
> > @@ -70,8 +21,17 @@ struct socfpga_fpga_manager {
> >  #define CDRATIO_x8				0x3
> >  
> >  /* SoCFPGA support functions */
> > -int fpgamgr_test_fpga_ready(void);
> > -int fpgamgr_poll_fpga_ready(void);
> >  int fpgamgr_get_mode(void);
> > +int fpgamgr_poll_fpga_ready(void);
> > +void fpgamgr_program_write(const void *rbf_data, unsigned long
> > rbf_size);
> use size_t for size .
> 
Okay.
> > 
> > +int fpgamgr_test_fpga_ready(void);
> > +
> > +#define FPGA_TIMEOUT_CNT	0x1000000
> Does that need to be in header file ?
> 
Yeah, gen5 and Arria10 driver need this macro.
> > 
> > +#ifndef __ASSEMBLY__
> > +
> > +/* Common prototypes */
> > +int fpgamgr_dclkcnt_set(unsigned long cnt);
> >  
> > +#endif /* __ASSEMBLY__ */
> >  #endif /* _FPGA_MANAGER_H_ */
> [...]
> > 
> > diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga_gen5.c
> > similarity index 82%
> > copy from drivers/fpga/socfpga.c
> > copy to drivers/fpga/socfpga_gen5.c
> > index f1b2f2c..269e81e 100644
> > --- a/drivers/fpga/socfpga.c
> > +++ b/drivers/fpga/socfpga_gen5.c
> > @@ -1,5 +1,5 @@
> >  /*
> > - * Copyright (C) 2012 Altera Corporation <www.altera.com>
> > + * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
> Removal of code doesn't extend copyright IMO.
> 
Oh....okay, understood. I will revert back.
> > 
> >   * All rights reserved.
> >   *
> >   * SPDX-License-Identifier:	BSD-3-Clause
> > @@ -14,9 +14,6 @@
> >  
> >  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;
> >  static struct socfpga_system_manager *sysmgr_regs =
> > @@ -30,29 +27,6 @@ static void fpgamgr_set_cd_ratio(unsigned long
> > ratio)
> >  			(ratio & 0x3) <<
> > FPGAMGRREGS_CTRL_CDRATIO_LSB);
> >  }
> >  
> > -static int fpgamgr_dclkcnt_set(unsigned long cnt)
> > -{
> > -	unsigned long i;
> > -
> > -	/* Clear any existing done status */
> > -	if (readl(&fpgamgr_regs->dclkstat))
> > -		writel(0x1, &fpgamgr_regs->dclkstat);
> > -
> > -	/* Write the dclkcnt */
> > -	writel(cnt, &fpgamgr_regs->dclkcnt);
> > -
> > -	/* Wait till the dclkcnt done */
> > -	for (i = 0; i < FPGA_TIMEOUT_CNT; i++) {
> > -		if (!readl(&fpgamgr_regs->dclkstat))
> > -			continue;
> > -
> > -		writel(0x1, &fpgamgr_regs->dclkstat);
> > -		return 0;
> > -	}
> > -
> > -	return -ETIMEDOUT;
> > -}
> > -
> >  /* Start the FPGA programming by initialize the FPGA Manager */
> >  static int fpgamgr_program_init(void)
> >  {
> > @@ -143,34 +117,6 @@ static int fpgamgr_program_init(void)
> >  	return 0;
> >  }
> >  
> > -/* Write the RBF data to FPGA Manager */
> > -static void fpgamgr_program_write(const void *rbf_data, unsigned
> > long rbf_size)
> > -{
> > -	uint32_t src = (uint32_t)rbf_data;
> > -	uint32_t dst = SOCFPGA_FPGAMGRDATA_ADDRESS;
> > -
> > -	/* Number of loops for 32-byte long copying. */
> > -	uint32_t loops32 = rbf_size / 32;
> > -	/* Number of loops for 4-byte long copying + trailing
> > bytes */
> > -	uint32_t loops4 = DIV_ROUND_UP(rbf_size % 32, 4);
> > -
> > -	asm volatile(
> > -		"1:	ldmia	%0!,	{r0-r7}\n"
> > -		"	stmia	%1!,	{r0-r7}\n"
> > -		"	sub	%1,	#32\n"
> > -		"	subs	%2,	#1\n"
> > -		"	bne	1b\n"
> > -		"	cmp	%3,	#0\n"
> > -		"	beq	3f\n"
> > -		"2:	ldr	%2,	[%0],	#4\n
> > "
> > -		"	str	%2,	[%1]\n"
> > -		"	subs	%3,	#1\n"
> > -		"	bne	2b\n"
> > -		"3:	nop\n"
> > -		: "+r"(src), "+r"(dst), "+r"(loops32),
> > "+r"(loops4) :
> > -		: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
> > "cc");
> > -}
> > -
> >  /* Ensure the FPGA entering config done */
> >  static int fpgamgr_program_poll_cd(void)
> >  {
> > @@ -267,7 +213,6 @@ int socfpga_load(Altera_desc *desc, const void
> > *rbf_data, size_t rbf_size)
> >  	}
> >  
> >  	/* Prior programming the FPGA, all bridges need to be shut
> > off */
> > -
> Drop this bit
> 
Are you means dropping "-"? Ermm... how to drop this as this is
generated from git.
> > 
> >  	/* Disable all signals from hps peripheral controller to
> > fpga */
> >  	writel(0, &sysmgr_regs->fpgaintfgrp_module);
> >  
> > 
> 

  reply	other threads:[~2017-05-12  3:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11  9:25 [U-Boot] [PATCH v2 0/5] Add Intel Arria 10 SoC FPGA driver tien.fong.chee at intel.com
2017-05-11  9:25 ` [U-Boot] [PATCH v2 1/5] arm: socfpga: Remove unused passing parameter of socfpga_bridges_reset tien.fong.chee at intel.com
2017-05-11 11:57   ` Marek Vasut
2017-05-12  3:46     ` Chee, Tien Fong
2017-05-11  9:25 ` [U-Boot] [PATCH v2 2/5] arm: socfpga: Restructure FPGA driver in the preparation to support A10 tien.fong.chee at intel.com
2017-05-11 12:03   ` Marek Vasut
2017-05-12  3:45     ` Chee, Tien Fong [this message]
2017-05-12  7:26       ` Marek Vasut
2017-05-12  8:10         ` Chee, Tien Fong
2017-05-11  9:25 ` [U-Boot] [PATCH v2 3/5] arm: socfpga: Move FPGA manager driver to FPGA driver tien.fong.chee at intel.com
2017-05-11  9:25 ` [U-Boot] [PATCH v2 4/5] arm: socfpga: Move the FPGA driver header from arch/arm to include/ tien.fong.chee at intel.com
2017-05-11 12:04   ` Marek Vasut
2017-05-12  3:33     ` Chee, Tien Fong
2017-05-12  7:27       ` Marek Vasut
2017-05-12  8:06         ` Chee, Tien Fong
2017-05-11  9:25 ` [U-Boot] [PATCH v2 5/5] arm: socfpga: Add FPGA driver support for Arria 10 tien.fong.chee at intel.com
2017-05-11 12:09   ` Marek Vasut
2017-05-12  3:56     ` Chee, Tien Fong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1494560712.6027.12.camel@intel.com \
    --to=tien.fong.chee@intel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.