Skip to contentSkip to conversation

powerpc, 8xx: Add support for MCR3000 board from CSSI

PATCH Superseded Christophe Leroy 3 participants 4 messages Jul 6, 2017 – Jul 7, 2017

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 powerpc, 8xx: Add support for MCR3000 board from CSSI

CS Systemes d'Information (CSSI) manufactures two boards, named MCR3000 and CMPC885 which are respectively based on MPC866 and MPC885 processors.

This patch adds support for the first board.

---
v3: Takes into account comments received from Heiko and Wolfgang

Applies after the v2 serie 'powerpc, 8xx: Modernise the 8xx'

 .travis.yml                     |   2 +
 arch/powerpc/cpu/mpc8xx/Kconfig |   5 +
 board/cssi/MAINTAINERS          |   6 +
 board/cssi/MCR3000/Kconfig      |  15 ++
 board/cssi/MCR3000/MCR3000.c    | 320 ++++++++++++++++++++++++++++++++++++++++
 board/cssi/MCR3000/Makefile     |  10 ++
 board/cssi/MCR3000/nand.c       |  65 ++++++++
 board/cssi/MCR3000/u-boot.lds   |  91 ++++++++++++
 configs/MCR3000_defconfig       |  88 +++++++++++
 drivers/net/mpc8xx_fec.c        |  20 +++
 include/configs/MCR3000.h       | 162 ++++++++++++++++++++
 11 files changed, 784 insertions(+)
 create mode 100644 board/cssi/MAINTAINERS
 create mode 100644 board/cssi/MCR3000/Kconfig
 create mode 100644 board/cssi/MCR3000/MCR3000.c
 create mode 100644 board/cssi/MCR3000/Makefile
 create mode 100644 board/cssi/MCR3000/nand.c
 create mode 100644 board/cssi/MCR3000/u-boot.lds
 create mode 100644 configs/MCR3000_defconfig
 create mode 100644 include/configs/MCR3000.h
.travis.yml +2 -0
index 6f14ec2396..226c8313b1 100644
@@ -210,6 +210,8 @@ matrix:
     - env:
         - BUILDMAN="mpc86xx"
     - env:
+        - BUILDMAN="mpc8xx"
+    - env:
         - BUILDMAN="siemens"
     - env:
         - BUILDMAN="tegra"
arch/powerpc/cpu/mpc8xx/Kconfig +5 -0
index 9e1ad33c28..5a7db335ed 100644
@@ -8,6 +8,9 @@ choice
 	prompt "Target select"
 	optional
 
+config TARGET_MCR3000
+	bool "Support MCR3000 board from CSSI"
+
 endchoice
 
 choice
@@ -167,4 +170,6 @@ config SYS_OR7_PRELIM
 config SYS_IMMR
 	hex "Value for IMMR"
 
+source "board/cssi/MCR3000/Kconfig"
+
 endmenu
board/cssi/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..cbf1406a54
@@ -0,0 +1,6 @@
+BOARDS from CS Systemes d'Information
+M:	Christophe Leroy <[email protected]>
+S:	Maintained
+F:	board/cssi/
+F:	include/configs/MCR3000.h
+F:	configs/MCR3000_defconfig
board/cssi/MCR3000/Kconfig new file +15 -0
new file mode 100644
index 0000000000..ecfd90fd4c
@@ -0,0 +1,15 @@
+if TARGET_MCR3000
+
+config SYS_BOARD
+	default "MCR3000"
+
+config SYS_VENDOR
+	default "cssi"
+
+config SYS_CONFIG_NAME
+	default "MCR3000"
+
+config SYS_TEXT_BASE
+	default 0x04000000
+
+endif
board/cssi/MCR3000/MCR3000.c new file +320 -0

320 lines not on this page · raw message

board/cssi/MCR3000/Makefile new file +10 -0
new file mode 100644
index 0000000000..401d5aa4c1
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2010-2017 CS Systemes d'Information
+# Christophe Leroy <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+#
+
+obj-y += MCR3000.o
+obj-$(CONFIG_CMD_NAND) += nand.o
board/cssi/MCR3000/nand.c new file +65 -0

65 lines not on this page · raw message

board/cssi/MCR3000/u-boot.lds new file +91 -0

91 lines not on this page · raw message

configs/MCR3000_defconfig new file +88 -0

88 lines not on this page · raw message

drivers/net/mpc8xx_fec.c +20 -0
index b070d6696a..e525d3b593 100644
@@ -413,6 +413,26 @@ static void fec_pin_init(int fecidx)
 		 */
 		out_be16(&immr->im_ioport.iop_pdpar, 0x1fff);
 		out_be16(&immr->im_ioport.iop_pddir, 0x1fff);
