Skip to contentSkip to conversation

apf27: add support of armadeus apf27

PATCH Superseded Philippe Reynes 2 participants 6 messages Dec 1, 2012 – Dec 7, 2012

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover apf27: add support of armadeus apf27

Difference between v3 and v2:
- rebase on imx branch
- merge support and spl patch
- clean code of apf27_gpio_init
- clean code of start.S
- enable only 64MB of ram so it could work on all apf27

Difference between v1 and v2:
- use spl instead of nand_spl
- use gpio api
- remove use of useless CONFIG_SYS
- remove use of config.mk
- remove dead code

Philippe Reynes (3):
apf27: add missing constant to mx27
apf27: add support for the armadeus APF27 board
apf27: add FPGA support for the apf27 board

 MAINTAINERS                               |    5 +
 arch/arm/cpu/arm926ejs/mx27/asm-offsets.c |   34 ++
 arch/arm/include/asm/arch-mx27/imx-regs.h |   11 +-
 arch/arm/include/asm/arch-mx27/mxc_nand.h |   83 +++++
 board/armadeus/apf27/Makefile             |   51 +++
 board/armadeus/apf27/apf27.c              |  363 +++++++++++++++++++
 board/armadeus/apf27/apf27.h              |  477 +++++++++++++++++++++++++
 board/armadeus/apf27/fpga.c               |  262 ++++++++++++++
 board/armadeus/apf27/fpga.h               |   39 ++
 board/armadeus/apf27/start.S              |  538 +++++++++++++++++++++++++++++
 board/armadeus/apf27/u-boot-spl.lds       |   86 +++++
 boards.cfg                                |    1 +
 include/configs/apf27.h                   |  445 ++++++++++++++++++++++++
 13 files changed, 2394 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx27/mxc_nand.h
 create mode 100644 board/armadeus/apf27/Makefile
 create mode 100644 board/armadeus/apf27/apf27.c
 create mode 100644 board/armadeus/apf27/apf27.h
 create mode 100644 board/armadeus/apf27/fpga.c
 create mode 100644 board/armadeus/apf27/fpga.h
 create mode 100644 board/armadeus/apf27/start.S
 create mode 100644 board/armadeus/apf27/u-boot-spl.lds
 create mode 100644 include/configs/apf27.h
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH v3 1/3 apf27: add missing constant to mx27

Add some missing constant (chip select, ...), and
a file mxc_nand.h with the NFC constant.

---
 arch/arm/cpu/arm926ejs/mx27/asm-offsets.c |   34 ++++++++++++
 arch/arm/include/asm/arch-mx27/imx-regs.h |   11 ++++-
 arch/arm/include/asm/arch-mx27/mxc_nand.h |   83 +++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx27/mxc_nand.h
arch/arm/cpu/arm926ejs/mx27/asm-offsets.c +34 -0
index f3a8d7b..b95c58c 100644
@@ -34,6 +34,7 @@ int main(void)
 	DEFINE(PCDR1, IMX_PLL_BASE + offsetof(struct pll_regs, pcdr1));
 	DEFINE(PCCR0, IMX_PLL_BASE + offsetof(struct pll_regs, pccr0));
 	DEFINE(PCCR1, IMX_PLL_BASE + offsetof(struct pll_regs, pccr1));
+	DEFINE(CCSR, IMX_PLL_BASE + offsetof(struct pll_regs, ccsr));
 
 	DEFINE(ESDCTL0_ROF, offsetof(struct esdramc_regs, esdctl0));
 	DEFINE(ESDCFG0_ROF, offsetof(struct esdramc_regs, esdcfg0));
@@ -41,5 +42,38 @@ int main(void)
 	DEFINE(ESDCFG1_ROF, offsetof(struct esdramc_regs, esdcfg1));
 	DEFINE(ESDMISC_ROF, offsetof(struct esdramc_regs, esdmisc));
 
+	DEFINE(GPCR, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, gpcr));
+	DEFINE(FMCR, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, fmcr));
+	DEFINE(DSCR2, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr2));
+	DEFINE(DSCR3, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr3));
+	DEFINE(DSCR7, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr7));
+	DEFINE(DSCR10, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr10));
+
+	DEFINE(CS0U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs0u));
+	DEFINE(CS0L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs0l));
+	DEFINE(CS0A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs0a));
+	DEFINE(CS1U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs1u));
+	DEFINE(CS1L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs1l));
+	DEFINE(CS1A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs1a));
+	DEFINE(CS2U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs2u));
+	DEFINE(CS2L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs2l));
+	DEFINE(CS2A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs2a));
+	DEFINE(CS3U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs3u));
+	DEFINE(CS3L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs3l));
+	DEFINE(CS3A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs3a));
+	DEFINE(CS4U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs4u));
+	DEFINE(CS4L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs4l));
+	DEFINE(CS4A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs4a));
+	DEFINE(CS5U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs5u));
+	DEFINE(CS5L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs5l));
+	DEFINE(CS5A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs5a));
+	DEFINE(EIM,  IMX_WEIM_BASE + offsetof(struct weim_regs, eim));
+
 	return 0;
 }
