Hi Ilario,

On 10/10/23 08:57, Ilario Gelmetti wrote:
> Dear all,
> thanks for your work in supporting the Allwinner devices!!
> 
> I am trying to use the 1-wire instructions I found on the wiki here [1]
> for connecting some DS18B20 1-wire thermometer to an
> A64-OLinuXino-2Ge8G-IND [2]. This single board computer is running a
> Debian 11 Bullseye image prepared by the Olimex people [3] and currently
> I am running a 5.10.180-olimex kernel.
> 
> I understand that I have to create a DeviceTree overlay (that I never
> did before), load this overlay in the /boot/uEnv.txt file (that's the
> name on the OS I am using) and hope it works. Right?
> 
> My (failed) first attempt to write a DeviceTree overlay is described on
> the Olimex forums here [4], but I suspect this is the proper channel for
> asking for some help on this topic.
> 
> Following attempts also failed. I always got a "pin PB0 already
> requested by onewire_device; cannot claim for 1c20800.pinctrl:32" error.
> These attempts included writing the code directly in the kernel dtb file
> (decompiled and compiled with dtc and included in the /boot/kernel.itb
> command using mkimage -f kernel.its kernel.itb).
> 
> I copy and paste here the latest attempt of DeviceTree overlay here.
> 
> ```
> /dts-v1/;
> /plugin/;
> 
> / {
>     compatible = "allwinner,sun50i-a64",
>                      "olimex,a64-olinuxino";
>     description = "Enable 1-Wire port";
> 
>     fragment@0 {
>         target-path = "/";
>         __overlay__ {
>             onewire_device: onewire_device {
>                 compatible = "w1-gpio";
>                 gpios = <&pio 1 0 0>; /* 1: B of PB0; 0: 0 of PB0; 0:
> GPIO_ACTIVE_HIGH */

You need GPIO_PULL_UP in the flags cell here.

>                 pinctrl-names = "default";
>                 pinctrl-0 = <&my_w1_pin>;
>             };
>         };
>     };
> 
>     fragment@1 {

And drop this entire fragment. See if it works with those two changes.

>         target = <&pio>;
>          __overlay__ {
>             my_w1_pin: my_w1_pin@0 {
>                 allwinner,pins = "PB0";
>                 allwinner,function = "gpio_in";
>                 allwinner,drive = <0>; /*<SUN4I_PINCTRL_10_MA>*/
>                 allwinner,pull = <1>; /*<SUN4I_PINCTRL_PULL_UP>*/
>             };
>         };
>     };
> };
> ```
> 
> I cannot get rid of this error in the dmesg (unless I specify two
> different pins in the two fragments, and then weird things happen, as
> explained in [4]):
> 
> [] Driver for 1-wire Dallas network protocol.
> [] sun50i-a64-pinctrl 1c20800.pinctrl: pin PB0 already requested by
> onewire_device; cannot claim for 1c20800.pinctrl:32
> [] sun50i-a64-pinctrl 1c20800.pinctrl: pin-32 (1c20800.pinctrl:32)
> status -22
> [] w1-gpio onewire_device: gpio_request (pin) failed
> [] w1-gpio: probe of onewire_device failed with error -22

The problem is that the GPIO reference and the pinctrl reference for the
same pin conflict. In this case, the only thing you need the pinctrl
reference for is the pull-up, which you can achieve with a GPIO flag.
However, for the more general case, you may need to apply some other
pinconf setting to a GPIO pin, so we may need to fix this.

Regards,
Samuel

> 
> Thanks for your help!!!
> Ilario
> 
> [1]: https://linux-sunxi.org/1-Wire
> [2]:
> https://www.olimex.com/Products/OLinuXino/A64/A64-OLinuXino/open-source-hardware
> [3]: https://images.olimex.com/
> [4]: https://www.olimex.com/forum/index.php?topic=9266.0
> 

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/e6c916fd-014c-6c7a-7d81-bea833cc9060%40sholland.org.

Reply via email to