Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Nov 2018 06:42:33 +0100
From:      Emmanuel Vadot <manu@bidouilliste.com>
To:        ticso@cicely.de
Cc:        Bernd Walter <ticso@cicely7.cicely.de>, Ian Lepore <ian@freebsd.org>, freebsd-arm@freebsd.org
Subject:   Re: How to add custom dts entries
Message-ID:  <20181108064233.fa5385cc6e7d515b5c2d6f83@bidouilliste.com>
In-Reply-To: <20181104220623.GR79858@cicely7.cicely.de>
References:  <20181103200709.GB79858@cicely7.cicely.de> <1541277990.52306.4.camel@freebsd.org> <20181103205455.GD79858@cicely7.cicely.de> <1541279079.52306.8.camel@freebsd.org> <20181103212031.GF79858@cicely7.cicely.de> <1541280338.52306.9.camel@freebsd.org> <20181104183247.GN79858@cicely7.cicely.de> <20181104184939.GO79858@cicely7.cicely.de> <20181104185337.GP79858@cicely7.cicely.de> <20181104195659.GQ79858@cicely7.cicely.de> <20181104220623.GR79858@cicely7.cicely.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 4 Nov 2018 23:06:23 +0100
Bernd Walter <ticso@cicely7.cicely.de> wrote:

> On Sun, Nov 04, 2018 at 08:57:00PM +0100, Bernd Walter wrote:
> > On Sun, Nov 04, 2018 at 07:53:38PM +0100, Bernd Walter wrote:
> > > On Sun, Nov 04, 2018 at 07:49:39PM +0100, Bernd Walter wrote:
> > > > On Sun, Nov 04, 2018 at 07:32:47PM +0100, Bernd Walter wrote:
> > > > > On Sat, Nov 03, 2018 at 03:25:38PM -0600, Ian Lepore wrote:
> > > > > > Add a status = "okay" to the spi node in your patch/overlay.
> > > > > 
> > > > > Makes sense.
> > > > > 
> > > > > So the spigen overlay works fine, once I set fdt_overlays in loader.conf
> > > > > to use the overlay file.
> > > > > 
> > > > > spi0: <BCM2708/2835 SPI controller> mem 0x7e204000-0x7e204fff irq 25 on simplebus0
> > > > > spibus0: <OFW SPI bus> on spi0
> > > > > spibus0: <unknown card> at cs 1 mode 0
> > > > > spibus0: <unknown card> at cs 0 mode 0
> > > > > spibus0: <unknown card> at cs 0 mode 0
> > > > > spibus0: <unknown card> at cs 1 mode 0
> > > > > 
> > > > > With my own overlay I do this to install it:
> > > > > dtc -I dts -O dtb -o rpi-apa102-matrix.dtbo rpi-apa102-matrix.dts
> > > > > cp rpi-apa102-matrix.dtbo /boot/dtb/overlays
> > > > > 
> > > > > [77]cicely1> cat rpi-apa102-matrix.dts
> > > > > /dts-v1/;
> > > > > /plugin/;
> > > > > 
> > > > > / {
> > > > >         compatible = "brcm,bcm2835";
> > > > > };
> > > > > 
> > > > > /* &spi0 { */
> > > > > &{/soc/spi@7e204000} {
> > > > >         status = "okay";
> > > > > 
> > > > >         apa102led0 {
> > > > >                 compatible = "led,apa102";
> > > > >                 reg = <0>;
> > > > >                 spi-max-frequency = <20000000>;
> > > > >                 status = "okay";
> > > > >         };
> > > > > };
> > > > > 
> > > > > &onewire {
> > > > >         compatible = "w1-gpio";
> > > > >         gpios = <&gpio 4 1>;
> > > > > };
> > > > > 
> > > > > Still puzzled with the format.
> > > > > With &spi0 it didn't work, neither with the current format, which is
> > > > > copied from the spigen.dts.
> > > > > Neither spi0 attaches, nor the onewire bus.
> > > > > 
> > > > > Some other, mostly beaglebone related examples use a more complex
> > > > > setup with overlay_ entries and everything inside the compatible block.
> > > > > 
> > > > > Can I have a device.hints please ;-)
> > > > > 
> > > > > ofwdump shows:
> > > > > ...
> > > > >     Node 0x20fc: spi@7e204000
> > > > >       compatible:
> > > > >         62 72 63 6d 2c 62 63 6d 32 38 33 35 2d 73 70 69 00 
> > > > >         'brcm,bcm2835-spi'
> > > > > ...
> > > > >       status:
> > > > >         64 69 73 61 62 6c 65 64 00 
> > > > >         'disabled'
> > > > > ...
> > > > > 
> > > > > Havn't checked ofwdump with the spigen overlay.
> > > > 
> > > > Interesting.
> > > > When I use &spi0 and leave out the &onewire block, it attaches something.
> > > > spi0: <BCM2708/2835 SPI controller> mem 0x7e204000-0x7e204fff irq 25 on simplebus0
> > > > spibus0: <OFW SPI bus> on spi0
> > > > spibus0: <unknown card> at cs 0 mode 0
> > > > spibus0: <unknown card> at cs 0 mode 0
> > > > spibus0: <unknown card> at cs 1 mode 0
> > > > 
> > > > And also my driver attaches just fine:
> > > > apa102led0: <APA102> at cs 0 mode 0 on spibus0
> > > > 
> > > > And ofwdump shows the spi0 es enabled:
> > > >     Node 0x20fc: spi@7e204000
> > > >       compatible:
> > > >         62 72 63 6d 2c 62 63 6d 32 38 33 35 2d 73 70 69 00 
> > > >         'brcm,bcm2835-spi'
> > > > ...
> > > >       status:
> > > >         6f 6b 61 79 00 
> > > >         'okay'
> > > > ...
> > > > 
> > > > I'm not on the real hardware, so no LED connected to test the driver.
> > > > It would probably also attach with the &{/soc/spi@7e204000}.
> > > > But why does the &onewire entry make such a difference?
> > > > Is the whole file revoked because of an error?
> > > > I have no console connected, so I don't see loader messages.
> > > > 
> > > > Also it is a bit puzzling about the "unknown card" entries.
> > > 
> > > Ah ok.
> > > Those 4 with the spigen driver are 2 devices defined by the generic DTS,
> > > plus 2 devices from the spigen overlay - the spigen module wasn't laoded.
> > > Same for my overlay, 2 generic, plus my LED definition.
> > >       spi0 pnpinfo name=spi@7e204000 compat=brcm,bcm2835-spi
> > >         spibus0
> > >           apa102led0 pnpinfo name=apa102led0 compat=led,apa102 at bus=0 cs=0
> > >           unknown pnpinfo name=spidev@0 compat=spidev at bus=0 cs=0
> > >           unknown pnpinfo name=spidev@1 compat=spidev at bus=0 cs=1
> > > 
> > > Makes sense.
> > 
> > Ok, no surprise that &onewire can't work if it isn't defined yet.
> > 
> > owc0: <FDT GPIO attached one-wire bus> at pin 4 on gpiobus0
> > ow0: <1 Wire Bus> on owc0
> > ow0: Reset discovered bus wired wrong.
> > gpioc0: <GPIO controller> on gpio0
> > uart0: <PrimeCell UART (PL011)> mem 0x7e201000-0x7e201fff irq 23 on simplebus0
> > uart0: console (115200,n,8,1)
> > spi0: <BCM2708/2835 SPI controller> mem 0x7e204000-0x7e204fff irq 25 on simplebus0
> > spibus0: <OFW SPI bus> on spi0
> > apa102led0: <APA102> at cs 0 mode 0 on spibus0
> > spibus0: <unknown card> at cs 0 mode 0
> > spibus0: <unknown card> at cs 1 mode 0
> > 
> > With the following dts:
> > [96]cicely1> cat rpi-apa102-matrix.dts
> > /dts-v1/;
> > /plugin/;
> > 
> > &spi0 {
> >         status = "okay";
> > 
> >         apa102led0 {
> >                 compatible = "led,apa102";
> >                 reg = <0>;
> >                 spi-max-frequency = <20000000>;
> >                 status = "okay";
> >         };
> > };
> > 
> > / {
> >         fragment@0 {
> >                 target-path = "/";
> >                 __overlay__ {
> >                         onewire {
> >                                 compatible = "w1-gpio";
> >                                 gpios = <&gpio 4 1>;
> >                         };
> >                 };
> >         };
> > };
> > 
> > I tried the same without the fragment and overlay blocks, but it didn't
> > work.
> > Why does it work for the spi0?

 That's because the node spi0 already exists in the base DTB so the fdt
