summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <uwe@kleine-koenig.org>2016-07-09 00:46:38 +0200
committerUwe Kleine-König <uwe@kleine-koenig.org>2016-07-09 00:46:38 +0200
commit92be9966a1e7c2ff7f261b50c74d79225948ff1a (patch)
tree6df877e3ce158652945a81f8ce719c64ca1a1a1a
parentd51d45fc6affadda0e65c048278c7a43a82b339c (diff)
downloaddt-utils-92be9966a1e7c2ff7f261b50c74d79225948ff1a.tar.gz
dt-utils-92be9966a1e7c2ff7f261b50c74d79225948ff1a.tar.xz
dtblint: check for fec reset gpio polarity mismatch
-rw-r--r--src/dtblint.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/dtblint.c b/src/dtblint.c
index cea2953..59cb11f 100644
--- a/src/dtblint.c
+++ b/src/dtblint.c
@@ -13,6 +13,55 @@
#include "dtblint.h"
+static const char * const fsl_fec_compatibles[] = {
+ "fsl,imx25-fec",
+ "fsl,imx27-fec",
+ "fsl,imx28-fec",
+ "fsl,imx6q-fec",
+ "fsl,imx6sx-fec",
+ "fsl,mvf600-fec",
+};
+
+static void fsl_fec_reset_polarity(void)
+{
+ size_t i;
+ /*
+ * For historical reasons the gpio flag in the phy-reset-gpios property
+ * isn't evaluated and the gpio is assumed to be active low. Inversion
+ * can be accomplished by adding the property phy-reset-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_fec_compatibles); ++i) {
+ for_each_compatible_node(np, NULL, fsl_fec_compatibles[i]) {
+ struct of_phandle_args out_args[MAX_PHANDLE_ARGS];
+
+ bool active_high_property =
+ of_property_read_bool(np,
+ "phy-reset-active-high");
+ bool active_high_gpio_flag;
+
+ ret = of_parse_phandle_with_args(np, "phy-reset-gpios",
+ "#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: phy-reset-gpios flags don't match presence of phy-reset-active-high property (%s)\n",
+ np->full_name);
+ }
+ }
+ }
+}
+
int main(int argc, const char *argv[])
{
void *fdt;
@@ -31,10 +80,12 @@ int main(int argc, const char *argv[])
root = of_unflatten_dtb(fdt);
if (IS_ERR(root)) {
- fprintf(stderr, "failed to unflatten device tree (%ld)\n", PTR_ERR(root));
+ fprintf(stderr, "failed to unflatten device tree (%ld)\n",
+ PTR_ERR(root));
return EXIT_FAILURE;
}
of_set_root_node(root);
dtblint_imx_pinmux();
+ fsl_fec_reset_polarity();
}