Page MenuHomeFreeBSD

asmc: add MMIO backend for T2 Macs
ClosedPublic

Authored by guest-seuros on Tue, May 19, 10:13 AM.
Referenced Files
Unknown Object (File)
Tue, Jun 9, 7:44 AM
Unknown Object (File)
Thu, Jun 4, 11:19 PM
Unknown Object (File)
Thu, Jun 4, 12:05 PM
Unknown Object (File)
Thu, Jun 4, 1:05 AM
Unknown Object (File)
Thu, May 28, 1:55 AM
Unknown Object (File)
Wed, May 27, 12:41 AM
Unknown Object (File)
Mon, May 25, 4:03 AM
Unknown Object (File)
Sat, May 23, 9:31 AM
Subscribers

Details

Summary

T2 Macs (2018+) expose the SMC via memory-mapped registers instead of
I/O ports. Add asmcmmio.c/asmcmmio.h implementing the MMIO transport:
key read/write, getinfo, getbyindex, and a poll-based wait with
exponential backoff.

The driver probes for MMIO at attach time by checking the LDKN firmware
version key; if MMIO is available it is used, otherwise the standard
I/O port backend is used.

T2 fan speeds use IEEE 754 floats instead of fpe2 fixed-point.
Per-fan manual mode uses F%dMd keys instead of the FS! bitmask.
Battery charge limit is exposed via dev.asmc.N.battery_charge_limit.

Tested on:

MacBookPro16,2 (A2251, iBridge2,10)
MacBookPro15,4 (A2159, iBridge2,8)
MacBookAir8,2  (A1932, iBridge2,5)
Mac mini 8,1   (A1993, iBridge2,7)
iMac20,2       (A2115, iBridge2,16)
iMacPro1,1     (A1862, iBridge1,1)

Diff Detail

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

Event Timeline

This looks fine, we can refactor it further later!

Did you test this on pre-T2 macs just to make sure the normal IO port path works ok?

sys/dev/asmc/asmc.c
461–463

Hm, ideally we'd be able to do this without this check. all the other drivers manage it! let me see what's causing trouble.

sys/dev/asmc/asmcvar.h
60

I'd put a space after here eventually to demarcate what's t2 / mmio.

(nowdays I use anonymous structs inside the softc to group things.)

This revision is now accepted and ready to land.Sat, May 30, 1:27 AM
ngie added a subscriber: jhb.

I'll be AFK this weekend, so I don't want to block merging this change. It would be good to address these issues before merge though to avoid having to do it after the fact.

sys/dev/asmc/asmcmmio.c
46

style(9) (there might be other instances that need to be handled elsewhere...)

70

I'm not sure if this is the right value to test with. Maybe @imp or @jhb has some thoughts here?

86–112

mtx_unlock_spin(..) is being called multiple times in multiple exit paths. I think this should use a goto.

147–156
181

Similar comment as before in this function...

212

Similar comment as before in this function.

256

Similar comment as before in this function.

sys/modules/asmc/Makefile
4

Why not asmc_mmio.c?

This revision was automatically updated to reflect the committed changes.