History log of /openbsd-current/sys/arch/arm64/dev/aplsmc.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.25 16-Jul-2023 kettenis

Read out the system power consumption immediately after wakeup and print
it out in the DVACT_WAKEUP phase. This is a debugging aid to help us
drive down the power consumption in suspend.

ok deraadt@


# 1.24 08-Jul-2023 tobhe

Adds request_sleep(), a MI way of sending the machine to sleep in
a safe thread. Support is limited to amd64, i386 and arm64 at the
moment, macppc gets only an empty stub.

feedback from kettenis@
tested by bluhm@
ok phessler@


# 1.23 29-May-2023 deraadt

some hackery to make arm64 ramdisk compile again


# 1.22 27-May-2023 kettenis

Implement battery charge control.

ok patrick@, tobhe@


Revision tags: OPENBSD_7_3_BASE
# 1.21 09-Jan-2023 kettenis

Implement suspend on lid close.

ok tobhe@, deraadt@


# 1.20 26-Nov-2022 tobhe

Add arm64 lid_action sysctl for Apple Silicon laptops.

ok kettenis@


# 1.19 25-Nov-2022 tobhe

Disable screen backlight on Apple silicon laptops when lid is closed.

ok kettenis@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.24 08-Jul-2023 tobhe

Adds request_sleep(), a MI way of sending the machine to sleep in
a safe thread. Support is limited to amd64, i386 and arm64 at the
moment, macppc gets only an empty stub.

feedback from kettenis@
tested by bluhm@
ok phessler@


# 1.23 29-May-2023 deraadt

some hackery to make arm64 ramdisk compile again


# 1.22 27-May-2023 kettenis

Implement battery charge control.

ok patrick@, tobhe@


Revision tags: OPENBSD_7_3_BASE
# 1.21 09-Jan-2023 kettenis

Implement suspend on lid close.

ok tobhe@, deraadt@


# 1.20 26-Nov-2022 tobhe

Add arm64 lid_action sysctl for Apple Silicon laptops.

ok kettenis@


# 1.19 25-Nov-2022 tobhe

Disable screen backlight on Apple silicon laptops when lid is closed.

ok kettenis@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.23 29-May-2023 deraadt

some hackery to make arm64 ramdisk compile again


# 1.22 27-May-2023 kettenis

Implement battery charge control.

ok patrick@, tobhe@


Revision tags: OPENBSD_7_3_BASE
# 1.21 09-Jan-2023 kettenis

Implement suspend on lid close.

ok tobhe@, deraadt@


# 1.20 26-Nov-2022 tobhe

Add arm64 lid_action sysctl for Apple Silicon laptops.

ok kettenis@


# 1.19 25-Nov-2022 tobhe

Disable screen backlight on Apple silicon laptops when lid is closed.

ok kettenis@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.21 09-Jan-2023 kettenis

Implement suspend on lid close.

ok tobhe@, deraadt@


# 1.20 26-Nov-2022 tobhe

Add arm64 lid_action sysctl for Apple Silicon laptops.

ok kettenis@


# 1.19 25-Nov-2022 tobhe

Disable screen backlight on Apple silicon laptops when lid is closed.

ok kettenis@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.20 26-Nov-2022 tobhe

Add arm64 lid_action sysctl for Apple Silicon laptops.

ok kettenis@


# 1.19 25-Nov-2022 tobhe

Disable screen backlight on Apple silicon laptops when lid is closed.

ok kettenis@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.20 26-Nov-2022 tobhe

Add arm64 lid_action sysctl for Apple Silicon laptops.

ok kettenis@


# 1.19 25-Nov-2022 tobhe

Disable screen backlight on Apple silicon laptops when lid is closed.

ok kettenis@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.18 14-Nov-2022 kettenis

Turns out the power button on the Mac mini and the touchid button on the
various Macbook models generate different events. So rename the existing
constant for a "short press" of the touchid button and add support for the
power button on the Mac mini such that is can be resumed.

ok tobhe@, patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.17 10-Nov-2022 kettenis

Sprinkle some #ifdef SUSPEND to unbreak the tree.


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.16 10-Nov-2022 kettenis