+
+#if defined(CONFIG_TARGET_MCR3000)
+		out_be16(&immr->im_ioport.iop_papar, 0xBBFF);
+		out_be16(&immr->im_ioport.iop_padir, 0x04F0);
+		out_be16(&immr->im_ioport.iop_paodr, 0x0000);
+
+		out_be32(&immr->im_cpm.cp_pbpar, 0x000133FF);
+		out_be32(&immr->im_cpm.cp_pbdir, 0x0003BF0F);
+		out_be16(&immr->im_cpm.cp_pbodr, 0x0000);
+
+		out_be16(&immr->im_ioport.iop_pcpar, 0x0400);
+		out_be16(&immr->im_ioport.iop_pcdir, 0x0080);
+		out_be16(&immr->im_ioport.iop_pcso , 0x0D53);
+		out_be16(&immr->im_ioport.iop_pcint, 0x0000);
+
+		out_be16(&immr->im_ioport.iop_pdpar, 0x03FE);
+		out_be16(&immr->im_ioport.iop_pddir, 0x1C09);
+
+		setbits_be32(&immr->im_ioport.utmode, 0x80);
+#endif
 #endif
 
 #endif	/* CONFIG_ETHER_ON_FEC1 */
include/configs/MCR3000.h new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.12.0
#1 lore raw

PATCH v3 1/1 powerpc, 8xx: Add support for MCR3000 board from CSSI

Dear Christophe,

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

CS Systemes d'Information (CSSI) manufactures two boards, named MCR3000 and CMPC885 which are respectively based on MPC866 and MPC885 processors.

This patch adds support for the first board.

---
v3: Takes into account comments received from Heiko and Wolfgang

Thanks.

Quoted 3 lines

+/* -------------------------------------------------------------------------
+ * Device Tree Support
+ */

Incorrect multiline comment style... Please fix globally.

board/cssi/MCR3000/MCR3000.c line 67

Quoted 3 lines
board/cssi/MCR3000/MCR3000.c new file +3 -0
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
+static int fdt_set_node_and_value(void *blob, char *nodename, char *regname,
+				  void *var, int size)

This is apparently ancient code. No other board does it this way any more. It seems do_fixup_by_path_*() is preferred now.

Quoted 1 line

+#define ADDR_FLASH_ENV_AREA ((unsigned short *)(ADDR_FLASH + 0x40000))

Is this not a redundant setting? Can you not use CONFIG_ENV_ADDR
instead?

board/cssi/MCR3000/MCR3000.c line 189

Quoted 4 lines
board/cssi/MCR3000/MCR3000.c new file +4 -0
+struct environment {
+	uint32_t	crc;
+	uint8_t		data[];
+};

This is a (incomplete) redefine of struct environment_s. Why cannot you use that?

Quoted 40 lines
board/cssi/MCR3000/MCR3000.c new file +40 -0
+	/* verifying environment variable area */
+	env = (struct environment *)CONFIG_ENV_ADDR;
+	crc = crc32(0, env->data, (CONFIG_ENV_SIZE - sizeof(uint32_t)));
+	if (crc != env->crc) {
+		/* It can be an update request */
+		for (i = 0; i < 8; i++) {
+			str[i] = *(((uint8_t *)CONFIG_ENV_ADDR) + i);
+			str[(i+1)] = 0;
+		}
+		if (strcmp(str, "ETHADDR=") == 0) {
+			/* getting saved value */
+			i = 0;
+			for (j = 0; j < 4; j++) {
+				while (*(((uint8_t *)CONFIG_ENV_ADDR) + i) !=
+				       '=')
+					i++;
+				switch (j) {
+				case 0:
+					s = s_ethaddr;
+					break;
+				case 1:
+					s = s_num_serie;
+					break;
+				case 2:
+					s = s_id_cpld;
+					break;
+				case 3:
+					s = s_password;
+					break;
+				}
+				do {
+					i++;
+					*s = *(((uint8_t *)CONFIG_ENV_ADDR) + i);
+					s++;
+				} while (*(((uint8_t *)CONFIG_ENV_ADDR) + i)
+					 != 0x00);
+			}
+
+			/* creating or updating environment variable */
+			if (s_ethaddr[0] != 0x00)

board/cssi/MCR3000/MCR3000.c line 274

Quoted 10 lines
board/cssi/MCR3000/MCR3000.c new file +10 -0
+				setenv("ethaddr", s_ethaddr);
+			if (s_num_serie[0] != 0x00)
+				setenv("num_serie", s_num_serie);
+			if (s_id_cpld[0] != 0x00)
+				setenv("id_cpld", s_id_cpld);
+			if (s_password[0] != 0x00)
+				setenv("password", s_password);
+			saveenv();
+		}
+	}