arch/arm/include/asm/arch-mx27/imx-regs.h +10 -1
index 2f6c823..d3a14e1 100644
@@ -185,7 +185,7 @@ struct iim_regs {
 	struct fuse_bank {
 		u32 fuse_regs[0x20];
 		u32 fuse_rsvd[0xe0];
-	} bank[1];
+	} bank[2];
 };
 
 struct fuse_bank0_regs {
@@ -511,4 +511,13 @@ struct fuse_bank0_regs {
 #define IIM_ERR_SNSE	(1 << 2)
 #define IIM_ERR_PARITYE	(1 << 1)
 
+/*
+ * Memory areas of the NFC
+ */
+#define IMX_NFC_BASE                    (0xD8000000)
+#define IMX_NFC_MAIN_AREA0              (0xD8000000)
+#define IMX_NFC_MAIN_AREA1              (0xD8000200)
+#define IMX_NFC_SPARE_AREA0             (0xD8000800)
+#define IMX_NFC_REGS                    (0xD8000E00)
+
 #endif				/* _IMX_REGS_H */
arch/arm/include/asm/arch-mx27/mxc_nand.h new file +83 -0

83 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#2 lore raw

PATCH v3 1/3 apf27: add missing constant to mx27

Quoted 6 lines · Philippe Reynes

Add some missing constant (chip select, ...), and
a file mxc_nand.h with the NFC constant.

---

Hi Philippe,

Quoted 62 lines
 arch/arm/cpu/arm926ejs/mx27/asm-offsets.c |   34 ++++++++++++
 arch/arm/include/asm/arch-mx27/imx-regs.h |   11 ++++-
 arch/arm/include/asm/arch-mx27/mxc_nand.h |   83 +++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx27/mxc_nand.h
arch/arm/cpu/arm926ejs/mx27/asm-offsets.c +34 -0
index f3a8d7b..b95c58c 100644
@@ -34,6 +34,7 @@ int main(void)
 	DEFINE(PCDR1, IMX_PLL_BASE + offsetof(struct pll_regs, pcdr1));
 	DEFINE(PCCR0, IMX_PLL_BASE + offsetof(struct pll_regs, pccr0));
 	DEFINE(PCCR1, IMX_PLL_BASE + offsetof(struct pll_regs, pccr1));
+	DEFINE(CCSR, IMX_PLL_BASE + offsetof(struct pll_regs, ccsr));
 
 	DEFINE(ESDCTL0_ROF, offsetof(struct esdramc_regs, esdctl0));
 	DEFINE(ESDCFG0_ROF, offsetof(struct esdramc_regs, esdcfg0));
@@ -41,5 +42,38 @@ int main(void)
 	DEFINE(ESDCFG1_ROF, offsetof(struct esdramc_regs, esdcfg1));
 	DEFINE(ESDMISC_ROF, offsetof(struct esdramc_regs, esdmisc));
 
+	DEFINE(GPCR, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, gpcr));
+	DEFINE(FMCR, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, fmcr));
+	DEFINE(DSCR2, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr2));
+	DEFINE(DSCR3, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr3));
+	DEFINE(DSCR7, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr7));
+	DEFINE(DSCR10, IMX_SYSTEM_CTL_BASE +
+	       offsetof(struct system_control_regs, dscr10));
+
+	DEFINE(CS0U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs0u));
+	DEFINE(CS0L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs0l));
+	DEFINE(CS0A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs0a));
+	DEFINE(CS1U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs1u));
+	DEFINE(CS1L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs1l));
+	DEFINE(CS1A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs1a));
+	DEFINE(CS2U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs2u));
+	DEFINE(CS2L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs2l));
+	DEFINE(CS2A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs2a));
+	DEFINE(CS3U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs3u));
+	DEFINE(CS3L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs3l));
+	DEFINE(CS3A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs3a));
+	DEFINE(CS4U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs4u));
+	DEFINE(CS4L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs4l));
+	DEFINE(CS4A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs4a));
+	DEFINE(CS5U, IMX_WEIM_BASE + offsetof(struct weim_regs, cs5u));
+	DEFINE(CS5L, IMX_WEIM_BASE + offsetof(struct weim_regs, cs5l));
+	DEFINE(CS5A, IMX_WEIM_BASE + offsetof(struct weim_regs, cs5a));
+	DEFINE(EIM,  IMX_WEIM_BASE + offsetof(struct weim_regs, eim));
+
 	return 0;
 }
arch/arm/include/asm/arch-mx27/imx-regs.h +0 -0
index 2f6c823..d3a14e1 100644

arch/arm/include/asm/arch-mx27/imx-regs.h struct iim_regs { · line 189

Quoted 6 lines
arch/arm/include/asm/arch-mx27/imx-regs.h +1 -1
@@ -185,7 +185,7 @@ struct iim_regs {
 	struct fuse_bank {
 		u32 fuse_regs[0x20];
 		u32 fuse_rsvd[0xe0];
-	} bank[1];
+	} bank[2];
 };

I think the

