Skip to content
Permalink
Browse files

armv8/fsl-layerscape: fdt: fixup LS1043A rev1 MSI node with upstream …

…method

Revert patch 'armv8/fsl-layerscape: fdt: fixup LS1043A rev1 MSI node'.
Commit id: 5e6f475

The patch reverted is sdk version. Then apply the upstream version with
context adjustment and a little change.

Upstream patch: 'armv8/fsl-layerscape: fdt: fixup LS1043A rev1 MSI node'
Commit id: 2ca84bf7b2d7930b424b19f5027d3c06ec7cb696

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
  • Loading branch information
yangbolu1991 committed Feb 16, 2017
1 parent 619eff8 commit 6a153b9e5fc2f314eb4b73327ccc94cf25d67360
Showing with 92 additions and 31 deletions.
  1. +91 −31 arch/arm/cpu/armv8/fsl-layerscape/fdt.c
  2. +1 −0 arch/arm/include/asm/arch-fsl-layerscape/soc.h
@@ -173,35 +173,89 @@ static void fdt_fixup_gic(void *blob)
return;
}
#endif

#ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI
static int _fdt_fixup_msi_subnode(void *blob, int parentoffset,
const char *name, int irq_no)
static int _fdt_fixup_msi_node(void *blob, const char *name,
int irq_0, int irq_1, int rev)
{
int err, offset;
u32 tmp[3];
int err, offset, len;
u32 tmp[4][3];
void *p;

offset = fdt_subnode_offset(blob, parentoffset, name);
offset = fdt_path_offset(blob, name);
if (offset < 0) {
printf("WARNING: fdt_subnode_offset can't find %s: %s\n",
printf("WARNING: fdt_path_offset can't find path %s: %s\n",
name, fdt_strerror(offset));
return 0;
}

tmp[0] = cpu_to_fdt32(0x0);
tmp[1] = cpu_to_fdt32(irq_no);
tmp[2] = cpu_to_fdt32(0x4);
/*fixup the property of interrupts*/

tmp[0][0] = cpu_to_fdt32(0x0);
tmp[0][1] = cpu_to_fdt32(irq_0);
tmp[0][2] = cpu_to_fdt32(0x4);

if (rev > REV1_0) {
tmp[1][0] = cpu_to_fdt32(0x0);
tmp[1][1] = cpu_to_fdt32(irq_1);
tmp[1][2] = cpu_to_fdt32(0x4);
tmp[2][0] = cpu_to_fdt32(0x0);
tmp[2][1] = cpu_to_fdt32(irq_1 + 1);
tmp[2][2] = cpu_to_fdt32(0x4);
tmp[3][0] = cpu_to_fdt32(0x0);
tmp[3][1] = cpu_to_fdt32(irq_1 + 2);
tmp[3][2] = cpu_to_fdt32(0x4);
len = sizeof(tmp);
} else {
len = sizeof(tmp[0]);
}

err = fdt_setprop(blob, offset, "interrupts", tmp, sizeof(tmp));
err = fdt_setprop(blob, offset, "interrupts", tmp, len);
if (err < 0) {
printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
"interrupts", name, fdt_strerror(err));
return 0;
}

/*fixup the property of reg*/
p = (char *)fdt_getprop(blob, offset, "reg", &len);
if (!p) {
printf("WARNING: fdt_getprop can't get %s from node %s\n",
"reg", name);
return 0;
}

memcpy((char *)tmp, p, len);

if (rev > REV1_0)
*((u32 *)tmp + 3) = cpu_to_fdt32(0x1000);
else
*((u32 *)tmp + 3) = cpu_to_fdt32(0x8);

err = fdt_setprop(blob, offset, "reg", tmp, len);
if (err < 0) {
printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
"reg", name, fdt_strerror(err));
return 0;
}

