From nobody Sun Nov 7 01:30:51 2021 X-Original-To: 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 406FA184A687 for ; Sun, 7 Nov 2021 01:31:31 +0000 (UTC) (envelope-from bscott@bunyatech.com.au) Received: from out202-237-vmse04.mailcluster.com.au (out202-237-vmse04.mailcluster.com.au [202.130.44.237]) (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 4HmxXv54Lgz4nCP for ; Sun, 7 Nov 2021 01:31:27 +0000 (UTC) (envelope-from bscott@bunyatech.com.au) Received: from vmcp43.digitalpacific.com.au ([101.0.119.58]) by vmse04.mailcluster.com.au with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1mjX1K-0001Hw-E1 for arm@FreeBSD.org; Sun, 07 Nov 2021 12:31:06 +1100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bunyatech.com.au; s=default; h=Content-Type:MIME-Version:Date:Message-ID: Subject:From:To:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=oNQUFrLpsXKVDFV90vrDZi2d6C4m7aNEEjDx9UfwniQ=; b=NdpsUCvq8hHULrPr0dbC3rG3Sc NK50OPRPwlZS2CnKZu5S9OxyVs5QBFmN/P6R3lxxiaFI+37JiniiimetrbctHOyS9UkD2HbdYO0J8 kH67XxABMx22xbLoNqQGVAQBoXnHteuK0qiaJkl+m7AZyLsTsXr+32WSHNBm6bVdC95d+YL5+Tagb 8UHPdE/ZHmgN6RialwXj2yyiwgjpOgH+CZhHnWnEiYN4ACxt/kMlQRfTRQd1MzlavOzDgfVbbeYNY IEObpORD9/eoekBy3P7NAnHjEpfLBO58fdahsrDu+uB88LYtXw0NTl8s9zUi2cq3aR4SPhwiFT5VS B3Q5gR6w==; Received: from ppp221-139.static.internode.on.net ([150.101.221.139]:54342 helo=DHCP.tawonga.bunyatech.com.au) 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 1mjX1I-0091Ho-1z for arm@FreeBSD.org; Sun, 07 Nov 2021 12:30:52 +1100 To: arm@FreeBSD.org From: Brian Scott Subject: DS3231 v. MAX77620 Message-ID: Date: Sun, 7 Nov 2021 12:30:51 +1100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 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 Content-Type: multipart/alternative; boundary="------------D7C0202946C30776F40EB1B0" Content-Language: en-GB 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.05) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT/ydifHIpUA8vqHH714IZE7PUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5wc4nYp84J0ALOlq9xwlkZ8q3DvIVJlkee0A8IXTRyzX2Et Mf73dmq6uz5wtO+mEMkh55uqY3MhMgFAHq5BxPxPKYnUu29PO0GnRr2nxDh0wUJZymJLIyc3p0l5 6tovMfk00RFwXOw/04WIl9fL1lbrustl6QvTnVRP+npGCtzmuI+LQDa8vBw0SPEaOIISt35/zEhP hDec8R03E7AFnGT60MxOKVrDfQzDgqFDumjx967VZqJmzCeHtqZ+QtMgTB3ouQYW33h0HHdOkCiQ DhSZsIZXKmwzbGT4VvpTL0Eb54bT3EszvIbAbB2Zy01d/7IXjkdTeVZ2qGWx/wHRpX68fBLeHaEI 85cu3fGAkhndsLVSCjj5bHGDWlwY4hef7sPQbxc4LQoQCqummTogywOzHQrtppYmxMktfUX7kfB+ UdezYqxGMqsKjARq8PBC4qgCCg+XTOkxqQssMwQ8j2PSOXdxYBqHSPeXVuKonoSUViCv9TR+UxzL ZWL8hwGBjhoiDZaHjjUjL+gPrBh/8n4kpYzALSfDrtQHo6yRgtyrJfVAoUtwvTBLoObUYKePXRMF qinrqOw/lzYi0l4FFuwtZlgXjbDZE+fJYOw9arcVrGlWR3n0m8zK8Y2CzsDpitA+/NXmI9JRgrj+ GeXa4WgfVzeXr7v8wezHhYuWI1Wtwo89mIoZPNvZfQKw2NX8SuWtcENxDMkwFFT9ZqgxcnnLhDqq oERRnhLesaLSJcee4WHhby23jzGXN9tkd+fUq670wGM3SitNDobVNxedx/LikHkFd5rOBdI1KtvF Z9IXFW8DdAQpMwW9RYHmSXu2k4qluYkt4NvfaztV1Tfwgiehw6nIoDr0sXUZ7YZoZ/GZ+snm+tAX oDIM1zzzAjEyxKFkq+GM/QO8Gyp+bdqzS+SnUAH1+xauOSEL79WTA8PrU7fwzcbkWclKzhCVo4fz XHnQzE4pWsN9DMOCoUO6aPH3j3JiOSC6vtxuYy/MBLIoEQplMWAkZmjMZmA5tTofSLTEvyjdrFHJ cTC6qZcoE8nL97gsnYzIjqUumh4x0w47xg== X-Report-Abuse-To: spam@vmse01.mailcluster.com.au X-Rspamd-Queue-Id: 4HmxXv54Lgz4nCP X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bunyatech.com.au header.s=default header.b=NdpsUCvq; dmarc=none; spf=pass (mx1.freebsd.org: domain of bscott@bunyatech.com.au designates 202.130.44.237 as permitted sender) smtp.mailfrom=bscott@bunyatech.com.au X-Spamd-Result: default: False [-3.28 / 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)[+ip4:202.130.44.224/28]; MIME_GOOD(-0.10)[multipart/alternative,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(-0.83)[-0.834]; DKIM_TRACE(0.00)[bunyatech.com.au:+]; NEURAL_HAM_SHORT(-0.95)[-0.946]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:55803, ipnet:202.130.44.0/22, country:AU]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: Y This is a multi-part message in MIME format. --------------D7C0202946C30776F40EB1B0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi All, I just plugged a DS3231 (RTC) into a RPi4 running 13.0 Release. Not strictly necessary but I had one on my desk and it's a weekend. Added an appropriate dtb overlay and loaded the ds3231.ko via loader.conf. Done this a few times before on other boards and not expecting any drama. Instead of showing up during boot as a DS3231, it appears to be probed as a MAX77620 (which fails) and  leaves the real device unavailable to the ds3231 driver. Nov  5 17:23:00 427269616e-60 kernel: iic0: on iicbus0 Nov  5 17:23:00 427269616e-60 kernel: rtc0: at addr 0xd0 on iicbus0 Nov  5 17:23:00 427269616e-60 kernel: rtc0: Error when reading reg 0x02, rv: 35 Nov  5 17:23:00 427269616e-60 kernel: rtc0: Failed to configure RTC Nov  5 17:23:00 427269616e-60 kernel: device_attach: rtc0 attach returned 5 After some investigation I have found that all I need to provoke these messages is the dtb overlay loaded. Exactly the same messages are generated without the ds3231.ko module and even when no physical device is present. Looking at max77620_rtc_probe in sys/arm64/nvidia/tegra210/max77620_rtc.c shows: static int max77620_rtc_probe(device_t dev) { struct iicbus_ivar *dinfo; dinfo = device_get_ivars(dev); if (dinfo == NULL) return (ENXIO); if (dinfo->addr != MAX77620_RTC_I2C_ADDR << 1) return (ENXIO); device_set_desc(dev, "MAX77620 RTC"); return (BUS_PROBE_DEFAULT); } This device will attempt to attach to anything with address == MAX77620_RTC_I2C_ADDR (0x68) that is found in the device tree. However, https://learn.adafruit.com/i2c-addresses/the-list lists: 0x68 This address is really popular with real time clocks, almost all of them use 0x68! AMG8833 IR Thermal Camera Breakout (0x68 or 0x69) DS1307 RTC (0x68 only) DS3231 RTC (0x68 only) ICM-20649 Accel+Gyro (0x68 or 0x69) ITG3200 Gyro (0x68 or 0x69) MPU-9250 9-DoF IMU (0x68 or 0x69) MPU-60X0 Accel+Gyro (0x68 or 0x69) PCF8523 RTC (0x68 only) A seven bit device address is clearly not enough to uniquely identify a type of device and so shouldn't be used like this in the driver. Either the driver should use ofw_bus_search_compatible (although I believe there is no entry for the rtc in the linux device tree) or at least made conditional on the parent device (the MAX77620) being in the device tree. As I said earlier, this doesn't matter a huge amount for me at this stage because in my current application time will be configured by ntp. In the future it will matter more. While it may well be that the target device cannot be identified any other way, this doesn't belong in GENERIC. Thanks for reading, Brian Scott --------------D7C0202946C30776F40EB1B0--