Quoted 67 lines
arch/arm/include/asm/arch-mx27/imx-regs.h +9 -0
 struct fuse_bank0_regs {
@@ -511,4 +511,13 @@ struct fuse_bank0_regs {
 #define IIM_ERR_SNSE	(1 << 2)
 #define IIM_ERR_PARITYE	(1 << 1)
 
+/*
+ * Memory areas of the NFC
+ */
+#define IMX_NFC_BASE                    (0xD8000000)
+#define IMX_NFC_MAIN_AREA0              (0xD8000000)
+#define IMX_NFC_MAIN_AREA1              (0xD8000200)
+#define IMX_NFC_SPARE_AREA0             (0xD8000800)
+#define IMX_NFC_REGS                    (0xD8000E00)
+
 #endif				/* _IMX_REGS_H */
arch/arm/include/asm/arch-mx27/mxc_nand.h new file +45 -0
new file mode 100644
index 0000000..564419e
@@ -0,0 +1,83 @@
+/*
+ * (c) 2012 Philippe Reynes <[email protected]>
+ *
+ * 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 __MXC_NAND_H
+#define __MXC_NAND_H
+
+/*
+ * NFC registers address offset
+ */
+#define NFC_OFFSET_BUFSIZE             (0x00) /* Internal SRAM Size */
+#define NFC_OFFSET_BLCK_ADD_LOCK       (0x02) /* NAND Flash Block Address for
+						 Lock Check */
+#define NFC_OFFSET_BUF_ADDR            (0x04) /* Buffer Number for Page Data
+						 Transfer To/From Flash Mem */
+#define NFC_OFFSET_FLASH_ADDR          (0x06) /* NAND Flash Address */
+#define NFC_OFFSET_FLASH_CMD           (0x08) /* NAND Flash Command */
+#define NFC_OFFSET_CONFIG              (0x0A) /* NFC Internal Buffer Lock
+						 Control */
+#define NFC_OFFSET_ECC_STATUS_RESULT   (0x0C) /* Controller Status/Result of
+						 Flash Operation */
+#define NFC_OFFSET_ECC_RSLT_MAIN_AREA  (0x0E) /* ECC Error Position of Main
+						 Area Data Error */
+#define NFC_OFFSET_ECC_RSLT_SPARE_AREA (0x10) /* ECC Error Position of Spare
+						 Area Data Error */
+#define NFC_OFFSET_WRPROT              (0x12) /* Nand Flash Write Protection */
+#define NFC_OFFSET_UNLOCKSTART_BLKADDR (0x14) /* Start Address for Write

arch/arm/include/asm/arch-mx27/mxc_nand.h line 55

Quoted 10 lines
arch/arm/include/asm/arch-mx27/mxc_nand.h new file +10 -0
+						 Protection Unlock */
+#define NFC_OFFSET_UNLOCKEND_BLKADDR   (0x16) /* End Address for Write
+						 Protection Unlock */
+#define NFC_OFFSET_WRPR_STAT           (0x18) /* Current Nand Flash Write
+						 Protection Status */
+#define NFC_OFFSET_CONFIG1             (0x1A) /* Nand Flash Operation
+						 Configuration 1 */
+#define NFC_OFFSET_CONFIG2             (0x1C) /* Nand Flash Operation
+						 Configuration 2 */
+

Why do you need an extra definitions for the NFC controller when we have already one general for all i.MX ? What you define here can be found in include/fsl_nfc.h, and the NFC controller for i.MX27 is supported as well.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#3 lore raw

PATCH v2 2/3 apf27: add support for the armadeus APF27 board

In reply to Philippe Reynes
---
 MAINTAINERS                         |    5 +
 board/armadeus/apf27/Makefile       |   48 +++
 board/armadeus/apf27/apf27.c        |  347 ++++++++++++++++++++++
 board/armadeus/apf27/apf27.h        |  477 +++++++++++++++++++++++++++++++
 board/armadeus/apf27/start.S        |  538 +++++++++++++++++++++++++++++++++++
 board/armadeus/apf27/u-boot-spl.lds |   86 ++++++
 boards.cfg                          |    1 +
 include/configs/apf27.h             |  445 +++++++++++++++++++++++++++++
 8 files changed, 1947 insertions(+), 0 deletions(-)
 create mode 100644 board/armadeus/apf27/Makefile
 create mode 100644 board/armadeus/apf27/apf27.c
 create mode 100644 board/armadeus/apf27/apf27.h
 create mode 100644 board/armadeus/apf27/start.S
 create mode 100644 board/armadeus/apf27/u-boot-spl.lds
 create mode 100644 include/configs/apf27.h
MAINTAINERS +5 -0
index e34d9f3..3ac0c92 100644
@@ -696,6 +696,11 @@ Ilko Iliev <[email protected]>
 	PM9263		AT91SAM9263
 	PM9G45		ARM926EJS (AT91SAM9G45 SoC)
 
+Eric Jarrige <[email protected]>
+Philippe Reynes <[email protected]>
+
+	apf27		ARM926EJS (i.MX27 SoC)
+
 Michael Jones <[email protected]>
 
 	omap3_mvblx	ARM ARMV7 (OMAP3xx SoC)
board/armadeus/apf27/Makefile new file +48 -0

48 lines not on this page · raw message

board/armadeus/apf27/apf27.c new file +347 -0

347 lines not on this page · raw message

board/armadeus/apf27/apf27.h new file +477 -0

477 lines not on this page · raw message

board/armadeus/apf27/start.S new file +538 -0

538 lines not on this page · raw message

board/armadeus/apf27/u-boot-spl.lds new file +86 -0

86 lines not on this page · raw message

boards.cfg +1 -0
index 6f21af0..fdee7e7 100644
@@ -186,6 +186,7 @@ jadecpu                      arm         arm926ejs   jadecpu             syteco
 mx25pdk                      arm         arm926ejs   mx25pdk             freescale      mx25		mx25pdk:IMX_CONFIG=board/freescale/mx25pdk/imximage.cfg
 tx25                         arm         arm926ejs   tx25                karo           mx25
 zmx25                        arm         arm926ejs   zmx25               syteco         mx25
+apf27                        arm         arm926ejs   apf27               armadeus       mx27
 imx27lite                    arm         arm926ejs   imx27lite           logicpd        mx27
 magnesium                    arm         arm926ejs   imx27lite           logicpd        mx27
 apx4devkit                   arm         arm926ejs   apx4devkit          bluegiga       mxs		apx4devkit
include/configs/apf27.h new file +445 -0

445 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#4 lore raw

PATCH v2 2/3 apf27: add support for the armadeus APF27 board

Quoted 20 lines · Philippe Reynes
---
 MAINTAINERS                         |    5 +
 board/armadeus/apf27/Makefile       |   48 +++
 board/armadeus/apf27/apf27.c        |  347 ++++++++++++++++++++++
 board/armadeus/apf27/apf27.h        |  477 +++++++++++++++++++++++++++++++
 board/armadeus/apf27/start.S        |  538 +++++++++++++++++++++++++++++++++++
 board/armadeus/apf27/u-boot-spl.lds |   86 ++++++
 boards.cfg                          |    1 +
 include/configs/apf27.h             |  445 +++++++++++++++++++++++++++++
 8 files changed, 1947 insertions(+), 0 deletions(-)
 create mode 100644 board/armadeus/apf27/Makefile
 create mode 100644 board/armadeus/apf27/apf27.c
 create mode 100644 board/armadeus/apf27/apf27.h
 create mode 100644 board/armadeus/apf27/start.S
 create mode 100644 board/armadeus/apf27/u-boot-spl.lds
 create mode 100644 include/configs/apf27.h

Hi Philippe,

I tried your patches, but build fails:

./MAKEALL apf27
Configuring for apf27 board...
make: *** [nand_spl] Error 2
arm-linux-gnueabi-size: './u-boot': No such file
make: *** nand_spl/board/armadeus/apf27: No such file or directory. Stop.
make: *** [nand_spl] Error 2
make: *** Waiting for unfinished jobs....

Using the generic SPL, I am expecting that nand_spl is not used at all. Objects and result should go into the SPL directory.

Quoted 13 lines
board/armadeus/apf27/apf27.c new file +13 -0
+/*
+ * Fuse bank 1 row 8 is "reserved for future use" and therefore available for
+ * customer use. The APF27 board uses this fuse to store the board revision:
+ * 0: initial board revision
+ * 1: first revision - Presence of the second RAM chip on the board is blown in
+ *     fuse bank 1 row 9  bit 0 - No hardware change
+ * N: to be defined
+ */
+u32 get_board_rev(void)
+{
+	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
+
+	return readl(&iim->bank[1].fuse_regs[8]);

board/armadeus/apf27/apf27.c line 58

Quoted 10 lines
board/armadeus/apf27/apf27.c new file +10 -0
+}
+
+/*
+ * Fuse bank 1 row 9 is "reserved for future use" and therefore available for
+ * customer use. The APF27 board revision 1 uses the bit 0 to permanently store
+ * the presence of the second RAM chip
+ * 0: AFP27 with 1 RAM of 64 MiB
+ * 1: AFP27 with 2 RAM chips of 64 MiB each (128MB)
+ */
+int get_num_ram_bank(void)

This should be declared static, I think.

board/armadeus/apf27/apf27.c line 271

Quoted 11 lines
board/armadeus/apf27/apf27.c new file +11 -0
+int
+dram_init(void)
+{
+	/* dram_init must store complete ramsize in gd->ram_size */
+	if (get_num_ram_bank() > 1) {
+		gd->ram_size = PHYS_SDRAM_2 - CONFIG_SYS_SDRAM_BASE
+			+ get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	} else {
+		gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
+			PHYS_SDRAM_1_SIZE);
+	}

Doesn't the following code work ?

	gd->ram_size =  get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
	get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);

board/armadeus/apf27/apf27.c line 287

Quoted 12 lines
board/armadeus/apf27/apf27.c new file +12 -0
+void dram_init_banksize(void)
+{
+	phys_size_t ramsize = gd->ram_size;
+
+	if (get_num_ram_bank() > 1)
+		ramsize -= PHYS_SDRAM_2 - CONFIG_SYS_SDRAM_BASE;
+
+	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+	gd->bd->bi_dram[0].size = ramsize;
+	gd->ram_size = gd->bd->bi_dram[0].size;
+
+	if (CONFIG_NR_DRAM_BANKS > 1) {

Do you need this ? It seems from your code that you can find at run time how many banks are mounted.

board/armadeus/apf27/apf27.c line 308

Quoted 12 lines
board/armadeus/apf27/apf27.c new file +12 -0
+/*
+ * Miscellaneous initialisation
+ */
+int
+misc_init_r(void)
+{
+	char *s;
+	u_char * firmware_buffer = (u_char *)(CONFIG_SYS_LOAD_ADDR + \
+					      CONFIG_SYS_MONITOR_LEN);
+	size_t size	= 0;
+	size_t offset	= -1;
+	char *autoload = getenv("firmware_autoload");

you search for the environment, but autoload is not used in this function, right ?

board/armadeus/apf27/apf27.c line 315

Quoted 7 lines
board/armadeus/apf27/apf27.c new file +7 -0
+	u8 pnum;
+	struct mtd_device *dev;
+	struct part_info *part;
+
+	/* detect compatibility issue of environment version */
+	s = getenv("env_version");
+	if ((NULL == s) || (0 != strcmp(s, CONFIG_ENV_VERSION))) {

Not clear at all. You add a version to the environment, ok, but you check it with a version number known at compile time. Do you use it really

board/armadeus/apf27/apf27.c line 324

Quoted 9 lines
board/armadeus/apf27/apf27.c new file +9 -0
+		char * const vars[] = {"flash_reset_env"};
+		printf("*** Warning - Environment version change suggests: "
+			"run flash_reset_env; reset\n");
+		set_default_vars(1, vars);
+	}
+
+	/* Unlock whole flash but U-Boot */
+	s = getenv("env_offset");
+	offset = CONFIG_ENV_OFFSET;

This seems dangerous. You can set a variable, but the offset for the environment is defined at compile time. This does not make a lot of sense for me.

board/armadeus/apf27/apf27.c line 346

Quoted 6 lines
board/armadeus/apf27/apf27.c new file +6 -0
+void enable_caches(void)
+{
+	/* Enable D-cache. I-cache is already enabled in start.S */
+	dcache_enable();
+}
+

I suggest you move this function in a separate patch to arch/arm/cpu/arm926ejs/mx27/generic.c. This code can be used by other boards, too.

Quoted 10 lines

+++ b/board/armadeus/apf27/apf27.h

board/armadeus/apf27/apf27.h new file +8 -0
@@ -0,0 +1,477 @@
+#ifndef __APF27_H
+#define __APF27_H
+
+/* FPGA program pin configuration */
+#define ACFG_FPGA_PWR	(GPIO_PORTF | 19)	/* FPGA prog pin  */
+#define ACFG_FPGA_PRG	(GPIO_PORTF | 11)	/* FPGA prog pin  */
+#define ACFG_FPGA_CLK	(GPIO_PORTF | 15)	/* FPGA clk pin   */
+#define ACFG_FPGA_RDATA	0xD6000000		/* FPGA data addr  */

board/armadeus/apf27/apf27.h line 18

Quoted 10 lines
board/armadeus/apf27/apf27.h new file +10 -0
+#define ACFG_FPGA_WDATA	0xD6000000		/* FPGA data addr  */
+#define ACFG_FPGA_INIT	(GPIO_PORTF | 12)	/* FPGA init pin  */
+#define ACFG_FPGA_DONE	(GPIO_PORTF | 9)	/* FPGA done pin  */
+#define ACFG_FPGA_RW	(GPIO_PORTF | 21)	/* FPGA done pin  */
+#define ACFG_FPGA_CS	(GPIO_PORTF | 22)	/* FPGA done pin  */
+#define ACFG_FPGA_SUSPEND (GPIO_PORTF | 10)	/* FPGA done pin  */
+#define ACFG_FPGA_RESET	(GPIO_PORTF | 7)	/* FPGA done pin  */
+
+/* MPU CLOCK source before PLL  */
+/* ACFG_CLK_FREQ (2/3 MPLL clock or ext 266 MHZ) */

Style, wrong multiline comment.

Quoted 5 lines
board/armadeus/apf27/apf27.h new file +5 -0
+#ifndef CONFIG_MX27_CLK26
+#if (CONFIG_MX27_CLK32 == 32000)
+#define ACFG_MPCTL0_VAL		0x00211803	/* 398.998 MHz */
+#define ACFG_MPCTL1_VAL		0
+#define CONFIG_MPLL_FREQ	399

board/armadeus/apf27/apf27.h line 33

Quoted 10 lines
board/armadeus/apf27/apf27.h new file +10 -0
+#else /* CONFIG_MX27_CLK32 == 32768*/
+#define ACFG_MPCTL0_VAL		0x01EF15D5	/* 399.000 MHz */
+#define ACFG_MPCTL1_VAL		0
+#define CONFIG_MPLL_FREQ	399
+#endif /* CONFIG_MX27_CLK32 */
+#else /* CONFIG_MX27_CLK26 in use*/
+#define ACFG_MPCTL0_VAL		0x00331C23	/* 399.000 MHz */
+#define ACFG_MPCTL1_VAL		0
+#define CONFIG_MPLL_FREQ	399
+#endif /* CONFIG_MX27_CLK26 */

Is it old code ? CONFIG_MX27_CLK26 is not used at all in u-boot, and you do not define it. If we can get rid of it, please then clean up also the other parts using #ifndef CONFIG_MX27_CLK26

Quoted 126 lines
board/armadeus/apf27/apf27.h new file +126 -0
+
+/* ARM bus frequency (have to be a CONFIG_MPLL_FREQ ratio) */
+#define CONFIG_ARM_FREQ		399	/* up to 400 MHz */
+
+/* external bus frequency (have to be a ACFG_CLK_FREQ ratio) */
+#define CONFIG_HCLK_FREQ	133	/* (ACFG_CLK_FREQ/2) */
+
+#define CONFIG_PERIF1_FREQ	16	/* 16.625 MHz UART, GPT, PWM*/
+#define CONFIG_PERIF2_FREQ	33	/* 33.25 MHz CSPI and SDHC */
+#define CONFIG_PERIF3_FREQ	33	/* 33.25 MHz LCD*/
+#define CONFIG_PERIF4_FREQ	33	/* 33.25 MHz CSI*/
+#define CONFIG_SSI1_FREQ	66	/* 66.50 MHz SSI1*/
+#define CONFIG_SSI2_FREQ	66	/* 66.50 MHz SSI2*/
+#define CONFIG_MSHC_FREQ	66	/* 66.50 MHz MSHC*/
+#define CONFIG_H264_FREQ	66	/* 66.50 MHz H264*/
+#define CONFIG_CLK0_DIV      3  /* Divide CLK0 by 4 */
+#define CONFIG_CLK0_EN       1  /* CLK0 enabled */
+
+/* external bus frequency (have to be a CONFIG_HCLK_FREQ ratio) */
+#define CONFIG_NFC_FREQ		44	/* NFC Clock up to 44 MHz wh 133MHz*/
+
+/* external serial bus frequency (have to be a CONFIG_SPLL_FREQ ratio) */
+#define CONFIG_USB_FREQ		60	/* 60 MHz */
+
+/*
+ * SDRAM
+ */
+#if (ACFG_SDRAM_MBYTE_SYZE == 64) /* micron MT46H16M32LF -6 */
+/* micron 64MB */
+#define ACFG_SDRAM_NUM_COL		9  /* 8, 9, 10 or 11
+						      column address bits */
+#define ACFG_SDRAM_NUM_ROW		13 /* 11, 12 or 13
+						      row address bits */
+#define ACFG_SDRAM_REFRESH		3  /* 0=OFF 1=2048
+						      2=4096 3=8192 refresh */
+#define ACFG_SDRAM_EXIT_PWD		25 /* ns exit power
+						      down delay */
+#define ACFG_SDRAM_W2R_DELAY		1  /* write to read
+						      cycle delay > 0 */
+#define ACFG_SDRAM_ROW_PRECHARGE_DELAY	18 /* ns */
+#define ACFG_SDRAM_TMRD_DELAY		2  /* Load mode register
+						      cycle delay 1..4 */
+#define ACFG_SDRAM_TWR_DELAY		1  /* LPDDR: 0=2ck 1=3ck;
+						      SDRAM: 0=1ck 1=2ck*/
+#define ACFG_SDRAM_RAS_DELAY		42 /* ns ACTIVE-to-PRECHARGE
+						      delay */
+#define ACFG_SDRAM_RRD_DELAY		12 /* ns ACTIVE-to-ACTIVE
+						      delay */
+#define ACFG_SDRAM_RCD_DELAY		18 /* ns Row to Column delay */
+#define ACFG_SDRAM_RC_DELAY		70 /* ns Row cycle delay (tRFC
+						      refresh to command) */
+#define ACFG_SDRAM_CLOCK_CYCLE_CL_1	0 /* ns clock cycle time
+						     estimated fo CL=1
+						     0=force 3 for lpddr */
+#define ACFG_SDRAM_PARTIAL_ARRAY_SR	0  /* 0=full 1=half 2=quater
+						      3=Eighth 4=Sixteenth */
+#define ACFG_SDRAM_DRIVE_STRENGH		0  /* 0=Full-strength 1=half
+						      2=quater 3=Eighth */
+#define ACFG_SDRAM_BURST_LENGTH		3  /* 2^N BYTES (N=0..3) */
+#define ACFG_SDRAM_SINGLE_ACCESS		0  /* 1= single access;
+						      0 = Burst mode */
+#endif
+
+#if (ACFG_SDRAM_MBYTE_SYZE == 128)
+/* micron 128MB */
+#define ACFG_SDRAM_NUM_COL		9  /* 8, 9, 10 or 11
+						      column address bits */
+#define ACFG_SDRAM_NUM_ROW		14 /* 11, 12 or 13
+						      row address bits */
+#define ACFG_SDRAM_REFRESH		3  /* 0=OFF 1=2048
+						      2=4096 3=8192 refresh */
+#define ACFG_SDRAM_EXIT_PWD		25 /* ns exit power
+						      down delay */
+#define ACFG_SDRAM_W2R_DELAY		1  /* write to read
+						      cycle delay > 0 */
+#define ACFG_SDRAM_ROW_PRECHARGE_DELAY	18 /* ns */
+#define ACFG_SDRAM_TMRD_DELAY		2  /* Load mode register
+						      cycle delay 1..4 */
+#define ACFG_SDRAM_TWR_DELAY		1  /* LPDDR: 0=2ck 1=3ck;
+						      SDRAM: 0=1ck 1=2ck*/
+#define ACFG_SDRAM_RAS_DELAY		42 /* ns ACTIVE-to-PRECHARGE
+						      delay */
+#define ACFG_SDRAM_RRD_DELAY		12 /* ns ACTIVE-to-ACTIVE
+						      delay */
+#define ACFG_SDRAM_RCD_DELAY		18 /* ns Row to Column delay */
+#define ACFG_SDRAM_RC_DELAY		70 /* ns Row cycle delay (tRFC
+						      refresh to command)*/
+#define ACFG_SDRAM_CLOCK_CYCLE_CL_1	0 /* ns clock cycle time
+						     estimated fo CL=1
+						     0=force 3 for lpddr*/
+#define ACFG_SDRAM_PARTIAL_ARRAY_SR	0  /* 0=full 1=half 2=quater
+						      3=Eighth 4=Sixteenth */
+#define ACFG_SDRAM_DRIVE_STRENGH		0  /* 0=Full-strength 1=half
+						      2=quater 3=Eighth */
+#define ACFG_SDRAM_BURST_LENGTH		3  /* 2^N BYTES (N=0..3) */
+#define ACFG_SDRAM_SINGLE_ACCESS		0  /* 1= single access;
+						      0 = Burst mode */
+#endif
+
+#if (ACFG_SDRAM_MBYTE_SYZE == 256)
+/* micron 256MB */
+#define ACFG_SDRAM_NUM_COL		10  /* 8, 9, 10 or 11
+						       column address bits */
+#define ACFG_SDRAM_NUM_ROW		14 /* 11, 12 or 13
+						      row address bits */
+#define ACFG_SDRAM_REFRESH		3  /* 0=OFF 1=2048
+						      2=4096 3=8192 refresh */
+#define ACFG_SDRAM_EXIT_PWD		25 /* ns exit power
+						      down delay */
+#define ACFG_SDRAM_W2R_DELAY		1  /* write to read cycle
+						      delay > 0 */
+#define ACFG_SDRAM_ROW_PRECHARGE_DELAY	18 /* ns */
+#define ACFG_SDRAM_TMRD_DELAY		2  /* Load mode register
+						      cycle delay 1..4 */
+#define ACFG_SDRAM_TWR_DELAY		1  /* LPDDR: 0=2ck 1=3ck;
+						      SDRAM: 0=1ck 1=2ck */
+#define ACFG_SDRAM_RAS_DELAY		42 /* ns ACTIVE-to-PRECHARGE
+						      delay */
+#define ACFG_SDRAM_RRD_DELAY		12 /* ns ACTIVE-to-ACTIVE
+						      delay */
+#define ACFG_SDRAM_RCD_DELAY		18 /* ns Row to Column delay */
+#define ACFG_SDRAM_RC_DELAY		70 /* ns Row cycle delay (tRFC
+						      refresh to command) */
+#define ACFG_SDRAM_CLOCK_CYCLE_CL_1	0 /* ns clock cycle time
+						     estimated fo CL=1
+						     0=force 3 for lpddr */

board/armadeus/apf27/apf27.h line 188

Quoted 10 lines
board/armadeus/apf27/apf27.h new file +10 -0
+#define ACFG_SDRAM_PARTIAL_ARRAY_SR	0  /* 0=full 1=half 2=quater
+						      3=Eighth 4=Sixteenth */
+#define ACFG_SDRAM_DRIVE_STRENGH		0  /* 0=Full-strength
+						      1=half
+						      2=quater
+						      3=Eighth */
+#define ACFG_SDRAM_BURST_LENGTH		3  /* 2^N BYTES (N=0..3) */
+#define ACFG_SDRAM_SINGLE_ACCESS		0  /* 1= single access;
+						      0 = Burst mode */
+#endif

I understand why, but maybe it is more readable if you define a table in apf27.c and you access to it on depend of the selected RAM. Something like:

	struct ram_timing {
		.....
	}

	struct ram_timing apf27_ram[] = {
		{... }, /* 64 MB */
		{...},	/* 128 MB */
		{...}	/* 256 MB */
	}

What do you think about ?

Quoted 8 lines
board/armadeus/apf27/apf27.h new file +8 -0
+/*
+ * Default configuration for GPIOs and peripherals
+ */
+#ifndef ACFG_APF27_CUSTOM
+#define ACFG_DDIR_A_VAL		0x00000000
+#define ACFG_OCR1_A_VAL		0x00000000
+#define ACFG_OCR2_A_VAL		0x00000000
+#define ACFG_ICFA1_A_VAL		0xFFFFFFFF

board/armadeus/apf27/apf27.h line 272

Quoted 10 lines
board/armadeus/apf27/apf27.h new file +10 -0
+#define ACFG_ICFA2_A_VAL		0xFFFFFFFF
+#define ACFG_ICFB1_A_VAL		0xFFFFFFFF
+#define ACFG_ICFB2_A_VAL		0xFFFFFFFF
+#define ACFG_DR_A_VAL		0x00000000
+#define ACFG_GIUS_A_VAL		0xFFFFFFFF
+#define ACFG_ICR1_A_VAL		0x00000000
+#define ACFG_ICR2_A_VAL		0x00000000
+#define ACFG_IMR_A_VAL		0x00000000
+#define ACFG_GPR_A_VAL		0x00000000
+#define ACFG_PUEN_A_VAL		0xFFFFFFFF

I am unsure if I have understood. This seems the setup of the GPIOs controller, and for that we have gpio_ function. Why do we need all this stuff ?

board/armadeus/apf27/apf27.h line 362

Quoted 13 lines
board/armadeus/apf27/apf27.h new file +13 -0
+/* Enforce DDR signal strengh & enable USB/PP/DMA burst override bits */
+#define ACFG_GPCR_VAL		0x0003000F
+
+#define ACFG_ESDMISC_VAL		ESDMISC_LHD+ESDMISC_MDDREN
+
+/* FMCR select num LPDDR RAMs and nand 16bits, 2KB pages */
+#if (CONFIG_NR_DRAM_BANKS == 1)
+#define ACFG_FMCR_VAL 0xFFFFFFF9
+#elif (CONFIG_NR_DRAM_BANKS == 2)
+#define ACFG_FMCR_VAL 0xFFFFFFFB
+#endif
+
+#ifndef ACFG_APF27_CUSTOM

..but ACFG_APF27_CUSTOM is not set at all - also old code and can we clean up ?

Quoted 98 lines
board/armadeus/apf27/start.S new file +92 -0
new file mode 100644
index 0000000..05d5de0
@@ -0,0 +1,538 @@
+/*
+ *  IMX27 NAND Flash SPL (Secondary Program Loader)
+ *
+ *  Copyright (c) 2008  Armadeus Project / eja
+ *
+ *  Based on Freescale NAND SPL
+ *
+ *  Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+ *  Copyright (c) 2008-2012 Eric Jarrige <[email protected]>
+ *
+ * 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 <config.h>
+#include <generated/asm-offsets.h>
+#include <version.h>
+#include <asm/macro.h>
+#include <asm/arch/mxc_nand.h>
+#include <asm/arch/imx-regs.h>
+#include "apf27.h"
+
+/*
+ * Standard NAND flash commands
+ */
+#define NAND_CMD_READ0		0
+#define NAND_CMD_READ1		1
+#define NAND_CMD_PAGEPROG	0x10
+#define NAND_CMD_READOOB	0x50
+#define NAND_CMD_ERASE1		0x60
+#define NAND_CMD_STATUS		0x70
+#define NAND_CMD_STATUS_MULTI	0x71
+#define NAND_CMD_SEQIN		0x80
+#define NAND_CMD_READID		0x90
+#define NAND_CMD_ERASE2		0xd0
+#define NAND_CMD_RESET		0xff
+
+/* Extended commands for large page devices */
+#define NAND_CMD_READSTART	0x30
+#define NAND_CMD_CACHEDPROG	0x15
+
+/* Status bits */
+#define NAND_STATUS_FAIL	0x01
+#define NAND_STATUS_FAIL_N1	0x02
+#define NAND_STATUS_TRUE_READY	0x20
+#define NAND_STATUS_READY	0x40
+#define NAND_STATUS_WP		0x80
+
+	.macro nand_boot
+
+#ifdef CONFIG_BOOT_TRACE_REG
+/*
+ * If CONFIG_BOOT_TRACE_REG is a SDRAM address then be sure to use the following
+ * 2 command after SDRAM init
+ */
+
+/* Backup state of previous boot to CONFIG_BOOT_TRACE_REG+4*/
+#define BACKUP_TRACE()			\
+	ldr r4, =CONFIG_BOOT_TRACE_REG;	\
+	ldr r3, [r4];			\
+	str r3, [r4, #0x04];
+
+/* Save a state of boot at CONFIG_BOOT_TRACE_REG */
+#define BOOT_TRACE(val)		\
+	ldr r4, =CONFIG_BOOT_TRACE_REG;	\
+	ldr r3, =val;			\
+	str r3, [r4];
+#else
+#define BACKUP_TRACE()
+#define BOOT_TRACE(val)
+#endif
+
+nand_boot_setup:
+
+	/* Copy SPL image from flash to SDRAM first */
+	BOOT_TRACE(1)

board/armadeus/apf27/start.S line 102

Quoted 10 lines
board/armadeus/apf27/start.S new file +10 -0
+	ldr r0, =IMX_NFC_MAIN_AREA0
+	add r2, r0, #(IMX_NFC_SPARE_AREA0-IMX_NFC_MAIN_AREA0) //2KB NFC Buff
+	ldr r1, =CONFIG_SYS_NAND_U_BOOT_DST
+
+	BOOT_TRACE(2)
+1:	ldmia r0!, {r3-r10}
+	stmia r1!, {r3-r10}
+	cmp r0, r2
+	blo 1b
+

If SPL can link mxc_nand.c, you have all functions if you link also nand_spl_simple.o and nand_spl_load.o. Why do we need to redefine them in assembly ?

board/armadeus/apf27/start.S line 111

Quoted 9 lines
board/armadeus/apf27/start.S new file +9 -0
+
+
+	/* Jump to SDRAM */
+	BOOT_TRACE(3)
+	ldr r1, =0x7FF
+	and r0, pc, r1	 /* offset of pc */
+	ldr r1, =CONFIG_SYS_NAND_U_BOOT_DST
+	add r1, r1, #0x10
+	add pc, r0, r1

This is also done by generic SPL code.

Quoted 38 lines
board/armadeus/apf27/start.S new file +38 -0
+.globl _start
+_start:
+
+/*
+ *************************************************************************
+ *
+ * Startup Code (reset vector)
+ *
+ * do important init only if we don't start from memory!
+ * setup Memory and board specific bits prior to relocation.
+ * relocate armboot to ram
+ * setup stack
+ *
+ *************************************************************************
+ */
+
+
+/*
+ * the actual reset code
+ */
+
+reset:
+	/*
+	 * set the cpu to SVC32 mode
+	 */
+	mrs	r0,cpsr
+	bic	r0,r0,#0x1f
+	orr	r0,r0,#0xd3
+	msr	cpsr,r0
+
+	/*
+	 * invalidate I/D cache/TLB and drain write buffer
+	 */
+	mov r0, #0
+	mcr p15, 0, r0, c7, c7, 0	/* invalidate I cache and D cache */
+	mcr p15, 0, r0, c8, c7, 0	/* invalidate TLBs */
+	mcr p15, 0, r0, c7, c10, 4   /* Drain the write buffer */
+

board/armadeus/apf27/start.S line 349

Quoted 10 lines
board/armadeus/apf27/start.S new file +10 -0
+	/*
+	 * disable MMU stuff and caches
+	 */
+	mrc p15, 0, r0, c1, c0, 0
+	bic	r0, r0, #0x00002300	/* clear bits 13, 9:8 (--V- --RS) */
+	bic	r0, r0, #0x00000087	/* clear bits 7, 2:0 (B--- -CAM) */
+	orr	r0, r0, #0x00000002	/* set bit 2 (A) Align */
+	orr	r0, r0, #0x00001000	/* set bit 12 (I) I-Cache */
+	mcr p15, 0, r0, c1, c0, 0
+

You also duplicate stuff that is in the generic arch/arm/cpu/arm926ejs/start.S. Better, you substitute the generic one with yours. But the generic has support to call SPL function, so why to replace it ?

Quoted 6 lines
board/armadeus/apf27/start.S new file +6 -0
+/*
+ * SPL
+ */
+/* Copy SPL+U-Boot here	     */
+#define CONFIG_SYS_NAND_U_BOOT_DST	(CONFIG_SYS_TEXT_BASE - 0x800)
+/* Size is the partion size  */

board/armadeus/apf27/start.S line 175

Quoted 10 lines
board/armadeus/apf27/start.S new file +10 -0
+#define CONFIG_SYS_NAND_U_BOOT_SIZE	CONFIG_SYS_MONITOR_LEN
+/* Build image with spl and u-boot */
+#define CONFIG_NAND_U_BOOT
+#define CONFIG_SPL_PAD_TO		0xa1000000
+
+/*
+ * SPL
+ */
+#define	CONFIG_SPL
+#define	CONFIG_SPL_NO_CPU_SUPPORT_CODE

I have not understood why using CONFIG_SPL_FRAMEWORK does not work for you. You should have availbale a lot of function that you redefine in your patches.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#5 lore raw

PATCH v3 3/3 apf27: add FPGA support for the apf27 board

In reply to Philippe Reynes
---
 board/armadeus/apf27/Makefile |    3 +
 board/armadeus/apf27/apf27.c  |   16 +++
 board/armadeus/apf27/fpga.c   |  262 +++++++++++++++++++++++++++++++++++++++++
 board/armadeus/apf27/fpga.h   |   39 ++++++
 4 files changed, 320 insertions(+), 0 deletions(-)
 create mode 100644 board/armadeus/apf27/fpga.c
 create mode 100644 board/armadeus/apf27/fpga.h
board/armadeus/apf27/Makefile +3 -0
index f57f405..9d356a3 100644
@@ -29,6 +29,9 @@ LIB	= $(obj)lib$(BOARD).o
 
 ifndef	CONFIG_SPL_BUILD
 COBJS	:= apf27.o
+ifdef CONFIG_FPGA
+COBJS	+= fpga.o
+endif
 endif
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
board/armadeus/apf27/apf27.c +16 -0
index cbd09a7..e375a76 100644
@@ -30,6 +30,7 @@
 #include <asm/errno.h>
 #include "apf27.h"
 #include "crc.h"
+#include "fpga.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -310,6 +311,21 @@ misc_init_r(void)
 	struct mtd_device *dev;
 	struct part_info *part;
 
+#if defined(CONFIG_FPGA)
+	/* init and download fpga */
+	if ((autoload) && (0 == strcmp(autoload, "1"))) {
+		if (mtdparts_init() == 0)
+			if (find_dev_and_part("firmware",
+					      &dev, &pnum, &part) == 0) {
+				size = part->size;
+				if (nand_read_skip_bad(&nand_info[0],
+					part->offset, &size, firmware_buffer))
+					size = 0;
+			}
+	}
+	APF27_init_fpga(firmware_buffer, size);
+#endif
+
 	/* detect compatibility issue of environment version */
 	s = getenv("env_version");
 	if ((NULL == s) || (0 != strcmp(s, CONFIG_ENV_VERSION))) {
board/armadeus/apf27/fpga.c new file +262 -0

262 lines not on this page · raw message

board/armadeus/apf27/fpga.h new file +39 -0
new file mode 100644
index 0000000..b11b24c
@@ -0,0 +1,39 @@
+/*
+ * (C) Copyright 2002-2012
+ * Eric Jarrige <[email protected]>
+ * Rich Ireland, Enterasys Networks, rireland at enterasys.com.
+ * Keith Outwater, keith_outwater at mvis.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
+ *
+ */
+extern int APF27_init_fpga(u_char *buffer, size_t size);
+
+extern int fpga_pre_fn(int cookie);
+extern int fpga_pgm_fn(int assert_pgm, int flush, int cookie);
+extern int fpga_cs_fn(int assert_cs, int flush, int cookie);
+extern int fpga_init_fn(int cookie);
+extern int fpga_done_fn(int cookie);
+extern int fpga_clk_fn(int assert_clk, int flush, int cookie);
+extern int fpga_wr_fn(int assert_write, int flush, int cookie);
+extern int fpga_rdata_fn(unsigned char *data, int cookie);
+extern int fpga_wdata_fn(unsigned char data, int cookie);
+extern int fpga_abort_fn(int cookie);
+extern int fpga_post_fn(int cookie);
+extern int fpga_busy_fn(int cookie);
Signature · 1 line
1.7.4.4