Skip to contentSkip to conversation

socfpga: Adding Scan Manager driver

PATCH Superseded Chin Liang See 2 participants 3 messages Feb 21, 2014 Arm (32-bit)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 socfpga: Adding Scan Manager driver

Scan Manager driver will be called to configure the IOCSR scan chain. This configuration will setup the IO buffer settings

Cc Dinh Nguyen <[email protected]>
Cc Wolfgang Denk <[email protected]>
CC Pavel Machek <[email protected]>
Cc Tom Rini <[email protected]>
Cc Albert Aribaud <[email protected]>

---
Changes for v3
- merge the handoff file and driver into single patch Changes for v2
- rebase with latest v2014.01-rc1

---
 arch/arm/cpu/armv7/socfpga/Makefile                |    2 +-
 arch/arm/cpu/armv7/socfpga/scan_manager.c          |  228 +++++++
 arch/arm/cpu/armv7/socfpga/spl.c                   |    4 +
 arch/arm/include/asm/arch-socfpga/scan_manager.h   |   97 +++
 .../include/asm/arch-socfpga/socfpga_base_addrs.h  |    1 +
 board/altera/socfpga/iocsr_config.c                |  657 ++++++++++++++++++++
 board/altera/socfpga/iocsr_config.h                |   17 +
 include/configs/socfpga_cyclone5.h                 |    1 +
 8 files changed, 1006 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/socfpga/scan_manager.c
 create mode 100644 arch/arm/include/asm/arch-socfpga/scan_manager.h
 create mode 100644 board/altera/socfpga/iocsr_config.c
 create mode 100644 board/altera/socfpga/iocsr_config.h
arch/arm/cpu/armv7/socfpga/Makefile +1 -1
index 3e84a0c..4edc5d4 100644
@@ -9,4 +9,4 @@
 
 obj-y	:= lowlevel_init.o
 obj-y	+= misc.o timer.o reset_manager.o system_manager.o
-obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
+obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o scan_manager.o
arch/arm/cpu/armv7/socfpga/scan_manager.c new file +228 -0

228 lines not on this page · raw message

arch/arm/cpu/armv7/socfpga/spl.c +4 -0
index 36a00c3..8a49a1a 100644
@@ -32,6 +32,10 @@ void spl_board_init(void)
 	/* freeze all IO banks */
 	sys_mgr_frzctrl_freeze_req();
 
+	/* configure the IOCSR / IO buffer settings */
+	if (scan_mgr_configure_iocsr())
+		hang();
+
 	/* configure the pin muxing through system manager */
 	sysmgr_pinmux_init();
 #endif /* CONFIG_SOCFPGA_VIRTUAL_TARGET */
arch/arm/include/asm/arch-socfpga/scan_manager.h new file +97 -0

97 lines not on this page · raw message

arch/arm/include/asm/arch-socfpga/socfpga_base_addrs.h +1 -0
index 50c4ebd..8d329cf 100644
@@ -13,5 +13,6 @@
 #define SOCFPGA_OSC1TIMER0_ADDRESS 0xffd00000
 #define SOCFPGA_RSTMGR_ADDRESS 0xffd05000
 #define SOCFPGA_SYSMGR_ADDRESS 0xffd08000
+#define SOCFPGA_SCANMGR_ADDRESS 0xfff02000
 
 #endif /* _SOCFPGA_BASE_ADDRS_H_ */
board/altera/socfpga/iocsr_config.c new file +657 -0

657 lines not on this page · raw message

board/altera/socfpga/iocsr_config.h new file +17 -0
new file mode 100644
index 0000000..490f109
@@ -0,0 +1,17 @@
+/*
+ * Copyright Altera Corporation (C) 2012-2014. All rights reserved
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+/* This file is generated by Preloader Generator */
+
+#ifndef _PRELOADER_IOCSR_CONFIG_H_
+#define _PRELOADER_IOCSR_CONFIG_H_
+
+#define CONFIG_HPS_IOCSR_SCANCHAIN0_LENGTH        (764)
+#define CONFIG_HPS_IOCSR_SCANCHAIN1_LENGTH        (1719)
+#define CONFIG_HPS_IOCSR_SCANCHAIN2_LENGTH        (955)
+#define CONFIG_HPS_IOCSR_SCANCHAIN3_LENGTH        (16766)
+
+#endif /*_PRELOADER_IOCSR_CONFIG_H_*/
include/configs/socfpga_cyclone5.h +1 -0
index 608578a..3d553f7 100644
@@ -8,6 +8,7 @@
 
 #include <asm/arch/socfpga_base_addrs.h>
 #include "../../board/altera/socfpga/pinmux_config.h"
