Hector Martin [Tue, 18 Jan 2022 11:22:32 +0000 (20:22 +0900)]
Merge branches 'refs/heads/bits/000-devicetree', 'refs/heads/bits/020-t6000-bringup', 'refs/heads/bits/030-misc', 'refs/heads/bits/060-spi', 'refs/heads/bits/070-audio', 'refs/heads/bits/080-wifi' and 'refs/heads/bits/090-spi-hid' into asahi
Janne Grunau [Fri, 10 Dec 2021 18:38:43 +0000 (19:38 +0100)]
WIP: HID: transport: spi: add Apple SPI transport
Keyboard and trackpad of Apple Sillicon SoCs (M1, M1 Pro/Max) laptops
are are HID devices connected via SPI.
This is the same protocol as implemented by applespi.c. It was not
noticed that protocol is a transport for HID. Adding support for ACPI
based Intel MacBooks will be done in a separate commit.
How HID is mapped in this protocol is not yet fully understood.
Microsoft has a specification for HID over SPI [1] incompatible with the
transport protocol used by Apple.
[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/hid-over-spi
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Thu, 16 Dec 2021 00:17:48 +0000 (01:17 +0100)]
HID: magicmouse: add support for Macbook trackpads
The trackpads in Macbooks beginning in 2015 are HID devices connected
over SPI. On Intel Macbooks they are currently supported by applespi.c.
This chang adds support for the trackpads on Apple Silicon Macbooks
starting in late 2020. They use a new HID over SPI transport driver.
The touch report format differs from USB/BT Magic Trackpads. It is the
same format as the type 4 format supported by bcm5974.c.
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Wed, 15 Dec 2021 23:15:30 +0000 (00:15 +0100)]
HID: magicmouse: use ops function pointers for input functionality
Will be used for supporting MacBook trackpads connected via SPI.
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Wed, 15 Dec 2021 23:12:35 +0000 (00:12 +0100)]
HID: magicmouse: use struct input_mt_pos for X/Y
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Wed, 15 Dec 2021 23:10:51 +0000 (00:10 +0100)]
HID: magicmouse: use a define of the max number of touch contacts
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Wed, 5 Jan 2022 22:27:34 +0000 (23:27 +0100)]
HID: apple: add Fn key mapping for Macbook Pro with touchbar
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Sun, 19 Dec 2021 17:08:15 +0000 (18:08 +0100)]
HID: apple: add Fn key mapping for Apple silicon MacBooks
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Thu, 16 Dec 2021 20:15:31 +0000 (21:15 +0100)]
HID: apple: add support for internal keyboards
Apple MacBook keyboards started using HID over SPI in 2015. With the
addition of the SPI HID transport they can be supported by this driver.
Support all product ids over with the Apple SPI vendor id for now.
Individual product ids will have to be added for a correct Fn/function
key mapping.
Enable by default on the Apple Arm platform.
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Sun, 12 Dec 2021 19:40:04 +0000 (20:40 +0100)]
HID: add device IDs for Apple SPI HID devices
Apple Silicon based laptop use SPI as transport for HID. Add support for
SPI-based HID devices and and Apple keyboard and trackpad devices.
Intel based laptops using the keyboard input driver applespi use the
same HID over SPI protocol and can be supported later.
This requires SPI keyboard/mouse HID types since Apple's intenal
keyboards/trackpads use the same product id.
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Sat, 11 Dec 2021 11:21:04 +0000 (12:21 +0100)]
spi: parse CS delay values from DT
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Sat, 11 Dec 2021 10:48:56 +0000 (11:48 +0100)]
spi: dt-bindings: add CS delay peripheral-specific properties
These properties are modelled after Linux' struct spi_device cs_setup,
cs_hold and cs_inactive delay values.
Signed-off-by: Janne Grunau <j@jannau.net>
Hector Martin [Sat, 25 Dec 2021 15:53:37 +0000 (00:53 +0900)]
brcmfmac: common: Add support for external calibration blobs
The calibration blob for a chip is normally stored in SROM and loaded
internally by the firmware. However, Apple ARM64 platforms instead store
it as part of platform configuration data, and provide it via the Apple
Device Tree. We forward this into the Linux DT in the bootloader.
Add support for taking this blob from the DT and loading it into the
dongle. The loading mechanism is the same as used for the CLM and TxCap
blobs.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sat, 25 Dec 2021 15:26:10 +0000 (00:26 +0900)]
brcmfmac: pcie: Load and provide TxCap blobs
These blobs are named .txcap_blob, and exist alongside the existing
.clm_blob files. Use the existing firmware machinery to provide them to
the core.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sat, 25 Dec 2021 15:25:00 +0000 (00:25 +0900)]
brcmfmac: common: Add support for downloading TxCap blobs
The TxCap blobs are additional data blobs used on Apple devices, and
are uploaded analogously to CLM blobs. Add core support for doing this.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:52:03 +0000 (17:52 +0900)]
brcmfmac: pcie: Add IDs/properties for BCM4387
This chip is present on Apple M1 Pro/Max (t600x) platforms:
* maldives (apple,j314s): MacBook Pro (14-inch, M1 Pro, 2021)
* maldives (apple,j314c): MacBook Pro (14-inch, M1 Max, 2021)
* madagascar (apple,j316s): MacBook Pro (16-inch, M1 Pro, 2021)
* madagascar (apple,j316c): MacBook Pro (16-inch, M1 Max, 2021)
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 6 Jan 2022 10:45:15 +0000 (19:45 +0900)]
brcmflac: cfg80211: Use WSEC to set SAE password
Using the WSEC command instead of sae_password seems to be the supported
mechanism on newer firmware, and also how the brcmdhd driver does it.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Mon, 20 Dec 2021 10:15:58 +0000 (19:15 +0900)]
brcmfmac: cfg80211: Pass the PMK in binary instead of hex
Apparently the hex passphrase mechanism does not work on newer
chips/firmware (e.g. BCM4387). It seems there was a simple way of
passing it in binary all along, so use that and avoid the hexification.
OpenBSD has been doing it like this from the beginning, so this should
work on all chips.
Also clear the structure before setting the PMK. This was leaking
uninitialized stack contents to the device.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Mon, 20 Dec 2021 09:16:33 +0000 (18:16 +0900)]
brcmfmac: cfg80211: Add support for PMKID_V3 operations
Add support for the new PMKID_V3 API, which allows performing PMKID
mutations individually, instead of requiring the driver to keep track of
the full list. This new API is required by at least BCM4387.
Note that PMKID_V2 is not implemented yet.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Mon, 20 Dec 2021 09:15:10 +0000 (18:15 +0900)]
brcmfmac: feature: Add support for setting feats based on WLC version
The "wlc_ver" iovar returns information on the WLC and EPI versions.
This can be used to determine whether the PMKID_V2 and _V3 features are
supported.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sun, 19 Dec 2021 18:39:44 +0000 (03:39 +0900)]
brcmfmac: cfg80211: Add support for scan params v2
This new API version is required for at least the BCM4387 firmware. Add
support for it, with a fallback to the v1 API.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:14:59 +0000 (17:14 +0900)]
brcmfmac: chip: Handle 1024-unit sizes for TCM blocks
BCM4387 has trailing odd-sized blocks as part of TCM which have
their size described as a multiple of 1024 instead of 8192. Handle this
so we can compute the TCM size properly.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Mon, 20 Dec 2021 11:00:57 +0000 (20:00 +0900)]
brcmfmac: chip: Only disable D11 cores; handle an arbitrary number
At least on BCM4387, the D11 cores are held in reset on cold startup and
firmware expects to release reset itself. Just assert reset here and let
firmware deassert it. Premature deassertion results in the firmware
failing to initialize properly some of the time, with strange AXI bus
errors.
Also, BCM4387 has 3 cores, up from 2. The logic for handling that is in
brcmf_chip_ai_resetcore(), but since we aren't using that any more, just
handle it here.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:51:52 +0000 (17:51 +0900)]
brcmfmac: pcie: Perform correct BCM4364 firmware selection
This chip exists in two revisions (B2=r3 and B3=r4) on different
platforms, and was added without regard to doing proper firmware
selection or differentiating between them. Fix this to have proper
per-revision firmwares and support Apple NVRAM selection.
Revision B2 is present on at least these Apple T2 Macs:
kauai: MacBook Pro 15" (Touch/2018-2019)
maui: MacBook Pro 13" (Touch/2018-2019)
lanai: Mac mini (Late 2018)
ekans: iMac Pro 27" (5K, Late 2017)
And these non-T2 Macs:
nihau: iMac 27" (5K, 2019)
Revision B3 is present on at least these Apple T2 Macs:
bali: MacBook Pro 16" (2019)
trinidad: MacBook Pro 13" (2020, 4 TB3)
borneo: MacBook Pro 16" (2019, 5600M)
kahana: Mac Pro (2019)
kahana: Mac Pro (2019, Rack)
hanauma: iMac 27" (5K, 2020)
kure: iMac 27" (5K, 2020, 5700/XT)
Fixes:
24f0bd136264 ("brcmfmac: add the BRCM 4364 found in MacBook Pro 15,2")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:51:31 +0000 (17:51 +0900)]
brcmfmac: pcie: Add IDs/properties for BCM4377
This chip is present on at least these Apple T2 Macs:
* tahiti: MacBook Pro 13" (2020, 2 TB3)
* formosa: MacBook Pro 13" (Touch/2019)
* fiji: MacBook Air 13" (Scissor, 2020)
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:50:15 +0000 (17:50 +0900)]
brcmfmac: pcie: Add IDs/properties for BCM4355
This chip is present on at least these Apple T2 Macs:
* hawaii: MacBook Air 13" (Late 2018)
* hawaii: MacBook Air 13" (True Tone, 2019)
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 23 Dec 2021 10:30:17 +0000 (19:30 +0900)]
brcmfmac: pcie: Provide a buffer of random bytes to the device
Newer Apple firmwares on chipsets without a hardware RNG require the
host to provide a buffer of 256 random bytes to the device on
initialization. This buffer is present immediately before NVRAM,
suffixed by a footer containing a magic number and the buffer length.
This won't affect chips/firmwares that do not use this feature, so do it
unconditionally.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 23 Dec 2021 10:51:36 +0000 (19:51 +0900)]
brcmfmac: acpi: Add support for fetching Apple ACPI properties
On DT platforms, the module-instance and antenna-sku-info properties
are passed in the DT. On ACPI platforms, module-instance is passed via
the analogous Apple device property mechanism, while the antenna SKU
info is instead obtained via an ACPI method that grabs it from
non-volatile storage.
Add support for this, to allow proper firmware selection on Apple
platforms.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 23 Dec 2021 10:51:11 +0000 (19:51 +0900)]
ACPI / property: Support strings in Apple _DSM props
The Wi-Fi module in Apple machines has a "module-instance" device
property that specifies the platform type and is used for firmware
selection. Its value is a string, so add support for string values in
acpi_extract_apple_properties().
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:46:40 +0000 (17:46 +0900)]
brcmfmac: pcie: Add IDs/properties for BCM4378
This chip is present on Apple M1 (t8103) platforms:
* atlantisb (apple,j274): Mac mini (M1, 2020)
* honshu (apple,j293): MacBook Pro (13-inch, M1, 2020)
* shikoku (apple,j313): MacBook Air (M1, 2020)
* capri (apple,j456): iMac (24-inch, 4x USB-C, M1, 2020)
* santorini (apple,j457): iMac (24-inch, 2x USB-C, M1, 2020)
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:25:35 +0000 (17:25 +0900)]
brcmfmac: pcie: Support PCIe core revisions >= 64
These newer PCIe core revisions include new sets of registers that must
be used instead of the legacy ones. Introduce a brcmf_pcie_reginfo to
hold the specific register offsets and values to use for a given
platform, and change all the register accesses to indirect through it.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:39:04 +0000 (17:39 +0900)]
brcmfmac: msgbuf: Increase RX ring sizes to 1024
Newer chips used on Apple platforms have a max_rxbufpost greater than
512, which causes warnings when brcmf_msgbuf_rxbuf_data_fill tries to
put more entries in the ring than will fit. Increase the ring sizes
to 1024.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 23 Dec 2021 13:32:08 +0000 (22:32 +0900)]
brcmfmac: firmware: Allow platform to override macaddr
On Device Tree platforms, it is customary to be able to set the MAC
address via the Device Tree, as it is often stored in system firmware.
This is particularly relevant for Apple ARM64 platforms, where this
information comes from system configuration and passed through by the
bootloader into the DT.
Implement support for this by fetching the platform MAC address and
adding or replacing the macaddr= property in nvram. This becomes the
dongle's default MAC address.
On platforms with an SROM MAC address, this overrides it. On platforms
without one, such as Apple ARM64 devices, this is required for the
firmware to boot (it will fail if it does not have a valid MAC at all).
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:45:21 +0000 (17:45 +0900)]
brcmfmac: pcie: Perform firmware selection for Apple platforms
On Apple platforms, firmware selection uses the following elements:
Property Example Source
============== ======= ========================
* Chip name 4378 Device ID
* Chip revision B1 OTP
* Platform shikoku DT (ARM64) or ACPI (x86)
* Module type RASP OTP
* Module vendor m OTP
* Module version 6.11 OTP
* Antenna SKU X3 DT (ARM64) or ACPI (x86)
In macOS, these firmwares are stored using filenames in this format
under /usr/share/firmware/wifi:
C-4378__s-B1/P-shikoku-X3_M-RASP_V-m__m-6.11.txt
To prepare firmwares for Linux, we rename these to a scheme following
the existing brcmfmac convention:
brcmfmac<chip><lower(rev)>-pcie.apple,<platform>-<mod_type>-\
<mod_vendor>-<mod_version>-<antenna_sku>.txt
The NVRAM uses all the components, while the firmware and CLM blob only
use the chip/revision/platform/antenna_sku:
brcmfmac<chip><lower(rev)>-pcie.apple,<platform>-<antenna_sku>.bin
e.g.
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11-X3.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-X3.bin
In addition, since there are over 1000 files in total, many of which are
symlinks or outright duplicates, we deduplicate and prune the firmware
tree to reduce firmware filenames to fewer dimensions. For example, the
shikoku platform (MacBook Air M1 2020) simplifies to just 4 files:
brcm/brcmfmac4378b1-pcie.apple,shikoku.clm_blob
brcm/brcmfmac4378b1-pcie.apple,shikoku.bin
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-u.txt
This reduces the total file count to around 170, of which 75 are
symlinks and 95 are regular files: 7 firmware blobs, 27 CLM blobs, and
61 NVRAM config files. We also slightly process NVRAM files to correct
some formatting issues.
To handle this, the driver must try the following path formats when
looking for firmware files:
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11-X3.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m-6.11.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP-m.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-RASP.txt
brcm/brcmfmac4378b1-pcie.apple,shikoku-X3.txt *
brcm/brcmfmac4378b1-pcie.apple,shikoku.txt
* Not relevant for NVRAM, only for firmware/CLM.
The chip revision nominally comes from OTP on Apple platforms, but it
can be mapped to the PCI revision number, so we ignore the OTP revision
and continue to use the existing PCI revision mechanism to identify chip
revisions, as the driver already does for other chips. Unfortunately,
the mapping is not consistent between different chip types, so this has
to be determined experimentally.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:27:19 +0000 (17:27 +0900)]
brcmfmac: of: Fetch Apple properties
On Apple ARM64 platforms, firmware selection requires two properties
that come from system firmware: the module-instance (aka "island", a
codename representing a given hardware platform) and the antenna-sku.
We map Apple's module codenames to board_types in the form
"apple,<module-instance>".
The mapped board_type is added to the DTS file in that form, while the
antenna-sku is forwarded by our bootloader from the Apple Device Tree
into the FDT. Grab them from the DT so firmware selection can use
them.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:26:34 +0000 (17:26 +0900)]
brcmfmac: pcie: Read Apple OTP information
On Apple platforms, the One Time Programmable ROM in the Broadcom chips
contains information about the specific board design (module, vendor,
version) that is required to select the correct NVRAM file. Parse this
OTP ROM and extract the required strings.
Note that the user OTP offset/size is per-chip. This patch does not add
any chips yet.
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Fri, 7 Jan 2022 02:14:44 +0000 (11:14 +0900)]
brcmfmac: firmware: Support passing in multiple board_types
Apple platforms have firmware and config files identified with multiple
dimensions. We want to be able to find the most specific firmware
available for any given platform, progressively trying more general
firmwares.
To do this, first add support for passing in multiple board_types,
which will be tried in sequence.
Since this will cause more log spam due to missing firmwares, also
switch the secondary firmware fecthes to use the _nowarn variant, which
will not log if the firmware is not found.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:13:49 +0000 (17:13 +0900)]
brcmfmac: pcie/sdio/usb: Get CLM blob via standard firmware mechanism
Now that the firmware fetcher can handle per-board CLM files, load the
CLM blob alongside the other firmware files and change the bus API to
just return the existing blob, instead of fetching the filename.
This enables per-board CLM blobs, which are required on Apple platforms.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sat, 18 Dec 2021 11:52:04 +0000 (20:52 +0900)]
brcmfmac: firmware: Handle per-board clm_blob files
Teach brcm_alt_fw_paths to correctly split off variable length
extensions, and enable alt firmware lookups for the CLM blob firmware
requests.
Apple platforms have per-board CLM blob files.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sun, 26 Dec 2021 13:04:09 +0000 (22:04 +0900)]
dt-bindings: net: bcm4329-fmac: Add Apple properties & chips
This binding is currently used for SDIO devices, but these chips are
also used as PCIe devices on DT platforms and may be represented in the
DT. Re-use the existing binding and add chip compatibles used by Apple
T2 and M1 platforms (the T2 ones are not known to be used in DT
platforms, but we might as well document them).
Then, add properties required for firmware selection and calibration on
M1 machines.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Fri, 7 Jan 2022 03:30:46 +0000 (12:30 +0900)]
brcmfmac: of: Use devm_kstrdup for board_type & check for errors
This was missing a NULL check, and we can collapse the strlen/alloc/copy
into a devm_kstrdup().
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:43:03 +0000 (17:43 +0900)]
brcmfmac: pcie: Read the console on init and shutdown
This allows us to get console messages if the firmware crashed during
early init, or if an operation failed and we're about to shut down.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sat, 25 Dec 2021 15:24:02 +0000 (00:24 +0900)]
brcmfmac: fwil: Constify iovar name arguments
Make all the iovar name arguments const char * instead of just char *.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:44:00 +0000 (17:44 +0900)]
brcmfmac: pcie: Fix crashes due to early IRQs
The driver was enabling IRQs before the message processing was
initialized. This could cause IRQs to come in too early and crash the
driver. Instead, move the IRQ enable and hostready to a bus preinit
function, at which point everything is properly initialized.
Fixes:
9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:39:28 +0000 (17:39 +0900)]
brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio
The alignment check was wrong (e.g. & 4 instead of & 3), and the logic
was also inefficient if the length was not a multiple of 4, since it
would needlessly fall back to copying the entire buffer bytewise.
We already have a perfectly good memcpy_toio function, so just call that
instead of rolling our own copy logic here. brcmf_pcie_init_ringbuffers
was already using it anyway.
Fixes:
9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 10:32:16 +0000 (19:32 +0900)]
brcmfmac: pcie: Declare missing firmware files in pcie.c
Move one of the declarations from sdio.c to pcie.c, since it makes no
sense in the former (SDIO support is optional), and add missing ones.
Fixes:
75729e110e68 ("brcmfmac: expose firmware config files through modinfo")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Fri, 7 Jan 2022 02:41:49 +0000 (11:41 +0900)]
brcmfmac: firmware: Do not crash on a NULL board_type
This unbreaks support for USB devices, which do not have a board_type
to create an alt_path out of and thus were running into a NULL
dereference.
Fixes:
5ff013914c62 ("brcmfmac: firmware: Allow per-board firmware binaries")
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Mon, 3 Jan 2022 06:07:58 +0000 (15:07 +0900)]
brcmfmac: firmware: Allocate space for default boardrev in nvram
If boardrev is missing from the NVRAM we add a default one, but this
might need more space in the output buffer than was allocated. Ensure
we have enough padding for this in the buffer.
Fixes:
46f2b38a91b0 ("brcmfmac: insert default boardrev in nvram data if missing")
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:44:51 +0000 (17:44 +0900)]
brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
This avoids leaking memory if brcmf_chip_get_raminfo fails. Note that
the CLM blob is released in the device remove path.
Fixes:
82f93cf46d60 ("brcmfmac: get chip's default RAM info during PCIe setup")
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:07:40 +0000 (17:07 +0900)]
pcie-apple: Fix MSI handling for new phandles
To be added to AICv2 patchset...
Signed-off-by: Hector Martin <marcan@marcan.st>
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
ASoC: cs42l42: Bypass device ID check
The cs42l42 driver is also applicable to the cs42l83 part.
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
HACK: ASoC: cs42l42: Disable regcache
There's some issue that has yet to be pinned down.
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
HACK: ASoC: tas2770: Set no of channels to 1
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
ASoC: tas2770: Set correct FSYNC polarity
Fix setting of FSYNC polarity for DAI formats other than I2S. Also
add support for polarity inversion.
Signed-off-by: Martin Povišer <povik@protonmail.com>
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
ASoC: apple-mca: Add platform driver for Apple SoCs
Add ASoC platform driver for the MCA block found on Apple SoCs
from the "Apple Silicon" family.
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
dt-bindings: dma: Add apple,admac binding
The Audio DMA Controller (ADMAC) is used to load and store audio
samples from/to system memory. It is present on Apple SoCs from
the "Apple Silicon" family.
Signed-off-by: Martin Povišer <povik@protonmail.com>
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
dmaengine: apple-admac: Add Apple ADMAC driver
Add driver for Audio DMA Controller present on Apple SoCs
from the "Apple Silicon" family.
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
clk: clk-apple-nco: Add driver for Apple NCO
Add a common clock driver for NCO blocks found on Apple SoCs where they
are typically the generators of audio clocks.
Signed-off-by: Martin Povišer <povik@protonmail.com>
Martin Povišer [Wed, 8 Dec 2021 19:42:35 +0000 (20:42 +0100)]
dt-bindings: clock: Add Apple NCO
The NCO block found on Apple SoCs is a programmable clock generator
performing fractional division of a high frequency input clock.
Signed-off-by: Martin Povišer <povik@protonmail.com>
Hector Martin [Thu, 9 Dec 2021 12:55:49 +0000 (21:55 +0900)]
spi: apple: Add driver for Apple SPI controller
This SPI controller is present in Apple SoCs such as the M1 (t8103) and
M1 Pro/Max (t600x). It is a relatively straightforward design with two
16-entry FIFOs, arbitrary transfer sizes (up to 2**32 - 1) and fully
configurable word size up to 32 bits. It supports one hardware CS line
which can also be driven via the pinctrl/GPIO driver instead, if
desired. TX and RX can be independently enabled.
There are a surprising number of knobs for tweaking details of the
transfer, most of which we do not use right now. Hardware CS control
is available, but we haven't found a way to make it stay low across
multiple logical transfers, so we just use software CS control for now.
There is also a shared DMA offload coprocessor that can be used to handle
larger transfers without requiring an IRQ every 8-16 words, but that
feature depends on a bunch of scaffolding that isn't ready to be
upstreamed yet, so leave it for later.
The hardware shares some register bit definitions with spi-s3c24xx which
suggests it has a shared legacy with Samsung SoCs, but it is too
different to warrant sharing a driver.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sun, 12 Dec 2021 02:46:33 +0000 (11:46 +0900)]
dt-bindings: spi: apple,spi: Add binding for Apple SPI controllers
The Apple SPI controller is present in SoCs such as the M1 (t8103) and
M1 Pro/Max (t600x). This controller uses one IRQ and one clock, and
doesn't need any special properties, so the binding is trivial.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sun, 12 Dec 2021 03:28:41 +0000 (12:28 +0900)]
MAINTAINERS: Add apple-spi driver & binding files
This Apple SPI controller is present on Apple ARM SoCs (t8103/t6000).
Splitting this change from the binding/driver commits to avoid merge
conflicts with other things touching this section, as usual.
Signed-off-by: Hector Martin <marcan@marcan.st>
Sven Peter [Thu, 9 Dec 2021 16:22:55 +0000 (17:22 +0100)]
WIP: nvme-apple: add initial Apple SoC NVMe driver
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Thu, 9 Dec 2021 16:22:53 +0000 (17:22 +0100)]
WIP: soc: apple: rtkit: Add RTKit library
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Thu, 9 Dec 2021 16:22:52 +0000 (17:22 +0100)]
soc: apple: sart: Add SART driver
The NVMe co-processor on the Apple M1 uses a DMA address filter called
SART for some DMA transactions. This adds a simple driver used to
configure the memory regions from which DMA transactions are allowed.
Co-developed-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Thu, 9 Dec 2021 16:22:50 +0000 (17:22 +0100)]
dt-bindings: soc: apple: Add ANS NVMe binding
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Thu, 9 Dec 2021 16:22:49 +0000 (17:22 +0100)]
dt-bindings: soc: apple: Add Apple SART bindings
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Sun, 7 Nov 2021 10:21:20 +0000 (11:21 +0100)]
usb: dwc3: Add role switch reset quirk for Apple DWC3
As mad as it sounds, the dwc3 controller present on the Apple M1 must be
reset and reinitialized whenever a device is unplugged from the root port.
The only reliable unplug/plug notification available comes from the USB
PD controller through the role-switch infrastructure.
This is required for at least two reasons:
- The USB2 D+/D- lines are connected through a stateful eUSB2 repeater
which in turn is controlled by a variant of the TI TPS6598x USB PD
chip. When the USB PD controller detects a hotplug event it resets
the eUSB2 repeater. Afterwards, no new device is recognized before
the DWC3 core and PHY are reset as well.
- It's possible to completely break the dwc3 controller by switching
it to device mode and unplugging the cable at just the wrong time.
Even a CORESOFTRESET is not enough to allow new devices again.
The only workaround is to trigger a hard reset of the entire
dwc3 core.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Sun, 7 Nov 2021 10:21:19 +0000 (11:21 +0100)]
dt-bindings: usb: Add Apple dwc3 bindings
Apple Silicon SoCs such as the M1 have multiple USB controllers based on
the Synopsys DesignWare USB3 controller.
References to the ATC PHY required for SuperSpeed are left out for now
until support has been upstreamed as well.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Hector Martin [Sat, 8 Jan 2022 12:04:12 +0000 (21:04 +0900)]
usb: typec: port-mapper: Do not crash on non-ACPI systems
If a match is not found in the ACPI bus, just return instead of trying
to link a NULL component.
Fixes:
730b49aac426 ("usb: typec: port-mapper: Convert to the component framework")
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Sun, 19 Sep 2021 17:23:11 +0000 (02:23 +0900)]
tty: serial: samsung_tty: Support runtime PM
This allows idle UART devices to be suspended using the standard
runtime-PM framework. The logic is modeled after stm32-usart.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 21 Dec 2021 08:07:40 +0000 (17:07 +0900)]
pcie-apple: Fix MSI handling for new phandles
To be added to AICv2 patchset...
Signed-off-by: Hector Martin <marcan@marcan.st>
Sven Peter [Tue, 2 Nov 2021 17:10:53 +0000 (18:10 +0100)]
iommu/io-pgtable: Add DART PTE support for t6000
The DARTs present in the M1 Pro/Max SoC support a 42bit physical address
space by shifting the paddr and extending its mask inside the PTE.
They also come with mandatory sub-page protection now which we just
configure to always allow access to the entire page. This feature is
already present but optional on the previous DARTs which allows to
unconditionally configure it.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Tue, 2 Nov 2021 17:10:52 +0000 (18:10 +0100)]
iommu: dart: Support t6000 variant
The M1 Pro/Max SoCs come with a new variant of DART which supports a
larger physical address space with a slightly different PTE format.
Pass through the correct paddr address space size to the io-pgtable code
which will take care of the rest.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Sven Peter [Tue, 2 Nov 2021 17:10:51 +0000 (18:10 +0100)]
dt-bindings: iommu: dart: add t6000 compatible
The M1 Max/Pro SoCs come with a new DART variant that is incompatible with
the previous one. Add a new compatible for those.
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Hector Martin [Tue, 7 Dec 2021 11:25:57 +0000 (20:25 +0900)]
irqchip/apple-aic: Add support for AICv2
Introduce support for the new AICv2 hardware block in t6000/t6001 SoCs.
It seems these blocks are missing the information required to compute
the event register offset in the capability registers, so we specify
that in the DT.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 7 Dec 2021 11:17:57 +0000 (20:17 +0900)]
irqchip/apple-aic: Support multiple dies
Multi-die support in AICv2 uses several sets of IRQ registers. Introduce
a die count and compute the register group offset based on the die ID
field of the hwirq number, as reported by the hardware.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 7 Dec 2021 11:06:22 +0000 (20:06 +0900)]
irqchip/apple-aic: Dynamically compute register offsets
This allows us to support AIC variants with different numbers of IRQs
based on capability registers.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 7 Dec 2021 10:53:07 +0000 (19:53 +0900)]
irqchip/apple-aic: Switch to irq_domain_create_tree and sparse hwirqs
This allows us to directly use the hardware event number as the hwirq
number. Since IRQ events have bit 16 set (type=1), FIQs now move to
starting at hwirq number 0.
This will become more important once multi-die support is introduced in
a later commit.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 7 Dec 2021 08:14:46 +0000 (17:14 +0900)]
irqchip/apple-aic: Add Fast IPI support
The newer AICv2 present in t600x SoCs does not have legacy IPI support
at all. Since t8103 also supports Fast IPIs, implement support for this
first. The legacy IPI code is left as a fallback, so it can be
potentially used by older SoCs in the future.
The vIPI code is shared; only the IPI firing/acking bits change for Fast
IPIs.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 7 Dec 2021 15:54:40 +0000 (00:54 +0900)]
dt-bindings: interrupt-controller: apple,aic: Add apple,aic2 support
This new incompatible revision of the AIC peripheral introduces
multi-die support. To handle that, we introduce an optional
4-argument interrupt-cells form.
Also add an apple,event-reg property to specify the offset of the event
register. Inexplicably, the capability registers allow us to compute
other register offsets, but not this one. This allows us to keep
forward-compatibility with future SoCs that will likely implement
different die counts, thus shifting the event register. Apple do the
same thing in their device tree...
Signed-off-by: Hector Martin <marcan@marcan.st>
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
t8103-jXXX.dts: Add nodes for audio through jack
Insert nodes for audio through jack into DTs of all t8103-based devices.
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
HACK: dt: Shuffle MCA power domains
It appears that specifying more than one power-domain in the MCA node
in devicetree doesn't work with the power-management-naive MCA driver.
Work around that by putting up some fabulated parent-child
relationships to have the kernel enable all the MCA power domains.
Martin Povišer [Sat, 20 Nov 2021 20:06:06 +0000 (21:06 +0100)]
dt: t8103.dtsi: Put in audio-related device nodes
Hector Martin [Tue, 21 Dec 2021 08:07:17 +0000 (17:07 +0900)]
arm64: dts: apple: Add WiFi module and antenna properties
Add the new module-instance/antenna-sku properties required to select
WiFi firmwares properly to all board device trees.
Signed-off-by: Hector Martin <marcan@marcan.st>
Janne Grunau [Thu, 25 Nov 2021 23:24:15 +0000 (00:24 +0100)]
arm64: dts: apple: t8103: Add spi3/keyboard nodes
Enables keyboard and touchpad input on MacBook Air (M1, 2020) and
MacBook Pro (13-inch, M1, 2020).
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Thu, 11 Nov 2021 20:31:21 +0000 (21:31 +0100)]
arm64: dts: apple: t600x: Add spi3 and keyboard nodes
Enables keyboard and touchpad input on MacBook Pro (14/16-inch,
M1 Pro/Max, 2021).
Signed-off-by: Janne Grunau <j@jannau.net>
Hector Martin [Thu, 9 Dec 2021 12:58:29 +0000 (21:58 +0900)]
arm64: dts: apple: t600x-j314-j316: Add NOR flash node
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 9 Dec 2021 12:58:10 +0000 (21:58 +0900)]
arm64: dts: apple: t6000: Add spi1 node
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 2 Dec 2021 11:20:35 +0000 (20:20 +0900)]
arm64: dts: apple: t6000: Add watchdog node
Add the watchdog node which also enables reboot support on t600x.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Fri, 26 Nov 2021 06:37:23 +0000 (15:37 +0900)]
arm64: dts: apple: t8103: Add dwc3 nodes
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Wed, 10 Nov 2021 11:45:14 +0000 (20:45 +0900)]
arm64: dts: apple: t6001: Add ANS2 nodes
This adds support for the NVMe controller.
Signed-off-by: Hector Martin <marcan@marcan.st>
Sven Peter [Thu, 9 Dec 2021 16:22:51 +0000 (17:22 +0100)]
arm64: dts: apple: t8103: Add ANS2 nodes
Hector Martin [Wed, 10 Nov 2021 10:08:25 +0000 (19:08 +0900)]
arm64: dts: apple: Add J314 and J316 devicetrees
These are the 14-inch and 16-inch 2021 MacBooks, in both M1 Pro and M1
Max variants (t6000 and t6001).
Signed-off-by: Hector Martin <marcan@marcan.st>
Janne Grunau [Thu, 25 Nov 2021 20:42:34 +0000 (21:42 +0100)]
arm64: dts: apple: t6001: Add i2c1 to i2c5 device nodes
feel free to squash without attribution
Devices are disabled until they gain an target on the i2c bus.
Signed-off-by: Janne Grunau <j@jannau.net>
Janne Grunau [Thu, 25 Nov 2021 20:24:02 +0000 (21:24 +0100)]
arm64: dts: apple: t6001: add aop, nub and smc pinctrl nodes
feel free to squash without attribution
Signed-off-by: Janne Grunau <j@jannau.net>
Hector Martin [Sun, 21 Nov 2021 12:04:00 +0000 (21:04 +0900)]
arm64: dts: apple: t600x: Add PMGR nodes
t6000 is like t6001, but lacks one entire PMGR node and all of its
domains.
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Wed, 10 Nov 2021 10:07:41 +0000 (19:07 +0900)]
arm64: dts: apple: Add initial t6000/t6001 DTs
t6000 is a cut-down version of t6001, so the former just includes the
latter and disables the missing bits (of which there are none, at the
moment).
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Thu, 2 Dec 2021 11:37:25 +0000 (20:37 +0900)]
Makefile: Add -asahi EXTRAVERSION
Signed-off-by: Hector Martin <marcan@marcan.st>
Hector Martin [Tue, 18 Jan 2022 11:15:19 +0000 (20:15 +0900)]
Merge tag 'asahi-soc-maintainers-5.17' into asahi-soc/next
Apple SoC MAINTAINERS updates for 5.17.
Adds the watchdog driver MAINTAINERS changes. The driver itself is
already merged.
This branch is based on asahi-soc-dt-5.17-v2 to avoid a merge conflict.