Re: [PATCH 3/3] PowerPC: keymile: Add support for kmcent2 board

2021-01-21 Thread Niel Fourie

Hi Stefan

On 19/01/2021 16:31, Stefan Roese wrote:




diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index 60b89fe348..608406dacd 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -321,6 +321,11 @@ static int ivm_populate_env(unsigned char *buf, 
int len, int mac_address_offset)

  process_mac(valbuf, page2, mac_address_offset, true);
  env_set((char *)"eth1addr", (char *)valbuf);
  #endif
+#if defined(CONFIG_TARGET_KMCENT2)


Can't you switch to using if (IS_ENABLED(CONFIG_TARGET_KMCENT2)) instead
adding more #ifdef's to this code?


Makes sense, changed that.




+/* 3rd ethernet interface */
+    process_mac(valbuf, page2, 2, true);
+    env_set((char *)"eth4addr", (char *)valbuf);
+#endif


eth_env_set_enetaddr() ?


This one is tricky, as process_mac() already formatted the mac address 
as a string (using the "%pM" format string) already, while 
eth_env_set_enetaddr() again applies the "%pM" format string to its input.


There are three other instances of the process_mac()/env_set() as above 
in this file, which would need to be changed along with process_mac() 
itself (to not apply "%pM"), so that eth_env_set_enetaddr() can be used. 
Should I do this for all the cases?





diff --git a/board/keymile/kmcent2/ddr.c b/board/keymile/kmcent2/ddr.c
new file mode 100644
index 00..2b4e58795a
--- /dev/null
+++ b/board/keymile/kmcent2/ddr.c
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2016 Keymile AG
+ * Rainer Boschung 
+ *
+ * Copyright 2013 Freescale Semiconductor, Inc.
+ */
+
+#include 


Please don't include common.h any more. Simon has worked hard to move
things out of common.h so that it should not be used any more.


Thanks, I did not know of this, will apply everywhere.


+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 


Sort header includes?


Thanks, will apply everywhere. I hit a couple of snags, though. Above,
fsl_ddr_dimm_params.h depends on generic_spd_eeprom_t defined in 
fsl_ddr_sdram.h, so I kept those two in that order.


Also in law.c, asm/fsl_law.h need config.h before it to compile.


+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define DQSn_POS(n)    (3 - (((n) - 1) % 4)) * 8
+#define DQSn_START(n, start)    ((start) << DQSn_POS(n))


Empty line please.


Fixed



diff --git a/board/keymile/kmcent2/kmcent2.c 
b/board/keymile/kmcent2/kmcent2.c

new file mode 100644
index 00..3d6bd8328e
--- /dev/null
+++ b/board/keymile/kmcent2/kmcent2.c




Nitpicking: The official coding style for multi line comment is this:

 /*
  * CFE_RST (front phy):
  * reset at power-up, unit and core reset, deasset reset w/o WD
  */

Please consistant in this file.


Thanks, fixed everywhere.




+#if defined(CONFIG_HUSH_INIT_VAR)
+int hush_init_var(void)
+{
+    ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
+    return 0;
+}
+#endif


Is hush disabled in any case? If not, remove the #ifdef please.


+
+#if defined(CONFIG_LAST_STAGE_INIT)


Again, is CONFIG_LAST_STAGE_INIT ever disabled?


Good point, thanks. I removed the #ifdefs for CONFIG_LAST_STAGE_INIT, 
CONFIG_LAST_STAGE_INIT, CONFIG_SYS_DPAA_FMAN and CONFIG_POST.





diff --git a/board/keymile/kmcent2/tlb.c b/board/keymile/kmcent2/tlb.c
new file mode 100644
index 00..8a726fbd17
--- /dev/null
+++ b/board/keymile/kmcent2/tlb.c
@@ -0,0 +1,120 @@





+#if defined(CONFIG_SYS_MRAM_BASE)
+    SET_TLB_ENTRY(1, CONFIG_SYS_MRAM_BASE, SYS_MRAM_BASE_PHYS,
+  MAS3_SW | MAS3_SR, MAS2_I | MAS2_G,
+  0, 12, BOOKE_PAGESZ_128M, 1),
+#endif
+    /* BFTIC */
+#if defined(SYS_BFTIC_BASE)