/*fixup the property of compatible*/
if (rev > REV1_0)
err = fdt_setprop_string(blob, offset, "compatible",
"fsl,ls1043a-v1.1-msi");
else
err = fdt_setprop_string(blob, offset, "compatible",
"fsl,ls1043a-msi");
if (err < 0) {
printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
"compatible", name, fdt_strerror(err));
return 0;
}

return 1;
}

static int _fdt_fixup_pci_msi(void *blob, const char *name)
static int _fdt_fixup_pci_msi(void *blob, const char *name, int rev)
{
int offset, len, err;
void *p;
@@ -223,10 +277,17 @@ static int _fdt_fixup_pci_msi(void *blob, const char *name)
}

memcpy((char *)tmp, p, len);

val = fdt32_to_cpu(tmp[0][6]);
tmp[1][6] = cpu_to_fdt32(val + 1);
tmp[2][6] = cpu_to_fdt32(val + 2);
tmp[3][6] = cpu_to_fdt32(val + 3);
if (rev > REV1_0) {
tmp[1][6] = cpu_to_fdt32(val + 1);
tmp[2][6] = cpu_to_fdt32(val + 2);
tmp[3][6] = cpu_to_fdt32(val + 3);
} else {
tmp[1][6] = cpu_to_fdt32(val);
tmp[2][6] = cpu_to_fdt32(val);
tmp[3][6] = cpu_to_fdt32(val);
}

err = fdt_setprop(blob, offset, "interrupt-map", tmp, sizeof(tmp));
if (err < 0) {
@@ -237,31 +298,30 @@ static int _fdt_fixup_pci_msi(void *blob, const char *name)
return 1;
}

/* Fixup msi to v1_0*/
/* Fixup msi node for ls1043a rev1.1*/

static void fdt_fixup_msi(void *blob)
{
int nodeoffset;
struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
unsigned int val;
unsigned int rev;

val = gur_in32(&gur->svr) & 0xff;
if (val == REV1_1)
return;
rev = gur_in32(&gur->svr);

nodeoffset = fdt_path_offset(blob, "/soc/msi-controller");
if (nodeoffset < 0) {
printf("WARNING: fdt_path_offset can't find path %s: %s\n",
"/soc/msi-controller", fdt_strerror(nodeoffset));
if (SVR_SOC_VER(rev) != SVR_LS1043A)
return;
}
_fdt_fixup_msi_subnode(blob, nodeoffset, "msi0@1571000", 116);
_fdt_fixup_msi_subnode(blob, nodeoffset, "msi1@1572000", 126);
_fdt_fixup_msi_subnode(blob, nodeoffset, "msi2@1573000", 160);

_fdt_fixup_pci_msi(blob, "/soc/pcie@3400000");
_fdt_fixup_pci_msi(blob, "/soc/pcie@3500000");
_fdt_fixup_pci_msi(blob, "/soc/pcie@3600000");
rev = SVR_REV(rev);

_fdt_fixup_msi_node(blob, "/soc/msi-controller1@1571000",
116, 111, rev);
_fdt_fixup_msi_node(blob, "/soc/msi-controller2@1572000",
126, 121, rev);
_fdt_fixup_msi_node(blob, "/soc/msi-controller3@1573000",
160, 155, rev);

_fdt_fixup_pci_msi(blob, "/soc/pcie@3400000", rev);
_fdt_fixup_pci_msi(blob, "/soc/pcie@3500000", rev);
_fdt_fixup_pci_msi(blob, "/soc/pcie@3600000", rev);
}
#endif

@@ -53,6 +53,7 @@ struct cpu_type {

#define SVR_MAJ(svr) (((svr) >> 4) & 0xf)
#define SVR_MIN(svr) (((svr) >> 0) & 0xf)
#define SVR_REV(svr) (((svr) >> 0) & 0xff)
#define SVR_SOC_VER(svr) (((svr) >> 8) & SVR_WO_E)
#define IS_E_PROCESSOR(svr) (!((svr >> 8) & 0x1))
#define IS_SVR_REV(svr, maj, min) \

0 comments on commit 6a153b9

Please sign in to comment.
You can’t perform that action at this time.