From nobody Mon Mar 07 09:05:51 2022 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 30F601A0E40C for ; Mon, 7 Mar 2022 09:06:15 +0000 (UTC) (envelope-from bscott@bunyatech.com.au) Received: from vmse02.mailcluster.com.au (vmse02.mailcluster.com.au [IPv6:2401:fc00:0:14::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4KBsyD0rPgz3khf for ; Mon, 7 Mar 2022 09:06:11 +0000 (UTC) (envelope-from bscott@bunyatech.com.au) Received: from vmcp43.digitalpacific.com.au ([101.0.119.58]) by vmse02.mailcluster.com.au with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1nR9JR-00043c-WE for freebsd-arm@freebsd.org; Mon, 07 Mar 2022 20:05:59 +1100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bunyatech.com.au; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:To:Subject:MIME-Version:Date:Message-ID:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=M86hXHJjMmnRP6i0C/j5TkwhajVN4CeB27YxUyKtey4=; b=mqXgROPbZ8oGPvyp+vObMrbmNg u490DjZ6JTJMOES7b/UnxfOH/3Pj+LavmPZy54ETM8iQdRaesOq3laT7Cjl/TiHs5sHpUxE0kR6MC o0fJjqeczx39IGiJIYQYwex3IqSV9zvMN1hiatXNdxaO2xzArHQM7xts+SRp7voERAyCQOxlQ/LQ6 uVdEGJdlveY4uQWZT8AmEpAGx8pB0JfztOCuHhLOQx7npSgLXAp2YN65kcT00HZzhl9hooG2uZqig QzxDvSEcUoNDhVBTI+2h5JkB7FiRob2rN99/F0DndMRb1m0ND+uvfb+q2JV2P/uSdYEkYb07NL8WK 74sfWUrA==; Received: from ppp221-139.static.internode.on.net ([150.101.221.139]:65124 helo=[10.0.1.106]) by vmcp43.digitalpacific.com.au with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nR9JQ-00ARlc-EG for freebsd-arm@freebsd.org; Mon, 07 Mar 2022 20:05:52 +1100 Message-ID: <9f337b5a-4e2d-a52f-2b99-4af69ad4c480@bunyatech.com.au> Date: Mon, 7 Mar 2022 20:05:51 +1100 List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: PCF8574 I2C configuration for 14.0-CURRENT on a RPi2B To: freebsd-arm@freebsd.org References: <20220306231815.6ea9b3b2@zeta.dino.sk> <20220306230947.47F0A19F60FF@mlmmj.nyi.freebsd.org> <20220307081005.6a944b46@zeta.dino.sk> From: Brian Scott In-Reply-To: <20220307081005.6a944b46@zeta.dino.sk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-User: bscott@bunyatech.com.au X-Authenticator: dovecot_plain X-Originating-IP: 101.0.119.58 X-SpamExperts-Domain: digipac-sh-outbound4.mailcluster.com.au X-SpamExperts-Username: 101.0.119.58 X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.10) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT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dfycpg/800vALz8mnE6wA706qGokY7okO g7HJIt1nJKmB0MxOKVrDfQzDgqFDumjx9w03a6SLNhJ6Q12/4jZa7jE= X-Report-Abuse-To: spam@vmse01.mailcluster.com.au X-Rspamd-Queue-Id: 4KBsyD0rPgz3khf X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bunyatech.com.au header.s=default header.b=mqXgROPb; dmarc=none; spf=pass (mx1.freebsd.org: domain of bscott@bunyatech.com.au designates 2401:fc00:0:14::6 as permitted sender) smtp.mailfrom=bscott@bunyatech.com.au X-Spamd-Result: default: False [-3.50 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[bunyatech.com.au:s=default]; HAS_XOIP(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[bunyatech.com.au]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DKIM_TRACE(0.00)[bunyatech.com.au:+]; NEURAL_HAM_SHORT(-1.00)[-0.998]; MLMMJ_DEST(0.00)[freebsd-arm]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:55803, ipnet:2401:fc00::/32, country:AU]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 7/3/22 6:10 pm, Milan Obuch wrote: > On 06 Mar 2022 23:09:14 UTC > Don Kuenz wrote: > >> Milan wrote: >> >>> could you show us what's in /dev directory? Probably no iic0 file >>> there. Also, you did not write which kernel are you using. For >>> /dev/iic0 to appear, you need either 'device iic' in your kernel >>> config or load it dynamically via 'kldload iic', in addition to >>> working i2c controller. >>> >>> Showing your 'dmesg' output helps to determine what's going on, >>> along with DTB used as well. >>> >>> All this are just basic hints what and where to look for, there are >>> probably other as well, but I hope this helps. >> root@generic:~ # dmesg | grep iic >> > OK, this means no iic device is being detected. > >> root@generic:~ # dmesg | grep gpio >> gpio0: mem 0x7e200000-0x7e2000b3 irq >> 7,8 on simplebus0 gpiobus0: on gpio0 >> gpioc0: on gpio0 >> gpioled0: on ofwbus0 >> > So, you have GPUIO controller present, you should see what's available > to control it with 'gpioctl -lv' (it uses /dev/gpioc0, which should be > present in your system according to the dmesg snippet above). > >> root@generic:~ # ls /dev/iic* >> ls: /dev/iic*: No such file or directory >> > This confirms what I wrote above, no iic device. > >> root@generic:~ # kldload iic >> kldload: can't load iic: module already loaded or in kernel >> > You are probably using GENERIC kernel, judging from host name show, and > indeed, 'device iic' is present in GENERIC kernel config. > >> root@generic:~ # kldstat >> Id Refs Address Size Name >> 1 14 0xc0000000 d6a938 kernel >> 2 1 0xc0d6b000 23358 gpioiic.ko >> 3 2 0xc0d8f000 23fcc iicbb.ko >> 4 1 0xc0db3000 24f48 umodem.ko >> 5 2 0xc0dd8000 28328 ucom.ko >> > 'kldstat -v' would show more details, device iic is presented as part > of kernel, most probably (again, judged from what you present). > >> FreeBSD 11.1 automatically creates /dev/iic (unsure of the suffices). >> But 11.1 is now obsolete. FDT replaced automatic IIC bit-bang driver >> discovery. >> You need to "wire" FDT beforehand. Although there's hints and >> configuration snippets all over the Inet, a full blown howto example >> eludes me thus far. >> > Well, I think what Mark wrote is exactly what's needed. As I did not > work with Raspberry a long time, I can't tell anything about config.txt > in /boot/msdos directory (or, in another word, in FAT partition > available for pre-FreeBSD boot loader), but I think this snippet from > your first message should not go there: > >> / { >> gpioiic0 { >> compatible = "i2c-gpio"; >> pinctrl-names = "default"; >> pinctrl-0 = <&pinctrl_gpioiic0>; >> scl-gpios = <&gpio2 3 GPIO_ACTIVE_HIGH>; >> sda-gpios = <&gpio3 5 GPIO_ACTIVE_HIGH>; >> status = "okay"; >> }; >> }; > My gut feeling here is it is just being ignored because syntactically it > does not make much sense. I may be wrong here. Do you have any pointer > where you got this snipped from? > > For me it would be meaningfull if you put this snippet into a file, > say, rpi2-gpioiic.dtso, use DTB compiler to create binary blob, > rpi2-gpioiic.dtbo. > > I would create such an overlay by putting source file into > sys/dts/arm/overlays directory and modifying Makefile in > sys/modules/dtb/rpi directory to include rpi2-gpioiic.dtso in DTSO > variable for appropriate MACHINE_ARCH. (As I see there now, file name > should be gpioiic-rpi2.dtso to match the convention used here, but this > is functionally irrelevant.) > > This way, overlay file would be created when doing 'make buildkernel' > and installed in appropriate place with 'make installkernel', but it is > possible to do just FDT overlay build, I just do not know exact > commands from my memory. > > Now, when you have your overlay in /boot/dtb/overlay directory, you > need to activate it by including its name in fdt_overlays variable in > loader.conf file present in /boot directory, so there should be line > like this: > > fdt_overlays="rpi2-gpioiic" > > I hope this is correct and usefull for you. It's based on my experience > elsewhere, but this is what works for me on my boards, albeit not RPI > (I did not use for a long time). > > Also, you can try 'ofwdump -a' command to see which devices should be > present according FDT provided to system before and after doing some > change to verify there is some effect from your changes... > > Regards, > Milan > I think I'm like most people here, trying to guess what you are wanting to achieve. Pins 2 and 3 are already avalable as iic1 provided you include: dtparam=i2c_arm in your config.txt file. There's a little more magic needed on the rpi4 but that doesn't effect you. Pin 3 (GPIO 2) is SDA and Pin 5 (GPIO 3) is SCL. This 'seems' to be the opposite of what you are doing in your dts snippet so I could be wrong, but I would have thought these functions would be hardwired in the SOC. As for your specific device, PCF8574; I don't have any direct experience but it looks like a standard IIC device that should work OK. I see there is a FreeBSD kernel module to support it but it is quite recent so probably only in CURRENT. As I said, I don't have experience with that particular device. Hope this helps, Brian