This code is pretty scary...

Quoted 15 lines
board/cssi/MCR3000/MCR3000.c new file +15 -0
+	/* we do not modify environment variable area if CRC is false */
+	crc = crc32(0, env->data, (CONFIG_ENV_SIZE - sizeof(uint32_t)));
+	if (crc == env->crc) {
+		/* getting version value in CPLD register */
+		for (i = 0; i < LEN_STR; i++)
+			str[i] = 0;
+		version_cpld = *ADDR_CPLD_R_ETAT & R_ID_CPLD_MASK;
+		if (((version_cpld >> 12) & 0x000f) < 0x000a)
+			str[0] = ((version_cpld >> 12) & 0x000f) + 0x30;
+		else
+			str[0] = (((version_cpld >> 12) & 0x000f) - 0x000a) +
+				 0x41;
+		if (((version_cpld >> 8) & 0x000f) < 0x000a)
+			str[1] = ((version_cpld >> 8) & 0x000f) + 0x30;
+		else

board/cssi/MCR3000/MCR3000.c line 300

Quoted 10 lines
board/cssi/MCR3000/MCR3000.c new file +10 -0
+			str[1] = (((version_cpld >> 8) & 0x000f) - 0x000a) +
+				 0x41;
+		str[2] = 0x30;
+		str[3] = 0x30;
+
+		/* updating "id_cpld" variable if not corresponding */
+		s = getenv("id_cpld");
+		if ((s == NULL) || (strcmp(s, str) != 0)) {
+			setenv("id_cpld", str);
+			saveenv();

And again comment (we do not modify environment variable area) and code (call to saveenv()) do not agree.

This code is giving me the creeps...

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
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
"Everybody is talking about the  weather  but  nobody  does  anything
about it."                                               - Mark Twain
#2 lore raw

PATCH v3 1/1 powerpc, 8xx: Add support for MCR3000 board from CSSI

Dear Wolfgang,

Quoted 12 lines · Wolfgang Denk

Dear Christophe,

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

CS Systemes d'Information (CSSI) manufactures two boards, named MCR3000 and CMPC885 which are respectively based on MPC866 and MPC885 processors.

This patch adds support for the first board.

---
v3: Takes into account comments received from Heiko and Wolfgang

Quoted 7 lines

Thanks.

Quoted 3 lines

+/* -------------------------------------------------------------------------
+ * Device Tree Support
+ */

Incorrect multiline comment style... Please fix globally.

Oops, I only fixed the ones in the .h
Done everywhere now.

Quoted 7 lines

board/cssi/MCR3000/MCR3000.c line 67

Quoted 4 lines
board/cssi/MCR3000/MCR3000.c new file +3 -0
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
+static int fdt_set_node_and_value(void *blob, char *nodename, char *regname,
+				  void *var, int size)

This is apparently ancient code. No other board does it this way any more. It seems do_fixup_by_path_*() is preferred now.

Ok

Quoted 5 lines
Quoted 2 lines

+#define ADDR_FLASH_ENV_AREA ((unsigned short *)(ADDR_FLASH + 0x40000))

Is this not a redundant setting? Can you not use CONFIG_ENV_ADDR
instead?

Yes you are right, fixed it.

Quoted 53 lines

board/cssi/MCR3000/MCR3000.c line 189

Quoted 5 lines
board/cssi/MCR3000/MCR3000.c new file +4 -0
+struct environment {
+	uint32_t	crc;
+	uint8_t		data[];
+};

This is a (incomplete) redefine of struct environment_s. Why cannot you use that?

Quoted 44 lines
board/cssi/MCR3000/MCR3000.c new file +44 -0
+	/* verifying environment variable area */
+	env = (struct environment *)CONFIG_ENV_ADDR;
+	crc = crc32(0, env->data, (CONFIG_ENV_SIZE - sizeof(uint32_t)));
+	if (crc != env->crc) {
+		/* It can be an update request */
+		for (i = 0; i < 8; i++) {
+			str[i] = *(((uint8_t *)CONFIG_ENV_ADDR) + i);
+			str[(i+1)] = 0;
+		}
+		if (strcmp(str, "ETHADDR=") == 0) {
+			/* getting saved value */
+			i = 0;
+			for (j = 0; j < 4; j++) {
+				while (*(((uint8_t *)CONFIG_ENV_ADDR) + i) !=
+				       '=')
+					i++;
+				switch (j) {
+				case 0:
+					s = s_ethaddr;
+					break;
+				case 1:
+					s = s_num_serie;
+					break;
+				case 2:
+					s = s_id_cpld;
+					break;
+				case 3:
+					s = s_password;
+					break;
+				}
+				do {
+					i++;
+					*s = *(((uint8_t *)CONFIG_ENV_ADDR) + i);
+					s++;
+				} while (*(((uint8_t *)CONFIG_ENV_ADDR) + i)
+					 != 0x00);
+			}
+
+			/* creating or updating environment variable */
+			if (s_ethaddr[0] != 0x00)
+				setenv("ethaddr", s_ethaddr);
+			if (s_num_serie[0] != 0x00)
+				setenv("num_serie", s_num_serie);
+			if (s_id_cpld[0] != 0x00)
Quoted 8 lines

board/cssi/MCR3000/MCR3000.c line 274

Quoted 6 lines
board/cssi/MCR3000/MCR3000.c new file +6 -0
+				setenv("id_cpld", s_id_cpld);
+			if (s_password[0] != 0x00)
+				setenv("password", s_password);
+			saveenv();
+		}
+	}

This code is pretty scary...

Ok, I remove it for the time being, this code is not necessary for starting the board. Will fix that later in a more correct way.

Quoted 30 lines
Quoted 16 lines
board/cssi/MCR3000/MCR3000.c new file +15 -0
+	/* we do not modify environment variable area if CRC is false */
+	crc = crc32(0, env->data, (CONFIG_ENV_SIZE - sizeof(uint32_t)));
+	if (crc == env->crc) {
+		/* getting version value in CPLD register */
+		for (i = 0; i < LEN_STR; i++)
+			str[i] = 0;
+		version_cpld = *ADDR_CPLD_R_ETAT & R_ID_CPLD_MASK;
+		if (((version_cpld >> 12) & 0x000f) < 0x000a)
+			str[0] = ((version_cpld >> 12) & 0x000f) + 0x30;
+		else
+			str[0] = (((version_cpld >> 12) & 0x000f) - 0x000a) +
+				 0x41;
+		if (((version_cpld >> 8) & 0x000f) < 0x000a)
+			str[1] = ((version_cpld >> 8) & 0x000f) + 0x30;
+		else

board/cssi/MCR3000/MCR3000.c line 300

Quoted 10 lines
board/cssi/MCR3000/MCR3000.c new file +10 -0
+			str[1] = (((version_cpld >> 8) & 0x000f) - 0x000a) +
+				 0x41;
+		str[2] = 0x30;
+		str[3] = 0x30;
+
+		/* updating "id_cpld" variable if not corresponding */
+		s = getenv("id_cpld");
+		if ((s == NULL) || (strcmp(s, str) != 0)) {
+			setenv("id_cpld", str);
+			saveenv();

And again comment (we do not modify environment variable area) and code (call to saveenv()) do not agree.

Quoted 1 line

This code is giving me the creeps...

Ok, removed (see above).

Quoted 10 lines

Best regards,

Wolfgang Denk

Best regards
Christophe

#3 lore raw

PATCH v3 1/1 powerpc, 8xx: Add support for MCR3000 board from CSSI

In reply to Christophe Leroy

Hello Christophe,

Am 06.07.2017 um 16:45 schrieb Christophe Leroy:

Quoted 23 lines

CS Systemes d'Information (CSSI) manufactures two boards, named MCR3000 and CMPC885 which are respectively based on MPC866 and MPC885 processors.

This patch adds support for the first board.

---
v3: Takes into account comments received from Heiko and Wolfgang

Applies after the v2 serie 'powerpc, 8xx: Modernise the 8xx'

  .travis.yml                     |   2 +
  arch/powerpc/cpu/mpc8xx/Kconfig |   5 +
  board/cssi/MAINTAINERS          |   6 +
  board/cssi/MCR3000/Kconfig      |  15 ++
  board/cssi/MCR3000/MCR3000.c    | 320 ++++++++++++++++++++++++++++++++++++++++
  board/cssi/MCR3000/Makefile     |  10 ++
  board/cssi/MCR3000/nand.c       |  65 ++++++++
  board/cssi/MCR3000/u-boot.lds   |  91 ++++++++++++
  configs/MCR3000_defconfig       |  88 +++++++++++
  drivers/net/mpc8xx_fec.c        |  20 +++
  include/configs/MCR3000.h       | 162 ++++++++++++++++++++
  11 files changed, 784 insertions(+)
Quoted 8 lines

create mode 100644 board/cssi/MAINTAINERS create mode 100644 board/cssi/MCR3000/Kconfig create mode 100644 board/cssi/MCR3000/MCR3000.c create mode 100644 board/cssi/MCR3000/Makefile create mode 100644 board/cssi/MCR3000/nand.c create mode 100644 board/cssi/MCR3000/u-boot.lds create mode 100644 configs/MCR3000_defconfig create mode 100644 include/configs/MCR3000.h

no more comments beside Wolfgangs.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany