Page MenuHomeFreeBSD

Revamping the existing Vybrid I2C Controller Driver to Include Support for the QorIQ LX2160A Controller
ClosedPublic

Authored by pldrouin_gmail.com on Feb 22 2024, 2:23 AM.
Referenced Files
Unknown Object (File)
Wed, May 22, 2:59 AM
Unknown Object (File)
Wed, May 22, 2:05 AM
Unknown Object (File)
Tue, May 21, 12:16 PM
Unknown Object (File)
Tue, May 21, 7:13 AM
Unknown Object (File)
Tue, May 21, 4:39 AM
Unknown Object (File)
Sun, May 19, 2:25 AM
Unknown Object (File)
Sun, May 19, 2:18 AM
Unknown Object (File)
Sun, May 19, 2:18 AM

Details

Summary

The diff D43811 has been split into two parts. The first part, D44020, consists in the splitting of the original vf_i2c driver between the FDT-specific code and the I2C controller code, as well as the introduction of ACPI-specific code. The driver files are also moved to a new recommended location. This second part changes the I2C controller logic so it is more consistent with the reference manual for the controller. I used Chapter 21 from the LX2160A Reference Manual, Rev. 1, 10/2021. The code from the original vf_i2c driver did not work with the LX2160A platform. Also there were lots of delays throughout the code that did not seem necessary.

Test Plan

Basic testing SolidRun LX2160A CEX7 using the DK2 UEFI firmware in ACPI mode:
dmesg:
vf_i2c_acpi0: <Vybrid Family Inter-Integrated Circuit (I2C)> iomem 0x2000000-0x200ffff irq 5 on acpi0
vf_i2c_acpi0: Using existing bus frequency divider register value (0xA2).
iicbus0: <Philips I2C bus (ACPI-hinted)> on vf_i2c_acpi0
iicbus0: <unknown card> at addr 0x77
iic0: <I2C generic I/O> on iicbus0
vf_i2c_acpi1: <Vybrid Family Inter-Integrated Circuit (I2C)> iomem 0x2010000-0x201ffff irq 6 on acpi0
vf_i2c_acpi1: Bus frequency divider value appears unset, defaulting to low I2C bus speed.
iicbus1: <Philips I2C bus (ACPI-hinted)> on vf_i2c_acpi1
iic1: <I2C generic I/O> on iicbus1

Right after boot:
i2c -s -f /dev/iic0
19 1b 36 37 50 51 53 57 77

After selecting MUX's channel 1 (MUX address is 0x77, I used the code https://github.com/pldrouin/amc6821_controller to select channel 1 on LX2160A and to query the ID of the fan controller):
i2c -s -f /dev/iic0
18 6a 77

TZ0 is still working. Have not witnessed interference between the thermal zone and the I2C controller driver so far:
sysctl hw.acpi.thermal.tz0
hw.acpi.thermal.tz0._TSP: 50
hw.acpi.thermal.tz0._TC2: 1
hw.acpi.thermal.tz0._TC1: 1
hw.acpi.thermal.tz0._ACx: 80.1C -1 -1 -1 -1 -1 -1 -1 -1 -1
hw.acpi.thermal.tz0._CRT: 95.1C
hw.acpi.thermal.tz0._HOT: -1
hw.acpi.thermal.tz0._CR3: -1
hw.acpi.thermal.tz0._PSV: 55.1C
hw.acpi.thermal.tz0.thermal_flags: 0
hw.acpi.thermal.tz0.passive_cooling: 0
hw.acpi.thermal.tz0.active: 1
hw.acpi.thermal.tz0.temperature: 44.1C

Retrying bus scanning:
i2c -s -f /dev/iic0
18 6a 77

Support for some other systems in FDT mode should be tested as well

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

pldrouin_gmail.com edited the summary of this revision. (Show Details)

WOW. Having looked at that logic probably a year ago this is good work; also good catches on the missing unlock and NOACK for the 1 byte!

I feel sorry about all the white space change requests.

sys/dev/iicbus/controller/vybrid/vf_i2c.c
150

please restore; this is currently just noise in the diff.

188

Also just a blank line change.

260

Blank line after declarations.

265–272

spaces around the "="

277

Wonder why this line changed. Spaces in it before or after?

350

if bus [insert: is] still busy[insert .] */

400

is this 2 tabs or are there spaces in there?

485

remove empty line again

493–498

the entire new block is marked in two greens in Phabricator; are there spaces and tabs mixed?

499–500

remove empty line

505–509

remove space after last

506

remove empty line

537

remove empty line

pldrouin_gmail.com marked 13 inline comments as done.
  • Merge changes that were done to D44020 into here
  • Implementing all bz's recommendations

Also changing the references for the driver updates, based on recommendations in D44020.

sys/dev/iicbus/controller/vybrid/vf_i2c.c
277

I could not find anything different?

400

2 tabs

493–498

I don't see any spaces...

In D44021#1005017, @bz wrote:

WOW. Having looked at that logic probably a year ago this is good work; also good catches on the missing unlock and NOACK for the 1 byte!

Thanks!

  • Merging readability change from D44020.
  • Fixing a bug that was introduced in Diff 134928 (a pointer was not properly declared).
bz requested changes to this revision.Mar 5 2024, 6:49 PM
bz added inline comments.
sys/dev/iicbus/controller/vybrid/vf_i2c_acpi.c
86–87

already in D44020

sys/dev/iicbus/controller/vybrid/vf_i2c_fdt.c
97–98

already in D44020

This revision now requires changes to proceed.Mar 5 2024, 6:49 PM

-The previous diff was not generated properly w.r.t. the last version of D44020

Sorry the previous diff had been generated using an outdated version of the D44020 diff.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 29 2024, 11:14 PM
This revision was automatically updated to reflect the committed changes.