Really? "SYS_BFTIC_BASE" or "CONFIG_SYS_BFTIC_BASE" ?


Well spotted! It turns out SYS_BFTIC_BASE, as CONFIG_SYS_BFTIC_BASE is 
not in config_whitelist.txt, and renaming it was the compromise. The 
code originally predates the disallowing of ad-hoc CONFIGs... I hope 
this is okay?



And here as well, if some of these defines are always set or never,
please remove the #ifdef's or the complete block if never set.


Thanks. Applied this to tlb.c and law.c.


+    SET_TLB_ENTRY(1, SYS_BFTIC_BASE, SYS_BFTIC_BASE_PHYS,
+  MAS3_SW | MAS3_SR, MAS2_I | MAS2_G,
+  0, 13, BOOKE_PAGESZ_128M, 1),
+#endif





diff --git a/include/configs/kmcent2.h b/include/configs/kmcent2.h
new file mode 100644
index 00..a0f3a09057
--- /dev/null
+++ b/include/configs/kmcent2.h
@@ -0,0 +1,537 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2016 Keymile AG
+ * Rainer Boschung 
+ *
+ */
+
+#ifndef __KMCENT2_H
+#define __KMCENT2_H
+
+#define CONFIG_HOSTNAME    "kmcent2"
+#define KM_BOARD_NAME    CONFIG_HOSTNAME
+
+#define CONFIG_KM_UBI_PARTITION_NAME_BOOT    "ubi0"
+#define CONFIG_KM_UBI_PARTITION_NAME_APP    "ubi1"
+#define MTDIDS_DEFAULT    "nor0=fe800.nor,nand0=ffa00.flash"
+
+#define MTDPARTS_DEFAULT    "mtdparts="    \
+    

Re: [PATCH 3/3] PowerPC: keymile: Add support for kmcent2 board

2021-01-19 Thread Stefan Roese

Hi Niel,

On 08.01.21 11:53, Niel Fourie wrote:

Add basic support for the Hitachi Power Grids kmcent2 board, based
on the NXP QorIQ T1040 SoC.

Signed-off-by: Valentin Longchamp 
Signed-off-by: Rainer Boschung 
Signed-off-by: Niel Fourie 
Cc: Holger Brunck 
Cc: Heiko Schocher 
Cc: Priyanka Jain 
---
  arch/powerpc/cpu/mpc85xx/Kconfig |   4 +
  arch/powerpc/dts/Makefile|   1 +
  arch/powerpc/dts/kmcent2-u-boot.dtsi |  97 +
  board/keymile/Kconfig|   1 +
  board/keymile/common/ivm.c   |   5 +
  board/keymile/kmcent2/Kconfig|  17 +
  board/keymile/kmcent2/MAINTAINERS|   8 +
  board/keymile/kmcent2/Makefile   |  15 +
  board/keymile/kmcent2/ddr.c  |  88 +
  board/keymile/kmcent2/kmcent2.c  | 349 +
  board/keymile/kmcent2/law.c  |  40 ++
  board/keymile/kmcent2/tlb.c  | 120 ++
  configs/kmcent2_defconfig|  90 +
  include/configs/kmcent2.h| 537 +++
  14 files changed, 1372 insertions(+)
  create mode 100644 arch/powerpc/dts/kmcent2-u-boot.dtsi
  create mode 100644 board/keymile/kmcent2/Kconfig
  create mode 100644 board/keymile/kmcent2/MAINTAINERS
  create mode 100644 board/keymile/kmcent2/Makefile
  create mode 100644 board/keymile/kmcent2/ddr.c
  create mode 100644 board/keymile/kmcent2/kmcent2.c
  create mode 100644 board/keymile/kmcent2/law.c
  create mode 100644 board/keymile/kmcent2/tlb.c
  create mode 100644 configs/kmcent2_defconfig
  create mode 100644 include/configs/kmcent2.h

diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig
index 54c7fd9522..c1a3770671 100644
--- a/arch/powerpc/cpu/mpc85xx/Kconfig
+++ b/arch/powerpc/cpu/mpc85xx/Kconfig
@@ -256,6 +256,10 @@ config TARGET_KMP204X
bool "Support kmp204x"
select VENDOR_KM
  
