[PATCH v3 4/4] 44x/fsp2: add irq error handlers

2017-12-08 Thread Ivan Mikhaylov
add irq error handlers for cmu, plb, opb, mcue, conf
with debug information output in case of problems.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |  198 -
 1 files changed, 197 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 7c9bc93..83786b2 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "fsp2.h"
 
 static __initdata struct of_device_id fsp2_of_bus[] = {
@@ -37,6 +39,194 @@
{},
 };
 
+static void l2regs(void)
+{
+   pr_err("L2 Controller:\n");
+   pr_err("MCK:  0x%08x\n", mfl2(L2MCK));
+   pr_err("INT:  0x%08x\n", mfl2(L2INT));
+   pr_err("PLBSTAT0: 0x%08x\n", mfl2(L2PLBSTAT0));
+   pr_err("PLBSTAT1: 0x%08x\n", mfl2(L2PLBSTAT1));
+   pr_err("ARRSTAT0: 0x%08x\n", mfl2(L2ARRSTAT0));
+   pr_err("ARRSTAT1: 0x%08x\n", mfl2(L2ARRSTAT1));
+   pr_err("ARRSTAT2: 0x%08x\n", mfl2(L2ARRSTAT2));
+   pr_err("CPUSTAT:  0x%08x\n", mfl2(L2CPUSTAT));
+   pr_err("RACSTAT0: 0x%08x\n", mfl2(L2RACSTAT0));
+   pr_err("WACSTAT0: 0x%08x\n", mfl2(L2WACSTAT0));
+   pr_err("WACSTAT1: 0x%08x\n", mfl2(L2WACSTAT1));
+   pr_err("WACSTAT2: 0x%08x\n", mfl2(L2WACSTAT2));
+   pr_err("WDFSTAT:  0x%08x\n", mfl2(L2WDFSTAT));
+   pr_err("LOG0: 0x%08x\n", mfl2(L2LOG0));
+   pr_err("LOG1: 0x%08x\n", mfl2(L2LOG1));
+   pr_err("LOG2: 0x%08x\n", mfl2(L2LOG2));
+   pr_err("LOG3: 0x%08x\n", mfl2(L2LOG3));
+   pr_err("LOG4: 0x%08x\n", mfl2(L2LOG4));
+   pr_err("LOG5: 0x%08x\n", mfl2(L2LOG5));
+}
+
+static void show_plbopb_regs(u32 base, int num)
+{
+   pr_err("\nPLBOPB Bridge %d:\n", num);
+   pr_err("GESR0: 0x%08x\n", mfdcr(base + PLB4OPB_GESR0));
+   pr_err("GESR1: 0x%08x\n", mfdcr(base + PLB4OPB_GESR1));
+   pr_err("GESR2: 0x%08x\n", mfdcr(base + PLB4OPB_GESR2));
+   pr_err("GEARU: 0x%08x\n", mfdcr(base + PLB4OPB_GEARU));
+   pr_err("GEAR:  0x%08x\n", mfdcr(base + PLB4OPB_GEAR));
+}
+
+static irqreturn_t bus_err_handler(int irq, void *data)
+{
+   pr_err("Bus Error\n");
+
+   l2regs();
+
+   pr_err("\nPLB6 Controller:\n");
+   pr_err("BC_SHD: 0x%08x\n", mfdcr(DCRN_PLB6_SHD));
+   pr_err("BC_ERR: 0x%08x\n", mfdcr(DCRN_PLB6_ERR));
+
+   pr_err("\nPLB6-to-PLB4 Bridge:\n");
+   pr_err("ESR:  0x%08x\n", mfdcr(DCRN_PLB6PLB4_ESR));
+   pr_err("EARH: 0x%08x\n", mfdcr(DCRN_PLB6PLB4_EARH));
+   pr_err("EARL: 0x%08x\n", mfdcr(DCRN_PLB6PLB4_EARL));
+
+   pr_err("\nPLB4-to-PLB6 Bridge:\n");
+   pr_err("ESR:  0x%08x\n", mfdcr(DCRN_PLB4PLB6_ESR));
+   pr_err("EARH: 0x%08x\n", mfdcr(DCRN_PLB4PLB6_EARH));
+   pr_err("EARL: 0x%08x\n", mfdcr(DCRN_PLB4PLB6_EARL));
+
+   pr_err("\nPLB6-to-MCIF Bridge:\n");
+   pr_err("BESR0: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BESR0));
+   pr_err("BESR1: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BESR1));
+   pr_err("BEARH: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BEARH));
+   pr_err("BEARL: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BEARL));
+
+   pr_err("\nPLB4 Arbiter:\n");
+   pr_err("P0ESRH 0x%08x\n", mfdcr(DCRN_PLB4_P0ESRH));
+   pr_err("P0ESRL 0x%08x\n", mfdcr(DCRN_PLB4_P0ESRL));
+   pr_err("P0EARH 0x%08x\n", mfdcr(DCRN_PLB4_P0EARH));
+   pr_err("P0EARH 0x%08x\n", mfdcr(DCRN_PLB4_P0EARH));
+   pr_err("P1ESRH 0x%08x\n", mfdcr(DCRN_PLB4_P1ESRH));
+   pr_err("P1ESRL 0x%08x\n", mfdcr(DCRN_PLB4_P1ESRL));
+   pr_err("P1EARH 0x%08x\n", mfdcr(DCRN_PLB4_P1EARH));
+   pr_err("P1EARH 0x%08x\n", mfdcr(DCRN_PLB4_P1EARH));
+
+   show_plbopb_regs(DCRN_PLB4OPB0_BASE, 0);
+   show_plbopb_regs(DCRN_PLB4OPB1_BASE, 1);
+   show_plbopb_regs(DCRN_PLB4OPB2_BASE, 2);
+   show_plbopb_regs(DCRN_PLB4OPB3_BASE, 3);
+
+   pr_err("\nPLB4-to-AHB Bridge:\n");
+   pr_err("ESR:   0x%08x\n", mfdcr(DCRN_PLB4AHB_ESR));
+   pr_err("SEUAR: 0x%08x\n", mfdcr(DCRN_PLB4AHB_SEUAR));
+   pr_err("SELAR: 0x%08x\n", mfdcr(DCRN_PLB4AHB_SELAR));
+
+   pr_err("\nAHB-to-PLB4 Bridge:\n");
+   pr_err("\nESR: 0x%08x\n", mfdcr(DCRN_AHBPLB4_ESR));
+   pr_err("\nEAR: 0x%08x\n", mfdcr(DCRN_AHBPLB4_EAR));
+   panic("Bus Error\n");
+}
+
+static irqr

[PATCH v2 4/4] 44x/fsp2: add irq error handlers

2017-12-01 Thread Ivan Mikhaylov
add irq error handlers for cmu, plb, opb, mcue, conf
with debug information output in case of problems.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |  205 -
 1 files changed, 204 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 7c9bc93..04f0c73 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -28,8 +28,17 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "fsp2.h"
 
+#define FSP2_BUS_ERR   "ibm,bus-error-irq"
+#define FSP2_CMU_ERR   "ibm,cmu-error-irq"
+#define FSP2_CONF_ERR  "ibm,conf-error-irq"
+#define FSP2_OPBD_ERR  "ibm,opbd-error-irq"
+#define FSP2_MCUE  "ibm,mc-ue-irq"
+#define FSP2_RST_WRN   "ibm,reset-warning-irq"
+
 static __initdata struct of_device_id fsp2_of_bus[] = {
{ .compatible = "ibm,plb4", },
{ .compatible = "ibm,plb6", },
@@ -37,6 +46,194 @@
{},
 };
 
+static void l2regs(void)
+{
+   pr_err("L2 Controller:\n");
+   pr_err("MCK:  0x%08x\n", mfl2(L2MCK));
+   pr_err("INT:  0x%08x\n", mfl2(L2INT));
+   pr_err("PLBSTAT0: 0x%08x\n", mfl2(L2PLBSTAT0));
+   pr_err("PLBSTAT1: 0x%08x\n", mfl2(L2PLBSTAT1));
+   pr_err("ARRSTAT0: 0x%08x\n", mfl2(L2ARRSTAT0));
+   pr_err("ARRSTAT1: 0x%08x\n", mfl2(L2ARRSTAT1));
+   pr_err("ARRSTAT2: 0x%08x\n", mfl2(L2ARRSTAT2));
+   pr_err("CPUSTAT:  0x%08x\n", mfl2(L2CPUSTAT));
+   pr_err("RACSTAT0: 0x%08x\n", mfl2(L2RACSTAT0));
+   pr_err("WACSTAT0: 0x%08x\n", mfl2(L2WACSTAT0));
+   pr_err("WACSTAT1: 0x%08x\n", mfl2(L2WACSTAT1));
+   pr_err("WACSTAT2: 0x%08x\n", mfl2(L2WACSTAT2));
+   pr_err("WDFSTAT:  0x%08x\n", mfl2(L2WDFSTAT));
+   pr_err("LOG0: 0x%08x\n", mfl2(L2LOG0));
+   pr_err("LOG1: 0x%08x\n", mfl2(L2LOG1));
+   pr_err("LOG2: 0x%08x\n", mfl2(L2LOG2));
+   pr_err("LOG3: 0x%08x\n", mfl2(L2LOG3));
+   pr_err("LOG4: 0x%08x\n", mfl2(L2LOG4));
+   pr_err("LOG5: 0x%08x\n", mfl2(L2LOG5));
+}
+
+static void show_plbopb_regs(u32 base, int num)
+{
+   pr_err("\nPLBOPB Bridge %d:\n", num);
+   pr_err("GESR0: 0x%08x\n", mfdcr(base + PLB4OPB_GESR0));
+   pr_err("GESR1: 0x%08x\n", mfdcr(base + PLB4OPB_GESR1));
+   pr_err("GESR2: 0x%08x\n", mfdcr(base + PLB4OPB_GESR2));
+   pr_err("GEARU: 0x%08x\n", mfdcr(base + PLB4OPB_GEARU));
+   pr_err("GEAR:  0x%08x\n", mfdcr(base + PLB4OPB_GEAR));
+}
+
+static irqreturn_t bus_err_handler(int irq, void *data)
+{
+   pr_err("Bus Error\n");
+
+   l2regs();
+
+   pr_err("\nPLB6 Controller:\n");
+   pr_err("BC_SHD: 0x%08x\n", mfdcr(DCRN_PLB6_SHD));
+   pr_err("BC_ERR: 0x%08x\n", mfdcr(DCRN_PLB6_ERR));
+
+   pr_err("\nPLB6-to-PLB4 Bridge:\n");
+   pr_err("ESR:  0x%08x\n", mfdcr(DCRN_PLB6PLB4_ESR));
+   pr_err("EARH: 0x%08x\n", mfdcr(DCRN_PLB6PLB4_EARH));
+   pr_err("EARL: 0x%08x\n", mfdcr(DCRN_PLB6PLB4_EARL));
+
+   pr_err("\nPLB4-to-PLB6 Bridge:\n");
+   pr_err("ESR:  0x%08x\n", mfdcr(DCRN_PLB4PLB6_ESR));
+   pr_err("EARH: 0x%08x\n", mfdcr(DCRN_PLB4PLB6_EARH));
+   pr_err("EARL: 0x%08x\n", mfdcr(DCRN_PLB4PLB6_EARL));
+
+   pr_err("\nPLB6-to-MCIF Bridge:\n");
+   pr_err("BESR0: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BESR0));
+   pr_err("BESR1: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BESR1));
+   pr_err("BEARH: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BEARH));
+   pr_err("BEARL: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BEARL));
+
+   pr_err("\nPLB4 Arbiter:\n");
+   pr_err("P0ESRH 0x%08x\n", mfdcr(DCRN_PLB4_P0ESRH));
+   pr_err("P0ESRL 0x%08x\n", mfdcr(DCRN_PLB4_P0ESRL));
+   pr_err("P0EARH 0x%08x\n", mfdcr(DCRN_PLB4_P0EARH));
+   pr_err("P0EARH 0x%08x\n", mfdcr(DCRN_PLB4_P0EARH));
+   pr_err("P1ESRH 0x%08x\n", mfdcr(DCRN_PLB4_P1ESRH));
+   pr_err("P1ESRL 0x%08x\n", mfdcr(DCRN_PLB4_P1ESRL));
+   pr_err("P1EARH 0x%08x\n", mfdcr(DCRN_PLB4_P1EARH));
+   pr_err("P1EARH 0x%08x\n", mfdcr(DCRN_PLB4_P1EARH));
+
+   show_plbopb_regs(DCRN_PLB4OPB0_BASE, 0);
+   show_plbopb_regs(DCRN_PLB4OPB1_BASE, 1);
+   show_plbopb_regs(DCRN_PLB4OPB2_BASE, 2);
+   show_plbopb_regs(DCRN_PLB4OPB3_BASE, 3);
+
+   pr_err("\nPLB4-to-AHB Bridge:\n");
+   pr_err("ESR:   0x%08x\n&q

[PATCH v2 3/4] 44x/fsp2: tvsense workaround for dd1

2017-12-01 Thread Ivan Mikhaylov
TVSENSE(temperature and voltage sensors) reset is blocked (clock gated)
by the POR default of the TVS sleep config bit. As a consequence,
TVSENSE will provide erratic sensor values, which may result in
spurious (parity) errors recorded in the CMU FIR and leading to
erroneous interrupt requests once the CMU interrupt is unmasked.
Purpose of this to set up CMU in working state in any cases even
in case of parity errors.

Reviewed-by: Alistair Popple <alist...@popple.id.au>
Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index baed409..7c9bc93 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -59,6 +59,23 @@ static int __init fsp2_probe(void)
mtdcr(DCRN_PLB6_HD, 0x);
mtdcr(DCRN_PLB6_SHD, 0x);
 
+   /* TVSENSE reset is blocked (clock gated) by the POR default of the TVS
+* sleep config bit. As a consequence, TVSENSE will provide erratic
+* sensor values, which may result in spurious (parity) errors
+* recorded in the CMU FIR and leading to erroneous interrupt requests
+* once the CMU interrupt is unmasked.
+*/
+
+   /* 1. set TVS1[UNDOZE] */
+   val = mfcmu(CMUN_TVS1);
+   val |= 0x4;
+   mtcmu(CMUN_TVS1, val);
+
+   /* 2. clear FIR[TVS] and FIR[TVSPAR] */
+   val = mfcmu(CMUN_FIR0);
+   val |= 0x3000;
+   mtcmu(CMUN_FIR0, val);
+
/* L2 machine checks */
mtl2(L2PLBMCKEN0, 0x);
mtl2(L2PLBMCKEN1, 0x);
-- 
1.7.1



[PATCH v2 2/4] 44x/fsp2: interrupt handling setup

2017-12-01 Thread Ivan Mikhaylov
* clear out any possible plb6 errors
* board interrupt handling setup within l2 reg set
* fsp2 parity error setup

All those points are needed for correct interrupt
handling on board level including error handling report.

Reviewed-by: Alistair Popple <alist...@popple.id.au>
Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |   37 +
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 92e9804..baed409 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -27,6 +27,8 @@
 #include 
 #include 
 #include 
+#include 
+#include "fsp2.h"
 
 static __initdata struct of_device_id fsp2_of_bus[] = {
{ .compatible = "ibm,plb4", },
@@ -44,10 +46,45 @@ static int __init fsp2_device_probe(void)
 
 static int __init fsp2_probe(void)
 {
+   u32 val;
unsigned long root = of_get_flat_dt_root();
 
if (!of_flat_dt_is_compatible(root, "ibm,fsp2"))
return 0;
+
+   /* Clear BC_ERR and mask snoopable request plb errors. */
+   val = mfdcr(DCRN_PLB6_CR0);
+   val |= 0x2000;
+   mtdcr(DCRN_PLB6_BASE, val);
+   mtdcr(DCRN_PLB6_HD, 0x);
+   mtdcr(DCRN_PLB6_SHD, 0x);
+
+   /* L2 machine checks */
+   mtl2(L2PLBMCKEN0, 0x);
+   mtl2(L2PLBMCKEN1, 0x);
+   mtl2(L2ARRMCKEN0, 0x);
+   mtl2(L2ARRMCKEN1, 0x);
+   mtl2(L2ARRMCKEN2, 0xf000);
+   mtl2(L2CPUMCKEN,  0x);
+   mtl2(L2RACMCKEN0, 0x);
+   mtl2(L2WACMCKEN0, 0x);
+   mtl2(L2WACMCKEN1, 0x);
+   mtl2(L2WACMCKEN2, 0x);
+   mtl2(L2WDFMCKEN,  0x);
+
+   /* L2 interrupts */
+   mtl2(L2PLBINTEN1, 0x);
+
+   /*
+* At a global level, enable all L2 machine checks and interrupts
+* reported by the L2 subsystems, except for the external machine check
+* input (UIC0.1).
+*/
+   mtl2(L2MCKEN, 0x07ff);
+   mtl2(L2INTEN, 0x04ff);
+
+   /* Enable FSP-2 configuration logic parity errors */
+   mtdcr(DCRN_CONF_EIR_RS, 0x8000);
return 1;
 }
 
-- 
1.7.1



[PATCH v2 1/4] 44x/fsp2: add fsp2 headers

2017-12-01 Thread Ivan Mikhaylov
add cmu, plbX, l2, ddr3/4, crcs register definitions.
add mfcmu, mtcmu functions for indirect access to cmu.
add mtl2, mfl2 same for l2 cache core reg set.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.h |  272 +
 1 files changed, 272 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/44x/fsp2.h

diff --git a/arch/powerpc/platforms/44x/fsp2.h 
b/arch/powerpc/platforms/44x/fsp2.h
new file mode 100644
index 000..9e1d527
--- /dev/null
+++ b/arch/powerpc/platforms/44x/fsp2.h
@@ -0,0 +1,272 @@
+#ifndef _ASM_POWERPC_FSP_DCR_H_
+#define _ASM_POWERPC_FSP_DCR_H_
+#ifdef __KERNEL__
+#include 
+
+#define DCRN_CMU_ADDR  0x00C   /* Chip management unic addr */
+#define DCRN_CMU_DATA  0x00D   /* Chip management unic data */
+
+/* PLB4 Arbiter */
+#define DCRN_PLB4_PCBI 0x010   /* PLB Crossbar ID/Rev Register */
+#define DCRN_PLB4_P0ACR0x011   /* PLB0 Arbiter Control 
Register */
+#define DCRN_PLB4_P0ESRL   0x012   /* PLB0 Error Status Register Low */
+#define DCRN_PLB4_P0ESRH   0x013   /* PLB0 Error Status Register High */
+#define DCRN_PLB4_P0EARL   0x014   /* PLB0 Error Address Register Low */
+#define DCRN_PLB4_P0EARH   0x015   /* PLB0 Error Address Register High */
+#define DCRN_PLB4_P0ESRLS  0x016   /* PLB0 Error Status Register Low Set*/
+#define DCRN_PLB4_P0ESRHS  0x017   /* PLB0 Error Status Register High */
+#define DCRN_PLB4_PCBC 0x018   /* PLB Crossbar Control Register */
+#define DCRN_PLB4_P1ACR0x019   /* PLB1 Arbiter Control 
Register */
+#define DCRN_PLB4_P1ESRL   0x01A   /* PLB1 Error Status Register Low */
+#define DCRN_PLB4_P1ESRH   0x01B   /* PLB1 Error Status Register High */
+#define DCRN_PLB4_P1EARL   0x01C   /* PLB1 Error Address Register Low */
+#define DCRN_PLB4_P1EARH   0x01D   /* PLB1 Error Address Register High */
+#define DCRN_PLB4_P1ESRLS  0x01E   /* PLB1 Error Status Register Low Set*/
+#define DCRN_PLB4_P1ESRHS  0x01F   /*PLB1 Error Status Register High Set*/
+
+/* PLB4/OPB bridge 0, 1, 2, 3 */
+#define DCRN_PLB4OPB0_BASE 0x020
+#define DCRN_PLB4OPB1_BASE 0x030
+#define DCRN_PLB4OPB2_BASE 0x040
+#define DCRN_PLB4OPB3_BASE 0x050
+
+#define PLB4OPB_GESR0  0x0 /* Error status 0: Master Dev 0-3 */
+#define PLB4OPB_GEAR   0x2 /* Error Address Register */
+#define PLB4OPB_GEARU  0x3 /* Error Upper Address Register */
+#define PLB4OPB_GESR1  0x4 /* Error Status 1: Master Dev 4-7 */
+#define PLB4OPB_GESR2  0xC /* Error Status 2: Master Dev 8-11 */
+
+/* PLB4-to-AHB Bridge */
+#define DCRN_PLB4AHB_BASE  0x400
+#define DCRN_PLB4AHB_SEUAR (DCRN_PLB4AHB_BASE + 1)
+#define DCRN_PLB4AHB_SELAR (DCRN_PLB4AHB_BASE + 2)
+#define DCRN_PLB4AHB_ESR   (DCRN_PLB4AHB_BASE + 3)
+#define DCRN_AHBPLB4_ESR   (DCRN_PLB4AHB_BASE + 8)
+#define DCRN_AHBPLB4_EAR   (DCRN_PLB4AHB_BASE + 9)
+
+/* PLB6 Controller */
+#define DCRN_PLB6_BASE 0x1300
+#define DCRN_PLB6_CR0  (DCRN_PLB6_BASE)
+#define DCRN_PLB6_ERR  (DCRN_PLB6_BASE + 0x0B)
+#define DCRN_PLB6_HD   (DCRN_PLB6_BASE + 0x0E)
+#define DCRN_PLB6_SHD  (DCRN_PLB6_BASE + 0x10)
+
+/* PLB4-to-PLB6 Bridge */
+#define DCRN_PLB4PLB6_BASE 0x1320
+#define DCRN_PLB4PLB6_ESR  (DCRN_PLB4PLB6_BASE + 1)
+#define DCRN_PLB4PLB6_EARH (DCRN_PLB4PLB6_BASE + 3)
+#define DCRN_PLB4PLB6_EARL (DCRN_PLB4PLB6_BASE + 4)
+
+/* PLB6-to-PLB4 Bridge */
+#define DCRN_PLB6PLB4_BASE 0x1350
+#define DCRN_PLB6PLB4_ESR  (DCRN_PLB6PLB4_BASE + 1)
+#define DCRN_PLB6PLB4_EARH (DCRN_PLB6PLB4_BASE + 3)
+#define DCRN_PLB6PLB4_EARL (DCRN_PLB6PLB4_BASE + 4)
+
+/* PLB6-to-MCIF Bridge */
+#define DCRN_PLB6MCIF_BASE 0x1380
+#define DCRN_PLB6MCIF_BESR0(DCRN_PLB6MCIF_BASE + 0)
+#define DCRN_PLB6MCIF_BESR1(DCRN_PLB6MCIF_BASE + 1)
+#define DCRN_PLB6MCIF_BEARL(DCRN_PLB6MCIF_BASE + 2)
+#define DCRN_PLB6MCIF_BEARH(DCRN_PLB6MCIF_BASE + 3)
+
+/* Configuration Logic Registers */
+#define DCRN_CONF_BASE 0x1400
+#define DCRN_CONF_FIR_RWC  (DCRN_CONF_BASE + 0x3A)
+#define DCRN_CONF_EIR_RS   (DCRN_CONF_BASE + 0x3E)
+#define DCRN_CONF_RPERR0   (DCRN_CONF_BASE + 0x4D)
+#define DCRN_CONF_RPERR1   (DCRN_CONF_BASE + 0x4E)
+
+#define DCRN_L2CDCRAI  0x1100
+#define DCRN_L2CDCRDI  0x1104
+/* L2 indirect addresses */
+#define L2MCK  0x120
+#define L2MCKEN0x130
+#define L2INT  0x150
+#define L2INTEN0x160
+#define L2LOG0 0x180
+#define L2LOG1 0x184
+#define L2LOG2 0x188
+#define L2LOG3 0x18C
+#define L2LOG4 0x190
+#define L2LOG5 0x194
+#define L2PLBSTAT0 0x300
+#define L2PLBSTAT1 0x304
+#define L2PLBMCKEN00x330
+#define L2PLBMCKEN10x334
+#define L2PLBINTEN0   

[PATCH 4/4] 44x/fsp2: add irq error handlers

2017-11-02 Thread Ivan Mikhaylov
* add irq error handlers for cmu, plb, opb, mcue, conf
  with debug information output in case of problem.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |  204 -
 1 files changed, 203 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 4e12490..2bbf9ea 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -29,6 +29,15 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+
+#define FSP2_BUS_ERR   "ibm,bus-error-irq"
+#define FSP2_CMU_ERR   "ibm,cmu-error-irq"
+#define FSP2_CONF_ERR  "ibm,conf-error-irq"
+#define FSP2_OPBD_ERR  "ibm,opbd-error-irq"
+#define FSP2_MCUE  "ibm,mc-ue-irq"
+#define FSP2_RST_WRN   "ibm,reset-warning-irq"
 
 static __initdata struct of_device_id fsp2_of_bus[] = {
{ .compatible = "ibm,plb4", },
@@ -37,6 +46,193 @@
{},
 };
 
+static void l2regs(void)
+{
+   pr_err("L2 Controller:\n");
+   pr_err("MCK:  0x%08x\n", mfl2(L2MCK));
+   pr_err("INT:  0x%08x\n", mfl2(L2INT));
+   pr_err("PLBSTAT0: 0x%08x\n", mfl2(L2PLBSTAT0));
+   pr_err("PLBSTAT1: 0x%08x\n", mfl2(L2PLBSTAT1));
+   pr_err("ARRSTAT0: 0x%08x\n", mfl2(L2ARRSTAT0));
+   pr_err("ARRSTAT1: 0x%08x\n", mfl2(L2ARRSTAT1));
+   pr_err("ARRSTAT2: 0x%08x\n", mfl2(L2ARRSTAT2));
+   pr_err("CPUSTAT:  0x%08x\n", mfl2(L2CPUSTAT));
+   pr_err("RACSTAT0: 0x%08x\n", mfl2(L2RACSTAT0));
+   pr_err("WACSTAT0: 0x%08x\n", mfl2(L2WACSTAT0));
+   pr_err("WACSTAT1: 0x%08x\n", mfl2(L2WACSTAT1));
+   pr_err("WACSTAT2: 0x%08x\n", mfl2(L2WACSTAT2));
+   pr_err("WDFSTAT:  0x%08x\n", mfl2(L2WDFSTAT));
+   pr_err("LOG0: 0x%08x\n", mfl2(L2LOG0));
+   pr_err("LOG1: 0x%08x\n", mfl2(L2LOG1));
+   pr_err("LOG2: 0x%08x\n", mfl2(L2LOG2));
+   pr_err("LOG3: 0x%08x\n", mfl2(L2LOG3));
+   pr_err("LOG4: 0x%08x\n", mfl2(L2LOG4));
+   pr_err("LOG5: 0x%08x\n", mfl2(L2LOG5));
+}
+
+static void show_plbopb_regs(u32 base, int num)
+{
+   pr_err("\nPLBOPB Bridge %d:\n", num);
+   pr_err("GESR0: 0x%08x\n", mfdcr(base + PLB4OPB_GESR0));
+   pr_err("GESR1: 0x%08x\n", mfdcr(base + PLB4OPB_GESR1));
+   pr_err("GESR2: 0x%08x\n", mfdcr(base + PLB4OPB_GESR2));
+   pr_err("GEARU: 0x%08x\n", mfdcr(base + PLB4OPB_GEARU));
+   pr_err("GEAR:  0x%08x\n", mfdcr(base + PLB4OPB_GEAR));
+}
+
+static irqreturn_t error_irq_handler(int irq, void *data)
+{
+   u32 crcs;
+   struct device_node *np = data;
+
+   if (of_device_is_compatible(np, FSP2_BUS_ERR)) {
+   pr_err("Bus Error\n");
+
+   l2regs();
+
+   pr_err("\nPLB6 Controller:\n");
+   pr_err("BC_SHD: 0x%08x\n", mfdcr(DCRN_PLB6_SHD));
+   pr_err("BC_ERR: 0x%08x\n", mfdcr(DCRN_PLB6_ERR));
+
+   pr_err("\nPLB6-to-PLB4 Bridge:\n");
+   pr_err("ESR:  0x%08x\n", mfdcr(DCRN_PLB6PLB4_ESR));
+   pr_err("EARH: 0x%08x\n", mfdcr(DCRN_PLB6PLB4_EARH));
+   pr_err("EARL: 0x%08x\n", mfdcr(DCRN_PLB6PLB4_EARL));
+
+   pr_err("\nPLB4-to-PLB6 Bridge:\n");
+   pr_err("ESR:  0x%08x\n", mfdcr(DCRN_PLB4PLB6_ESR));
+   pr_err("EARH: 0x%08x\n", mfdcr(DCRN_PLB4PLB6_EARH));
+   pr_err("EARL: 0x%08x\n", mfdcr(DCRN_PLB4PLB6_EARL));
+
+   pr_err("\nPLB6-to-MCIF Bridge:\n");
+   pr_err("BESR0: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BESR0));
+   pr_err("BESR1: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BESR1));
+   pr_err("BEARH: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BEARH));
+   pr_err("BEARL: 0x%08x\n", mfdcr(DCRN_PLB6MCIF_BEARL));
+
+   pr_err("\nPLB4 Arbiter:\n");
+   pr_err("P0ESRH 0x%08x\n", mfdcr(DCRN_PLB4_P0ESRH));
+   pr_err("P0ESRL 0x%08x\n", mfdcr(DCRN_PLB4_P0ESRL));
+   pr_err("P0EARH 0x%08x\n", mfdcr(DCRN_PLB4_P0EARH));
+   pr_err("P0EARH 0x%08x\n", mfdcr(DCRN_PLB4_P0EARH));
+   pr_err("P1ESRH 0x%08x\n", mfdcr(DCRN_PLB4_P1ESRH));
+   pr_err("P1ESRL 0x%08x\n", mfdcr(DCRN_PLB4_P1ESRL));
+   pr_err("P1EARH 0x%08x\n", mfdcr(DCRN_PLB4_P1EARH));
+   pr_err("P1EARH 0x%08x\n", mfdcr(DCRN_PLB4_P1EARH));
+
+   show_plbopb_regs(DCR

[PATCH 3/4] 44x/fsp2: tvsense workaround for dd1

2017-11-02 Thread Ivan Mikhaylov
* tvsense(temperature and voltage sensors) may provide
  erratic sense values which may result in parity errors
  on CMU.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 9585725..4e12490 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -59,6 +59,23 @@ static int __init fsp2_probe(void)
mtdcr(DCRN_PLB6_HD, 0x);
mtdcr(DCRN_PLB6_SHD, 0x);
 
+   /* TVSENSE reset is blocked (clock gated) by the POR default of the TVS
+* sleep config bit. As a consequence, TVSENSE will provide erratic
+* sensor values, which may result in spurious (parity) errors
+* recorded in the CMU FIR and leading to erroneous interrupt requests
+* once the CMU interrupt is unmasked.
+*/
+
+   /* 1. set TVS1[UNDOZE] */
+   val = mfcmu(CMUN_TVS1);
+   val |= 0x4;
+   mtcmu(CMUN_TVS1, val);
+
+   /* 2. clear FIR[TVS] and FIR[TVSPAR] */
+   val = mfcmu(CMUN_FIR0);
+   val |= 0x3000;
+   mtcmu(CMUN_FIR0, val);
+
/* L2 machine checks */
mtl2(L2PLBMCKEN0, 0x);
mtl2(L2PLBMCKEN1, 0x);
-- 
1.7.1



[PATCH 2/4] 44x/fsp2: l2 setup with error clear

2017-11-02 Thread Ivan Mikhaylov
Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/fsp2.c |   37 +
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 92e9804..9585725 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -27,6 +27,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 static __initdata struct of_device_id fsp2_of_bus[] = {
{ .compatible = "ibm,plb4", },
@@ -44,10 +46,45 @@ static int __init fsp2_device_probe(void)
 
 static int __init fsp2_probe(void)
 {
+   u32 val;
unsigned long root = of_get_flat_dt_root();
 
if (!of_flat_dt_is_compatible(root, "ibm,fsp2"))
return 0;
+
+   /* Clear BC_ERR and mask snoopable request plb errors. */
+   val = mfdcr(DCRN_PLB6_CR0);
+   val |= 0x2000;
+   mtdcr(DCRN_PLB6_BASE, val);
+   mtdcr(DCRN_PLB6_HD, 0x);
+   mtdcr(DCRN_PLB6_SHD, 0x);
+
+   /* L2 machine checks */
+   mtl2(L2PLBMCKEN0, 0x);
+   mtl2(L2PLBMCKEN1, 0x);
+   mtl2(L2ARRMCKEN0, 0x);
+   mtl2(L2ARRMCKEN1, 0x);
+   mtl2(L2ARRMCKEN2, 0xf000);
+   mtl2(L2CPUMCKEN,  0x);
+   mtl2(L2RACMCKEN0, 0x);
+   mtl2(L2WACMCKEN0, 0x);
+   mtl2(L2WACMCKEN1, 0x);
+   mtl2(L2WACMCKEN2, 0x);
+   mtl2(L2WDFMCKEN,  0x);
+
+   /* L2 interrupts */
+   mtl2(L2PLBINTEN1, 0x);
+
+   /*
+* At a global level, enable all L2 machine checks and interrupts
+* reported by the L2 subsystems, except for the external machine check
+* input (UIC0.1).
+*/
+   mtl2(L2MCKEN, 0x07ff);
+   mtl2(L2INTEN, 0x04ff);
+
+   /* Enable FSP-2 configuration logic parity errors */
+   mtdcr(DCRN_CONF_EIR_RS, 0x8000);
return 1;
 }
 
-- 
1.7.1



[PATCH 1/4] 44x/fsp2: add fsp2 headers

2017-11-02 Thread Ivan Mikhaylov
* add cmu, plbX, l2 register definitions

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/include/asm/fsp2_reg.h |  272 +++
 1 files changed, 272 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/include/asm/fsp2_reg.h

diff --git a/arch/powerpc/include/asm/fsp2_reg.h 
b/arch/powerpc/include/asm/fsp2_reg.h
new file mode 100644
index 000..9e1d527
--- /dev/null
+++ b/arch/powerpc/include/asm/fsp2_reg.h
@@ -0,0 +1,272 @@
+#ifndef _ASM_POWERPC_FSP_DCR_H_
+#define _ASM_POWERPC_FSP_DCR_H_
+#ifdef __KERNEL__
+#include 
+
+#define DCRN_CMU_ADDR  0x00C   /* Chip management unic addr */
+#define DCRN_CMU_DATA  0x00D   /* Chip management unic data */
+
+/* PLB4 Arbiter */
+#define DCRN_PLB4_PCBI 0x010   /* PLB Crossbar ID/Rev Register */
+#define DCRN_PLB4_P0ACR0x011   /* PLB0 Arbiter Control 
Register */
+#define DCRN_PLB4_P0ESRL   0x012   /* PLB0 Error Status Register Low */
+#define DCRN_PLB4_P0ESRH   0x013   /* PLB0 Error Status Register High */
+#define DCRN_PLB4_P0EARL   0x014   /* PLB0 Error Address Register Low */
+#define DCRN_PLB4_P0EARH   0x015   /* PLB0 Error Address Register High */
+#define DCRN_PLB4_P0ESRLS  0x016   /* PLB0 Error Status Register Low Set*/
+#define DCRN_PLB4_P0ESRHS  0x017   /* PLB0 Error Status Register High */
+#define DCRN_PLB4_PCBC 0x018   /* PLB Crossbar Control Register */
+#define DCRN_PLB4_P1ACR0x019   /* PLB1 Arbiter Control 
Register */
+#define DCRN_PLB4_P1ESRL   0x01A   /* PLB1 Error Status Register Low */
+#define DCRN_PLB4_P1ESRH   0x01B   /* PLB1 Error Status Register High */
+#define DCRN_PLB4_P1EARL   0x01C   /* PLB1 Error Address Register Low */
+#define DCRN_PLB4_P1EARH   0x01D   /* PLB1 Error Address Register High */
+#define DCRN_PLB4_P1ESRLS  0x01E   /* PLB1 Error Status Register Low Set*/
+#define DCRN_PLB4_P1ESRHS  0x01F   /*PLB1 Error Status Register High Set*/
+
+/* PLB4/OPB bridge 0, 1, 2, 3 */
+#define DCRN_PLB4OPB0_BASE 0x020
+#define DCRN_PLB4OPB1_BASE 0x030
+#define DCRN_PLB4OPB2_BASE 0x040
+#define DCRN_PLB4OPB3_BASE 0x050
+
+#define PLB4OPB_GESR0  0x0 /* Error status 0: Master Dev 0-3 */
+#define PLB4OPB_GEAR   0x2 /* Error Address Register */
+#define PLB4OPB_GEARU  0x3 /* Error Upper Address Register */
+#define PLB4OPB_GESR1  0x4 /* Error Status 1: Master Dev 4-7 */
+#define PLB4OPB_GESR2  0xC /* Error Status 2: Master Dev 8-11 */
+
+/* PLB4-to-AHB Bridge */
+#define DCRN_PLB4AHB_BASE  0x400
+#define DCRN_PLB4AHB_SEUAR (DCRN_PLB4AHB_BASE + 1)
+#define DCRN_PLB4AHB_SELAR (DCRN_PLB4AHB_BASE + 2)
+#define DCRN_PLB4AHB_ESR   (DCRN_PLB4AHB_BASE + 3)
+#define DCRN_AHBPLB4_ESR   (DCRN_PLB4AHB_BASE + 8)
+#define DCRN_AHBPLB4_EAR   (DCRN_PLB4AHB_BASE + 9)
+
+/* PLB6 Controller */
+#define DCRN_PLB6_BASE 0x1300
+#define DCRN_PLB6_CR0  (DCRN_PLB6_BASE)
+#define DCRN_PLB6_ERR  (DCRN_PLB6_BASE + 0x0B)
+#define DCRN_PLB6_HD   (DCRN_PLB6_BASE + 0x0E)
+#define DCRN_PLB6_SHD  (DCRN_PLB6_BASE + 0x10)
+
+/* PLB4-to-PLB6 Bridge */
+#define DCRN_PLB4PLB6_BASE 0x1320
+#define DCRN_PLB4PLB6_ESR  (DCRN_PLB4PLB6_BASE + 1)
+#define DCRN_PLB4PLB6_EARH (DCRN_PLB4PLB6_BASE + 3)
+#define DCRN_PLB4PLB6_EARL (DCRN_PLB4PLB6_BASE + 4)
+
+/* PLB6-to-PLB4 Bridge */
+#define DCRN_PLB6PLB4_BASE 0x1350
+#define DCRN_PLB6PLB4_ESR  (DCRN_PLB6PLB4_BASE + 1)
+#define DCRN_PLB6PLB4_EARH (DCRN_PLB6PLB4_BASE + 3)
+#define DCRN_PLB6PLB4_EARL (DCRN_PLB6PLB4_BASE + 4)
+
+/* PLB6-to-MCIF Bridge */
+#define DCRN_PLB6MCIF_BASE 0x1380
+#define DCRN_PLB6MCIF_BESR0(DCRN_PLB6MCIF_BASE + 0)
+#define DCRN_PLB6MCIF_BESR1(DCRN_PLB6MCIF_BASE + 1)
+#define DCRN_PLB6MCIF_BEARL(DCRN_PLB6MCIF_BASE + 2)
+#define DCRN_PLB6MCIF_BEARH(DCRN_PLB6MCIF_BASE + 3)
+
+/* Configuration Logic Registers */
+#define DCRN_CONF_BASE 0x1400
+#define DCRN_CONF_FIR_RWC  (DCRN_CONF_BASE + 0x3A)
+#define DCRN_CONF_EIR_RS   (DCRN_CONF_BASE + 0x3E)
+#define DCRN_CONF_RPERR0   (DCRN_CONF_BASE + 0x4D)
+#define DCRN_CONF_RPERR1   (DCRN_CONF_BASE + 0x4E)
+
+#define DCRN_L2CDCRAI  0x1100
+#define DCRN_L2CDCRDI  0x1104
+/* L2 indirect addresses */
+#define L2MCK  0x120
+#define L2MCKEN0x130
+#define L2INT  0x150
+#define L2INTEN0x160
+#define L2LOG0 0x180
+#define L2LOG1 0x184
+#define L2LOG2 0x188
+#define L2LOG3 0x18C
+#define L2LOG4 0x190
+#define L2LOG5 0x194
+#define L2PLBSTAT0 0x300
+#define L2PLBSTAT1 0x304
+#define L2PLBMCKEN00x330
+#define L2PLBMCKEN10x334
+#define L2PLBINTEN00x360
+#define L2PLBINTEN10x364
+#define L2ARRSTAT0 0x500
+#define L2ARRSTAT1 0x504
+#define L2AR

[PATCH 0/4] fsp2 low level setup

2017-11-02 Thread Ivan Mikhaylov
fsp2 board setup with l2 setup and irq handlers
for some critical exceptions.


Ivan Mikhaylov (4):
  44x/fsp2: add fsp2 headers
  44x/fsp2: l2 setup with error clear
  44x/fsp2: tvsense workaround for dd1
  44x/fsp2: add irq error handlers

 arch/powerpc/include/asm/fsp2_reg.h |  272 +++
 arch/powerpc/platforms/44x/fsp2.c   |  254 +-
 2 files changed, 529 insertions(+), 1 deletions(-)
 create mode 100644 arch/powerpc/include/asm/fsp2_reg.h



[PATCH v2 2/2] 44x/fsp2: enable eMMC arasan for fsp2 platform

2017-07-25 Thread Ivan Mikhaylov
Add mmc0 changes for enabling arasan emmc and change
defconfig appropriately.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/boot/dts/fsp2.dts  |   33 +-
 arch/powerpc/configs/44x/fsp2_defconfig |2 +
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsp2.dts b/arch/powerpc/boot/dts/fsp2.dts
index 475953a..6a63026 100644
--- a/arch/powerpc/boot/dts/fsp2.dts
+++ b/arch/powerpc/boot/dts/fsp2.dts
@@ -52,6 +52,7 @@
clocks {
mmc_clk: mmc_clk {
compatible = "fixed-clock";
+   #clock-cells = <0>;
clock-frequency = <5000>;
clock-output-names = "mmc_clk";
};
@@ -359,20 +360,6 @@
interrupts = <31 0x4 15 0x84>;
};
 
-   mmc0: sdhci@020c {
-   compatible  = "st,sdhci-stih407", "st,sdhci";
-   status  = "disabled";
-   reg = <0x020c 0x2>;
-   reg-names   = "mmc";
-   interrupt-parent = <_3>;
-   interrupts  = <21 0x4 22 0x4>;
-   interrupt-names = "mmcirq";
-   pinctrl-names   = "default";
-   pinctrl-0   = <>;
-   clock-names = "mmc";
-   clocks  = <_clk>;
-   };
-
plb6 {
compatible = "ibm,plb6";
#address-cells = <2>;
@@ -501,6 +488,24 @@
 /*RXDE*/  4 _2 13 0x4>;
};
 
+   mmc0: mmc@20c {
+   compatible  = "st,sdhci-stih407", "st,sdhci";
+   reg = <0x020c 0x2>;
+   reg-names   = "mmc";
+   interrupts  = <21 0x4>;
+   interrupt-parent = <_3>;
+   interrupt-names = "mmcirq";
+   pinctrl-names   = "default";
+   pinctrl-0   = <>;
+   clock-names = "mmc";
+   clocks  = <_clk>;
+   bus-width   = <4>;
+   non-removable;
+   sd-uhs-sdr50;
+   sd-uhs-sdr104;
+   sd-uhs-ddr50;
+   };
+
opb {
compatible = "ibm,opb";
#address-cells = <1>;
diff --git a/arch/powerpc/configs/44x/fsp2_defconfig 
b/arch/powerpc/configs/44x/fsp2_defconfig
index e8e6a69..935aabe 100644
--- a/arch/powerpc/configs/44x/fsp2_defconfig
+++ b/arch/powerpc/configs/44x/fsp2_defconfig
@@ -92,8 +92,10 @@ CONFIG_MMC_DEBUG=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_OF_ARASAN=y
+CONFIG_MMC_SDHCI_ST=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_M41T80=y
+CONFIG_RESET_CONTROLLER=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT4_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
-- 
1.7.1



Re: [PATCH] powerpc/44x/fsp2: correct dtb reg property for /sdhci@020c0000

2017-07-21 Thread Ivan Mikhaylov
Hi Ian,
>Building the split device-tree tree[0] highlighted that upstream commit
>9eec6cb142bd ("powerpc/44x/fsp2: Add device tree for FSP2 board") introduced
>this warning when building the device tree:
>
>$ make CROSS_COMPILE=powerpc-linux-gnu- ARCH=powerpc fsp2.dtb
>  CHK scripts/mod/devicetable-offsets.h
>  DTC arch/powerpc/boot/fsp2.dtb
>arch/powerpc/boot/fsp2.dtb: Warning (reg_format): "reg" property in 
>/sdhci@020c has invalid length (8 bytes) (#address-cells == 2, #size-cells 
>== 1)
>
>This commit adds the second adress cell as zeroes to resolve the warning. Note:
>I have no access to or information about this platform so this is purely a
>guess as to the fix. An alternative would be to adjust #address-cells, but
>whether that is correct or not depends on the platform.

Yes, this problem exists on this tag but it is already fixed and waiting for
review by this https://patchwork.kernel.org/patch/9819379/ . You can check it
if you want, anyways it will go to powerpc next branch first.

Thank you.



[PATCH v1 2/2] 44x/fsp2: enable eMMC arasan for fsp2 platform

2017-06-30 Thread Ivan Mikhaylov
Add mmc0 changes for enabling arasan emmc and change
defconfig appropriately.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/boot/dts/fsp2.dts  |   33 +-
 arch/powerpc/configs/44x/fsp2_defconfig |2 +
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsp2.dts b/arch/powerpc/boot/dts/fsp2.dts
index 475953a..6a63026 100644
--- a/arch/powerpc/boot/dts/fsp2.dts
+++ b/arch/powerpc/boot/dts/fsp2.dts
@@ -52,6 +52,7 @@
clocks {
mmc_clk: mmc_clk {
compatible = "fixed-clock";
+   #clock-cells = <0>;
clock-frequency = <5000>;
clock-output-names = "mmc_clk";
};
@@ -359,20 +360,6 @@
interrupts = <31 0x4 15 0x84>;
};
 
-   mmc0: sdhci@020c {
-   compatible  = "st,sdhci-stih407", "st,sdhci";
-   status  = "disabled";
-   reg = <0x020c 0x2>;
-   reg-names   = "mmc";
-   interrupt-parent = <_3>;
-   interrupts  = <21 0x4 22 0x4>;
-   interrupt-names = "mmcirq";
-   pinctrl-names   = "default";
-   pinctrl-0   = <>;
-   clock-names = "mmc";
-   clocks  = <_clk>;
-   };
-
plb6 {
compatible = "ibm,plb6";
#address-cells = <2>;
@@ -501,6 +488,24 @@
 /*RXDE*/  4 _2 13 0x4>;
};
 
+   mmc0: sdhci@020c {
+   compatible  = "st,sdhci-stih407", "st,sdhci";
+   reg = <0x020c 0x2>;
+   reg-names   = "mmc";
+   interrupts  = <21 0x4>;
+   interrupt-parent = <_3>;
+   interrupt-names = "mmcirq";
+   pinctrl-names   = "default";
+   pinctrl-0   = <>;
+   clock-names = "mmc";
+   clocks  = <_clk>;
+   bus-width   = <4>;
+   non-removable;
+   sd-uhs-sdr50;
+   sd-uhs-sdr104;
+   sd-uhs-ddr50;
+   };
+
opb {
compatible = "ibm,opb";
#address-cells = <1>;
diff --git a/arch/powerpc/configs/44x/fsp2_defconfig 
b/arch/powerpc/configs/44x/fsp2_defconfig
index e8e6a69..935aabe 100644
--- a/arch/powerpc/configs/44x/fsp2_defconfig
+++ b/arch/powerpc/configs/44x/fsp2_defconfig
@@ -92,8 +92,10 @@ CONFIG_MMC_DEBUG=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_OF_ARASAN=y
+CONFIG_MMC_SDHCI_ST=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_M41T80=y
+CONFIG_RESET_CONTROLLER=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT4_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
-- 
1.7.1



[PATCH v1 0/2] add eMMC support for fsp2 board

2017-06-30 Thread Ivan Mikhaylov
fsp2 based on powerpc 476fpe using eMMC arasan, so we added support
of this inside our dts and also enabled via additional
dependence for sdhci-st driver in Kconfig.

this code depends on commit c4b56b023daa91953e9ebe91143e6ca156f0bcb7
which is located in powerpc linux tree in 'next' branch.

Ivan Mikhaylov (2):
  mmc/host: add FSP2(ppc476fpe) into depends for sdhci-st
  44x/fsp2: enable eMMC arasan for fsp2 platform

 arch/powerpc/boot/dts/fsp2.dts  |   33 +-
 arch/powerpc/configs/44x/fsp2_defconfig |2 ++
 drivers/mmc/host/Kconfig|2 +-
 3 files changed, 22 insertions(+), 15 deletions(-)



[PATCH v1 1/2] mmc/host: add FSP2(ppc476fpe) into depends for sdhci-st

2017-06-30 Thread Ivan Mikhaylov
shdci-st driver can be used for ppc476 fsp2 soc.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 drivers/mmc/host/Kconfig |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 2eb9701..edf5787 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -354,7 +354,7 @@ config MMC_MOXART
 
 config MMC_SDHCI_ST
tristate "SDHCI support on STMicroelectronics SoC"
-   depends on ARCH_STI
+   depends on ARCH_STI || FSP2
depends on MMC_SDHCI_PLTFM
select MMC_SDHCI_IO_ACCESSORS
help
-- 
1.7.1



[PATCH 1/2] mmc/host: add FSP2(ppc476fpe) into depends for sdhci-st

2017-06-23 Thread Ivan Mikhaylov
* shdci-st driver can be used for ppc476 fsp2 soc

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 drivers/mmc/host/Kconfig |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 2eb9701..e6c0d86 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -354,8 +354,8 @@ config MMC_MOXART
 
 config MMC_SDHCI_ST
tristate "SDHCI support on STMicroelectronics SoC"
-   depends on ARCH_STI
depends on MMC_SDHCI_PLTFM
+   depends on ARCH_STI || FSP2
select MMC_SDHCI_IO_ACCESSORS
help
  This selects the Secure Digital Host Controller Interface in
-- 
1.7.1



[PATCH 2/2] 44x/fsp2: enable eMMC arasan for fsp2 platform

2017-06-23 Thread Ivan Mikhaylov
* add mmc0 section into dts for arasan
* change defconfig appropriately

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/boot/dts/fsp2.dts  |   19 +++
 arch/powerpc/configs/44x/fsp2_defconfig |2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsp2.dts b/arch/powerpc/boot/dts/fsp2.dts
index de9d606..6a63026 100644
--- a/arch/powerpc/boot/dts/fsp2.dts
+++ b/arch/powerpc/boot/dts/fsp2.dts
@@ -52,6 +52,7 @@
clocks {
mmc_clk: mmc_clk {
compatible = "fixed-clock";
+   #clock-cells = <0>;
clock-frequency = <5000>;
clock-output-names = "mmc_clk";
};
@@ -487,6 +488,24 @@
 /*RXDE*/  4 _2 13 0x4>;
};
 
+   mmc0: sdhci@020c {
+   compatible  = "st,sdhci-stih407", "st,sdhci";
+   reg = <0x020c 0x2>;
+   reg-names   = "mmc";
+   interrupts  = <21 0x4>;
+   interrupt-parent = <_3>;
+   interrupt-names = "mmcirq";
+   pinctrl-names   = "default";
+   pinctrl-0   = <>;
+   clock-names = "mmc";
+   clocks  = <_clk>;
+   bus-width   = <4>;
+   non-removable;
+   sd-uhs-sdr50;
+   sd-uhs-sdr104;
+   sd-uhs-ddr50;
+   };
+
opb {
compatible = "ibm,opb";
#address-cells = <1>;
diff --git a/arch/powerpc/configs/44x/fsp2_defconfig 
b/arch/powerpc/configs/44x/fsp2_defconfig
index e8e6a69..935aabe 100644
--- a/arch/powerpc/configs/44x/fsp2_defconfig
+++ b/arch/powerpc/configs/44x/fsp2_defconfig
@@ -92,8 +92,10 @@ CONFIG_MMC_DEBUG=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SDHCI_OF_ARASAN=y
+CONFIG_MMC_SDHCI_ST=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_M41T80=y
+CONFIG_RESET_CONTROLLER=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT4_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
-- 
1.7.1



[PATCH 0/2] add eMMC support for fsp2 board

2017-06-23 Thread Ivan Mikhaylov
fsp2 based on powerpc 476fpe using eMMC arasan, so we added support
of this inside our dts and also enabled via additional
dependence for sdhci-st driver in Kconfig.

this code depends on commit c4b56b023daa91953e9ebe91143e6ca156f0bcb7
which is located in powerpc linux tree in 'next' branch.

Ivan Mikhaylov (2):
  mmc/host: add FSP2(ppc476fpe) into depends for sdhci-st
  44x/fsp2: enable eMMC arasan for fsp2 platform

 arch/powerpc/boot/dts/fsp2.dts  |   19 +++
 arch/powerpc/configs/44x/fsp2_defconfig |2 ++
 drivers/mmc/host/Kconfig|2 +-
 3 files changed, 22 insertions(+), 1 deletions(-)



Re: [PATCH 4/4] arch/powerpc/44x/fsp2: wdt tcr update instead of whole rewrite

2017-05-19 Thread Ivan Mikhaylov
Hi Michael,

>> diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
>> index 2b33cfa..f75e512 100644
>> --- a/arch/powerpc/kernel/time.c
>> +++ b/arch/powerpc/kernel/time.c
>> @@ -738,12 +738,28 @@ static int __init get_freq(char *name, int cells, 
>> unsigned long *val)
>>  
>>  static void start_cpu_decrementer(void)
>>  {
>> +unsigned int tcr;
>>  #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
>>  /* Clear any pending timer interrupts */
>>  mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
>>  
>> +#ifdef CONFIG_FSP2
>> +/*
>> + * Prevent a kernel panic caused by unintentionally clearing TCR
>> + * watchdog bits.  At this point in the kernel boot, the watchdog has
>> + * already been enabled by u-boot.  The original code's attempt to
>
> Don't refer to "the original code", as it doesn't exist anymore now that
> we've patched it. Just say something like ".. so we must not clear the
> watchdog configuration bits".
Ok, got it.

>That breaks the build for other platforms:
>
> arch/powerpc/kernel/time.c: In function ‘start_cpu_decrementer’:
> arch/powerpc/kernel/time.c:741:15: error: unused variable ‘tcr’ 
> [-Werror=unused-variable]
>
Oops, didn't notice, my fault. 

>Or you could possibly just always leave TCR[WP], is there any case where
>it would be correct to clear that?
>
>cheers

>From my point of view it's possible. I've checked docu and on idea
it should be possible cause WP is only affecting watchdog ping time.
Which in case of '00' is very small, around ~5 ms. 
Ben also in next message said about get rid of ifdef for FSP2.

And now patch looks like this, What do you think Michael, Ben?

 arch/powerpc/kernel/time.c |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index bc2e08d..2411c49 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -718,11 +718,22 @@ static int __init get_freq(char *name, int cells, 
unsigned long *val)
 static void start_cpu_decrementer(void)
 {
 #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
+   unsigned int tcr;
/* Clear any pending timer interrupts */
mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
 
-   /* Enable decrementer interrupt */
-   mtspr(SPRN_TCR, TCR_DIE);
+   tcr = mfspr(SPRN_TCR);
+   /*
+* At this point in the kernel boot, the watchdog has already
+* been enabled by u-boot. If we set it this to '00' it may
+* trigger watchdog earlier than needed which will cause
+* inattentional kernel panic. In this case we leaving TCR[WP]
+* bit setting from uboot/bootstrap.
+*/
+   tcr &= TCR_WP_MASK; /* clear all bits except for TCR[WP] */
+   tcr |= TCR_DIE; /* enable decrementer */
+   mtspr(SPRN_TCR, tcr);
+
 #endif /* defined(CONFIG_BOOKE) || defined(CONFIG_40x) */
 }
 
-- 
1.7.1



[PATCH 3/4] arch/powerpc/44x/fsp2: add defconfig for fsp2 board

2017-05-15 Thread Ivan Mikhaylov
this patch adds default fsp2 config for main usage.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/configs/44x/fsp2_defconfig |  126 +++
 1 files changed, 126 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/configs/44x/fsp2_defconfig

diff --git a/arch/powerpc/configs/44x/fsp2_defconfig 
b/arch/powerpc/configs/44x/fsp2_defconfig
new file mode 100644
index 000..e8e6a69
--- /dev/null
+++ b/arch/powerpc/configs/44x/fsp2_defconfig
@@ -0,0 +1,126 @@
+CONFIG_44x=y
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+# CONFIG_FHANDLE is not set
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=16
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+CONFIG_KALLSYMS_ALL=y
+CONFIG_BPF_SYSCALL=y
+CONFIG_EMBEDDED=y
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_BLK_DEV_BSG is not set
+CONFIG_PPC_47x=y
+# CONFIG_EBONY is not set
+CONFIG_FSP2=y
+CONFIG_476FPE_ERR46=y
+CONFIG_SWIOTLB=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="ip=on rw"
+# CONFIG_SUSPEND is not set
+# CONFIG_PCI is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_IPV6 is not set
+CONFIG_VLAN_8021Q=m
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_CONNECTOR=y
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_JEDECPROBE=y
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=35000
+# CONFIG_SCSI_PROC_FS is not set
+CONFIG_BLK_DEV_SD=y
+# CONFIG_SCSI_LOWLEVEL is not set
+CONFIG_ATA=y
+# CONFIG_SATA_PMP is not set
+# CONFIG_ATA_SFF is not set
+CONFIG_NETDEVICES=y
+CONFIG_BONDING=m
+CONFIG_IBM_EMAC=m
+# CONFIG_INPUT is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_DEVMEM is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=32
+CONFIG_SERIAL_8250_RUNTIME_UARTS=32
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_OF_PLATFORM=y
+# CONFIG_HW_RANDOM is not set
+CONFIG_I2C=y
+CONFIG_I2C_IBM_IIC=y
+CONFIG_PTP_1588_CLOCK=y
+# CONFIG_HWMON is not set
+CONFIG_THERMAL=y
+CONFIG_WATCHDOG=y
+CONFIG_BOOKE_WDT=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_MMC=y
+CONFIG_MMC_DEBUG=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_MMC_SDHCI_OF_ARASAN=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_M41T80=y
+CONFIG_EXT2_FS=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_PROC_KCORE=y
+CONFIG_TMPFS=y
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_WBUF_VERIFY=y
+CONFIG_JFFS2_SUMMARY=y
+CONFIG_JFFS2_FS_XATTR=y
+CONFIG_CRAMFS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_ROOT_NFS=y
+CONFIG_NLS_DEFAULT="n"
+CONFIG_XZ_DEC=y
+CONFIG_PRINTK_TIME=y
+CONFIG_MESSAGE_LOGLEVEL_DEFAULT=3
+CONFIG_DYNAMIC_DEBUG=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_FS=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DETECT_HUNG_TASK=y
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_ECB=y
+CONFIG_CRYPTO_PCBC=y
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_HW is not set
-- 
1.7.1



[PATCH 1/4] arch/powerpc/44x/fsp2: platform support for fsp2(476fpe) board

2017-05-15 Thread Ivan Mikhaylov
Add platform code support for FSP2 (476fpe) board.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/platforms/44x/Kconfig  |   12 +++
 arch/powerpc/platforms/44x/Makefile |1 +
 arch/powerpc/platforms/44x/fsp2.c   |   62 +++
 3 files changed, 75 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/44x/fsp2.c

diff --git a/arch/powerpc/platforms/44x/Kconfig 
b/arch/powerpc/platforms/44x/Kconfig
index 9b0afe9..01cb109 100644
--- a/arch/powerpc/platforms/44x/Kconfig
+++ b/arch/powerpc/platforms/44x/Kconfig
@@ -199,6 +199,18 @@ config CURRITUCK
help
  This option enables support for the IBM Currituck (476fpe) evaluation 
board
 
+config FSP2
+   bool "IBM FSP2 (476fpe) Support"
+   depends on PPC_47x
+   default n
+   select 476FPE
+   select IBM_EMAC_EMAC4 if IBM_EMAC
+   select IBM_EMAC_RGMII if IBM_EMAC
+   select COMMON_CLK
+   select DEFAULT_UIMAGE
+   help
+ This option enables support for the IBM FSP2 (476fpe) board
+
 config AKEBONO
bool "IBM Akebono (476gtr) Support"
depends on PPC_47x
diff --git a/arch/powerpc/platforms/44x/Makefile 
b/arch/powerpc/platforms/44x/Makefile
index 26d35b5..72b8241 100644
--- a/arch/powerpc/platforms/44x/Makefile
+++ b/arch/powerpc/platforms/44x/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_ISS4xx)  += iss4xx.o
 obj-$(CONFIG_CANYONLANDS)+= canyonlands.o
 obj-$(CONFIG_CURRITUCK)+= ppc476.o
 obj-$(CONFIG_AKEBONO)  += ppc476.o
+obj-$(CONFIG_FSP2) += fsp2.o
diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
new file mode 100644
index 000..92e9804
--- /dev/null
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -0,0 +1,62 @@
+/*
+ * FSP-2 board specific routines
+ *
+ * Based on earlier code:
+ *Matt Porter <mpor...@kernel.crashing.org>
+ *Copyright 2002-2005 MontaVista Software Inc.
+ *
+ *Eugene Surovegin <eugene.surove...@zultys.com> or <e...@ebshome.net>
+ *Copyright (c) 2003-2005 Zultys Technologies
+ *
+ *Rewritten and ported to the merged powerpc tree:
+ *Copyright 2007 David Gibson <d...@au1.ibm.com>, IBM Corporation.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static __initdata struct of_device_id fsp2_of_bus[] = {
+   { .compatible = "ibm,plb4", },
+   { .compatible = "ibm,plb6", },
+   { .compatible = "ibm,opb", },
+   {},
+};
+
+static int __init fsp2_device_probe(void)
+{
+   of_platform_bus_probe(NULL, fsp2_of_bus, NULL);
+   return 0;
+}
+machine_device_initcall(fsp2, fsp2_device_probe);
+
+static int __init fsp2_probe(void)
+{
+   unsigned long root = of_get_flat_dt_root();
+
+   if (!of_flat_dt_is_compatible(root, "ibm,fsp2"))
+   return 0;
+   return 1;
+}
+
+define_machine(fsp2) {
+   .name   = "FSP-2",
+   .probe  = fsp2_probe,
+   .progress   = udbg_progress,
+   .init_IRQ   = uic_init_tree,
+   .get_irq= uic_get_irq,
+   .restart= ppc4xx_reset_system,
+   .calibrate_decr = generic_calibrate_decr,
+};
-- 
1.7.1



[PATCH 2/4] arch/powerpc/44x/fsp2: add device tree for fsp2 board

2017-05-15 Thread Ivan Mikhaylov
Add a device tree for fsp2 board (476 based).

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/boot/dts/fsp2.dts |  608 
 1 files changed, 608 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/fsp2.dts

diff --git a/arch/powerpc/boot/dts/fsp2.dts b/arch/powerpc/boot/dts/fsp2.dts
new file mode 100644
index 000..475953a
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsp2.dts
@@ -0,0 +1,608 @@
+/*
+ * Device Tree Source for FSP2
+ *
+ * Copyright 2010,2012 IBM Corp.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without
+ * any warranty of any kind, whether express or implied.
+ */
+
+
+/dts-v1/;
+
+/ {
+   #address-cells = <2>;
+   #size-cells = <1>;
+   model = "ibm,fsp2";
+   compatible = "ibm,fsp2";
+   dcr-parent = <&{/cpus/cpu@0}>;
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   serial0 = 
+   };
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   device_type = "cpu";
+   model = "PowerPC, 476FSP2";
+   reg = <0x0>;
+   clock-frequency = <0>;/* Filled in by cuboot */
+   timebase-frequency = <0>; /* Filled in by cuboot */
+   i-cache-line-size = <32>;
+   d-cache-line-size = <32>;
+   d-cache-size = <32768>;
+   i-cache-size = <32768>;
+   dcr-controller;
+   dcr-access-method = "native";
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x 0x>; /* Filled in by
+cuboot */
+   };
+
+   clocks {
+   mmc_clk: mmc_clk {
+   compatible = "fixed-clock";
+   clock-frequency = <5000>;
+   clock-output-names = "mmc_clk";
+   };
+   };
+
+   UIC0: uic0 {
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+   compatible = "ibm,uic";
+   interrupt-controller;
+   cell-index = <0>;
+   dcr-reg = <0x2c0 0x8>;
+   };
+
+   /* "interrupts" field is 
+  first pair is non-critical, second is critical */
+   UIC1_0: uic1_0 {
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+
+   compatible = "ibm,uic";
+   interrupt-controller;
+   cell-index = <1>;
+   dcr-reg = <0x2c8 0x8>;
+   interrupt-parent = <>;
+   interrupts = <21 0x4 4 0x84>;
+   };
+
+   /* PSI and DMA */
+   UIC1_1: uic1_1 {
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+
+   compatible = "ibm,uic";
+   interrupt-controller;
+   cell-index = <2>;
+   dcr-reg = <0x350 0x8>;
+   interrupt-parent = <>;
+   interrupts = <22 0x4 5 0x84>;
+   };
+
+   /* Ethernet and USB */
+   UIC1_2: uic1_2 {
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+
+   compatible = "ibm,uic";
+   interrupt-controller;
+   cell-index = <3>;
+   dcr-reg = <0x358 0x8>;
+   interrupt-parent = <>;
+   interrupts = <23 0x4 6 0x84>;
+   };
+
+   /* PLB Errors */
+   UIC1_3: uic1_3 {
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+
+   compatible = "ibm,uic";
+   interrupt-controller;
+   cell-index = <4>;
+   dcr-reg = <0x360 0x8>;
+   interrupt-parent = <>;
+   interrupts = <24 0x4 7 0x84>;
+   };
+
+   UIC1_4: uic1_4 {
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+
+   compatible = "ibm,uic";
+   interrupt-controller;
+   cell-ind

[PATCH 4/4] arch/powerpc/44x/fsp2: wdt tcr update instead of whole rewrite

2017-05-15 Thread Ivan Mikhaylov
Prevent a kernel panic caused by unintentionally clearing TCR
watchdog bits.  At this point in the kernel boot, the watchdog has
already been enabled by u-boot.  The original code's attempt to
write to the TCR register results in an inadvertent clearing of the
watchdog configuration bits, causing the 476 to reset.
Panic happens in case of error as silently reboot without any outputs
on serial.

Signed-off-by: Ivan Mikhaylov <i...@de.ibm.com>
---
 arch/powerpc/kernel/time.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 2b33cfa..f75e512 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -738,12 +738,28 @@ static int __init get_freq(char *name, int cells, 
unsigned long *val)
 
 static void start_cpu_decrementer(void)
 {
+   unsigned int tcr;
 #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
/* Clear any pending timer interrupts */
mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS);
 
+#ifdef CONFIG_FSP2
+   /*
+* Prevent a kernel panic caused by unintentionally clearing TCR
+* watchdog bits.  At this point in the kernel boot, the watchdog has
+* already been enabled by u-boot.  The original code's attempt to
+* write to the TCR register results in an inadvertent clearing of the
+* watchdog configuration bits, causing the 440 to reset.
+*/
+   tcr = mfspr(SPRN_TCR);
+   tcr &= TCR_WP_MASK; /* clear all bits except for TCR[WP] */
+   tcr |= TCR_DIE; /* enable decrementer */
+   mtspr(SPRN_TCR, tcr);
+#else
/* Enable decrementer interrupt */
mtspr(SPRN_TCR, TCR_DIE);
+#endif
+
 #endif /* defined(CONFIG_BOOKE) || defined(CONFIG_40x) */
 }
 
-- 
1.7.1



[PATCH 0/4] Support for the FSP2 476fpe board in arch/powerpc

2017-05-15 Thread Ivan Mikhaylov
This adds support for the FSP2 (476fpe) board. This includes code in
arch/powerpc/platforms/44x for board initialization. Only uImage is
supported by now. Also there was some problem with whole watchdog TCR
rewrite which causing unexpected very early panic and fixed by 4 patch.
dts and defconfig for common usage included as well. Tested on FSP2 board
with uboot and initramfs image.

Ivan Mikhaylov (4):
  arch/powerpc/44x/fsp2: platform support for fsp2(476fpe) board
  arch/powerpc/44x/fsp2: add device tree for fsp2 board
  arch/powerpc/44x/fsp2: add defconfig for fsp2 board
  arch/powerpc/44x/fsp2: wdt tcr update instead of whole rewrite

 arch/powerpc/boot/dts/fsp2.dts  |  608 +++
 arch/powerpc/configs/44x/fsp2_defconfig |  126 +++
 arch/powerpc/kernel/time.c  |   16 +
 arch/powerpc/platforms/44x/Kconfig  |   12 +
 arch/powerpc/platforms/44x/Makefile |1 +
 arch/powerpc/platforms/44x/fsp2.c   |   62 
 6 files changed, 825 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/fsp2.dts
 create mode 100644 arch/powerpc/configs/44x/fsp2_defconfig
 create mode 100644 arch/powerpc/platforms/44x/fsp2.c