overlay in loader can find it and patch it.
 For the onewire you want to create a new node and you can do that
either by doing this how you did it (using fragment and target-path) or
with the new syntax :

/dts-v1/;
/plugins/;

/ {
    compatible = "your_board_compatible";
};

&{/soc} {
    onewire@0 {
         compatible = "w1-gpio";
         gpios = <&gpio 4 1>;
         status = "okay";
    };
};


 Completely untested but this should work.

> > Have to put the SD card into the real system to see if the spi and the onewire
> > works.
> > So far everything looks fine, although I don't exactly know why.
> > I understand that I would have to setup the CS pin for normal spi use.
> 
> The DS18B20 look good:
> owc0: <FDT GPIO attached one-wire bus> at pin 4 on gpiobus0
> ow0: <1 Wire Bus> on owc0
> ow_temp0: <Advanced One Wire Temperature> romid 28:b0:6b:29:05:00:00:ae on ow0
> ow_temp1: <Advanced One Wire Temperature> romid 28:04:87:29:05:00:00:8e on ow0
> ow_temp2: <Advanced One Wire Temperature> romid 28:e6:2c:29:05:00:00:8a on ow0
> ow_temp3: <Advanced One Wire Temperature> romid 28:71:34:29:05:00:00:fc on ow0
> ow_temp4: <Advanced One Wire Temperature> romid 28:99:3b:29:05:00:00:1b on ow0
> ow_temp5: <Advanced One Wire Temperature> romid 28:05:d6:29:05:00:00:e1 on ow0
> ow_temp6: <Advanced One Wire Temperature> romid 28:75:e6:1a:05:00:00:3d on ow0
> ow_temp7: <Advanced One Wire Temperature> romid 28:37:d3:29:05:00:00:b0 on ow0
> 
> [55]rpi-b# sysctl dev.ow_temp | grep temper
> dev.ow_temp.7.temperature: 24.437C
> dev.ow_temp.6.temperature: 24.125C
> dev.ow_temp.5.temperature: 24.312C
> dev.ow_temp.4.temperature: 24.312C
> dev.ow_temp.3.temperature: 23.937C
> dev.ow_temp.2.temperature: 24.250C
> dev.ow_temp.1.temperature: 24.250C
> dev.ow_temp.0.temperature: 24.312C
> 
> And the LEDs also work fine.
> 
> -- 
> B.Walter <bernd@bwct.de> http://www.bwct.de
> Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.
> _______________________________________________
> freebsd-arm@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-arm
> To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"


-- 
Emmanuel Vadot <manu@bidouilliste.com> <manu@freebsd.org>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20181108064233.fa5385cc6e7d515b5c2d6f83>