Skip to contentSkip to conversation

arm: add Faraday A36x SoC platform support

PATCH Superseded Kuo-Jung Su 12 participants 311 messages Mar 29, 2013 – Apr 7, 2014 Page 2 of 3

Subsystems (16)
lore
Share & tools
lore
#127 lore raw

PATCH v2 1/1 video: add Faraday FTLCDC200 LCD controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTLCDC200 Color LCD controller performs translation of pixel-coded data into the required formats and timings to drive a variety of single/dual mono and color LCDs.

Depending on the LCD type and mode, the unpacked data can represent:
1. an actual true display gray or color value
2. an address to a 256 x 16 bit wide palette RAM gray or color value.

The FTLCDC200 generates 4 individual interrupts for:
1. DMA FIFO underflow
2. base address update
3. vertical status
4. bus error.

There is also a single combined interrupt that is raised when any of the individual interrupts become active.

CC Anatolij Gustschin <[email protected]>

---
Changes for v2:
- Make it a separate patch, rather then a part of Faraday A36x patch series

 drivers/video/Makefile          |    1 +
 drivers/video/ftlcdc200.c       |  134 +++++++++++++++++++++++++
 drivers/video/ftlcdc200_panel.c |  210 +++++++++++++++++++++++++++++++++++++++
 include/faraday/ftlcdc200.h     |  179 +++++++++++++++++++++++++++++++++
 include/lcd.h                   |   33 ++++++
 5 files changed, 557 insertions(+)
 create mode 100644 drivers/video/ftlcdc200.c
 create mode 100644 drivers/video/ftlcdc200_panel.c
 create mode 100644 include/faraday/ftlcdc200.h
drivers/video/Makefile +1 -0
index 53952ab..ec8df26 100644
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_EXYNOS_MIPI_DSIM) += exynos_mipi_dsi.o exynos_mipi_dsi_common.o \
 				exynos_mipi_dsi_lowlevel.o
 COBJS-$(CONFIG_EXYNOS_PWM_BL) += exynos_pwm_bl.o
 COBJS-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o videomodes.o
+COBJS-$(CONFIG_FTLCDC200) += ftlcdc200.o ftlcdc200_panel.o
 COBJS-$(CONFIG_MPC8XX_LCD) += mpc8xx_lcd.o
 COBJS-$(CONFIG_PXA_LCD) += pxa_lcd.o
 COBJS-$(CONFIG_S6E8AX0) += s6e8ax0.o
drivers/video/ftlcdc200.c new file +134 -0

134 lines not on this page · raw message

drivers/video/ftlcdc200_panel.c new file +210 -0

210 lines not on this page · raw message

include/faraday/ftlcdc200.h new file +179 -0

179 lines not on this page · raw message

include/lcd.h +33 -0
index c6e7fc5..1d9e584 100644
@@ -253,6 +253,39 @@ typedef struct vidinfo {
 
 void init_panel_info(vidinfo_t *vid);
 
+#elif defined(CONFIG_FTLCDC200)
+
+typedef struct vidinfo {
+	ushort	vl_col;		/* Number of columns (i.e. 800) */
+	ushort	vl_row;		/* Number of rows (i.e. 600) */
+
+	u_char	vl_bpix;	/* Bits per pixel, 0 = 1, 1 = 2 ... 4 = 16 */
+
+	/* Timing Parameters */
+	u_char	vl_fps;		/* Frame per second */
+
+	u_char	vl_hsw;
+	u_char	vl_hbp;
+	u_char	vl_hfp;
+
+	u_char	vl_vsw;
+	u_char	vl_vbp;
+	u_char	vl_vfp;
+
+	/* Pre-defined FTLCDC200 register values */
+	u_long	vl_enable;	/* LCDEnable */
+	u_long	vl_pixel;	/* PanelPixel */
+	u_long	vl_polarity;/* Polarity */
+	u_long	vl_serial;	/* SerialPanelPixel */
+	u_long	vl_ccir656;	/* CCIR656 */
+
+	/* Panel name */
+	char	*vl_name;
+
+	ushort	*cmap;		/* Pointer to the colormap */
+	void	*priv;		/* Pointer to driver-specific data */
+} vidinfo_t;
+
 #else
 
 typedef struct vidinfo {

--
1.7.9.5

#128 lore raw

PATCH v3 11/11 arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday A36x EVB is a Faraday SoC platform evalution board used for Faraday IP functional verification based on the well-known ARM AMBA 2.0 architecture.

Faraday A360 EVB:
CPU: FA626TE
NET: FTMAC110
USB: FUSBH200, FOTG210
LCD: FTLCDC200
I2C: FTI2C010
SPI: FTSSP010 v1.18.0
MMC: FTSDC010
RTC: FTRTC010
WDT: FTWDT010
TMR: FTTMR010
PIC: FTINTC020
UART: FTUART010
NAND: FTNANDC020

Faraday A369 EVB:
CPU: FA626TE(Master)/FA606TE(Slave)
NET: FTGMAC100
USB: FUSBH200, FOTG210
LCD: FTLCDC200
I2C: FTI2C010
SPI: FTSSP010 v1.18.0
MMC: FTSDC010
RTC: FTRTC011
WDT: FTWDT010
TMR: FTPWMTMR010
PIC: FTINTC020
UART: FTUART010
NAND: FTNANDC021

CC Albert Aribaud <[email protected]>
---
 arch/arm/cpu/faraday/Makefile             |   57 ++++
 arch/arm/cpu/faraday/a360/Makefile        |   49 +++
 arch/arm/cpu/faraday/a369/Makefile        |   50 +++
 arch/arm/cpu/faraday/a369/cmd_fa606.c     |   72 ++++
 arch/arm/cpu/faraday/cmd_bootfa.c         |  132 ++++++++
 arch/arm/cpu/faraday/config.mk            |   33 ++
 arch/arm/cpu/faraday/cpu.c                |  238 +++++++++++++
 arch/arm/cpu/faraday/ftintc020.h          |   37 ++
 arch/arm/cpu/faraday/ftpwmtmr010.c        |  156 +++++++++
 arch/arm/cpu/faraday/ftpwmtmr010.h        |   41 +++
 arch/arm/cpu/faraday/fttmr010.c           |  156 +++++++++
 arch/arm/cpu/faraday/fwimage.h            |   38 +++
 arch/arm/cpu/faraday/fwimage2.h           |   70 ++++
 arch/arm/cpu/faraday/interrupts.c         |  151 +++++++++
 arch/arm/cpu/faraday/reset.c              |   38 +++
 arch/arm/cpu/faraday/start.S              |  523 +++++++++++++++++++++++++++++
 arch/arm/cpu/u-boot.lds                   |   11 +
 arch/arm/include/asm/arch-a360/hardware.h |   73 ++++
 arch/arm/include/asm/arch-a360/pmu.h      |   39 +++
 arch/arm/include/asm/arch-a360/scu.h      |   27 ++
 arch/arm/include/asm/arch-a369/hardware.h |   88 +++++
 arch/arm/include/asm/arch-a369/scu.h      |   48 +++
 arch/arm/include/asm/mach-types.h         |    1 +
 board/faraday/a360evb/Makefile            |   49 +++
 board/faraday/a360evb/board.c             |   65 ++++
 board/faraday/a360evb/clk.c               |   57 ++++
 board/faraday/a360evb/config.mk           |   33 ++
 board/faraday/a360evb/lowlevel_init.S     |   33 ++
 board/faraday/a369evb/Makefile            |   49 +++
 board/faraday/a369evb/board.c             |  188 +++++++++++
 board/faraday/a369evb/clk.c               |   72 ++++
 board/faraday/a369evb/config.mk           |   33 ++
 board/faraday/a369evb/lowlevel_init.S     |  136 ++++++++
 boards.cfg                                |    3 +
 include/common.h                          |   13 +
 include/configs/a360.h                    |   63 ++++
 include/configs/a369-common.h             |   74 ++++
 include/configs/a369.h                    |   33 ++
 include/configs/a369_fa606te.h            |   26 ++
 include/configs/a36x-common.h             |  303 +++++++++++++++++
 include/faraday/fttmr010.h                |   17 +
 41 files changed, 3375 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/ftintc020.h
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.h
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
 create mode 100644 arch/arm/cpu/faraday/interrupts.c
 create mode 100644 arch/arm/cpu/faraday/reset.c
 create mode 100644 arch/arm/cpu/faraday/start.S
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a360/pmu.h
 create mode 100644 arch/arm/include/asm/arch-a360/scu.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/scu.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clk.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clk.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369-common.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_fa606te.h
 create mode 100644 include/configs/a36x-common.h
arch/arm/cpu/faraday/Makefile new file +57 -0
new file mode 100644
index 0000000..b6d55b8
@@ -0,0 +1,57 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+src-y						:= interrupts.o reset.o
+src-$(CONFIG_FTPWMTMR010)	+= ftpwmtmr010.o
+src-$(CONFIG_FTTMR010)		+= fttmr010.o
+
+START	= start.o
+COBJS	= cpu.o cmd_bootfa.o $(src-y)
+
+ifdef	CONFIG_SPL_BUILD
+ifdef	CONFIG_SPL_NO_CPU_SUPPORT_CODE
+START	:=
+endif
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/faraday/a360/Makefile new file +49 -0

49 lines not on this page · raw message

arch/arm/cpu/faraday/a369/Makefile new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/faraday/a369/cmd_fa606.c new file +72 -0

72 lines not on this page · raw message

arch/arm/cpu/faraday/cmd_bootfa.c new file +132 -0

132 lines not on this page · raw message

arch/arm/cpu/faraday/config.mk new file +33 -0
new file mode 100644
index 0000000..f03030a
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2002
+# Gary Jennejohn, DENX Software Engineering, <[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
+#
+
+PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
+
+PLATFORM_CPPFLAGS += -march=armv4
+# =========================================================================
+#
+# Supply options according to compiler version
+#
+# =========================================================================
+PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
+PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)
arch/arm/cpu/faraday/cpu.c new file +238 -0

238 lines not on this page · raw message

arch/arm/cpu/faraday/ftintc020.h new file +37 -0
new file mode 100644
index 0000000..e23d1e7
@@ -0,0 +1,37 @@
+/*
+ * arch/arm/cpu/faraday/ftintc020.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FTINTC020_H
+#define ARCH_ARM_CPU_FARADAY_FTINTC020_H
+
+struct ftintc020_pic_regs {
+	uint32_t src; /* source register */
+	uint32_t ena; /* enable register */
+	uint32_t scr; /* status clear register */
+	uint32_t tmr; /* trigger mode register */
+	uint32_t tlr; /* trigger level register */
+	uint32_t sr;  /* status register */
+	uint32_t rsvd[2];
+};
+
+struct ftintc020_regs {
+	/* IRQ/FIQ:  0 ~ 31 */
+	struct ftintc020_pic_regs irq32; /* 0x00 - 0x1C: IRQ 0 ~ 31 */
+	struct ftintc020_pic_regs fiq32; /* 0x20 - 0x3C: FIQ 0 ~ 31 */
+	uint32_t rsvd1[4];               /* 0x40 - 0x4C: Reserved */
+	uint32_t revision;               /* 0x50: Revision Register */
+	uint32_t feature;                /* 0x54: Feature Register */
+	uint32_t rsvd2[2];               /* 0x58 - 0x5C: Reserved */
+	/* IRQ/FIQ: 32 ~ 63 */
+	struct ftintc020_pic_regs irq64; /* 0x60 - 0x7C: IRQ 32 ~ 63 */
+	struct ftintc020_pic_regs fiq64; /* 0x80 - 0x9C: FIQ 32 ~ 63 */
+};
+
+#endif
arch/arm/cpu/faraday/ftpwmtmr010.c new file +156 -0

156 lines not on this page · raw message

arch/arm/cpu/faraday/ftpwmtmr010.h new file +41 -0

41 lines not on this page · raw message

arch/arm/cpu/faraday/fttmr010.c new file +156 -0

156 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage.h new file +38 -0
new file mode 100644
index 0000000..af4f2f9
@@ -0,0 +1,38 @@
+/*
+ * arch/arm/cpu/faraday/fwimage.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FWIMAGE_H
+#define ARCH_ARM_CPU_FARADAY_FWIMAGE_H
+
+struct fwparam {
+	uint32_t	count;
+	uint32_t	version; /* ycmo100525: for firmware image version */
+	uint32_t	addr[31];
+	uint32_t	data[31];
+};
+
+struct fwfile {
+	char		name[64];
+	uint32_t	size;
+	/* uint32_t	block[1]; */
+};
+
+struct fwimage {
+	/* 8 bytes */
+	uint32_t		magic;	/* Magic number */
+	uint32_t		length;	/* It shall not be greater than 2048 */
+
+	/* 256 bytes, embedded paramters area */
+	struct fwparam	param;
+
+	struct fwfile	file[1];
+};
+
+#endif
arch/arm/cpu/faraday/fwimage2.h new file +70 -0

70 lines not on this page · raw message

arch/arm/cpu/faraday/interrupts.c new file +151 -0

151 lines not on this page · raw message

arch/arm/cpu/faraday/reset.c new file +38 -0
new file mode 100644
index 0000000..80afabb
@@ -0,0 +1,38 @@
+/*
+ * arch/arm/cpu/faraday/reset.c
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <faraday/ftwdt010_wdt.h>
+
+void reset_cpu(unsigned long ignored)
+{
+#ifdef CONFIG_FTWDT010_BASE
+	struct ftwdt010_wdt __iomem *regs =
+		(struct ftwdt010_wdt __iomem *)CONFIG_FTWDT010_BASE;
+
+	/* Disable WDT */
+	writel(0, &regs->wdcr);
+	/* Timeout in 1000 ticks */
+	writel(1000, &regs->wdload);
+	/* Enable WDT with System Reset Function */
+	writel(FTWDT010_WDCR_ENABLE | FTWDT010_WDCR_RST, &regs->wdcr);
+	/* Kick it to make sure it's in running state */
+	writel(FTWDT010_WDRESTART_MAGIC, &regs->wdrestart);
+#else
+	uint32_t start = CONFIG_SYS_TEXT_BASE;
+
+	__asm__ __volatile__ (
+		"mov pc, %0\n"
+		: /* output */
+		: "r"(start) /* input */
+	);
+#endif
+}
arch/arm/cpu/faraday/start.S new file +523 -0

523 lines not on this page · raw message

arch/arm/cpu/u-boot.lds +11 -0
index d9bbee3..ac59fec 100644
@@ -23,6 +23,8 @@
  * MA 02111-1307 USA
  */
 
+#include <config.h>
+
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -35,6 +37,15 @@ SECTIONS
 	{
 		__image_copy_start = .;
 		CPUDIR/start.o (.text*)
+#ifdef CONFIG_FARADAY
+		/*
+		 * Dante Su 2012.10.09:
+		 * Reserved for the faimage v2.1.
+		 * 1. CPUDIR/start.o: It shall never be > 4KB.
+		 * 2. faimage header: It shall always be stored at 0x1000, and <= 1KB.
+		 */
+		. = 0x00001400;
+#endif
 		*(.text*)
 	}
 
arch/arm/include/asm/arch-a360/hardware.h new file +73 -0

73 lines not on this page · raw message

arch/arm/include/asm/arch-a360/pmu.h new file +39 -0
new file mode 100644
index 0000000..51b9391
@@ -0,0 +1,39 @@
+/*
+ * asm/arch-a360/pmu.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef __ASM_ARCH_PMU_H
+#define __ASM_ARCH_PMU_H
+
+struct a360pmu_regs {
+	uint32_t idr;      /* ID register */
+	uint32_t rsvd0;
+	uint32_t osccr;    /* OSC control register */
+	uint32_t pmr;      /* Power mode register */
+
+	uint32_t pmcr;     /* Power manager control register */
+	uint32_t peer;     /* Power manager edge detect enable register */
+	uint32_t pesr;     /* Power manager edge detect status register */
+	uint32_t rsvd1;
+
+	uint32_t pmsr;     /* Power manager status register */
+	uint32_t pgsr;     /* Power manager GPIO sleep state register */
+	uint32_t rsvd2;
+	uint32_t mcr;      /* Misc. control register */
+
+	uint32_t pdcr;     /* PLL/DLL control register */
+	uint32_t rsvd3[7];
+
+	uint32_t pspr[16]; /* Power manager scratch pad register */
+
+	uint32_t rsvd4[3];
+	uint32_t jssr;     /* Jumper setting status register */
+};
+
+#endif
arch/arm/include/asm/arch-a360/scu.h new file +27 -0
new file mode 100644
index 0000000..6fbd1b8
@@ -0,0 +1,27 @@
+/*
+ * asm/arch-a360/scu.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef __ASM_ARCH_SCU_H
+#define __ASM_ARCH_SCU_H
+
+struct a360scu_regs {
+	uint32_t idr;      /* 0x00: ID Register */
+	uint32_t gcr;      /* 0x04: General Control Register */
+	uint32_t ccr;      /* 0x08: Clock Configuration Register */
+	uint32_t hcer;     /* 0x0C: AHB Clock Enable Register */
+	uint32_t pcer;     /* 0x10: APB Clock Enable Register */
+	uint32_t csr;      /* 0x14: Configuration Strap Register */
+	uint32_t iomcr[4]; /* IO Mux Control Register */
+	uint32_t iopcr[2]; /* IO Parameter Control Register */
+	uint32_t cescr;    /* CPU Edge Sync Control Register */
+	uint32_t expcr[3]; /* PCI-Express Control Register */
+};
+
+#endif
arch/arm/include/asm/arch-a369/hardware.h new file +88 -0

88 lines not on this page · raw message

arch/arm/include/asm/arch-a369/scu.h new file +48 -0

48 lines not on this page · raw message

arch/arm/include/asm/mach-types.h +1 -0
index 440b041..a103922 100644
@@ -144,6 +144,7 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_AKITA                744
 #define MACH_TYPE_E330                 753
 #define MACH_TYPE_NOKIA770             755
+#define MACH_TYPE_FARADAY              758
 #define MACH_TYPE_CARMEVA              769
 #define MACH_TYPE_EDB9315A             772
 #define MACH_TYPE_STARGATE2            774
board/faraday/a360evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a360evb/board.c new file +65 -0

65 lines not on this page · raw message

board/faraday/a360evb/clk.c new file +57 -0

57 lines not on this page · raw message

board/faraday/a360evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a360evb/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000..1ead608
@@ -0,0 +1,33 @@
+/*
+ * Board specific setup info
+ *
+ * (C) Copyright 2010
+ * Faraday Technology Inc. <www.faraday-tech.com>
+ * Dante Su <[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 <version.h>
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+	mov	pc,lr
board/faraday/a369evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a369evb/board.c new file +188 -0

188 lines not on this page · raw message

board/faraday/a369evb/clk.c new file +72 -0

72 lines not on this page · raw message

board/faraday/a369evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a369evb/lowlevel_init.S new file +136 -0

136 lines not on this page · raw message

boards.cfg +3 -0
index 8b7933f..941f158 100644
@@ -73,6 +73,9 @@ mini2440                     arm         arm920t     mini2440            friendl
 VCMA9                        arm         arm920t     vcma9               mpl            s3c24x0
 smdk2410                     arm         arm920t     -                   samsung        s3c24x0
 omap1510inn                  arm         arm925t     -                   ti
+a360                         arm         faraday     a360evb             faraday        a360
+a369                         arm         faraday     a369evb             faraday        a369
+a369_fa606te                 arm         faraday     a369evb             faraday        a369
 integratorap_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorap:CM926EJ_S
 integratorcp_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorcp:CM924EJ_S
 aspenite                     arm         arm926ejs   -                   Marvell        armada100
include/common.h +13 -0
index 0cfa6a8..fa134f3 100644
@@ -112,6 +112,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_SOC_DA8XX
 #include <asm/arch/hardware.h>
 #endif
+#ifdef CONFIG_FARADAY
+#include <asm/arch/hardware.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
@@ -257,6 +260,16 @@ typedef void (interrupt_handler_t)(void *);
 	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
+#ifdef CONFIG_FARADAY
+/* board/faraday/xxx/clk.c */
+extern ulong clk_get_rate(char *id);
+
+/* arch/arm/cpu/faraday/xxx/interrupt.c */
+extern void irq_set_trigger(int irq, int edge, int low);
+extern void irq_enable(int irq);
+extern void irq_disable(int irq);
+#endif
+
 /*
  * Function Prototypes
  */
include/configs/a360.h new file +63 -0

63 lines not on this page · raw message

include/configs/a369-common.h new file +74 -0

42 lines not on this page · raw message

include/configs/a369.h new file +33 -0
new file mode 100644
index 0000000..40e6b60

Lines of this file are not shown. View the raw message.

include/configs/a369_fa606te.h new file +26 -0
new file mode 100644
index 0000000..9fb1b0a

Lines of this file are not shown. View the raw message.

include/configs/a36x-common.h new file +303 -0

303 lines not on this page · raw message

include/faraday/fttmr010.h +17 -0
index 72abcb3..ef10f31 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.9.5

Part of the diff is not shown here. View the raw message.

#129 lore raw

v3 cover arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su
Quoted 53 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

To: u-boot at lists.denx.de
CC: Albert Aribaud <[email protected]>

These patches introduce Faraday A36x SoC platform support.

Here are some public documents for your reference.

http://www.faraday-tech.com/html/documentation/index.html

There is also a A369 QEMU emulator available at my github account:

    https://github.com/dantesu1218/qemu.git

Here is quick start for QEMU:

1. Download the QEMU source tree

    $ git clone -b qemu-1.3.0 https://github.com/dantesu1218/qemu.git

2. Build & Install the QEMU:

    $ ./configure --target-list=arm-softmmu
    $ make
    $ make install

3. Launch u-boot with QEMU:

    $ qemu-system-arm -M a369 -m 512M -nographic -kernel ~/u-boot-devel/u-boot

Changes for v3:
- Coding Style cleanup.
There is still one warnning reported by checkpatch.pl, however it's too deep for me to fix it.
Here is the shapshot for it:
-----------------------------------------------------
WARNING: do not add new typedefs
#9735: FILE: include/lcd.h:258:
+typedef struct vidinfo {
-----------------------------------------------------
- Drop bit fields from c struct.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- cmd_boot.c: Make it a separate stand-alone patch.
- ftspi020: Make it a separate stand-alone patch.
- dma-mapping.h: Have the global data ptr declared outside functions.
- dma-mapping.h: Add #if...#else...#endif to dma_free_coherent().
- MMU/D-Cache: Drop static non-cached region, now we use map_physmem()/unmap_physmem() for dynamic mappings.
- ftmac110: Make a correction to multi-line comment style

Quoted 8 lines

- ftmac110: Use random MAC address while having trouble to get one from environment variables.
- ftmac110: Add comments to timing control registers.
- ftnandc021: Re-write this driver with ECC enabled and correct column address handling for OOB read/write, and fixing issused addressed by Scott.
- a36x_config: No more static global network configurations.
- a36x_config: Add a common file for the redundant configurations.

I see a few:
/* --------------------
* Comment
*/
in various places, and I pointed it out in the net changes, but I also saw in the SPI block '100' being used as a timeout, rather than defined. Please give everything a check for magic numbers and direct numbers used as timeout, rather than a #define.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130502/303fab73/attachment.pgp>
#130 lore raw

v3 cover arm: add Faraday A36x SoC platform support

2013/5/3 Tom Rini <[email protected]>:

Quoted 64 lines · Kuo-Jung Su
Quoted 54 lines

From: Kuo-Jung Su <[email protected]>

To: u-boot at lists.denx.de
CC: Albert Aribaud <[email protected]>

These patches introduce Faraday A36x SoC platform support.

Here are some public documents for your reference.

http://www.faraday-tech.com/html/documentation/index.html

There is also a A369 QEMU emulator available at my github account:

    https://github.com/dantesu1218/qemu.git

Here is quick start for QEMU:

1. Download the QEMU source tree

    $ git clone -b qemu-1.3.0 https://github.com/dantesu1218/qemu.git

2. Build & Install the QEMU:

    $ ./configure --target-list=arm-softmmu
    $ make
    $ make install

3. Launch u-boot with QEMU:

    $ qemu-system-arm -M a369 -m 512M -nographic -kernel ~/u-boot-devel/u-boot

Changes for v3:
- Coding Style cleanup.
There is still one warnning reported by checkpatch.pl, however it's too deep for me to fix it.
Here is the shapshot for it:
-----------------------------------------------------
WARNING: do not add new typedefs
#9735: FILE: include/lcd.h:258:
+typedef struct vidinfo {
-----------------------------------------------------
- Drop bit fields from c struct.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- cmd_boot.c: Make it a separate stand-alone patch.
- ftspi020: Make it a separate stand-alone patch.
- dma-mapping.h: Have the global data ptr declared outside functions.
- dma-mapping.h: Add #if...#else...#endif to dma_free_coherent().
- MMU/D-Cache: Drop static non-cached region, now we use map_physmem()/unmap_physmem() for dynamic mappings.
- ftmac110: Make a correction to multi-line comment style

Quoted 8 lines

- ftmac110: Use random MAC address while having trouble to get one from environment variables.
- ftmac110: Add comments to timing control registers.
- ftnandc021: Re-write this driver with ECC enabled and correct column address handling for OOB read/write, and fixing issused addressed by Scott.
- a36x_config: No more static global network configurations.
- a36x_config: Add a common file for the redundant configurations.

Quoted 4 lines

I see a few:
/* --------------------
* Comment
*/

It's used in ftssp010_spi.c only, and it would be removed later.

Quoted 5 lines

in various places, and I pointed it out in the net changes, but I also saw in the SPI block '100' being used as a timeout, rather than defined. Please give everything a check for magic numbers and direct numbers used as timeout, rather than a #define.

Got it, thanks

Quoted 2 lines

--
Tom

--
Best wishes,
Kuo-Jung Su

#131 lore raw

PATCH v2 2/12 net: ftgmac100: add MMU/D-cache support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Joe Hershberger <[email protected]>
---
 drivers/net/ftgmac100.c |   70 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 21 deletions(-)
drivers/net/ftgmac100.c +49 -21
index 69ba57d..2dbb328 100644
@@ -27,11 +27,13 @@
 #include <malloc.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/dma-mapping.h>
 #include <linux/mii.h>
 
 #include "ftgmac100.h"
 
 #define ETH_ZLEN	60
+#define CFG_XBUF_SIZE	1536
 
 /* RBSR - hw default init value is also 0x640 */
 #define RBSR_DEFAULT_VALUE	0x640
@@ -40,8 +42,10 @@
 #define PKTBUFSTX	4	/* must be power of 2 */
 
 struct ftgmac100_data {
-	struct ftgmac100_txdes txdes[PKTBUFSTX];
-	struct ftgmac100_rxdes rxdes[PKTBUFSRX];
+	ulong txdes_dma;
+	struct ftgmac100_txdes *txdes;
+	ulong rxdes_dma;
+	struct ftgmac100_rxdes *rxdes;
 	int tx_index;
 	int rx_index;
 	int phy_addr;
@@ -375,13 +379,34 @@ static int ftgmac100_init(struct eth_device *dev, bd_t *bd)
 {
 	struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
 	struct ftgmac100_data *priv = dev->priv;
-	struct ftgmac100_txdes *txdes = priv->txdes;
-	struct ftgmac100_rxdes *rxdes = priv->rxdes;
+	struct ftgmac100_txdes *txdes;
+	struct ftgmac100_rxdes *rxdes;
 	unsigned int maccr;
+	void *buf;
 	int i;
 
 	debug("%s()\n", __func__);
 
+	if (!priv->txdes) {
+		txdes = dma_alloc_coherent(
+			sizeof(*txdes) * PKTBUFSTX, &priv->txdes_dma);
+		if (!txdes)
+			panic("ftgmac100: out of memory\n");
+		memset(txdes, 0, sizeof(*txdes) * PKTBUFSTX);
+		priv->txdes = txdes;
+	}
+	txdes = priv->txdes;
+
+	if (!priv->rxdes) {
+		rxdes = dma_alloc_coherent(
+			sizeof(*rxdes) * PKTBUFSRX, &priv->rxdes_dma);
+		if (!rxdes)
+			panic("ftgmac100: out of memory\n");
+		memset(rxdes, 0, sizeof(*rxdes) * PKTBUFSRX);
+		priv->rxdes = rxdes;
+	}
+	rxdes = priv->rxdes;
+
 	/* set the ethernet address */
 	ftgmac100_set_mac_from_env(dev);
 
@@ -397,21 +422,31 @@ static int ftgmac100_init(struct eth_device *dev, bd_t *bd)
 
 	for (i = 0; i < PKTBUFSTX; i++) {
 		/* TXBUF_BADR */
-		txdes[i].txdes3 = 0;
+		if (!txdes[i].txdes2) {
+			buf = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE);
+			if (!buf)
+				panic("ftgmac100: out of memory\n");
+			txdes[i].txdes3 = virt_to_phys(buf);
+			txdes[i].txdes2 = (uint)buf;
+		}
 		txdes[i].txdes1 = 0;
 	}
 
 	for (i = 0; i < PKTBUFSRX; i++) {
 		/* RXBUF_BADR */
-		rxdes[i].rxdes3 = (unsigned int)NetRxPackets[i];
+		if (!rxdes[i].rxdes2) {
+			buf = NetRxPackets[i];
+			rxdes[i].rxdes3 = virt_to_phys(buf);
+			rxdes[i].rxdes2 = (uint)buf;
+		}
 		rxdes[i].rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY;
 	}
 
 	/* transmit ring */
-	writel((unsigned int)txdes, &ftgmac100->txr_badr);
+	writel(priv->txdes_dma, &ftgmac100->txr_badr);
 
 	/* receive ring */
-	writel((unsigned int)rxdes, &ftgmac100->rxr_badr);
+	writel(priv->rxdes_dma, &ftgmac100->rxr_badr);
 
 	/* poll receive descriptor automatically */
 	writel(FTGMAC100_APTC_RXPOLL_CNT(1), &ftgmac100->aptc);
@@ -466,8 +501,11 @@ static int ftgmac100_recv(struct eth_device *dev)
 	debug("%s(): RX buffer %d, %x received\n",
 	       __func__, priv->rx_index, rxlen);
 
+	/* invalidate d-cache */
+	dma_map_single((void *)curr_des->rxdes2, rxlen, DMA_FROM_DEVICE);
+
 	/* pass the packet up to the protocol layers. */
-	NetReceive((void *)curr_des->rxdes3, rxlen);
+	NetReceive((void *)curr_des->rxdes2, rxlen);
 
 	/* release buffer to DMA */
 	curr_des->rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY;
@@ -485,7 +523,6 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 	struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
 	struct ftgmac100_data *priv = dev->priv;
 	struct ftgmac100_txdes *curr_des = &priv->txdes[priv->tx_index];
-	int start;
 
 	if (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) {
 		debug("%s(): no TX descriptor available\n", __func__);
@@ -496,8 +533,8 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 
 	length = (length < ETH_ZLEN) ? ETH_ZLEN : length;
 
-	/* initiate a transmit sequence */
-	curr_des->txdes3 = (unsigned int)packet;	/* TXBUF_BADR */
+	memcpy((void *)curr_des->txdes2, (void *)packet, length);
+	dma_map_single((void *)curr_des->txdes2, length, DMA_TO_DEVICE);
 
 	/* only one descriptor on TXBUF */
 	curr_des->txdes0 &= FTGMAC100_TXDES0_EDOTR;
@@ -509,15 +546,6 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 	/* start transmit */
 	writel(1, &ftgmac100->txpd);
 
-	/* wait for transfer to succeed */
-	start = get_timer(0);
-	while (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) {
-		if (get_timer(0) >= 5) {
-			debug("%s(): timed out\n", __func__);
-			return -1;
-		}
-	}
-
 	debug("%s(): packet sent\n", __func__);
 
 	priv->tx_index = (priv->tx_index + 1) % PKTBUFSTX;

--
1.7.9.5

#132 lore raw

PATCH v2 3/12 net: add Faraday FTMAC110 10/100Mbps ethernet support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTMAC110 10/100Mbps supports half-word data transfer for Linux. However it has a weird DMA alignment issue:

(1) Tx DMA Buffer Address:
1 bytes aligned: Invalid
2 bytes aligned: O.K
4 bytes aligned: O.K

(2) Rx DMA Buffer Address:
1 bytes aligned: Invalid
2 bytes aligned: O.K
4 bytes aligned: Invalid!!!

CC Joe Hershberger <[email protected]>
---
 drivers/net/Makefile   |    1 +
 drivers/net/ftmac110.c |  452 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftmac110.h |  159 +++++++++++++++++
 include/netdev.h       |    1 +
 4 files changed, 613 insertions(+)
 create mode 100644 drivers/net/ftmac110.c
 create mode 100644 drivers/net/ftmac110.h
drivers/net/Makefile +1 -0
index 786a656..0e23817 100644
@@ -46,6 +46,7 @@ COBJS-$(CONFIG_ETHOC) += ethoc.o
 COBJS-$(CONFIG_FEC_MXC) += fec_mxc.o
 COBJS-$(CONFIG_FSLDMAFEC) += fsl_mcdmafec.o mcfmii.o
 COBJS-$(CONFIG_FTGMAC100) += ftgmac100.o
+COBJS-$(CONFIG_FTMAC110) += ftmac110.o
 COBJS-$(CONFIG_FTMAC100) += ftmac100.o
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
drivers/net/ftmac110.c new file +452 -0

452 lines not on this page · raw message

drivers/net/ftmac110.h new file +159 -0

159 lines not on this page · raw message

include/netdev.h +1 -0
index fd3e243..48c2fe5 100644
@@ -67,6 +67,7 @@ int fecmxc_initialize(bd_t *bis);
 int fecmxc_initialize_multi(bd_t *bis, int dev_id, int phy_id, uint32_t addr);
 int ftgmac100_initialize(bd_t *bits);
 int ftmac100_initialize(bd_t *bits);
+int ftmac110_initialize(bd_t *bits);
 int greth_initialize(bd_t *bis);
 void gt6426x_eth_initialize(bd_t *bis);
 int inca_switch_initialize(bd_t *bis);

--
1.7.9.5

#133 lore raw

PATCH v2 3/12 net: add Faraday FTMAC110 10/100Mbps ethernet support

Dear Kuo-Jung Su,

Quoted 8 lines · In message <[email protected]> you wrote:
drivers/net/ftmac110.c new file +7 -0
+/*******************************************************************/
+/*               FTMAC110 DMA design issue                         */
+/*                                             Dante Su 2010.02.03 */
+/*                                                                 */
+/* The DMA engine has a weird restriction that its Rx DMA engine   */
+/* accepts only 16-bits aligned address, 32-bits aligned is not    */
+/* acceptable. However this restriction does not apply to Tx DMA.  */

drivers/net/ftmac110.c line 44

Quoted 10 lines
drivers/net/ftmac110.c new file +10 -0
+/* Conclusion:                                                     */
+/* (1) Tx DMA Buffer Address:                                      */
+/*     1 bytes aligned: Invalid                                    */
+/*     2 bytes aligned: O.K                                        */
+/*     4 bytes aligned: O.K (-> u-boot ZeroCopy is possible)       */
+/* (2) Rx DMA Buffer Address:                                      */
+/*     1 bytes aligned: Invalid                                    */
+/*     2 bytes aligned: O.K                                        */
+/*     4 bytes aligned: Invalid                                    */
+/*******************************************************************/

Incorrect multi-line comment style. Please fix globally.

drivers/net/ftmac110.c line 64

Quoted 3 lines
drivers/net/ftmac110.c new file +3 -0
+/* Register access macros */
+#define MAC_READ(r)			le32_to_cpu(readl(r))
+#define MAC_WRITE(v, r)		writel(cpu_to_le32(v), r)

Please drop these and use the real functions instead.

Quoted 1 line

+static char ftmac110_mac_addr[] = { 0x00, 0x41, 0x71, 0x00, 0x00, 0x52 };

NAK. We do not allow static configuration of MAC addresses.

drivers/net/ftmac110.c line 115

Quoted 3 lines
drivers/net/ftmac110.c new file +3 -0
+	ulong ts;
+	uint32_t maccr;
+	uint16_t pa, tmp;

Are you sure using uint16_t gives more efficient code than a plain int?

drivers/net/ftmac110.c line 128

Quoted 2 lines
drivers/net/ftmac110.c new file +2 -0
+	if (pa >= 32) {
+		puts("ftmac110: phy device not found!\n");

make this a debug() ?

...

drivers/net/ftmac110.c line 227

Quoted 4 lines
drivers/net/ftmac110.c new file +4 -0
+	MAC_WRITE(0x00001010, &regs->itc);
+	MAC_WRITE(0x00000001, &regs->aptc);
+	MAC_WRITE(0x00000390, &regs->dblac);
+	MAC_WRITE(0x000003FF, &regs->isr);

What do these magic numbers mean?

Quoted 15 lines
drivers/net/ftmac110.h new file +15 -0
+struct ftmac110_rxd {
+	/* RXDES0 */
+#ifdef __ARMEB__
+	uint32_t owner:1; /* BIT: 31 - 1:Hardware, 0: Software */
+	uint32_t rsvd3:1;
+	uint32_t frs:1;
+	uint32_t lrs:1;
+	uint32_t rsvd2:5;
+	uint32_t error:5;
+	uint32_t bcast:1;
+	uint32_t mcast:1;
+	uint32_t rsvd1:5;
+	uint32_t len:11;
+#else
+	uint32_t len:11;

drivers/net/ftmac110.h line 101

Quoted 10 lines
drivers/net/ftmac110.h new file +10 -0
+	uint32_t rsvd1:5;
+	uint32_t mcast:1;
+	uint32_t bcast:1;
+	uint32_t error:5;
+	uint32_t rsvd2:5;
+	uint32_t lrs:1;
+	uint32_t frs:1;
+	uint32_t rsvd3:1;
+	uint32_t owner:1; /* BIT: 31 - 1:Hardware, 0: Software */
+#endif

NAK. Please do NOT use bit fields. They are non-portable and dangerous.

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A year spent in artificial intelligence is enough to make one believe
in God.
#134 lore raw

PATCH v2 3/12 net: add Faraday FTMAC110 10/100Mbps ethernet support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 15 lines

Dear Kuo-Jung Su,

Quoted 12 lines · In message <[email protected]> you wrote:
drivers/net/ftmac110.c new file +11 -0
+/*******************************************************************/
+/*               FTMAC110 DMA design issue                         */
+/*                                             Dante Su 2010.02.03 */
+/*                                                                 */
+/* The DMA engine has a weird restriction that its Rx DMA engine   */
+/* accepts only 16-bits aligned address, 32-bits aligned is not    */
+/* acceptable. However this restriction does not apply to Tx DMA.  */
+/* Conclusion:                                                     */
+/* (1) Tx DMA Buffer Address:                                      */
+/*     1 bytes aligned: Invalid                                    */
+/*     2 bytes aligned: O.K                                        */
Quoted 9 lines

drivers/net/ftmac110.c line 44

Quoted 6 lines
drivers/net/ftmac110.c new file +6 -0
+/*     4 bytes aligned: O.K (-> u-boot ZeroCopy is possible)       */
+/* (2) Rx DMA Buffer Address:                                      */
+/*     1 bytes aligned: Invalid                                    */
+/*     2 bytes aligned: O.K                                        */
+/*     4 bytes aligned: Invalid                                    */
+/*******************************************************************/

Incorrect multi-line comment style. Please fix globally.

Got it, thanks

Quoted 6 lines

drivers/net/ftmac110.c line 64

Quoted 3 lines
drivers/net/ftmac110.c new file +3 -0
+/* Register access macros */
+#define MAC_READ(r)                  le32_to_cpu(readl(r))
+#define MAC_WRITE(v, r)              writel(cpu_to_le32(v), r)

Please drop these and use the real functions instead.

Got it, thanks.

Quoted 4 lines
Quoted 1 line

+static char ftmac110_mac_addr[] = { 0x00, 0x41, 0x71, 0x00, 0x00, 0x52 };

NAK. We do not allow static configuration of MAC addresses.

Got it, thanks.

Quoted 7 lines

drivers/net/ftmac110.c line 115

Quoted 3 lines
drivers/net/ftmac110.c new file +3 -0
+     ulong ts;
+     uint32_t maccr;
+     uint16_t pa, tmp;

Are you sure using uint16_t gives more efficient code than a plain int?

No, it won't.
It' would be fixed latter.

Quoted 6 lines

drivers/net/ftmac110.c line 128

Quoted 2 lines
drivers/net/ftmac110.c new file +2 -0
+     if (pa >= 32) {
+             puts("ftmac110: phy device not found!\n");

make this a debug() ?

...

Got it, thanks

Quoted 8 lines

drivers/net/ftmac110.c line 227

Quoted 4 lines
drivers/net/ftmac110.c new file +4 -0
+     MAC_WRITE(0x00001010, &regs->itc);
+     MAC_WRITE(0x00000001, &regs->aptc);
+     MAC_WRITE(0x00000390, &regs->dblac);
+     MAC_WRITE(0x000003FF, &regs->isr);

What do these magic numbers mean?

Got it, thanks.
I'll add comments to these timing control registers

Quoted 20 lines
Quoted 20 lines
drivers/net/ftmac110.h new file +20 -0
+struct ftmac110_rxd {
+     /* RXDES0 */
+#ifdef __ARMEB__
+     uint32_t owner:1; /* BIT: 31 - 1:Hardware, 0: Software */
+     uint32_t rsvd3:1;
+     uint32_t frs:1;
+     uint32_t lrs:1;
+     uint32_t rsvd2:5;
+     uint32_t error:5;
+     uint32_t bcast:1;
+     uint32_t mcast:1;
+     uint32_t rsvd1:5;
+     uint32_t len:11;
+#else
+     uint32_t len:11;
+     uint32_t rsvd1:5;
+     uint32_t mcast:1;
+     uint32_t bcast:1;
+     uint32_t error:5;
+     uint32_t rsvd2:5;
Quoted 10 lines

drivers/net/ftmac110.h line 101

Quoted 5 lines
drivers/net/ftmac110.h new file +5 -0
+     uint32_t lrs:1;
+     uint32_t frs:1;
+     uint32_t rsvd3:1;
+     uint32_t owner:1; /* BIT: 31 - 1:Hardware, 0: Software */
+#endif

NAK. Please do NOT use bit fields. They are non-portable and dangerous.

Got it, thanks

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A year spent in artificial intelligence is enough to make one believe in God.

--
Best wishes,
Kuo-Jung Su

#135 lore raw

PATCH v2 4/12 i2c: add Faraday FTI2C010 I2C controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTI2C010 is a multi-function I2C controller which supports both master and slave mode. This patch simplily implements the master mode only.

CC Heiko Schocher <[email protected]>
---
 drivers/i2c/Makefile   |    1 +
 drivers/i2c/fti2c010.c |  363 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/fti2c010.h |   71 ++++++++++
 3 files changed, 435 insertions(+)
 create mode 100644 drivers/i2c/fti2c010.c
 create mode 100644 drivers/i2c/fti2c010.h
drivers/i2c/Makefile +1 -0
index 5dbdbe3..ed2b8c0 100644
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o
 COBJS-$(CONFIG_DW_I2C) += designware_i2c.o
 COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
+COBJS-$(CONFIG_FTI2C010) += fti2c010.o
 COBJS-$(CONFIG_I2C_MVTWSI) += mvtwsi.o
 COBJS-$(CONFIG_I2C_MV) += mv_i2c.o
 COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
drivers/i2c/fti2c010.c new file +363 -0

363 lines not on this page · raw message

drivers/i2c/fti2c010.h new file +71 -0

71 lines not on this page · raw message

--
1.7.9.5

#136 lore raw

PATCH v2 4/12 i2c: add Faraday FTI2C010 I2C controller support

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/i2c/fti2c010.c line 27

Quoted 2 lines
drivers/i2c/fti2c010.c new file +2 -0
+#define I2C_READ(r)		le32_to_cpu(readl(r))
+#define I2C_WRITE(v, r)	writel(cpu_to_le32(v), r)

Please drop these macros and use the real functions instead.

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Little known fact about Middle Earth:   The Hobbits had a very sophi-
sticated computer network!   It was a Tolkien Ring...
#137 lore raw

PATCH v2 4/12 i2c: add Faraday FTI2C010 I2C controller support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 10 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/i2c/fti2c010.c line 27

Quoted 2 lines
drivers/i2c/fti2c010.c new file +2 -0
+#define I2C_READ(r)          le32_to_cpu(readl(r))
+#define I2C_WRITE(v, r)      writel(cpu_to_le32(v), r)

Please drop these macros and use the real functions instead.

Got it, thanks

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Little known fact about Middle Earth: The Hobbits had a very sophi-
sticated computer network! It was a Tolkien Ring...

--
Best wishes,
Kuo-Jung Su

#138 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday FTSSP010 is a multi-function controller which supports I2S/SPI/SSP/AC97/SPDIF.
This patch simpily implements the SPI mode only. BTW the DMA and CS/Clock control logic has been altered since revision 1.19.0. So this patch would 1st detects the revision id of the underlying chip, and then switch to the corresponding control routines.

---
 drivers/spi/Makefile       |    1 +
 drivers/spi/ftssp010_spi.c |  337 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/ftssp010_spi.h |   86 +++++++++++
 3 files changed, 424 insertions(+)
 create mode 100644 drivers/spi/ftssp010_spi.c
 create mode 100644 drivers/spi/ftssp010_spi.h
drivers/spi/Makefile +1 -0
index d08609e..947d60e 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o
 COBJS-$(CONFIG_CF_SPI) += cf_spi.o
 COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
 COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+COBJS-$(CONFIG_FTSSP010_SPI) += ftssp010_spi.o
 COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 COBJS-$(CONFIG_ICH_SPI) +=  ich.o
 COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
drivers/spi/ftssp010_spi.c new file +337 -0

337 lines not on this page · raw message

drivers/spi/ftssp010_spi.h new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#139 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/spi/ftssp010_spi.c line 55

Quoted 5 lines
drivers/spi/ftssp010_spi.c new file +5 -0
+/* Register access macros */
+#define SPI_READ(r)			le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)		writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)	setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)	clrbits_le32(r, m)

Ad before: drop these.

drivers/spi/ftssp010_spi.c line 66

Quoted 10 lines
drivers/spi/ftssp010_spi.c new file +10 -0
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+#define SPI_GPIO_READ(p, r)	\
+	le32_to_cpu(readl((p)->gpio.iobase + (r)))
+#define SPI_GPIO_WRITE(p, v, r)	\
+	writel(cpu_to_le32(v), (p)->gpio.iobase + (r))
+#define SPI_GPIO_SETBITS(p, m, r)	\
+	setbits_le32((p)->gpio.iobase + (r), m)
+#define SPI_GPIO_CLRBITS(p, m, r)	\
+	clrbits_le32((p)->gpio.iobase + (r), m)
+#endif /* #ifdef CONFIG_FTSSP010_GPIO_BASE */

We do not allos I/O accesses throug base addrss plus offset. Please use proper C structs instead.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Sorry, but my karma just ran over your dogma.
#140 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 4 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

Quoted 8 lines

drivers/spi/ftssp010_spi.c line 55

Quoted 5 lines
drivers/spi/ftssp010_spi.c new file +5 -0
+/* Register access macros */
+#define SPI_READ(r)                  le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)              writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)    setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)    clrbits_le32(r, m)

Ad before: drop these.

Got it, thanks

Quoted 5 lines
Quoted 5 lines
drivers/spi/ftssp010_spi.c new file +5 -0
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+#define SPI_GPIO_READ(p, r)  \
+     le32_to_cpu(readl((p)->gpio.iobase + (r)))
+#define SPI_GPIO_WRITE(p, v, r)      \
+     writel(cpu_to_le32(v), (p)->gpio.iobase + (r))
Quoted 10 lines

drivers/spi/ftssp010_spi.c line 66

Quoted 5 lines
drivers/spi/ftssp010_spi.c new file +5 -0
+#define SPI_GPIO_SETBITS(p, m, r)    \
+     setbits_le32((p)->gpio.iobase + (r), m)
+#define SPI_GPIO_CLRBITS(p, m, r)    \
+     clrbits_le32((p)->gpio.iobase + (r), m)
+#endif /* #ifdef CONFIG_FTSSP010_GPIO_BASE */

We do not allos I/O accesses throug base addrss plus offset. Please use proper C structs instead.

Got it, thanks

Quoted 9 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Sorry, but my karma just ran over your dogma.

--
Best wishes,
Kuo-Jung Su

#141 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

In reply to Kuo-Jung Su

Hi Kuo-Jung Su,

Please fix the comments I sent on v4.
http://patchwork.ozlabs.org/patch/242023/

Feel free to ask for any quires.

Thanks,
Jagan.

Quoted 474 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday FTSSP010 is a multi-function controller which supports I2S/SPI/SSP/AC97/SPDIF.
This patch simpily implements the SPI mode only. BTW the DMA and CS/Clock control logic has been altered since revision 1.19.0. So this patch would 1st detects the revision id of the underlying chip, and then switch to the corresponding control routines.

---
 drivers/spi/Makefile       |    1 +
 drivers/spi/ftssp010_spi.c |  337 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/ftssp010_spi.h |   86 +++++++++++
 3 files changed, 424 insertions(+)
 create mode 100644 drivers/spi/ftssp010_spi.c
 create mode 100644 drivers/spi/ftssp010_spi.h
drivers/spi/Makefile +1 -0
index d08609e..947d60e 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o
 COBJS-$(CONFIG_CF_SPI) += cf_spi.o
 COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
 COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+COBJS-$(CONFIG_FTSSP010_SPI) += ftssp010_spi.o
 COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 COBJS-$(CONFIG_ICH_SPI) +=  ich.o
 COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
drivers/spi/ftssp010_spi.c new file +337 -0
new file mode 100644
index 0000000..4247c8c
@@ -0,0 +1,337 @@
+/*
+ * Faraday Multi-function Controller - SPI Mode
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <spi.h>
+#include <malloc.h>
+
+#include "ftssp010_spi.h"
+
+struct ftssp010_chip {
+       void    *iobase;
+       uint32_t fifo;
+       uint32_t rev;
+       uint32_t div;
+       uint32_t mode;
+
+       struct {
+               uint32_t iobase;
+               uint32_t pin;
+       } gpio;
+};
+
+static struct ftssp010_chip chip_list[] = {
+#if defined(CONFIG_FTSSP010_BASE) || defined(CONFIG_FTSSP010_BASE0)
+       {
+               .iobase = (void *)CONFIG_FTSSP010_BASE,
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               .gpio = { CONFIG_FTSSP010_GPIO_BASE, CONFIG_FTSSP010_GPIO_PIN },
+#endif
+       },
+#endif
+#ifdef CONFIG_FTSSP010_BASE1
+       { .iobase = (void *)CONFIG_FTSSP010_BASE1, },
+#endif
+#ifdef CONFIG_FTSSP010_BASE2
+       { .iobase = (void *)CONFIG_FTSSP010_BASE2, },
+#endif
+#ifdef CONFIG_FTSSP010_BASE3
+       { .iobase = (void *)CONFIG_FTSSP010_BASE3, },
+#endif
+};
+
+/* Register access macros */
+#define SPI_READ(r)                    le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)                writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)      setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)      clrbits_le32(r, m)
+
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+#define SPI_GPIO_READ(p, r)    \
+       le32_to_cpu(readl((p)->gpio.iobase + (r)))
+#define SPI_GPIO_WRITE(p, v, r)        \
+       writel(cpu_to_le32(v), (p)->gpio.iobase + (r))
+#define SPI_GPIO_SETBITS(p, m, r)      \
+       setbits_le32((p)->gpio.iobase + (r), m)
+#define SPI_GPIO_CLRBITS(p, m, r)      \
+       clrbits_le32((p)->gpio.iobase + (r), m)
+#endif /* #ifdef CONFIG_FTSSP010_GPIO_BASE */
+
+static int ftssp010_spi_work_transfer_v1_19(struct ftssp010_chip *chip,
+       const void *tx_buf, void *rx_buf, int len, uint flags)
+{
+       struct ftssp010_regs *regs = chip->iobase;
+       const uint8_t *txb = tx_buf;
+       uint8_t       *rxb = rx_buf;
+
+       while (len > 0) {
+               int i, depth = min(chip->fifo >> 2, len);
+               uint32_t xmsk = 0;
+
+               if (tx_buf) {
+                       for (i = 0; i < depth; ++i) {
+                               while (!(SPI_READ(&regs->sr) & SR_TFNF))
+                                       ;
+                               SPI_WRITE(*txb++, &regs->dr);
+                       }
+                       xmsk |= CR2_TXEN | CR2_TXDOE;
+                       if ((SPI_READ(&regs->cr[2]) & xmsk) != xmsk)
+                               SPI_SETBITS(xmsk, &regs->cr[2]);
+               }
+               if (rx_buf) {
+                       xmsk |= CR2_RXEN;
+                       if ((SPI_READ(&regs->cr[2]) & xmsk) != xmsk)
+                               SPI_SETBITS(xmsk, &regs->cr[2]);
+                       for (i = 0; i < depth; ++i) {
+                               while (!SR_RFVE(SPI_READ(&regs->sr)))
+                                       ;
+                               *rxb++ = (uint8_t)SPI_READ(&regs->dr);
+                       }
+               }
+
+               len -= depth;
+       }
+
+       return 0;
+}
+
+static int ftssp010_spi_work_transfer(struct ftssp010_chip *chip,
+       const void *tx_buf, void *rx_buf, int len, uint flags)
+{
+       struct ftssp010_regs *regs = chip->iobase;
+       const uint8_t *txb = tx_buf;
+       uint8_t       *rxb = rx_buf;
+
+       while (len > 0) {
+               int i, depth = min(chip->fifo >> 2, len);
+               uint32_t tmp;
+
+               for (i = 0; i < depth; ++i) {
+                       while (!(SPI_READ(&regs->sr) & SR_TFNF))
+                               ;
+                       SPI_WRITE(txb ? (*txb++) : 0, &regs->dr);
+               }
+               for (i = 0; i < depth; ++i) {
+                       while (!SR_RFVE(SPI_READ(&regs->sr)))
+                               ;
+                       tmp = SPI_READ(&regs->dr);
+                       if (rxb)
+                               *rxb++ = (uint8_t)tmp;
+               }
+
+               len -= depth;
+       }
+
+       return 0;
+}
+
+/*=====================================================================*/
+/*                         Public Functions                            */
+/*=====================================================================*/
+
+/*-----------------------------------------------------------------------
+ * Determine if a SPI chipselect is valid.
+ * This function is provided by the board if the low-level SPI driver
+ * needs it to determine if a given chipselect is actually valid.
+ *
+ * Returns: 1 if bus:cs identifies a valid chip on this board, 0
+ * otherwise.
+ */
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+       struct ftssp010_chip *chip;
+       struct ftssp010_regs *regs;
+       uint32_t txfifo, rxfifo;
+
+       if (bus >= ARRAY_SIZE(chip_list))
+               return 0;
+
+       chip = chip_list + bus;
+       regs = chip->iobase;
+       chip->rev = SPI_READ(&regs->revr);
+       txfifo = FEAR_TXFIFO(SPI_READ(&regs->fear));
+       rxfifo = FEAR_RXFIFO(SPI_READ(&regs->fear));
+       chip->fifo = min(txfifo, rxfifo);
+
+       printf("ftssp010: rev.=0x%08X, fifo=%d\n", chip->rev, chip->fifo);
+
+       if (chip->rev >= 0x00011900) {
+               if (cs > 3)
+                       return 0;
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               if (cs > 0)
+                       return 0;
+               /* setup gpio pin as an output pin */
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x08);
+#else
+               return 0;
+#endif
+       }
+
+       return 1;
+}
+
+/*-----------------------------------------------------------------------
+ * Activate a SPI chipselect.
+ * This function is provided by the board code when using a driver
+ * that can't control its chipselects automatically (e.g.
+ * common/soft_spi.c). When called, it should activate the chip select
+ * to the device identified by "slave".
+ */
+void spi_cs_activate(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       /* cs pull low */
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE((slave->cs << 10) | CR2_SSPEN | CR2_TXFCLR
+                       | CR2_RXFCLR, &regs->cr[2]);
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x14);
+#endif
+       }
+       udelay_masked(1);
+}
+
+/*-----------------------------------------------------------------------
+ * Deactivate a SPI chipselect.
+ * This function is provided by the board code when using a driver
+ * that can't control its chipselects automatically (e.g.
+ * common/soft_spi.c). When called, it should deactivate the chip
+ * select to the device identified by "slave".
+ */
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       /* wait until device idle */
+       while (SPI_READ(&regs->sr) & SR_BUSY)
+               ;
+
+       /* cs pull high */
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE((slave->cs << 10) | CR2_FS, &regs->cr[2]);
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x10);
+#endif
+       }
+       udelay_masked(1);
+}
+
+void spi_init(void)
+{
+}
+
+struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode)
+{
+       uint32_t clk, div;
+       struct spi_slave *ss;
+       struct ftssp010_chip *chip;
+
+       if (!spi_cs_is_valid(bus, cs))
+               return NULL;
+
+       if (mode != SPI_MODE_0) {
+               printf("ftssp010: MODE%d is not supported\n", mode);
+               return NULL;
+       }
+
+       ss = malloc(sizeof(struct spi_slave));
+       if (!ss)
+               return NULL;
+
+       ss->bus = bus;
+       ss->cs  = cs;
+
+#ifdef CONFIG_FTSSP010_SCLK
+       clk = CONFIG_FTSSP010_SCLK;
+#else
+       clk = clk_get_rate("SSP");
+#endif
+       if (max_hz > 0) {
+               for (div = 0; div < 0xFFFF; ++div) {
+                       if ((clk / (2 * (div + 1))) <= max_hz)
+                               break;
+               }
+       } else {
+               div = 7;
+       }
+
+       chip = chip_list + bus;
+       chip->div  = div;
+       chip->mode = mode;
+
+       printf("ftssp010: bus=%d, hz=%u\n", bus, (clk / (2 * (div + 1))));
+
+       return ss;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+       free(slave);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       SPI_WRITE(CR1_SDL(8) | CR1_CLKDIV(chip->div), &regs->cr[1]);
+
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE(CR0_OPM_MASTER | CR0_FFMT_SPI | CR0_FSPO | CR0_FLASH,
+                       &regs->cr[0]);
+               SPI_WRITE(CR2_TXFCLR | CR2_RXFCLR,
+                       &regs->cr[2]);
+       } else {
+               SPI_WRITE(CR0_OPM_MASTER | CR0_FFMT_SPI | CR0_FSPO,
+                       &regs->cr[0]);
+               SPI_WRITE(CR2_TXFCLR | CR2_RXFCLR | CR2_SSPEN | CR2_TXDOE,
+                       &regs->cr[2]);
+       }
+
+       spi_cs_deactivate(slave);
+
+       return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       SPI_WRITE(0, &regs->cr[2]);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+                        const void *dout, void *din, unsigned long flags)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       uint32_t len = bitlen >> 3;
+
+       if (flags & SPI_XFER_BEGIN)
+               spi_cs_activate(slave);
+
+       if (chip->rev >= 0x00011900)
+               ftssp010_spi_work_transfer_v1_19(chip, dout, din, len, flags);
+       else
+               ftssp010_spi_work_transfer(chip, dout, din, len, flags);
+
+       if (flags & SPI_XFER_END)
+               spi_cs_deactivate(slave);
+
+       return 0;
+}
drivers/spi/ftssp010_spi.h new file +86 -1
new file mode 100644
index 0000000..5ad7c47
@@ -0,0 +1,86 @@
+/*
+ * Faraday Multi-function Controller - SPI Mode
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef _FTSSP010_H
+#define _FTSSP010_H
+
+/* FTSSP010 HW Registers */
+struct ftssp010_regs {
+       uint32_t cr[3];/* control register */
+       uint32_t sr;   /* status register */
+       uint32_t icr;  /* interrupt control register */
+       uint32_t isr;  /* interrupt status register */
+       uint32_t dr;   /* data register */
+       uint32_t rsvd[17];
+       uint32_t revr; /* revision register */
+       uint32_t fear; /* feature register */
+};
+
+/* Control register 0  */
+#define CR0_FFMT_MASK       (7 << 12)
+#define CR0_FFMT_SSP        (0 << 12)
+#define CR0_FFMT_SPI        (1 << 12)
+#define CR0_FFMT_MICROWIRE  (2 << 12)
+#define CR0_FFMT_I2S        (3 << 12)
+#define CR0_FFMT_AC97       (4 << 12)
+#define CR0_FLASH           (1 << 11)
+#define CR0_FSDIST(x)       (((x) & 0x03) << 8)
+#define CR0_LBM             (1 << 7)  /* Loopback mode */
+#define CR0_LSB             (1 << 6)  /* LSB first */
+#define CR0_FSPO            (1 << 5)  /* Frame sync atcive low */
+#define CR0_FSJUSTIFY       (1 << 4)
+#define CR0_OPM_SLAVE       (0 << 2)
+#define CR0_OPM_MASTER      (3 << 2)
+#define CR0_OPM_I2S_MSST    (3 << 2)  /* Master stereo mode */
+#define CR0_OPM_I2S_MSMO    (2 << 2)  /* Master mono mode */
+#define CR0_OPM_I2S_SLST    (1 << 2)  /* Slave stereo mode */
+#define CR0_OPM_I2S_SLMO    (0 << 2)  /* Slave mono mode */
+#define CR0_SCLKPO          (1 << 1)  /* SCLK Remain HIGH */
+#define CR0_SCLKPH          (1 << 0)  /* Half CLK cycle */
+
+/* Control Register 1 */
+
+#define CR1_PDL(x)          (((x) & 0xff) << 24) /* padding length */
+#define CR1_SDL(x)          ((((x) - 1) & 0x1f) << 16) /* data length */
+#define CR1_CLKDIV(x)       ((x) & 0xffff) /*  clk divider */
+
+/* Control Register 2 */
+#define CR2_FSOS(x)         (((x) & 0x03) << 10)       /* FS/CS Select */
+#define CR2_FS              (1 << 9)   /* FS/CS Signal Level */
+#define CR2_TXEN            (1 << 8)   /* Tx Enable */
+#define CR2_RXEN            (1 << 7)   /* Rx Enable */
+#define CR2_SSPRST          (1 << 6)   /* SSP reset */
+#define CR2_TXFCLR          (1 << 3)   /* TX FIFO Clear */
+#define CR2_RXFCLR          (1 << 2)   /* RX FIFO Clear */
+#define CR2_TXDOE           (1 << 1)   /* TX Data Output Enable */
+#define CR2_SSPEN           (1 << 0)   /* SSP Enable */
+
+/*
+ * Status Register
+ */
+#define SR_RFF       (1 << 0) /* receive FIFO full */
+#define SR_TFNF      (1 << 1) /* transmit FIFO not full */
+#define SR_BUSY      (1 << 2) /* bus is busy */
+#define SR_RFVE(reg) (((reg) >> 4) & 0x1f)  /* receive  FIFO valid entries */
+#define SR_TFVE(reg) (((reg) >> 12) & 0x1f) /* transmit FIFO valid entries */
+
+/*
+ * Feature Register
+ */
+#define FEAR_WIDTH(reg)  ((((reg) >>  0) & 0xff) + 1)
+#define FEAR_RXFIFO(reg) ((((reg) >>  8) & 0xff) + 1)
+#define FEAR_TXFIFO(reg) ((((reg) >> 16) & 0xff) + 1)
+#define FEAR_AC97        (1 << 24)
+#define FEAR_I2S         (1 << 25)
+#define FEAR_SPI_MWR     (1 << 26)
+#define FEAR_SSP         (1 << 27)
+#define FEAR_SPDIF       (1 << 28)
+
+#endif
--

1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#142 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

Hi Jagan:

Thanks for the comments, but the [spi bus controller: ftssp010]

has been scheduled after the [Faraday A36x platform support] get approved.

In this way, the entire patch itself looks much better & clean.

Best Wishes

Dante Su

2013/8/8 Jagan Teki <[email protected]>:

Quoted 485 lines

Hi Kuo-Jung Su,

Please fix the comments I sent on v4.
http://patchwork.ozlabs.org/patch/242023/

Feel free to ask for any quires.

Thanks,
Jagan.

Quoted 474 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday FTSSP010 is a multi-function controller which supports I2S/SPI/SSP/AC97/SPDIF.
This patch simpily implements the SPI mode only. BTW the DMA and CS/Clock control logic has been altered since revision 1.19.0. So this patch would 1st detects the revision id of the underlying chip, and then switch to the corresponding control routines.

---
 drivers/spi/Makefile       |    1 +
 drivers/spi/ftssp010_spi.c |  337 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/ftssp010_spi.h |   86 +++++++++++
 3 files changed, 424 insertions(+)
 create mode 100644 drivers/spi/ftssp010_spi.c
 create mode 100644 drivers/spi/ftssp010_spi.h
drivers/spi/Makefile +1 -0
index d08609e..947d60e 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o
 COBJS-$(CONFIG_CF_SPI) += cf_spi.o
 COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
 COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+COBJS-$(CONFIG_FTSSP010_SPI) += ftssp010_spi.o
 COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 COBJS-$(CONFIG_ICH_SPI) +=  ich.o
 COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
drivers/spi/ftssp010_spi.c new file +337 -0
new file mode 100644
index 0000000..4247c8c
@@ -0,0 +1,337 @@
+/*
+ * Faraday Multi-function Controller - SPI Mode
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <spi.h>
+#include <malloc.h>
+
+#include "ftssp010_spi.h"
+
+struct ftssp010_chip {
+       void    *iobase;
+       uint32_t fifo;
+       uint32_t rev;
+       uint32_t div;
+       uint32_t mode;
+
+       struct {
+               uint32_t iobase;
+               uint32_t pin;
+       } gpio;
+};
+
+static struct ftssp010_chip chip_list[] = {
+#if defined(CONFIG_FTSSP010_BASE) || defined(CONFIG_FTSSP010_BASE0)
+       {
+               .iobase = (void *)CONFIG_FTSSP010_BASE,
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               .gpio = { CONFIG_FTSSP010_GPIO_BASE, CONFIG_FTSSP010_GPIO_PIN },
+#endif
+       },
+#endif
+#ifdef CONFIG_FTSSP010_BASE1
+       { .iobase = (void *)CONFIG_FTSSP010_BASE1, },
+#endif
+#ifdef CONFIG_FTSSP010_BASE2
+       { .iobase = (void *)CONFIG_FTSSP010_BASE2, },
+#endif
+#ifdef CONFIG_FTSSP010_BASE3
+       { .iobase = (void *)CONFIG_FTSSP010_BASE3, },
+#endif
+};
+
+/* Register access macros */
+#define SPI_READ(r)                    le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)                writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)      setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)      clrbits_le32(r, m)
+
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+#define SPI_GPIO_READ(p, r)    \
+       le32_to_cpu(readl((p)->gpio.iobase + (r)))
+#define SPI_GPIO_WRITE(p, v, r)        \
+       writel(cpu_to_le32(v), (p)->gpio.iobase + (r))
+#define SPI_GPIO_SETBITS(p, m, r)      \
+       setbits_le32((p)->gpio.iobase + (r), m)
+#define SPI_GPIO_CLRBITS(p, m, r)      \
+       clrbits_le32((p)->gpio.iobase + (r), m)
+#endif /* #ifdef CONFIG_FTSSP010_GPIO_BASE */
+
+static int ftssp010_spi_work_transfer_v1_19(struct ftssp010_chip *chip,
+       const void *tx_buf, void *rx_buf, int len, uint flags)
+{
+       struct ftssp010_regs *regs = chip->iobase;
+       const uint8_t *txb = tx_buf;
+       uint8_t       *rxb = rx_buf;
+
+       while (len > 0) {
+               int i, depth = min(chip->fifo >> 2, len);
+               uint32_t xmsk = 0;
+
+               if (tx_buf) {
+                       for (i = 0; i < depth; ++i) {
+                               while (!(SPI_READ(&regs->sr) & SR_TFNF))
+                                       ;
+                               SPI_WRITE(*txb++, &regs->dr);
+                       }
+                       xmsk |= CR2_TXEN | CR2_TXDOE;
+                       if ((SPI_READ(&regs->cr[2]) & xmsk) != xmsk)
+                               SPI_SETBITS(xmsk, &regs->cr[2]);
+               }
+               if (rx_buf) {
+                       xmsk |= CR2_RXEN;
+                       if ((SPI_READ(&regs->cr[2]) & xmsk) != xmsk)
+                               SPI_SETBITS(xmsk, &regs->cr[2]);
+                       for (i = 0; i < depth; ++i) {
+                               while (!SR_RFVE(SPI_READ(&regs->sr)))
+                                       ;
+                               *rxb++ = (uint8_t)SPI_READ(&regs->dr);
+                       }
+               }
+
+               len -= depth;
+       }
+
+       return 0;
+}
+
+static int ftssp010_spi_work_transfer(struct ftssp010_chip *chip,
+       const void *tx_buf, void *rx_buf, int len, uint flags)
+{
+       struct ftssp010_regs *regs = chip->iobase;
+       const uint8_t *txb = tx_buf;
+       uint8_t       *rxb = rx_buf;
+
+       while (len > 0) {
+               int i, depth = min(chip->fifo >> 2, len);
+               uint32_t tmp;
+
+               for (i = 0; i < depth; ++i) {
+                       while (!(SPI_READ(&regs->sr) & SR_TFNF))
+                               ;
+                       SPI_WRITE(txb ? (*txb++) : 0, &regs->dr);
+               }
+               for (i = 0; i < depth; ++i) {
+                       while (!SR_RFVE(SPI_READ(&regs->sr)))
+                               ;
+                       tmp = SPI_READ(&regs->dr);
+                       if (rxb)
+                               *rxb++ = (uint8_t)tmp;
+               }
+
+               len -= depth;
+       }
+
+       return 0;
+}
+
+/*=====================================================================*/
+/*                         Public Functions                            */
+/*=====================================================================*/
+
+/*-----------------------------------------------------------------------
+ * Determine if a SPI chipselect is valid.
+ * This function is provided by the board if the low-level SPI driver
+ * needs it to determine if a given chipselect is actually valid.
+ *
+ * Returns: 1 if bus:cs identifies a valid chip on this board, 0
+ * otherwise.
+ */
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+       struct ftssp010_chip *chip;
+       struct ftssp010_regs *regs;
+       uint32_t txfifo, rxfifo;
+
+       if (bus >= ARRAY_SIZE(chip_list))
+               return 0;
+
+       chip = chip_list + bus;
+       regs = chip->iobase;
+       chip->rev = SPI_READ(&regs->revr);
+       txfifo = FEAR_TXFIFO(SPI_READ(&regs->fear));
+       rxfifo = FEAR_RXFIFO(SPI_READ(&regs->fear));
+       chip->fifo = min(txfifo, rxfifo);
+
+       printf("ftssp010: rev.=0x%08X, fifo=%d\n", chip->rev, chip->fifo);
+
+       if (chip->rev >= 0x00011900) {
+               if (cs > 3)
+                       return 0;
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               if (cs > 0)
+                       return 0;
+               /* setup gpio pin as an output pin */
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x08);
+#else
+               return 0;
+#endif
+       }
+
+       return 1;
+}
+
+/*-----------------------------------------------------------------------
+ * Activate a SPI chipselect.
+ * This function is provided by the board code when using a driver
+ * that can't control its chipselects automatically (e.g.
+ * common/soft_spi.c). When called, it should activate the chip select
+ * to the device identified by "slave".
+ */
+void spi_cs_activate(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       /* cs pull low */
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE((slave->cs << 10) | CR2_SSPEN | CR2_TXFCLR
+                       | CR2_RXFCLR, &regs->cr[2]);
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x14);
+#endif
+       }
+       udelay_masked(1);
+}
+
+/*-----------------------------------------------------------------------
+ * Deactivate a SPI chipselect.
+ * This function is provided by the board code when using a driver
+ * that can't control its chipselects automatically (e.g.
+ * common/soft_spi.c). When called, it should deactivate the chip
+ * select to the device identified by "slave".
+ */
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       /* wait until device idle */
+       while (SPI_READ(&regs->sr) & SR_BUSY)
+               ;
+
+       /* cs pull high */
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE((slave->cs << 10) | CR2_FS, &regs->cr[2]);
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x10);
+#endif
+       }
+       udelay_masked(1);
+}
+
+void spi_init(void)
+{
+}
+
+struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode)
+{
+       uint32_t clk, div;
+       struct spi_slave *ss;
+       struct ftssp010_chip *chip;
+
+       if (!spi_cs_is_valid(bus, cs))
+               return NULL;
+
+       if (mode != SPI_MODE_0) {
+               printf("ftssp010: MODE%d is not supported\n", mode);
+               return NULL;
+       }
+
+       ss = malloc(sizeof(struct spi_slave));
+       if (!ss)
+               return NULL;
+
+       ss->bus = bus;
+       ss->cs  = cs;
+
+#ifdef CONFIG_FTSSP010_SCLK
+       clk = CONFIG_FTSSP010_SCLK;
+#else
+       clk = clk_get_rate("SSP");
+#endif
+       if (max_hz > 0) {
+               for (div = 0; div < 0xFFFF; ++div) {
+                       if ((clk / (2 * (div + 1))) <= max_hz)
+                               break;
+               }
+       } else {
+               div = 7;
+       }
+
+       chip = chip_list + bus;
+       chip->div  = div;
+       chip->mode = mode;
+
+       printf("ftssp010: bus=%d, hz=%u\n", bus, (clk / (2 * (div + 1))));
+
+       return ss;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+       free(slave);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       SPI_WRITE(CR1_SDL(8) | CR1_CLKDIV(chip->div), &regs->cr[1]);
+
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE(CR0_OPM_MASTER | CR0_FFMT_SPI | CR0_FSPO | CR0_FLASH,
+                       &regs->cr[0]);
+               SPI_WRITE(CR2_TXFCLR | CR2_RXFCLR,
+                       &regs->cr[2]);
+       } else {
+               SPI_WRITE(CR0_OPM_MASTER | CR0_FFMT_SPI | CR0_FSPO,
+                       &regs->cr[0]);
+               SPI_WRITE(CR2_TXFCLR | CR2_RXFCLR | CR2_SSPEN | CR2_TXDOE,
+                       &regs->cr[2]);
+       }
+
+       spi_cs_deactivate(slave);
+
+       return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       SPI_WRITE(0, &regs->cr[2]);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+                        const void *dout, void *din, unsigned long flags)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       uint32_t len = bitlen >> 3;
+
+       if (flags & SPI_XFER_BEGIN)
+               spi_cs_activate(slave);
+
+       if (chip->rev >= 0x00011900)
+               ftssp010_spi_work_transfer_v1_19(chip, dout, din, len, flags);
+       else
+               ftssp010_spi_work_transfer(chip, dout, din, len, flags);
+
+       if (flags & SPI_XFER_END)
+               spi_cs_deactivate(slave);
+
+       return 0;
+}
drivers/spi/ftssp010_spi.h new file +86 -1
new file mode 100644
index 0000000..5ad7c47
@@ -0,0 +1,86 @@
+/*
+ * Faraday Multi-function Controller - SPI Mode
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef _FTSSP010_H
+#define _FTSSP010_H
+
+/* FTSSP010 HW Registers */
+struct ftssp010_regs {
+       uint32_t cr[3];/* control register */
+       uint32_t sr;   /* status register */
+       uint32_t icr;  /* interrupt control register */
+       uint32_t isr;  /* interrupt status register */
+       uint32_t dr;   /* data register */
+       uint32_t rsvd[17];
+       uint32_t revr; /* revision register */
+       uint32_t fear; /* feature register */
+};
+
+/* Control register 0  */
+#define CR0_FFMT_MASK       (7 << 12)
+#define CR0_FFMT_SSP        (0 << 12)
+#define CR0_FFMT_SPI        (1 << 12)
+#define CR0_FFMT_MICROWIRE  (2 << 12)
+#define CR0_FFMT_I2S        (3 << 12)
+#define CR0_FFMT_AC97       (4 << 12)
+#define CR0_FLASH           (1 << 11)
+#define CR0_FSDIST(x)       (((x) & 0x03) << 8)
+#define CR0_LBM             (1 << 7)  /* Loopback mode */
+#define CR0_LSB             (1 << 6)  /* LSB first */
+#define CR0_FSPO            (1 << 5)  /* Frame sync atcive low */
+#define CR0_FSJUSTIFY       (1 << 4)
+#define CR0_OPM_SLAVE       (0 << 2)
+#define CR0_OPM_MASTER      (3 << 2)
+#define CR0_OPM_I2S_MSST    (3 << 2)  /* Master stereo mode */
+#define CR0_OPM_I2S_MSMO    (2 << 2)  /* Master mono mode */
+#define CR0_OPM_I2S_SLST    (1 << 2)  /* Slave stereo mode */
+#define CR0_OPM_I2S_SLMO    (0 << 2)  /* Slave mono mode */
+#define CR0_SCLKPO          (1 << 1)  /* SCLK Remain HIGH */
+#define CR0_SCLKPH          (1 << 0)  /* Half CLK cycle */
+
+/* Control Register 1 */
+
+#define CR1_PDL(x)          (((x) & 0xff) << 24) /* padding length */
+#define CR1_SDL(x)          ((((x) - 1) & 0x1f) << 16) /* data length */
+#define CR1_CLKDIV(x)       ((x) & 0xffff) /*  clk divider */
+
+/* Control Register 2 */
+#define CR2_FSOS(x)         (((x) & 0x03) << 10)       /* FS/CS Select */
+#define CR2_FS              (1 << 9)   /* FS/CS Signal Level */
+#define CR2_TXEN            (1 << 8)   /* Tx Enable */
+#define CR2_RXEN            (1 << 7)   /* Rx Enable */
+#define CR2_SSPRST          (1 << 6)   /* SSP reset */
+#define CR2_TXFCLR          (1 << 3)   /* TX FIFO Clear */
+#define CR2_RXFCLR          (1 << 2)   /* RX FIFO Clear */
+#define CR2_TXDOE           (1 << 1)   /* TX Data Output Enable */
+#define CR2_SSPEN           (1 << 0)   /* SSP Enable */
+
+/*
+ * Status Register
+ */
+#define SR_RFF       (1 << 0) /* receive FIFO full */
+#define SR_TFNF      (1 << 1) /* transmit FIFO not full */
+#define SR_BUSY      (1 << 2) /* bus is busy */
+#define SR_RFVE(reg) (((reg) >> 4) & 0x1f)  /* receive  FIFO valid entries */
+#define SR_TFVE(reg) (((reg) >> 12) & 0x1f) /* transmit FIFO valid entries */
+
+/*
+ * Feature Register
+ */
+#define FEAR_WIDTH(reg)  ((((reg) >>  0) & 0xff) + 1)
+#define FEAR_RXFIFO(reg) ((((reg) >>  8) & 0xff) + 1)
+#define FEAR_TXFIFO(reg) ((((reg) >> 16) & 0xff) + 1)
+#define FEAR_AC97        (1 << 24)
+#define FEAR_I2S         (1 << 25)
+#define FEAR_SPI_MWR     (1 << 26)
+#define FEAR_SSP         (1 << 27)
+#define FEAR_SPDIF       (1 << 28)
+
+#endif
--

1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 2 lines
Best wishes,
Kuo-Jung Su
#143 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

Quoted 494 lines · Kuo-Jung Su

Hi Jagan:

Thanks for the comments, but the [spi bus controller: ftssp010]

has been scheduled after the [Faraday A36x platform support] get approved.

In this way, the entire patch itself looks much better & clean.

Best Wishes

Dante Su

2013/8/8 Jagan Teki <[email protected]>:

Quoted 481 lines

Hi Kuo-Jung Su,

Please fix the comments I sent on v4.
http://patchwork.ozlabs.org/patch/242023/

Feel free to ask for any quires.

Thanks,
Jagan.

Quoted 470 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday FTSSP010 is a multi-function controller which supports I2S/SPI/SSP/AC97/SPDIF.
This patch simpily implements the SPI mode only. BTW the DMA and CS/Clock control logic has been altered since revision 1.19.0. So this patch would 1st detects the revision id of the underlying chip, and then switch to the corresponding control routines.

---
 drivers/spi/Makefile       |    1 +
 drivers/spi/ftssp010_spi.c |  337 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/ftssp010_spi.h |   86 +++++++++++
 3 files changed, 424 insertions(+)
 create mode 100644 drivers/spi/ftssp010_spi.c
 create mode 100644 drivers/spi/ftssp010_spi.h
drivers/spi/Makefile +1 -0
index d08609e..947d60e 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o
 COBJS-$(CONFIG_CF_SPI) += cf_spi.o
 COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
 COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+COBJS-$(CONFIG_FTSSP010_SPI) += ftssp010_spi.o
 COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 COBJS-$(CONFIG_ICH_SPI) +=  ich.o
 COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
drivers/spi/ftssp010_spi.c new file +337 -0
new file mode 100644
index 0000000..4247c8c
@@ -0,0 +1,337 @@
+/*
+ * Faraday Multi-function Controller - SPI Mode
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <spi.h>
+#include <malloc.h>
+
+#include "ftssp010_spi.h"
+
+struct ftssp010_chip {
+       void    *iobase;
+       uint32_t fifo;
+       uint32_t rev;
+       uint32_t div;
+       uint32_t mode;
+
+       struct {
+               uint32_t iobase;
+               uint32_t pin;
+       } gpio;
+};
+
+static struct ftssp010_chip chip_list[] = {
+#if defined(CONFIG_FTSSP010_BASE) || defined(CONFIG_FTSSP010_BASE0)
+       {
+               .iobase = (void *)CONFIG_FTSSP010_BASE,
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               .gpio = { CONFIG_FTSSP010_GPIO_BASE, CONFIG_FTSSP010_GPIO_PIN },
+#endif
+       },
+#endif
+#ifdef CONFIG_FTSSP010_BASE1
+       { .iobase = (void *)CONFIG_FTSSP010_BASE1, },
+#endif
+#ifdef CONFIG_FTSSP010_BASE2
+       { .iobase = (void *)CONFIG_FTSSP010_BASE2, },
+#endif
+#ifdef CONFIG_FTSSP010_BASE3
+       { .iobase = (void *)CONFIG_FTSSP010_BASE3, },
+#endif
+};
+
+/* Register access macros */
+#define SPI_READ(r)                    le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)                writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)      setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)      clrbits_le32(r, m)
+
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+#define SPI_GPIO_READ(p, r)    \
+       le32_to_cpu(readl((p)->gpio.iobase + (r)))
+#define SPI_GPIO_WRITE(p, v, r)        \
+       writel(cpu_to_le32(v), (p)->gpio.iobase + (r))
+#define SPI_GPIO_SETBITS(p, m, r)      \
+       setbits_le32((p)->gpio.iobase + (r), m)
+#define SPI_GPIO_CLRBITS(p, m, r)      \
+       clrbits_le32((p)->gpio.iobase + (r), m)
+#endif /* #ifdef CONFIG_FTSSP010_GPIO_BASE */
+
+static int ftssp010_spi_work_transfer_v1_19(struct ftssp010_chip *chip,
+       const void *tx_buf, void *rx_buf, int len, uint flags)
+{
+       struct ftssp010_regs *regs = chip->iobase;
+       const uint8_t *txb = tx_buf;
+       uint8_t       *rxb = rx_buf;
+
+       while (len > 0) {
+               int i, depth = min(chip->fifo >> 2, len);
+               uint32_t xmsk = 0;
+
+               if (tx_buf) {
+                       for (i = 0; i < depth; ++i) {
+                               while (!(SPI_READ(&regs->sr) & SR_TFNF))
+                                       ;
+                               SPI_WRITE(*txb++, &regs->dr);
+                       }
+                       xmsk |= CR2_TXEN | CR2_TXDOE;
+                       if ((SPI_READ(&regs->cr[2]) & xmsk) != xmsk)
+                               SPI_SETBITS(xmsk, &regs->cr[2]);
+               }
+               if (rx_buf) {
+                       xmsk |= CR2_RXEN;
+                       if ((SPI_READ(&regs->cr[2]) & xmsk) != xmsk)
+                               SPI_SETBITS(xmsk, &regs->cr[2]);
+                       for (i = 0; i < depth; ++i) {
+                               while (!SR_RFVE(SPI_READ(&regs->sr)))
+                                       ;
+                               *rxb++ = (uint8_t)SPI_READ(&regs->dr);
+                       }
+               }
+
+               len -= depth;
+       }
+
+       return 0;
+}
+
+static int ftssp010_spi_work_transfer(struct ftssp010_chip *chip,
+       const void *tx_buf, void *rx_buf, int len, uint flags)
+{
+       struct ftssp010_regs *regs = chip->iobase;
+       const uint8_t *txb = tx_buf;
+       uint8_t       *rxb = rx_buf;
+
+       while (len > 0) {
+               int i, depth = min(chip->fifo >> 2, len);
+               uint32_t tmp;
+
+               for (i = 0; i < depth; ++i) {
+                       while (!(SPI_READ(&regs->sr) & SR_TFNF))
+                               ;
+                       SPI_WRITE(txb ? (*txb++) : 0, &regs->dr);
+               }
+               for (i = 0; i < depth; ++i) {
+                       while (!SR_RFVE(SPI_READ(&regs->sr)))
+                               ;
+                       tmp = SPI_READ(&regs->dr);
+                       if (rxb)
+                               *rxb++ = (uint8_t)tmp;
+               }
+
+               len -= depth;
+       }
+
+       return 0;
+}
+
+/*=====================================================================*/
+/*                         Public Functions                            */
+/*=====================================================================*/
+
+/*-----------------------------------------------------------------------
+ * Determine if a SPI chipselect is valid.
+ * This function is provided by the board if the low-level SPI driver
+ * needs it to determine if a given chipselect is actually valid.
+ *
+ * Returns: 1 if bus:cs identifies a valid chip on this board, 0
+ * otherwise.
+ */
+int spi_cs_is_valid(unsigned int bus, unsigned int cs)
+{
+       struct ftssp010_chip *chip;
+       struct ftssp010_regs *regs;
+       uint32_t txfifo, rxfifo;
+
+       if (bus >= ARRAY_SIZE(chip_list))
+               return 0;
+
+       chip = chip_list + bus;
+       regs = chip->iobase;
+       chip->rev = SPI_READ(&regs->revr);
+       txfifo = FEAR_TXFIFO(SPI_READ(&regs->fear));
+       rxfifo = FEAR_RXFIFO(SPI_READ(&regs->fear));
+       chip->fifo = min(txfifo, rxfifo);
+
+       printf("ftssp010: rev.=0x%08X, fifo=%d\n", chip->rev, chip->fifo);
+
+       if (chip->rev >= 0x00011900) {
+               if (cs > 3)
+                       return 0;
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               if (cs > 0)
+                       return 0;
+               /* setup gpio pin as an output pin */
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x08);
+#else
+               return 0;
+#endif
+       }
+
+       return 1;
+}
+
+/*-----------------------------------------------------------------------
+ * Activate a SPI chipselect.
+ * This function is provided by the board code when using a driver
+ * that can't control its chipselects automatically (e.g.
+ * common/soft_spi.c). When called, it should activate the chip select
+ * to the device identified by "slave".
+ */
+void spi_cs_activate(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       /* cs pull low */
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE((slave->cs << 10) | CR2_SSPEN | CR2_TXFCLR
+                       | CR2_RXFCLR, &regs->cr[2]);
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x14);
+#endif
+       }
+       udelay_masked(1);
+}
+
+/*-----------------------------------------------------------------------
+ * Deactivate a SPI chipselect.
+ * This function is provided by the board code when using a driver
+ * that can't control its chipselects automatically (e.g.
+ * common/soft_spi.c). When called, it should deactivate the chip
+ * select to the device identified by "slave".
+ */
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       /* wait until device idle */
+       while (SPI_READ(&regs->sr) & SR_BUSY)
+               ;
+
+       /* cs pull high */
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE((slave->cs << 10) | CR2_FS, &regs->cr[2]);
+       } else {
+#ifdef CONFIG_FTSSP010_GPIO_BASE
+               SPI_GPIO_SETBITS(chip, 1 << chip->gpio.pin, 0x10);
+#endif
+       }
+       udelay_masked(1);
+}
+
+void spi_init(void)
+{
+}
+
+struct spi_slave *spi_setup_slave(uint bus, uint cs, uint max_hz, uint mode)
+{
+       uint32_t clk, div;
+       struct spi_slave *ss;
+       struct ftssp010_chip *chip;
+
+       if (!spi_cs_is_valid(bus, cs))
+               return NULL;
+
+       if (mode != SPI_MODE_0) {
+               printf("ftssp010: MODE%d is not supported\n", mode);
+               return NULL;
+       }
+
+       ss = malloc(sizeof(struct spi_slave));
+       if (!ss)
+               return NULL;
+
+       ss->bus = bus;
+       ss->cs  = cs;
+
+#ifdef CONFIG_FTSSP010_SCLK
+       clk = CONFIG_FTSSP010_SCLK;
+#else
+       clk = clk_get_rate("SSP");
+#endif
+       if (max_hz > 0) {
+               for (div = 0; div < 0xFFFF; ++div) {
+                       if ((clk / (2 * (div + 1))) <= max_hz)
+                               break;
+               }
+       } else {
+               div = 7;
+       }
+
+       chip = chip_list + bus;
+       chip->div  = div;
+       chip->mode = mode;
+
+       printf("ftssp010: bus=%d, hz=%u\n", bus, (clk / (2 * (div + 1))));
+
+       return ss;
+}
+
+void spi_free_slave(struct spi_slave *slave)
+{
+       free(slave);
+}
+
+int spi_claim_bus(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       SPI_WRITE(CR1_SDL(8) | CR1_CLKDIV(chip->div), &regs->cr[1]);
+
+       if (chip->rev >= 0x00011900) {
+               SPI_WRITE(CR0_OPM_MASTER | CR0_FFMT_SPI | CR0_FSPO | CR0_FLASH,
+                       &regs->cr[0]);
+               SPI_WRITE(CR2_TXFCLR | CR2_RXFCLR,
+                       &regs->cr[2]);
+       } else {
+               SPI_WRITE(CR0_OPM_MASTER | CR0_FFMT_SPI | CR0_FSPO,
+                       &regs->cr[0]);
+               SPI_WRITE(CR2_TXFCLR | CR2_RXFCLR | CR2_SSPEN | CR2_TXDOE,
+                       &regs->cr[2]);
+       }
+
+       spi_cs_deactivate(slave);
+
+       return 0;
+}
+
+void spi_release_bus(struct spi_slave *slave)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       struct ftssp010_regs *regs = chip->iobase;
+
+       SPI_WRITE(0, &regs->cr[2]);
+}
+
+int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+                        const void *dout, void *din, unsigned long flags)
+{
+       struct ftssp010_chip *chip = chip_list + slave->bus;
+       uint32_t len = bitlen >> 3;
+
+       if (flags & SPI_XFER_BEGIN)
+               spi_cs_activate(slave);
+
+       if (chip->rev >= 0x00011900)
+               ftssp010_spi_work_transfer_v1_19(chip, dout, din, len, flags);
+       else
+               ftssp010_spi_work_transfer(chip, dout, din, len, flags);
+
+       if (flags & SPI_XFER_END)
+               spi_cs_deactivate(slave);
+
+       return 0;
+}
drivers/spi/ftssp010_spi.h new file +86 -1
new file mode 100644
index 0000000..5ad7c47
@@ -0,0 +1,86 @@
+/*
+ * Faraday Multi-function Controller - SPI Mode
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef _FTSSP010_H
+#define _FTSSP010_H
+
+/* FTSSP010 HW Registers */
+struct ftssp010_regs {
+       uint32_t cr[3];/* control register */
+       uint32_t sr;   /* status register */
+       uint32_t icr;  /* interrupt control register */
+       uint32_t isr;  /* interrupt status register */
+       uint32_t dr;   /* data register */
+       uint32_t rsvd[17];
+       uint32_t revr; /* revision register */
+       uint32_t fear; /* feature register */
+};
+
+/* Control register 0  */
+#define CR0_FFMT_MASK       (7 << 12)
+#define CR0_FFMT_SSP        (0 << 12)
+#define CR0_FFMT_SPI        (1 << 12)
+#define CR0_FFMT_MICROWIRE  (2 << 12)
+#define CR0_FFMT_I2S        (3 << 12)
+#define CR0_FFMT_AC97       (4 << 12)
+#define CR0_FLASH           (1 << 11)
+#define CR0_FSDIST(x)       (((x) & 0x03) << 8)
+#define CR0_LBM             (1 << 7)  /* Loopback mode */
+#define CR0_LSB             (1 << 6)  /* LSB first */
+#define CR0_FSPO            (1 << 5)  /* Frame sync atcive low */
+#define CR0_FSJUSTIFY       (1 << 4)
+#define CR0_OPM_SLAVE       (0 << 2)
+#define CR0_OPM_MASTER      (3 << 2)
+#define CR0_OPM_I2S_MSST    (3 << 2)  /* Master stereo mode */
+#define CR0_OPM_I2S_MSMO    (2 << 2)  /* Master mono mode */
+#define CR0_OPM_I2S_SLST    (1 << 2)  /* Slave stereo mode */
+#define CR0_OPM_I2S_SLMO    (0 << 2)  /* Slave mono mode */
+#define CR0_SCLKPO          (1 << 1)  /* SCLK Remain HIGH */
+#define CR0_SCLKPH          (1 << 0)  /* Half CLK cycle */
+
+/* Control Register 1 */
+
+#define CR1_PDL(x)          (((x) & 0xff) << 24) /* padding length */
+#define CR1_SDL(x)          ((((x) - 1) & 0x1f) << 16) /* data length */
+#define CR1_CLKDIV(x)       ((x) & 0xffff) /*  clk divider */
+
+/* Control Register 2 */
+#define CR2_FSOS(x)         (((x) & 0x03) << 10)       /* FS/CS Select */
+#define CR2_FS              (1 << 9)   /* FS/CS Signal Level */
+#define CR2_TXEN            (1 << 8)   /* Tx Enable */
+#define CR2_RXEN            (1 << 7)   /* Rx Enable */
+#define CR2_SSPRST          (1 << 6)   /* SSP reset */
+#define CR2_TXFCLR          (1 << 3)   /* TX FIFO Clear */
+#define CR2_RXFCLR          (1 << 2)   /* RX FIFO Clear */
+#define CR2_TXDOE           (1 << 1)   /* TX Data Output Enable */
+#define CR2_SSPEN           (1 << 0)   /* SSP Enable */
+
+/*
+ * Status Register
+ */
+#define SR_RFF       (1 << 0) /* receive FIFO full */
+#define SR_TFNF      (1 << 1) /* transmit FIFO not full */
+#define SR_BUSY      (1 << 2) /* bus is busy */
+#define SR_RFVE(reg) (((reg) >> 4) & 0x1f)  /* receive  FIFO valid entries */
+#define SR_TFVE(reg) (((reg) >> 12) & 0x1f) /* transmit FIFO valid entries */
+
+/*
+ * Feature Register
+ */
+#define FEAR_WIDTH(reg)  ((((reg) >>  0) & 0xff) + 1)
+#define FEAR_RXFIFO(reg) ((((reg) >>  8) & 0xff) + 1)
+#define FEAR_TXFIFO(reg) ((((reg) >> 16) & 0xff) + 1)
+#define FEAR_AC97        (1 << 24)
+#define FEAR_I2S         (1 << 25)
+#define FEAR_SPI_MWR     (1 << 26)
+#define FEAR_SSP         (1 << 27)
+#define FEAR_SPDIF       (1 << 28)
+
+#endif
--

1.7.9.5

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Please see the comments on below patch
http://patchwork.ozlabs.org/patch/265683/

--
Thanks,
Jagan.

#145 lore raw

PATCH v2 5/12 spi: add Faraday FTSPI010 SPI controller support

Any update on this.

Quoted 12 lines · Kuo-Jung Su
Quoted 5 lines

Please see the comments on below patch
http://patchwork.ozlabs.org/patch/265683/

--

Got it, thanks

--
Best wishes,
Kuo-Jung Su

Signature · 8 lines
Thanks,
Jagan.
--------
Jagannadha Sutradharudu Teki,
E: jagannadh.teki at gmail.com, P: +91-9676773388
Engineer - System Software Hacker
U-boot - SPI Custodian and Zynq APSOC
Ln: http://www.linkedin.com/in/jaganteki
#146 lore raw

PATCH v2 6/12 mmc: add an alternative driver to Faraday FTSDC010

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTSDC010 is a MMC/SD host controller. Although there is already a driver in current u-boot release, which is modified from eSHDC and contributed by Andes Tech. Its performance is too terrible on Faraday A36x SoC platforms, so I turn to implement this new version of driver which is 10+ times faster than the old one.

If the hardware platform is avaiable, you may modify the 'include/configs/a369_defaults.h' for performance evaluation.

Here is the code snapshot of the 'a369_defaults.h'

#if 1
#define CONFIG_FTSDC010_MCI 1
#define CONFIG_FTSDC010_SDIO 1 /* The hardware core supports SDIO */
#else
#define CONFIG_FTSDC010 1
#define CONFIG_FTSDC010_SDIO 1 /* The hardware core supports SDIO */
#define CONFIG_FTSDC010_NUMBER 1
#define CONFIG_SYS_CLK_FREQ 133000000 /* AHB clock */
#endif

#define CONFIG_MMC             1
#define CONFIG_CMD_MMC         1
#define CONFIG_GENERIC_MMC     1
---
 drivers/mmc/Makefile       |    1 +
 drivers/mmc/ftsdc010_mci.c |  373 ++++++++++++++++++++++++++++++++++++++++++++
 include/faraday/ftsdc010.h |   16 +-
 include/faraday/mmc.h      |   16 ++
 4 files changed, 403 insertions(+), 3 deletions(-)
 create mode 100644 drivers/mmc/ftsdc010_mci.c
 create mode 100644 include/faraday/mmc.h
drivers/mmc/Makefile +1 -0
index 1d6faa2..52908bd 100644
@@ -33,6 +33,7 @@ COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
 COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 COBJS-$(CONFIG_FTSDC010) += ftsdc010_esdhc.o
+COBJS-$(CONFIG_FTSDC010_MCI) += ftsdc010_mci.o
 COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
 COBJS-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o
 COBJS-$(CONFIG_MMC_SPI) += mmc_spi.o
drivers/mmc/ftsdc010_mci.c new file +373 -0

373 lines not on this page · raw message

include/faraday/ftsdc010.h +13 -3
index c34dde7..d8c289c 100644
@@ -23,6 +23,9 @@
 #define __FTSDC010_H
 
 #ifndef __ASSEMBLY__
+
+#include "mmc.h"
+
 /* sd controller register */
 struct ftsdc010_mmc {
 	unsigned int	cmd;		/* 0x00 - command reg		*/
@@ -67,9 +70,6 @@ struct mmc_host {
 	unsigned int card_type;		/* Card type */
 };
 
-/* functions */
-int ftsdc010_mmc_init(int dev_index);
-
 #endif	/* __ASSEMBLY__ */
 
 /* global defines */
@@ -143,6 +143,15 @@ int ftsdc010_mmc_init(int dev_index);
 #define FTSDC010_STATUS_SDIO_IRPT		(1 << 16) /* SDIO card intr */
 #define FTSDC010_STATUS_DATA0_STATUS		(1 << 17)
 #endif /* CONFIG_FTSDC010_SDIO */
+#define FTSDC010_STATUS_RSP_ERROR	\
+	(FTSDC010_STATUS_RSP_CRC_FAIL | FTSDC010_STATUS_RSP_TIMEOUT)
+#define FTSDC010_STATUS_RSP_MASK	\
+	(FTSDC010_STATUS_RSP_ERROR | FTSDC010_STATUS_RSP_CRC_OK)
+#define FTSDC010_STATUS_DATA_ERROR	\
+	(FTSDC010_STATUS_DATA_CRC_FAIL | FTSDC010_STATUS_DATA_TIMEOUT)
+#define FTSDC010_STATUS_DATA_MASK	\
+	(FTSDC010_STATUS_DATA_ERROR | FTSDC010_STATUS_DATA_CRC_OK \
+	| FTSDC010_STATUS_DATA_END)
 
 /* 0x2c - clear register */
 #define FTSDC010_CLR_RSP_CRC_FAIL		(1 << 0)
@@ -192,6 +201,7 @@ int ftsdc010_mmc_init(int dev_index);
 #define FTSDC010_CCR_CLK_DIV(x)			(((x) & 0x7f) << 0)
 #define FTSDC010_CCR_CLK_SD			(1 << 7) /* 0: MMC, 1: SD */
 #define FTSDC010_CCR_CLK_DIS			(1 << 8)
+#define FTSDC010_CCR_CLK_HISPD			(1 << 9) /* high speed */
 
 /* card type */
 #define FTSDC010_CARD_TYPE_SD			FTSDC010_CLOCK_REG_CARD_TYPE
include/faraday/mmc.h new file +16 -0
new file mode 100644
index 0000000..ed09292
@@ -0,0 +1,16 @@
+/*
+ * Faraday MMC/SD Host Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef _FARADAY_MMC_H
+#define _FARADAY_MMC_H
+
+int ftsdc010_mmc_init(int dev_index);
+
+#endif /* _FARADAY_MMC_H */

--
1.7.9.5

#147 lore raw

PATCH v2 6/12 mmc: add an alternative driver to Faraday FTSDC010

Dear Kuo-Jung Su,

Quoted 11 lines · In message <[email protected]> you wrote:

From: Kuo-Jung Su <[email protected]>

Faraday FTSDC010 is a MMC/SD host controller. Although there is already a driver in current u-boot release, which is modified from eSHDC and contributed by Andes Tech. Its performance is too terrible on Faraday A36x SoC platforms, so I turn to implement this new version of driver which is 10+ times faster than the old one.

If the hardware platform is avaiable, you may modify the 'include/configs/a369_defaults.h' for performance evaluation.

NAK. Instead of adding another driver, please fix the problems of the original one, or replace the old one with your new, better one. We do not want to have several drivers for the same piece of hardware.

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The greatest warriors are the ones who fight for peace."
- Holly Near
#148 lore raw

PATCH v2 6/12 mmc: add an alternative driver to Faraday FTSDC010

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 12 lines

Dear Kuo-Jung Su,

Quoted 9 lines · In message <[email protected]> you wrote:

From: Kuo-Jung Su <[email protected]>

Faraday FTSDC010 is a MMC/SD host controller. Although there is already a driver in current u-boot release, which is modified from eSHDC and contributed by Andes Tech. Its performance is too terrible on Faraday A36x SoC platforms, so I turn to implement this new version of driver which is 10+ times faster than the old one.

Quoted 7 lines
Quoted 2 lines

If the hardware platform is avaiable, you may modify the 'include/configs/a369_defaults.h' for performance evaluation.

NAK. Instead of adding another driver, please fix the problems of the original one, or replace the old one with your new, better one. We do not want to have several drivers for the same piece of hardware.

Got it, thanks.
I plan to replace it with my own new one at next patch. And I'll make a CC to Andes to see if they has any issue.

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The greatest warriors are the ones who fight for peace."
- Holly Near

--
Best wishes,
Kuo-Jung Su

#149 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTNANDC021 is a integrated NAND flash controller. It use a build-in command table to abstract the underlying NAND flash control logic.

For example:

Issuing a command 0x10 to FTNANDC021 would result in a page write + a read status operation.

---
 drivers/mtd/nand/Makefile     |    1 +
 drivers/mtd/nand/ftnandc021.c |  544 +++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/ftnandc021.h |  132 ++++++++++
 include/faraday/nand.h        |   16 ++
 4 files changed, 693 insertions(+)
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 drivers/mtd/nand/ftnandc021.h
 create mode 100644 include/faraday/nand.h
drivers/mtd/nand/Makefile +1 -0
index 35769c5..f6f89f0 100644
@@ -63,6 +63,7 @@ COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_FSMC) += fsmc_nand.o
+COBJS-$(CONFIG_NAND_FTNANDC021) += ftnandc021.o
 COBJS-$(CONFIG_NAND_JZ4740) += jz4740_nand.o
 COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
drivers/mtd/nand/ftnandc021.c new file +544 -0

544 lines not on this page · raw message

drivers/mtd/nand/ftnandc021.h new file +132 -0

132 lines not on this page · raw message

include/faraday/nand.h new file +16 -0
new file mode 100644
index 0000000..6d8efb2
@@ -0,0 +1,16 @@
+/*
+ * Faraday NAND Flash Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef _FARADAY_NAND_H
+#define _FARADAY_NAND_H
+
+int ftnandc021_probe(struct nand_chip *chip);
+
+#endif /* _FARADAY_NAND_H */

--
1.7.9.5

#150 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/mtd/nand/ftnandc021.c line 42

Quoted 5 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+/* Register access macros */
+#define NAND_READ(r)		le32_to_cpu(readl(r))
+#define NAND_WRITE(v, r)	writel(cpu_to_le32(v), r)
+#define NAND_SETBITS(m, r)	setbits_le32(r, m)
+#define NAND_CLRBITS(m, r)	clrbits_le32(r, m)

As before: drop these.

drivers/mtd/nand/ftnandc021.c line 91

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+	/* wait until chip ready */
+	while (NAND_READ(&regs->srr) & SRR_CHIP_RESET)
+		;

Please add a timeout (and fix similar locations in the rest of the code if there are such).

Quoted 4 lines
drivers/mtd/nand/ftnandc021.c new file +4 -0
+	switch (priv->bksz / priv->pgsz) {
+	case 16:
+		bk = 0;
+		break;

drivers/mtd/nand/ftnandc021.c line 106

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+	case 32:
+		bk = 1;
+		break;
+	case 64:
+		bk = 2;
+		break;
+	case 128:
+		bk = 3;
+		break;
+	}
	bk = ffs(priv->bksz / priv->pgsz) - 4;

?

drivers/mtd/nand/ftnandc021.c line 130

Quoted 11 lines
drivers/mtd/nand/ftnandc021.c new file +11 -0
+	switch (priv->adrc) {
+	case 3:
+		ac = 0;
+		break;
+	case 4:
+		ac = 1;
+		break;
+	case 5:
+		ac = 2;
+		break;
+	}
	ac = priv->adrc - 3;

?

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"You're just jealous." "What, of an overgrown puppy  with  a  single-
figure IQ?"                      - Terry Pratchett, _Moving Pictures_
#151 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 4 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

Quoted 8 lines

drivers/mtd/nand/ftnandc021.c line 42

Quoted 5 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+/* Register access macros */
+#define NAND_READ(r)         le32_to_cpu(readl(r))
+#define NAND_WRITE(v, r)     writel(cpu_to_le32(v), r)
+#define NAND_SETBITS(m, r)   setbits_le32(r, m)
+#define NAND_CLRBITS(m, r)   clrbits_le32(r, m)

As before: drop these.

Got it, thanks

Quoted 7 lines

drivers/mtd/nand/ftnandc021.c line 91

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+     /* wait until chip ready */
+     while (NAND_READ(&regs->srr) & SRR_CHIP_RESET)
+             ;

Please add a timeout (and fix similar locations in the rest of the code if there are such).

Got it, thanks

Quoted 15 lines
Quoted 4 lines
drivers/mtd/nand/ftnandc021.c new file +4 -0
+     switch (priv->bksz / priv->pgsz) {
+     case 16:
+             bk = 0;
+             break;

drivers/mtd/nand/ftnandc021.c line 106

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+     case 32:
+             bk = 1;
+             break;
+     case 64:
+             bk = 2;
+             break;
+     case 128:
+             bk = 3;
+             break;
+     }
Quoted 4 lines
        bk = ffs(priv->bksz / priv->pgsz) - 4;

?

Got it, thanks

Quoted 12 lines

drivers/mtd/nand/ftnandc021.c line 130

Quoted 11 lines
drivers/mtd/nand/ftnandc021.c new file +11 -0
+     switch (priv->adrc) {
+     case 3:
+             ac = 0;
+             break;
+     case 4:
+             ac = 1;
+             break;
+     case 5:
+             ac = 2;
+             break;
+     }
Quoted 5 lines
        ac = priv->adrc - 3;

?

Got it, thanks

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "You're just jealous." "What, of an overgrown puppy with a single-
figure IQ?" - Terry Pratchett, _Moving Pictures_

--
Best wishes,
Kuo-Jung Su

#152 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

In reply to Kuo-Jung Su
Quoted 24 lines · Kuo-Jung Su
drivers/mtd/nand/ftnandc021.c new file +7 -0
new file mode 100644
index 0000000..58863dc
@@ -0,0 +1,544 @@
+/*
+ * Faraday NAND Flash Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later  

version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */

drivers/mtd/nand/ftnandc021.c new file +6 -0
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/unaligned.h>
+#include <nand.h>
+#include <malloc.h>

drivers/mtd/nand/ftnandc021.c line 25

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+
+#include "ftnandc021.h"
+
+/* common bitmask of nand flash status register */
+#define NAND_IOSTATUS_ERROR		BIT_MASK(0)
+#define NAND_IOSTATUS_READY		BIT_MASK(6)
+#define NAND_IOSTATUS_UNPROTCT	BIT_MASK(7)
+
+struct ftnandc021_chip {
+	void    *iobase;

struct ftnandc021_regs __iomem *iobase;

Quoted 7 lines
drivers/mtd/nand/ftnandc021.c new file +7 -0
+	uint32_t cmd;
+
+	uint32_t pgidx;
+
+	uint32_t off;
+	uint8_t  buf[256];
+

drivers/mtd/nand/ftnandc021.c line 42

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+	uint32_t adrc;	/* address cycle */
+	uint32_t pgsz;	/* page size */
+	uint32_t bksz;	/* block size */
+};
+
+/* Register access macros */
+#define NAND_READ(r)		le32_to_cpu(readl(r))
+#define NAND_WRITE(v, r)	writel(cpu_to_le32(v), r)
+#define NAND_SETBITS(m, r)	setbits_le32(r, m)
+#define NAND_CLRBITS(m, r)	clrbits_le32(r, m)

Do we really need these wrappers? At least use inline functions (with lowercase names) rather than ALLCAPS MACROS, but I don't see the point once you get rid of the byteswapping, which is broken. readl() reads a little-endian register and returns a CPU-ordered value, and then you pass that CPU ordered value to a function that wants to take a little endian value and swap it again. Likewise with writel, in reverse.

Quoted 4 lines
drivers/mtd/nand/ftnandc021.c new file +4 -0
+static struct nand_ecclayout ftnandc021_oob_2k = {
+	.eccbytes = 24,
+	.eccpos = {
+		40, 41, 42, 43, 44, 45, 46, 47,

drivers/mtd/nand/ftnandc021.c line 57

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+		48, 49, 50, 51, 52, 53, 54, 55,
+		56, 57, 58, 59, 60, 61, 62, 63
+	},
+	.oobfree = {
+		{
+			.offset = 9,
+			.length = 3
+		}
+	}
+};

This layout doesn't seem to match what the code does. The code says there is no ECC, and only writes to specific fixed bytes of the OOB (which doesn't match 3 bytes at offset 9).

drivers/mtd/nand/ftnandc021.c line 60

Quoted 2 lines
drivers/mtd/nand/ftnandc021.c new file +2 -0
+static int
+ftnandc021_reset(struct nand_chip *chip)

We don't generally do the "function name starts in column 0" thing in U-Boot.

drivers/mtd/nand/ftnandc021.c line 63

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+{
+	struct ftnandc021_chip *priv = chip->priv;
+	struct ftnandc021_regs *regs = priv->iobase;

struct ftnandc021_regs __iomem *regs

Here and elsewhere, for "sparse" checking.

drivers/mtd/nand/ftnandc021.c line 66

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+	uint32_t bk = 2;	/* 64 pages */
+	uint32_t pg = 1;	/* 2k */
+	uint32_t ac = 2;	/* 5 */

When do you actually use these default values, other than when one of the
switch statements fail to match -- which seems like it would be an error condition; even if you don't explicitly check for the error it doesn't seem good to paper over it by providing common values that might work.

drivers/mtd/nand/ftnandc021.c line 73

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +6 -0
+#ifdef CONFIG_FTNANDC021_ACTIMING_1
+	NAND_WRITE(CONFIG_FTNANDC021_ACTIMING_1, &regs->atr[0]);
+#endif
+#ifdef CONFIG_FTNANDC021_ACTIMING_2
+	NAND_WRITE(CONFIG_FTNANDC021_ACTIMING_2, &regs->atr[1]);
+#endif

Use CONFIG_SYS_ for things which describe hardware rather than user preference. Document all CONFIG symbols (including CONFIG_SYS symbols) in the README.

Quoted 9 lines
drivers/mtd/nand/ftnandc021.c new file +8 -0
+	NAND_WRITE(0, &regs->ier);
+	NAND_WRITE(0, &regs->pir);
+	NAND_WRITE(0xff, &regs->bbiwr);
+	NAND_WRITE(0xffffffff, &regs->lsnwr);
+	NAND_WRITE(0xffffffff, &regs->crcwr);
+
+	if (chip->options & NAND_BUSWIDTH_16)
+		NAND_WRITE(FCR_SWCRC | FCR_IGNCRC | FCR_16BIT,  

&regs->fcr);

drivers/mtd/nand/ftnandc021.c line 91

Quoted 9 lines
drivers/mtd/nand/ftnandc021.c new file +9 -0
+	else
+		NAND_WRITE(FCR_SWCRC | FCR_IGNCRC, &regs->fcr);
+
+	/* chip reset */
+	NAND_WRITE(SRR_CHIP_RESET, &regs->srr);
+
+	/* wait until chip ready */
+	while (NAND_READ(&regs->srr) & SRR_CHIP_RESET)
+		;

Timeout?

drivers/mtd/nand/ftnandc021.c line 130

Quoted 11 lines
drivers/mtd/nand/ftnandc021.c new file +11 -0
+	switch (priv->adrc) {
+	case 3:
+		ac = 0;
+		break;
+	case 4:
+		ac = 1;
+		break;
+	case 5:
+		ac = 2;
+		break;
+	}

ac = priv->adrc - 3;

Quoted 7 lines
drivers/mtd/nand/ftnandc021.c new file +7 -0
+static inline int
+ftnandc021_ckst(struct ftnandc021_chip *priv)
+{
+	struct ftnandc021_regs *regs = priv->iobase;
+	uint32_t st = NAND_READ(&regs->idr[1]);
+
+	if (st & NAND_IOSTATUS_ERROR)

drivers/mtd/nand/ftnandc021.c line 157

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+		return -NAND_IOSTATUS_ERROR;
+
+	if (!(st & NAND_IOSTATUS_READY))
+		return -NAND_IOSTATUS_READY;
+
+	if (!(st & NAND_IOSTATUS_UNPROTCT))
+		return -NAND_IOSTATUS_UNPROTCT;
+
+	return 0;
+}

Why the negation of NAND_IOSTATUS_*? These aren't standard error codes... you don't even use the return value at all that I see, other than checking zero or not-zero.

Quoted 7 lines
drivers/mtd/nand/ftnandc021.c new file +7 -0
+static uint8_t
+ftnandc021_read_byte(struct mtd_info *mtd)
+{
+	struct nand_chip *chip = mtd->priv;
+	struct ftnandc021_chip *priv = chip->priv;
+	struct ftnandc021_regs *regs = priv->iobase;
+	uint8_t ret = 0xff;

drivers/mtd/nand/ftnandc021.c line 296

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+
+	switch (priv->cmd) {
+	case NAND_CMD_READID:
+	case NAND_CMD_READOOB:
+		ret = priv->buf[priv->off % 256];
+		priv->off += 1;
+		break;
+	case NAND_CMD_STATUS:
+		ret = (uint8_t)(NAND_READ(&regs->idr[1]) & 0xff);
+		break;

Why "% 256" in one case but "& 0xff" in the other?

drivers/mtd/nand/ftnandc021.c line 299

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+	default:
+		debug("ftnandc021_read_byte: unknown cmd(0x%02X)\n",
+			priv->cmd);

This is an error, not just debug info. Use printf.

Quoted 9 lines
drivers/mtd/nand/ftnandc021.c new file +9 -0
+/**
+ * Read data from NAND controller into buffer
+ * @mtd: MTD device structure
+ * @buf: buffer to store date
+ * @len: number of bytes to read
+ */
+static void
+ftnandc021_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+{

drivers/mtd/nand/ftnandc021.c line 336

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+	struct nand_chip *chip = mtd->priv;
+	struct ftnandc021_chip *priv = chip->priv;
+	struct ftnandc021_regs *regs = priv->iobase;
+	ulong off;
+
+	/* oob read */
+	if (len <= mtd->oobsize) {
+		ftnandc021_read_oob(mtd, buf, len);
+		return;
+	}

Are you sure that a length smaller than the oobsize always means that it's an oob read?

drivers/mtd/nand/ftnandc021.c line 343

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +6 -0
+	/* page read */
+	for (off = 0; len > 0; len -= 4, off += 4) {
+		while (!(NAND_READ(&regs->ior) & IOR_READY))
+			;
+		*(uint32_t *)(buf + off) = NAND_READ(&regs->dr);
+	}

Why do you need to check IOR_READY here but not in read_byte?

Quoted 13 lines
drivers/mtd/nand/ftnandc021.c new file +2 -0
+static void
+ftnandc021_cmdfunc(struct mtd_info *mtd, unsigned cmd, int column,  

int pgidx)

drivers/mtd/nand/ftnandc021.c new file +10 -0
+{
+	struct nand_chip *chip = mtd->priv;
+	struct ftnandc021_chip *priv = chip->priv;
+	struct ftnandc021_regs *regs = priv->iobase;
+
+	priv->cmd   = cmd;
+	priv->pgidx = pgidx;
+
+	switch (cmd) {
+	case NAND_CMD_READID:	/* 0x90 */

drivers/mtd/nand/ftnandc021.c line 428

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+		if (ftnandc021_command(priv, FTNANDC021_CMD_RDID)) {
+			printf("ftnandc021: RDID failed.\n");
+		} else {
+			put_unaligned_le32(NAND_READ(&regs->idr[0]),
+				priv->buf);
+			put_unaligned_le32(NAND_READ(&regs->idr[1]),
+				priv->buf + 4);
+			priv->off = 0;
+		}
+		break;

Do error handling like this:

	if (ftnandc021_command(priv, FTNANDC021_CMD_RDID)) {
		printf(...);
		break;
	}

	put_unaligned...
	...

Why would it be unaligned?
Why _le32?
Can you not read a byte at a time here?

Quoted 14 lines
drivers/mtd/nand/ftnandc021.c new file +13 -0
+/**
+ * hardware specific access to control-lines
+ * @mtd: MTD device structure
+ * @cmd: command to device
+ * @ctrl:
+ * NAND_NCE: bit 0 -> don't care
+ * NAND_CLE: bit 1 -> Command Latch
+ * NAND_ALE: bit 2 -> Address Latch
+ *
+ * NOTE: boards may use different bits for these!!
+ */
+static void
+ftnandc021_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int  

ctrl)

drivers/mtd/nand/ftnandc021.c

Quoted 2 lines
drivers/mtd/nand/ftnandc021.c new file +2 -0
+{
+}

Just leave the function pointer NULL.

drivers/mtd/nand/ftnandc021.c line 533

Quoted 1 line
drivers/mtd/nand/ftnandc021.c new file +1 -0
+	chip->ecc.mode   = NAND_ECC_NONE;

Really, no ECC at all? That is quite broken. There is absolutely no way
to get access to the full OOB in order to do software ECC?

Or is it doing hardware ECC in a way that is transparent? You should still use NAND_ECC_HARD in that case.

drivers/mtd/nand/ftnandc021.c line 534

Quoted 1 line
drivers/mtd/nand/ftnandc021.c new file +1 -0
+	chip->ecc.layout = &ftnandc021_oob_2k;

What if it's not 2K NAND?

Quoted 17 lines
include/faraday/nand.h new file +7 -0
new file mode 100644
index 0000000..6d8efb2
@@ -0,0 +1,16 @@
+/*
+ * Faraday NAND Flash Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later  

version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */

include/faraday/nand.h line 14

Quoted 5 lines
include/faraday/nand.h new file +5 -0
+
+#ifndef _FARADAY_NAND_H
+#define _FARADAY_NAND_H
+
+int ftnandc021_probe(struct nand_chip *chip);

New drivers should use CONFIG_SYS_NAND_SELF_INIT

-Scott

#153 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

2013/4/19 Scott Wood <[email protected]>:

Quoted 29 lines · Kuo-Jung Su
Quoted 28 lines
drivers/mtd/nand/ftnandc021.c new file +8 -0
new file mode 100644
index 0000000..58863dc
@@ -0,0 +1,544 @@
+/*
+ * Faraday NAND Flash Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for

details.
+ */

drivers/mtd/nand/ftnandc021.c new file +11 -0
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/unaligned.h>
+#include <nand.h>
+#include <malloc.h>
+
+#include "ftnandc021.h"
+
+/* common bitmask of nand flash status register */
+#define NAND_IOSTATUS_ERROR            BIT_MASK(0)
Quoted 10 lines

drivers/mtd/nand/ftnandc021.c line 25

Quoted 5 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+#define NAND_IOSTATUS_READY            BIT_MASK(6)
+#define NAND_IOSTATUS_UNPROTCT BIT_MASK(7)
+
+struct ftnandc021_chip {
+       void    *iobase;

struct ftnandc021_regs __iomem *iobase;

Got it, thanks.

Quoted 19 lines
Quoted 7 lines
drivers/mtd/nand/ftnandc021.c new file +7 -0
+       uint32_t cmd;
+
+       uint32_t pgidx;
+
+       uint32_t off;
+       uint8_t  buf[256];
+

drivers/mtd/nand/ftnandc021.c line 42

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+       uint32_t adrc;  /* address cycle */
+       uint32_t pgsz;  /* page size */
+       uint32_t bksz;  /* block size */
+};
+
+/* Register access macros */
+#define NAND_READ(r)           le32_to_cpu(readl(r))
+#define NAND_WRITE(v, r)       writel(cpu_to_le32(v), r)
+#define NAND_SETBITS(m, r)     setbits_le32(r, m)
+#define NAND_CLRBITS(m, r)     clrbits_le32(r, m)
Quoted 8 lines

Do we really need these wrappers? At least use inline functions (with lowercase names) rather than ALLCAPS MACROS, but I don't see the point once you get rid of the byteswapping, which is broken. readl() reads a little-endian register and returns a CPU-ordered value, and then you pass that CPU ordered value to a function that wants to take a little endian value and swap it again. Likewise with writel, in reverse.

No, we don't need these wrappers, they're here only because my miss-understanding
about readl()/writel(), I don't know they've already done these for me. I'll drop these wrappers at next patch.

Quoted 11 lines
Quoted 11 lines
drivers/mtd/nand/ftnandc021.c new file +11 -0
+static struct nand_ecclayout ftnandc021_oob_2k = {
+       .eccbytes = 24,
+       .eccpos = {
+               40, 41, 42, 43, 44, 45, 46, 47,
+               48, 49, 50, 51, 52, 53, 54, 55,
+               56, 57, 58, 59, 60, 61, 62, 63
+       },
+       .oobfree = {
+               {
+                       .offset = 9,
+                       .length = 3
Quoted 10 lines

drivers/mtd/nand/ftnandc021.c line 57

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+               }
+       }
+};

This layout doesn't seem to match what the code does. The code says there is no ECC, and only writes to specific fixed bytes of the OOB (which doesn't match 3 bytes at offset 9).

Sorry, it's my bad, I forget to clean it up.
In my private base, it's possible to turn-on ECC support to FTNADC021 with the following issues:

1. When ECC is enabled, FTNANDC021 would always do ECC on every data block, including the blank block(all 0xff).
What I mean is 'With ECC enabled, we'll have ECC errors on non-ecc
proected data blocks or even the blank block'.

2. FTNANDC021 would stop upon ECC errors, a chip reset is required to make it work again.

3. There are only 4 bytes data + 1 byte Bad Block Info available to software, and because of the ECC issues above.
I'll have to use 1 byte of data to tag if this block is 'not blank', to make it possible to cancel the operation on these blocks
to prevent the chip to be stopped. (It means that I don't have to reset chip) And thus if the ECC is enabled, there are only 3 data bytes
available to software,
which makes it not possible to support BBT. (BBT requres 4 data bytes in OOB)

So in this patch, I'll prefer ECC disabled.
BTW, because of the issues above, this chip has been faced out many years ago. It would only be available to A369 or QEMU, and never in mass production. And thus I think it's ok to have ECC disabled in this patch.

Quoted 8 lines

drivers/mtd/nand/ftnandc021.c line 60

Quoted 2 lines
drivers/mtd/nand/ftnandc021.c new file +2 -0
+static int
+ftnandc021_reset(struct nand_chip *chip)

We don't generally do the "function name starts in column 0" thing in U-Boot.

Quoted 10 lines

drivers/mtd/nand/ftnandc021.c line 63

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+{
+       struct ftnandc021_chip *priv = chip->priv;
+       struct ftnandc021_regs *regs = priv->iobase;

struct ftnandc021_regs __iomem *regs

Here and elsewhere, for "sparse" checking.

Got it, thanks

Quoted 11 lines

drivers/mtd/nand/ftnandc021.c line 66

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+       uint32_t bk = 2;        /* 64 pages */
+       uint32_t pg = 1;        /* 2k */
+       uint32_t ac = 2;        /* 5 */

When do you actually use these default values, other than when one of the switch statements fail to match -- which seems like it would be an error condition; even if you don't explicitly check for the error it doesn't seem good to paper over it by providing common values that might work.

Got it, thanks.
I'll make it a fatal error when we got troubles to parse system straps.

Quoted 13 lines

drivers/mtd/nand/ftnandc021.c line 73

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +6 -0
+#ifdef CONFIG_FTNANDC021_ACTIMING_1
+       NAND_WRITE(CONFIG_FTNANDC021_ACTIMING_1, &regs->atr[0]);
+#endif
+#ifdef CONFIG_FTNANDC021_ACTIMING_2
+       NAND_WRITE(CONFIG_FTNANDC021_ACTIMING_2, &regs->atr[1]);
+#endif

Use CONFIG_SYS_ for things which describe hardware rather than user preference. Document all CONFIG symbols (including CONFIG_SYS symbols) in the README.

Got it, thanks

Quoted 13 lines
Quoted 13 lines
drivers/mtd/nand/ftnandc021.c new file +8 -0
+       NAND_WRITE(0, &regs->ier);
+       NAND_WRITE(0, &regs->pir);
+       NAND_WRITE(0xff, &regs->bbiwr);
+       NAND_WRITE(0xffffffff, &regs->lsnwr);
+       NAND_WRITE(0xffffffff, &regs->crcwr);
+
+       if (chip->options & NAND_BUSWIDTH_16)
+               NAND_WRITE(FCR_SWCRC | FCR_IGNCRC | FCR_16BIT,

&regs->fcr);

drivers/mtd/nand/ftnandc021.c new file +4 -0
+       else
+               NAND_WRITE(FCR_SWCRC | FCR_IGNCRC, &regs->fcr);
+
+       /* chip reset */
Quoted 10 lines

drivers/mtd/nand/ftnandc021.c line 91

Quoted 5 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+       NAND_WRITE(SRR_CHIP_RESET, &regs->srr);
+
+       /* wait until chip ready */
+       while (NAND_READ(&regs->srr) & SRR_CHIP_RESET)
+               ;

Timeout?

Got it, thanks.
I'll add a timeout for it.

Quoted 13 lines

drivers/mtd/nand/ftnandc021.c line 130

Quoted 11 lines
drivers/mtd/nand/ftnandc021.c new file +11 -0
+       switch (priv->adrc) {
+       case 3:
+               ac = 0;
+               break;
+       case 4:
+               ac = 1;
+               break;
+       case 5:
+               ac = 2;
+               break;
+       }
Quoted 2 lines

ac = priv->adrc - 3;

Got it, thanks

Quoted 14 lines
Quoted 14 lines
drivers/mtd/nand/ftnandc021.c new file +14 -0
+static inline int
+ftnandc021_ckst(struct ftnandc021_chip *priv)
+{
+       struct ftnandc021_regs *regs = priv->iobase;
+       uint32_t st = NAND_READ(&regs->idr[1]);
+
+       if (st & NAND_IOSTATUS_ERROR)
+               return -NAND_IOSTATUS_ERROR;
+
+       if (!(st & NAND_IOSTATUS_READY))
+               return -NAND_IOSTATUS_READY;
+
+       if (!(st & NAND_IOSTATUS_UNPROTCT))
+               return -NAND_IOSTATUS_UNPROTCT;
Quoted 10 lines

drivers/mtd/nand/ftnandc021.c line 139

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+
+       return 0;
+}

Why the negation of NAND_IOSTATUS_*? These aren't standard error codes... you don't even use the return value at all that I see, other than checking zero or not-zero.

It's for my personal debugging purpose, and it would be removed at next patch.

Quoted 12 lines
Quoted 12 lines
drivers/mtd/nand/ftnandc021.c new file +12 -0
+static uint8_t
+ftnandc021_read_byte(struct mtd_info *mtd)
+{
+       struct nand_chip *chip = mtd->priv;
+       struct ftnandc021_chip *priv = chip->priv;
+       struct ftnandc021_regs *regs = priv->iobase;
+       uint8_t ret = 0xff;
+
+       switch (priv->cmd) {
+       case NAND_CMD_READID:
+       case NAND_CMD_READOOB:
+               ret = priv->buf[priv->off % 256];
Quoted 10 lines

drivers/mtd/nand/ftnandc021.c line 296

Quoted 5 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+               priv->off += 1;
+               break;
+       case NAND_CMD_STATUS:
+               ret = (uint8_t)(NAND_READ(&regs->idr[1]) & 0xff);
+               break;

Why "% 256" in one case but "& 0xff" in the other?

Sorry, I don't know, too. :P
It would be fixed latter.

Quoted 8 lines

drivers/mtd/nand/ftnandc021.c line 299

Quoted 3 lines
drivers/mtd/nand/ftnandc021.c new file +3 -0
+       default:
+               debug("ftnandc021_read_byte: unknown cmd(0x%02X)\n",
+                       priv->cmd);

This is an error, not just debug info. Use printf.

Got it, thanks

Quoted 25 lines
Quoted 9 lines
drivers/mtd/nand/ftnandc021.c new file +9 -0
+/**
+ * Read data from NAND controller into buffer
+ * @mtd: MTD device structure
+ * @buf: buffer to store date
+ * @len: number of bytes to read
+ */
+static void
+ftnandc021_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+{

drivers/mtd/nand/ftnandc021.c line 336

Quoted 10 lines
drivers/mtd/nand/ftnandc021.c new file +10 -0
+       struct nand_chip *chip = mtd->priv;
+       struct ftnandc021_chip *priv = chip->priv;
+       struct ftnandc021_regs *regs = priv->iobase;
+       ulong off;
+
+       /* oob read */
+       if (len <= mtd->oobsize) {
+               ftnandc021_read_oob(mtd, buf, len);
+               return;
+       }

Are you sure that a length smaller than the oobsize always means that it's an oob read?

#154 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

Quoted 9 lines · Kuo-Jung Su

Sorry, it's my bad, I forget to clean it up.
In my private base, it's possible to turn-on ECC support to FTNADC021 with the following issues:

1. When ECC is enabled, FTNANDC021 would always do ECC on every data block,
including the blank block(all 0xff).
What I mean is 'With ECC enabled, we'll have ECC errors on non-ecc
proected data blocks or even the blank block'.

fsl_ifc_nand is similar -- when we see an uncorrectable error, we check whether the page is blank.

Quoted 2 lines

2. FTNANDC021 would stop upon ECC errors, a chip reset is required to make it work again.

This sounds bad, though. I assume that this is more than just resetting the NAND controller -- that you're resetting the entire system on a chip or similar?

Quoted 4 lines

3. There are only 4 bytes data + 1 byte Bad Block Info available to software,
and because of the ECC issues above.
I'll have to use 1 byte of data to tag if this block is 'not

Quoted 8 lines

blank',
to make it possible to cancel the operation on these blocks to prevent the chip to be stopped. (It means that I don't have to
reset chip)
And thus if the ECC is enabled, there are only 3 data bytes
available to software,
which makes it not possible to support BBT. (BBT requres 4 data
bytes in OOB)

You could define a custom BBT descriptor that uses fewer bytes.

Quoted 6 lines

So in this patch, I'll prefer ECC disabled.
BTW, because of the issues above, this chip has been faced out many years ago.
It would only be available to A369 or QEMU, and never in mass production.
And thus I think it's ok to have ECC disabled in this patch.

Why do we need support in U-Boot, then? Couldn't you just have QEMU model saner hardware? What is A369?

Quoted 12 lines
Quoted 11 lines

drivers/mtd/nand/ftnandc021.c line 343

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +6 -0
+       /* page read */
+       for (off = 0; len > 0; len -= 4, off += 4) {
+               while (!(NAND_READ(&regs->ior) & IOR_READY))
+                       ;
+               *(uint32_t *)(buf + off) = NAND_READ(&regs->dr);
+       }

Why do you need to check IOR_READY here but not in read_byte?

Quoted 7 lines

Because there is no any hardware access in 'read_byte'. The FTNANDC021 simplily does not support byte access by default. (I mean it's possible to update hardware RTL code,
but it's not the case to A369)
So I add some tricks to READ_ID, READ_OOB and READ_STATUS. The actual hardware access is performed at ftnandc021_cmdfunc(), The ftnandc021_read_byte() simpily access the cached data buffer.

OK, so you're assuming that the OOB will never be larger than the 256-byte software buffer?

-Scott

#155 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

2013/4/23 Scott Wood <[email protected]>:

Quoted 13 lines · Kuo-Jung Su
Quoted 10 lines

Sorry, it's my bad, I forget to clean it up.
In my private base, it's possible to turn-on ECC support to FTNADC021 with the following issues:

1. When ECC is enabled, FTNANDC021 would always do ECC on every data block,
including the blank block(all 0xff).
What I mean is 'With ECC enabled, we'll have ECC errors on non-ecc
proected data blocks or even the blank block'.

Quoted 4 lines

fsl_ifc_nand is similar -- when we see an uncorrectable error, we check whether the page is blank.

Good, I'm not alone....

Quoted 9 lines
Quoted 2 lines

2. FTNANDC021 would stop upon ECC errors, a chip reset is required to make it work again.

This sounds bad, though. I assume that this is more than just resetting the NAND controller -- that you're resetting the entire system on a chip or similar?

No, just reset the NAND controller. Since it's simply a peripheral device attached to the bus, and supports only PIO mode.

Quoted 13 lines
Quoted 11 lines

3. There are only 4 bytes data + 1 byte Bad Block Info available to software,
and because of the ECC issues above.
I'll have to use 1 byte of data to tag if this block is 'not blank', to make it possible to cancel the operation on these blocks to prevent the chip to be stopped. (It means that I don't have to reset
chip)
And thus if the ECC is enabled, there are only 3 data bytes
available to software,
which makes it not possible to support BBT. (BBT requres 4 data bytes
in OOB)

Quoted 3 lines

You could define a custom BBT descriptor that uses fewer bytes.

As far as I know, it's O.K to Linux, but requires some source file updated to u-boot in old release. (i.e. u-boot-2009.01, which was the original target release to FTNANDC021)
I'll check if it's now O.K to do that in u-boot. (I means no source code needs to be modified, except FTNANDC021.[ch])

Quoted 11 lines
Quoted 5 lines

So in this patch, I'll prefer ECC disabled.
BTW, because of the issues above, this chip has been faced out many years ago.
It would only be available to A369 or QEMU, and never in mass production. And thus I think it's ok to have ECC disabled in this patch.

Why do we need support in U-Boot, then? Couldn't you just have QEMU model saner hardware? What is A369?

A369 is a short for 'Faraday A369 SoC Evaluation Platform' with IC design companies as
its target customers, which means A369 should never be the ASIC used in mass production.
And the FTNANDC021 is actually designed for SSD applications, the general software (e.g. linux)
is never put into consideration during IP/CHIP design process.

It's an an accident that the FTNANDC021 get integrated into the A369. Although the NAND controller of A369 is considered a bad chip, the NAND flash is still a primary storage
to A369. So it still needs to be integrated to U-Boot to make everything work correctly.

The QEMU model for A369 is out several month ago, its primary target is to provide ROM code development
environment for myself.
However 80% of the peripheral chips have been modeled at the end. (The 20% is MPEG4/H.264 and SATA)

It's now known to work properly with U-boot, eCos, Linux and even Android Linux. So I integrate the QEMU model into my open-source Faraday SDK, and thus the QEMU modeled A369 would be the primary target platform from now on.

That's why I think the ECC function is optional to FTNANDC021, and the reason why I want it to be integrated to U-Boot.

BTW, I'm still struggling for QEMU contribution. So all the stuff are still available at my own github account only.
And of course, they're not the up-to-date source tree, because the github is actually my secondary storage.

P.S: My github account is 'dantesu1218', there you could find the stuff described above.
If you really want to have a try on it, I'll suggest starting from 'falinux', it's a copy-cat of uClinuc & buildroot.
Which means user only needs to run 'make menuconfig', falinux would gather all the stuff for him.

Quoted 21 lines
Quoted 12 lines
Quoted 11 lines

drivers/mtd/nand/ftnandc021.c line 343

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +6 -0
+       /* page read */
+       for (off = 0; len > 0; len -= 4, off += 4) {
+               while (!(NAND_READ(&regs->ior) & IOR_READY))
+                       ;
+               *(uint32_t *)(buf + off) = NAND_READ(&regs->dr);
+       }

Why do you need to check IOR_READY here but not in read_byte?

Quoted 7 lines

Because there is no any hardware access in 'read_byte'. The FTNANDC021 simplily does not support byte access by default. (I mean it's possible to update hardware RTL code,
but it's not the case to A369)
So I add some tricks to READ_ID, READ_OOB and READ_STATUS. The actual hardware access is performed at ftnandc021_cmdfunc(), The ftnandc021_read_byte() simpily access the cached data buffer.

Quoted 4 lines

OK, so you're assuming that the OOB will never be larger than the 256-byte software buffer?

-Scott

--
Best wishes,
Kuo-Jung Su

#156 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

Quoted 10 lines · Kuo-Jung Su

2013/4/23 Scott Wood <[email protected]>:

Quoted 2 lines · Kuo-Jung Su
Quoted 1 line

2. FTNANDC021 would stop upon ECC errors, a chip reset is required

to

Quoted 4 lines
Quoted 1 line

make it work again.

This sounds bad, though. I assume that this is more than just

resetting the

Quoted 1 line

NAND controller -- that you're resetting the entire system on a

Quoted 8 lines

chip or

Quoted 3 lines

similar?

No, just reset the NAND controller. Since it's simply a peripheral device
attached to the bus, and supports only PIO mode.

OK, so what's the downside to resetting the chip on an ECC error? Performance when reading a bunch of blank pages?

Quoted 10 lines
Quoted 3 lines

You could define a custom BBT descriptor that uses fewer bytes.

As far as I know, it's O.K to Linux, but requires some source file updated
to u-boot in old release. (i.e. u-boot-2009.01, which was the original target release to FTNANDC021)
I'll check if it's now O.K to do that in u-boot. (I means no source code needs to be modified, except FTNANDC021.[ch])

The NAND code has been updated since then (currently corresponds to Linux 3.0), though I'm not sure what the problem would have been even back then.

Quoted 27 lines

A369 is a short for 'Faraday A369 SoC Evaluation Platform' with IC design companies as
its target customers, which means A369 should never be the ASIC used in mass production.
And the FTNANDC021 is actually designed for SSD applications, the general software (e.g. linux)
is never put into consideration during IP/CHIP design process.

It's an an accident that the FTNANDC021 get integrated into the A369. Although the NAND controller of A369 is considered a bad chip, the NAND flash is still a primary storage
to A369. So it still needs to be integrated to U-Boot to make everything work correctly.

The QEMU model for A369 is out several month ago, its primary target is to provide ROM code development
environment for myself.
However 80% of the peripheral chips have been modeled at the end. (The 20% is MPEG4/H.264 and SATA)

It's now known to work properly with U-boot, eCos, Linux and even Android Linux.
So I integrate the QEMU model into my open-source Faraday SDK, and thus
the QEMU modeled A369 would be the primary target platform from now on.

Quoted 2 lines

That's why I think the ECC function is optional to FTNANDC021, and the reason why I want it to be integrated to U-Boot.

It could still be a problem during evaluation, though I guess you don't support MLC NAND chips which would need it the most. I won't block it, but at least make sure it prints a prominent warning message.

-Scott

#157 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

2013/4/24 Scott Wood <[email protected]>:

Quoted 15 lines · Kuo-Jung Su
Quoted 14 lines

2013/4/23 Scott Wood <[email protected]>:

Quoted 11 lines · Kuo-Jung Su
Quoted 2 lines

2. FTNANDC021 would stop upon ECC errors, a chip reset is required to make it work again.

This sounds bad, though. I assume that this is more than just resetting the
NAND controller -- that you're resetting the entire system on a chip or similar?

Quoted 8 lines
Quoted 2 lines

No, just reset the NAND controller. Since it's simply a peripheral device attached to the bus, and supports only PIO mode.

OK, so what's the downside to resetting the chip on an ECC error? Performance when reading a bunch of blank pages?

1. I'm lazy and coward.
2. It do impact the performance very much, because the ECC error is currently detected by a ~200ms NAND flash command timeout.

Now I plan to enable ECC in the next patch, and I'll check
if it's possible to detect ECC error more directly and cancel command wait.

P.S:
Both the RTL and datasheet of FTNANDC021 are buggy,
and the IP designer has quit from Faraday years.
I have to do it by trial and error.... so I'll always say 'I'll try....'

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

You could define a custom BBT descriptor that uses fewer bytes.

As far as I know, it's O.K to Linux, but requires some source file updated to u-boot in old release. (i.e. u-boot-2009.01, which was the original target release to FTNANDC021)
I'll check if it's now O.K to do that in u-boot. (I means no source code needs to be modified, except FTNANDC021.[ch])

Quoted 4 lines

The NAND code has been updated since then (currently corresponds to Linux 3.0), though I'm not sure what the problem would have been even back then.

That sounds good!
But I've found that BBT support has been dropped from default settings of Linux by myself years ago, I simply forget it.
It means that I don't even need to create a customized BBT header.

P.S:
The BBT was turned on to accelerate bad block scan in old days. Because the former driver written by one of my colleague, always read a full page rather than oob only. It takes +5 min to scan bad blocks from 256MB flash.
However the driver has been re-written with reading oob only at several years ago,
it now takes < 1 sec to scan bad blocks from 512MB flash, so I drop the BBT support by then.

Quoted 25 lines
Quoted 25 lines

A369 is a short for 'Faraday A369 SoC Evaluation Platform' with IC design companies as
its target customers, which means A369 should never be the ASIC used in mass production.
And the FTNANDC021 is actually designed for SSD applications, the general software (e.g. linux)
is never put into consideration during IP/CHIP design process.

It's an an accident that the FTNANDC021 get integrated into the A369. Although the NAND controller of A369 is considered a bad chip, the NAND flash is still a primary storage
to A369. So it still needs to be integrated to U-Boot to make everything work correctly.

The QEMU model for A369 is out several month ago, its primary target is to provide ROM code development
environment for myself.
However 80% of the peripheral chips have been modeled at the end. (The 20% is MPEG4/H.264 and SATA)

It's now known to work properly with U-boot, eCos, Linux and even Android Linux.
So I integrate the QEMU model into my open-source Faraday SDK, and thus the QEMU modeled A369 would be the primary target platform from now on.

Quoted 8 lines
Quoted 2 lines

That's why I think the ECC function is optional to FTNANDC021, and the reason why I want it to be integrated to U-Boot.

It could still be a problem during evaluation, though I guess you don't support MLC NAND chips which would need it the most. I won't block it, but at least make sure it prints a prominent warning message.

Don't worry about that, I've made my mind to enable ECC at next patch. Sorry for the mess that I've done.

Quoted 1 line

-Scott

--
Best wishes,
Kuo-Jung Su

#158 lore raw

PATCH v2 7/12 mtd: nand: add Faraday FTNANDC021 NAND controller support

In reply to Scott Wood

2013/4/23 Scott Wood <[email protected]>:

Quoted 74 lines · Kuo-Jung Su
Quoted 10 lines

Sorry, it's my bad, I forget to clean it up.
In my private base, it's possible to turn-on ECC support to FTNADC021 with the following issues:

1. When ECC is enabled, FTNANDC021 would always do ECC on every data block,
including the blank block(all 0xff).
What I mean is 'With ECC enabled, we'll have ECC errors on non-ecc
proected data blocks or even the blank block'.

fsl_ifc_nand is similar -- when we see an uncorrectable error, we check whether the page is blank.

Quoted 2 lines

2. FTNANDC021 would stop upon ECC errors, a chip reset is required to make it work again.

This sounds bad, though. I assume that this is more than just resetting the NAND controller -- that you're resetting the entire system on a chip or similar?

Quoted 11 lines

3. There are only 4 bytes data + 1 byte Bad Block Info available to software,
and because of the ECC issues above.
I'll have to use 1 byte of data to tag if this block is 'not blank', to make it possible to cancel the operation on these blocks to prevent the chip to be stopped. (It means that I don't have to reset
chip)
And thus if the ECC is enabled, there are only 3 data bytes
available to software,
which makes it not possible to support BBT. (BBT requres 4 data bytes
in OOB)

You could define a custom BBT descriptor that uses fewer bytes.

Quoted 5 lines

So in this patch, I'll prefer ECC disabled.
BTW, because of the issues above, this chip has been faced out many years ago.
It would only be available to A369 or QEMU, and never in mass production. And thus I think it's ok to have ECC disabled in this patch.

Why do we need support in U-Boot, then? Couldn't you just have QEMU model saner hardware? What is A369?

Quoted 12 lines
Quoted 11 lines

drivers/mtd/nand/ftnandc021.c line 343

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +6 -0
+       /* page read */
+       for (off = 0; len > 0; len -= 4, off += 4) {
+               while (!(NAND_READ(&regs->ior) & IOR_READY))
+                       ;
+               *(uint32_t *)(buf + off) = NAND_READ(&regs->dr);
+       }

Why do you need to check IOR_READY here but not in read_byte?

Quoted 7 lines

Because there is no any hardware access in 'read_byte'. The FTNANDC021 simplily does not support byte access by default. (I mean it's possible to update hardware RTL code,
but it's not the case to A369)
So I add some tricks to READ_ID, READ_OOB and READ_STATUS. The actual hardware access is performed at ftnandc021_cmdfunc(), The ftnandc021_read_byte() simpily access the cached data buffer.

Quoted 3 lines

OK, so you're assuming that the OOB will never be larger than the 256-byte software buffer?

No, that's my bad.
I don't really understand NAND flash protocol 4 years ago, I'm now re-writing the read/write stuff
with correct column address handling.

Quoted 1 line

-Scott

--
Best wishes,
Kuo-Jung Su

#159 lore raw

PATCH v2 8/12 mtd: spi: add FTSPI020 SPI Flash controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTSPI020 is dedicated SPI bus designed for SPI Flashes.

It supports Fast-Read-Dual, Fast-Read-Dual-IO, Fast-Read-Quad and Fast-Read-Quad-IO.

---
 drivers/mtd/spi/Makefile   |    4 +
 drivers/mtd/spi/ftspi020.c |  691 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/spi/ftspi020.h |  109 +++++++
 3 files changed, 804 insertions(+)
 create mode 100644 drivers/mtd/spi/ftspi020.c
 create mode 100644 drivers/mtd/spi/ftspi020.h
drivers/mtd/spi/Makefile +4 -0
index 90f8392..ce60e1b 100644
@@ -29,6 +29,9 @@ ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 endif
 
+ifeq ($(CONFIG_FTSPI020),y)
+COBJS-$(CONFIG_FTSPI020) += ftspi020.o
+else
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_EON)	+= eon.o
@@ -39,6 +42,7 @@ COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
 COBJS-$(CONFIG_SPI_FLASH_WINBOND)	+= winbond.o
 COBJS-$(CONFIG_SPI_FRAM_RAMTRON)	+= ramtron.o
 COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
+endif
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mtd/spi/ftspi020.c new file +691 -0

691 lines not on this page · raw message

drivers/mtd/spi/ftspi020.h new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#160 lore raw

PATCH v2 8/12 mtd: spi: add FTSPI020 SPI Flash controller support

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/mtd/spi/ftspi020.c line 93

Quoted 5 lines
drivers/mtd/spi/ftspi020.c new file +5 -0
+/* Register access macros */
+#define SPI_READ(r)			le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)		writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)	setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)	clrbits_le32(r, m)

see before...

drivers/mtd/spi/ftspi020.c line 99

Quoted 2 lines
drivers/mtd/spi/ftspi020.c new file +2 -0
+	struct spi_flash_info *fl = (struct spi_flash_info *)flash;
+	return fl->chip;

Please always insert a blank line between declarations and code.

drivers/mtd/spi/ftspi020.c line 117

Quoted 9 lines
drivers/mtd/spi/ftspi020.c new file +9 -0
+static const struct spi_flash_param sf_list[] = {
+
+	/* Atmel -- some are (confusingly) marketed as "DataFlash" */
+	{ "at25fs010",  0x1f6601, 0, 32 * 1024,   4 },
+	{ "at25fs040",  0x1f6604, 0, 64 * 1024,   8 },
+
+	{ "at25df041a", 0x1f4401, 0, 64 * 1024,   8 },
+	{ "at25df321a", 0x1f4701, 0, 64 * 1024,  64 },
+	{ "at25df641",  0x1f4800, 0, 64 * 1024, 128 },

...

should we not rather move this into a separate, global header file?

drivers/mtd/spi/ftspi020.c line 262

Quoted 4 lines
drivers/mtd/spi/ftspi020.c new file +4 -0
+	for (i = 0; i < ARRAY_SIZE(id32); ++i) {
+		/* wait until rx ready */
+		while (!(SPI_READ(&regs->sr) & SR_RFR))
+			;

See previous note about timeouts. Please fix globally.

drivers/mtd/spi/ftspi020.c line 268

Quoted 3 lines
drivers/mtd/spi/ftspi020.c new file +3 -0
+	/* wait until command finish */
+	while (!(SPI_READ(&regs->isr) & ISR_CMD))
+		;

Ditto. etc. etc.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Ja, mach' nur einen Plan,    sei nur ein grosses Licht
und mach' dann noch 'nen zweiten Plan,    geh'n tun sie beide nicht."
                                     -- Bert Brecht, Dreigroschenoper
#161 lore raw

PATCH v2 8/12 mtd: spi: add FTSPI020 SPI Flash controller support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 4 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

Quoted 8 lines

drivers/mtd/spi/ftspi020.c line 93

Quoted 5 lines
drivers/mtd/spi/ftspi020.c new file +5 -0
+/* Register access macros */
+#define SPI_READ(r)                  le32_to_cpu(readl(r))
+#define SPI_WRITE(v, r)              writel(cpu_to_le32(v), r)
+#define SPI_SETBITS(m, r)    setbits_le32(r, m)
+#define SPI_CLRBITS(m, r)    clrbits_le32(r, m)

see before...

Got it, thanks

Quoted 5 lines

drivers/mtd/spi/ftspi020.c line 99

Quoted 2 lines
drivers/mtd/spi/ftspi020.c new file +2 -0
+     struct spi_flash_info *fl = (struct spi_flash_info *)flash;
+     return fl->chip;

Please always insert a blank line between declarations and code.

Got it, thanks

Quoted 11 lines
Quoted 9 lines
drivers/mtd/spi/ftspi020.c new file +9 -0
+static const struct spi_flash_param sf_list[] = {
+
+     /* Atmel -- some are (confusingly) marketed as "DataFlash" */
+     { "at25fs010",  0x1f6601, 0, 32 * 1024,   4 },
+     { "at25fs040",  0x1f6604, 0, 64 * 1024,   8 },
+
+     { "at25df041a", 0x1f4401, 0, 64 * 1024,   8 },
+     { "at25df321a", 0x1f4701, 0, 64 * 1024,  64 },
+     { "at25df641",  0x1f4800, 0, 64 * 1024, 128 },

...

Quoted 2 lines

should we not rather move this into a separate, global header file?

Sure, I'll make it a separate file or a global header file if possible.

Quoted 5 lines

drivers/mtd/spi/ftspi020.c line 262

Quoted 4 lines
drivers/mtd/spi/ftspi020.c new file +4 -0
+     for (i = 0; i < ARRAY_SIZE(id32); ++i) {
+             /* wait until rx ready */
+             while (!(SPI_READ(&regs->sr) & SR_RFR))
+                     ;
Quoted 8 lines

See previous note about timeouts. Please fix globally.

drivers/mtd/spi/ftspi020.c line 268

Quoted 3 lines
drivers/mtd/spi/ftspi020.c new file +3 -0
+     /* wait until command finish */
+     while (!(SPI_READ(&regs->isr) & ISR_CMD))
+             ;

Ditto. etc. etc.

Got it, thanks

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Ja, mach' nur einen Plan, sei nur ein grosses Licht
und mach' dann noch 'nen zweiten Plan, geh'n tun sie beide nicht."
-- Bert Brecht, Dreigroschenoper

--
Best wishes,
Kuo-Jung Su

#162 lore raw

PATCH v2 9/12 usb: ehci: add Faraday USB 2.0 EHCI support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This patch add supports to both Faraday FUSBH200 and FOTG210, these controllers slightly differ from standard EHCI specification.

---
 common/usb_hub.c                |    5 ++
 drivers/usb/host/Makefile       |    1 +
 drivers/usb/host/ehci-faraday.c |  139 +++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/ehci-hcd.c     |   11 ++++
 drivers/usb/host/ehci.h         |    5 ++
 include/usb/fotg210.h           |   71 ++++++++++++++++++++
 include/usb/fusbh200.h          |   28 ++++++++
 7 files changed, 260 insertions(+)
 create mode 100644 drivers/usb/host/ehci-faraday.c
 create mode 100644 include/usb/fotg210.h
 create mode 100644 include/usb/fusbh200.h
common/usb_hub.c +5 -0
index b5eeb62..26d66b8 100644
@@ -375,6 +375,11 @@ static int usb_hub_configure(struct usb_device *dev)
 		return -1;
 	}
 
+#ifdef CONFIG_USB_EHCI_FARADAY
+	/* Faraday USB 2.0 EHCI chips need a long long delay here */
+	mdelay(250);
+#endif
+
 	if (usb_get_hub_status(dev, buffer) < 0) {
 		USB_HUB_PRINTF("usb_hub_configure: failed to get Status %lX\n",
 				dev->status);
drivers/usb/host/Makefile +1 -0
index 87a5970..98f2a10 100644
@@ -43,6 +43,7 @@ COBJS-$(CONFIG_USB_EHCI_FSL) += ehci-mpc512x.o
 else
 COBJS-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o
 endif
+COBJS-$(CONFIG_USB_EHCI_FARADAY) += ehci-faraday.o
 COBJS-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
 COBJS-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 COBJS-$(CONFIG_USB_EHCI_MXS) += ehci-mxs.o
drivers/usb/host/ehci-faraday.c new file +139 -0

139 lines not on this page · raw message

drivers/usb/host/ehci-hcd.c +11 -0
index c816878..450d217 100644
@@ -149,8 +149,10 @@ static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
 static int ehci_reset(int index)
 {
 	uint32_t cmd;
+#ifndef CONFIG_USB_EHCI_FARADAY
 	uint32_t tmp;
 	uint32_t *reg_ptr;
+#endif
 	int ret = 0;
 
 	cmd = ehci_readl(&ehcic[index].hcor->or_usbcmd);
@@ -163,6 +165,7 @@ static int ehci_reset(int index)
 		goto out;
 	}
 
+#ifndef CONFIG_USB_EHCI_FARADAY
 	if (ehci_is_TDI()) {
 		reg_ptr = (uint32_t *)((u8 *)ehcic[index].hcor + USBMODE);
 		tmp = ehci_readl(reg_ptr);
@@ -172,6 +175,7 @@ static int ehci_reset(int index)
 #endif
 		ehci_writel(reg_ptr, tmp);
 	}
+#endif	/* !CONFIG_USB_EHCI_FARADAY */
 
 #ifdef CONFIG_USB_EHCI_TXFIFO_THRESH
 	cmd = ehci_readl(&ehcic[index].hcor->or_txfilltuning);
@@ -711,6 +715,9 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 			tmpbuf[1] |= USB_PORT_STAT_POWER >> 8;
 
 		if (ehci_is_TDI()) {
+#ifdef CONFIG_USB_EHCI_FARADAY
+			tmpbuf[1] |= ehci_hcd_port_speed(ctrl->hccr) >> 8;
+#else
 			switch (PORTSC_PSPD(reg)) {
 			case PORTSC_PSPD_FS:
 				break;
@@ -722,6 +729,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 				tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
 				break;
 			}
+#endif
 		} else {
 			tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
 		}
@@ -950,10 +958,13 @@ int usb_lowlevel_init(int index, void **controller)
 	cmd |= CMD_RUN;
 	ehci_writel(&ehcic[index].hcor->or_usbcmd, cmd);
 
+#ifndef CONFIG_USB_EHCI_FARADAY
 	/* take control over the ports */
 	cmd = ehci_readl(&ehcic[index].hcor->or_configflag);
 	cmd |= FLAG_CF;
 	ehci_writel(&ehcic[index].hcor->or_configflag, cmd);
+#endif
+
 	/* unblock posted write */
 	cmd = ehci_readl(&ehcic[index].hcor->or_usbcmd);
 	mdelay(5);
drivers/usb/host/ehci.h +5 -0
index d090f0a..9309ede 100644
@@ -82,6 +82,7 @@ struct ehci_hcor {
 	uint32_t or_periodiclistbase;
 	uint32_t or_asynclistaddr;
 	uint32_t _reserved_0_;
+#ifndef CONFIG_USB_EHCI_FARADAY
 	uint32_t or_burstsize;
 	uint32_t or_txfilltuning;
 #define TXFIFO_THRESH_MASK		(0x3f << 16)
@@ -89,6 +90,7 @@ struct ehci_hcor {
 	uint32_t _reserved_1_[6];
 	uint32_t or_configflag;
 #define FLAG_CF		(1 << 0)	/* true:  we'll support "high speed" */
+#endif  /* #ifndef CONFIG_USB_EHCI_FARADAY */
 	uint32_t or_portsc[CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS];
 #define PORTSC_PSPD(x)		(((x) >> 26) & 0x3)
 #define PORTSC_PSPD_FS			0x0
@@ -255,5 +257,8 @@ struct QH {
 /* Low level init functions */
 int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor);
 int ehci_hcd_stop(int index);
+#ifdef CONFIG_USB_EHCI_FARADAY
+int ehci_hcd_port_speed(struct ehci_hccr *hccr);
+#endif
 
 #endif /* USB_EHCI_H */
include/usb/fotg210.h new file +71 -0

71 lines not on this page · raw message

include/usb/fusbh200.h new file +28 -0
new file mode 100644
index 0000000..2d514b8
@@ -0,0 +1,28 @@
+/*
+ * Faraday USB 2.0 EHCI Controller
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef _FUSBH200_H
+#define _FUSBH200_H
+
+struct fusbh200_regs {
+	struct {
+		uint32_t data[4];
+	} hccr;			/* 0x00 - 0x0f: hccr */
+	struct {
+		uint32_t data[9];
+	} hcor;			/* 0x10 - 0x33: hcor */
+	uint32_t easstr;/* 0x34: EOF&Async. Schedule Sleep Timer Register */
+	uint32_t rsvd[2];
+	uint32_t bmcsr;	/* 0x40: Bus Monitor Control Status Register */
+	uint32_t bmisr;	/* 0x44: Bus Monitor Interrupt Status Register */
+	uint32_t bmier; /* 0x48: Bus Monitor Interrupt Enable Register */
+};
+
+#endif

--
1.7.9.5

#163 lore raw

PATCH v2 9/12 usb: ehci: add Faraday USB 2.0 EHCI support

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/usb/host/ehci-faraday.c line 46

Quoted 4 lines
drivers/usb/host/ehci-faraday.c new file +4 -0
+#define HCD_READ(r)			le32_to_cpu(readl(r))
+#define HCD_WRITE(v, r)		writel(cpu_to_le32(v), r)
+#define HCD_SETBITS(m, r)	setbits_le32(r, m)
+#define HCD_CLRBITS(m, r)	clrbits_le32(r, m)

As before...

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I'm a programmer: I don't buy software, I write it.
                                                  -- Tom Christiansen
#164 lore raw

PATCH v2 9/12 usb: ehci: add Faraday USB 2.0 EHCI support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 11 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

drivers/usb/host/ehci-faraday.c line 46

Quoted 4 lines
drivers/usb/host/ehci-faraday.c new file +4 -0
+#define HCD_READ(r)                  le32_to_cpu(readl(r))
+#define HCD_WRITE(v, r)              writel(cpu_to_le32(v), r)
+#define HCD_SETBITS(m, r)    setbits_le32(r, m)
+#define HCD_CLRBITS(m, r)    clrbits_le32(r, m)

As before...

Got it, thanks

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I'm a programmer: I don't buy software, I write it.
-- Tom Christiansen

--
Best wishes,
Kuo-Jung Su

#165 lore raw

PATCH v2 10/12 usb: gadget: add Faraday FOTG210 USB gadget support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday FOTG210 is an OTG chip which could operate as either an EHCI Host or a USB Device as a time.

---
 drivers/usb/gadget/Makefile       |    1 +
 drivers/usb/gadget/fotg210.c      |  922 +++++++++++++++++++++++++++++++++++++
 drivers/usb/gadget/gadget_chips.h |    8 +
 3 files changed, 931 insertions(+)
 create mode 100644 drivers/usb/gadget/fotg210.c
drivers/usb/gadget/Makefile +1 -0
index e545b6b..432cf17 100644
@@ -35,6 +35,7 @@ endif
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
+COBJS-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
 COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o
 endif
drivers/usb/gadget/fotg210.c new file +922 -0

922 lines not on this page · raw message

drivers/usb/gadget/gadget_chips.h +8 -0
index e570142..f038747 100644
@@ -150,6 +150,12 @@
 #define gadget_is_mv(g)        0
 #endif
 
+#ifdef CONFIG_USB_GADGET_FOTG210
+#define gadget_is_fotg210(g)        (!strcmp("fotg210_udc", (g)->name))
+#else
+#define gadget_is_fotg210(g)        0
+#endif
+
 /*
  * CONFIG_USB_GADGET_SX2
  * CONFIG_USB_GADGET_AU1X00
@@ -215,5 +221,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
 		return 0x20;
 	else if (gadget_is_mv(gadget))
 		return 0x21;
+	else if (gadget_is_fotg210(gadget))
+		return 0x22;
 	return -ENOENT;
 }

--
1.7.9.5

#166 lore raw

PATCH v2 10/12 usb: gadget: add Faraday FOTG210 USB gadget support

Dear Kuo-Jung Su,

Quoted 4 lines · In message <[email protected]> you wrote:

From: Kuo-Jung Su <[email protected]>

The Faraday FOTG210 is an OTG chip which could operate as either an EHCI Host or a USB Device as a time.

...

drivers/usb/gadget/fotg210.c line 36

Quoted 4 lines
drivers/usb/gadget/fotg210.c new file +4 -0
+	uint32_t maxpacket:16;
+	uint32_t id:4;
+	uint32_t stopped:1;
+	uint32_t rsvd:11;

Please do NOT use bit fields. Fix globally.

drivers/usb/gadget/fotg210.c line 63

Quoted 4 lines
drivers/usb/gadget/fotg210.c new file +4 -0
+#define USB_READ(r)			le32_to_cpu(readl(r))
+#define USB_WRITE(v, r)		writel(cpu_to_le32(v), r)
+#define USB_SETBITS(m, r)	setbits_le32(r, m)
+#define USB_CLRBITS(m, r)	clrbits_le32(r, m)

As before...

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
e-credibility: the non-guaranteeable likelihood that  the  electronic
data you're seeing is genuine rather than somebody's made-up crap.
- Karl Lehenbauer
#167 lore raw

PATCH v2 10/12 usb: gadget: add Faraday FOTG210 USB gadget support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 7 lines

Dear Kuo-Jung Su,

Quoted 4 lines · In message <[email protected]> you wrote:

From: Kuo-Jung Su <[email protected]>

The Faraday FOTG210 is an OTG chip which could operate as either an EHCI Host or a USB Device as a time.

Quoted 8 lines

...

drivers/usb/gadget/fotg210.c line 36

Quoted 4 lines
drivers/usb/gadget/fotg210.c new file +4 -0
+     uint32_t maxpacket:16;
+     uint32_t id:4;
+     uint32_t stopped:1;
+     uint32_t rsvd:11;

Please do NOT use bit fields. Fix globally.

Got it, thanks

Quoted 8 lines

drivers/usb/gadget/fotg210.c line 63

Quoted 4 lines
drivers/usb/gadget/fotg210.c new file +4 -0
+#define USB_READ(r)                  le32_to_cpu(readl(r))
+#define USB_WRITE(v, r)              writel(cpu_to_le32(v), r)
+#define USB_SETBITS(m, r)    setbits_le32(r, m)
+#define USB_CLRBITS(m, r)    clrbits_le32(r, m)

As before...

Got it, thanks

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
e-credibility: the non-guaranteeable likelihood that the electronic data you're seeing is genuine rather than somebody's made-up crap.
- Karl Lehenbauer

--
Best wishes,
Kuo-Jung Su

#168 lore raw

PATCH v2 11/12 arm: add MMU/d-cache support for Faraday cores

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This patch would enable MMU for Faraday ARMv5TE cores.

Here is the abstract of this MMU design.

Assume SDRAM memory region starts at 0x10000000, and its size = 0x800000.

0x00000000 +-------------------+

           |                   |
           |     UN-CACHED     |
           |                   |
           |                   |
0x10000000 +-------------------+
           |  CACHED (SDRAM)   | <- It's where data/bss/stack lived.
           |                   |
           |                   |
0x10800000 +-------------------+
           |                   |
           |                   |
           |     UN-CACHED     |
           |                   |
           |                   |
0xFF800000 +-------------------+
           | UN-CACHED (SDRAM) | <- An un-cached shadow of the SDRAM.
           |                   |    dma_alloc_coherent() always returns
           |                   |    an address in this region.

0xFFFFFFFF +-------------------+

CC Albert Aribaud <[email protected]>
---
 arch/arm/include/asm/dma-mapping.h |   56 ++++++++++++++++++++++--
 arch/arm/include/asm/global_data.h |    4 ++
 arch/arm/include/asm/io.h          |   84 +++++++++++++++++++++++++++++++++++-
 arch/arm/lib/cache-cp15.c          |   42 ++++++++++++++++++
 common/cmd_boot.c                  |    4 ++
 5 files changed, 186 insertions(+), 4 deletions(-)
arch/arm/include/asm/dma-mapping.h +53 -3
index 5bbb0a0..53c4edf 100644
@@ -3,6 +3,9 @@
  * Stelian Pop <[email protected]>
  * Lead Tech Design <www.leadtechdesign.com>
  *
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -24,22 +27,69 @@
 #ifndef __ASM_ARM_DMA_MAPPING_H
 #define __ASM_ARM_DMA_MAPPING_H
 
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <malloc.h>
+
 enum dma_data_direction {
 	DMA_BIDIRECTIONAL	= 0,
 	DMA_TO_DEVICE		= 1,
 	DMA_FROM_DEVICE		= 2,
 };
 
-static void *dma_alloc_coherent(size_t len, unsigned long *handle)
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	DECLARE_GLOBAL_DATA_PTR;
+#endif
+	void *va = memalign(ARCH_DMA_MINALIGN, len);
+
+	if (va && handle)
+		*handle = virt_to_phys(va);
+
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	if (gd->arch.cpu_mmu) {
+		/* invalidate the buffer, convert to un-cached address */
+		if (va != NULL) {
+			invalidate_dcache_range((ulong)va, (ulong)va + len);
+			va = virt_to_uncached(va);
+		}
+	}
+#endif
+
+	return va;
+}
+
+static inline void dma_free_coherent(void *va)
 {
-	*handle = (unsigned long)malloc(len);
-	return (void *)*handle;
+	free(virt_to_cached(va));
 }
 
 static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
 					   enum dma_data_direction dir)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	DECLARE_GLOBAL_DATA_PTR;
+
+	if (gd->arch.cpu_mmu) {
+		switch (dir) {
+		case DMA_BIDIRECTIONAL:
+		case DMA_TO_DEVICE:
+			flush_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+
+		case DMA_FROM_DEVICE:
+			invalidate_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+		}
+	}
+	return virt_to_phys((void *)vaddr);
+#else
 	return (unsigned long)vaddr;
+#endif
 }
 
 static inline void dma_unmap_single(volatile void *vaddr, size_t len,
arch/arm/include/asm/global_data.h +4 -0
index 37ac0da..bd18ff7 100644
@@ -38,6 +38,10 @@ struct arch_global_data {
 	unsigned long	pllb_rate_hz;
 	unsigned long	at91_pllb_usb_init;
 #endif
+#ifdef CONFIG_FARADAY
+	unsigned long   cpu_id;
+	unsigned long   cpu_mmu;	/* has mmu */
+#endif
 	/* "static data" needed by most of timer.c on ARM platforms */
 	unsigned long timer_rate_hz;
 	unsigned long tbu;
arch/arm/include/asm/io.h +83 -1

104 lines not on this page · raw message

arch/arm/lib/cache-cp15.c +42 -0

75 lines not on this page · raw message

common/cmd_boot.c +4 -0
index d3836fd..b2477e8 100644
@@ -50,6 +50,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	printf ("## Starting application at 0x%08lX ...\n", addr);
 
+#if defined(__ARM__) && !defined(CONFIG_SYS_DCACHE_OFF)
+	cleanup_before_linux();
+#endif
+
 	/*
 	 * pass address parameter as argv[0] (aka command name),
 	 * and all remaining args

--
1.7.9.5

#169 lore raw

PATCH v2 11/12 arm: add MMU/d-cache support for Faraday cores

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

common/cmd_boot.c static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 59

Quoted 13 lines
common/cmd_boot.c +4 -0
@@ -50,6 +50,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	printf ("## Starting application at 0x%08lX ...\n", addr);
 
+#if defined(__ARM__) && !defined(CONFIG_SYS_DCACHE_OFF)
+	cleanup_before_linux();
+#endif
+
 	/*
 	 * pass address parameter as argv[0] (aka command name),
 	 * and all remaining args

Thios affects global code. Please submit as separate patch.

And why exactly is this ARM specific?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
My play was a complete success.  The audience was a failure.
#170 lore raw

PATCH v2 11/12 arm: add MMU/d-cache support for Faraday cores

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 10 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

Quoted 6 lines
common/cmd_boot.c +0 -0
@@ -50,6 +50,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
      printf ("## Starting application at 0x%08lX ...\n", addr);
 
Quoted 9 lines

common/cmd_boot.c static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 59

Quoted 7 lines
common/cmd_boot.c +4 -0
+#if defined(__ARM__) && !defined(CONFIG_SYS_DCACHE_OFF)
+     cleanup_before_linux();
+#endif
+
      /*
       * pass address parameter as argv[0] (aka command name),
       * and all remaining args

Thios affects global code. Please submit as separate patch.

Got it, thanks

Quoted 3 lines

And why exactly is this ARM specific?

Because it only has been tested on ARM platform only,
I'm not sure if the others arch. also has the function: cleanup_before_linux();

Quoted 9 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de My play was a complete success. The audience was a failure.

--
Best wishes,
Kuo-Jung Su

#171 lore raw

PATCH v2 11/12 arm: add MMU/d-cache support for Faraday cores

In reply to Kuo-Jung Su

Hi Kuo-Jung,

Quoted 27 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This patch would enable MMU for Faraday ARMv5TE cores.

Here is the abstract of this MMU design.

Assume SDRAM memory region starts at 0x10000000, and its size = 0x800000.

0x00000000 +-------------------+

           |                   |
           |     UN-CACHED     |
           |                   |
           |                   |
0x10000000 +-------------------+
           |  CACHED (SDRAM)   | <- It's where data/bss/stack lived.
           |                   |
           |                   |
0x10800000 +-------------------+
           |                   |
           |                   |
           |     UN-CACHED     |
           |                   |
           |                   |
0xFF800000 +-------------------+
           | UN-CACHED (SDRAM) | <- An un-cached shadow of the SDRAM.
           |                   |    dma_alloc_coherent() always returns
           |                   |    an address in this region.
Quoted 1 line

0xFFFFFFFF +-------------------+

The ASCII map is great for explaining, but I find it a bit big for a commit message. Can you summarize it as lines like

0x00000000-0x0FFFFFFF not cached
0x10000000-0x107FFFFF cached (SDRAM)
...

?

Quoted 34 lines
CC Albert Aribaud <[email protected]>
---
 arch/arm/include/asm/dma-mapping.h |   56 ++++++++++++++++++++++--
 arch/arm/include/asm/global_data.h |    4 ++
 arch/arm/include/asm/io.h          |   84 +++++++++++++++++++++++++++++++++++-
 arch/arm/lib/cache-cp15.c          |   42 ++++++++++++++++++
 common/cmd_boot.c                  |    4 ++
 5 files changed, 186 insertions(+), 4 deletions(-)
arch/arm/include/asm/dma-mapping.h +8 -0
index 5bbb0a0..53c4edf 100644
@@ -3,6 +3,9 @@
  * Stelian Pop <[email protected]>
  * Lead Tech Design <www.leadtechdesign.com>
  *
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -24,22 +27,69 @@
 #ifndef __ASM_ARM_DMA_MAPPING_H
 #define __ASM_ARM_DMA_MAPPING_H
 
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <malloc.h>
+
 enum dma_data_direction {

arch/arm/include/asm/dma-mapping.h line 44

Quoted 10 lines
arch/arm/include/asm/dma-mapping.h +4 -1
 	DMA_BIDIRECTIONAL	= 0,
 	DMA_TO_DEVICE		= 1,
 	DMA_FROM_DEVICE		= 2,
 };
 
-static void *dma_alloc_coherent(size_t len, unsigned long *handle)
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	DECLARE_GLOBAL_DATA_PTR;

I'd rather have the global data ptr be declared outside any function, and only once.

Quoted 15 lines
arch/arm/include/asm/dma-mapping.h +15 -0
+#endif
+	void *va = memalign(ARCH_DMA_MINALIGN, len);
+
+	if (va && handle)
+		*handle = virt_to_phys(va);
+
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	if (gd->arch.cpu_mmu) {
+		/* invalidate the buffer, convert to un-cached address */
+		if (va != NULL) {
+			invalidate_dcache_range((ulong)va, (ulong)va + len);
+			va = virt_to_uncached(va);
+		}
+	}
+#endif

arch/arm/include/asm/dma-mapping.h line 67

Quoted 10 lines
arch/arm/include/asm/dma-mapping.h +6 -2
+
+	return va;
+}
+
+static inline void dma_free_coherent(void *va)
 {
-	*handle = (unsigned long)malloc(len);
-	return (void *)*handle;
+	free(virt_to_cached(va));
 }

If I read this correctly, this code changes the semantics of dma_alloc_coherent() for boards other than Faraday-based: before, mempry was simply malloc()ed, now it would be memalign()ed then virt_to_phys()ed. Why not simply keep the previous implementation under a #else...#endif block?

Quoted 15 lines
arch/arm/include/asm/dma-mapping.h +12 -0
 static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
 					   enum dma_data_direction dir)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	DECLARE_GLOBAL_DATA_PTR;
+
+	if (gd->arch.cpu_mmu) {
+		switch (dir) {
+		case DMA_BIDIRECTIONAL:
+		case DMA_TO_DEVICE:
+			flush_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+
+		case DMA_FROM_DEVICE:

arch/arm/include/asm/dma-mapping.h line 93

Quoted 10 lines
arch/arm/include/asm/dma-mapping.h +8 -0
+			invalidate_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+		}
+	}
+	return virt_to_phys((void *)vaddr);
+#else
 	return (unsigned long)vaddr;
+#endif
 }

Here we have such a #else/#endif, which makes sure non-Farady boards are unaffected.

Quoted 38 lines
arch/arm/include/asm/dma-mapping.h +0 -0
 static inline void dma_unmap_single(volatile void *vaddr, size_t len,
arch/arm/include/asm/global_data.h +4 -0
index 37ac0da..bd18ff7 100644
@@ -38,6 +38,10 @@ struct arch_global_data {
 	unsigned long	pllb_rate_hz;
 	unsigned long	at91_pllb_usb_init;
 #endif
+#ifdef CONFIG_FARADAY
+	unsigned long   cpu_id;
+	unsigned long   cpu_mmu;	/* has mmu */
+#endif
 	/* "static data" needed by most of timer.c on ARM platforms */
 	unsigned long timer_rate_hz;
 	unsigned long tbu;
arch/arm/include/asm/io.h +3 -0
index 1fbc531..17d8898 100644
@@ -2,6 +2,7 @@
  *  linux/include/asm-arm/io.h
  *
  *  Copyright (C) 1996-2000 Russell King
+ *  Copyright (C) 2009-2010 Dante Su <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -23,6 +24,8 @@
 #ifdef __KERNEL__
 
 #include <linux/types.h>
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
 #include <asm/byteorder.h>
 #include <asm/memory.h>
 #if 0	/* XXX###XXX */

arch/arm/include/asm/io.h static inline void unmap_physmem(void *vaddr, unsigned long flags) · line 69

Quoted 10 lines
arch/arm/include/asm/io.h +7 -0
@@ -57,9 +60,88 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
+#ifdef CONFIG_FARADAY
+
+# ifndef CONFIG_SYS_DCACHE_OFF
+
+static inline ulong uncached_base(volatile gd_t *gd)
+{
+	return (4096 - (gd->ram_size >> 20)) << 20;

Symbolic constants or a comment would not hurt here.

Quoted 179 lines
arch/arm/include/asm/io.h +73 -1
+}
+# endif
+
+static inline void *virt_to_cached(void *va)
+{
+# ifndef CONFIG_SYS_DCACHE_OFF
+	DECLARE_GLOBAL_DATA_PTR;
+	ulong base = uncached_base(gd);
+
+	if (!gd->arch.cpu_mmu)
+		return va;
+
+	if ((ulong)va >= base &&
+		(ulong)va < (base + gd->ram_size))
+		va = (void *)((ulong)va - base + CONFIG_SYS_SDRAM_BASE);
+# endif	/* !CONFIG_SYS_DCACHE_OFF */
+
+	return va;
+}
+
+static inline void *virt_to_uncached(void *va)
+{
+# ifndef CONFIG_SYS_DCACHE_OFF
+	DECLARE_GLOBAL_DATA_PTR;
+	ulong base = uncached_base(gd);
+
+	if (!gd->arch.cpu_mmu)
+		return va;
+
+#  ifdef CONFIG_USE_IRQ
+	if ((ulong)va < SZ_1M)
+		return (void *)(base + (ulong)va);
+#  endif
+
+	if ((ulong)va >= CONFIG_SYS_SDRAM_BASE &&
+		(ulong)va < (CONFIG_SYS_SDRAM_BASE + gd->ram_size))
+		va = (void *)(base + ((ulong)va - CONFIG_SYS_SDRAM_BASE));
+# endif	/* !CONFIG_SYS_DCACHE_OFF */
+
+	return va;
+}
+
+#endif	/* CONFIG_FARADAY */
+
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
-	return (phys_addr_t)(vaddr);
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+
+	DECLARE_GLOBAL_DATA_PTR;
+	bd_t *bd = gd->bd;
+	ulong base = uncached_base(gd);
+	ulong phys = (ulong)vaddr;
+
+	if (!gd->arch.cpu_mmu)
+		return (phys_addr_t)phys;
+
+	if (phys >= base) {
+		ulong bank;
+		ulong off = phys - base;
+		for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; ++bank) {
+			if (bd->bi_dram[bank].size > off)
+				break;
+			off -= bd->bi_dram[bank].size;
+		}
+		phys = bd->bi_dram[bank].start + off;
+	}
+# ifdef CONFIG_USE_IRQ
+	else if (phys < SZ_1M && bd->bi_dram[0].start != 0)
+		phys = bd->bi_dram[0].start + phys;
+# endif
+
+	return (phys_addr_t)phys;
+#else
+	return (phys_addr_t)vaddr;
+#endif
 }
 
 /*
arch/arm/lib/cache-cp15.c +42 -0
index 4abe1cf..eee8585 100644
@@ -1,6 +1,8 @@
 /*
  * (C) Copyright 2002
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -87,6 +89,10 @@ __weak void dram_bank_mmu_setup(int bank)
 {
 	bd_t *bd = gd->bd;
 	int	i;
+#ifdef CONFIG_FARADAY
+	ulong ubase, off;
+	u32 *page_table = (u32 *)gd->arch.tlb_addr;
+#endif
 
 	debug("%s: bank: %d\n", __func__, bank);
 	for (i = bd->bi_dram[bank].start >> 20;
@@ -98,6 +104,32 @@ __weak void dram_bank_mmu_setup(int bank)
 		set_section_dcache(i, DCACHE_WRITEBACK);
 #endif
 	}
+#ifdef CONFIG_FARADAY
+# ifdef CONFIG_USE_IRQ
+	/* map the exception table to 0x00000000 if necessary */
+	if (bank == 0 && bd->bi_dram[bank].start != 0) {
+		u32 pa = bd->bi_dram[bank].start;
+#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
+		page_table[0] = pa | (3 << 10) | DCACHE_WRITETHROUGH;
+#else
+		page_table[0] = pa | (3 << 10) | DCACHE_WRITEBACK;
+#endif
+	}
+# endif
+	/* calculate address offset */
+	off  = 0;
+	for (i = 0; i < bank; ++i)
+		off += bd->bi_dram[bank].size;
+
+	/* create memory map */
+	ubase = (4096 - (gd->ram_size >> 20)) << 20;
+	for (i = 0; i < bd->bi_dram[bank].size >> 20; ++i) {
+		u32 pa = bd->bi_dram[bank].start + (i << 20);
+		/* create un-cached address map */
+		u32 va = ubase + off + (i << 20);
+		page_table[va >> 20] = pa | (3 << 10) | DCACHE_OFF;
+	}
+#endif
 }
 
 /* to activate the MMU we need to set up virtual memory: use 1M areas */
@@ -126,6 +158,10 @@ static inline void mmu_setup(void)
 
 	/* and enable the mmu */
 	reg = get_cr();	/* get control reg. */
+#ifdef CONFIG_FARADAY
+	reg |= CR_W;	/* enable write buffer */
+	reg |= CR_Z;	/* enable branch prediction */
+#endif
 	cp_delay();
 	set_cr(reg | CR_M);
 }
@@ -140,9 +176,15 @@ static void cache_enable(uint32_t cache_bit)
 {
 	uint32_t reg;
 
+#ifdef CONFIG_FARADAY
+	if (!gd->arch.cpu_mmu && (cache_bit == CR_C))
+		return;
+#endif
+
 	/* The data cache is not active unless the mmu is enabled too */
 	if ((cache_bit == CR_C) && !mmu_enabled())
 		mmu_setup();
+
 	reg = get_cr();	/* get control reg. */
 	cp_delay();
 	set_cr(reg | cache_bit);
common/cmd_boot.c +4 -1
index d3836fd..b2477e8 100644
@@ -50,6 +50,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	printf ("## Starting application at 0x%08lX ...\n", addr);
 
+#if defined(__ARM__) && !defined(CONFIG_SYS_DCACHE_OFF)
+	cleanup_before_linux();
+#endif
+
 	/*
 	 * pass address parameter as argv[0] (aka command name),
 	 * and all remaining args
--
Quoted 2 lines

1.7.9.5

Amicalement,

Signature · 1 line
Albert.
#172 lore raw

PATCH v2 11/12 arm: add MMU/d-cache support for Faraday cores

2013/4/19 Albert ARIBAUD <[email protected]>:

Quoted 34 lines

Hi Kuo-Jung,

Quoted 27 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This patch would enable MMU for Faraday ARMv5TE cores.

Here is the abstract of this MMU design.

Assume SDRAM memory region starts at 0x10000000, and its size = 0x800000.

0x00000000 +-------------------+

           |                   |
           |     UN-CACHED     |
           |                   |
           |                   |
0x10000000 +-------------------+
           |  CACHED (SDRAM)   | <- It's where data/bss/stack lived.
           |                   |
           |                   |
0x10800000 +-------------------+
           |                   |
           |                   |
           |     UN-CACHED     |
           |                   |
           |                   |
0xFF800000 +-------------------+
           | UN-CACHED (SDRAM) | <- An un-cached shadow of the SDRAM.
           |                   |    dma_alloc_coherent() always returns
           |                   |    an address in this region.
Quoted 1 line

0xFFFFFFFF +-------------------+

Quoted 9 lines

The ASCII map is great for explaining, but I find it a bit big for a commit message. Can you summarize it as lines like

0x00000000-0x0FFFFFFF not cached
0x10000000-0x107FFFFF cached (SDRAM)
...

?

Sure,
it would be updated in that way at next patch.

Quoted 39 lines
Quoted 39 lines
CC Albert Aribaud <[email protected]>
---
 arch/arm/include/asm/dma-mapping.h |   56 ++++++++++++++++++++++--
 arch/arm/include/asm/global_data.h |    4 ++
 arch/arm/include/asm/io.h          |   84 +++++++++++++++++++++++++++++++++++-
 arch/arm/lib/cache-cp15.c          |   42 ++++++++++++++++++
 common/cmd_boot.c                  |    4 ++
 5 files changed, 186 insertions(+), 4 deletions(-)
arch/arm/include/asm/dma-mapping.h +8 -0
index 5bbb0a0..53c4edf 100644
@@ -3,6 +3,9 @@
  * Stelian Pop <[email protected]>
  * Lead Tech Design <www.leadtechdesign.com>
  *
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -24,22 +27,69 @@
 #ifndef __ASM_ARM_DMA_MAPPING_H
 #define __ASM_ARM_DMA_MAPPING_H
 
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <malloc.h>
+
 enum dma_data_direction {
      DMA_BIDIRECTIONAL       = 0,
      DMA_TO_DEVICE           = 1,
      DMA_FROM_DEVICE         = 2,
 };
 
Quoted 9 lines

arch/arm/include/asm/dma-mapping.h line 44

Quoted 5 lines
arch/arm/include/asm/dma-mapping.h +4 -1
-static void *dma_alloc_coherent(size_t len, unsigned long *handle)
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+     DECLARE_GLOBAL_DATA_PTR;

I'd rather have the global data ptr be declared outside any function, and only once.

Got it, thanks

Quoted 23 lines
Quoted 23 lines
arch/arm/include/asm/dma-mapping.h +20 -2
+#endif
+     void *va = memalign(ARCH_DMA_MINALIGN, len);
+
+     if (va && handle)
+             *handle = virt_to_phys(va);
+
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+     if (gd->arch.cpu_mmu) {
+             /* invalidate the buffer, convert to un-cached address */
+             if (va != NULL) {
+                     invalidate_dcache_range((ulong)va, (ulong)va + len);
+                     va = virt_to_uncached(va);
+             }
+     }
+#endif
+
+     return va;
+}
+
+static inline void dma_free_coherent(void *va)
 {
-     *handle = (unsigned long)malloc(len);
-     return (void *)*handle;
Quoted 9 lines

arch/arm/include/asm/dma-mapping.h line 67

Quoted 2 lines
arch/arm/include/asm/dma-mapping.h +1 -0
+     free(virt_to_cached(va));
 }

If I read this correctly, this code changes the semantics of dma_alloc_coherent() for boards other than Faraday-based: before, mempry was simply malloc()ed, now it would be memalign()ed then virt_to_phys()ed. Why not simply keep the previous implementation under a #else...#endif block?

Sorry, it's an accident, I'll have it fixed at next version.

Quoted 70 lines
Quoted 15 lines
arch/arm/include/asm/dma-mapping.h +12 -0
 static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
                                         enum dma_data_direction dir)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+     DECLARE_GLOBAL_DATA_PTR;
+
+     if (gd->arch.cpu_mmu) {
+             switch (dir) {
+             case DMA_BIDIRECTIONAL:
+             case DMA_TO_DEVICE:
+                     flush_dcache_range((ulong)vaddr,
+                             (ulong)vaddr + len);
+                     break;
+
+             case DMA_FROM_DEVICE:

arch/arm/include/asm/dma-mapping.h line 93

Quoted 10 lines
arch/arm/include/asm/dma-mapping.h +8 -0
+                     invalidate_dcache_range((ulong)vaddr,
+                             (ulong)vaddr + len);
+                     break;
+             }
+     }
+     return virt_to_phys((void *)vaddr);
+#else
      return (unsigned long)vaddr;
+#endif
 }

Here we have such a #else/#endif, which makes sure non-Farady boards are unaffected.

Quoted 41 lines
arch/arm/include/asm/dma-mapping.h +0 -0
 static inline void dma_unmap_single(volatile void *vaddr, size_t len,
arch/arm/include/asm/global_data.h +4 -0
index 37ac0da..bd18ff7 100644
@@ -38,6 +38,10 @@ struct arch_global_data {
      unsigned long   pllb_rate_hz;
      unsigned long   at91_pllb_usb_init;
 #endif
+#ifdef CONFIG_FARADAY
+     unsigned long   cpu_id;
+     unsigned long   cpu_mmu;        /* has mmu */
+#endif
      /* "static data" needed by most of timer.c on ARM platforms */
      unsigned long timer_rate_hz;
      unsigned long tbu;
arch/arm/include/asm/io.h +3 -0
index 1fbc531..17d8898 100644
@@ -2,6 +2,7 @@
  *  linux/include/asm-arm/io.h
  *
  *  Copyright (C) 1996-2000 Russell King
+ *  Copyright (C) 2009-2010 Dante Su <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -23,6 +24,8 @@
 #ifdef __KERNEL__
 
 #include <linux/types.h>
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
 #include <asm/byteorder.h>
 #include <asm/memory.h>
 #if 0        /* XXX###XXX */
@@ -57,9 +60,88 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
 
 }
 
Quoted 10 lines

arch/arm/include/asm/io.h static inline void unmap_physmem(void *vaddr, unsigned long flags) · line 69

Quoted 7 lines
arch/arm/include/asm/io.h +7 -0
+#ifdef CONFIG_FARADAY
+
+# ifndef CONFIG_SYS_DCACHE_OFF
+
+static inline ulong uncached_base(volatile gd_t *gd)
+{
+     return (4096 - (gd->ram_size >> 20)) << 20;

Symbolic constants or a comment would not hurt here.

Got it, thanks

Quoted 171 lines
Quoted 171 lines
arch/arm/include/asm/io.h +73 -1
+}
+# endif
+
+static inline void *virt_to_cached(void *va)
+{
+# ifndef CONFIG_SYS_DCACHE_OFF
+     DECLARE_GLOBAL_DATA_PTR;
+     ulong base = uncached_base(gd);
+
+     if (!gd->arch.cpu_mmu)
+             return va;
+
+     if ((ulong)va >= base &&
+             (ulong)va < (base + gd->ram_size))
+             va = (void *)((ulong)va - base + CONFIG_SYS_SDRAM_BASE);
+# endif      /* !CONFIG_SYS_DCACHE_OFF */
+
+     return va;
+}
+
+static inline void *virt_to_uncached(void *va)
+{
+# ifndef CONFIG_SYS_DCACHE_OFF
+     DECLARE_GLOBAL_DATA_PTR;
+     ulong base = uncached_base(gd);
+
+     if (!gd->arch.cpu_mmu)
+             return va;
+
+#  ifdef CONFIG_USE_IRQ
+     if ((ulong)va < SZ_1M)
+             return (void *)(base + (ulong)va);
+#  endif
+
+     if ((ulong)va >= CONFIG_SYS_SDRAM_BASE &&
+             (ulong)va < (CONFIG_SYS_SDRAM_BASE + gd->ram_size))
+             va = (void *)(base + ((ulong)va - CONFIG_SYS_SDRAM_BASE));
+# endif      /* !CONFIG_SYS_DCACHE_OFF */
+
+     return va;
+}
+
+#endif       /* CONFIG_FARADAY */
+
 static inline phys_addr_t virt_to_phys(void * vaddr)
 {
-     return (phys_addr_t)(vaddr);
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+
+     DECLARE_GLOBAL_DATA_PTR;
+     bd_t *bd = gd->bd;
+     ulong base = uncached_base(gd);
+     ulong phys = (ulong)vaddr;
+
+     if (!gd->arch.cpu_mmu)
+             return (phys_addr_t)phys;
+
+     if (phys >= base) {
+             ulong bank;
+             ulong off = phys - base;
+             for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; ++bank) {
+                     if (bd->bi_dram[bank].size > off)
+                             break;
+                     off -= bd->bi_dram[bank].size;
+             }
+             phys = bd->bi_dram[bank].start + off;
+     }
+# ifdef CONFIG_USE_IRQ
+     else if (phys < SZ_1M && bd->bi_dram[0].start != 0)
+             phys = bd->bi_dram[0].start + phys;
+# endif
+
+     return (phys_addr_t)phys;
+#else
+     return (phys_addr_t)vaddr;
+#endif
 }
 
 /*
arch/arm/lib/cache-cp15.c +42 -0
index 4abe1cf..eee8585 100644
@@ -1,6 +1,8 @@
 /*
  * (C) Copyright 2002
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -87,6 +89,10 @@ __weak void dram_bank_mmu_setup(int bank)
 {
      bd_t *bd = gd->bd;
      int     i;
+#ifdef CONFIG_FARADAY
+     ulong ubase, off;
+     u32 *page_table = (u32 *)gd->arch.tlb_addr;
+#endif
 
      debug("%s: bank: %d\n", __func__, bank);
      for (i = bd->bi_dram[bank].start >> 20;
@@ -98,6 +104,32 @@ __weak void dram_bank_mmu_setup(int bank)
              set_section_dcache(i, DCACHE_WRITEBACK);
 #endif
      }
+#ifdef CONFIG_FARADAY
+# ifdef CONFIG_USE_IRQ
+     /* map the exception table to 0x00000000 if necessary */
+     if (bank == 0 && bd->bi_dram[bank].start != 0) {
+             u32 pa = bd->bi_dram[bank].start;
+#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
+             page_table[0] = pa | (3 << 10) | DCACHE_WRITETHROUGH;
+#else
+             page_table[0] = pa | (3 << 10) | DCACHE_WRITEBACK;
+#endif
+     }
+# endif
+     /* calculate address offset */
+     off  = 0;
+     for (i = 0; i < bank; ++i)
+             off += bd->bi_dram[bank].size;
+
+     /* create memory map */
+     ubase = (4096 - (gd->ram_size >> 20)) << 20;
+     for (i = 0; i < bd->bi_dram[bank].size >> 20; ++i) {
+             u32 pa = bd->bi_dram[bank].start + (i << 20);
+             /* create un-cached address map */
+             u32 va = ubase + off + (i << 20);
+             page_table[va >> 20] = pa | (3 << 10) | DCACHE_OFF;
+     }
+#endif
 }
 
 /* to activate the MMU we need to set up virtual memory: use 1M areas */
@@ -126,6 +158,10 @@ static inline void mmu_setup(void)
 
      /* and enable the mmu */
      reg = get_cr(); /* get control reg. */
+#ifdef CONFIG_FARADAY
+     reg |= CR_W;    /* enable write buffer */
+     reg |= CR_Z;    /* enable branch prediction */
+#endif
      cp_delay();
      set_cr(reg | CR_M);
 }
@@ -140,9 +176,15 @@ static void cache_enable(uint32_t cache_bit)
 {
      uint32_t reg;
 
+#ifdef CONFIG_FARADAY
+     if (!gd->arch.cpu_mmu && (cache_bit == CR_C))
+             return;
+#endif
+
      /* The data cache is not active unless the mmu is enabled too */
      if ((cache_bit == CR_C) && !mmu_enabled())
              mmu_setup();
+
      reg = get_cr(); /* get control reg. */
      cp_delay();
      set_cr(reg | cache_bit);
common/cmd_boot.c +0 -0
index d3836fd..b2477e8 100644
@@ -50,6 +50,10 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
      printf ("## Starting application at 0x%08lX ...\n", addr);
 
Quoted 15 lines
Quoted 10 lines
common/cmd_boot.c +4 -1
+#if defined(__ARM__) && !defined(CONFIG_SYS_DCACHE_OFF)
+     cleanup_before_linux();
+#endif
+
      /*
       * pass address parameter as argv[0] (aka command name),
       * and all remaining args
--

1.7.9.5

Amicalement,
--
Albert.

--
Best wishes,
Kuo-Jung Su

#173 lore raw

PATCH v2 12/12 arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday A36x EVB is a Faraday SoC platform evalution board used for Faraday IP functional verification based on the well-known ARM AMBA 2.0 architecture.

Faraday A360 EVB:
CPU: FA626TE
NET: FTMAC110
USB: FUSBH200, FOTG210
LCD: FTLCDC200
I2C: FTI2C010
SPI: FTSSP010 v1.18.0
MMC: FTSDC010
RTC: FTRTC010
WDT: FTWDT010
TMR: FTTMR010
PIC: FTINTC020
UART: FTUART010
NAND: FTNANDC020

Faraday A369 EVB:
CPU: FA626TE(Master)/FA606TE(Slave)
NET: FTGMAC100
USB: FUSBH200, FOTG210
LCD: FTLCDC200
I2C: FTI2C010
SPI: FTSSP010 v1.18.0
MMC: FTSDC010
RTC: FTRTC011
WDT: FTWDT010
TMR: FTPWMTMR010
PIC: FTINTC020
UART: FTUART010
NAND: FTNANDC021

CC Albert Aribaud <[email protected]>
---
 arch/arm/cpu/faraday/Makefile             |   57 ++++
 arch/arm/cpu/faraday/a360/Makefile        |   49 +++
 arch/arm/cpu/faraday/a360/reset.c         |   26 ++
 arch/arm/cpu/faraday/a369/Makefile        |   50 +++
 arch/arm/cpu/faraday/a369/cmd_fa606.c     |   75 +++++
 arch/arm/cpu/faraday/a369/reset.c         |   26 ++
 arch/arm/cpu/faraday/cmd_bootfa.c         |  132 ++++++++
 arch/arm/cpu/faraday/config.mk            |   33 ++
 arch/arm/cpu/faraday/cpu.c                |  238 +++++++++++++
 arch/arm/cpu/faraday/ftintc020.h          |   37 ++
 arch/arm/cpu/faraday/ftpwmtmr010.c        |  156 +++++++++
 arch/arm/cpu/faraday/ftpwmtmr010.h        |   41 +++
 arch/arm/cpu/faraday/fttmr010.c           |  159 +++++++++
 arch/arm/cpu/faraday/fwimage.h            |   38 +++
 arch/arm/cpu/faraday/fwimage2.h           |   70 ++++
 arch/arm/cpu/faraday/interrupts.c         |  155 +++++++++
 arch/arm/cpu/faraday/start.S              |  523 +++++++++++++++++++++++++++++
 arch/arm/cpu/u-boot.lds                   |   11 +
 arch/arm/include/asm/arch-a360/hardware.h |   72 ++++
 arch/arm/include/asm/arch-a369/hardware.h |   98 ++++++
 arch/arm/include/asm/mach-types.h         |    1 +
 board/faraday/a360evb/Makefile            |   49 +++
 board/faraday/a360evb/board.c             |   67 ++++
 board/faraday/a360evb/clk.c               |   52 +++
 board/faraday/a360evb/config.mk           |   33 ++
 board/faraday/a360evb/lowlevel_init.S     |   33 ++
 board/faraday/a369evb/Makefile            |   49 +++
 board/faraday/a369evb/board.c             |  178 ++++++++++
 board/faraday/a369evb/clk.c               |   81 +++++
 board/faraday/a369evb/config.mk           |   33 ++
 board/faraday/a369evb/lowlevel_init.S     |  136 ++++++++
 boards.cfg                                |    3 +
 include/common.h                          |   13 +
 include/configs/a360.h                    |  185 ++++++++++
 include/configs/a369.h                    |   41 +++
 include/configs/a369_defaults.h           |  295 ++++++++++++++++
 include/configs/a369_fa606te.h            |   32 ++
 include/faraday/fttmr010.h                |   17 +
 38 files changed, 3344 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/reset.c
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/cpu/faraday/a369/reset.c
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/ftintc020.h
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.h
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
 create mode 100644 arch/arm/cpu/faraday/interrupts.c
 create mode 100644 arch/arm/cpu/faraday/start.S
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clk.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clk.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_defaults.h
 create mode 100644 include/configs/a369_fa606te.h
arch/arm/cpu/faraday/Makefile new file +57 -0
new file mode 100644
index 0000000..fb712a1
@@ -0,0 +1,57 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+src-y						:= interrupts.o
+src-$(CONFIG_FTPWMTMR010)	+= ftpwmtmr010.o
+src-$(CONFIG_FTTMR010)		+= fttmr010.o
+
+START	= start.o
+COBJS	= cpu.o cmd_bootfa.o $(src-y)
+
+ifdef	CONFIG_SPL_BUILD
+ifdef	CONFIG_SPL_NO_CPU_SUPPORT_CODE
+START	:=
+endif
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/faraday/a360/Makefile new file +49 -0

49 lines not on this page · raw message

arch/arm/cpu/faraday/a360/reset.c new file +26 -0
new file mode 100644
index 0000000..ea2db58
@@ -0,0 +1,26 @@
+/*
+ * arch/arm/cpu/faraday/a360/reset.c
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <faraday/ftwdt010_wdt.h>
+
+#define WDT_READ(r)		le32_to_cpu(readl(r))
+#define WDT_WRITE(v, r)	writel(cpu_to_le32(v), r)
+
+void reset_cpu(unsigned long ignored)
+{
+	struct ftwdt010_wdt *regs = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
+
+	WDT_WRITE(0, &regs->wdcr);
+	WDT_WRITE(1000, &regs->wdload);
+	WDT_WRITE(FTWDT010_WDCR_ENABLE | FTWDT010_WDCR_RST, &regs->wdcr);
+	WDT_WRITE(FTWDT010_WDRESTART_MAGIC, &regs->wdrestart);
+}
arch/arm/cpu/faraday/a369/Makefile new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/faraday/a369/cmd_fa606.c new file +75 -0

75 lines not on this page · raw message

arch/arm/cpu/faraday/a369/reset.c new file +26 -0
new file mode 100644
index 0000000..5bb37d5
@@ -0,0 +1,26 @@
+/*
+ * arch/arm/cpu/faraday/a369/reset.c
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <faraday/ftwdt010_wdt.h>
+
+#define WDT_READ(r)		le32_to_cpu(readl(r))
+#define WDT_WRITE(v, r)	writel(cpu_to_le32(v), r)
+
+void reset_cpu(unsigned long ignored)
+{
+	struct ftwdt010_wdt *regs = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
+
+	WDT_WRITE(0, &regs->wdcr);
+	WDT_WRITE(1000, &regs->wdload);
+	WDT_WRITE(FTWDT010_WDCR_ENABLE | FTWDT010_WDCR_RST, &regs->wdcr);
+	WDT_WRITE(FTWDT010_WDRESTART_MAGIC, &regs->wdrestart);
+}
arch/arm/cpu/faraday/cmd_bootfa.c new file +132 -0

132 lines not on this page · raw message

arch/arm/cpu/faraday/config.mk new file +33 -0
new file mode 100644
index 0000000..ffb2e6c
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2002
+# Gary Jennejohn, DENX Software Engineering, <[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
+#
+
+PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
+
+PLATFORM_CPPFLAGS += -march=armv5te
+# =========================================================================
+#
+# Supply options according to compiler version
+#
+# =========================================================================
+PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
+PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)
arch/arm/cpu/faraday/cpu.c new file +238 -0

238 lines not on this page · raw message

arch/arm/cpu/faraday/ftintc020.h new file +37 -0
new file mode 100644
index 0000000..e23d1e7
@@ -0,0 +1,37 @@
+/*
+ * arch/arm/cpu/faraday/ftintc020.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FTINTC020_H
+#define ARCH_ARM_CPU_FARADAY_FTINTC020_H
+
+struct ftintc020_pic_regs {
+	uint32_t src; /* source register */
+	uint32_t ena; /* enable register */
+	uint32_t scr; /* status clear register */
+	uint32_t tmr; /* trigger mode register */
+	uint32_t tlr; /* trigger level register */
+	uint32_t sr;  /* status register */
+	uint32_t rsvd[2];
+};
+
+struct ftintc020_regs {
+	/* IRQ/FIQ:  0 ~ 31 */
+	struct ftintc020_pic_regs irq32; /* 0x00 - 0x1C: IRQ 0 ~ 31 */
+	struct ftintc020_pic_regs fiq32; /* 0x20 - 0x3C: FIQ 0 ~ 31 */
+	uint32_t rsvd1[4];               /* 0x40 - 0x4C: Reserved */
+	uint32_t revision;               /* 0x50: Revision Register */
+	uint32_t feature;                /* 0x54: Feature Register */
+	uint32_t rsvd2[2];               /* 0x58 - 0x5C: Reserved */
+	/* IRQ/FIQ: 32 ~ 63 */
+	struct ftintc020_pic_regs irq64; /* 0x60 - 0x7C: IRQ 32 ~ 63 */
+	struct ftintc020_pic_regs fiq64; /* 0x80 - 0x9C: FIQ 32 ~ 63 */
+};
+
+#endif
arch/arm/cpu/faraday/ftpwmtmr010.c new file +156 -0

156 lines not on this page · raw message

arch/arm/cpu/faraday/ftpwmtmr010.h new file +41 -0

41 lines not on this page · raw message

arch/arm/cpu/faraday/fttmr010.c new file +159 -0

159 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage.h new file +38 -0
new file mode 100644
index 0000000..af4f2f9
@@ -0,0 +1,38 @@
+/*
+ * arch/arm/cpu/faraday/fwimage.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FWIMAGE_H
+#define ARCH_ARM_CPU_FARADAY_FWIMAGE_H
+
+struct fwparam {
+	uint32_t	count;
+	uint32_t	version; /* ycmo100525: for firmware image version */
+	uint32_t	addr[31];
+	uint32_t	data[31];
+};
+
+struct fwfile {
+	char		name[64];
+	uint32_t	size;
+	/* uint32_t	block[1]; */
+};
+
+struct fwimage {
+	/* 8 bytes */
+	uint32_t		magic;	/* Magic number */
+	uint32_t		length;	/* It shall not be greater than 2048 */
+
+	/* 256 bytes, embedded paramters area */
+	struct fwparam	param;
+
+	struct fwfile	file[1];
+};
+
+#endif
arch/arm/cpu/faraday/fwimage2.h new file +70 -0

70 lines not on this page · raw message

arch/arm/cpu/faraday/interrupts.c new file +155 -0

155 lines not on this page · raw message

arch/arm/cpu/faraday/start.S new file +523 -0

523 lines not on this page · raw message

arch/arm/cpu/u-boot.lds +11 -0
index d9bbee3..ac59fec 100644
@@ -23,6 +23,8 @@
  * MA 02111-1307 USA
  */
 
+#include <config.h>
+
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -35,6 +37,15 @@ SECTIONS
 	{
 		__image_copy_start = .;
 		CPUDIR/start.o (.text*)
+#ifdef CONFIG_FARADAY
+		/*
+		 * Dante Su 2012.10.09:
+		 * Reserved for the faimage v2.1.
+		 * 1. CPUDIR/start.o: It shall never be > 4KB.
+		 * 2. faimage header: It shall always be stored at 0x1000, and <= 1KB.
+		 */
+		. = 0x00001400;
+#endif
 		*(.text*)
 	}
 
arch/arm/include/asm/arch-a360/hardware.h new file +72 -0

72 lines not on this page · raw message

arch/arm/include/asm/arch-a369/hardware.h new file +98 -0

98 lines not on this page · raw message

arch/arm/include/asm/mach-types.h +1 -0
index 440b041..a103922 100644
@@ -144,6 +144,7 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_AKITA                744
 #define MACH_TYPE_E330                 753
 #define MACH_TYPE_NOKIA770             755
+#define MACH_TYPE_FARADAY              758
 #define MACH_TYPE_CARMEVA              769
 #define MACH_TYPE_EDB9315A             772
 #define MACH_TYPE_STARGATE2            774
board/faraday/a360evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a360evb/board.c new file +67 -0

67 lines not on this page · raw message

board/faraday/a360evb/clk.c new file +52 -0

52 lines not on this page · raw message

board/faraday/a360evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a360evb/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000..1ead608
@@ -0,0 +1,33 @@
+/*
+ * Board specific setup info
+ *
+ * (C) Copyright 2010
+ * Faraday Technology Inc. <www.faraday-tech.com>
+ * Dante Su <[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 <version.h>
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+	mov	pc,lr
board/faraday/a369evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a369evb/board.c new file +178 -0

178 lines not on this page · raw message

board/faraday/a369evb/clk.c new file +81 -0

81 lines not on this page · raw message

board/faraday/a369evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a369evb/lowlevel_init.S new file +136 -0

136 lines not on this page · raw message

boards.cfg +3 -0
index f785da8..e2de722 100644
@@ -73,6 +73,9 @@ mini2440                     arm         arm920t     mini2440            friendl
 VCMA9                        arm         arm920t     vcma9               mpl            s3c24x0
 smdk2410                     arm         arm920t     -                   samsung        s3c24x0
 omap1510inn                  arm         arm925t     -                   ti
+a360                         arm         faraday     a360evb             faraday        a360
+a369                         arm         faraday     a369evb             faraday        a369
+a369_fa606te                 arm         faraday     a369evb             faraday        a369
 integratorap_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorap:CM926EJ_S
 integratorcp_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorcp:CM924EJ_S
 aspenite                     arm         arm926ejs   -                   Marvell        armada100
include/common.h +13 -0
index 0cfa6a8..fa134f3 100644
@@ -112,6 +112,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_SOC_DA8XX
 #include <asm/arch/hardware.h>
 #endif
+#ifdef CONFIG_FARADAY
+#include <asm/arch/hardware.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
@@ -257,6 +260,16 @@ typedef void (interrupt_handler_t)(void *);
 	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
+#ifdef CONFIG_FARADAY
+/* board/faraday/xxx/clk.c */
+extern ulong clk_get_rate(char *id);
+
+/* arch/arm/cpu/faraday/xxx/interrupt.c */
+extern void irq_set_trigger(int irq, int edge, int low);
+extern void irq_enable(int irq);
+extern void irq_disable(int irq);
+#endif
+
 /*
  * Function Prototypes
  */
include/configs/a360.h new file +185 -0

185 lines not on this page · raw message

include/configs/a369.h new file +41 -0

5 lines not on this page · raw message

include/configs/a369_defaults.h new file +295 -0

295 lines not on this page · raw message

include/configs/a369_fa606te.h new file +32 -0
new file mode 100644
index 0000000..8c90fd8

Lines of this file are not shown. View the raw message.

include/faraday/fttmr010.h +17 -0
index 72abcb3..ef10f31 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

--
1.7.9.5

Part of the diff is not shown here. View the raw message.

#174 lore raw

PATCH v2 12/12 arm: add Faraday A36x SoC platform support

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

include/configs/a360.h line 123

Quoted 5 lines
include/configs/a360.h new file +5 -0
+#define CONFIG_FTMAC110        1
+#define CONFIG_ETHADDR         00:84:14:72:61:69 /* used by env_common.c */
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_IPADDR          10.0.0.123
+#define CONFIG_SERVERIP        10.0.0.128

NAK. We don't allow static global network configurations like that.

include/configs/a369_defaults.h line 121

Quoted 7 lines
include/configs/a369_defaults.h new file +7 -0
+#define CONFIG_FTGMAC100       1
+#define CONFIG_PHY_MAX_ADDR    32 /* used by Ratbert's ftgmac100 only */
+#define CONFIG_FTGMAC100_EGIGA 1  /* used by Ratbert's ftgmac100 only */
+#define CONFIG_ETHADDR         00:84:14:72:61:69 /* used by env_common.c */
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_IPADDR          10.0.0.123
+#define CONFIG_SERVERIP        10.0.0.128

NAK again.

Hm... this looks like a LOT of repeated code. Can you please factor out the common parts into a separate file?

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Vulcans worship peace above all.
	-- McCoy, "Return to Tomorrow", stardate 4768.3
#175 lore raw

PATCH v2 12/12 arm: add Faraday A36x SoC platform support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 4 lines

Dear Kuo-Jung Su,

In message <[email protected]> you wrote:
...

Quoted 9 lines

include/configs/a360.h line 123

Quoted 5 lines
include/configs/a360.h new file +5 -0
+#define CONFIG_FTMAC110        1
+#define CONFIG_ETHADDR         00:84:14:72:61:69 /* used by env_common.c */
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_IPADDR          10.0.0.123
+#define CONFIG_SERVERIP        10.0.0.128

NAK. We don't allow static global network configurations like that.

Got it, thanks

Quoted 10 lines

include/configs/a369_defaults.h line 121

Quoted 7 lines
include/configs/a369_defaults.h new file +7 -0
+#define CONFIG_FTGMAC100       1
+#define CONFIG_PHY_MAX_ADDR    32 /* used by Ratbert's ftgmac100 only */
+#define CONFIG_FTGMAC100_EGIGA 1  /* used by Ratbert's ftgmac100 only */
+#define CONFIG_ETHADDR         00:84:14:72:61:69 /* used by env_common.c */
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_IPADDR          10.0.0.123
+#define CONFIG_SERVERIP        10.0.0.128

NAK again.

Quoted 4 lines

Hm... this looks like a LOT of repeated code. Can you please factor out the common parts into a separate file?

Sure, I'll define a common file for these stuff at next patch.

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Vulcans worship peace above all.

        -- McCoy, "Return to Tomorrow", stardate 4768.3

--
Best wishes,
Kuo-Jung Su

#176 lore raw

v2 cover arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

Dear Kuo-Jung Su,

Quoted 2 lines · In message <[email protected]> you wrote:

These patches introduce Faraday A36x SoC platform support.

Please run all your patches through checkpatch and clean up thew reported warnings and errors before you resubmit.

Best regards,

Wolfgang Denk

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-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The algorithm to do that is extremely nasty. You might want  to  mug
someone with it."                   - M. Devine, Computer Science 340
#177 lore raw

v2 cover arm: add Faraday A36x SoC platform support

2013/4/18 Wolfgang Denk <[email protected]>:

Quoted 9 lines

Dear Kuo-Jung Su,

Quoted 2 lines · In message <[email protected]> you wrote:

These patches introduce Faraday A36x SoC platform support.

Please run all your patches through checkpatch and clean up thew reported warnings and errors before you resubmit.

Got it, thanks

Quoted 10 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "The algorithm to do that is extremely nasty. You might want to mug
someone with it." - M. Devine, Computer Science 340

--
Best wishes,
Kuo-Jung Su

#178 lore raw

PATCH 2/11 net/ftgmac100: add MMU/D-cache support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

---
 drivers/net/ftgmac100.c |   83 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 56 insertions(+), 27 deletions(-)
drivers/net/ftgmac100.c +56 -27
index 69ba57d..0169a42 100644
@@ -7,6 +7,9 @@
  * (C) Copyright 2010 Andes Technology
  * Macpaul Lin <[email protected]>
  *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
  * 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
@@ -28,20 +31,25 @@
 #include <net.h>
 #include <asm/io.h>
 #include <linux/mii.h>
+#include <asm/dma-mapping.h>
 
 #include "ftgmac100.h"
 
-#define ETH_ZLEN	60
+#define CFG_XBUF_SIZE		1536
+
+#define ETH_ZLEN			60
 
 /* RBSR - hw default init value is also 0x640 */
 #define RBSR_DEFAULT_VALUE	0x640
 
 /* PKTBUFSTX/PKTBUFSRX must both be power of 2 */
-#define PKTBUFSTX	4	/* must be power of 2 */
+#define PKTBUFSTX			4	/* must be power of 2 */
 
 struct ftgmac100_data {
-	struct ftgmac100_txdes txdes[PKTBUFSTX];
-	struct ftgmac100_rxdes rxdes[PKTBUFSRX];
+	ulong txdes_dma;
+	struct ftgmac100_txdes *txdes;
+	ulong rxdes_dma;
+	struct ftgmac100_rxdes *rxdes;
 	int tx_index;
 	int rx_index;
 	int phy_addr;
@@ -375,13 +383,32 @@ static int ftgmac100_init(struct eth_device *dev, bd_t *bd)
 {
 	struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
 	struct ftgmac100_data *priv = dev->priv;
-	struct ftgmac100_txdes *txdes = priv->txdes;
-	struct ftgmac100_rxdes *rxdes = priv->rxdes;
+	struct ftgmac100_txdes *txdes;
+	struct ftgmac100_rxdes *rxdes;
 	unsigned int maccr;
+	void *buf;
 	int i;
 
 	debug("%s()\n", __func__);
 
+	if (!priv->txdes) {
+		txdes = dma_alloc_coherent(sizeof(*txdes) * PKTBUFSTX, &priv->txdes_dma);
+		if (!txdes)
+			panic("ftgmac100: out of memory\n");
+		memset(txdes, 0, sizeof(*txdes) * PKTBUFSTX);
+		priv->txdes = txdes;
+	}
+	txdes = priv->txdes;
+
+	if (!priv->rxdes) {
+		rxdes = dma_alloc_coherent(sizeof(*rxdes) * PKTBUFSRX, &priv->rxdes_dma);
+		if (!rxdes)
+			panic("ftgmac100: out of memory\n");
+		memset(rxdes, 0, sizeof(*rxdes) * PKTBUFSRX);
+		priv->rxdes = rxdes;
+	}
+	rxdes = priv->rxdes;
+
 	/* set the ethernet address */
 	ftgmac100_set_mac_from_env(dev);
 
@@ -397,21 +424,31 @@ static int ftgmac100_init(struct eth_device *dev, bd_t *bd)
 
 	for (i = 0; i < PKTBUFSTX; i++) {
 		/* TXBUF_BADR */
-		txdes[i].txdes3 = 0;
+		if (!txdes[i].txdes2) {
+			buf = memalign(64, CFG_XBUF_SIZE);
+			if (!buf)
+				panic("ftgmac100: out of memory\n");
+			txdes[i].txdes3 = virt_to_phys(buf);
+			txdes[i].txdes2 = (uint)buf;
+		}
 		txdes[i].txdes1 = 0;
 	}
 
 	for (i = 0; i < PKTBUFSRX; i++) {
 		/* RXBUF_BADR */
-		rxdes[i].rxdes3 = (unsigned int)NetRxPackets[i];
+		if (!rxdes[i].rxdes2) {
+			buf = NetRxPackets[i];
+			rxdes[i].rxdes3 = virt_to_phys(buf);
+			rxdes[i].rxdes2 = (uint)buf;
+		}
 		rxdes[i].rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY;
 	}
 
 	/* transmit ring */
-	writel((unsigned int)txdes, &ftgmac100->txr_badr);
+	writel(priv->txdes_dma, &ftgmac100->txr_badr);
 
 	/* receive ring */
-	writel((unsigned int)rxdes, &ftgmac100->rxr_badr);
+	writel(priv->rxdes_dma, &ftgmac100->rxr_badr);
 
 	/* poll receive descriptor automatically */
 	writel(FTGMAC100_APTC_RXPOLL_CNT(1), &ftgmac100->aptc);
@@ -466,8 +503,11 @@ static int ftgmac100_recv(struct eth_device *dev)
 	debug("%s(): RX buffer %d, %x received\n",
 	       __func__, priv->rx_index, rxlen);
 
+	/* invalidate d-cache */
+	dma_map_single((void *)curr_des->rxdes2, rxlen, DMA_FROM_DEVICE);
+
 	/* pass the packet up to the protocol layers. */
-	NetReceive((void *)curr_des->rxdes3, rxlen);
+	NetReceive((void *)curr_des->rxdes2, rxlen);
 
 	/* release buffer to DMA */
 	curr_des->rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY;
@@ -485,7 +525,6 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 	struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
 	struct ftgmac100_data *priv = dev->priv;
 	struct ftgmac100_txdes *curr_des = &priv->txdes[priv->tx_index];
-	int start;
 
 	if (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) {
 		debug("%s(): no TX descriptor available\n", __func__);
@@ -496,28 +535,18 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 
 	length = (length < ETH_ZLEN) ? ETH_ZLEN : length;
 
-	/* initiate a transmit sequence */
-	curr_des->txdes3 = (unsigned int)packet;	/* TXBUF_BADR */
+	memcpy((void *)curr_des->txdes2, (void *)packet, length);
+	dma_map_single((void *)curr_des->txdes2, length, DMA_TO_DEVICE);
 
-	/* only one descriptor on TXBUF */
 	curr_des->txdes0 &= FTGMAC100_TXDES0_EDOTR;
 	curr_des->txdes0 |= FTGMAC100_TXDES0_FTS |
-			    FTGMAC100_TXDES0_LTS |
-			    FTGMAC100_TXDES0_TXBUF_SIZE(length) |
-			    FTGMAC100_TXDES0_TXDMA_OWN ;
+				FTGMAC100_TXDES0_LTS |
+				FTGMAC100_TXDES0_TXBUF_SIZE(length) |
+				FTGMAC100_TXDES0_TXDMA_OWN ;
 
 	/* start transmit */
 	writel(1, &ftgmac100->txpd);
 
-	/* wait for transfer to succeed */
-	start = get_timer(0);
-	while (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) {
-		if (get_timer(0) >= 5) {
-			debug("%s(): timed out\n", __func__);
-			return -1;
-		}
-	}
-
 	debug("%s(): packet sent\n", __func__);
 
 	priv->tx_index = (priv->tx_index + 1) % PKTBUFSTX;

--
1.7.9.5

#179 lore raw

PATCH 3/11 net: add FTMAC110 10/100Mbps ethernet support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTMAC110 10/100Mbps supports half-word data transfer for Linux. However it has a weird DMA alignment issue:

(1) Tx DMA Buffer Address:
1 bytes aligned: Invalid
2 bytes aligned: O.K
4 bytes aligned: O.K

(2) Rx DMA Buffer Address:
1 bytes aligned: Invalid
2 bytes aligned: O.K
4 bytes aligned: Invalid!!!

---
 drivers/net/Makefile   |    1 +
 drivers/net/ftmac110.c |  484 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftmac110.h |  131 +++++++++++++
 3 files changed, 616 insertions(+)
 create mode 100644 drivers/net/ftmac110.c
 create mode 100644 drivers/net/ftmac110.h
drivers/net/Makefile +1 -0
index 786a656..0e23817 100644
@@ -46,6 +46,7 @@ COBJS-$(CONFIG_ETHOC) += ethoc.o
 COBJS-$(CONFIG_FEC_MXC) += fec_mxc.o
 COBJS-$(CONFIG_FSLDMAFEC) += fsl_mcdmafec.o mcfmii.o
 COBJS-$(CONFIG_FTGMAC100) += ftgmac100.o
+COBJS-$(CONFIG_FTMAC110) += ftmac110.o
 COBJS-$(CONFIG_FTMAC100) += ftmac100.o
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
drivers/net/ftmac110.c new file +484 -0

484 lines not on this page · raw message

drivers/net/ftmac110.h new file +131 -0

131 lines not on this page · raw message

--
1.7.9.5

#180 lore raw

PATCH 4/11 usb-ehci: add Faraday USB 2.0 EHCI controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This patch add supports to both Faraday FUSBH200 and FOTG210, these controllers slightly differ from standard EHCI specification.

---
 common/usb_hub.c                |    5 ++
 drivers/usb/host/Makefile       |    1 +
 drivers/usb/host/ehci-faraday.c |  157 +++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/ehci-hcd.c     |   11 +++
 drivers/usb/host/ehci.h         |    5 ++
 5 files changed, 179 insertions(+)
 create mode 100644 drivers/usb/host/ehci-faraday.c
common/usb_hub.c +5 -0
index b5eeb62..099696e 100644
@@ -375,6 +375,11 @@ static int usb_hub_configure(struct usb_device *dev)
 		return -1;
 	}
 
+#ifdef CONFIG_USB_EHCI_FARADAY
+	/* dante: fusbh200 requires a long long delay ... */
+	mdelay(250);
+#endif
+
 	if (usb_get_hub_status(dev, buffer) < 0) {
 		USB_HUB_PRINTF("usb_hub_configure: failed to get Status %lX\n",
 				dev->status);
drivers/usb/host/Makefile +1 -0
index 9a6f982..d5577bd 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_USB_EHCI_FSL) += ehci-mpc512x.o
 else
 COBJS-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o
 endif
+COBJS-$(CONFIG_USB_EHCI_FARADAY) += ehci-faraday.o
 COBJS-$(CONFIG_USB_EHCI_EXYNOS) += ehci-exynos.o
 COBJS-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
 COBJS-$(CONFIG_USB_EHCI_MXS) += ehci-mxs.o
drivers/usb/host/ehci-faraday.c new file +157 -0

157 lines not on this page · raw message

drivers/usb/host/ehci-hcd.c +11 -0
index c816878..450d217 100644
@@ -149,8 +149,10 @@ static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec)
 static int ehci_reset(int index)
 {
 	uint32_t cmd;
+#ifndef CONFIG_USB_EHCI_FARADAY
 	uint32_t tmp;
 	uint32_t *reg_ptr;
+#endif
 	int ret = 0;
 
 	cmd = ehci_readl(&ehcic[index].hcor->or_usbcmd);
@@ -163,6 +165,7 @@ static int ehci_reset(int index)
 		goto out;
 	}
 
+#ifndef CONFIG_USB_EHCI_FARADAY
 	if (ehci_is_TDI()) {
 		reg_ptr = (uint32_t *)((u8 *)ehcic[index].hcor + USBMODE);
 		tmp = ehci_readl(reg_ptr);
@@ -172,6 +175,7 @@ static int ehci_reset(int index)
 #endif
 		ehci_writel(reg_ptr, tmp);
 	}
+#endif	/* !CONFIG_USB_EHCI_FARADAY */
 
 #ifdef CONFIG_USB_EHCI_TXFIFO_THRESH
 	cmd = ehci_readl(&ehcic[index].hcor->or_txfilltuning);
@@ -711,6 +715,9 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 			tmpbuf[1] |= USB_PORT_STAT_POWER >> 8;
 
 		if (ehci_is_TDI()) {
+#ifdef CONFIG_USB_EHCI_FARADAY
+			tmpbuf[1] |= ehci_hcd_port_speed(ctrl->hccr) >> 8;
+#else
 			switch (PORTSC_PSPD(reg)) {
 			case PORTSC_PSPD_FS:
 				break;
@@ -722,6 +729,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 				tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
 				break;
 			}
+#endif
 		} else {
 			tmpbuf[1] |= USB_PORT_STAT_HIGH_SPEED >> 8;
 		}
@@ -950,10 +958,13 @@ int usb_lowlevel_init(int index, void **controller)
 	cmd |= CMD_RUN;
 	ehci_writel(&ehcic[index].hcor->or_usbcmd, cmd);
 
+#ifndef CONFIG_USB_EHCI_FARADAY
 	/* take control over the ports */
 	cmd = ehci_readl(&ehcic[index].hcor->or_configflag);
 	cmd |= FLAG_CF;
 	ehci_writel(&ehcic[index].hcor->or_configflag, cmd);
+#endif
+
 	/* unblock posted write */
 	cmd = ehci_readl(&ehcic[index].hcor->or_usbcmd);
 	mdelay(5);
drivers/usb/host/ehci.h +5 -0
index d090f0a..9309ede 100644
@@ -82,6 +82,7 @@ struct ehci_hcor {
 	uint32_t or_periodiclistbase;
 	uint32_t or_asynclistaddr;
 	uint32_t _reserved_0_;
+#ifndef CONFIG_USB_EHCI_FARADAY
 	uint32_t or_burstsize;
 	uint32_t or_txfilltuning;
 #define TXFIFO_THRESH_MASK		(0x3f << 16)
@@ -89,6 +90,7 @@ struct ehci_hcor {
 	uint32_t _reserved_1_[6];
 	uint32_t or_configflag;
 #define FLAG_CF		(1 << 0)	/* true:  we'll support "high speed" */
+#endif  /* #ifndef CONFIG_USB_EHCI_FARADAY */
 	uint32_t or_portsc[CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS];
 #define PORTSC_PSPD(x)		(((x) >> 26) & 0x3)
 #define PORTSC_PSPD_FS			0x0
@@ -255,5 +257,8 @@ struct QH {
 /* Low level init functions */
 int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor);
 int ehci_hcd_stop(int index);
+#ifdef CONFIG_USB_EHCI_FARADAY
+int ehci_hcd_port_speed(struct ehci_hccr *hccr);
+#endif
 
 #endif /* USB_EHCI_H */

--
1.7.9.5

#181 lore raw

PATCH 4/11 usb-ehci: add Faraday USB 2.0 EHCI controller support

Dear Kuo-Jung Su,

Quoted 6 lines

From: Kuo-Jung Su <[email protected]>

This patch add supports to both Faraday FUSBH200 and FOTG210, these controllers slightly differ from standard EHCI specification.

You want to fix the magic values here, use readl()/writel() to operate registers, kill the BIT() macro and review comments in common files.

Best regards,
Marek Vasut

#182 lore raw

PATCH 4/11 usb-ehci: add Faraday USB 2.0 EHCI controller support

2013/3/30 Marek Vasut <[email protected]>:

Quoted 7 lines

Dear Kuo-Jung Su,

Quoted 5 lines

From: Kuo-Jung Su <[email protected]>

This patch add supports to both Faraday FUSBH200 and FOTG210, these controllers slightly differ from standard EHCI specification.

Quoted 7 lines
Quoted 1 line

You want to fix the magic values here, use readl()/writel() to operate registers, kill the BIT() macro and review comments in common files.

Best regards,
Marek Vasut

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#183 lore raw

PATCH 5/11 usb-gadget: add FOTG210 USB gadget support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This patch would try to use Faraday FOTG210 to implement a USB RNDIS Ethernet.

---
 drivers/usb/gadget/Makefile       |    1 +
 drivers/usb/gadget/fotg210.c      |  926 +++++++++++++++++++++++++++++++++++++
 drivers/usb/gadget/fotg210.h      |   99 ++++
 drivers/usb/gadget/gadget_chips.h |    8 +
 4 files changed, 1034 insertions(+)
 create mode 100644 drivers/usb/gadget/fotg210.c
 create mode 100644 drivers/usb/gadget/fotg210.h
drivers/usb/gadget/Makefile +1 -0
index e545b6b..432cf17 100644
@@ -35,6 +35,7 @@ endif
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
+COBJS-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
 COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o
 endif
drivers/usb/gadget/fotg210.c new file +926 -0

926 lines not on this page · raw message

drivers/usb/gadget/fotg210.h new file +99 -0

99 lines not on this page · raw message

drivers/usb/gadget/gadget_chips.h +8 -0
index e570142..f038747 100644
@@ -150,6 +150,12 @@
 #define gadget_is_mv(g)        0
 #endif
 
+#ifdef CONFIG_USB_GADGET_FOTG210
+#define gadget_is_fotg210(g)        (!strcmp("fotg210_udc", (g)->name))
+#else
+#define gadget_is_fotg210(g)        0
+#endif
+
 /*
  * CONFIG_USB_GADGET_SX2
  * CONFIG_USB_GADGET_AU1X00
@@ -215,5 +221,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
 		return 0x20;
 	else if (gadget_is_mv(gadget))
 		return 0x21;
+	else if (gadget_is_fotg210(gadget))
+		return 0x22;
 	return -ENOENT;
 }

--
1.7.9.5

#184 lore raw

PATCH 5/11 usb-gadget: add FOTG210 USB gadget support

Dear Kuo-Jung Su,

Quoted 6 lines

From: Kuo-Jung Su <[email protected]>

This patch would try to use Faraday FOTG210 to implement a USB RNDIS Ethernet.

[...]

Quoted 6 lines
drivers/usb/gadget/fotg210.c new file +6 -0
+static inline int
+ep_reset(struct fotg210_chip *chip, uint8_t ep_addr)
+{
+	int ep = ep_addr & USB_ENDPOINT_NUMBER_MASK;
+
+	if (ep_addr & USB_DIR_IN) {

drivers/usb/gadget/fotg210.c line 98

Quoted 10 lines
drivers/usb/gadget/fotg210.c new file +10 -0
+		/* input */
+		USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) |= BIT(12);
+		USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) &= ~BIT(12);
+		USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) &= ~BIT(11);
+	} else {
+		/* output */
+		USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) |= BIT(12);
+		USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) &= BIT(12);
+		USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) &= BIT(11);
+	}

Use readl(), writel(), clrsetbits_le32() etc.

For example see drivers/i2c/mxs_i2c.c

[...]

drivers/usb/gadget/fotg210.h line 25

Quoted 5 lines
drivers/usb/gadget/fotg210.h new file +5 -0
+/*
+ * Global Registers
+ */
+#define REG_ISR         0x0C0    /* Interrupt Status */
+#define REG_IMR         0x0C4    /* Interrupt Control */

Use structure based access, ie.

arch/arm/include/asm/arch-mxs/regs-i2c.h

struct regs {
	uint32_t reg1;
	uint32_t reg2;

...
};

writel(val, &regs->reg1);

#185 lore raw

PATCH 5/11 usb-gadget: add FOTG210 USB gadget support

2013/3/30 Marek Vasut <[email protected]>:

Quoted 30 lines

Dear Kuo-Jung Su,

Quoted 6 lines

From: Kuo-Jung Su <[email protected]>

This patch would try to use Faraday FOTG210 to implement a USB RNDIS Ethernet.

[...]

Quoted 6 lines
drivers/usb/gadget/fotg210.c new file +6 -0
+static inline int
+ep_reset(struct fotg210_chip *chip, uint8_t ep_addr)
+{
+     int ep = ep_addr & USB_ENDPOINT_NUMBER_MASK;
+
+     if (ep_addr & USB_DIR_IN) {

drivers/usb/gadget/fotg210.c line 98

Quoted 10 lines
drivers/usb/gadget/fotg210.c new file +10 -0
+             /* input */
+             USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) |= BIT(12);
+             USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) &= ~BIT(12);
+             USB_REG32(chip, REG_IEP1 + (ep - 1) * 4) &= ~BIT(11);
+     } else {
+             /* output */
+             USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) |= BIT(12);
+             USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) &= BIT(12);
+             USB_REG32(chip, REG_OEP1 + (ep - 1) * 4) &= BIT(11);
+     }

Use readl(), writel(), clrsetbits_le32() etc.

Quoted 2 lines

For example see drivers/i2c/mxs_i2c.c

Got it, thanks

Quoted 12 lines

[...]

drivers/usb/gadget/fotg210.h line 25

Quoted 5 lines
drivers/usb/gadget/fotg210.h new file +5 -0
+/*
+ * Global Registers
+ */
+#define REG_ISR         0x0C0    /* Interrupt Status */
+#define REG_IMR         0x0C4    /* Interrupt Control */

Use structure based access, ie.

arch/arm/include/asm/arch-mxs/regs-i2c.h

Quoted 7 lines
struct regs {
        uint32_t reg1;
        uint32_t reg2;

...
};

writel(val, &regs->reg1);

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#186 lore raw

PATCH 6/11 i2c: add FTI2C010 I2C controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTI2C010 is a multi-function I2C controller which supports both master and slave mode. This patch simplily implements the master mode only.

---
 drivers/i2c/Makefile   |    1 +
 drivers/i2c/fti2c010.c |  360 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/i2c/fti2c010.h |   68 +++++++++
 3 files changed, 429 insertions(+)
 create mode 100644 drivers/i2c/fti2c010.c
 create mode 100644 drivers/i2c/fti2c010.h
drivers/i2c/Makefile +1 -0
index 5dbdbe3..ed2b8c0 100644
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
 COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o
 COBJS-$(CONFIG_DW_I2C) += designware_i2c.o
 COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
+COBJS-$(CONFIG_FTI2C010) += fti2c010.o
 COBJS-$(CONFIG_I2C_MVTWSI) += mvtwsi.o
 COBJS-$(CONFIG_I2C_MV) += mv_i2c.o
 COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
drivers/i2c/fti2c010.c new file +360 -0

360 lines not on this page · raw message

drivers/i2c/fti2c010.h new file +68 -0

68 lines not on this page · raw message

--
1.7.9.5

#187 lore raw

PATCH 7/11 spi: add FTSPI010 SPI controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday FTSSP010 is a multi-function controller which supports I2S/SPI/SSP/AC97/SPDIF.
This patch simpily implements the SPI mode only. BTW the DMA and CS/Clock control logic has been altered since revision 1.19.0. So this patch would 1st detects the revision id of the underlying chip, and then switch to the corresponding control routines.

---
 drivers/spi/Makefile       |    1 +
 drivers/spi/ftssp010_spi.c |  333 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/spi/ftssp010_spi.h |   85 +++++++++++
 3 files changed, 419 insertions(+)
 create mode 100644 drivers/spi/ftssp010_spi.c
 create mode 100644 drivers/spi/ftssp010_spi.h
drivers/spi/Makefile +1 -0
index 4268595..2db2a5c 100644
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o
 COBJS-$(CONFIG_CF_SPI) += cf_spi.o
 COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o
 COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
+COBJS-$(CONFIG_FTSSP010_SPI) += ftssp010_spi.o
 COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o
 COBJS-$(CONFIG_ICH_SPI) +=  ich.o
 COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o
drivers/spi/ftssp010_spi.c new file +333 -0

333 lines not on this page · raw message

drivers/spi/ftssp010_spi.h new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#188 lore raw

PATCH 8/11 mtd/nand: add FTNANDC021 NAND flash controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTNANDC021 is a integrated NAND flash controller. It use a build-in command table to abstract the underlying NAND flash control logic.

For example:

Issuing a command 0x10 to FTNANDC021 would result in a page write + a read status operation.

---
 drivers/mtd/nand/Makefile     |    1 +
 drivers/mtd/nand/ftnandc021.c |  550 +++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/nand/ftnandc021.h |  165 +++++++++++++
 3 files changed, 716 insertions(+)
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 drivers/mtd/nand/ftnandc021.h
drivers/mtd/nand/Makefile +1 -0
index c77c0c4..16b5016 100644
@@ -63,6 +63,7 @@ COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_FSMC) += fsmc_nand.o
+COBJS-$(CONFIG_NAND_FTNANDC021) += ftnandc021.o
 COBJS-$(CONFIG_NAND_JZ4740) += jz4740_nand.o
 COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
drivers/mtd/nand/ftnandc021.c new file +550 -0

550 lines not on this page · raw message

drivers/mtd/nand/ftnandc021.h new file +165 -0

165 lines not on this page · raw message

--
1.7.9.5

#189 lore raw

PATCH 9/11 mtd/spi: add FTSPI020 SPI Flash controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTSPI020 is dedicated SPI bus designed for SPI Flash chips. It supports Fast-Read-Dual, Fast-Read-Dual-IO, Fast-Read-Quad and Fast-Read-Quad-IO.

---
 drivers/mtd/spi/Makefile   |    4 +
 drivers/mtd/spi/ftspi020.c |  589 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/mtd/spi/ftspi020.h |  118 +++++++++
 drivers/mtd/spi/winbond.c  |   17 +-
 4 files changed, 727 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/spi/ftspi020.c
 create mode 100644 drivers/mtd/spi/ftspi020.h
drivers/mtd/spi/Makefile +4 -0
index 90f8392..ce60e1b 100644
@@ -29,6 +29,9 @@ ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_SPL_SPI_LOAD)	+= spi_spl_load.o
 endif
 
+ifeq ($(CONFIG_FTSPI020),y)
+COBJS-$(CONFIG_FTSPI020) += ftspi020.o
+else
 COBJS-$(CONFIG_SPI_FLASH)	+= spi_flash.o
 COBJS-$(CONFIG_SPI_FLASH_ATMEL)	+= atmel.o
 COBJS-$(CONFIG_SPI_FLASH_EON)	+= eon.o
@@ -39,6 +42,7 @@ COBJS-$(CONFIG_SPI_FLASH_STMICRO)	+= stmicro.o
 COBJS-$(CONFIG_SPI_FLASH_WINBOND)	+= winbond.o
 COBJS-$(CONFIG_SPI_FRAM_RAMTRON)	+= ramtron.o
 COBJS-$(CONFIG_SPI_M95XXX) += eeprom_m95xxx.o
+endif
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mtd/spi/ftspi020.c new file +589 -0

589 lines not on this page · raw message

drivers/mtd/spi/ftspi020.h new file +118 -0

118 lines not on this page · raw message

drivers/mtd/spi/winbond.c +16 -1
index 05dc644..7c354ce 100644
@@ -18,6 +18,21 @@ struct winbond_spi_flash_params {
 
 static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
 	{
+		.id			= 0x2014,
+		.nr_blocks		= 16,
+		.name			= "W25P80",
+	},
+	{
+		.id			= 0x2015,
+		.nr_blocks		= 32,
+		.name			= "W25P16",
+	},
+	{
+		.id			= 0x2016,
+		.nr_blocks		= 64,
+		.name			= "W25P32",
+	},
+	{
 		.id			= 0x3013,
 		.nr_blocks		= 8,
 		.name			= "W25X40",
@@ -99,7 +114,7 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
 	}
 
 	flash->page_size = 256;
-	flash->sector_size = 4096;
+	flash->sector_size = (idcode[1] == 0x20) ? 65536 : 4096;
 	flash->size = 4096 * 16 * params->nr_blocks;
 
 	return flash;
Signature · 1 line
1.7.9.5
#190 lore raw

PATCH 10/11 mmc: add an alternative FTSDC010 driver support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTSDC010 is a MMC/SD host controller. There is already a driver in u-boot, which is modified from eSHDC and contributed by Andes Tech.

However it works extreamly slow in Faraday A36x SoC Platforms, so I turn to implement this new version of driver with 10 times faster speed, and improved stability.

---
 drivers/mmc/Makefile       |    1 +
 drivers/mmc/ftsdc010_mci.c |  362 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/ftsdc010_mci.h |   91 +++++++++++
 3 files changed, 454 insertions(+)
 create mode 100644 drivers/mmc/ftsdc010_mci.c
 create mode 100644 drivers/mmc/ftsdc010_mci.h
drivers/mmc/Makefile +1 -0
index 65791aa..dfe1b8c 100644
@@ -33,6 +33,7 @@ COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
 COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 COBJS-$(CONFIG_FTSDC010) += ftsdc010_esdhc.o
+COBJS-$(CONFIG_FTSDC010_MCI) += ftsdc010_mci.o
 COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
 COBJS-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o
 COBJS-$(CONFIG_MMC_SPI) += mmc_spi.o
drivers/mmc/ftsdc010_mci.c new file +362 -0

362 lines not on this page · raw message

drivers/mmc/ftsdc010_mci.h new file +91 -0

91 lines not on this page · raw message

--
1.7.9.5

#191 lore raw

PATCH 11/11 arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

The Faraday A36x EVB is a Faraday SoC platform evalution board used for Faraday IP functional verification based on the well-known ARM AMBA 2.0 architecture.

Faraday A360 EVB:
CPU: FA626TE
NET: FTMAC110
USB: FUSBH200, FOTG210
LCD: FTLCDC200
I2C: FTI2C010
SPI: FTSSP010 v1.18.0
MMC: FTSDC010
RTC: FTRTC010
WDT: FTWDT010
TMR: FTTMR010
PIC: FTINTC020
UART: FTUART010
NAND: FTNANDC020

Faraday A369 EVB:
CPU: FA626TE(Master)/FA606TE(Slave)
NET: FTGMAC100
USB: FUSBH200, FOTG210
LCD: FTLCDC200
I2C: FTI2C010
SPI: FTSSP010 v1.18.0
MMC: FTSDC010
RTC: FTRTC011
WDT: FTWDT010
TMR: FTPWMTMR010
PIC: FTINTC020
UART: FTUART010
NAND: FTNANDC021

---
 arch/arm/cpu/faraday/Makefile             |   57 +++
 arch/arm/cpu/faraday/a360/Makefile        |   49 +++
 arch/arm/cpu/faraday/a360/reset.c         |   22 ++
 arch/arm/cpu/faraday/a369/Makefile        |   50 +++
 arch/arm/cpu/faraday/a369/cmd_fa606.c     |   74 ++++
 arch/arm/cpu/faraday/a369/reset.c         |   22 ++
 arch/arm/cpu/faraday/cmd_bootfa.c         |  121 +++++++
 arch/arm/cpu/faraday/config.mk            |   33 ++
 arch/arm/cpu/faraday/cpu.c                |  230 +++++++++++++
 arch/arm/cpu/faraday/ftpwmtmr010.c        |  165 +++++++++
 arch/arm/cpu/faraday/fttmr010.c           |  155 +++++++++
 arch/arm/cpu/faraday/fwimage.h            |   38 ++
 arch/arm/cpu/faraday/fwimage2.h           |   70 ++++
 arch/arm/cpu/faraday/interrupts.c         |  169 +++++++++
 arch/arm/cpu/faraday/start.S              |  535 +++++++++++++++++++++++++++++
 arch/arm/cpu/u-boot.lds                   |   11 +
 arch/arm/include/asm/arch-a360/hardware.h |   80 +++++
 arch/arm/include/asm/arch-a369/hardware.h |  106 ++++++
 arch/arm/include/asm/mach-types.h         |    1 +
 board/faraday/a360evb/Makefile            |   49 +++
 board/faraday/a360evb/board.c             |   65 ++++
 board/faraday/a360evb/clk.c               |   48 +++
 board/faraday/a360evb/config.mk           |   33 ++
 board/faraday/a360evb/lowlevel_init.S     |   33 ++
 board/faraday/a369evb/Makefile            |   49 +++
 board/faraday/a369evb/board.c             |  182 ++++++++++
 board/faraday/a369evb/clk.c               |   80 +++++
 board/faraday/a369evb/config.mk           |   33 ++
 board/faraday/a369evb/lowlevel_init.S     |  133 +++++++
 boards.cfg                                |    3 +
 include/common.h                          |   13 +
 include/configs/a360.h                    |  180 ++++++++++
 include/configs/a369.h                    |   40 +++
 include/configs/a369_defaults.h           |  285 +++++++++++++++
 include/configs/a369_fa606te.h            |   32 ++
 include/faraday/fttmr010.h                |   51 ++-
 include/faraday/ftwdt010_wdt.h            |    8 +
 37 files changed, 3301 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/reset.c
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/cpu/faraday/a369/reset.c
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
 create mode 100644 arch/arm/cpu/faraday/interrupts.c
 create mode 100644 arch/arm/cpu/faraday/start.S
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clk.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clk.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_defaults.h
 create mode 100644 include/configs/a369_fa606te.h
arch/arm/cpu/faraday/Makefile new file +57 -0
new file mode 100644
index 0000000..fb712a1
@@ -0,0 +1,57 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+src-y						:= interrupts.o
+src-$(CONFIG_FTPWMTMR010)	+= ftpwmtmr010.o
+src-$(CONFIG_FTTMR010)		+= fttmr010.o
+
+START	= start.o
+COBJS	= cpu.o cmd_bootfa.o $(src-y)
+
+ifdef	CONFIG_SPL_BUILD
+ifdef	CONFIG_SPL_NO_CPU_SUPPORT_CODE
+START	:=
+endif
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/faraday/a360/Makefile new file +49 -0

49 lines not on this page · raw message

arch/arm/cpu/faraday/a360/reset.c new file +22 -0
new file mode 100644
index 0000000..3a1b607
@@ -0,0 +1,22 @@
+/*
+ * arch/arm/cpu/faraday/a360/reset.c
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <faraday/ftwdt010_wdt.h>
+
+#define WDT_REG32(off)		REG32(CONFIG_FTWDT010_BASE + (off))
+
+void reset_cpu(unsigned long ignored)
+{
+	WDT_REG32(REG_CR)      = 0;
+	WDT_REG32(REG_LOAD)    = 1000;
+	WDT_REG32(REG_CR)      = FTWDT010_WDCR_ENABLE | FTWDT010_WDCR_RST;
+	WDT_REG32(REG_RESTART) = FTWDT010_WDRESTART_MAGIC;
+}
arch/arm/cpu/faraday/a369/Makefile new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/faraday/a369/cmd_fa606.c new file +74 -0

74 lines not on this page · raw message

arch/arm/cpu/faraday/a369/reset.c new file +22 -0
new file mode 100644
index 0000000..74211cf
@@ -0,0 +1,22 @@
+/*
+ * arch/arm/cpu/faraday/a369/reset.c
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#include <common.h>
+#include <faraday/ftwdt010_wdt.h>
+
+#define WDT_REG32(off)		REG32(CONFIG_FTWDT010_BASE + (off))
+
+void reset_cpu(unsigned long ignored)
+{
+	WDT_REG32(REG_CR)      = 0;
+	WDT_REG32(REG_LOAD)    = 1000;
+	WDT_REG32(REG_CR)      = FTWDT010_WDCR_ENABLE | FTWDT010_WDCR_RST;
+	WDT_REG32(REG_RESTART) = FTWDT010_WDRESTART_MAGIC;
+}
arch/arm/cpu/faraday/cmd_bootfa.c new file +121 -0

121 lines not on this page · raw message

arch/arm/cpu/faraday/config.mk new file +33 -0
new file mode 100644
index 0000000..ffb2e6c
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2002
+# Gary Jennejohn, DENX Software Engineering, <[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
+#
+
+PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
+
+PLATFORM_CPPFLAGS += -march=armv5te
+# =========================================================================
+#
+# Supply options according to compiler version
+#
+# =========================================================================
+PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
+PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)
arch/arm/cpu/faraday/cpu.c new file +230 -0

230 lines not on this page · raw message

arch/arm/cpu/faraday/ftpwmtmr010.c new file +165 -0

165 lines not on this page · raw message

arch/arm/cpu/faraday/fttmr010.c new file +155 -0

155 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage.h new file +38 -0
new file mode 100644
index 0000000..dd1a453
@@ -0,0 +1,38 @@
+/*
+ * arch/arm/cpu/faraday/fwimage.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FWIMAGE_H
+#define ARCH_ARM_CPU_FARADAY_FWIMAGE_H
+
+struct fwparam {
+	uint32_t	count;
+	uint32_t	version; /* ycmo100525: for firmware image version */
+	uint32_t	addr[31];
+	uint32_t	data[31];
+};
+
+struct fwfile {
+	char		name[64];
+	uint32_t	size;
+	/* uint32_t	block[1]; */
+};
+
+struct fwimage {
+	/* 8 bytes */
+	uint32_t		magic;	/* The magic number for the specific platform */
+	uint32_t		length;	/* It shall not be greater than 2048 */
+
+	/* 256 bytes, embedded paramters area */
+	struct fwparam	param;
+
+	struct fwfile	file[1];
+};
+
+#endif
arch/arm/cpu/faraday/fwimage2.h new file +70 -0

70 lines not on this page · raw message

arch/arm/cpu/faraday/interrupts.c new file +169 -0

169 lines not on this page · raw message

arch/arm/cpu/faraday/start.S new file +535 -0

535 lines not on this page · raw message

arch/arm/cpu/u-boot.lds +11 -0
index 3a1083d..fceea9c 100644
@@ -23,6 +23,8 @@
  * MA 02111-1307 USA
  */
 
+#include <config.h>
+
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -35,6 +37,15 @@ SECTIONS
 	{
 		__image_copy_start = .;
 		CPUDIR/start.o (.text*)
+#ifdef CONFIG_FARADAY
+		/*
+		 * Dante Su 2012.10.09:
+		 * Reserved for the faimage v2.1.
+		 * 1. CPUDIR/start.o: It shall never be > 4KB.
+		 * 2. faimage header: It shall always be stored at 0x1000, and <= 1KB.
+		 */
+		. = 0x00001400;
+#endif
 		*(.text*)
 	}
 
arch/arm/include/asm/arch-a360/hardware.h new file +80 -0

80 lines not on this page · raw message

arch/arm/include/asm/arch-a369/hardware.h new file +106 -0

106 lines not on this page · raw message

arch/arm/include/asm/mach-types.h +1 -0
index a676b6d..64fc68b 100644
@@ -144,6 +144,7 @@ extern unsigned int __machine_arch_type;
 #define MACH_TYPE_AKITA                744
 #define MACH_TYPE_E330                 753
 #define MACH_TYPE_NOKIA770             755
+#define MACH_TYPE_FARADAY              758
 #define MACH_TYPE_CARMEVA              769
 #define MACH_TYPE_EDB9315A             772
 #define MACH_TYPE_STARGATE2            774
board/faraday/a360evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a360evb/board.c new file +65 -0

65 lines not on this page · raw message

board/faraday/a360evb/clk.c new file +48 -0

48 lines not on this page · raw message

board/faraday/a360evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a360evb/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000..1ead608
@@ -0,0 +1,33 @@
+/*
+ * Board specific setup info
+ *
+ * (C) Copyright 2010
+ * Faraday Technology Inc. <www.faraday-tech.com>
+ * Dante Su <[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 <version.h>
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+	mov	pc,lr
board/faraday/a369evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a369evb/board.c new file +182 -0

182 lines not on this page · raw message

board/faraday/a369evb/clk.c new file +80 -0

80 lines not on this page · raw message

board/faraday/a369evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a369evb/lowlevel_init.S new file +133 -0

133 lines not on this page · raw message

boards.cfg +3 -0
index ee68fdd..fbf76a9 100644
@@ -73,6 +73,9 @@ mini2440                     arm         arm920t     mini2440            friendl
 VCMA9                        arm         arm920t     vcma9               mpl            s3c24x0
 smdk2410                     arm         arm920t     -                   samsung        s3c24x0
 omap1510inn                  arm         arm925t     -                   ti
+a360                         arm         faraday     a360evb             faraday        a360
+a369                         arm         faraday     a369evb             faraday        a369
+a369_fa606te                 arm         faraday     a369evb             faraday        a369
 integratorap_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorap:CM926EJ_S
 integratorcp_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorcp:CM924EJ_S
 aspenite                     arm         arm926ejs   -                   Marvell        armada100
include/common.h +13 -0
index d41aeb4..6324806 100644
@@ -112,6 +112,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_SOC_DA8XX
 #include <asm/arch/hardware.h>
 #endif
+#ifdef CONFIG_FARADAY
+#include <asm/arch/hardware.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
@@ -257,6 +260,16 @@ typedef void (interrupt_handler_t)(void *);
 	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
 
+#ifdef CONFIG_FARADAY
+/* board/faraday/xxx/clk.c */
+extern ulong clk_get_rate(char *id);
+
+/* arch/arm/cpu/faraday/xxx/interrupt.c */
+extern void irq_set_trigger(int irq, int edge, int low);
+extern void irq_enable(int irq);
+extern void irq_disable(int irq);
+#endif
+
 /*
  * Function Prototypes
  */
include/configs/a360.h new file +180 -0

180 lines not on this page · raw message

include/configs/a369.h new file +40 -0
new file mode 100644
index 0000000..e37ea9d
@@ -0,0 +1,40 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_A369_PLATFORM        1
+
+/* Support external AHB */
+#if 0
+#define CONFIG_SUPP_EXTAHB          1
+#endif
+
+/* Support USB RNDIS Ethernet */
+#if 0
+#define CONFIG_SUPP_USB_RNDIS       1
+#endif
+
+/* Disable NOR flash support */
+#define CONFIG_SYS_NO_FLASH         1
+
+/* Support interrupt */
+#if 0
+#define CONFIG_USE_IRQ              1
+#endif
+
+#if 1
+/* Enable MMU/D-CACHE */
+#define CONFIG_SYS_ARM_CACHE_WRITETHROUGH 1
+#else
+/* Disable MMU/D-CACHE */
+#define CONFIG_SYS_DCACHE_OFF       1
+#endif
+
+/* Transfer the control to the built-in slave cpu: FA606TE */
+#define CONFIG_CMD_FA606            1
+
+/* Hardware Resources (i.e. iobase, irq) */
+#include <asm/arch/hardware.h>
+
+#include "a369_defaults.h"
+
+#endif
include/configs/a369_defaults.h new file +285 -0

35 lines not on this page · raw message

include/configs/a369_fa606te.h new file +32 -0
new file mode 100644
index 0000000..c69962c

Lines of this file are not shown. View the raw message.

include/faraday/fttmr010.h +47 -4

51 lines not on this page · raw message

include/faraday/ftwdt010_wdt.h +8 -0
index 31ca768..98fa956 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

--
1.7.9.5

Part of the diff is not shown here. View the raw message.

#192 lore raw

v5 cover arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

These patches introduce Faraday A36x SoC platform support.

Here are some public documents for your reference.

http://www.faraday-tech.com/html/documentation/index.html

There is also a A369 QEMU emulator available at my github account:

https://github.com/dantesu1218/qemu.git

Here is quick start for QEMU + U-Boot:

1. Download the QEMU source tree

   $ git clone -b qemu-1.4.0 https://github.com/dantesu1218/qemu.git

2. Build & Install the QEMU:

   $ ./configure --target-list=arm-softmmu
   $ make
   $ make install

3. Launch u-boot with QEMU:

   $ qemu-system-arm -M a369 -m 512M -nographic -kernel ~/u-boot-2013.04/u-boot

Changes for v5:
- Coding Style cleanup:
1. struct chip_regs __iomem *regs -> struct chip_regs *regs
2. Move Faraday specific APIs into asm/arch-faraday/*.h
- Fix Copyright notices (dates) throughout the patch
- Make 'arm: dma_alloc_coherent: malloc() -> memalign()' as a separate patch
- Make 'cfi_flash: use buffer length in unmap_physmem()' as a separate patch
- Define Faraday machine type in board's config header file
- Add the rationale to the command 'bootfa'
- Add myself as the maintainer for Faraday A360/A369 in MAINTAINERS.
- Chain the video:FTLCDC200 back to this patch series.
- Chain the nand:FTNANDC021 back to this patch series.
- Chain the net:FTGMAC100 & FTMAC110 back to this patch series.
- Update Faraday Firmware Image Format:
1. Drop u-boot image support to simplify the design.
Since it's not possible for the hard-wired ROM code of A360/A369 to support U-boot images. And the real bootloader for A360/A369 is actually Faraday bootcode2, rather than U-Boot.
2. Add image creation timestamp
- Update 'arch/arm/cpu/faraday/start.S' with the new design, which move relocation into 'arch/arm/lib/relocate.S'
- Drop i2c:FTI2C010 & spi:FTSSP010_SPI support. The corresponding patch would restart after this patch series have been accepted.
- Revise IRQ & MMU design: Now the exception table would be mapped to

     0x00000000 as a small page(4KB), rather than runtime adjust after
     relocation finished.

- Revise irq:FTINTC020 design, now the irq is always enabled inside irq_install_handler().
- Revise clock management system
- Revise FTPWMTMR010 & FTTMR010 timer design:
1. Drop IRQ dependant implementation
2. Use gd->arch.timer_rate_hz for timer clock source
3. Use gd->arch.tbl for timestamp

Changes for v4:
- Coding Style cleanup.
- Break down the patch series:
- Patches without hard dependency to this series are now seperate patches.
- Split up the patch into more logical changesets (i.e. interrupt & timers are now split up)
- Drop the faraday/nand.h to remove dependency to ftnandc021
- Drop the faraday/mmc.h to remove dependency to ftsdc010
- Add change logs to each part of the patch series to make patchwork be able to grab comments.

Changes for v3:
- Coding Style cleanup.
There is still one warnning reported by checkpatch.pl, however it's too deep for me to fix it.
Here is the shapshot for it:
-----------------------------------------------------
WARNING: do not add new typedefs
#9735: FILE: include/lcd.h:258:
+typedef struct vidinfo {
-----------------------------------------------------
- Drop bit fields from c struct.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- cmd_boot.c: Make it a separate stand-alone patch.
- ftspi020: Make it a separate stand-alone patch.
- dma-mapping.h: Have the global data ptr declared outside functions.
- dma-mapping.h: Add #if...#else...#endif to dma_free_coherent().
- MMU/D-Cache: Drop static non-cached region, now we use map_physmem()/unmap_physmem() for dynamic mappings.
- ftmac110: Make a correction to multi-line comment style
- ftmac110: Use random MAC address while having trouble to get one from environment variables.
- ftmac110: Add comments to timing control registers.
- ftnandc021: Re-write this driver with ECC enabled and correct column address handling for OOB read/write,
and fixing issused addressed by Scott.
- a36x_config: No more static global network configurations.
- a36x_config: Add a common file for the redundant configurations.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().
- echi-faraday: Remove debug codes.
- ftmac110: Remove debug codes.
- cache-cp15: Enable write buffer in write-through mode.

Kuo-Jung Su (14):
arm: dma_alloc_coherent: malloc() -> memalign()
net: ftgmac100: add MMU/D-cache support
net: add Faraday FTMAC110 10/100Mbps ethernet support
video: add Faraday FTLCDC200 LCD controller support
nand: add Faraday FTNANDC021 NAND controller support
cfi_flash: use buffer length in unmap_physmem()
arm: add MMU/D-Cache support for Faraday cores
arm: add Faraday processor core support
arm: add Faraday FTINTC020 interrupt controller support
arm: add Faraday FTTMR010 timer support
arm: add Faraday FTPWMTMR010 timer support
arm: add Faraday firmware image support
mmc: ftsdc010_mci: clk_get_rate() -> clock_get_rate()
arm: add Faraday A360/A369 SoC platform support

 MAINTAINERS                                   |    5 +
 README                                        |    6 +
 arch/arm/cpu/faraday/Makefile                 |   58 +++
 arch/arm/cpu/faraday/a360/Makefile            |   49 ++
 arch/arm/cpu/faraday/a369/Makefile            |   50 ++
 arch/arm/cpu/faraday/a369/cmd_fa606.c         |   86 ++++
 arch/arm/cpu/faraday/cmd_bootfa.c             |  143 ++++++
 arch/arm/cpu/faraday/config.mk                |   33 ++
 arch/arm/cpu/faraday/cpu.c                    |  346 ++++++++++++++
 arch/arm/cpu/faraday/ftintc020.c              |  156 +++++++
 arch/arm/cpu/faraday/ftpwmtmr010.c            |  128 +++++
 arch/arm/cpu/faraday/fttmr010.c               |  136 ++++++
 arch/arm/cpu/faraday/fwimage.h                |   47 ++
 arch/arm/cpu/faraday/fwimage2.h               |   67 +++
 arch/arm/cpu/faraday/start.S                  |  431 +++++++++++++++++
 arch/arm/cpu/u-boot.lds                       |   11 +
 arch/arm/include/asm/arch-a360/hardware.h     |   84 ++++
 arch/arm/include/asm/arch-a360/pmu.h          |   54 +++
 arch/arm/include/asm/arch-a360/scu.h          |   48 ++
 arch/arm/include/asm/arch-a369/ahbc.h         |   34 ++
 arch/arm/include/asm/arch-a369/hardware.h     |   99 ++++
 arch/arm/include/asm/arch-a369/scu.h          |  224 +++++++++
 arch/arm/include/asm/arch-faraday/clock.h     |   41 ++
 arch/arm/include/asm/arch-faraday/interrupt.h |   29 ++
 arch/arm/include/asm/dma-mapping.h            |   61 ++-
 arch/arm/include/asm/global_data.h            |    4 +
 arch/arm/include/asm/io.h                     |  160 ++++++-
 arch/arm/include/asm/system.h                 |    7 +-
 arch/arm/lib/cache-cp15.c                     |   12 +
 board/faraday/a360evb/Makefile                |   49 ++
 board/faraday/a360evb/board.c                 |   72 +++
 board/faraday/a360evb/clock.c                 |   72 +++
 board/faraday/a360evb/config.mk               |   33 ++
 board/faraday/a360evb/lowlevel_init.S         |   33 ++
 board/faraday/a369evb/Makefile                |   49 ++
 board/faraday/a369evb/board.c                 |  176 +++++++
 board/faraday/a369evb/clock.c                 |   80 ++++
 board/faraday/a369evb/config.mk               |   33 ++
 board/faraday/a369evb/lowlevel_init.S         |  136 ++++++
 boards.cfg                                    |    3 +
 drivers/mmc/ftsdc010_mci.c                    |    2 +-
 drivers/mtd/cfi_flash.c                       |    2 +-
 drivers/mtd/nand/Makefile                     |    1 +
 drivers/mtd/nand/ftnandc021.c                 |  622 +++++++++++++++++++++++++
 drivers/net/Makefile                          |    1 +
 drivers/net/ftgmac100.c                       |   70 ++-
 drivers/net/ftmac110.c                        |  484 +++++++++++++++++++
 drivers/net/ftmac110.h                        |  188 ++++++++
 drivers/video/Makefile                        |    1 +
 drivers/video/ftlcdc200.c                     |  148 ++++++
 drivers/video/ftlcdc200_panel.c               |  221 +++++++++
 include/common.h                              |    5 +
 include/configs/a360.h                        |   60 +++
 include/configs/a369-common.h                 |   72 +++
 include/configs/a369.h                        |   34 ++
 include/configs/a369_fa606te.h                |   31 ++
 include/configs/faraday-common.h              |  243 ++++++++++
 include/faraday/ftintc020.h                   |   37 ++
 include/faraday/ftlcdc200.h                   |  179 +++++++
 include/faraday/ftnandc021.h                  |  153 ++++++
 include/faraday/ftpwmtmr010.h                 |   41 ++
 include/faraday/ftsmc020.h                    |    1 +
 include/faraday/fttmr010.h                    |   17 +
 include/lcd.h                                 |   33 ++
 include/netdev.h                              |    1 +
 65 files changed, 5956 insertions(+), 36 deletions(-)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/ftintc020.c
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
 create mode 100644 arch/arm/cpu/faraday/start.S
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a360/pmu.h
 create mode 100644 arch/arm/include/asm/arch-a360/scu.h
 create mode 100644 arch/arm/include/asm/arch-a369/ahbc.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/scu.h
 create mode 100644 arch/arm/include/asm/arch-faraday/clock.h
 create mode 100644 arch/arm/include/asm/arch-faraday/interrupt.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clock.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clock.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 drivers/net/ftmac110.c
 create mode 100644 drivers/net/ftmac110.h
 create mode 100644 drivers/video/ftlcdc200.c
 create mode 100644 drivers/video/ftlcdc200_panel.c
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369-common.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_fa606te.h
 create mode 100644 include/configs/faraday-common.h
 create mode 100644 include/faraday/ftintc020.h
 create mode 100644 include/faraday/ftlcdc200.h
 create mode 100644 include/faraday/ftnandc021.h
 create mode 100644 include/faraday/ftpwmtmr010.h

--
1.7.9.5

#193 lore raw

PATCH v5 1/14 arm: dma_alloc_coherent: malloc() -> memalign()

From: Kuo-Jung Su <[email protected]>

Even though the MMU/D-cache is off, some DMA engines still expect strict address alignment.

For example, the incoming Faraday FTMAC110 & FTGMAC100 ethernet controllers expect the tx/rx descriptors should always be aligned to 16-bytes boundary.

CC Albert ARIBAUD <[email protected]>

---
Changes for v5:
- Initial commit, which is separated from "arm: add MMU/D-Cache support for Faraday cores"

 arch/arm/include/asm/dma-mapping.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/dma-mapping.h +1 -1
index 5bbb0a0..a11178f 100644
@@ -32,7 +32,7 @@ enum dma_data_direction {
 
 static void *dma_alloc_coherent(size_t len, unsigned long *handle)
 {
-	*handle = (unsigned long)malloc(len);
+	*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
 	return (void *)*handle;
 }
 

--
1.7.9.5

#194 lore raw

PATCH v5 2/14 net: ftgmac100: add MMU/D-cache support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

1. Dynamically allocate the tx/rx descriptors through dma_alloc_coherent(), instead of allocating at compile/link time.

2. Do not block on ftgmac100_send(), the packet has been copied to a safe buffer. Although it's a little bit slower, but the tx performance is never critical.

3. No matter if MMU/D-cache is on or off, this patch always depends on previous patch:

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTGMAC100 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

CC Albert ARIBAUD <[email protected]>
CC Joe Hershberger <[email protected]>
CC Tom Rini <[email protected]>

---
Changes for v5:
- Chain it back to Faraday A360/A369 patch series, because this strongly depends on patch to dma_alloc_coherent() at the Faraday A360/A369 patch series.

Changes for v4:
- Make it a separate patch, rather then a part of Faraday A36x patch series

Changes for v3:
- Coding Style cleanup

Changes for v2:
- Coding Style cleanup
- Cleanup (Drop cosmetic patch)

 drivers/net/ftgmac100.c |   70 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 21 deletions(-)
drivers/net/ftgmac100.c +49 -21
index 69ba57d..2dbb328 100644
@@ -27,11 +27,13 @@
 #include <malloc.h>
 #include <net.h>
 #include <asm/io.h>
+#include <asm/dma-mapping.h>
 #include <linux/mii.h>
 
 #include "ftgmac100.h"
 
 #define ETH_ZLEN	60
+#define CFG_XBUF_SIZE	1536
 
 /* RBSR - hw default init value is also 0x640 */
 #define RBSR_DEFAULT_VALUE	0x640
@@ -40,8 +42,10 @@
 #define PKTBUFSTX	4	/* must be power of 2 */
 
 struct ftgmac100_data {
-	struct ftgmac100_txdes txdes[PKTBUFSTX];
-	struct ftgmac100_rxdes rxdes[PKTBUFSRX];
+	ulong txdes_dma;
+	struct ftgmac100_txdes *txdes;
+	ulong rxdes_dma;
+	struct ftgmac100_rxdes *rxdes;
 	int tx_index;
 	int rx_index;
 	int phy_addr;
@@ -375,13 +379,34 @@ static int ftgmac100_init(struct eth_device *dev, bd_t *bd)
 {
 	struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
 	struct ftgmac100_data *priv = dev->priv;
-	struct ftgmac100_txdes *txdes = priv->txdes;
-	struct ftgmac100_rxdes *rxdes = priv->rxdes;
+	struct ftgmac100_txdes *txdes;
+	struct ftgmac100_rxdes *rxdes;
 	unsigned int maccr;
+	void *buf;
 	int i;
 
 	debug("%s()\n", __func__);
 
+	if (!priv->txdes) {
+		txdes = dma_alloc_coherent(
+			sizeof(*txdes) * PKTBUFSTX, &priv->txdes_dma);
+		if (!txdes)
+			panic("ftgmac100: out of memory\n");
+		memset(txdes, 0, sizeof(*txdes) * PKTBUFSTX);
+		priv->txdes = txdes;
+	}
+	txdes = priv->txdes;
+
+	if (!priv->rxdes) {
+		rxdes = dma_alloc_coherent(
+			sizeof(*rxdes) * PKTBUFSRX, &priv->rxdes_dma);
+		if (!rxdes)
+			panic("ftgmac100: out of memory\n");
+		memset(rxdes, 0, sizeof(*rxdes) * PKTBUFSRX);
+		priv->rxdes = rxdes;
+	}
+	rxdes = priv->rxdes;
+
 	/* set the ethernet address */
 	ftgmac100_set_mac_from_env(dev);
 
@@ -397,21 +422,31 @@ static int ftgmac100_init(struct eth_device *dev, bd_t *bd)
 
 	for (i = 0; i < PKTBUFSTX; i++) {
 		/* TXBUF_BADR */
-		txdes[i].txdes3 = 0;
+		if (!txdes[i].txdes2) {
+			buf = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE);
+			if (!buf)
+				panic("ftgmac100: out of memory\n");
+			txdes[i].txdes3 = virt_to_phys(buf);
+			txdes[i].txdes2 = (uint)buf;
+		}
 		txdes[i].txdes1 = 0;
 	}
 
 	for (i = 0; i < PKTBUFSRX; i++) {
 		/* RXBUF_BADR */
-		rxdes[i].rxdes3 = (unsigned int)NetRxPackets[i];
+		if (!rxdes[i].rxdes2) {
+			buf = NetRxPackets[i];
+			rxdes[i].rxdes3 = virt_to_phys(buf);
+			rxdes[i].rxdes2 = (uint)buf;
+		}
 		rxdes[i].rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY;
 	}
 
 	/* transmit ring */
-	writel((unsigned int)txdes, &ftgmac100->txr_badr);
+	writel(priv->txdes_dma, &ftgmac100->txr_badr);
 
 	/* receive ring */
-	writel((unsigned int)rxdes, &ftgmac100->rxr_badr);
+	writel(priv->rxdes_dma, &ftgmac100->rxr_badr);
 
 	/* poll receive descriptor automatically */
 	writel(FTGMAC100_APTC_RXPOLL_CNT(1), &ftgmac100->aptc);
@@ -466,8 +501,11 @@ static int ftgmac100_recv(struct eth_device *dev)
 	debug("%s(): RX buffer %d, %x received\n",
 	       __func__, priv->rx_index, rxlen);
 
+	/* invalidate d-cache */
+	dma_map_single((void *)curr_des->rxdes2, rxlen, DMA_FROM_DEVICE);
+
 	/* pass the packet up to the protocol layers. */
-	NetReceive((void *)curr_des->rxdes3, rxlen);
+	NetReceive((void *)curr_des->rxdes2, rxlen);
 
 	/* release buffer to DMA */
 	curr_des->rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY;
@@ -485,7 +523,6 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 	struct ftgmac100 *ftgmac100 = (struct ftgmac100 *)dev->iobase;
 	struct ftgmac100_data *priv = dev->priv;
 	struct ftgmac100_txdes *curr_des = &priv->txdes[priv->tx_index];
-	int start;
 
 	if (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) {
 		debug("%s(): no TX descriptor available\n", __func__);
@@ -496,8 +533,8 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 
 	length = (length < ETH_ZLEN) ? ETH_ZLEN : length;
 
-	/* initiate a transmit sequence */
-	curr_des->txdes3 = (unsigned int)packet;	/* TXBUF_BADR */
+	memcpy((void *)curr_des->txdes2, (void *)packet, length);
+	dma_map_single((void *)curr_des->txdes2, length, DMA_TO_DEVICE);
 
 	/* only one descriptor on TXBUF */
 	curr_des->txdes0 &= FTGMAC100_TXDES0_EDOTR;
@@ -509,15 +546,6 @@ static int ftgmac100_send(struct eth_device *dev, void *packet, int length)
 	/* start transmit */
 	writel(1, &ftgmac100->txpd);
 
-	/* wait for transfer to succeed */
-	start = get_timer(0);
-	while (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) {
-		if (get_timer(0) >= 5) {
-			debug("%s(): timed out\n", __func__);
-			return -1;
-		}
-	}
-
 	debug("%s(): packet sent\n", __func__);
 
 	priv->tx_index = (priv->tx_index + 1) % PKTBUFSTX;

--
1.7.9.5

#195 lore raw

PATCH v5 2/14 net: ftgmac100: add MMU/D-cache support

Hi Kuo-Jung,

Quoted 7 lines · Kuo-Jung Su

3. No matter if MMU/D-cache is on or off, this patch always depends on previous patch:

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTGMAC100 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

Nitpick: as a general rule, the commit message does not need to mention that a patch in a series depends on a previous one; this is implied by the series itself.

In fact, it should even /refrain/ from doing so because even though the series is usually applied atomically, it is not impossible that a an unrelated 'hot' bugfix patch slip in the middle of it, so "previous patch", which makes sense at submission time, might not make sense any more later.

Personally I like the commit message to only provide a short explanation of the whys and hows of the patch itself, and put any additional info after the commit message separator "---" below or, if using patman, in the cover letter.

Quoted 6 lines
CC Albert ARIBAUD <[email protected]>
CC Joe Hershberger <[email protected]>
CC Tom Rini <[email protected]>

---
Changes for v5:

Amicalement,

Signature · 1 line
Albert.
#196 lore raw

PATCH v5 2/14 net: ftgmac100: add MMU/D-cache support

2013/6/23 Albert ARIBAUD <[email protected]>:

Quoted 23 lines

Hi Kuo-Jung,

Quoted 7 lines · Kuo-Jung Su

3. No matter if MMU/D-cache is on or off, this patch always depends on previous patch:

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTGMAC100 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

Nitpick: as a general rule, the commit message does not need to mention that a patch in a series depends on a previous one; this is implied by the series itself.

In fact, it should even /refrain/ from doing so because even though the series is usually applied atomically, it is not impossible that a an unrelated 'hot' bugfix patch slip in the middle of it, so "previous patch", which makes sense at submission time, might not make sense any more later.

Quoted 5 lines

Personally I like the commit message to only provide a short explanation of the whys and hows of the patch itself, and put any additional info after the commit message separator "---" below or, if using patman, in the cover letter.

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#197 lore raw

PATCH v5 3/14 net: add Faraday FTMAC110 10/100Mbps ethernet support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTMAC110 10/100Mbps supports half-word data transfer for Linux. However it has a weird DMA alignment issue:

(1) Tx DMA Buffer Address:
1 bytes aligned: Invalid
2 bytes aligned: O.K
4 bytes aligned: O.K

(2) Rx DMA Buffer Address:
1 bytes aligned: Invalid
2 bytes aligned: O.K
4 bytes aligned: Invalid!!!

NOTE:
No matter if MMU/D-cache is on or off, this patch always depends on previous patch:

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTMAC110 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

CC Albert ARIBAUD <[email protected]>
CC Joe Hershberger <[email protected]>
CC Tom Rini <[email protected]>

---
Changes for v5:
- Coding Style cleanup:

     struct chip_regs __iomem *regs -> struct chip_regs *regs

- Chain it back to Faraday A360/A369 patch series, because this strongly depends on patch to dma_alloc_coherent() at the Faraday A360/A369 patch series.

Changes for v4:
- Make it a separate patch, rather then a part of Faraday A36x patch series
- Use macro constants for timeout control
- Use only named constants for bit mask/shift and values
- Drop the magic number from mdio read/write.

Changes for v3:
- Coding Style cleanup.
- Drop bit fields from c struct.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- Make a correction to multi-line comment style
- Use random MAC address while having trouble
to get one from environment variables.
- Add comments to timing control registers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().
- ftmac110: Remove debug codes.

 drivers/net/Makefile   |    1 +
 drivers/net/ftmac110.c |  484 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/ftmac110.h |  188 +++++++++++++++++++
 include/netdev.h       |    1 +
 4 files changed, 674 insertions(+)
 create mode 100644 drivers/net/ftmac110.c
 create mode 100644 drivers/net/ftmac110.h
drivers/net/Makefile +1 -0
index 786a656..0e23817 100644
@@ -46,6 +46,7 @@ COBJS-$(CONFIG_ETHOC) += ethoc.o
 COBJS-$(CONFIG_FEC_MXC) += fec_mxc.o
 COBJS-$(CONFIG_FSLDMAFEC) += fsl_mcdmafec.o mcfmii.o
 COBJS-$(CONFIG_FTGMAC100) += ftgmac100.o
+COBJS-$(CONFIG_FTMAC110) += ftmac110.o
 COBJS-$(CONFIG_FTMAC100) += ftmac100.o
 COBJS-$(CONFIG_GRETH) += greth.o
 COBJS-$(CONFIG_INCA_IP_SWITCH) += inca-ip_sw.o
drivers/net/ftmac110.c new file +484 -0

484 lines not on this page · raw message

drivers/net/ftmac110.h new file +188 -0

188 lines not on this page · raw message

include/netdev.h +1 -0
index df454b5..c8d3b62 100644
@@ -67,6 +67,7 @@ int fecmxc_initialize(bd_t *bis);
 int fecmxc_initialize_multi(bd_t *bis, int dev_id, int phy_id, uint32_t addr);
 int ftgmac100_initialize(bd_t *bits);
 int ftmac100_initialize(bd_t *bits);
+int ftmac110_initialize(bd_t *bits);
 int greth_initialize(bd_t *bis);
 void gt6426x_eth_initialize(bd_t *bis);
 int inca_switch_initialize(bd_t *bis);

--
1.7.9.5

#198 lore raw

PATCH v5 3/14 net: add Faraday FTMAC110 10/100Mbps ethernet support

Hi Kuo-Jung,

Quoted 8 lines · Kuo-Jung Su

NOTE:
No matter if MMU/D-cache is on or off, this patch
always depends on previous patch:

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTMAC110 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

Ditto patch 01/14.

Amicalement,

Signature · 1 line
Albert.
#199 lore raw

PATCH v5 3/14 net: add Faraday FTMAC110 10/100Mbps ethernet support

Quoted 9 lines · Albert ARIBAUD

Hi Kuo-Jung,

Quoted 4 lines · Kuo-Jung Su

NOTE:
No matter if MMU/D-cache is on or off, this patch
always depends on previous patch:

Quoted 6 lines
Quoted 4 lines

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTMAC110 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

Ditto patch 01/14.

Hasn't hit the list yet :)

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130623/24638562/attachment.pgp>
#200 lore raw

PATCH v5 3/14 net: add Faraday FTMAC110 10/100Mbps ethernet support

Hi Tom,

Quoted 10 lines · Tom Rini
Quoted 9 lines · Albert ARIBAUD

Hi Kuo-Jung,

Quoted 4 lines · Kuo-Jung Su

NOTE:
No matter if MMU/D-cache is on or off, this patch
always depends on previous patch:

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTMAC110 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

Ditto patch 01/14.

Actually I meant 02/14, as 01/14 is the patch upon which 02 and 03 depend.

Quoted 1 line

Hasn't hit the list yet :)

Hmm... Gmane has the full series, and so has patchwork.

Or did I miss a joke/pun/other(please specify)?

Amicalement,

Signature · 1 line
Albert.
#201 lore raw

PATCH v5 3/14 net: add Faraday FTMAC110 10/100Mbps ethernet support

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 20 lines · Albert ARIBAUD

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 8 lines · Albert ARIBAUD

Hi Kuo-Jung,

Quoted 3 lines · Kuo-Jung Su

NOTE: No matter if MMU/D-cache is on or off, this patch always depends on previous patch:

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines

arm: dma_alloc_coherent: malloc() -> memalign().

Because the FTMAC110 expects the tx/rx descriptors are always be aligned to 16-bytes boundary.

Ditto patch 01/14.

Quoted 8 lines

Actually I meant 02/14, as 01/14 is the patch upon which 02 and 03
depend.

Quoted 1 line

Hasn't hit the list yet :)

Hmm... Gmane has the full series, and so has patchwork.

Or did I miss a joke/pun/other(please specify)?

No, I just assumed you had a comment in 1/14, hadn't looked at the whole thing yet.

- --
Tom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRxxGDAAoJENk4IS6UOR1WhFIP/2VWO75krgx9OPR0j5uf7NXl HmcGzctPU1eyxQs5Ss7YgaZueo3dZ76+2zboJ/Y/PfjXjKyWvh2i7BsILElhr1CJ ufhtS35/Gfi4jvxokMf2w5KTcahXq6SGgo4C8sUc85NfIscnMnWROaFFVe8LiInq DchFQiqEN1yTJr/nyTnjV/BjHg9L2piXRmTrdxtDjQIYI2Fi7WLIRYTbfqeWwLZ4 AvWwCIh7mDzHM1QQ/+pVsNjJvDZS0Ae1NsM9JS7QRjPlBHVECt/AWqxMnSYsZFfa A7FyZyBzVtfp3QHYP2jQnS6ZcE4ErYd4aorrnvN4TMmaWzl0jcD3HeCf40SWGAVm HFzvANj530C3XyPSHHVyCjAGc9ijNO6K9vVZCJpsYceyM3OLMArwIWnuYwFQfqSN kmhbfOfbSOQhNaiECaZOkSlZEymq1//F25hr1uF0T8nQfXMZMh64NcOyXTysBhX3 WpCpujp/eAywpZaK40Odu2bBiVsSsBtdxkhQACcyIp1bnJslioE3GXEWmwBShP5A O1a09a3MZG+chAZgiLK4a12JqqapMO2so6Dq7CEw7See/Xkg0WkeTt7NtwTFPlvK R5x6gfr5EkE0uBWLAr8yJ4HtmUJY4BnlRqXxTYA2Za6d6x5vgIFgkDjQccnPD0JA 8pOaSTargAx7Y1PwZvPG
=X+XJ
-----END PGP SIGNATURE-----

#202 lore raw

PATCH v5 4/14 video: add Faraday FTLCDC200 LCD controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTLCDC200 Color LCD controller performs translation of pixel-coded data into the required formats and timings to drive a variety of single/dual mono and color LCDs.

Depending on the LCD type and mode, the unpacked data can represent:
1. an actual true display gray or color value
2. an address to a 256 x 16 bit wide palette RAM gray or color value.

The FTLCDC200 generates 4 individual interrupts for:
1. DMA FIFO underflow
2. base address update
3. vertical status
4. bus error.

There is also a single combined interrupt that is raised when any of the individual interrupts become active.

CC Albert Aribaud <[email protected]>
CC Anatolij Gustschin <[email protected]>

---
Changes for v5:
- Coding Style cleanup:

     struct chip_regs __iomem *regs -> struct chip_regs *regs

- Chain it back to Faraday A360/A369 patch series, because Faraday A369 depends on the header file of this patch for I2C work-around.(Enable I2C clock to prevent I2C bus hangs)

Changes for v4:
- Nothing updates

Changes for v3:
- Nothing updates

Changes for v2:
- Make it a separate patch, rather then a part of Faraday A36x patch series

 drivers/video/Makefile          |    1 +
 drivers/video/ftlcdc200.c       |  148 ++++++++++++++++++++++++++
 drivers/video/ftlcdc200_panel.c |  221 +++++++++++++++++++++++++++++++++++++++
 include/faraday/ftlcdc200.h     |  179 +++++++++++++++++++++++++++++++
 include/lcd.h                   |   33 ++++++
 5 files changed, 582 insertions(+)
 create mode 100644 drivers/video/ftlcdc200.c
 create mode 100644 drivers/video/ftlcdc200_panel.c
 create mode 100644 include/faraday/ftlcdc200.h
drivers/video/Makefile +1 -0
index 68ff34b..92ab9d1 100644
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_EXYNOS_MIPI_DSIM) += exynos_mipi_dsi.o exynos_mipi_dsi_common.o \
 				exynos_mipi_dsi_lowlevel.o
 COBJS-$(CONFIG_EXYNOS_PWM_BL) += exynos_pwm_bl.o
 COBJS-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o videomodes.o
+COBJS-$(CONFIG_FTLCDC200) += ftlcdc200.o ftlcdc200_panel.o
 COBJS-$(CONFIG_MPC8XX_LCD) += mpc8xx_lcd.o
 COBJS-$(CONFIG_PXA_LCD) += pxa_lcd.o
 COBJS-$(CONFIG_S6E8AX0) += s6e8ax0.o
drivers/video/ftlcdc200.c new file +148 -0

148 lines not on this page · raw message

drivers/video/ftlcdc200_panel.c new file +221 -0

221 lines not on this page · raw message

include/faraday/ftlcdc200.h new file +179 -0

179 lines not on this page · raw message

include/lcd.h +33 -0
index 30225ed..14fa4fd 100644
@@ -253,6 +253,39 @@ typedef struct vidinfo {
 
 void init_panel_info(vidinfo_t *vid);
 
+#elif defined(CONFIG_FTLCDC200)
+
+typedef struct vidinfo {
+	ushort	vl_col;		/* Number of columns (i.e. 800) */
+	ushort	vl_row;		/* Number of rows (i.e. 600) */
+
+	u_char	vl_bpix;	/* Bits per pixel, 0 = 1, 1 = 2 ... 4 = 16 */
+
+	/* Timing Parameters */
+	u_char	vl_fps;		/* Frame per second */
+
+	u_char	vl_hsw;
+	u_char	vl_hbp;
+	u_char	vl_hfp;
+
+	u_char	vl_vsw;
+	u_char	vl_vbp;
+	u_char	vl_vfp;
+
+	/* Pre-defined FTLCDC200 register values */
+	u_long	vl_enable;	/* LCDEnable */
+	u_long	vl_pixel;	/* PanelPixel */
+	u_long	vl_polarity;/* Polarity */
+	u_long	vl_serial;	/* SerialPanelPixel */
+	u_long	vl_ccir656;	/* CCIR656 */
+
+	/* Panel name */
+	char	*vl_name;
+
+	ushort	*cmap;		/* Pointer to the colormap */
+	void	*priv;		/* Pointer to driver-specific data */
+} vidinfo_t;
+
 #else
 
 typedef struct vidinfo {

--
1.7.9.5

#203 lore raw

PATCH v5 5/14 nand: add Faraday FTNANDC021 NAND controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTNANDC021 is a integrated NAND flash controller. It use a build-in command table to abstract the underlying NAND flash control logic.

For example:

Issuing a command 0x10 to FTNANDC021 would result in a page write + a read status operation.

CC Albert ARIBAUD <[email protected]>
CC Scott Wood <[email protected]>

---
Changes for v5 (Part of A360/A369 patch series):
- Coding Style cleanup:

     struct chip_regs __iomem *regs -> struct chip_regs *regs

- For there is a strong dependancy between this and A360/A369 patch series, it had been chained back to A360/A369 patch series.
- The latest nand_base requires the ecc.strength to be set properlly, so this patch adds ecc.strength setting accroding to ECC algorithm.

Changes for v5 (Standalone):
- Update README for the description of CONFIG_SYS_FTNANDC021_TIMING.
- Drop redundant white space. (i.e. if (mtd->writesize >= ' '4096))

Changes for v4:
- Make it a separate patch, rather then a part of Faraday A36x patch series
- Drop the faraday/nand.h to remove dependency to Faraday A36x patch series.
- CONFIG_SYS_NAND_TIMING -> CONFIG_SYS_FTNANDC021_TIMING
- Remove non-ECC code.
- Implement private hwecc read/write_page functions to get rid of .eccpos & .eccbytes.
- Use macro constants for timeout control

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- Re-write this driver with ECC enabled and correct column address handling for OOB read/write,
- Fix issuses addressed by Scott.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 README                        |    6 +
 drivers/mtd/nand/Makefile     |    1 +
 drivers/mtd/nand/ftnandc021.c |  622 +++++++++++++++++++++++++++++++++++++++++
 include/faraday/ftnandc021.h  |  153 ++++++++++
 4 files changed, 782 insertions(+)
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 include/faraday/ftnandc021.h
README +6 -0
index ac1ec44..3dbb7cc 100644
@@ -3930,6 +3930,12 @@ Low Level (hardware related) configuration options:
 		- drivers/mtd/nand/ndfc.c
 		- drivers/mtd/nand/mxc_nand.c
 
+- CONFIG_SYS_FTNANDC021_TIMING
+		This option specifies an array of customized timing parameters
+		for Faraday FTNANDC021 NAND flash controller.
+		e.g.
+		#define CONFIG_SYS_FTNANDC021_TIMING { 0x02240264, 0x42054209 }
+
 - CONFIG_SYS_NDFC_EBC0_CFG
 		Sets the EBC0_CFG register for the NDFC. If not defined
 		a default value will be used.
drivers/mtd/nand/Makefile +1 -0
index 8821704..f2c8b1a 100644
@@ -64,6 +64,7 @@ COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_FSMC) += fsmc_nand.o
+COBJS-$(CONFIG_NAND_FTNANDC021) += ftnandc021.o
 COBJS-$(CONFIG_NAND_JZ4740) += jz4740_nand.o
 COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
drivers/mtd/nand/ftnandc021.c new file +622 -0

622 lines not on this page · raw message

include/faraday/ftnandc021.h new file +153 -0

153 lines not on this page · raw message

--
1.7.9.5

#204 lore raw

PATCH v5 5/14 nand: add Faraday FTNANDC021 NAND controller support

Quoted 15 lines · Kuo-Jung Su
README +0 -0
index ac1ec44..3dbb7cc 100644
@@ -3930,6 +3930,12 @@ Low Level (hardware related) configuration  

options:

README +2 -0
 		- drivers/mtd/nand/ndfc.c
 		- drivers/mtd/nand/mxc_nand.c
 
+- CONFIG_SYS_FTNANDC021_TIMING
+		This option specifies an array of customized timing  

parameters

README +3 -0
+		for Faraday FTNANDC021 NAND flash controller.
+		e.g.
+		#define CONFIG_SYS_FTNANDC021_TIMING { 0x02240264,  
Quoted 1 line

0x42054209 }

But what does 0x02240264 mean? What does 0x42054209 mean? I wasn't looking for an example, but rather the name of the register you're going to use each array element to initialize.

README

Quoted 4 lines
README +4 -0
+	off = 0;
+	while (off < len && priv->col < mtd->writesize) {
+		ftnandc021_pio_wait(priv);
+		*(uint32_t *)(buf + off) = readl(&regs->dr);

This looks like illegal type-punning. Use memcpy.

Likewise elsewhere.

-Scott

#205 lore raw

PATCH v5 5/14 nand: add Faraday FTNANDC021 NAND controller support

2013/6/18 Scott Wood <[email protected]>:

Quoted 10 lines · Kuo-Jung Su
Quoted 9 lines
README +0 -0
index ac1ec44..3dbb7cc 100644
@@ -3930,6 +3930,12 @@ Low Level (hardware related) configuration options:
                - drivers/mtd/nand/ndfc.c
                - drivers/mtd/nand/mxc_nand.c
 
Quoted 13 lines
Quoted 7 lines
README +2 -0
+- CONFIG_SYS_FTNANDC021_TIMING
+               This option specifies an array of customized timing

parameters

README +3 -0
+               for Faraday FTNANDC021 NAND flash controller.
+               e.g.
+               #define CONFIG_SYS_FTNANDC021_TIMING { 0x02240264,

0x42054209 }

But what does 0x02240264 mean? What does 0x42054209 mean? I wasn't looking for an example, but rather the name of the register you're going to use each array element to initialize.

Got it, thanks

Quoted 9 lines

README

Quoted 4 lines
README +4 -0
+       off = 0;
+       while (off < len && priv->col < mtd->writesize) {
+               ftnandc021_pio_wait(priv);
+               *(uint32_t *)(buf + off) = readl(&regs->dr);

This looks like illegal type-punning. Use memcpy.

Likewise elsewhere.

How about put_unaligned() / get_unaligned() ?
It looks more simpler and safer to me.

--
Best wishes,
Kuo-Jung Su

#206 lore raw

PATCH v5 5/14 nand: add Faraday FTNANDC021 NAND controller support

Quoted 8 lines · Kuo-Jung Su

2013/6/18 Scott Wood <[email protected]>:

Quoted 7 lines · Kuo-Jung Su
Quoted 4 lines
drivers/mtd/nand/ftnandc021.c new file +4 -0
+       off = 0;
+       while (off < len && priv->col < mtd->writesize) {
+               ftnandc021_pio_wait(priv);
+               *(uint32_t *)(buf + off) = readl(&regs->dr);
Quoted 6 lines
Quoted 3 lines

This looks like illegal type-punning. Use memcpy.

Likewise elsewhere.

How about put_unaligned() / get_unaligned() ?
It looks more simpler and safer to me.

That's fine too.

-Scott

#207 lore raw

PATCH v5 6/14 cfi_flash: use buffer length in unmap_physmem()

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

While the flash_detect_legacy() of drivers/mtd/cfi_flash.c feed unmap_physmem() with MAP_NOCACHE as 2nd parameter, the do_spi_flash_read_write() of common/cmd_sf.c feed unmap_physmem() with the length of the mapped buffer as 2nd parameter.

It's apparently a bug, and I personally think the 2nd parameter should be the length of the mapped buffer.

CC Albert Aribaud <[email protected]>
CC Stefan Roese <[email protected]>

---
Changes for v5:
- Initial commit, which is separated from "arm: add MMU/D-Cache support for Faraday cores"

 drivers/mtd/cfi_flash.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/cfi_flash.c +1 -1
index 25f8752..0d7a5ac 100644
@@ -1820,7 +1820,7 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 					break;
 				else
 					unmap_physmem((void *)info->start[0],
-						      MAP_NOCACHE);
+						      info->portwidth);
 			}
 		}
 

--
1.7.9.5

#208 lore raw

PATCH v5 7/14 arm: add MMU/D-Cache support for Faraday cores

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This updates the map_physmem()/unmap_physmem(), and use them to implement dma_alloc_coherent() & dma_free_coherent().

It uses 1MB section for each mapping, and thus wastes lots of address space, however this should still be good enough for tiny systems (i.e. u-boot).

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Add void dram_bank_mmu_setup() into 'arch/arm/cpu/faraday/cpu.c' to override the weak function in "cache-cp15.c".
- Use small page (4KB) to map relocated exception table to 0x0000

Changes for v4:
- Coding Style cleanup.

Changes for v3:
- Coding Style cleanup.
- Always insert a blank line between declarations and code.
- dma-mapping.h: Have the global data ptr declared outside functions.
- dma-mapping.h: Add #if...#else...#endif to dma_free_coherent().
- Drop static non-cached region, now we use map_physmem()/unmap_physmem() for dynamic mappings.

Changes for v2:
- Coding Style cleanup.
- cache-cp15: Enable write buffer in write-through mode.

 arch/arm/include/asm/dma-mapping.h |   59 ++++++++++++-
 arch/arm/include/asm/global_data.h |    4 +
 arch/arm/include/asm/io.h          |  160 ++++++++++++++++++++++++++++++++++--
 arch/arm/include/asm/system.h      |    7 +-
 arch/arm/lib/cache-cp15.c          |   12 +++
 5 files changed, 230 insertions(+), 12 deletions(-)
arch/arm/include/asm/dma-mapping.h +58 -1
index a11178f..5a13af5 100644
@@ -3,6 +3,9 @@
  * Stelian Pop <[email protected]>
  * Lead Tech Design <www.leadtechdesign.com>
  *
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -24,22 +27,76 @@
 #ifndef __ASM_ARM_DMA_MAPPING_H
 #define __ASM_ARM_DMA_MAPPING_H
 
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <malloc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
+
 enum dma_data_direction {
 	DMA_BIDIRECTIONAL	= 0,
 	DMA_TO_DEVICE		= 1,
 	DMA_FROM_DEVICE		= 2,
 };
 
-static void *dma_alloc_coherent(size_t len, unsigned long *handle)
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	void *map, *va = memalign(ARCH_DMA_MINALIGN, len);
+
+	if (va && gd->arch.cpu_mmu) {
+		invalidate_dcache_range((ulong)va, (ulong)va + len);
+		map = map_physmem((phys_addr_t)va, len, MAP_NOCACHE);
+		if (!map)
+			free(va);
+		va = map;
+	}
+
+	if (handle)
+		*handle = virt_to_phys(va);
+
+	return va;
+#else  /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
 	*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
 	return (void *)*handle;
+#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
+}
+
+static inline void dma_free_coherent(void *vaddr, ulong len)
+{
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	void *tmp = (void *)virt_to_phys(vaddr);
+	unmap_physmem(vaddr, len);
+	vaddr = tmp;
+#endif
+	free(vaddr);
 }
 
 static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
 					   enum dma_data_direction dir)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	if (gd->arch.cpu_mmu) {
+		switch (dir) {
+		case DMA_BIDIRECTIONAL:
+		case DMA_TO_DEVICE:
+			flush_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+
+		case DMA_FROM_DEVICE:
+			invalidate_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+		}
+	}
+	return virt_to_phys((void *)vaddr);
+#else  /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
 	return (unsigned long)vaddr;
+#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
 }
 
 static inline void dma_unmap_single(volatile void *vaddr, size_t len,
arch/arm/include/asm/global_data.h +4 -0
index 7611d0a..fc78c6a 100644
@@ -42,6 +42,10 @@ struct arch_global_data {
 	unsigned long	pllb_rate_hz;
 	unsigned long	at91_pllb_usb_init;
 #endif
+#ifdef CONFIG_FARADAY
+	unsigned long   cpu_id;
+	unsigned long   cpu_mmu;	/* has mmu */
+#endif
 	/* "static data" needed by most of timer.c on ARM platforms */
 	unsigned long timer_rate_hz;
 	unsigned long tbu;
arch/arm/include/asm/io.h +152 -8

194 lines not on this page · raw message

arch/arm/include/asm/system.h +4 -3
index 760345f..050b707 100644
@@ -97,9 +97,10 @@ static inline void set_dacr(unsigned int val)
 
 /* options available for data cache on each page */
 enum dcache_option {
-	DCACHE_OFF = 0x12,
-	DCACHE_WRITETHROUGH = 0x1a,
-	DCACHE_WRITEBACK = 0x1e,
+	DCACHE_OFF = 0x12,          /* non-cached + non-buffered */
+	DCACHE_WRITECOMBINE = 0x16, /* non-cached + buffered */
+	DCACHE_WRITETHROUGH = 0x1a, /* cached + non-buffered */
+	DCACHE_WRITEBACK = 0x1e,    /* cached + buffered */
 };
 
 /* Size of an MMU section */
arch/arm/lib/cache-cp15.c +12 -0
index 4abe1cf..97436f6 100644
@@ -1,6 +1,8 @@
 /*
  * (C) Copyright 2002
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -126,6 +128,10 @@ static inline void mmu_setup(void)
 
 	/* and enable the mmu */
 	reg = get_cr();	/* get control reg. */
+#ifdef CONFIG_FARADAY
+	reg |= CR_W;	/* enable write buffer */
+	reg |= CR_Z;	/* enable branch prediction */
+#endif
 	cp_delay();
 	set_cr(reg | CR_M);
 }
@@ -140,9 +146,15 @@ static void cache_enable(uint32_t cache_bit)
 {
 	uint32_t reg;
 
+#ifdef CONFIG_FARADAY
+	if (!gd->arch.cpu_mmu && (cache_bit == CR_C))
+		return;
+#endif
+
 	/* The data cache is not active unless the mmu is enabled too */
 	if ((cache_bit == CR_C) && !mmu_enabled())
 		mmu_setup();
+
 	reg = get_cr();	/* get control reg. */
 	cp_delay();
 	set_cr(reg | cache_bit);

--
1.7.9.5

#209 lore raw

PATCH v5 8/14 arm: add Faraday processor core support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This adds i/d-cache control, mmu setup & bootstrap code for Faraday cores.

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Initial commit which is separated from
"arm: add Faraday common utilities"

 arch/arm/cpu/faraday/Makefile  |   55 +++++
 arch/arm/cpu/faraday/config.mk |   33 +++
 arch/arm/cpu/faraday/cpu.c     |  346 ++++++++++++++++++++++++++++++++
 arch/arm/cpu/faraday/start.S   |  431 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 865 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/start.S
arch/arm/cpu/faraday/Makefile new file +55 -0
new file mode 100644
index 0000000..ecb240a
@@ -0,0 +1,55 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+src-y  := cpu.o
+
+START	= start.o
+COBJS	= $(src-y)
+
+ifdef	CONFIG_SPL_BUILD
+ifdef	CONFIG_SPL_NO_CPU_SUPPORT_CODE
+START	:=
+endif
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/faraday/config.mk new file +33 -0
new file mode 100644
index 0000000..f03030a
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2002
+# Gary Jennejohn, DENX Software Engineering, <[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
+#
+
+PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
+
+PLATFORM_CPPFLAGS += -march=armv4
+# =========================================================================
+#
+# Supply options according to compiler version
+#
+# =========================================================================
+PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
+PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)
arch/arm/cpu/faraday/cpu.c new file +346 -0

346 lines not on this page · raw message

arch/arm/cpu/faraday/start.S new file +431 -0

431 lines not on this page · raw message

--
1.7.9.5

#210 lore raw

PATCH v5 9/14 arm: add Faraday FTINTC020 interrupt controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Coding Style cleanup.
- Now the irq is always enabled inside irq_install_handler().

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 arch/arm/cpu/faraday/Makefile    |    1 +
 arch/arm/cpu/faraday/ftintc020.c |  156 ++++++++++++++++++++++++++++++++++++++
 include/common.h                 |    3 +
 include/faraday/ftintc020.h      |   37 +++++++++
 4 files changed, 197 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/ftintc020.c
 create mode 100644 include/faraday/ftintc020.h
arch/arm/cpu/faraday/Makefile +1 -0
index ecb240a..35926c2 100644
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).o
 
 src-y  := cpu.o
+src-$(CONFIG_FTINTC020)   += ftintc020.o
 
 START	= start.o
 COBJS	= $(src-y)
arch/arm/cpu/faraday/ftintc020.c new file +156 -0

156 lines not on this page · raw message

include/common.h +3 -0
index 126891d..812e9b6 100644
@@ -110,6 +110,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_SOC_DA8XX
 #include <asm/arch/hardware.h>
 #endif
+#ifdef CONFIG_FARADAY
+#include <asm/arch-faraday/interrupt.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
include/faraday/ftintc020.h new file +37 -0
new file mode 100644
index 0000000..e23d1e7
@@ -0,0 +1,37 @@
+/*
+ * arch/arm/cpu/faraday/ftintc020.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FTINTC020_H
+#define ARCH_ARM_CPU_FARADAY_FTINTC020_H
+
+struct ftintc020_pic_regs {
+	uint32_t src; /* source register */
+	uint32_t ena; /* enable register */
+	uint32_t scr; /* status clear register */
+	uint32_t tmr; /* trigger mode register */
+	uint32_t tlr; /* trigger level register */
+	uint32_t sr;  /* status register */
+	uint32_t rsvd[2];
+};
+
+struct ftintc020_regs {
+	/* IRQ/FIQ:  0 ~ 31 */
+	struct ftintc020_pic_regs irq32; /* 0x00 - 0x1C: IRQ 0 ~ 31 */
+	struct ftintc020_pic_regs fiq32; /* 0x20 - 0x3C: FIQ 0 ~ 31 */
+	uint32_t rsvd1[4];               /* 0x40 - 0x4C: Reserved */
+	uint32_t revision;               /* 0x50: Revision Register */
+	uint32_t feature;                /* 0x54: Feature Register */
+	uint32_t rsvd2[2];               /* 0x58 - 0x5C: Reserved */
+	/* IRQ/FIQ: 32 ~ 63 */
+	struct ftintc020_pic_regs irq64; /* 0x60 - 0x7C: IRQ 32 ~ 63 */
+	struct ftintc020_pic_regs fiq64; /* 0x80 - 0x9C: FIQ 32 ~ 63 */
+};
+
+#endif

--
1.7.9.5

#211 lore raw

PATCH v5 10/14 arm: add Faraday FTTMR010 timer support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Drop IRQ dependant implementation
- Use gd->arch.timer_rate_hz for timer clock source
- Use gd->arch.tbl for timestamp

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 arch/arm/cpu/faraday/Makefile   |    1 +
 arch/arm/cpu/faraday/fttmr010.c |  136 +++++++++++++++++++++++++++++++++++++++
 include/faraday/fttmr010.h      |   17 +++++
 3 files changed, 154 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
arch/arm/cpu/faraday/Makefile +1 -0
index 35926c2..658d9ed 100644
@@ -27,6 +27,7 @@ LIB	= $(obj)lib$(CPU).o
 
 src-y  := cpu.o
 src-$(CONFIG_FTINTC020)   += ftintc020.o
+src-$(CONFIG_FTTMR010)    += fttmr010.o
 
 START	= start.o
 COBJS	= $(src-y)
arch/arm/cpu/faraday/fttmr010.c new file +136 -0

136 lines not on this page · raw message

include/faraday/fttmr010.h +17 -0
index 72abcb3..ef10f31 100644
@@ -57,6 +57,16 @@ struct fttmr010 {
 #define FTTMR010_TM1_CLOCK	(1 << 1)
 #define FTTMR010_TM1_ENABLE	(1 << 0)
 
+#define FTTMR010_TM1_CRMASK \
+	(FTTMR010_TM1_UPDOWN | FTTMR010_TM1_OFENABLE \
+	| FTTMR010_TM1_CLOCK | FTTMR010_TM1_ENABLE)
+#define FTTMR010_TM2_CRMASK \
+	(FTTMR010_TM2_UPDOWN | FTTMR010_TM2_OFENABLE \
+	| FTTMR010_TM2_CLOCK | FTTMR010_TM2_ENABLE)
+#define FTTMR010_TM3_CRMASK \
+	(FTTMR010_TM3_UPDOWN | FTTMR010_TM3_OFENABLE \
+	| FTTMR010_TM3_CLOCK | FTTMR010_TM3_ENABLE)
+
 /*
  * Timer Interrupt State & Mask Registers
  */
@@ -70,4 +80,11 @@ struct fttmr010 {
 #define FTTMR010_TM1_MATCH2	(1 << 1)
 #define FTTMR010_TM1_MATCH1	(1 << 0)
 
+#define FTTMR010_TM1_ISRMASK \
+	(FTTMR010_TM1_OVERFLOW | FTTMR010_TM1_MATCH2 | FTTMR010_TM1_MATCH1)
+#define FTTMR010_TM2_ISRMASK \
+	(FTTMR010_TM2_OVERFLOW | FTTMR010_TM2_MATCH2 | FTTMR010_TM2_MATCH1)
+#define FTTMR010_TM3_ISRMASK \
+	(FTTMR010_TM3_OVERFLOW | FTTMR010_TM3_MATCH2 | FTTMR010_TM3_MATCH1)
+
 #endif	/* __FTTMR010_H */

--
1.7.9.5

#212 lore raw

PATCH v5 11/14 arm: add Faraday FTPWMTMR010 timer support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Drop IRQ dependant implementation
- Use gd->arch.timer_rate_hz for timer clock source
- Use gd->arch.tbl for timestamp

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 arch/arm/cpu/faraday/Makefile      |    1 +
 arch/arm/cpu/faraday/ftpwmtmr010.c |  128 ++++++++++++++++++++++++++++++++++++
 include/faraday/ftpwmtmr010.h      |   41 ++++++++++++
 3 files changed, 170 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 include/faraday/ftpwmtmr010.h
arch/arm/cpu/faraday/Makefile +1 -0
index 658d9ed..6b96e32 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)lib$(CPU).o
 src-y  := cpu.o
 src-$(CONFIG_FTINTC020)   += ftintc020.o
 src-$(CONFIG_FTTMR010)    += fttmr010.o
+src-$(CONFIG_FTPWMTMR010) += ftpwmtmr010.o
 
 START	= start.o
 COBJS	= $(src-y)
arch/arm/cpu/faraday/ftpwmtmr010.c new file +128 -0

128 lines not on this page · raw message

include/faraday/ftpwmtmr010.h new file +41 -0

41 lines not on this page · raw message

--
1.7.9.5

#213 lore raw

PATCH v5 12/14 arm: add Faraday specific boot command

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

At the time of writting, none of Faraday NAND & SPI controllers supports XIP (eXecute In Place). So the Faraday A360/A369 SoC has to implement a 1st level bootstrap code stored in the embedded ROM inside the SoC.

After power-on, the ROM code (1st level bootstrap code) would load the 2nd bootstrap code into SRAM without any SDRAM initialization.

The 2nd bootstrap code would then initialize SDRAM and load the generic firmware (u-boot/linux) into SDRAM, and finally make a long-jump to the firmware.

Which means the SPL design of U-boot would never fit to A360/A369, since it's usually not possible to alter a embedded ROM code. And because both the 1st & 2nd level bootstrap code use the private Faraday Firmware Image Format, it would be better to drop U-boot image support to simplify the design.

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Rename from 'arm: add Faraday firmware image utility' into 'arm: add Faraday specific boot command'
- Add missing CRC check to the command 'bootfa'.
- Add rationale to the command 'bootfa'.

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Always insert a blank line between declarations and code.

Changes for v2:
- Coding Style cleanup.

 arch/arm/cpu/faraday/Makefile     |    2 +-
 arch/arm/cpu/faraday/cmd_bootfa.c |  276 +++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/faraday/fwimage.h    |   47 +++++++
 arch/arm/cpu/faraday/fwimage2.h   |   67 +++++++++
 arch/arm/cpu/u-boot.lds           |   11 ++
 5 files changed, 402 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
arch/arm/cpu/faraday/Makefile +1 -1
index 6b96e32..ef6a72e 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(CPU).o
 
-src-y  := cpu.o
+src-y  := cpu.o cmd_bootfa.o
 src-$(CONFIG_FTINTC020)   += ftintc020.o
 src-$(CONFIG_FTTMR010)    += fttmr010.o
 src-$(CONFIG_FTPWMTMR010) += ftpwmtmr010.o
arch/arm/cpu/faraday/cmd_bootfa.c new file +276 -0

276 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage.h new file +47 -0

47 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage2.h new file +67 -0

67 lines not on this page · raw message

arch/arm/cpu/u-boot.lds +11 -0
index d9bbee3..ac59fec 100644
@@ -23,6 +23,8 @@
  * MA 02111-1307 USA
  */
 
+#include <config.h>
+
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -35,6 +37,15 @@ SECTIONS
 	{
 		__image_copy_start = .;
 		CPUDIR/start.o (.text*)
+#ifdef CONFIG_FARADAY
+		/*
+		 * Dante Su 2012.10.09:
+		 * Reserved for the faimage v2.1.
+		 * 1. CPUDIR/start.o: It shall never be > 4KB.
+		 * 2. faimage header: It shall always be stored at 0x1000, and <= 1KB.
+		 */
+		. = 0x00001400;
+#endif
 		*(.text*)
 	}
 

--
1.7.9.5

#214 lore raw

PATCH v5 12/14 arm: add Faraday specific boot command

Hi Kuo-Jung,

Quoted 14 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

At the time of writting, none of Faraday NAND & SPI controllers supports XIP (eXecute In Place). So the Faraday A360/A369 SoC has to implement a 1st level bootstrap code stored in the embedded ROM inside the SoC.

After power-on, the ROM code (1st level bootstrap code) would load the 2nd bootstrap code into SRAM without any SDRAM initialization.

The 2nd bootstrap code would then initialize SDRAM and load the generic firmware (u-boot/linux) into SDRAM, and finally make a long-jump to the firmware.

Quoted 5 lines

Which means the SPL design of U-boot would never fit to A360/A369, since it's usually not possible to alter a embedded ROM code. And because both the 1st & 2nd level bootstrap code use the private Faraday Firmware Image Format, it would be better to drop U-boot image support to simplify the design.

Please reword the last sentence: you're not suggesting "to drop U-boot support" from U-Boot, right? You're only suggesting adding the Faraday image format.

Also, maybe the long explanation should go in the cover letter and a single shorter paragraph should be given as commit message here.

Quoted 3 lines
CC Albert Aribaud <[email protected]>

---

Amicalement,

Signature · 1 line
Albert.
#215 lore raw

PATCH v5 12/14 arm: add Faraday specific boot command

2013/6/23 Albert ARIBAUD <[email protected]>:

Quoted 25 lines

Hi Kuo-Jung,

Quoted 14 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

At the time of writting, none of Faraday NAND & SPI controllers supports XIP (eXecute In Place). So the Faraday A360/A369 SoC has to implement a 1st level bootstrap code stored in the embedded ROM inside the SoC.

After power-on, the ROM code (1st level bootstrap code) would load the 2nd bootstrap code into SRAM without any SDRAM initialization.

The 2nd bootstrap code would then initialize SDRAM and load the generic firmware (u-boot/linux) into SDRAM, and finally make a long-jump to the firmware.

Quoted 5 lines

Which means the SPL design of U-boot would never fit to A360/A369, since it's usually not possible to alter a embedded ROM code. And because both the 1st & 2nd level bootstrap code use the private Faraday Firmware Image Format, it would be better to drop U-boot image support to simplify the design.

Quoted 4 lines

Please reword the last sentence: you're not suggesting "to drop U-boot support" from U-Boot, right? You're only suggesting adding the Faraday image format.

1. Got it, I'll reword the last sentence.
2. Yes, what I meant is "Drop u-boot image support in Faraday image utility" However I forget that's a tool which is not actually related to U-boot. :P

Quoted 3 lines

Also, maybe the long explanation should go in the cover letter and a single shorter paragraph should be given as commit message here.

Got it, thanks.

--
Best wishes,
Kuo-Jung Su

#216 lore raw

PATCH v5 13/14 mmc: ftsdc010_mci: clk_get_rate() -> clock_get_rate()

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This updates ftsdc010_mci.c for latest Faraday clock APIs.

CC Albert Aribaud <[email protected]>
CC Andy Fleming <[email protected]>

---
Changes for v5:
- Initial commit

 drivers/mmc/ftsdc010_mci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/ftsdc010_mci.c +1 -1
index 562b14a..0a0a19b 100644
@@ -363,7 +363,7 @@ int ftsdc010_mmc_init(int devid)
 #ifdef CONFIG_SYS_CLK_FREQ
 	chip->sclk = CONFIG_SYS_CLK_FREQ;
 #else
-	chip->sclk = clk_get_rate("SDC");
+	chip->sclk = clock_get_rate(MMC_CLK);
 #endif
 
 	mmc->voltages  = MMC_VDD_32_33 | MMC_VDD_33_34;

--
1.7.9.5

#217 lore raw

PATCH v5 13/14 mmc: ftsdc010_mci: clk_get_rate() -> clock_get_rate()

Quoted 8 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This updates ftsdc010_mci.c for latest Faraday clock APIs.

CC Albert Aribaud <[email protected]>
CC Andy Fleming <[email protected]>

Since this is part of a series, it should go in with the rest of them, rather than through the mmc tree.

Andy

#218 lore raw

PATCH v5 13/14 mmc: ftsdc010_mci: clk_get_rate() -> clock_get_rate()

2013/6/18 Andy Fleming <[email protected]>:

Quoted 15 lines · Kuo-Jung Su
Quoted 8 lines

From: Kuo-Jung Su <[email protected]>

This updates ftsdc010_mci.c for latest Faraday clock APIs.

CC Albert Aribaud <[email protected]>
CC Andy Fleming <[email protected]>
Quoted 5 lines

Since this is part of a series, it should go in with the rest of them, rather than through the mmc tree.

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#219 lore raw

PATCH v5 14/14 arm: add Faraday A360/A369 SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This adds board support for the Faraday A360/A369 SoC platforms.

Working functions:
- MMU/D-cache
- SD Host controller
- USB EHCI controller
- USB Gadget controller
- Network
- NAND

CC Albert Aribaud <[email protected]>

---
Changes for v5:
- Coding Style cleanup:
1. struct chip_regs __iomem *regs -> struct chip_regs *regs
2. Move Faraday specific APIs into asm/arch-faraday/*.h
- Fix Copyright notices (dates) throughout the patch
- Define Faraday machine type in board's config header file
- Add myself as the maintainer for Faraday A360/A369 in MAINTAINERS.
- Drop i2c:FTI2C010 & spi:FTSSP010_SPI support. The corresponding patch would restart after this patch series have been accepted.
- Revise clock management system

Changes for v4:
- Coding Style cleanup.
- Break-down the interrupt, timers and common utilties.

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.
- a36x_config: No more static global network configurations.
- a36x_config: Add a common file for the redundant configurations.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 MAINTAINERS                                   |    5 +
 arch/arm/cpu/faraday/a360/Makefile            |   49 +++++
 arch/arm/cpu/faraday/a369/Makefile            |   50 +++++
 arch/arm/cpu/faraday/a369/cmd_fa606.c         |   86 +++++++++
 arch/arm/include/asm/arch-a360/hardware.h     |   84 +++++++++
 arch/arm/include/asm/arch-a360/pmu.h          |   54 ++++++
 arch/arm/include/asm/arch-a360/scu.h          |   48 +++++
 arch/arm/include/asm/arch-a369/ahbc.h         |   34 ++++
 arch/arm/include/asm/arch-a369/hardware.h     |   99 ++++++++++
 arch/arm/include/asm/arch-a369/scu.h          |  224 +++++++++++++++++++++++
 arch/arm/include/asm/arch-faraday/clock.h     |   41 +++++
 arch/arm/include/asm/arch-faraday/interrupt.h |   29 +++
 board/faraday/a360evb/Makefile                |   49 +++++
 board/faraday/a360evb/board.c                 |   72 ++++++++
 board/faraday/a360evb/clock.c                 |   72 ++++++++
 board/faraday/a360evb/config.mk               |   33 ++++
 board/faraday/a360evb/lowlevel_init.S         |   33 ++++
 board/faraday/a369evb/Makefile                |   49 +++++
 board/faraday/a369evb/board.c                 |  176 ++++++++++++++++++
 board/faraday/a369evb/clock.c                 |   80 ++++++++
 board/faraday/a369evb/config.mk               |   33 ++++
 board/faraday/a369evb/lowlevel_init.S         |  136 ++++++++++++++
 boards.cfg                                    |    3 +
 include/common.h                              |    2 +
 include/configs/a360.h                        |   60 ++++++
 include/configs/a369-common.h                 |   72 ++++++++
 include/configs/a369.h                        |   34 ++++
 include/configs/a369_fa606te.h                |   31 ++++
 include/configs/faraday-common.h              |  243 +++++++++++++++++++++++++
 include/faraday/ftsmc020.h                    |    1 +
 30 files changed, 1982 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a360/pmu.h
 create mode 100644 arch/arm/include/asm/arch-a360/scu.h
 create mode 100644 arch/arm/include/asm/arch-a369/ahbc.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/scu.h
 create mode 100644 arch/arm/include/asm/arch-faraday/clock.h
 create mode 100644 arch/arm/include/asm/arch-faraday/interrupt.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clock.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clock.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369-common.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_fa606te.h
 create mode 100644 include/configs/faraday-common.h
MAINTAINERS +5 -0
index 14075af..65f00aa 100644
@@ -643,6 +643,11 @@ Po-Yu Chuang <[email protected]>
 
 	a320evb		FA526 (ARM920T-like) (a320 SoC)
 
+Kuo-Jung Su <[email protected]>
+
+	a360evb		FA626TE (Faraday ARMv5TE) (a360 SoC)
+	a369evb		FA626TE & FA606TE (Faraday ARMv5TE) (a369 SoC)
+
 Eric Cooper <[email protected]>
 
 	dockstar	ARM926EJS (Kirkwood SoC)
arch/arm/cpu/faraday/a360/Makefile new file +49 -0

49 lines not on this page · raw message

arch/arm/cpu/faraday/a369/Makefile new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/faraday/a369/cmd_fa606.c new file +86 -0

86 lines not on this page · raw message

arch/arm/include/asm/arch-a360/hardware.h new file +84 -0

84 lines not on this page · raw message

arch/arm/include/asm/arch-a360/pmu.h new file +54 -0

54 lines not on this page · raw message

arch/arm/include/asm/arch-a360/scu.h new file +48 -0

48 lines not on this page · raw message

arch/arm/include/asm/arch-a369/ahbc.h new file +34 -0
new file mode 100644
index 0000000..5a77825
@@ -0,0 +1,34 @@
+/*
+ * arch/arm/include/asm/arch-a369/ahbc.h
+ *
+ * (C) Copyright 2013 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * 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 __ASM_ARCH_AHBC_H
+#define __ASM_ARCH_AHBC_H
+
+struct a369ahbc_regs {
+	uint32_t slave[32];/* Slave Device Configurations */
+	uint32_t priority; /* Priority */
+	uint32_t idle_cnt; /* IDLE Counter */
+	uint32_t control;  /* Control Register */
+	uint32_t revision; /* Revision ID */
+	uint32_t cpusao;   /* CPUS (FA606TE) Address Offset */
+};
+
+#endif
arch/arm/include/asm/arch-a369/hardware.h new file +99 -0

99 lines not on this page · raw message

arch/arm/include/asm/arch-a369/scu.h new file +224 -0

224 lines not on this page · raw message

arch/arm/include/asm/arch-faraday/clock.h new file +41 -0

41 lines not on this page · raw message

arch/arm/include/asm/arch-faraday/interrupt.h new file +29 -0
new file mode 100644
index 0000000..8a38946
@@ -0,0 +1,29 @@
+/*
+ * asm/arch-faraday/interrupt.h
+ *
+ * (C) Copyright 2013 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * 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 _ASM_ARCH_FARADAY_INTERRUPT_H
+#define _ASM_ARCH_FARADAY_INTERRUPT_H
+
+void irq_set_trigger(int irq, int edge, int low);
+void irq_enable(int irq);
+void irq_disable(int irq);
+
+#endif	/* _ASM_ARCH_FARADAY_INTERRUPT_H */
board/faraday/a360evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a360evb/board.c new file +72 -0

72 lines not on this page · raw message

board/faraday/a360evb/clock.c new file +72 -0

72 lines not on this page · raw message

board/faraday/a360evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a360evb/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000..0d6c43f
@@ -0,0 +1,33 @@
+/*
+ * Board specific setup info
+ *
+ * (C) Copyright 2013
+ * Faraday Technology Inc. <www.faraday-tech.com>
+ * Dante Su <[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 <version.h>
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+	mov	pc,lr
board/faraday/a369evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a369evb/board.c new file +176 -0

176 lines not on this page · raw message

board/faraday/a369evb/clock.c new file +80 -0

80 lines not on this page · raw message

board/faraday/a369evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a369evb/lowlevel_init.S new file +136 -0

136 lines not on this page · raw message

boards.cfg +3 -0
index e2a8d42..16610e2 100644
@@ -73,6 +73,9 @@ mini2440                     arm         arm920t     mini2440            friendl
 VCMA9                        arm         arm920t     vcma9               mpl            s3c24x0
 smdk2410                     arm         arm920t     -                   samsung        s3c24x0
 omap1510inn                  arm         arm925t     -                   ti
+a360                         arm         faraday     a360evb             faraday        a360
+a369                         arm         faraday     a369evb             faraday        a369
+a369_fa606te                 arm         faraday     a369evb             faraday        a369
 integratorap_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorap:CM926EJ_S
 integratorcp_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorcp:CM924EJ_S
 aspenite                     arm         arm926ejs   -                   Marvell        armada100
include/common.h +2 -0
index 812e9b6..dc48a84 100644
@@ -111,6 +111,8 @@ typedef volatile unsigned char	vu_char;
 #include <asm/arch/hardware.h>
 #endif
 #ifdef CONFIG_FARADAY
+#include <asm/arch/hardware.h>
+#include <asm/arch-faraday/clock.h>
 #include <asm/arch-faraday/interrupt.h>
 #endif
 
include/configs/a360.h new file +60 -0

60 lines not on this page · raw message

include/configs/a369-common.h new file +72 -0

72 lines not on this page · raw message

include/configs/a369.h new file +34 -0
new file mode 100644
index 0000000..da7856e
@@ -0,0 +1,34 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_A369_PLATFORM
+
+/* Support USB-EHCI */
+#define CONFIG_SUPP_EHCI_FARADAY
+
+/* Support external AHB */
+/* #define CONFIG_SUPP_EXTAHB */
+
+/* Support USB RNDIS Ethernet */
+/* #define CONFIG_SUPP_USB_RNDIS */
+
+/* Support VGA Console */
+/* #define CONFIG_SUPP_VGA_CONSOLE */
+
+/* Support interrupt */
+/* #define CONFIG_USE_IRQ */
+
+/* Disable MMU/D-CACHE */
+/* #define CONFIG_SYS_DCACHE_OFF */
+
+/* Support runtime switching to built-in slave core: FA606TE */
+#define CONFIG_CMD_FA606
+
+/* Autoboot */
+#define CONFIG_BOOTDELAY            3
+#define CONFIG_BOOTCOMMAND          "bootfa nand linux"
+
+/* A369 common configuration */
+#include "a369-common.h"
+
+#endif
include/configs/a369_fa606te.h new file +31 -0
new file mode 100644
index 0000000..c549edb
@@ -0,0 +1,31 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_A369_FA606TE_PLATFORM
+
+/* Support external AHB */
+/* #define CONFIG_SUPP_EXTAHB */
+
+/* Support USB RNDIS Ethernet */
+/* #define CONFIG_SUPP_USB_RNDIS */
+
+/* Support VGA Console */
+/* #define CONFIG_SUPP_VGA_CONSOLE */
+
+/* Support interrupt */
+/* #define CONFIG_USE_IRQ */
+
+/* Disable MMU/D-CACHE */
+#define CONFIG_SYS_DCACHE_OFF
+
+/* Disable I-CACHE */
+#define CONFIG_SYS_ICACHE_OFF
+
+/* Set interrupt controler to FTINCT020:1 */
+#undef  CONFIG_FTINTC020_BASE
+#define CONFIG_FTINTC020_BASE       CONFIG_FTINTC020_BASE1
+
+/* A369 common configuration */
+#include "a369-common.h"
+
+#endif
include/configs/faraday-common.h new file +243 -0

243 lines not on this page · raw message

include/faraday/ftsmc020.h +1 -0
index 59c6f8e..aa02717 100644
@@ -82,5 +82,6 @@ void ftsmc020_init(void);
 #define FTSMC020_TPR_WTC(x)	(((x) & 0x3) << 6)
 #define FTSMC020_TPR_AHT(x)	(((x) & 0x3) << 4)
 #define FTSMC020_TPR_TRNA(x)	(((x) & 0xf) << 0)
+#define FTSMC020_TPR_WORST	0x0f1ff3ff /* worst but safe */
 
 #endif	/* __FTSMC020_H */

--
1.7.9.5

#220 lore raw

v6 cover arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

These patches introduce Faraday A36x SoC platform support.

Here are some public documents for your reference.

http://www.faraday-tech.com/html/documentation/index.html

There is also a A369 QEMU emulator available at my github account:

https://github.com/dantesu1218/qemu.git

Here is quick start for QEMU + U-Boot:

1. Download the QEMU source tree

   $ git clone -b qemu-1.4.0 https://github.com/dantesu1218/qemu.git

2. Build & Install the QEMU:

   $ ./configure --target-list=arm-softmmu
   $ make
   $ make install

3. Launch u-boot with QEMU:

   $ qemu-system-arm -M a369 -m 512M -nographic -kernel ~/u-boot-2013.04/u-boot

Changes for v6:
- Drop ethernet driver updates for ftmac110&ftgmac100, because they are already commited.
- arch/arm/cpu/faraday/cpu.c:

     struct ftwdt010_wdt __iomem *regs -> struct ftwdt010_wdt *regs

- arch/arm/cpu/faraday/cmd_bootfa.c: fix compiler warnning
- arch/arm/cpu/faraday/cmd_bootfa.c: use shorter paragraph in commit message, and move the original statement into the top of source file.
- ftnandc021: update README for CONFIG_SYS_FTNANDC021_TIMING
- ftnandc021: remove illegal type-punning

Changes for v5:
- Coding Style cleanup:
1. struct chip_regs __iomem *regs -> struct chip_regs *regs
2. Move Faraday specific APIs into asm/arch-faraday/*.h
- Fix Copyright notices (dates) throughout the patch
- Make 'arm: dma_alloc_coherent: malloc() -> memalign()' as a separate patch
- Make 'cfi_flash: use buffer length in unmap_physmem()' as a separate patch
- Define Faraday machine type in board's config header file
- Add the rationale to the command 'bootfa'
- Add myself as the maintainer for Faraday A360/A369 in MAINTAINERS.
- Chain the video:FTLCDC200 back to this patch series.
- Chain the nand:FTNANDC021 back to this patch series.
- Chain the net:FTGMAC100 & FTMAC110 back to this patch series.
- Update Faraday Firmware Image Format:
1. Drop u-boot image support to simplify the design.
Since it's not possible for the hard-wired ROM code of A360/A369 to support U-boot images. And the real bootloader for A360/A369 is actually Faraday bootcode2, rather than U-Boot.
2. Add image creation timestamp
- Update 'arch/arm/cpu/faraday/start.S' with the new design, which move relocation into 'arch/arm/lib/relocate.S'
- Drop i2c:FTI2C010 & spi:FTSSP010_SPI support. The corresponding patch would restart after this patch series have been accepted.
- Revise IRQ & MMU design: Now the exception table would be mapped to

     0x00000000 as a small page(4KB), rather than runtime adjust after
     relocation finished.

- Revise irq:FTINTC020 design, now the irq is always enabled inside irq_install_handler().
- Revise clock management system
- Revise FTPWMTMR010 & FTTMR010 timer design:
1. Drop IRQ dependant implementation
2. Use gd->arch.timer_rate_hz for timer clock source
3. Use gd->arch.tbl for timestamp

Changes for v4:
- Coding Style cleanup.
- Break down the patch series:
- Patches without hard dependency to this series are now seperate patches.
- Split up the patch into more logical changesets (i.e. interrupt & timers are now split up)
- Drop the faraday/nand.h to remove dependency to ftnandc021
- Drop the faraday/mmc.h to remove dependency to ftsdc010
- Add change logs to each part of the patch series to make patchwork be able to grab comments.

Changes for v3:
- Coding Style cleanup.
There is still one warnning reported by checkpatch.pl, however it's too deep for me to fix it.
Here is the shapshot for it:
-----------------------------------------------------
WARNING: do not add new typedefs
#9735: FILE: include/lcd.h:258:
+typedef struct vidinfo {
-----------------------------------------------------
- Drop bit fields from c struct.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- cmd_boot.c: Make it a separate stand-alone patch.
- ftspi020: Make it a separate stand-alone patch.
- dma-mapping.h: Have the global data ptr declared outside functions.
- dma-mapping.h: Add #if...#else...#endif to dma_free_coherent().
- MMU/D-Cache: Drop static non-cached region, now we use map_physmem()/unmap_physmem() for dynamic mappings.
- ftmac110: Make a correction to multi-line comment style
- ftmac110: Use random MAC address while having trouble to get one from environment variables.
- ftmac110: Add comments to timing control registers.
- ftnandc021: Re-write this driver with ECC enabled and correct column address handling for OOB read/write,
and fixing issused addressed by Scott.
- a36x_config: No more static global network configurations.
- a36x_config: Add a common file for the redundant configurations.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().
- echi-faraday: Remove debug codes.
- ftmac110: Remove debug codes.
- cache-cp15: Enable write buffer in write-through mode.

Kuo-Jung Su (12):
arm: dma_alloc_coherent: malloc() -> memalign()
video: add Faraday FTLCDC200 LCD controller support
nand: add Faraday FTNANDC021 NAND controller support
cfi_flash: use buffer length in unmap_physmem()
arm: add MMU/D-Cache support for Faraday cores
arm: add Faraday processor core support
arm: add Faraday FTINTC020 interrupt controller support
arm: add Faraday FTTMR010 timer support
arm: add Faraday FTPWMTMR010 timer support
arm: add customized boot command for Faraday Images
mmc: ftsdc010_mci: clk_get_rate() -> clock_get_rate()
arm: add Faraday A360/A369 SoC platform support

 MAINTAINERS                                   |    5 +
 README                                        |   10 +
 arch/arm/cpu/faraday/Makefile                 |   58 +++
 arch/arm/cpu/faraday/a360/Makefile            |   49 ++
 arch/arm/cpu/faraday/a369/Makefile            |   50 ++
 arch/arm/cpu/faraday/a369/cmd_fa606.c         |   86 ++++
 arch/arm/cpu/faraday/cmd_bootfa.c             |  279 +++++++++++
 arch/arm/cpu/faraday/config.mk                |   33 ++
 arch/arm/cpu/faraday/cpu.c                    |  345 ++++++++++++++
 arch/arm/cpu/faraday/ftintc020.c              |  156 ++++++
 arch/arm/cpu/faraday/ftpwmtmr010.c            |  128 +++++
 arch/arm/cpu/faraday/fttmr010.c               |  136 ++++++
 arch/arm/cpu/faraday/fwimage.h                |   47 ++
 arch/arm/cpu/faraday/fwimage2.h               |   67 +++
 arch/arm/cpu/faraday/start.S                  |  431 +++++++++++++++++
 arch/arm/cpu/u-boot.lds                       |   11 +
 arch/arm/include/asm/arch-a360/hardware.h     |   84 ++++
 arch/arm/include/asm/arch-a360/pmu.h          |   95 ++++
 arch/arm/include/asm/arch-a360/scu.h          |   79 ++++
 arch/arm/include/asm/arch-a369/ahbc.h         |   34 ++
 arch/arm/include/asm/arch-a369/hardware.h     |   99 ++++
 arch/arm/include/asm/arch-a369/scu.h          |  224 +++++++++
 arch/arm/include/asm/arch-faraday/clock.h     |   41 ++
 arch/arm/include/asm/arch-faraday/interrupt.h |   29 ++
 arch/arm/include/asm/dma-mapping.h            |   61 ++-
 arch/arm/include/asm/global_data.h            |    4 +
 arch/arm/include/asm/io.h                     |  160 ++++++-
 arch/arm/include/asm/system.h                 |    7 +-
 arch/arm/lib/cache-cp15.c                     |   12 +
 board/faraday/a360evb/Makefile                |   49 ++
 board/faraday/a360evb/board.c                 |   72 +++
 board/faraday/a360evb/clock.c                 |   72 +++
 board/faraday/a360evb/config.mk               |   33 ++
 board/faraday/a360evb/lowlevel_init.S         |   33 ++
 board/faraday/a369evb/Makefile                |   49 ++
 board/faraday/a369evb/board.c                 |  176 +++++++
 board/faraday/a369evb/clock.c                 |   80 ++++
 board/faraday/a369evb/config.mk               |   33 ++
 board/faraday/a369evb/lowlevel_init.S         |  136 ++++++
 boards.cfg                                    |    3 +
 drivers/mmc/ftsdc010_mci.c                    |    2 +-
 drivers/mtd/cfi_flash.c                       |    2 +-
 drivers/mtd/nand/Makefile                     |    1 +
 drivers/mtd/nand/ftnandc021.c                 |  626 +++++++++++++++++++++++++
 drivers/video/Makefile                        |    1 +
 drivers/video/ftlcdc200.c                     |  148 ++++++
 drivers/video/ftlcdc200_panel.c               |  221 +++++++++
 include/common.h                              |    5 +
 include/configs/a360.h                        |   60 +++
 include/configs/a369-common.h                 |   75 +++
 include/configs/a369.h                        |   34 ++
 include/configs/a369_fa606te.h                |   31 ++
 include/configs/faraday-common.h              |  243 ++++++++++
 include/faraday/ftintc020.h                   |   37 ++
 include/faraday/ftlcdc200.h                   |  179 +++++++
 include/faraday/ftnandc021.h                  |  153 ++++++
 include/faraday/ftpwmtmr010.h                 |   41 ++
 include/faraday/ftsmc020.h                    |    1 +
 include/faraday/fttmr010.h                    |   17 +
 include/lcd.h                                 |   33 ++
 60 files changed, 5451 insertions(+), 15 deletions(-)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/ftintc020.c
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
 create mode 100644 arch/arm/cpu/faraday/start.S
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a360/pmu.h
 create mode 100644 arch/arm/include/asm/arch-a360/scu.h
 create mode 100644 arch/arm/include/asm/arch-a369/ahbc.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/scu.h
 create mode 100644 arch/arm/include/asm/arch-faraday/clock.h
 create mode 100644 arch/arm/include/asm/arch-faraday/interrupt.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clock.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clock.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 drivers/video/ftlcdc200.c
 create mode 100644 drivers/video/ftlcdc200_panel.c
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369-common.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_fa606te.h
 create mode 100644 include/configs/faraday-common.h
 create mode 100644 include/faraday/ftintc020.h
 create mode 100644 include/faraday/ftlcdc200.h
 create mode 100644 include/faraday/ftnandc021.h
 create mode 100644 include/faraday/ftpwmtmr010.h

--
1.7.9.5

#221 lore raw

PATCH v6 1/12 arm: dma_alloc_coherent: malloc() -> memalign()

From: Kuo-Jung Su <[email protected]>

Even though the MMU/D-cache is off, some DMA engines still expect strict address alignment.

For example, the incoming Faraday FTMAC110 & FTGMAC100 ethernet controllers expect the tx/rx descriptors should always be aligned to 16-bytes boundary.

CC Albert ARIBAUD <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Initial commit, which is separated from "arm: add MMU/D-Cache support for Faraday cores"

 arch/arm/include/asm/dma-mapping.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/dma-mapping.h +1 -1
index 5bbb0a0..a11178f 100644
@@ -32,7 +32,7 @@ enum dma_data_direction {
 
 static void *dma_alloc_coherent(size_t len, unsigned long *handle)
 {
-	*handle = (unsigned long)malloc(len);
+	*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
 	return (void *)*handle;
 }
 

--
1.7.9.5

#222 lore raw

PATCH v6 2/12 video: add Faraday FTLCDC200 LCD controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTLCDC200 Color LCD controller performs translation of pixel-coded data into the required formats and timings to drive a variety of single/dual mono and color LCDs.

Depending on the LCD type and mode, the unpacked data can represent:
1. an actual true display gray or color value
2. an address to a 256 x 16 bit wide palette RAM gray or color value.

The FTLCDC200 generates 4 individual interrupts for:
1. DMA FIFO underflow
2. base address update
3. vertical status
4. bus error.

There is also a single combined interrupt that is raised when any of the individual interrupts become active.

CC Albert Aribaud <[email protected]>
CC Anatolij Gustschin <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Coding Style cleanup:

     struct chip_regs __iomem *regs -> struct chip_regs *regs

- Chain it back to Faraday A360/A369 patch series, because Faraday A369 depends on the header file of this patch for I2C work-around.(Enable I2C clock to prevent I2C bus hangs)

Changes for v4:
- Nothing updates

Changes for v3:
- Nothing updates

Changes for v2:
- Make it a separate patch, rather then a part of Faraday A36x patch series

 drivers/video/Makefile          |    1 +
 drivers/video/ftlcdc200.c       |  148 ++++++++++++++++++++++++++
 drivers/video/ftlcdc200_panel.c |  221 +++++++++++++++++++++++++++++++++++++++
 include/faraday/ftlcdc200.h     |  179 +++++++++++++++++++++++++++++++
 include/lcd.h                   |   33 ++++++
 5 files changed, 582 insertions(+)
 create mode 100644 drivers/video/ftlcdc200.c
 create mode 100644 drivers/video/ftlcdc200_panel.c
 create mode 100644 include/faraday/ftlcdc200.h
drivers/video/Makefile +1 -0
index 68ff34b..92ab9d1 100644
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_EXYNOS_MIPI_DSIM) += exynos_mipi_dsi.o exynos_mipi_dsi_common.o \
 				exynos_mipi_dsi_lowlevel.o
 COBJS-$(CONFIG_EXYNOS_PWM_BL) += exynos_pwm_bl.o
 COBJS-$(CONFIG_FSL_DIU_FB) += fsl_diu_fb.o videomodes.o
+COBJS-$(CONFIG_FTLCDC200) += ftlcdc200.o ftlcdc200_panel.o
 COBJS-$(CONFIG_MPC8XX_LCD) += mpc8xx_lcd.o
 COBJS-$(CONFIG_PXA_LCD) += pxa_lcd.o
 COBJS-$(CONFIG_S6E8AX0) += s6e8ax0.o
drivers/video/ftlcdc200.c new file +148 -0

148 lines not on this page · raw message

drivers/video/ftlcdc200_panel.c new file +221 -0

221 lines not on this page · raw message

include/faraday/ftlcdc200.h new file +179 -0

179 lines not on this page · raw message

include/lcd.h +33 -0
index 30225ed..14fa4fd 100644
@@ -253,6 +253,39 @@ typedef struct vidinfo {
 
 void init_panel_info(vidinfo_t *vid);
 
+#elif defined(CONFIG_FTLCDC200)
+
+typedef struct vidinfo {
+	ushort	vl_col;		/* Number of columns (i.e. 800) */
+	ushort	vl_row;		/* Number of rows (i.e. 600) */
+
+	u_char	vl_bpix;	/* Bits per pixel, 0 = 1, 1 = 2 ... 4 = 16 */
+
+	/* Timing Parameters */
+	u_char	vl_fps;		/* Frame per second */
+
+	u_char	vl_hsw;
+	u_char	vl_hbp;
+	u_char	vl_hfp;
+
+	u_char	vl_vsw;
+	u_char	vl_vbp;
+	u_char	vl_vfp;
+
+	/* Pre-defined FTLCDC200 register values */
+	u_long	vl_enable;	/* LCDEnable */
+	u_long	vl_pixel;	/* PanelPixel */
+	u_long	vl_polarity;/* Polarity */
+	u_long	vl_serial;	/* SerialPanelPixel */
+	u_long	vl_ccir656;	/* CCIR656 */
+
+	/* Panel name */
+	char	*vl_name;
+
+	ushort	*cmap;		/* Pointer to the colormap */
+	void	*priv;		/* Pointer to driver-specific data */
+} vidinfo_t;
+
 #else
 
 typedef struct vidinfo {

--
1.7.9.5

#223 lore raw

PATCH v6 3/12 nand: add Faraday FTNANDC021 NAND controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

Faraday FTNANDC021 is a integrated NAND flash controller. It use a build-in command table to abstract the underlying NAND flash control logic.

For example:

Issuing a command 0x10 to FTNANDC021 would result in a page write + a read status operation.

CC Albert ARIBAUD <[email protected]>
CC Scott Wood <[email protected]>

---
Changes for v6:
- Update README for CONFIG_SYS_FTNANDC021_TIMING
- Remove illegal type-punning by introducing put_unaligned() & get_unaligned().

Changes for v5 (Part of A360/A369 patch series):
- Coding Style cleanup:

     struct chip_regs __iomem *regs -> struct chip_regs *regs

- For there is a strong dependancy between this and A360/A369 patch series, it had been chained back to A360/A369 patch series.
- The latest nand_base requires the ecc.strength to be set properlly, so this patch adds ecc.strength setting accroding to ECC algorithm.

Changes for v5 (Standalone):
- Update README for the description of CONFIG_SYS_FTNANDC021_TIMING.
- Drop redundant white space. (i.e. if (mtd->writesize >= ' '4096))

Changes for v4:
- Make it a separate patch, rather then a part of Faraday A36x patch series
- Drop the faraday/nand.h to remove dependency to Faraday A36x patch series.
- CONFIG_SYS_NAND_TIMING -> CONFIG_SYS_FTNANDC021_TIMING
- Remove non-ECC code.
- Implement private hwecc read/write_page functions to get rid of .eccpos & .eccbytes.
- Use macro constants for timeout control

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Replace all the infinite wait loop with a timeout.
- Add '__iomem' to all the declaration of HW register pointers.
- Re-write this driver with ECC enabled and correct column address handling for OOB read/write,
- Fix issuses addressed by Scott.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 README                        |   10 +
 drivers/mtd/nand/Makefile     |    1 +
 drivers/mtd/nand/ftnandc021.c |  626 +++++++++++++++++++++++++++++++++++++++++
 include/faraday/ftnandc021.h  |  153 ++++++++++
 4 files changed, 790 insertions(+)
 create mode 100644 drivers/mtd/nand/ftnandc021.c
 create mode 100644 include/faraday/ftnandc021.h
README +10 -0
index 85e5a8d..538ba85 100644
@@ -4036,6 +4036,16 @@ Low Level (hardware related) configuration options:
 		- drivers/mtd/nand/ndfc.c
 		- drivers/mtd/nand/mxc_nand.c
 
+- CONFIG_SYS_FTNANDC021_TIMING
+		This option specifies an array of customized timing parameters
+		for Faraday FTNANDC021 NAND flash controller.
+		e.g.
+		#define CONFIG_SYS_FTNANDC021_TIMING \
+			{ CONFIG_NAND_K9F4G08U0B_AC1, CONFIG_NAND_K9F4G08U0B_AC2 }
+		where CONFIG_NAND_K9F4G08U0B_AC[1/2] are the optimized AC
+		timing parameters for register AC_TIMING1 and AC_TIMING2 which
+		control the timing for CLE, ALE, WE and RE signals.
+
 - CONFIG_SYS_NDFC_EBC0_CFG
 		Sets the EBC0_CFG register for the NDFC. If not defined
 		a default value will be used.
drivers/mtd/nand/Makefile +1 -0
index bb81e84..765171a 100644
@@ -64,6 +64,7 @@ COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o
 COBJS-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o
 COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_FSMC) += fsmc_nand.o
+COBJS-$(CONFIG_NAND_FTNANDC021) += ftnandc021.o
 COBJS-$(CONFIG_NAND_JZ4740) += jz4740_nand.o
 COBJS-$(CONFIG_NAND_KB9202) += kb9202_nand.o
 COBJS-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o
drivers/mtd/nand/ftnandc021.c new file +626 -0

626 lines not on this page · raw message

include/faraday/ftnandc021.h new file +153 -0

153 lines not on this page · raw message

--
1.7.9.5

#224 lore raw

PATCH v6 3/12 nand: add Faraday FTNANDC021 NAND controller support

drivers/mtd/nand/ftnandc021.c line 416

Quoted 5 lines · Kuo-Jung Su
drivers/mtd/nand/ftnandc021.c new file +5 -0
+#ifndef __ARMEB__
+		put_unaligned_le32(readl(&regs->dr), buf + off);
+#else
+		put_unaligned_be32(readl(&regs->dr), buf + off);
+#endif

Can't you just use plain put_unaligned()? Be sure to cast buf + off to a 32-bit pointer.

Also, when you *do* need to have an if/else, use positive logic -- ifdef rather than ifndef, with the if/else swapped.

-Scott

#225 lore raw

PATCH v6 3/12 nand: add Faraday FTNANDC021 NAND controller support

2013/7/9 Scott Wood <[email protected]>:

Quoted 12 lines · Kuo-Jung Su

drivers/mtd/nand/ftnandc021.c line 416

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+#ifndef __ARMEB__
+               put_unaligned_le32(readl(&regs->dr), buf + off);
+#else
+               put_unaligned_be32(readl(&regs->dr), buf + off);
+#endif

Can't you just use plain put_unaligned()? Be sure to cast buf + off to a 32-bit pointer.

Ummm... I think it'll be better to replace put_unaligned() with memcpy(), just like what your suggested before.

So that we don't even have to worry about this endian issue and pointer cast.

Quoted 3 lines

Also, when you *do* need to have an if/else, use positive logic -- ifdef rather than ifndef, with the if/else swapped.

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#226 lore raw

PATCH v6 3/12 nand: add Faraday FTNANDC021 NAND controller support

Quoted 15 lines · Kuo-Jung Su

2013/7/9 Scott Wood <[email protected]>:

Quoted 10 lines · Kuo-Jung Su

drivers/mtd/nand/ftnandc021.c line 416

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+#ifndef __ARMEB__
+               put_unaligned_le32(readl(&regs->dr), buf + off);
+#else
+               put_unaligned_be32(readl(&regs->dr), buf + off);
+#endif

Can't you just use plain put_unaligned()? Be sure to cast buf +

off to a

Quoted 2 lines

32-bit pointer.

Quoted 6 lines

Ummm... I think it'll be better to replace put_unaligned() with memcpy(),
just like what your suggested before.

So that we don't even have to worry about this endian issue and pointer cast.

OK. BTW, it'd be nice if there were a native-endian, fixed-size put_unaligned32() -- having a u8 pointer seems like it'd be a common situation when dealing with unaligned things (and it's what the underlying implementation takes).

-Scott

#227 lore raw

PATCH v6 3/12 nand: add Faraday FTNANDC021 NAND controller support

2013/7/9 Scott Wood <[email protected]>:

Quoted 20 lines · Kuo-Jung Su
Quoted 19 lines

2013/7/9 Scott Wood <[email protected]>:

Quoted 13 lines · Kuo-Jung Su

drivers/mtd/nand/ftnandc021.c line 416

Quoted 6 lines
drivers/mtd/nand/ftnandc021.c new file +5 -0
+#ifndef __ARMEB__
+               put_unaligned_le32(readl(&regs->dr), buf + off);
+#else
+               put_unaligned_be32(readl(&regs->dr), buf + off);
+#endif

Can't you just use plain put_unaligned()? Be sure to cast buf + off to a
32-bit pointer.

Ummm... I think it'll be better to replace put_unaligned() with memcpy(), just like what your suggested before.

Quoted 9 lines
Quoted 2 lines

So that we don't even have to worry about this endian issue and pointer cast.

OK. BTW, it'd be nice if there were a native-endian, fixed-size put_unaligned32() -- having a u8 pointer seems like it'd be a common situation when dealing with unaligned things (and it's what the underlying implementation takes).

Got it, thanks

--
Best wishes,
Kuo-Jung Su

#228 lore raw

PATCH v6 4/12 cfi_flash: use buffer length in unmap_physmem()

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

While the flash_detect_legacy() of drivers/mtd/cfi_flash.c feed unmap_physmem() with MAP_NOCACHE as 2nd parameter, the do_spi_flash_read_write() of common/cmd_sf.c feed unmap_physmem() with the length of the mapped buffer as 2nd parameter.

It's apparently a bug, and I personally think the 2nd parameter should be the length of the mapped buffer.

CC Albert Aribaud <[email protected]>
CC Stefan Roese <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Initial commit, which is separated from "arm: add MMU/D-Cache support for Faraday cores"

 drivers/mtd/cfi_flash.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/cfi_flash.c +1 -1
index 25a5710..616750d 100644
@@ -1820,7 +1820,7 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
 					break;
 				else
 					unmap_physmem((void *)info->start[0],
-						      MAP_NOCACHE);
+						      info->portwidth);
 			}
 		}
 

--
1.7.9.5

#229 lore raw

PATCH v6 4/12 cfi_flash: use buffer length in unmap_physmem()

Quoted 8 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

While the flash_detect_legacy() of drivers/mtd/cfi_flash.c feed unmap_physmem() with MAP_NOCACHE as 2nd parameter, the do_spi_flash_read_write() of common/cmd_sf.c feed unmap_physmem() with the length of the mapped buffer as 2nd parameter.

Quoted 6 lines

It's apparently a bug, and I personally think the 2nd parameter should be the length of the mapped buffer.

CC Albert Aribaud <[email protected]>
CC Stefan Roese <[email protected]>

Applied to u-boot-cfi-flash.

Thanks,
Stefan

#230 lore raw

PATCH v6 5/12 arm: add MMU/D-Cache support for Faraday cores

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This updates the map_physmem()/unmap_physmem(), and use them to implement dma_alloc_coherent() & dma_free_coherent().

It uses 1MB section for each mapping, and thus wastes lots of address space, however this should still be good enough for tiny systems (i.e. u-boot).

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Add void dram_bank_mmu_setup() into 'arch/arm/cpu/faraday/cpu.c' to override the weak function in "cache-cp15.c".
- Use small page (4KB) to map relocated exception table to 0x0000

Changes for v4:
- Coding Style cleanup.

Changes for v3:
- Coding Style cleanup.
- Always insert a blank line between declarations and code.
- dma-mapping.h: Have the global data ptr declared outside functions.
- dma-mapping.h: Add #if...#else...#endif to dma_free_coherent().
- Drop static non-cached region, now we use map_physmem()/unmap_physmem() for dynamic mappings.

Changes for v2:
- Coding Style cleanup.
- cache-cp15: Enable write buffer in write-through mode.

 arch/arm/include/asm/dma-mapping.h |   59 ++++++++++++-
 arch/arm/include/asm/global_data.h |    4 +
 arch/arm/include/asm/io.h          |  160 ++++++++++++++++++++++++++++++++++--
 arch/arm/include/asm/system.h      |    7 +-
 arch/arm/lib/cache-cp15.c          |   12 +++
 5 files changed, 230 insertions(+), 12 deletions(-)
arch/arm/include/asm/dma-mapping.h +58 -1
index a11178f..5a13af5 100644
@@ -3,6 +3,9 @@
  * Stelian Pop <[email protected]>
  * Lead Tech Design <www.leadtechdesign.com>
  *
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -24,22 +27,76 @@
 #ifndef __ASM_ARM_DMA_MAPPING_H
 #define __ASM_ARM_DMA_MAPPING_H
 
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <malloc.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
+
 enum dma_data_direction {
 	DMA_BIDIRECTIONAL	= 0,
 	DMA_TO_DEVICE		= 1,
 	DMA_FROM_DEVICE		= 2,
 };
 
-static void *dma_alloc_coherent(size_t len, unsigned long *handle)
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	void *map, *va = memalign(ARCH_DMA_MINALIGN, len);
+
+	if (va && gd->arch.cpu_mmu) {
+		invalidate_dcache_range((ulong)va, (ulong)va + len);
+		map = map_physmem((phys_addr_t)va, len, MAP_NOCACHE);
+		if (!map)
+			free(va);
+		va = map;
+	}
+
+	if (handle)
+		*handle = virt_to_phys(va);
+
+	return va;
+#else  /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
 	*handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
 	return (void *)*handle;
+#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
+}
+
+static inline void dma_free_coherent(void *vaddr, ulong len)
+{
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	void *tmp = (void *)virt_to_phys(vaddr);
+	unmap_physmem(vaddr, len);
+	vaddr = tmp;
+#endif
+	free(vaddr);
 }
 
 static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
 					   enum dma_data_direction dir)
 {
+#if defined(CONFIG_FARADAY) && !defined(CONFIG_SYS_DCACHE_OFF)
+	if (gd->arch.cpu_mmu) {
+		switch (dir) {
+		case DMA_BIDIRECTIONAL:
+		case DMA_TO_DEVICE:
+			flush_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+
+		case DMA_FROM_DEVICE:
+			invalidate_dcache_range((ulong)vaddr,
+				(ulong)vaddr + len);
+			break;
+		}
+	}
+	return virt_to_phys((void *)vaddr);
+#else  /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
 	return (unsigned long)vaddr;
+#endif /* CONFIG_FARADAY && !CONFIG_SYS_DCACHE_OFF */
 }
 
 static inline void dma_unmap_single(volatile void *vaddr, size_t len,
arch/arm/include/asm/global_data.h +4 -0
index 7611d0a..fc78c6a 100644
@@ -42,6 +42,10 @@ struct arch_global_data {
 	unsigned long	pllb_rate_hz;
 	unsigned long	at91_pllb_usb_init;
 #endif
+#ifdef CONFIG_FARADAY
+	unsigned long   cpu_id;
+	unsigned long   cpu_mmu;	/* has mmu */
+#endif
 	/* "static data" needed by most of timer.c on ARM platforms */
 	unsigned long timer_rate_hz;
 	unsigned long tbu;
arch/arm/include/asm/io.h +152 -8

194 lines not on this page · raw message

arch/arm/include/asm/system.h +4 -3
index 760345f..050b707 100644
@@ -97,9 +97,10 @@ static inline void set_dacr(unsigned int val)
 
 /* options available for data cache on each page */
 enum dcache_option {
-	DCACHE_OFF = 0x12,
-	DCACHE_WRITETHROUGH = 0x1a,
-	DCACHE_WRITEBACK = 0x1e,
+	DCACHE_OFF = 0x12,          /* non-cached + non-buffered */
+	DCACHE_WRITECOMBINE = 0x16, /* non-cached + buffered */
+	DCACHE_WRITETHROUGH = 0x1a, /* cached + non-buffered */
+	DCACHE_WRITEBACK = 0x1e,    /* cached + buffered */
 };
 
 /* Size of an MMU section */
arch/arm/lib/cache-cp15.c +12 -0
index 4abe1cf..97436f6 100644
@@ -1,6 +1,8 @@
 /*
  * (C) Copyright 2002
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ * (C) Copyright 2010
+ * Dante Su <[email protected]>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -126,6 +128,10 @@ static inline void mmu_setup(void)
 
 	/* and enable the mmu */
 	reg = get_cr();	/* get control reg. */
+#ifdef CONFIG_FARADAY
+	reg |= CR_W;	/* enable write buffer */
+	reg |= CR_Z;	/* enable branch prediction */
+#endif
 	cp_delay();
 	set_cr(reg | CR_M);
 }
@@ -140,9 +146,15 @@ static void cache_enable(uint32_t cache_bit)
 {
 	uint32_t reg;
 
+#ifdef CONFIG_FARADAY
+	if (!gd->arch.cpu_mmu && (cache_bit == CR_C))
+		return;
+#endif
+
 	/* The data cache is not active unless the mmu is enabled too */
 	if ((cache_bit == CR_C) && !mmu_enabled())
 		mmu_setup();
+
 	reg = get_cr();	/* get control reg. */
 	cp_delay();
 	set_cr(reg | cache_bit);

--
1.7.9.5

#231 lore raw

PATCH v6 6/12 arm: add Faraday processor core support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This adds i/d-cache control, mmu setup & bootstrap code for Faraday cores.

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Initial commit which is separated from
"arm: add Faraday common utilities"

 arch/arm/cpu/faraday/Makefile  |   55 +++++
 arch/arm/cpu/faraday/config.mk |   33 +++
 arch/arm/cpu/faraday/cpu.c     |  343 ++++++++++++++++++++++++++++++++
 arch/arm/cpu/faraday/start.S   |  431 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 862 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/Makefile
 create mode 100644 arch/arm/cpu/faraday/config.mk
 create mode 100644 arch/arm/cpu/faraday/cpu.c
 create mode 100644 arch/arm/cpu/faraday/start.S
arch/arm/cpu/faraday/Makefile new file +55 -0
new file mode 100644
index 0000000..ecb240a
@@ -0,0 +1,55 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(CPU).o
+
+src-y  := cpu.o
+
+START	= start.o
+COBJS	= $(src-y)
+
+ifdef	CONFIG_SPL_BUILD
+ifdef	CONFIG_SPL_NO_CPU_SUPPORT_CODE
+START	:=
+endif
+endif
+
+SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+START	:= $(addprefix $(obj),$(START))
+
+all:	$(obj).depend $(START) $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/faraday/config.mk new file +33 -0
new file mode 100644
index 0000000..f03030a
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2002
+# Gary Jennejohn, DENX Software Engineering, <[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
+#
+
+PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
+
+PLATFORM_CPPFLAGS += -march=armv4
+# =========================================================================
+#
+# Supply options according to compiler version
+#
+# =========================================================================
+PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
+PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)
arch/arm/cpu/faraday/cpu.c new file +343 -0

343 lines not on this page · raw message

arch/arm/cpu/faraday/start.S new file +431 -0

431 lines not on this page · raw message

--
1.7.9.5

#232 lore raw

PATCH v6 7/12 arm: add Faraday FTINTC020 interrupt controller support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Coding Style cleanup.
- Now the irq is always enabled inside irq_install_handler().

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 arch/arm/cpu/faraday/Makefile    |    1 +
 arch/arm/cpu/faraday/ftintc020.c |  156 ++++++++++++++++++++++++++++++++++++++
 include/common.h                 |    3 +
 include/faraday/ftintc020.h      |   37 +++++++++
 4 files changed, 197 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/ftintc020.c
 create mode 100644 include/faraday/ftintc020.h
arch/arm/cpu/faraday/Makefile +1 -0
index ecb240a..35926c2 100644
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).o
 
 src-y  := cpu.o
+src-$(CONFIG_FTINTC020)   += ftintc020.o
 
 START	= start.o
 COBJS	= $(src-y)
arch/arm/cpu/faraday/ftintc020.c new file +156 -0

156 lines not on this page · raw message

include/common.h +3 -0
index e5220cf..ec3bf0d 100644
@@ -110,6 +110,9 @@ typedef volatile unsigned char	vu_char;
 #ifdef CONFIG_SOC_DA8XX
 #include <asm/arch/hardware.h>
 #endif
+#ifdef CONFIG_FARADAY
+#include <asm/arch-faraday/interrupt.h>
+#endif
 
 #include <part.h>
 #include <flash.h>
include/faraday/ftintc020.h new file +37 -0
new file mode 100644
index 0000000..e23d1e7
@@ -0,0 +1,37 @@
+/*
+ * arch/arm/cpu/faraday/ftintc020.h
+ *
+ * (C) Copyright 2010 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ */
+
+#ifndef ARCH_ARM_CPU_FARADAY_FTINTC020_H
+#define ARCH_ARM_CPU_FARADAY_FTINTC020_H
+
+struct ftintc020_pic_regs {
+	uint32_t src; /* source register */
+	uint32_t ena; /* enable register */
+	uint32_t scr; /* status clear register */
+	uint32_t tmr; /* trigger mode register */
+	uint32_t tlr; /* trigger level register */
+	uint32_t sr;  /* status register */
+	uint32_t rsvd[2];
+};
+
+struct ftintc020_regs {
+	/* IRQ/FIQ:  0 ~ 31 */
+	struct ftintc020_pic_regs irq32; /* 0x00 - 0x1C: IRQ 0 ~ 31 */
+	struct ftintc020_pic_regs fiq32; /* 0x20 - 0x3C: FIQ 0 ~ 31 */
+	uint32_t rsvd1[4];               /* 0x40 - 0x4C: Reserved */
+	uint32_t revision;               /* 0x50: Revision Register */
+	uint32_t feature;                /* 0x54: Feature Register */
+	uint32_t rsvd2[2];               /* 0x58 - 0x5C: Reserved */
+	/* IRQ/FIQ: 32 ~ 63 */
+	struct ftintc020_pic_regs irq64; /* 0x60 - 0x7C: IRQ 32 ~ 63 */
+	struct ftintc020_pic_regs fiq64; /* 0x80 - 0x9C: FIQ 32 ~ 63 */
+};
+
+#endif

--
1.7.9.5

#233 lore raw

PATCH v6 8/12 arm: add Faraday FTTMR010 timer support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Drop IRQ dependant implementation
- Use gd->arch.timer_rate_hz for timer clock source
- Use gd->arch.tbl for timestamp

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 arch/arm/cpu/faraday/Makefile   |    1 +
 arch/arm/cpu/faraday/fttmr010.c |  136 +++++++++++++++++++++++++++++++++++++++
 include/faraday/fttmr010.h      |   17 +++++
 3 files changed, 154 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/fttmr010.c
arch/arm/cpu/faraday/Makefile +1 -0
index 35926c2..658d9ed 100644
@@ -27,6 +27,7 @@ LIB	= $(obj)lib$(CPU).o
 
 src-y  := cpu.o
 src-$(CONFIG_FTINTC020)   += ftintc020.o
+src-$(CONFIG_FTTMR010)    += fttmr010.o
 
 START	= start.o
 COBJS	= $(src-y)
arch/arm/cpu/faraday/fttmr010.c new file +136 -0

136 lines not on this page · raw message

include/faraday/fttmr010.h +17 -0
index 72abcb3..ef10f31 100644
@@ -57,6 +57,16 @@ struct fttmr010 {
 #define FTTMR010_TM1_CLOCK	(1 << 1)
 #define FTTMR010_TM1_ENABLE	(1 << 0)
 
+#define FTTMR010_TM1_CRMASK \
+	(FTTMR010_TM1_UPDOWN | FTTMR010_TM1_OFENABLE \
+	| FTTMR010_TM1_CLOCK | FTTMR010_TM1_ENABLE)
+#define FTTMR010_TM2_CRMASK \
+	(FTTMR010_TM2_UPDOWN | FTTMR010_TM2_OFENABLE \
+	| FTTMR010_TM2_CLOCK | FTTMR010_TM2_ENABLE)
+#define FTTMR010_TM3_CRMASK \
+	(FTTMR010_TM3_UPDOWN | FTTMR010_TM3_OFENABLE \
+	| FTTMR010_TM3_CLOCK | FTTMR010_TM3_ENABLE)
+
 /*
  * Timer Interrupt State & Mask Registers
  */
@@ -70,4 +80,11 @@ struct fttmr010 {
 #define FTTMR010_TM1_MATCH2	(1 << 1)
 #define FTTMR010_TM1_MATCH1	(1 << 0)
 
+#define FTTMR010_TM1_ISRMASK \
+	(FTTMR010_TM1_OVERFLOW | FTTMR010_TM1_MATCH2 | FTTMR010_TM1_MATCH1)
+#define FTTMR010_TM2_ISRMASK \
+	(FTTMR010_TM2_OVERFLOW | FTTMR010_TM2_MATCH2 | FTTMR010_TM2_MATCH1)
+#define FTTMR010_TM3_ISRMASK \
+	(FTTMR010_TM3_OVERFLOW | FTTMR010_TM3_MATCH2 | FTTMR010_TM3_MATCH1)
+
 #endif	/* __FTTMR010_H */

--
1.7.9.5

#234 lore raw

PATCH v6 9/12 arm: add Faraday FTPWMTMR010 timer support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Drop IRQ dependant implementation
- Use gd->arch.timer_rate_hz for timer clock source
- Use gd->arch.tbl for timestamp

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 arch/arm/cpu/faraday/Makefile      |    1 +
 arch/arm/cpu/faraday/ftpwmtmr010.c |  128 ++++++++++++++++++++++++++++++++++++
 include/faraday/ftpwmtmr010.h      |   41 ++++++++++++
 3 files changed, 170 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/ftpwmtmr010.c
 create mode 100644 include/faraday/ftpwmtmr010.h
arch/arm/cpu/faraday/Makefile +1 -0
index 658d9ed..6b96e32 100644
@@ -28,6 +28,7 @@ LIB	= $(obj)lib$(CPU).o
 src-y  := cpu.o
 src-$(CONFIG_FTINTC020)   += ftintc020.o
 src-$(CONFIG_FTTMR010)    += fttmr010.o
+src-$(CONFIG_FTPWMTMR010) += ftpwmtmr010.o
 
 START	= start.o
 COBJS	= $(src-y)
arch/arm/cpu/faraday/ftpwmtmr010.c new file +128 -0

128 lines not on this page · raw message

include/faraday/ftpwmtmr010.h new file +41 -0

41 lines not on this page · raw message

--
1.7.9.5

#235 lore raw

PATCH v6 10/12 arm: add customized boot command for Faraday Images

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

At the time of writting, none of Faraday NAND & SPI controllers supports XIP (eXecute In Place), and the 1st stage bootstrap stored in embedded ROM is not compatible to U-Boot design.

So this patch is added to support booting from Faraday Images.

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- Fix compiler warnning
- Use shorter paragraph in commit message, and move the original statement into the top of cmd_bootfa.c.

Changes for v5:
- Rename from 'arm: add Faraday firmware image utility' into 'arm: add Faraday specific boot command'
- Add missing CRC check to the command 'bootfa'.
- Add rationale to the command 'bootfa'.

Changes for v4:
- Coding Style cleanup.
- Break up from [arm: add Faraday A36x SoC platform support]

Changes for v3:
- Coding Style cleanup.
- Always insert a blank line between declarations and code.

Changes for v2:
- Coding Style cleanup.

 arch/arm/cpu/faraday/Makefile     |    2 +-
 arch/arm/cpu/faraday/cmd_bootfa.c |  279 +++++++++++++++++++++++++++++++++++++
 arch/arm/cpu/faraday/fwimage.h    |   47 +++++++
 arch/arm/cpu/faraday/fwimage2.h   |   67 +++++++++
 arch/arm/cpu/u-boot.lds           |   11 ++
 5 files changed, 405 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/faraday/cmd_bootfa.c
 create mode 100644 arch/arm/cpu/faraday/fwimage.h
 create mode 100644 arch/arm/cpu/faraday/fwimage2.h
arch/arm/cpu/faraday/Makefile +1 -1
index 6b96e32..ef6a72e 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(CPU).o
 
-src-y  := cpu.o
+src-y  := cpu.o cmd_bootfa.o
 src-$(CONFIG_FTINTC020)   += ftintc020.o
 src-$(CONFIG_FTTMR010)    += fttmr010.o
 src-$(CONFIG_FTPWMTMR010) += ftpwmtmr010.o
arch/arm/cpu/faraday/cmd_bootfa.c new file +279 -0

279 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage.h new file +47 -0

47 lines not on this page · raw message

arch/arm/cpu/faraday/fwimage2.h new file +67 -0

67 lines not on this page · raw message

arch/arm/cpu/u-boot.lds +11 -0
index 3037885..032018f 100644
@@ -23,6 +23,8 @@
  * MA 02111-1307 USA
  */
 
+#include <config.h>
+
 OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 ENTRY(_start)
@@ -35,6 +37,15 @@ SECTIONS
 	{
 		*(.__image_copy_start)
 		CPUDIR/start.o (.text*)
+#ifdef CONFIG_FARADAY
+		/*
+		 * Dante Su 2012.10.09:
+		 * Reserved for the faimage v2.1.
+		 * 1. CPUDIR/start.o: It shall never be > 4KB.
+		 * 2. faimage header: It shall always be stored at 0x1000, and <= 1KB.
+		 */
+		. = 0x00001400;
+#endif
 		*(.text*)
 	}
 

--
1.7.9.5

#236 lore raw

PATCH v6 11/12 mmc: ftsdc010_mci: clk_get_rate() -> clock_get_rate()

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This updates ftsdc010_mci.c for latest Faraday clock APIs.

CC Albert Aribaud <[email protected]>
CC Andy Fleming <[email protected]>

---
Changes for v6:
- Nothing updates

Changes for v5:
- Initial commit

 drivers/mmc/ftsdc010_mci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/ftsdc010_mci.c +1 -1
index 562b14a..0a0a19b 100644
@@ -363,7 +363,7 @@ int ftsdc010_mmc_init(int devid)
 #ifdef CONFIG_SYS_CLK_FREQ
 	chip->sclk = CONFIG_SYS_CLK_FREQ;
 #else
-	chip->sclk = clk_get_rate("SDC");
+	chip->sclk = clock_get_rate(MMC_CLK);
 #endif
 
 	mmc->voltages  = MMC_VDD_32_33 | MMC_VDD_33_34;

--
1.7.9.5

#237 lore raw

PATCH v6 12/12 arm: add Faraday A360/A369 SoC platform support

In reply to Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

This adds board support for the Faraday A360/A369 SoC platforms.

Working functions:
- MMU/D-cache
- SD Host controller
- USB EHCI controller
- USB Gadget controller
- Network
- NAND

CC Albert Aribaud <[email protected]>

---
Changes for v6:
- arch/arm/cpu/faraday/cpu.c:

     struct ftwdt010_wdt __iomem *regs -> struct ftwdt010_wdt *regs

Changes for v5:
- Coding Style cleanup:
1. struct chip_regs __iomem *regs -> struct chip_regs *regs
2. Move Faraday specific APIs into asm/arch-faraday/*.h
- Fix Copyright notices (dates) throughout the patch
- Define Faraday machine type in board's config header file
- Add myself as the maintainer for Faraday A360/A369 in MAINTAINERS.
- Drop i2c:FTI2C010 & spi:FTSSP010_SPI support. The corresponding patch would restart after this patch series have been accepted.
- Revise clock management system

Changes for v4:
- Coding Style cleanup.
- Break-down the interrupt, timers and common utilties.

Changes for v3:
- Coding Style cleanup.
- Drop macros for wirtel()/readl(), call them directly.
- Always insert a blank line between declarations and code.
- Add '__iomem' to all the declaration of HW register pointers.
- a36x_config: No more static global network configurations.
- a36x_config: Add a common file for the redundant configurations.

Changes for v2:
- Coding Style cleanup.
- Use readl(), writel(), clrsetbits_le32() to replace REG() macros.
- Use structure based hardware registers to replace the macro constants.
- Replace BIT() with BIT_MASK().

 MAINTAINERS                                   |    5 +
 arch/arm/cpu/faraday/a360/Makefile            |   49 +++++
 arch/arm/cpu/faraday/a369/Makefile            |   50 +++++
 arch/arm/cpu/faraday/a369/cmd_fa606.c         |   86 +++++++++
 arch/arm/cpu/faraday/cpu.c                    |    2 +
 arch/arm/include/asm/arch-a360/hardware.h     |   84 +++++++++
 arch/arm/include/asm/arch-a360/pmu.h          |   95 ++++++++++
 arch/arm/include/asm/arch-a360/scu.h          |   79 ++++++++
 arch/arm/include/asm/arch-a369/ahbc.h         |   34 ++++
 arch/arm/include/asm/arch-a369/hardware.h     |   99 ++++++++++
 arch/arm/include/asm/arch-a369/scu.h          |  224 +++++++++++++++++++++++
 arch/arm/include/asm/arch-faraday/clock.h     |   41 +++++
 arch/arm/include/asm/arch-faraday/interrupt.h |   29 +++
 board/faraday/a360evb/Makefile                |   49 +++++
 board/faraday/a360evb/board.c                 |   72 ++++++++
 board/faraday/a360evb/clock.c                 |   72 ++++++++
 board/faraday/a360evb/config.mk               |   33 ++++
 board/faraday/a360evb/lowlevel_init.S         |   33 ++++
 board/faraday/a369evb/Makefile                |   49 +++++
 board/faraday/a369evb/board.c                 |  176 ++++++++++++++++++
 board/faraday/a369evb/clock.c                 |   80 ++++++++
 board/faraday/a369evb/config.mk               |   33 ++++
 board/faraday/a369evb/lowlevel_init.S         |  136 ++++++++++++++
 boards.cfg                                    |    3 +
 include/common.h                              |    2 +
 include/configs/a360.h                        |   60 ++++++
 include/configs/a369-common.h                 |   75 ++++++++
 include/configs/a369.h                        |   34 ++++
 include/configs/a369_fa606te.h                |   31 ++++
 include/configs/faraday-common.h              |  243 +++++++++++++++++++++++++
 include/faraday/ftsmc020.h                    |    1 +
 31 files changed, 2059 insertions(+)
 create mode 100644 arch/arm/cpu/faraday/a360/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/Makefile
 create mode 100644 arch/arm/cpu/faraday/a369/cmd_fa606.c
 create mode 100644 arch/arm/include/asm/arch-a360/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a360/pmu.h
 create mode 100644 arch/arm/include/asm/arch-a360/scu.h
 create mode 100644 arch/arm/include/asm/arch-a369/ahbc.h
 create mode 100644 arch/arm/include/asm/arch-a369/hardware.h
 create mode 100644 arch/arm/include/asm/arch-a369/scu.h
 create mode 100644 arch/arm/include/asm/arch-faraday/clock.h
 create mode 100644 arch/arm/include/asm/arch-faraday/interrupt.h
 create mode 100644 board/faraday/a360evb/Makefile
 create mode 100644 board/faraday/a360evb/board.c
 create mode 100644 board/faraday/a360evb/clock.c
 create mode 100644 board/faraday/a360evb/config.mk
 create mode 100644 board/faraday/a360evb/lowlevel_init.S
 create mode 100644 board/faraday/a369evb/Makefile
 create mode 100644 board/faraday/a369evb/board.c
 create mode 100644 board/faraday/a369evb/clock.c
 create mode 100644 board/faraday/a369evb/config.mk
 create mode 100644 board/faraday/a369evb/lowlevel_init.S
 create mode 100644 include/configs/a360.h
 create mode 100644 include/configs/a369-common.h
 create mode 100644 include/configs/a369.h
 create mode 100644 include/configs/a369_fa606te.h
 create mode 100644 include/configs/faraday-common.h
MAINTAINERS +5 -0
index 7820375..537e09f 100644
@@ -643,6 +643,11 @@ Po-Yu Chuang <[email protected]>
 
 	a320evb		FA526 (ARM920T-like) (a320 SoC)
 
+Kuo-Jung Su <[email protected]>
+
+	a360evb		FA626TE (Faraday ARMv5TE) (a360 SoC)
+	a369evb		FA626TE & FA606TE (Faraday ARMv5TE) (a369 SoC)
+
 Eric Cooper <[email protected]>
 
 	dockstar	ARM926EJS (Kirkwood SoC)
arch/arm/cpu/faraday/a360/Makefile new file +49 -0

49 lines not on this page · raw message

arch/arm/cpu/faraday/a369/Makefile new file +50 -0

50 lines not on this page · raw message

arch/arm/cpu/faraday/a369/cmd_fa606.c new file +86 -0

86 lines not on this page · raw message

arch/arm/cpu/faraday/cpu.c +2 -0
index 449bf0d..123ec7e 100644
@@ -339,5 +339,7 @@ void reset_cpu(unsigned long ignored)
 	writel(1000, &regs->wdload);
 	/* Enable WDT with System Reset Function */
 	writel(FTWDT010_WDCR_ENABLE | FTWDT010_WDCR_RST, &regs->wdcr);
+	/* Kick it to force counter reloaded */
+    writel(FTWDT010_WDRESTART_MAGIC, &regs->wdrestart);
 #endif
 }
arch/arm/include/asm/arch-a360/hardware.h new file +84 -0

84 lines not on this page · raw message

arch/arm/include/asm/arch-a360/pmu.h new file +95 -0

95 lines not on this page · raw message

arch/arm/include/asm/arch-a360/scu.h new file +79 -0

79 lines not on this page · raw message

arch/arm/include/asm/arch-a369/ahbc.h new file +34 -0
new file mode 100644
index 0000000..5a77825
@@ -0,0 +1,34 @@
+/*
+ * arch/arm/include/asm/arch-a369/ahbc.h
+ *
+ * (C) Copyright 2013 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * 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 __ASM_ARCH_AHBC_H
+#define __ASM_ARCH_AHBC_H
+
+struct a369ahbc_regs {
+	uint32_t slave[32];/* Slave Device Configurations */
+	uint32_t priority; /* Priority */
+	uint32_t idle_cnt; /* IDLE Counter */
+	uint32_t control;  /* Control Register */
+	uint32_t revision; /* Revision ID */
+	uint32_t cpusao;   /* CPUS (FA606TE) Address Offset */
+};
+
+#endif
arch/arm/include/asm/arch-a369/hardware.h new file +99 -0

99 lines not on this page · raw message

arch/arm/include/asm/arch-a369/scu.h new file +224 -0

224 lines not on this page · raw message

arch/arm/include/asm/arch-faraday/clock.h new file +41 -0

41 lines not on this page · raw message

arch/arm/include/asm/arch-faraday/interrupt.h new file +29 -0
new file mode 100644
index 0000000..8a38946
@@ -0,0 +1,29 @@
+/*
+ * asm/arch-faraday/interrupt.h
+ *
+ * (C) Copyright 2013 Faraday Technology
+ * Dante Su <[email protected]>
+ *
+ * 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 _ASM_ARCH_FARADAY_INTERRUPT_H
+#define _ASM_ARCH_FARADAY_INTERRUPT_H
+
+void irq_set_trigger(int irq, int edge, int low);
+void irq_enable(int irq);
+void irq_disable(int irq);
+
+#endif	/* _ASM_ARCH_FARADAY_INTERRUPT_H */
board/faraday/a360evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a360evb/board.c new file +72 -0

72 lines not on this page · raw message

board/faraday/a360evb/clock.c new file +72 -0

72 lines not on this page · raw message

board/faraday/a360evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a360evb/lowlevel_init.S new file +33 -0
new file mode 100644
index 0000000..0d6c43f
@@ -0,0 +1,33 @@
+/*
+ * Board specific setup info
+ *
+ * (C) Copyright 2013
+ * Faraday Technology Inc. <www.faraday-tech.com>
+ * Dante Su <[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 <version.h>
+
+/* Set up the platform, once the cpu has been initialized */
+.globl lowlevel_init
+lowlevel_init:
+	mov	pc,lr
board/faraday/a369evb/Makefile new file +49 -0

49 lines not on this page · raw message

board/faraday/a369evb/board.c new file +176 -0

176 lines not on this page · raw message

board/faraday/a369evb/clock.c new file +80 -0

80 lines not on this page · raw message

board/faraday/a369evb/config.mk new file +33 -0
new file mode 100644
index 0000000..eb1a258
@@ -0,0 +1,33 @@
+#
+# (C) Copyright 2010
+# Dante Su <[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
+#
+
+#########################################################################
+
+ALL += $(obj)u-boot.img
+
+# Environment variables in NAND
+#ifeq ($(ENV),NAND)
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_NAND
+#else
+#PLATFORM_RELFLAGS += -DCONFIG_ENV_IS_IN_FLASH
+#endif
board/faraday/a369evb/lowlevel_init.S new file +136 -0

136 lines not on this page · raw message

boards.cfg +3 -0
index c0c4282..23a0448 100644
@@ -72,6 +72,9 @@ mini2440                     arm         arm920t     mini2440            friendl
 VCMA9                        arm         arm920t     vcma9               mpl            s3c24x0
 smdk2410                     arm         arm920t     -                   samsung        s3c24x0
 omap1510inn                  arm         arm925t     -                   ti
+a360                         arm         faraday     a360evb             faraday        a360
+a369                         arm         faraday     a369evb             faraday        a369
+a369_fa606te                 arm         faraday     a369evb             faraday        a369
 integratorap_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorap:CM926EJ_S
 integratorcp_cm926ejs        arm         arm926ejs   integrator          armltd         -           integratorcp:CM924EJ_S
 aspenite                     arm         arm926ejs   -                   Marvell        armada100
include/common.h +2 -0
index ec3bf0d..514c531 100644
@@ -111,6 +111,8 @@ typedef volatile unsigned char	vu_char;
 #include <asm/arch/hardware.h>
 #endif
 #ifdef CONFIG_FARADAY
+#include <asm/arch/hardware.h>
+#include <asm/arch-faraday/clock.h>
 #include <asm/arch-faraday/interrupt.h>
 #endif
 
include/configs/a360.h new file +60 -0

60 lines not on this page · raw message

include/configs/a369-common.h new file +75 -0

75 lines not on this page · raw message

include/configs/a369.h new file +34 -0
new file mode 100644
index 0000000..da7856e
@@ -0,0 +1,34 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_A369_PLATFORM
+
+/* Support USB-EHCI */
+#define CONFIG_SUPP_EHCI_FARADAY
+
+/* Support external AHB */
+/* #define CONFIG_SUPP_EXTAHB */
+
+/* Support USB RNDIS Ethernet */
+/* #define CONFIG_SUPP_USB_RNDIS */
+
+/* Support VGA Console */
+/* #define CONFIG_SUPP_VGA_CONSOLE */
+
+/* Support interrupt */
+/* #define CONFIG_USE_IRQ */
+
+/* Disable MMU/D-CACHE */
+/* #define CONFIG_SYS_DCACHE_OFF */
+
+/* Support runtime switching to built-in slave core: FA606TE */
+#define CONFIG_CMD_FA606
+
+/* Autoboot */
+#define CONFIG_BOOTDELAY            3
+#define CONFIG_BOOTCOMMAND          "bootfa nand linux"
+
+/* A369 common configuration */
+#include "a369-common.h"
+
+#endif
include/configs/a369_fa606te.h new file +31 -0
new file mode 100644
index 0000000..c549edb
@@ -0,0 +1,31 @@
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_A369_FA606TE_PLATFORM
+
+/* Support external AHB */
+/* #define CONFIG_SUPP_EXTAHB */
+
+/* Support USB RNDIS Ethernet */
+/* #define CONFIG_SUPP_USB_RNDIS */
+
+/* Support VGA Console */
+/* #define CONFIG_SUPP_VGA_CONSOLE */
+
+/* Support interrupt */
+/* #define CONFIG_USE_IRQ */
+
+/* Disable MMU/D-CACHE */
+#define CONFIG_SYS_DCACHE_OFF
+
+/* Disable I-CACHE */
+#define CONFIG_SYS_ICACHE_OFF
+
+/* Set interrupt controler to FTINCT020:1 */
+#undef  CONFIG_FTINTC020_BASE
+#define CONFIG_FTINTC020_BASE       CONFIG_FTINTC020_BASE1
+
+/* A369 common configuration */
+#include "a369-common.h"
+
+#endif
include/configs/faraday-common.h new file +243 -0

243 lines not on this page · raw message

include/faraday/ftsmc020.h +1 -0
index 59c6f8e..aa02717 100644
@@ -82,5 +82,6 @@ void ftsmc020_init(void);
 #define FTSMC020_TPR_WTC(x)	(((x) & 0x3) << 6)
 #define FTSMC020_TPR_AHT(x)	(((x) & 0x3) << 4)
 #define FTSMC020_TPR_TRNA(x)	(((x) & 0xf) << 0)
+#define FTSMC020_TPR_WORST	0x0f1ff3ff /* worst but safe */
 
 #endif	/* __FTSMC020_H */

--
1.7.9.5

#238 lore raw

v6 cover arm: add Faraday A36x SoC platform support

In reply to Kuo-Jung Su

Hi Kuo-Jung,

Quoted 3 lines · Kuo-Jung Su

From: Kuo-Jung Su <[email protected]>

These patches introduce Faraday A36x SoC platform support.

So where are we on this series? Seems like there were a few comments about V6, and I haven't seen a V7 to address them.

Amicalement,

Signature · 1 line
Albert.
#239 lore raw

v6 cover arm: add Faraday A36x SoC platform support

2013/7/25 Albert ARIBAUD <[email protected]>:

Quoted 5 lines

Hi Kuo-Jung,

On Thu, 4 Jul 2013 11:40:32 +0800, Kuo-Jung Su <[email protected]> wrote:

Quoted 7 lines
Quoted 3 lines

From: Kuo-Jung Su <[email protected]>

These patches introduce Faraday A36x SoC platform support.

So where are we on this series? Seems like there were a few comments about V6, and I haven't seen a V7 to address them.

The V7 would be released by next Tuesday.
It looks to me that only the NAND flash controller needs a trivial update. :)

--
Best wishes,
Kuo-Jung Su