Make the power button function as a wakeup button during suspend.

ok phessler@, patrick@, tobhe@


# 1.15 09-Nov-2022 kettenis

Implement wakeup interrupt support. For now this is only implemented for
aplintc(4); other arm64 interrupt controllers will follow.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.14 12-Oct-2022 kettenis

Extend struct todr_chip_handle with a todr_quality member. This allows us
to assign a quality to RTC implementation and pick the "best" RTC if a
system has multiple RTCs (or multiple interfaces to an RTC). This allows
us to prefer a battery-backed I2C RTC over an RTC that is part of the SoC
which is only running of the SoC is powered. It also allows us to
work around issues with firmware RTC interfaces that may lie to us or
even crash the system.

This change makes sure the todr_quality member of the struct is always
initialized. In most cases the quality will be set to zero; further
adjustments of the quality for specific subsystems/architectures will follow.

ok cheloha@, patrick@


Revision tags: OPENBSD_7_2_BASE
# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.13 27-Aug-2022 kettenis

Add power button support.

ok tobhe@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.12 12-Jun-2022 kettenis

The NVMe firmware distributed with the macOS 13 developer beta does not
like some of the shortcuts we've taken in the code that talks to RTKit.
In particular it does not like our NAK of the request for ioreport buffers.
So allocate the requested buffers and ACK the request instead.

However, the hardware implements a address filter between the coprocessor
that the firmware runs on and main memory. So we have to add a mapping
into this address filter such that the firmware can access these buffers.
Support for this address filter is implemented in a new aplsart(4) driver.

ok dlg@


Revision tags: OPENBSD_7_1_BASE
# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.11 25-Mar-2022 kettenis

Implement reboot/powerdown support based on nvmem cells. This works on
M1 Pro/Max machines and will hopefully continue to work on future models
by abstracting the magic flag that needs to be set using device tree
properties.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.10 15-Mar-2022 kettenis

Implement additional error checking for aplsmc_read_key() such that we can
detect when we read a key that isn't supported by the firmware.
Only provide RTC functionality if the "CLKM" key is implemented.
Fixes reading the time on machines with old SMC firmware from macOS 11.x.

ok jsg@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.9 02-Mar-2022 kettenis

Add RTC support to aplsmc(4). The SMC firmware distributed with macOS 12.x
has a method to read the counter that forms the base of the RTC. This seems
to be the preferred way to access the RTC going forward. The RTC offset is
still stored in the SPMI PMU, but we can use the nvmem interface to read
and write that. This makes the RTC work on systems with the M1 Pro/Max SoC.

Sprinkle some #ifdef SMALL_KERNEL around and enable the driver on RAMDISK
kernels.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.8 22-Feb-2022 kettenis

Fix thinko in construction of SMC key for the targeted GPIO pin.

visa@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.7 13-Feb-2022 kettenis

Add basic GPIO support.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.6 13-Jan-2022 kettenis

Implement powerdown. This involves writing a magic bit somewhere in the
address space of the SPMI PMU to prevent the machine from immediately
starting up again.

The implementaton makes aplpmu(4) provide powerdownfn(), which sets the
magic bit and then chains into cpuresetfn(). It also makes aplsmc(4)
provide cpuresetfn() to reset the machine via the SMC. Resetting via
the watchdog works as well (and will powerdown the machine if the magic
bit is set) but letting the SMC handle things might do some other
required steps.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.5 12-Jan-2022 robert

toggle hw.power based on the ACDI SMR key if available

ok kettenis@


# 1.4 12-Jan-2022 robert

add three new SMC sensors to get information about the power supply status
and remaining time to battery full and empty and feed these values to
apm(4)

ok kettenis@


# 1.3 12-Jan-2022 kettenis

Fix array index. Spotted by robert@


# 1.2 12-Jan-2022 jsg

maxumum -> maximum


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@


# 1.1 10-Jan-2022 kettenis

Add aplsmc(4), a driver for the SMC found on Apple M1 SoCs.

The SMC implements a lot of functionality. For now the driver only
implements a bunch of sensors. This is a small subset of the sensors
that are made available by the SMC as we don't know what measurments
are provided for most sensors.

ok patrick@