diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2012-05-10 00:08:03 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2012-05-10 00:13:11 +0200 |
commit | 645680d62b82455d24fcb178f1cc5208f9942e38 (patch) | |
tree | 1a9f928afc34260059bf986fc2caa7fc5b2a2028 /firmware/target/arm/imx233/pinctrl-imx233.c | |
parent | d29a11b7a8f4ce230e9385a44f352a559bde753f (diff) | |
download | rockbox-645680d62b82455d24fcb178f1cc5208f9942e38.tar.gz rockbox-645680d62b82455d24fcb178f1cc5208f9942e38.zip |
imx233: add pinctrl debug code to track pin uses
Past development has proved that one can mistakely use
the same pin for two uses without noticing. Since this
causes extremely hard to find bugs, the infrastructure
will allow to register pin uses and panic when a conflict
is detected. The pinctrl debug now shows the pin uses
when its support is compiled in.
Change-Id: Idb2d5235ce09207d77aa474d6f158e72b933761a
Diffstat (limited to 'firmware/target/arm/imx233/pinctrl-imx233.c')
-rw-r--r-- | firmware/target/arm/imx233/pinctrl-imx233.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/pinctrl-imx233.c b/firmware/target/arm/imx233/pinctrl-imx233.c index 7997292fcb..be2d8b2262 100644 --- a/firmware/target/arm/imx233/pinctrl-imx233.c +++ b/firmware/target/arm/imx233/pinctrl-imx233.c | |||
@@ -21,8 +21,47 @@ | |||
21 | #include "system.h" | 21 | #include "system.h" |
22 | #include "system-target.h" | 22 | #include "system-target.h" |
23 | #include "cpu.h" | 23 | #include "cpu.h" |
24 | #include "string.h" | ||
24 | #include "pinctrl-imx233.h" | 25 | #include "pinctrl-imx233.h" |
25 | 26 | ||
27 | #ifdef IMX233_PINCTRL_DEBUG | ||
28 | // 4 banks of 32 pins | ||
29 | static const char *pin_use[4][32]; | ||
30 | |||
31 | void imx233_pinctrl_acquire_pin(unsigned bank, unsigned pin, const char *name) | ||
32 | { | ||
33 | if(pin_use[bank][pin] != NULL && pin_use[bank][pin] != name) | ||
34 | panicf("acquire B%dP%02d for %s, was %s!", bank, pin, name, pin_use[bank][pin]); | ||
35 | pin_use[bank][pin] = name; | ||
36 | } | ||
37 | |||
38 | void imx233_pinctrl_acquire_pin_mask(unsigned bank, uint32_t mask, const char *name) | ||
39 | { | ||
40 | for(unsigned pin = 0; pin < 32; pin++) | ||
41 | if(mask & (1 << pin)) | ||
42 | imx233_pinctrl_acquire_pin(bank, pin, name); | ||
43 | } | ||
44 | |||
45 | void imx233_pinctrl_release_pin(unsigned bank, unsigned pin, const char *name) | ||
46 | { | ||
47 | if(pin_use[bank][pin] != NULL && pin_use[bank][pin] != name) | ||
48 | panicf("release B%dP%02d for %s: was %s!", bank, pin, name, pin_use[bank][pin]); | ||
49 | pin_use[bank][pin] = NULL; | ||
50 | } | ||
51 | |||
52 | void imx233_pinctrl_release_pin_mask(unsigned bank, uint32_t mask, const char *name) | ||
53 | { | ||
54 | for(unsigned pin = 0; pin < 32; pin++) | ||
55 | if(mask & (1 << pin)) | ||
56 | imx233_pinctrl_release_pin(bank, pin, name); | ||
57 | } | ||
58 | |||
59 | const char *imx233_pinctrl_get_pin_use(unsigned bank, unsigned pin) | ||
60 | { | ||
61 | return pin_use[bank][pin]; | ||
62 | } | ||
63 | #endif | ||
64 | |||
26 | static pin_irq_cb_t pin_cb[3][32]; /* 3 banks, 32 pins/bank */ | 65 | static pin_irq_cb_t pin_cb[3][32]; /* 3 banks, 32 pins/bank */ |
27 | 66 | ||
28 | static void INT_GPIO(int bank) | 67 | static void INT_GPIO(int bank) |