+#include "../../board/altera/socfpga/iocsr_config.h"
 
 /*
  * High level configuration
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/1 socfpga: Adding Scan Manager driver

Hi!

arch/arm/cpu/armv7/socfpga/scan_manager.c line 73

Quoted 9 lines
arch/arm/cpu/armv7/socfpga/scan_manager.c new file +9 -0
+	/*
+	 * Check if the scan chain engine is inactive and the
+	 * WFIFO is empty before enabling the IO scan chain
+	 */
+	if (SCAN_MGR_IO_SCAN_ENGINE_STATUS_IDLE
+		!= scan_mgr_io_scan_chain_engine_is_idle(
+		MAX_WAITING_DELAY_IO_SCAN_ENGINE)) {
+		return 1;
+	}

Hmm.. function named "_is_idle" maybe should just return 0 or 1?

arch/arm/cpu/armv7/socfpga/scan_manager.c line 125

Quoted 13 lines
arch/arm/cpu/armv7/socfpga/scan_manager.c new file +13 -0
+		/*
+		 * Check if the scan chain engine has completed the
+		 * IO scan chain data shifting
+		 */
+		if (SCAN_MGR_IO_SCAN_ENGINE_STATUS_IDLE
+			!= scan_mgr_io_scan_chain_engine_is_idle(
+			MAX_WAITING_DELAY_IO_SCAN_ENGINE)) {
+			/* Disable IO Scan chain when error detected */
+			clrbits_le32(&scan_manager_base->en,
+				1 << io_scan_chain_id);
+			return 1;
+		}
+	}

"goto error" would help avoid code duplication.

arch/arm/include/asm/arch-socfpga/scan_manager.h line 17

Quoted 8 lines
arch/arm/include/asm/arch-socfpga/scan_manager.h new file +8 -0
+struct socfpga_scan_manager {
+	u32	stat;
+	u32	en;
+	u32	padding[2];
+	u32	fifosinglebyte;
+	u32	fifodoublebyte;
+	u32	fifoquadbyte;
+};

some underscores should be added here.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw

PATCH v3 1/1 socfpga: Adding Scan Manager driver

Hi Pavel,

Nice to hear from you again :)

Quoted 13 lines · ZY - pavel

Hi!

arch/arm/cpu/armv7/socfpga/scan_manager.c line 73

Quoted 9 lines
arch/arm/cpu/armv7/socfpga/scan_manager.c new file +9 -0
+	/*
+	 * Check if the scan chain engine is inactive and the
+	 * WFIFO is empty before enabling the IO scan chain
+	 */
+	if (SCAN_MGR_IO_SCAN_ENGINE_STATUS_IDLE
+		!= scan_mgr_io_scan_chain_engine_is_idle(
+		MAX_WAITING_DELAY_IO_SCAN_ENGINE)) {
+		return 1;
+	}

Hmm.. function named "_is_idle" maybe should just return 0 or 1?

Yup we can simplify that. Probably just remain for readability. Hope its ok for you.

Quoted 16 lines
Quoted 4 lines
arch/arm/cpu/armv7/socfpga/scan_manager.c new file +3 -0
+		/*
+		 * Check if the scan chain engine has completed the
+		 * IO scan chain data shifting

arch/arm/cpu/armv7/socfpga/scan_manager.c line 125

Quoted 10 lines
arch/arm/cpu/armv7/socfpga/scan_manager.c new file +10 -0
+		 */
+		if (SCAN_MGR_IO_SCAN_ENGINE_STATUS_IDLE
+			!= scan_mgr_io_scan_chain_engine_is_idle(
+			MAX_WAITING_DELAY_IO_SCAN_ENGINE)) {
+			/* Disable IO Scan chain when error detected */
+			clrbits_le32(&scan_manager_base->en,
+				1 << io_scan_chain_id);
+			return 1;
+		}
+	}

"goto error" would help avoid code duplication.

Good suggestion here. Will change that.

Quoted 11 lines

arch/arm/include/asm/arch-socfpga/scan_manager.h line 17

Quoted 9 lines
arch/arm/include/asm/arch-socfpga/scan_manager.h new file +8 -0
+struct socfpga_scan_manager {
+	u32	stat;
+	u32	en;
+	u32	padding[2];
+	u32	fifosinglebyte;
+	u32	fifodoublebyte;
+	u32	fifoquadbyte;
+};

some underscores should be added here.

Sure, for better readability.

Thanks!

Chin Liang

Quoted 3 lines

Thanks,
Pavel