+config TARGET_KMCENT2

+   bool "Support kmcent2"
+   select VENDOR_KM
+
  config TARGET_XPEDITE520X
bool "Support xpedite520x"
select ARCH_MPC8548
diff --git a/arch/powerpc/dts/Makefile b/arch/powerpc/dts/Makefile
index 266d345f72..3ecda36538 100644
--- a/arch/powerpc/dts/Makefile
+++ b/arch/powerpc/dts/Makefile
@@ -1,5 +1,6 @@
  # SPDX-License-Identifier: GPL-2.0+
  
+dtb-$(CONFIG_TARGET_KMCENT2) += kmcent2.dtb

  dtb-$(CONFIG_TARGET_KMCOGE5NE) += kmcoge5ne.dtb
  dtb-$(CONFIG_TARGET_KMETER1) += kmeter1.dtb
  dtb-$(CONFIG_TARGET_KMOPTI2) += kmopti2.dtb
diff --git a/arch/powerpc/dts/kmcent2-u-boot.dtsi 
b/arch/powerpc/dts/kmcent2-u-boot.dtsi
new file mode 100644
index 00..ab76a9f122
--- /dev/null
+++ b/arch/powerpc/dts/kmcent2-u-boot.dtsi
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2021  Niel Fourie 
+ */
+
+#include 
+
+/ {
+
+   aliases {
+   spi0 = "/soc@ffe00/spi@11";
+   i2c0 = "/soc@ffe00/i2c@118000";
+   i2c1 = "/soc@ffe00/i2c@118000/mux@70/i2c@0";
+   i2c2 = "/soc@ffe00/i2c@118000/mux@70/i2c@1";
+   i2c3 = "/soc@ffe00/i2c@118000/mux@70/i2c@7";
+   i2c4 = "/soc@ffe00/i2c@118100";
+   /delete-property/ pci1;
+   /delete-property/ pci2;
+   /delete-property/ pci3;
+   };
+
+   chosen {
+   stdout-path = "/soc@ffe00/serial@11c500";
+   };
+
+   soc@ffe00 {
+   u-boot,dm-pre-reloc;
+   spi@11 {
+   /* This documents where km_fpgacfg should be appear */
+   fpga@0 {
+   compatible = "keymile,fpga-conf";
+   reg = <0>;
+   spi-max-frequency = <2500>;
+   };
+   };
+
+   sdhc@114000 {
+   status = "okay";
+   };
+
+   i2c@118000 {
+   u-boot,dm-pre-reloc;
+   mux@70 {
+   i2c@1 { /* IVM bus */
+   reg = <1>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
+   };
+   };
+
+   serial@11c500 {
+   u-boot,dm-pre-reloc;
+   clock-frequency = <2>;
+   };
+
+   fman@40 {
+   ethernet@e {
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e2000 {
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e8000 {
+   phy-connection-type = "rgmii-id";
+   };
+   };
+
+   };
+
+   pcie@ffe24 {
+   compatible = "fsl,pcie-t104x";
+   

[PATCH 3/3] PowerPC: keymile: Add support for kmcent2 board

2021-01-08 Thread Niel Fourie
Add basic support for the Hitachi Power Grids kmcent2 board, based
on the NXP QorIQ T1040 SoC.

Signed-off-by: Valentin Longchamp 
Signed-off-by: Rainer Boschung 
Signed-off-by: Niel Fourie 
Cc: Holger Brunck 
Cc: Heiko Schocher 
Cc: Priyanka Jain 
---
 arch/powerpc/cpu/mpc85xx/Kconfig |   4 +
 arch/powerpc/dts/Makefile|   1 +
 arch/powerpc/dts/kmcent2-u-boot.dtsi |  97 +
 board/keymile/Kconfig|   1 +
 board/keymile/common/ivm.c   |   5 +
 board/keymile/kmcent2/Kconfig|  17 +
 board/keymile/kmcent2/MAINTAINERS|   8 +
 board/keymile/kmcent2/Makefile   |  15 +
 board/keymile/kmcent2/ddr.c  |  88 +
 board/keymile/kmcent2/kmcent2.c  | 349 +
 board/keymile/kmcent2/law.c  |  40 ++
 board/keymile/kmcent2/tlb.c  | 120 ++
 configs/kmcent2_defconfig|  90 +
 include/configs/kmcent2.h| 537 +++
 14 files changed, 1372 insertions(+)
 create mode 100644 arch/powerpc/dts/kmcent2-u-boot.dtsi
 create mode 100644 board/keymile/kmcent2/Kconfig
 create mode 100644 board/keymile/kmcent2/MAINTAINERS
 create mode 100644 board/keymile/kmcent2/Makefile
 create mode 100644 board/keymile/kmcent2/ddr.c
 create mode 100644 board/keymile/kmcent2/kmcent2.c
 create mode 100644 board/keymile/kmcent2/law.c
 create mode 100644 board/keymile/kmcent2/tlb.c
 create mode 100644 configs/kmcent2_defconfig
 create mode 100644 include/configs/kmcent2.h

diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig
index 54c7fd9522..c1a3770671 100644
--- a/arch/powerpc/cpu/mpc85xx/Kconfig
+++ b/arch/powerpc/cpu/mpc85xx/Kconfig
@@ -256,6 +256,10 @@ config TARGET_KMP204X
bool "Support kmp204x"
select VENDOR_KM
 
+config TARGET_KMCENT2
+   bool "Support kmcent2"
+   select VENDOR_KM
+
 config TARGET_XPEDITE520X
bool "Support xpedite520x"
select ARCH_MPC8548
diff --git a/arch/powerpc/dts/Makefile b/arch/powerpc/dts/Makefile
index 266d345f72..3ecda36538 100644
--- a/arch/powerpc/dts/Makefile
+++ b/arch/powerpc/dts/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+dtb-$(CONFIG_TARGET_KMCENT2) += kmcent2.dtb
 dtb-$(CONFIG_TARGET_KMCOGE5NE) += kmcoge5ne.dtb
 dtb-$(CONFIG_TARGET_KMETER1) += kmeter1.dtb
 dtb-$(CONFIG_TARGET_KMOPTI2) += kmopti2.dtb
diff --git a/arch/powerpc/dts/kmcent2-u-boot.dtsi 
b/arch/powerpc/dts/kmcent2-u-boot.dtsi
new file mode 100644
index 00..ab76a9f122
--- /dev/null
+++ b/arch/powerpc/dts/kmcent2-u-boot.dtsi
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2021  Niel Fourie 
+ */
+
+#include 
+
+/ {
+
+   aliases {
+   spi0 = "/soc@ffe00/spi@11";
+   i2c0 = "/soc@ffe00/i2c@118000";
+   i2c1 = "/soc@ffe00/i2c@118000/mux@70/i2c@0";
+   i2c2 = "/soc@ffe00/i2c@118000/mux@70/i2c@1";
+   i2c3 = "/soc@ffe00/i2c@118000/mux@70/i2c@7";
+   i2c4 = "/soc@ffe00/i2c@118100";
+   /delete-property/ pci1;
+   /delete-property/ pci2;
+   /delete-property/ pci3;
+   };
+
+   chosen {
+   stdout-path = "/soc@ffe00/serial@11c500";
+   };
+
+   soc@ffe00 {
+   u-boot,dm-pre-reloc;
+   spi@11 {
+   /* This documents where km_fpgacfg should be appear */
+   fpga@0 {
+   compatible = "keymile,fpga-conf";
+   reg = <0>;
+   spi-max-frequency = <2500>;
+   };
+   };
+
+   sdhc@114000 {
+   status = "okay";
+   };
+
+   i2c@118000 {
+   u-boot,dm-pre-reloc;
+   mux@70 {
+   i2c@1 { /* IVM bus */
+   reg = <1>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   };
+   };
+   };
+
+   serial@11c500 {
+   u-boot,dm-pre-reloc;
+   clock-frequency = <2>;
+   };
+
+   fman@40 {
+   ethernet@e {
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e2000 {
+   phy-connection-type = "sgmii";
+   };
+
+   ethernet@e8000 {
+   phy-connection-type = "rgmii-id";
+   };
+   };
+
+   };
+
+   pcie@ffe24 {
+   compatible = "fsl,pcie-t104x";
+   law_trgt_if = <0>;
+   };
+
+   binman {
+