summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2019-02-11 10:01:19 +0100
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>2019-02-11 10:01:19 +0100
commit38d7af00e6cb0eb5890e1b4397d9bc2776ef8f62 (patch)
tree6cca99b032a40d1b39e9d865552f1f9f2a3535b3
parentaf85ab844b1dfdbf4276a57384ef5594266db0cd (diff)
dtblint: check reset-gpio-active-high + reset-gpio for matching polarity
-rw-r--r--src/dtblint.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/dtblint.c b/src/dtblint.c
index 1947e5e..ed9f0b2 100644
--- a/src/dtblint.c
+++ b/src/dtblint.c
@@ -62,6 +62,53 @@ static void fsl_fec_reset_polarity(void)
}
}
+static const char * const fsl_pcie_compatibles[] = {
+ "fsl,imx6q-pcie",
+ "fsl,imx6sx-pcie",
+ "fsl,imx6qp-pcie",
+ "fsl,imx7d-pcie",
+};
+
+static void fsl_pcie_reset_polarity(void)
+{
+ size_t i;
+ /*
+ * For historical reasons the gpio flag in the reset-gpio property
+ * isn't evaluated and the gpio is assumed to be active low. Inversion
+ * can be accomplished by adding the property reset-gpio-active-high.
+ * The gpio flag should match the presence of this property.
+ */
+ struct device_node *np;
+ int ret;
+
+ for (i = 0; i < ARRAY_SIZE(fsl_pcie_compatibles); ++i) {
+ for_each_compatible_node(np, NULL, fsl_pcie_compatibles[i]) {
+ struct of_phandle_args out_args[MAX_PHANDLE_ARGS];
+
+ bool active_high_property =
+ of_property_read_bool(np,
+ "reset-gpio-active-high");
+ bool active_high_gpio_flag;
+
+ ret = of_parse_phandle_with_args(np, "reset-gpio",
+ "#gpio-cells", 0,
+ out_args);
+ if (ret < 0)
+ continue;
+
+ if (out_args->args_count < 2)
+ continue;
+
+ active_high_gpio_flag = out_args->args[1] == 0;
+
+ if (active_high_gpio_flag != active_high_property) {
+ printf("E: reset-gpios flags don't match presence of reset-gpio-active-high property (%s)\n",
+ np->full_name);
+ }
+ }
+ }
+}
+
int main(int argc, const char *argv[])
{
void *fdt;
@@ -89,4 +136,5 @@ int main(int argc, const char *argv[])
dtblint_imx_pinmux();
fsl_fec_reset_polarity();
+ fsl_pcie_reset_polarity();
}