Skip to contentSkip to conversation

board/t104xrdb: Add support of CPLD

PATCH Superseded Prabhakar Kushwaha 2 participants 2 messages Feb 28, 2014 – Mar 7, 2014

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 board/t104xrdb: Add support of CPLD

T1040RDB and T1042RDB_PI has CPLD. Here CPLD controls board mux/features.

This support of CPLD includes
- files and register defintion
- Commands to swtich alternate bank and default bank

---
Changes for v2:
- Updated the cpld command
Changes for v3:
- fix typo

 board/freescale/t104xrdb/Makefile   |    1 +
 board/freescale/t104xrdb/cpld.c     |  113 +++++++++++++++++++++++++++++++++++
 board/freescale/t104xrdb/cpld.h     |   40 +++++++++++++
 board/freescale/t104xrdb/t104xrdb.c |   13 ++++
 include/configs/T1040RDB.h          |    8 +++
 include/configs/T1042RDB_PI.h       |    8 +++
 6 files changed, 183 insertions(+)
 create mode 100644 board/freescale/t104xrdb/cpld.c
 create mode 100644 board/freescale/t104xrdb/cpld.h
board/freescale/t104xrdb/Makefile +1 -0
index e51fb7a..af38d9f 100644
@@ -11,3 +11,4 @@ obj-y	+= eth.o
 obj-$(CONFIG_PCI)	+= pci.o
 obj-y	+= law.o
 obj-y	+= tlb.o
+obj-y	+= cpld.o
board/freescale/t104xrdb/cpld.c new file +113 -0

113 lines not on this page · raw message

board/freescale/t104xrdb/cpld.h new file +40 -0
new file mode 100644
index 0000000..0da9a01
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2013 Freescale Semiconductor
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * This file provides support for the ngPIXIS, a board-specific FPGA used on
+ * some Freescale reference boards.
+ */
+
+/*
+ * CPLD register set. Feel free to add board-specific #ifdefs where necessary.
+ */
+struct cpld_data {
+	u8 cpld_ver;		/* 0x00 - CPLD Major Revision Register */
+	u8 cpld_ver_sub;	/* 0x01 - CPLD Minor Revision Register */
+	u8 hw_ver;		/* 0x02 - Hardware Revision Register */
+	u8 sw_ver;		/* 0x03 - Software Revision register */
+	u8 res0[12];		/* 0x04 - 0x0F - not used */
+	u8 reset_ctl1;		/* 0x10 - Reset control Register1 */
+	u8 reset_ctl2;		/* 0x11 - Reset control Register2 */
+	u8 int_status;		/* 0x12 - Interrupt status Register */
+	u8 flash_ctl_status;	/* 0x13 - Flash control and status register */
+	u8 fan_ctl_status;	/* 0x14 - Fan control and status register  */
+	u8 led_ctl_status;	/* 0x15 - LED control and status register */
+	u8 sfp_ctl_status;	/* 0x16 - SFP control and status register  */
+	u8 misc_ctl_status;	/* 0x17 - Miscellanies ctrl & status register*/
+	u8 boot_override;	/* 0x18 - Boot override register */
+	u8 boot_config1;	/* 0x19 - Boot config override register*/
+	u8 boot_config2;	/* 0x1A - Boot config override register*/
+} cpld_data_t;
+
+
+/* Pointer to the CPLD register set */
+
+u8 cpld_read(unsigned int reg);
+void cpld_write(unsigned int reg, u8 value);
+
+#define CPLD_READ(reg) cpld_read(offsetof(struct cpld_data, reg))
+#define CPLD_WRITE(reg, value)\
+		cpld_write(offsetof(struct cpld_data, reg), value)
board/freescale/t104xrdb/t104xrdb.c +13 -0
index 6e29d64..b48133a 100644
@@ -19,14 +19,27 @@
 #include <fm_eth.h>
 
 #include "t104xrdb.h"
+#include "cpld.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
 int checkboard(void)
 {
 	struct cpu_type *cpu = gd->arch.cpu;
+	u8 sw;
 
 	printf("Board: %sRDB\n", cpu->name);
+	printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
+	       CPLD_READ(hw_ver), CPLD_READ(sw_ver));
+
+	sw = CPLD_READ(flash_ctl_status);
+	sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
+
+	if (sw <= 7)
+		printf("vBank: %d\n", sw);
+	else
+		printf("Unsupported Bank=%x\n", sw);
+
 	return 0;
 }
 
include/configs/T1040RDB.h +8 -0
index fd010c0..596129c 100644
@@ -196,6 +196,14 @@
 #define CONFIG_SYS_FLASH_BANKS_LIST	{CONFIG_SYS_FLASH_BASE_PHYS}
 
 /* CPLD on IFC */
+#define CPLD_LBMAP_MASK			0x3F
+#define CPLD_BANK_SEL_MASK		0x07
+#define CPLD_BANK_OVERRIDE		0x40
+#define CPLD_LBMAP_ALTBANK		0x44 /* BANK OR | BANK 4 */
+#define CPLD_LBMAP_DFLTBANK		0x40 /* BANK OR | BANK0 */
+#define CPLD_LBMAP_RESET		0xFF
+#define CPLD_LBMAP_SHIFT		0x03
+
 #define CONFIG_SYS_CPLD_BASE	0xffdf0000
 #define CONFIG_SYS_CPLD_BASE_PHYS	(0xf00000000ull | CONFIG_SYS_CPLD_BASE)
 #define CONFIG_SYS_CSPR2_EXT	(0xf)
include/configs/T1042RDB_PI.h +8 -0
index 6d07805..12a60f8 100644
@@ -196,6 +196,14 @@
 #define CONFIG_SYS_FLASH_BANKS_LIST	{CONFIG_SYS_FLASH_BASE_PHYS}
 
 /* CPLD on IFC */
+#define CPLD_LBMAP_MASK			0x3F
+#define CPLD_BANK_SEL_MASK		0x07
+#define CPLD_BANK_OVERRIDE		0x40
+#define CPLD_LBMAP_ALTBANK		0x44 /* BANK OR | BANK 4 */
+#define CPLD_LBMAP_DFLTBANK		0x40 /* BANK OR | BANK0 */
+#define CPLD_LBMAP_RESET		0xFF
+#define CPLD_LBMAP_SHIFT		0x03
+
 #define CONFIG_SYS_CPLD_BASE	0xffdf0000
 #define CONFIG_SYS_CPLD_BASE_PHYS	(0xf00000000ull | CONFIG_SYS_CPLD_BASE)
 #define CONFIG_SYS_CSPR2_EXT	(0xf)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/1 board/t104xrdb: Add support of CPLD

Quoted 13 lines · Prabhakar Kushwaha

T1040RDB and T1042RDB_PI has CPLD. Here CPLD controls board mux/features.

This support of CPLD includes
- files and register defintion
- Commands to swtich alternate bank and default bank

---
Changes for v2:
- Updated the cpld command
Changes for v3:
- fix typo

<snip>

board/freescale/t104xrdb/cpld.c line 112

Quoted 8 lines
board/freescale/t104xrdb/cpld.c new file +8 -0
+U_BOOT_CMD(
+	cpld, CONFIG_SYS_MAXARGS, 1, do_cpld,
+	"Reset the board or alternate bank",
+	"reset - hard reset to default bank\n"
+	"cpld_cmd reset altbank - reset to alternate bank\n"
+#ifdef DEBUG
+	"cpld_cmd dump - display the CPLD registers\n"
+#endif

More to fix. Please keep the command consistent. I think you want to use cpld, instead of cpld_cmd.

York