Skip to content

Commit e52aab4

Browse files
author
Fox Snowpatch
committed
1 parent a2f7734 commit e52aab4

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

drivers/bus/fsl-mc/fsl-mc-bus.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ struct fsl_mc_addr_translation_range {
6666
#define GCR1_P1_STOP BIT(31)
6767
#define GCR1_P2_STOP BIT(30)
6868

69+
#define FSL_MC_GSR 0x8
70+
#define FSL_MC_GSR_BOOT_DONE BIT(0)
71+
#define FSL_MC_GSR_MCS_MASK GENMASK(7, 0)
72+
#define FSL_MC_GSR_MCS_ERR_MASK GENMASK(7, 1)
73+
#define FSL_MC_GSR_BC_MASK GENMASK(15, 8)
74+
#define FSL_MC_GSR_BC_SHIFT 8
75+
6976
#define FSL_MC_FAPR 0x28
7077
#define MC_FAPR_PL BIT(18)
7178
#define MC_FAPR_BMT BIT(17)
@@ -1021,6 +1028,41 @@ static int get_mc_addr_translation_ranges(struct device *dev,
10211028
return 0;
10221029
}
10231030

1031+
static u32 fsl_mc_read_gsr(struct fsl_mc *mc)
1032+
{
1033+
return readl(mc->fsl_mc_regs + FSL_MC_GSR);
1034+
}
1035+
1036+
static int fsl_mc_firmware_check(struct platform_device *pdev)
1037+
{
1038+
struct fsl_mc *mc = platform_get_drvdata(pdev);
1039+
u32 gsr, boot_done, boot_code, mcs;
1040+
1041+
gsr = fsl_mc_read_gsr(mc);
1042+
boot_code = (gsr & FSL_MC_GSR_BC_MASK) >> FSL_MC_GSR_BC_SHIFT;
1043+
if (boot_code == 0xDD) {
1044+
dev_err(&pdev->dev,
1045+
"fsl-mc: DPL processing was not started, DPAA2 will not work!\n");
1046+
return -EOPNOTSUPP;
1047+
}
1048+
1049+
boot_done = gsr & FSL_MC_GSR_BOOT_DONE;
1050+
if (!boot_done) {
1051+
dev_dbg(&pdev->dev,
1052+
"fsl-mc: DPL processing in progress, defer probe\n");
1053+
return -EPROBE_DEFER;
1054+
}
1055+
1056+
mcs = gsr & FSL_MC_GSR_MCS_MASK;
1057+
if (mcs & FSL_MC_GSR_MCS_ERR_MASK) {
1058+
dev_err(&pdev->dev,
1059+
"fsl-mc: MC boot completed with error 0x%x\n", mcs);
1060+
return -EINVAL;
1061+
}
1062+
1063+
return 0;
1064+
}
1065+
10241066
/*
10251067
* fsl_mc_bus_probe - callback invoked when the root MC bus is being
10261068
* added
@@ -1085,6 +1127,10 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
10851127
mc->fsl_mc_regs + FSL_MC_GCR1);
10861128
}
10871129

1130+
error = fsl_mc_firmware_check(pdev);
1131+
if (error)
1132+
return error;
1133+
10881134
/*
10891135
* Get physical address of MC portal for the root DPRC:
10901136
*/

0 commit comments

Comments
 (0)