I'm trying to use UART4 in my Pandaboard with Arch Linux. I'm using the latest kernel (4.2.0-2-ARCH) so I can't configure MUX in the old way using omap_mux, I have to do it using Device Tree Overlay. This is new to me so it's hard, I've never done this before. I have been reading some post about how to use them in Beaglebone boards in sites like this and this. So I downloaded the OMAP4 Technical Reference Manual (download here). Table 18-504 shows the UART4 control register. Based on that and the urls above I created and compiled the following Device Tree Overlay filling the register with 0's, this should set the MUX for UART4 functionality:
// Util: http://lxr.free-electrons.com/source/arch/arm/boot/dts/omap4-panda-es.dts
// http://www.valvers.com/embedded-linux/beaglebone-black/step04-gpio/
/dts-v1/;
/plugin/;
/ {
model = "TI OMAP4 PandaBoard-ES";
compatible = "ti,omap4-panda-es", "ti,omap4460";
part-number = "ANDRES-IO";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
uart4_pins: pinmux_uart4_pins {
pinctrl-single,pins = <
0x15C 0x00 // kernel pin 142 (uart4 tx y rx - address 0x4A10 015C)
>;
};
};
};
fragment@1 {
target = <&ocp>;
__overlay__ {
uart4_pins_helper {
compatible = "panda-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&uart4_pins>;
status = "okay";
};
};
};
};
I copied the compiled file to /lib/firmware/ but after that I don't know how to use or enable it. Beaglebone boards have bone_capemgr but I can't see such a thing in Pandaboard.
Other OS like Ubuntu has UART4 already configured, I tried looking for the Device Tree Overlay they use but couldn't find anything.
I solved it!!!!! Maybe is something trivial but it was really hard for me and I learned a lot. There is no much info about how to do it in Pandaboard, just for Beagleboards. So first, the
Device Tree Overlayfile it's loaded only at boot, we can't load it dynamically as with Beagleboard because we don't have abone_capemgr. The compiled.dtbfile is located in/boot/dtbs(at least in Arch Linux), there are a lot of.dtbfiles there but only one is loaded at boot depending on the board and you can see which one is loaded when booting, for example, in my case it is:I have a Pandaboard ES so the loaded file is
/boot/dtbs/omap4-panda-es.dtb. I decompiled the file so I can add the UART4 MUX settings usingdtc -I dtb -O dts omap4-panda-es.dtb > omap4-panda-es.dts(taken from here). So now we have aomap4-panda-es.dtswhich is the complete Device Tree Overlays that sets everything up, I just need to add the UART4 MUX settings. We have to use thepinctrl-single,pinsproperty. Here is a really good explanation aboutpinctrl-single,pins:This was something I misunderstood at the beginning, I though the
pinctrladdress was absolute but it's relative to the base address in the tree. In my case for example there are a lot ofpinmux_tfp410_pins,pinmux_dss_hdmi_pins,pinmux_i2c1_pins, etc. All thesepinmux_*are under a parent calledpinmux@40, that means that the address specified inpinctrlis relative to0x40, but thispinmux@40is under another node calledscm@100000which is inside another node calledl4@4a000000, so the addresses insidepinmux@40are relative to the base address of the node that is the sum of all these addresses, that is0x4a000000 + 0x100000 + 0x40 = 0x4a100040, so0xa100040is the base address, all the address specified inpinctrlare relative to0xa100040. So, according to Table 18-504 in theOMAP4 Technical Reference Manual(download available here) the address for the UART4 control register that control the MUX and some other things is0x4A10015C. The base address of pinctrl is0x4a100040so the address we must specify inpinctrlis0x11cbecause0x4a100040 + 0x11c = 0x4A10015C. All the Device Tree Overlays I found of other linux distros that support Pandaboard use the same base address0x4a100040(here for example). So I added under the nodepinmux@40this:I took this settings from here but just changing the
0x100and0will change the settings in the register. In my case I also had to add:I don't see this in Ubuntu for example (https://github.com/Canonical-kernel/Ubuntu-kernel/blob/master/arch/arm/boot/dts/omap4.dtsi) but I don't know why or what is the purpose of this
phandle, all I know if that they are used as a reference, a reference I need to put somewhere else in the Device Tree, just make sure it is unique, it can be any 32-bit value but must be unique inside the tree. In my case there was another node referring UART4:So there I had to use
phandleotherwise MUX settings won't be applied:Finally, at the end of the file there a lot of definitions, one for each node, for example
They just describe where each node is located, here we can clearly see what the base address is. So here I just added this:
Now we have a complete
.dtsfile which should get the UART4 working. We must compile it usingdtc -O dtb -o omap4-panda-es.dtb -b O -@ omap4-panda-es.dts, this will generate a.dtbfile that will replace the one in/boot/dtbs, so replace it and reboot! After rebooting runcat /sys/kernel/debug/pinctrl/4a100040.pinmux/pinmux-functions, it should show something like this:If we see
uart4everything is fine and it should be working! Otherwise there is something wrong in the.dtsfile. We can test if the uart is working by running for exampleecho -e "AT" > /dev/ttyO3, remember that/dev/ttyO3isUART4. I hope this will be useful for someone!Just for reference here is the complete
.dtsand compiled.dtbfile with working UART4: https://gist.github.com/dragondgold/1aaabf93279006b703f3