GPIO configuration on device Tree[Beagle Board]

1,309 views
Skip to first unread message

Mehmet Özgür Bayhan

unread,
Aug 17, 2015, 3:17:21 AM8/17/15
to BeagleBoard
Hi. I am using Robert C. Nelson's kernel on my Beagle Board Rev-C

I want to use mmc2 ports as GPIO.

There is 8 pins in mmc and the default configuration in device tree is  = 

mmc2: mmc@480b4000 {
compatible = "ti,omap3-hsmmc";
reg = <0x480b4000 0x200>;
interrupts = <86>;
ti,hwmods = "mmc2";
dmas = <&sdma 47>, <&sdma 48>;
dma-names = "tx", "rx";
};

but disbled default in omap3-beagle.dts. So how should i use these ports as GPIO(not as mmc2) and pull them HIGH and direction > out during sturtup?

I am a newbie, I've tried many things but still can't solve. 

Any help could be great.

Thanks.
Message has been deleted

Robert Nelson

unread,
Aug 17, 2015, 10:22:44 AM8/17/15
to Beagle Board, mozgur...@gmail.com
See this example of the "eMMC" reset gpio on the black, pick the
correct gpio on the xm and it'll work the same..

Step 1: define the pins a pinmux..

mmc1_pins: pinmux_mmc1_pins {
pinctrl-single,pins = <
0x160 (PIN_INPUT | MUX_MODE7) /* GPIO0_6 */
>;
};

Step 2: gpio-hog...

&gpio1 {
emmc_rst {
gpio-hog;
gpios = <20 0>;
output-high;
line-name = "EMMC ResetN";
};
};

Regards,

--
Robert Nelson
https://rcn-ee.com/

Robert Nelson

unread,
Aug 18, 2015, 8:49:29 AM8/18/15
to Mehmet Özgür Bayhan, Beagle Board
re-adding the beagle list...

On Tue, Aug 18, 2015 at 7:42 AM, Mehmet Özgür Bayhan
<mozgur...@gmail.com> wrote:
> Thanks for your help. But it is getting complicated. :S
>
> Ok. Lets keep it simple. Assume that i just want to light on a led from
> MMC2_DAT7 whis is equal to GPIO_139 in Beagleboard.
>
> I test GPIO's by exporting under /sys/class/gpio and echo > high to
> direction. Works well under kernel ver. 3.0.x with Angstrom distro. My leds
> are on.
>
>
> Ok here is the story:
>
> I am using your directions under eewiki with kernel 4.x + ubuntu.
>
> 1) First i tried to handle this from u-boot, so i pulled every MMC2_DAT* to
> MUX_4 (Which is assigned to GPIO's for documentation) . Reboot again with
> new u-boot image from SD. Nothing was happened. So i tought Kernel is
> blocking GPIO behave of this ports.
>
> Question 1: Does patching only u-boot is enough or necessary? Did i
> missing something?
>
> 2) Then i start to investigate Kernel Device Tree file from
> https://github.com/RobertCNelson/dtb-rebuilder/tree/4.1-ti/src/arm.
>
> I found some documentation under dtb-rebuilder/Bindings/gpio/ . gpio.txt and
> gpio-omap.txt. Read them.
>
> Then I found that omap3-beagle.dts and omap3.dtsi are main files. And in
> these files:
>
>> mmc2: mmc@480b4000 {
>> compatible = "ti,omap3-hsmmc";
>> reg = <0x480b4000 0x200>;
>> interrupts = <86>;
>> ti,hwmods = "mmc2";
>> dmas = <&sdma 47>, <&sdma 48>;
>> dma-names = "tx", "rx";
>> };
>
>
>> &mmc2 {
>> status = "disabled";
>> };
>
>
> Acoording to this files i understand that mmc2 pins are handled by kernel
> and disabled default. Next i deleted this files rebooted and tested again
> still nothing was happened.

Leave the mmc2 disabled section..

>
> Question 2: Why kernel still blocks this ports to behave like GPIO even i
> remove them in device tree and applied mux_4 in u-boot?
>
>
> 3) Then i removed mmc comments and asked this question here. Now i tried
> the example that you gave as:
>>
>>
>> &mmc2 {
>> status = "disabled";
>> };
>
>
> still remains and i added:
>
>> &omap3_pmx_core {
>> .....
>> mmc2_pins: pinmux_mmc2_pins {
>> pinctrl-single,pins = <
>> 0x016A (PIN_INPUT | MUX_MODE4) /* GPIO_139 -pin3 -mmc_dat_7 */
>> >;
>> };
>>
>> }
>
>
> And this part gives Error while "make":
>
>> &gpio139{
>> GPIO_139 {
>> gpio-hog;
>> gpios = <20 0>;
>> output-high;
>> line-name = "GPIO_139";
>> };
>> };
>
>
>
> //'gpio139', not found at this line &gpio139{

options are &gpio1 -> &gpio6, pick the correct "bank" that gpio139 is in..

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/omap3.dtsi#n216

>
> Then i removed and make again. Builded but stil nothing happens
>
> Question 3: Must i remove mmc2 status="disabled" part?
>
> Question 4: Where and how should i define &gpio139 or must i leave it as
> &gpio1
>
> Question 5: Is first part enough to test GPIO from /sys/class/gpio/ or must
> i add tthe second part too? line-name = "GPIO_139"; What is it related with?
>
> Question 6: Is 0x016A the offset of the register? According to what? Where
> can i find the documentation of these adresses or offsets? In u-boot's
> mux.h they differs.

This offset can be found in the dm3730 reference manual.

>
> For example in omap3-beagle.dts > 0x0ac (PIN_OUTPUT | MUX_MODE0) /*
> dss_data0.dss_data0 */
>
> But in u-boot -> mux.h #define CONTROL_PADCONF_DSS_DATA0
> 0x00DC
>
> I confused in there.
>
> If you have time and if you may answer them it should be greaceful.

Mehmet Özgür Bayhan

unread,
Aug 19, 2015, 4:16:13 AM8/19/15
to Robert Nelson, Beagle Board
Sorry i  answered last message directly to you.

Now i  rearranged the omap3-beagle.dts.

sudo cat /sys/kernel/debug/gpio >

...
GPIOs 128-159, platform/49058000.gpio, gpio:
...

So i picked up  &gpio6 for GPIO_139 and set gpios = <11 0>;

I've searched in dm3730 reference manual but there is no knowledge about offsets of registers.


I've also found real physical adress of the register CONTROL_PADCONF_MMC2_DAT6[31:16] ==== 0x4800 2168 ==== mmc2_dat7  in OMAP35 Techinical Reference Manual.

So i combined them and 
 
&omap3_pmx_core {
       ...
       ...
       ...
mmc2_pins: pinmux_mmc2_pins {
pinctrl-single,pins = <
0x16A (PIN_OUTPUT | MUX_MODE4) 
>;
};
};
&gpio6{
     GPIO_139 {
          gpio-hog;
          gpios = <11 0>;
          output-high;
          line-name = "GPIO_139_6";
     };
};

make & make install & reboot.

But still nothing happens. My LED still remains silently.

when i checked sudo cat /sys/kernel/debug/gpio

GPIOs 128-159, platform/49058000.gpio, gpio:
     gpio-138 (tfp410 PD           ) out hi    
     gpio-139 (GPIO_139_6          ) out hi   

it looks ok.  And also

dmesg | grep GPIO

[    0.811126] GPIO line 139 (GPIO_139_6) hogged as output/high


what am i doing wrong? I suspect about pin offset but dont enough knowledge of this is offset of what and how to calculate. So i cannot be sure what is wrong.

Best Wishes.
Reply all
Reply to author
Forward
0 new messages