summaryrefslogtreecommitdiff
path: root/utils/imxtools/misc/io_pins.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-09-13 14:35:41 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-09-18 13:17:54 +0200
commit8f122e00919e351f260e08103dd7ed4d9f7f32ba (patch)
treeddcd025867bbb4ac60bc7a08ea9dcfe8db42f6e9 /utils/imxtools/misc/io_pins.c
parentb4c1bb021489412f6156bf859002f11052c8d0a9 (diff)
downloadrockbox-8f122e00919e351f260e08103dd7ed4d9f7f32ba.zip
rockbox-8f122e00919e351f260e08103dd7ed4d9f7f32ba.tar.gz
rockbox-8f122e00919e351f260e08103dd7ed4d9f7f32ba.tar.bz2
rockbox-8f122e00919e351f260e08103dd7ed4d9f7f32ba.tar.xz
imxtools: add pin map and decoding tool
Also add the tool which was used to generate the map on wiki. Change-Id: I54f3474028b5fa75348564437ec1b46ba20f071b
Diffstat (limited to 'utils/imxtools/misc/io_pins.c')
-rw-r--r--utils/imxtools/misc/io_pins.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/utils/imxtools/misc/io_pins.c b/utils/imxtools/misc/io_pins.c
new file mode 100644
index 0000000..37e0331
--- /dev/null
+++ b/utils/imxtools/misc/io_pins.c
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "map.h"
+
+bool read_number(const char *str, uint32_t *value)
+{
+ char *end;
+ long int ret = strtol(str, &end, 0);
+ if((str + strlen(str)) != end)
+ return false;
+ if(ret < 0)
+ return false;
+ *value = ret;
+ return true;
+}
+
+int main(int argc, char **argv)
+{
+ if(argc != 6)
+ {
+ printf("usage: %s <soc> <ver> <mux> <clr mask> <set mask>\n", argv[0]);
+ printf(" where <soc> is stmp3700 or imx233\n");
+ printf(" where <ver> is bga169 or lqfp128\n");
+ printf(" where <mux> is between 0 and 7");
+ printf(" where <mask> is a number or ~number\n");
+ return 1;
+ }
+
+ const char *soc = argv[1];
+ const char *ver = argv[2];
+ const char *s_mux = argv[3];
+ const char *s_clr_mask = argv[4];
+ const char *s_set_mask = argv[5];
+ uint32_t mux, clr_mask, set_mask;
+
+ if(!read_number(s_mux, &mux) || mux >= NR_BANKS * 2)
+ {
+ printf("invalid mux number\n");
+ return 1;
+ }
+ if(!read_number(s_clr_mask, &clr_mask))
+ {
+ printf("invalid clear mask\n");
+ return 2;
+ }
+ if(!read_number(s_set_mask, &set_mask))
+ {
+ printf("invalid set mask\n");
+ return 3;
+ }
+
+ struct bank_map_t *map = NULL;
+ for(unsigned i = 0; i < NR_SOCS; i++)
+ if(strcmp(soc, socs[i].soc) == 0 && strcmp(ver, socs[i].ver) == 0)
+ map = socs[i].map;
+ if(map == NULL)
+ {
+ printf("no valid map found\n");
+ return 4;
+ }
+
+ if(clr_mask & set_mask)
+ printf("warning: set and clear mask intersect!\n");
+ unsigned bank = mux / 2;
+ unsigned offset = 16 * (mux % 2);
+ for(unsigned i = 0; i < 16; i++)
+ {
+ unsigned pin = offset + i;
+ uint32_t pin_shift = 2 * i;
+ uint32_t set_fn = (set_mask >> pin_shift) & 3;
+ uint32_t clr_fn = (clr_mask >> pin_shift) & 3;
+ if(set_fn == 0 && clr_fn == 0)
+ continue;
+ bool partial_mask = (set_fn | clr_fn) != 3;
+
+ printf("B%dP%02d => %s (select = %d)", bank, pin,
+ map[bank].pins[pin].function[set_fn].name, set_fn);
+ if(partial_mask)
+ printf(" (warning: partial mask)");
+ printf("\n");
+ }
+
+ return 0;
+}