diff options
Diffstat (limited to 'recipes-demo/de10-nano-gpio-apps/files/find_gpio_controllers_dt.src')
-rw-r--r-- | recipes-demo/de10-nano-gpio-apps/files/find_gpio_controllers_dt.src | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/recipes-demo/de10-nano-gpio-apps/files/find_gpio_controllers_dt.src b/recipes-demo/de10-nano-gpio-apps/files/find_gpio_controllers_dt.src new file mode 100644 index 0000000..9fd38f8 --- /dev/null +++ b/recipes-demo/de10-nano-gpio-apps/files/find_gpio_controllers_dt.src @@ -0,0 +1,27 @@ +function find_gpio_controllers_dt () +{ + for NEXT in $(find -L /proc/device-tree -name "compatible" | sort); + do + cat ${NEXT} | grep -xz "snps,dw-apb-gpio" > /dev/null && { + GPIO_DIRNAME="$(dirname ${NEXT})"; + echo ${GPIO_DIRNAME}; + GPIO_COMPATIBLE="$(cat ${GPIO_DIRNAME}/compatible)"; + echo -e "\tcompatible = '${GPIO_COMPATIBLE}'"; + WF="${GPIO_DIRNAME}/gpio-controller@0/snps,nr-gpios"; + GPIO_HEX_WIDTH="$(hexdump -v -e '"0x"' -e '4/1 "%02x"' "${WF}")"; + GPIO_WIDTH=$(printf "%d" ${GPIO_HEX_WIDTH}); + echo -e "\t width = '${GPIO_WIDTH}'" + }; + cat ${NEXT} | grep -e "altr,pio" > /dev/null && { + GPIO_DIRNAME="$(dirname ${NEXT})"; + echo ${GPIO_DIRNAME}; + GPIO_COMPATIBLE="$(cat ${GPIO_DIRNAME}/compatible)"; + echo -e "\tcompatible = '${GPIO_COMPATIBLE}'"; + WF="${GPIO_DIRNAME}/altr,gpio-bank-width"; + GPIO_HEX_WIDTH="$(hexdump -v -e '"0x"' -e '4/1 "%02x"' "${WF}")"; + GPIO_WIDTH=$(printf "%d" ${GPIO_HEX_WIDTH}); + echo -e "\t width = '${GPIO_WIDTH}'" + }; + done +} + |