diff --git a/Documentation/devicetree/bindings/phy/apple,s5l8942x-usb-phy.yaml b/Documentation/devicetree/bindings/phy/apple,s5l8942x-usb-phy.yaml index b9cf8b7d2a9a2f..cc30150ab9e07c 100644 --- a/Documentation/devicetree/bindings/phy/apple,s5l8942x-usb-phy.yaml +++ b/Documentation/devicetree/bindings/phy/apple,s5l8942x-usb-phy.yaml @@ -4,7 +4,7 @@ $id: http://devicetree.org/schemas/phy/apple,s5l8942x-usb-phy.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Apple S5L8942X USB and HSIC PHY +title: Apple S5L8942X and S5L8950X USB and HSIC PHY maintainers: - Shayne Legault <8741557+shaynelegault@users.noreply.github.com> @@ -14,19 +14,28 @@ description: | and reset. The first PHY argument selects the output: 0 for USB OTG, 1 for the HSIC host. The HSIC supplies power the attached peripheral. + On the S5L8950X (A6) the PHY can also hold the PMGR power-state gates + of the OTG block (UPERF, USB-OTG and USBREG), which it switches on at + probe and never off again. Its PMGR offsets and tuning differ from the + A5's, so it has no S5L8940X fallback. + select: properties: compatible: contains: - const: apple,s5l8942x-otgphy + enum: + - apple,s5l8942x-otgphy + - apple,s5l8950x-otgphy required: - compatible properties: compatible: - items: - - const: apple,s5l8942x-otgphy - - const: apple,s5l8940x-otgphy + oneOf: + - items: + - const: apple,s5l8942x-otgphy + - const: apple,s5l8940x-otgphy + - const: apple,s5l8950x-otgphy reg: items: @@ -34,11 +43,20 @@ properties: - description: USB complex control registers clocks: - maxItems: 1 - description: PHY reference clock, at 12, 24 or 48 MHz + minItems: 1 + items: + - description: PHY reference clock, at 12, 24 or 48 MHz + - description: UPERF power-state gate + - description: USB-OTG power-state gate + - description: USBREG power-state gate clock-names: - const: ref + minItems: 1 + items: + - const: ref + - const: uperf + - const: otg + - const: usbreg '#phy-cells': const: 1 @@ -67,3 +85,11 @@ examples: clock-names = "ref"; #phy-cells = <1>; }; + - | + phy@36000000 { + compatible = "apple,s5l8950x-otgphy"; + reg = <0x36000000 0x1000>, <0x3f108000 0x1000>; + clocks = <&refclk24mhz>, <&uperf_ps>, <&usb_otg_ps>, <&usbreg_ps>; + clock-names = "ref", "uperf", "otg", "usbreg"; + #phy-cells = <1>; + }; diff --git a/Documentation/devicetree/bindings/usb/dwc2.yaml b/Documentation/devicetree/bindings/usb/dwc2.yaml index 759eb83a36fb39..a838702328e789 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.yaml +++ b/Documentation/devicetree/bindings/usb/dwc2.yaml @@ -20,6 +20,7 @@ allOf: enum: - apple,s5l8940x-dwc2 - apple,s5l8942x-dwc2 + - apple,s5l8950x-dwc2 then: required: - phys @@ -32,6 +33,11 @@ allOf: properties: compatible: oneOf: + - items: + - const: apple,s5l8950x-dwc2 + - const: apple,s5l8942x-dwc2 + - const: apple,s5l8940x-dwc2 + - const: snps,dwc2 - items: - const: apple,s5l8942x-dwc2 - const: apple,s5l8940x-dwc2 diff --git a/arch/arm/boot/dts/apple/Makefile b/arch/arm/boot/dts/apple/Makefile index ba7ec8501b0577..a60735b0905136 100644 --- a/arch/arm/boot/dts/apple/Makefile +++ b/arch/arm/boot/dts/apple/Makefile @@ -2,3 +2,5 @@ dtb-$(CONFIG_ARCH_APPLE_S5L) += s5l8942x-p105.dtb dtb-$(CONFIG_ARCH_APPLE_S5L) += s5l8945x-j1.dtb dtb-$(CONFIG_ARCH_APPLE_S5L) += s5l8940x-k93.dtb +dtb-$(CONFIG_ARCH_APPLE_S5L) += s5l8950x-n41.dtb +dtb-$(CONFIG_ARCH_APPLE_S5L) += s5l8950x-n42.dtb diff --git a/arch/arm/boot/dts/apple/s5l8950x-5.dtsi b/arch/arm/boot/dts/apple/s5l8950x-5.dtsi new file mode 100644 index 00000000000000..0d8858f3ece075 --- /dev/null +++ b/arch/arm/boot/dts/apple/s5l8950x-5.dtsi @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Apple iPhone 5 (N41 / iPhone5,1 and N42 / iPhone5,2, S5L8950X / Apple A6): + * what the two models share. Apple sells them as one phone that differs in + * its cellular bands, which Linux does not drive, and the N42's ADT names + * its touch controller "multi-touch,n41". Everything below was read from + * the N42: the iPhone5,2 iOS 8.4.1 (12H321) ADT as iBoot passes it, and the + * iPhone5,2 10.3.4 (14G61) ADT and kernelcache. N41 is untested. + */ + +#include "s5l8950x.dtsi" + +/ { + aliases { + serial0 = &uart6; + }; +}; + +/* + * UART6 is the debug port. Production iBEC leaves it gated off unless + * debug-uarts is set, so there is no earlycon on it: the serial driver + * switches the gate on before its first register access. + */ +&uart6_ps { + status = "okay"; +}; + +&uart6 { + status = "okay"; +}; diff --git a/arch/arm/boot/dts/apple/s5l8950x-n41.dts b/arch/arm/boot/dts/apple/s5l8950x-n41.dts new file mode 100644 index 00000000000000..d1b4f7622346e6 --- /dev/null +++ b/arch/arm/boot/dts/apple/s5l8950x-n41.dts @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Apple iPhone 5 (GSM) -- iPhone5,1 / N41AP / S5L8950X (Apple A6). + * + * The same phone as the N42 for everything Linux drives (s5l8950x-5.dtsi). + * Untested: every value was read from an N42. + */ + +/dts-v1/; + +#include "s5l8950x-5.dtsi" + +/ { + compatible = "apple,n41ap", "apple,s5l8950x", "apple,arm"; + model = "Apple iPhone 5 (GSM) (iPhone5,1)"; + + chosen { + bootargs = "console=tty0 console=ttyGS0,115200 lpj=6500000 root=/dev/ram0 rw rootwait panic=10 loglevel=8 ignore_loglevel g_cdc.host_addr=02:10:5a:51:00:01 g_cdc.dev_addr=02:10:5a:51:00:02"; + + /* Overwritten by m1n1 kboot_prepare_dt() when an initrd is loaded. */ + linux,initrd-start = <0x88000000>; + linux,initrd-end = <0x88000000>; + }; +}; diff --git a/arch/arm/boot/dts/apple/s5l8950x-n42.dts b/arch/arm/boot/dts/apple/s5l8950x-n42.dts new file mode 100644 index 00000000000000..57acd61ab757f3 --- /dev/null +++ b/arch/arm/boot/dts/apple/s5l8950x-n42.dts @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Apple iPhone 5 (Global) -- iPhone5,2 / N42AP / S5L8950X (Apple A6). + * + * Booted from a jailbroken iOS through kDFU: iBSS, then a patched iBEC + * starts m1n1 (armv7) with bootx, and m1n1 starts Linux. + */ + +/dts-v1/; + +#include "s5l8950x-5.dtsi" + +/ { + compatible = "apple,n42ap", "apple,s5l8950x", "apple,arm"; + model = "Apple iPhone 5 (Global) (iPhone5,2)"; + + chosen { + /* + * console=tty0 draws the boot log on the 640x1136 portrait + * simple-framebuffer; ttyGS0 stays last so /dev/console is the + * USB CDC ACM serial gadget. + */ + bootargs = "console=tty0 console=ttyGS0,115200 lpj=6500000 root=/dev/ram0 rw rootwait panic=10 loglevel=8 ignore_loglevel g_cdc.host_addr=02:10:5a:52:00:01 g_cdc.dev_addr=02:10:5a:52:00:02"; + + /* Overwritten by m1n1 kboot_prepare_dt() when an initrd is loaded. */ + linux,initrd-start = <0x88000000>; + linux,initrd-end = <0x88000000>; + }; +}; diff --git a/arch/arm/boot/dts/apple/s5l8950x.dtsi b/arch/arm/boot/dts/apple/s5l8950x.dtsi new file mode 100644 index 00000000000000..84d98ff6de92ff --- /dev/null +++ b/arch/arm/boot/dts/apple/s5l8950x.dtsi @@ -0,0 +1,418 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Apple A6 (S5L8950X) SoC core device tree include. + * + * Shared by iPhone 5 (N41 / iPhone5,1 and N42 / iPhone5,2). + * + * Every address, IRQ, and PMGR power-state offset below was verified from the + * decrypted iPhone5,2 iOS 8.4.1 (12H321) Apple Device Tree, iBEC, and + * kernelcache (AppleS5L8950XPerformanceController + USB PHY init). + * + * What sits outside the SoC (PMU, touch, display panel, Wi-Fi, Bluetooth, + * battery) is described by the iPhone 5 include, s5l8950x-5.dtsi. + */ + +/ { + #address-cells = <1>; + #size-cells = <1>; + interrupt-parent = <&aic>; + + /* + * 1 GiB DRAM at 0x80000000..0xc0000000. m1n1 overwrites reg at boot + * from iBoot's boot_args (phys_base, mem_size). + */ + memory@80000000 { + device_type = "memory"; + reg = <0x80000000 0x3fc00000>; + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* + * iBoot's scanout buffer. Base and size are patched by m1n1 + * at boot from boot_args.video together with framebuffer0. + */ + fb_region: framebuffer@bf000000 { + reg = <0xbf000000 0x400000>; + no-map; + }; + + /* + * First page of DRAM: physical 0 aliases here when a secondary + * core leaves reset via PMGR+0x1214/+0x1220 (platsmp.c). + */ + cpu_reset_page: cpu-reset@80000000 { + reg = <0x80000000 0x1000>; + no-map; + }; + + /* + * iBoot's 16 KiB persistent RAM (its console and panic data), + * which the boot chain keeps across a reset. + */ + pram_region: pram@bfffc000 { + reg = <0xbfffc000 0x4000>; + no-map; + }; + }; + + /* + * simple-framebuffer over iBoot's live CLCD scanout (640x1136 portrait + * Retina panel on iPhone 5). m1n1 patches reg/width/height/stride + * from boot_args.video before entering Linux. + */ + framebuffer0: framebuffer@bf000000 { + compatible = "simple-framebuffer"; + reg = <0xbf000000 0x400000>; + width = <640>; + height = <1136>; + stride = <2560>; + format = "a8r8g8b8"; + memory-region = <&fb_region>; + status = "okay"; + }; + + /* + * Dual Apple Swift (ARMv7s) cores with integrated architectural L2 + * cache (no external PL310, no Cortex-A9 SCU). + * + * ADT /cpus/cpu0 reg = 0, /cpus/cpu1 reg = 1. XNU indexes cores by + * MPIDR Aff0 (0 and 1, Aff1 = 0). Secondary bring-up uses PMGR + * +0x1214 (START) and +0x1220 (RUN), verified from + * AppleS5L8950XPerformanceController in iOS 8.4.1 kernelcache. + */ + cpus { + #address-cells = <1>; + #size-cells = <0>; + apple,cpu-reset-page = <&cpu_reset_page>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "apple,swift", "arm,armv7"; + reg = <0x0>; + enable-method = "apple,pmgr-core"; + }; + + cpu1: cpu@1 { + device_type = "cpu"; + compatible = "apple,swift", "arm,armv7"; + reg = <0x1>; + enable-method = "apple,pmgr-core"; + }; + }; + + refclk24mhz: clock-24000000 { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; + }; + + soc: soc@30000000 { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x30000000 0x10000000>; + + /* Apple Interrupt Controller rev 1 (ADT /arm-io/aic). */ + aic: interrupt-controller@f200000 { + compatible = "aic,1"; + reg = <0xf200000 0x10000>; + interrupt-controller; + #interrupt-cells = <1>; + #address-cells = <0>; + apple,main-cpus = <2>; + }; + + /* + * 24 MHz watchdog counter (ADT /arm-io/wdt, wdt-version 1): + * used as wall clocksource, sched_clock, udelay timer, and + * CPU frequency calibration reference. + */ + wdt: timer@f103020 { + compatible = "apple,s5l8940x-wdt-timer"; + reg = <0xf103020 0x10>; + interrupts = <4>; + clock-frequency = <24000000>; + status = "okay"; + }; + + /* + * Power/clock manager (ADT /arm-io/pmgr). Kept disabled so no + * generic driver gates boot-critical clocks; platsmp.c looks + * up the node directly for PMGR_CORE_STOP/START/RUN + * (+0x1210/+0x1214/+0x1220). + */ + pmgr: power-management@f100000 { + compatible = "apple,s5l8950x-pmgr", "apple,s5l8940x-pmgr", "syscon"; + reg = <0xf100000 0x7000>; + status = "disabled"; + }; + + /* + * USB OTG gates (ADT usb-complex clock-gates; device-clocks + * UPERF id 0x04 index 0x21, USB-OTG id 0x35 index 0x22, USBREG + * id 0x06 index 0x27). Registered with the OTG PHY, which holds + * them from probe. The host side's USB-EHCI (+0x108c) and + * USB-OHCI0 (+0x1094) stay with the PHY's host power-on and are + * not clocks, so nothing at late_initcall can switch them off. + */ + uperf_ps: uperf-ps@f101084 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101084 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uperf_ps"; + }; + + usb_otg_ps: usb-otg-ps@f101088 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101088 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "usb_otg_ps"; + }; + + usbreg_ps: usbreg-ps@f10109c { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf10109c 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "usbreg_ps"; + }; + + /* + * Individual PMGR power-state gates (offset = 0x1000 + ps_idx * 4 + * from the 81-entry x 44-byte ADT pmgr device-clocks table). + * + * Every gate is disabled here and enabled by the board next to + * the consumer that claims it. A registered gate nobody holds + * is switched off by clk_disable_unused at late_initcall, and + * iBoot leaves most of these on: on N42 that cut took the USB + * OTG PHY with it ("PHY reference clock selection did not + * latch", gadget start -EIO) although no USB gate is among + * them. An unregistered gate keeps the state iBoot left. + */ + /* + * CDMA (ADT id 0x31, index 0x1f). No Linux driver claims it yet, + * so no board should enable it: it must stay as iBoot left it. + */ + cdma_ps: cdma-ps@f10107c { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf10107c 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "cdma_ps"; + status = "disabled"; + }; + + spi1_ps: spi1-ps@f1010e8 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf1010e8 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "spi1_ps"; + status = "disabled"; + }; + + uart1_ps: uart1-ps@f1010fc { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf1010fc 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uart1_ps"; + status = "disabled"; + }; + + uart2_ps: uart2-ps@f101100 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101100 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uart2_ps"; + status = "disabled"; + }; + + uart3_ps: uart3-ps@f101104 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101104 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uart3_ps"; + status = "disabled"; + }; + + uart4_ps: uart4-ps@f101108 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101108 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uart4_ps"; + status = "disabled"; + }; + + uart5_ps: uart5-ps@f10110c { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf10110c 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uart5_ps"; + status = "disabled"; + }; + + uart6_ps: uart6-ps@f101110 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101110 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "uart6_ps"; + status = "disabled"; + }; + + i2c0_ps: i2c0-ps@f101118 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101118 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "i2c0_ps"; + status = "disabled"; + }; + + i2c1_ps: i2c1-ps@f10111c { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf10111c 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "i2c1_ps"; + status = "disabled"; + }; + + i2c2_ps: i2c2-ps@f101120 { + compatible = "apple,s5l8940x-pmgr-clk-gate"; + #clock-cells = <0>; + reg = <0xf101120 0x4>; + clocks = <&refclk24mhz>; + clock-output-names = "i2c2_ps"; + status = "disabled"; + }; + + /* + * GPIO / pinctrl block (ADT /arm-io/gpio, "gpio,s5l8950x", + * "gpio,s5l8930x"): 29 ports = 232 pins, IRQ 119. + */ + gpio: gpio@fa00000 { + compatible = "apple,s5l8950x-gpio", "apple,s5l8940x-gpio"; + reg = <0xfa00000 0x1000>; + interrupts = <119>; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + #address-cells = <0>; + pin-count = <232>; + interrupt-groups = <1>; + status = "okay"; + }; + + /* + * UARTs (ADT /arm-io/uart1..uart6; S5L8950X has no uart0). + * uart6 is the board's boot-console / debug-console port. + */ + uart1: serial@2600000 { + compatible = "apple,s5l8940x-uart", "apple,s5l-uart", + "samsung,s3c6400-uart"; + reg = <0x2600000 0x1000>; + interrupts = <22>; + clocks = <&uart1_ps>, <&refclk24mhz>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + + uart2: serial@2700000 { + compatible = "apple,s5l8940x-uart", "apple,s5l-uart", + "samsung,s3c6400-uart"; + reg = <0x2700000 0x1000>; + interrupts = <23>; + clocks = <&uart2_ps>, <&refclk24mhz>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + + uart3: serial@2800000 { + compatible = "apple,s5l8940x-uart", "apple,s5l-uart", + "samsung,s3c6400-uart"; + reg = <0x2800000 0x1000>; + interrupts = <24>; + clocks = <&uart3_ps>, <&refclk24mhz>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + + uart4: serial@2900000 { + compatible = "apple,s5l8940x-uart", "apple,s5l-uart", + "samsung,s3c6400-uart"; + reg = <0x2900000 0x1000>; + interrupts = <25>; + clocks = <&uart4_ps>, <&refclk24mhz>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + + uart5: serial@2a00000 { + compatible = "apple,s5l8940x-uart", "apple,s5l-uart", + "samsung,s3c6400-uart"; + reg = <0x2a00000 0x1000>; + interrupts = <26>; + clocks = <&uart5_ps>, <&refclk24mhz>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + + uart6: serial@2b00000 { + compatible = "apple,s5l8940x-uart", "apple,s5l-uart", + "samsung,s3c6400-uart"; + reg = <0x2b00000 0x1000>; + interrupts = <27>; + clocks = <&uart6_ps>, <&refclk24mhz>; + clock-names = "uart", "clk_uart_baud0"; + status = "disabled"; + }; + + /* + * USB OTG PHY (ADT /arm-io/otgphyctrl + /arm-io/usb-complex). + * Uses S5L8950X PMGR gates (+0x1084/+0x1088/+0x109c) and + * OPHY_UOTGTUNE1 = 0x749. The PHY holds the three OTG gates + * from probe. + */ + otgphy: phy@6000000 { + compatible = "apple,s5l8950x-otgphy"; + reg = <0x6000000 0x1000>, /* otgphyctrl */ + <0xf108000 0x1000>; /* usb-complex */ + #phy-cells = <1>; + clocks = <&refclk24mhz>, <&uperf_ps>, <&usb_otg_ps>, + <&usbreg_ps>; + clock-names = "ref", "uperf", "otg", "usbreg"; + status = "okay"; + }; + + /* + * DWC2 USB-OTG gadget controller (ADT /arm-io/usb-complex/usb-device: + * reg 0x06100000, IRQ 11, num-of-eps 14, fifo-depth 0x820). + */ + dwc2: usb@6100000 { + compatible = "apple,s5l8950x-dwc2", "apple,s5l8942x-dwc2", + "apple,s5l8940x-dwc2", "snps,dwc2"; + reg = <0x6100000 0x10000>; + interrupts = <11>; + phys = <&otgphy 0>; + phy-names = "usb2-phy"; + dr_mode = "peripheral"; + g-rx-fifo-size = <512>; + g-np-tx-fifo-size = <128>; + g-tx-fifo-size = <128 128 128 128 128 128 128 128>; + status = "okay"; + }; + }; +}; diff --git a/arch/arm/mach-apple/Kconfig b/arch/arm/mach-apple/Kconfig index 63f344f2985527..f0cb1cb44458e0 100644 --- a/arch/arm/mach-apple/Kconfig +++ b/arch/arm/mach-apple/Kconfig @@ -18,6 +18,8 @@ menuconfig ARCH_APPLE_S5L select COMMON_CLK select GENERIC_IRQ_CHIP select HAVE_ARM_TWD if SMP + select WATCHDOG + select WATCHDOG_CORE help Support for Apple's 32-bit ARM application processors, as used in iOS devices from the A4 through the A6X. diff --git a/arch/arm/mach-apple/apple.c b/arch/arm/mach-apple/apple.c index 647bfecf9fc315..9ff189c6bd5daa 100644 --- a/arch/arm/mach-apple/apple.c +++ b/arch/arm/mach-apple/apple.c @@ -17,6 +17,7 @@ #include void __init apple_s5l_pmccntr_enable_counter(void); +bool apple_s5l_has_pmccntr(void); void __init apple_s5l_pmccntr_init(unsigned long rate); unsigned long __init apple_s5l_calibrate_cpu_hz(void); void __init apple_s5l_wdt_clocksource_init(void); @@ -29,6 +30,10 @@ static void __init apple_s5l_reserve(void) { phys_addr_t phys = P105_FB_PHYS & ~(SZ_1M - 1); + /* The A6 boards describe iBoot's scanout in reserved-memory. */ + if (of_machine_is_compatible("apple,s5l8950x")) + return; + memblock_remove(phys, P105_FB_PHYS - phys); } @@ -100,6 +105,20 @@ static void __init apple_s5l_init_time(void) { unsigned long cpu_hz; + /* + * The A6's Swift cores are Apple's own (MIDR implementer 'a', 0x613f0001 + * on the iPhone 5) and have no ARM PMU: the first CP15 c9 write is an + * undefined instruction, and Linux died on it in time_init. They get the + * 24 MHz watchdog counter only (clocksource, sched_clock); the tick + * comes from the AIC timer. + */ + if (!apple_s5l_has_pmccntr()) { + pr_info("No ARM PMU on this core (MIDR %#x): no cycle counter, no PMU tick\n", + read_cpuid_id()); + apple_s5l_wdt_clocksource_init(); + return; + } + /* Enable the cycle counter first, then measure it against the watchdog's * exact 24 MHz reference, and only then register the clocksource -- its * rate used to be a hardcoded 1 GHz guess, which made all wall-clock time @@ -121,6 +140,7 @@ static void __init apple_s5l_init_time(void) static const char * const apple_s5l_dt_compat[] __initconst = { "apple,s5l8940x", "apple,s5l8942x", + "apple,s5l8950x", NULL }; diff --git a/arch/arm/mach-apple/apple_sof_clkevt.c b/arch/arm/mach-apple/apple_sof_clkevt.c index 6c4b4694810922..5dc3b35243e941 100644 --- a/arch/arm/mach-apple/apple_sof_clkevt.c +++ b/arch/arm/mach-apple/apple_sof_clkevt.c @@ -53,6 +53,8 @@ #include #include +bool apple_s5l_has_pmccntr(void); /* pmccntr.c */ + /* One SOF per 125 us microframe at high speed. */ #define SOF_TICK_HZ 8000 @@ -171,13 +173,19 @@ static struct clock_event_device sof_clkevt = { static int __init apple_sof_clkevt_register(void) { unsigned int before = READ_ONCE(sof_seen); - u32 start = pmccntr(); unsigned long cpu_hz = 1000000000UL; /* only used to size the spin */ + u32 start; if (sof_superseded) { pr_err("SOF-TIMER: not needed -- the AIC timer is the tick, SOF interrupts stay off.\n"); return 0; } + /* The spin below counts CPU cycles; the A6 has no cycle counter */ + if (!apple_s5l_has_pmccntr()) { + pr_err("SOF-TIMER: no cycle counter on this core, not registering\n"); + return 0; + } + start = pmccntr(); while ((u32)(pmccntr() - start) < cpu_hz * 2) { /* up to ~2 s */ if (READ_ONCE(sof_seen) != before) diff --git a/arch/arm/mach-apple/apple_wdt_clkevt.c b/arch/arm/mach-apple/apple_wdt_clkevt.c index bd58731f7ceaec..19f86ae9fe2dce 100644 --- a/arch/arm/mach-apple/apple_wdt_clkevt.c +++ b/arch/arm/mach-apple/apple_wdt_clkevt.c @@ -37,6 +37,7 @@ #define pr_fmt(fmt) "apple-wdt: " fmt #include +#include #include #include #include @@ -47,7 +48,9 @@ #include #include #include +#include #include +#include #include #include @@ -56,6 +59,7 @@ #define WDT_BITE_TIME 0x04 #define WDT_CTRL 0x0c #define WDT_CTRL_RESET_EN BIT(2) +#define WDT_CTRL_ENABLE BIT(3) #define APPLE_WDT_REF_HZ 24000000UL static inline u32 apple_pmccntr(void) @@ -110,6 +114,59 @@ static struct delay_timer apple_wdt_delay = { .freq = APPLE_WDT_REF_HZ, }; +/* + * The A6 family's watchdog counter runs only while WDT_CTRL_ENABLE is set, + * and its bite needs ENABLE with RESET_EN. The A6X (S5L8955X) is of that + * family -- its ADT pmgr names "pmgr,s5l8950x" after its own -- and has the + * same wdt-version 1 block, so it gets the A6's handling too. + */ +static bool apple_wdt_counter_gated(void) +{ + return of_machine_is_compatible("apple,s5l8950x") || + of_machine_is_compatible("apple,s5l8955x"); +} + +/* + * Map the watchdog's 24 MHz counter (once). The A5 does this from the CPU + * calibration; the A6 has no cycle counter to calibrate, so its clocksource + * init maps it here directly. + */ +static bool __init apple_wdt_map(void) +{ + struct device_node *np; + + if (wdt_base) + return true; + np = of_find_compatible_node(NULL, NULL, "apple,s5l8940x-wdt-timer"); + if (!np) { + pr_err("no wdt node\n"); + return false; + } + + wdt_base = of_iomap(np, 0); + of_node_put(np); + if (!wdt_base) { + pr_err("cannot map wdt counter\n"); + return false; + } + + /* + * On S5L8950X (A6), WDT_CUR_TIME only ticks while WDT_CTRL_ENABLE (bit 3) + * is set. If the bootloader left CTRL=0 (no watchdog armed), enable the + * counter without RESET_EN so calibration and the clocksource tick; if + * a boot watchdog is already armed (0xc), leave it intact. + */ + if (apple_wdt_counter_gated()) { + u32 ctrl = readl_relaxed(wdt_base + WDT_CTRL); + + if (!(ctrl & WDT_CTRL_ENABLE)) { + writel(ctrl | WDT_CTRL_ENABLE, wdt_base + WDT_CTRL); + (void)readl(wdt_base + WDT_CTRL); + } + } + return true; +} + /** * apple_s5l_wdt_clocksource_init - wall time that survives idle * @@ -119,7 +176,7 @@ static struct delay_timer apple_wdt_delay = { */ void __init apple_s5l_wdt_clocksource_init(void) { - if (!wdt_base) { + if (!apple_wdt_map()) { pr_err("CS: counter not mapped, wall time stays on PMCCNTR (wrong in idle)\n"); return; } @@ -138,28 +195,22 @@ void __init apple_s5l_wdt_clocksource_init(void) */ unsigned long __init apple_s5l_calibrate_cpu_hz(void) { - struct device_node *np; u32 w0, w1, c0, c1, wd, cd; u64 hz; - np = of_find_compatible_node(NULL, NULL, "apple,s5l8940x-wdt-timer"); - if (!np) { - pr_err("CALIB: no wdt node; CPU rate stays a guess\n"); - return 0; - } - - wdt_base = of_iomap(np, 0); - of_node_put(np); - if (!wdt_base) { - pr_err("CALIB: cannot map wdt counter\n"); + if (!apple_wdt_map()) return 0; - } /* ~50 ms of reference ticks is plenty and costs nothing at boot. */ w0 = readl_relaxed(wdt_base + WDT_CUR_TIME); c0 = apple_pmccntr(); - while ((u32)(readl_relaxed(wdt_base + WDT_CUR_TIME) - w0) < APPLE_WDT_REF_HZ / 20) - cpu_relax(); + { + u32 guard = 0; + + while ((u32)(readl_relaxed(wdt_base + WDT_CUR_TIME) - w0) < APPLE_WDT_REF_HZ / 20 && + ++guard < 50000000U) + cpu_relax(); + } w1 = readl_relaxed(wdt_base + WDT_CUR_TIME); c1 = apple_pmccntr(); /* deliberately not unmapped: the clocksource lives on this counter */ @@ -191,11 +242,24 @@ unsigned long __init apple_s5l_calibrate_cpu_hz(void) */ static int apple_wdt_restart(struct sys_off_data *data) { - u32 now = readl_relaxed(wdt_base + WDT_CUR_TIME); + if (apple_wdt_counter_gated()) { + /* + * S5L8950X (A6) requires both WDT_CTRL_ENABLE and WDT_CTRL_RESET_EN + * (0xc), following iBEC's wdt_enable() sequence. + */ + writel(0, wdt_base + WDT_CTRL); + writel(APPLE_WDT_REF_HZ / 1000, wdt_base + WDT_BITE_TIME); + writel(0x80000000U, wdt_base + WDT_CUR_TIME); + writel(WDT_CTRL_ENABLE | WDT_CTRL_RESET_EN, wdt_base + WDT_CTRL); + writel(0, wdt_base + WDT_CUR_TIME); + (void)readl(wdt_base + WDT_CTRL); + } else { + u32 now = readl_relaxed(wdt_base + WDT_CUR_TIME); - writel_relaxed(now + APPLE_WDT_REF_HZ / 1000, wdt_base + WDT_BITE_TIME); - writel(WDT_CTRL_RESET_EN, wdt_base + WDT_CTRL); - (void)readl(wdt_base + WDT_CTRL); + writel_relaxed(now + APPLE_WDT_REF_HZ / 1000, wdt_base + WDT_BITE_TIME); + writel(WDT_CTRL_RESET_EN, wdt_base + WDT_CTRL); + (void)readl(wdt_base + WDT_CTRL); + } mdelay(500); pr_emerg("the watchdog did not reset the machine\n"); return NOTIFY_DONE; @@ -210,16 +274,30 @@ static int apple_wdt_restart(struct sys_off_data *data) */ static int apple_wdt_reboot_notify(struct notifier_block *nb, unsigned long action, void *data) { - if (action == SYS_RESTART) { + if (action == SYS_RESTART || action == SYS_POWER_OFF || action == SYS_HALT) { u32 now = readl_relaxed(wdt_base + WDT_CUR_TIME); + u32 ctrl = apple_wdt_counter_gated() ? + (WDT_CTRL_ENABLE | WDT_CTRL_RESET_EN) : WDT_CTRL_RESET_EN; writel_relaxed(now + 10 * APPLE_WDT_REF_HZ, wdt_base + WDT_BITE_TIME); - writel(WDT_CTRL_RESET_EN, wdt_base + WDT_CTRL); - pr_info("restart: the watchdog will reset the machine in 10 s at the latest\n"); + writel(ctrl, wdt_base + WDT_CTRL); + pr_info("%s: the watchdog will reset the machine in 10 s at the latest\n", + action == SYS_RESTART ? "restart" : action == SYS_POWER_OFF ? "power off" : "halt"); } return NOTIFY_DONE; } +/* + * Power off: this board has no way to cut its own power, and a phone booted + * from iOS that "powers off" belongs back in iOS. So a power off is the + * restart, at once -- at a low priority, so a real power-off driver wins. + */ +static int apple_wdt_power_off(struct sys_off_data *data) +{ + pr_emerg("power off: no power-off control here; restarting through the watchdog\n"); + return apple_wdt_restart(data); +} + static struct notifier_block apple_wdt_reboot_nb = { .notifier_call = apple_wdt_reboot_notify, .priority = INT_MAX, /* before anything else gets to hang */ @@ -238,6 +316,134 @@ static int __init apple_wdt_restart_init(void) pr_err("no restart handler: %ld\n", PTR_ERR(h)); else pr_info("restart through the watchdog's bite\n"); + h = register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_LOW, + apple_wdt_power_off, NULL); + if (IS_ERR(h)) + pr_err("no power-off handler: %ld\n", PTR_ERR(h)); return 0; } device_initcall(apple_wdt_restart_init); + +/* + * The watchdog as a watchdog: /dev/watchdog for systemd (RuntimeWatchdogSec=) + * and the kernel's own pinger until userspace opens it, so a healthy system + * runs for ever and a hung one is reset -- into iOS, on a phone started from + * it -- within the timeout, with no button pressed. + * + * A ping moves the bite forward: BITE_TIME = CUR_TIME + timeout. CUR_TIME is + * never written: it is the clocksource. The comparator fires when the counter + * reaches BITE_TIME, not while it is above it (iBoot enables RESET_EN with + * CUR_TIME at 0x80000000 and a small BITE_TIME, and nothing resets), so a bite + * past the 32-bit wrap (about every 179 s) is simply where the counter gets to + * after wrapping; the reboot notifier above relies on the same. Timeouts stop + * at 178 s, one turn of the counter. + * + * It is started at boot whatever the boot loader left (m1n1 hands over with a + * window armed), and it has no way out: a poweroff or halt, which this + * hardware cannot do, ends in the bite too. apple_wdt_timeout=0 on the + * command line leaves the watchdog as the boot loader left it, for debugging. + */ +static unsigned int apple_wdt_timeout = 60; +core_param(apple_wdt_timeout, apple_wdt_timeout, uint, 0444); + +static u32 apple_wdt_ctrl_on(void) +{ + /* the A6 family's counter only runs with ENABLE (see apple_wdt_map()) */ + return apple_wdt_counter_gated() ? WDT_CTRL_ENABLE : 0; +} + +static int apple_wdt_ping(struct watchdog_device *wdd) +{ + u32 now = readl_relaxed(wdt_base + WDT_CUR_TIME); + u32 bite = now + wdd->timeout * APPLE_WDT_REF_HZ; + + writel(bite, wdt_base + WDT_BITE_TIME); + /* the bite lies past the counter's wrap: said once per turn or so */ + if (bite < now) + pr_info("watchdog: ping across the wrap: CUR %#010x BITE %#010x\n", now, bite); + return 0; +} + +/* debugfs apple-wdt/state: the counter, the bite and CTRL, for the flights */ +static int apple_wdt_state_show(struct seq_file *s, void *unused) +{ + seq_printf(s, "cur %#010x bite %#010x ctrl %#x\n", readl_relaxed(wdt_base + WDT_CUR_TIME), + readl_relaxed(wdt_base + WDT_BITE_TIME), readl_relaxed(wdt_base + WDT_CTRL)); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(apple_wdt_state); + +static int apple_wdt_start(struct watchdog_device *wdd) +{ + apple_wdt_ping(wdd); + writel(apple_wdt_ctrl_on() | WDT_CTRL_RESET_EN, wdt_base + WDT_CTRL); + (void)readl(wdt_base + WDT_CTRL); + return 0; +} + +static int apple_wdt_stop(struct watchdog_device *wdd) +{ + writel(apple_wdt_ctrl_on(), wdt_base + WDT_CTRL); + (void)readl(wdt_base + WDT_CTRL); + return 0; +} + +static int apple_wdt_set_timeout(struct watchdog_device *wdd, unsigned int timeout) +{ + wdd->timeout = timeout; + return apple_wdt_ping(wdd); +} + +static const struct watchdog_ops apple_wdt_ops = { + .owner = THIS_MODULE, + .start = apple_wdt_start, + .stop = apple_wdt_stop, + .ping = apple_wdt_ping, + .set_timeout = apple_wdt_set_timeout, +}; + +static const struct watchdog_info apple_wdt_info = { + .identity = "Apple S5L wdt-version 1", + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, +}; + +static struct watchdog_device apple_wdt_wdd = { + .info = &apple_wdt_info, + .ops = &apple_wdt_ops, + .min_timeout = 1, + .max_timeout = U32_MAX / APPLE_WDT_REF_HZ, /* 178 s */ +}; + +static int __init apple_wdt_watchdog_init(void) +{ + u32 ctrl; + int ret; + + if (!wdt_base) + return 0; + ctrl = readl_relaxed(wdt_base + WDT_CTRL); + if (!apple_wdt_timeout) { + pr_info("watchdog: left as the boot loader left it (CTRL %#x)\n", ctrl); + return 0; + } + apple_wdt_wdd.timeout = clamp(apple_wdt_timeout, apple_wdt_wdd.min_timeout, + apple_wdt_wdd.max_timeout); + watchdog_set_nowayout(&apple_wdt_wdd, true); + /* No watchdog_stop_on_reboot(): a halt or poweroff must still end in the + * bite, and a restart keeps the 10 s net the reboot notifier arms. */ + apple_wdt_start(&apple_wdt_wdd); + set_bit(WDOG_HW_RUNNING, &apple_wdt_wdd.status); + ret = watchdog_register_device(&apple_wdt_wdd); + if (ret) { + /* nobody would pet it: back to what the boot loader left */ + writel(ctrl, wdt_base + WDT_CTRL); + pr_err("watchdog: not registered (%d); CTRL back to %#x\n", ret, ctrl); + return 0; + } + pr_info("watchdog: armed, %u s, petted by the kernel until userspace opens /dev/watchdog (boot CTRL %#x)\n", + apple_wdt_wdd.timeout, ctrl); + debugfs_create_file("state", 0444, debugfs_create_dir("apple-wdt", NULL), NULL, + &apple_wdt_state_fops); + return 0; +} +device_initcall(apple_wdt_watchdog_init); diff --git a/arch/arm/mach-apple/headsmp.S b/arch/arm/mach-apple/headsmp.S index 50cc1d53b2e57d..56c6d4221e255d 100644 --- a/arch/arm/mach-apple/headsmp.S +++ b/arch/arm/mach-apple/headsmp.S @@ -13,9 +13,15 @@ * Invalidate this core's duplicate tags in the SCU (SCU + 0x0c, four bits * per core), as iBoot does when it resets a core: nothing the SCU remembers * about this core's L1 from before the power went is true any more. + * Cortex-A9 only (Apple Swift has an integrated L2 and no A9 SCU/CBAR). * Corrupts r0-r2. */ apple_s5l_scu_inv_self: + mrc p15, 0, r0, c0, c0, 0 @ MIDR + ubfx r1, r0, #4, #12 @ primary part number + movw r2, #0xc09 @ ARM_CPU_PART_CORTEX_A9 >> 4 + cmp r1, r2 + retne lr mrc p15, 4, r0, c15, c0, 0 @ CBAR: the SCU mrc p15, 0, r1, c0, c0, 5 @ MPIDR and r1, r1, #3 @@ -29,11 +35,15 @@ apple_s5l_scu_inv_self: /* * Cortex-A9 errata 743622 (r2p*, diagnostic bit 6) and 751472 (before r3p0, * bit 11), which multi_v7 leaves out: the diagnostic register is secure-only, - * and this kernel runs secure. apple.c does the same for CPU0. Corrupts - * r0-r2. + * and this kernel runs secure. apple.c does the same for CPU0. Skipped on + * non-A9 cores such as Apple Swift. Corrupts r0-r2. */ apple_s5l_a9_errata: mrc p15, 0, r0, c0, c0, 0 @ MIDR + ubfx r1, r0, #4, #12 @ primary part number + movw r2, #0xc09 @ ARM_CPU_PART_CORTEX_A9 >> 4 + cmp r1, r2 + retne lr ubfx r1, r0, #20, #4 @ variant mrc p15, 0, r2, c15, c0, 1 @ diagnostic register cmp r1, #2 diff --git a/arch/arm/mach-apple/platsmp.c b/arch/arm/mach-apple/platsmp.c index 6245ac72c0bf9b..1e2d89aed8fe98 100644 --- a/arch/arm/mach-apple/platsmp.c +++ b/arch/arm/mach-apple/platsmp.c @@ -96,17 +96,38 @@ static void tramp_target(phys_addr_t pa) dsb(st); } -/* On the core going down: clean L1, leave coherency, WFI. Returns only if - * the core was not powered off after all (an interrupt already pending). */ +/* On the core going down: clean L1, leave coherency (on Cortex-A9), WFI. + * Returns only if the core was not powered off after all (an interrupt already + * pending). Apple Swift (S5L8950X) does not use Cortex-A9 ACTLR.SMP bit 6. */ static int apple_s5l_powerdown(unsigned long arg) { - v7_exit_coherency_flush(louis); - wfi(); + if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) { + v7_exit_coherency_flush(louis); + wfi(); + asm volatile( + " mrc p15, 0, r0, c1, c0, 1\n" + " orr r0, r0, #(1 << 6)\n" /* ACTLR.SMP */ + " mcr p15, 0, r0, c1, c0, 1\n" + " isb\n" + " mrc p15, 0, r0, c1, c0, 0\n" + " orr r0, r0, #(1 << 2)\n" /* SCTLR.C */ + " mcr p15, 0, r0, c1, c0, 0\n" + " isb\n" + : : : "r0", "memory"); + return 1; + } + asm volatile( - " mrc p15, 0, r0, c1, c0, 1\n" - " orr r0, r0, #(1 << 6)\n" /* ACTLR.SMP */ - " mcr p15, 0, r0, c1, c0, 1\n" + " mrc p15, 0, r0, c1, c0, 0\n" + " bic r0, r0, #(1 << 2)\n" /* SCTLR.C */ + " mcr p15, 0, r0, c1, c0, 0\n" " isb\n" + " bl v7_flush_dcache_louis\n" + " dsb\n" + : : : "r0", "r1", "r2", "r3", "r4", "r5", "r6", + "r9", "r10", "ip", "lr", "memory"); + wfi(); + asm volatile( " mrc p15, 0, r0, c1, c0, 0\n" " orr r0, r0, #(1 << 2)\n" /* SCTLR.C */ " mcr p15, 0, r0, c1, c0, 0\n" @@ -144,7 +165,9 @@ static void __init apple_smp_prepare_cpus(unsigned int max_cpus) of_node_put(page); of_node_put(cpus); - pmgr = of_find_compatible_node(NULL, NULL, "apple,s5l8940x-pmgr"); + pmgr = of_find_compatible_node(NULL, NULL, "apple,s5l8950x-pmgr"); + if (!pmgr) + pmgr = of_find_compatible_node(NULL, NULL, "apple,s5l8940x-pmgr"); if (pmgr) pmgr_base = of_iomap(pmgr, 0); of_node_put(pmgr); diff --git a/arch/arm/mach-apple/pmccntr.c b/arch/arm/mach-apple/pmccntr.c index dc1e349453b28b..d53f5b88c5e846 100644 --- a/arch/arm/mach-apple/pmccntr.c +++ b/arch/arm/mach-apple/pmccntr.c @@ -15,6 +15,7 @@ #include #include +#include #include /* Fallback only. apple_s5l_pmccntr_init() is handed the rate measured against @@ -85,6 +86,16 @@ static void __init apple_pmccntr_enable(void) isb(); } +/* + * Only the A5's Cortex-A9 has the ARM PMU and so this counter. The A6's + * Swift cores (implementer 'a') take an undefined instruction on any CP15 + * c9 PMU access. + */ +bool apple_s5l_has_pmccntr(void) +{ + return read_cpuid_part() == ARM_CPU_PART_CORTEX_A9; +} + /* Split in two so the caller can enable the counter, measure the real CPU * frequency against the watchdog's 24 MHz reference, and only then register * everything with a rate that is not a guess. */ diff --git a/drivers/irqchip/irq-apple-aic1.c b/drivers/irqchip/irq-apple-aic1.c index f6fda81687d418..3216d7de00d1d4 100644 --- a/drivers/irqchip/irq-apple-aic1.c +++ b/drivers/irqchip/irq-apple-aic1.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -559,6 +560,20 @@ static int aic1_irq_domain_map(struct irq_domain *d, unsigned int virq, NULL, NULL); irq_set_probe(virq); + /* Every line is routed to CPU0 (aic1_irq_unmask writes TARGET = CPU0) + * and the chip has no irq_set_affinity, so say so: affinity and + * effective affinity CPU0, and no balancing. /proc/irq/N then tells + * the truth, irqaffinity= is not needed, and nothing expects a + * device interrupt on CPU1. */ + { + struct irq_data *irqd = irq_get_irq_data(virq); + + irqd_set_single_target(irqd); + irq_data_update_affinity(irqd, cpumask_of(0)); + irq_data_update_effective_affinity(irqd, cpumask_of(0)); + irq_set_status_flags(virq, IRQ_NO_BALANCING); + } + return 0; } @@ -774,8 +789,33 @@ static bool aic1_tmr_registered; static bool aic1_tmr_percpu; static DEFINE_PER_CPU(struct clock_event_device, aic1_clkevts); +/* + * The timer is one of the per-core registers of the AIC: the window at 0x2000 + * is banked by the core that accesses it (WHOAMI, the EVENT/IACK and the IPI + * registers are, and IPI_SEND there already tells the two cores apart), and + * its timer event is a local event (type 7) in that core's own EVENT. So each + * core has a timer of its own, and the A6's CPU1 is given its own (see + * aic1_tmr_cpu_online). A window picked for one CPU overrides the global + * choice; 0 means none picked. + */ +static DEFINE_PER_CPU(u32, aic1_tmr_cpu_win); +/* The window a CPU's own self-test saw fire, kept across CPU hotplug. */ +static u32 aic1_tmr_cpu_ok[AIC1_NR_CPUS]; +static u64 aic1_tmr_cpu_last[AIC1_NR_CPUS]; + +/* Timer events taken per CPU: /sys/module/aic1/parameters/timer_events. + * Both counts must grow; CPU1's staying at 0 means CPU1 has no tick. */ +#undef MODULE_PARAM_PREFIX +#define MODULE_PARAM_PREFIX "aic1." +static unsigned int timer_events[AIC1_NR_CPUS]; +module_param_array(timer_events, uint, NULL, 0444); + static inline u32 aic1_tmr_base(void) { + u32 win = this_cpu_read(aic1_tmr_cpu_win); + + if (win) + return win; return aic1_tmr_percpu ? AIC1_CPU_WINDOW(smp_processor_id()) : aic1_tmr_win; } @@ -829,8 +869,14 @@ static void aic1_tmr_arm(struct apple_aic1 *aic, u32 delta) */ static void aic1_tmr_event(struct apple_aic1 *aic) { + unsigned int cpu = smp_processor_id(); + aic1_tmr_events++; aic1_tmr_last = aic1_time(aic); + if (cpu < AIC1_NR_CPUS) { + aic1_tmr_cpu_last[cpu] = aic1_tmr_last; + WRITE_ONCE(timer_events[cpu], timer_events[cpu] + 1); + } aic1_tmr_disarm(aic); if (aic1_tmr_registered) { @@ -854,6 +900,23 @@ static int aic1_ce_shutdown(struct clock_event_device *ce) return 0; } +/* The CPU's own clockevent, registered on that CPU. */ +static void aic1_tmr_register_ce(unsigned int cpu) +{ + struct clock_event_device *ce = per_cpu_ptr(&aic1_clkevts, cpu); + + ce->name = "apple-aic1-timer"; + ce->features = CLOCK_EVT_FEAT_ONESHOT; + /* Above the USB SOF tick (250), which stays registered as a spare. */ + ce->rating = 400; + ce->set_next_event = aic1_ce_set_next_event; + ce->set_state_shutdown = aic1_ce_shutdown; + ce->set_state_oneshot = aic1_ce_shutdown; + ce->tick_resume = aic1_ce_shutdown; + ce->cpumask = cpumask_of(cpu); + clockevents_config_and_register(ce, AIC1_TIMER_HZ, 0xf, 0x7fffffff); +} + /* * CPU hotplug STARTING, on the CPU itself with interrupts off: its window's * timer set up the way the probe found it working, and its clockevent. @@ -862,23 +925,13 @@ static int aic1_ce_shutdown(struct clock_event_device *ce) */ static int aic1_tmr_cpu_starting(unsigned int cpu) { - struct clock_event_device *ce = per_cpu_ptr(&aic1_clkevts, cpu); struct apple_aic1 *aic = apple_aic1; if (cpu) { aic1_tmr_write(aic, AIC1_TMR_CFG, AIC1_TMR_CFG_IBOOT); aic1_tmr_disarm(aic); } - ce->name = "apple-aic1-timer"; - ce->features = CLOCK_EVT_FEAT_ONESHOT; - /* Above the USB SOF tick (250), which stays registered as a spare. */ - ce->rating = 400; - ce->set_next_event = aic1_ce_set_next_event; - ce->set_state_shutdown = aic1_ce_shutdown; - ce->set_state_oneshot = aic1_ce_shutdown; - ce->tick_resume = aic1_ce_shutdown; - ce->cpumask = cpumask_of(cpu); - clockevents_config_and_register(ce, AIC1_TIMER_HZ, 0xf, 0x7fffffff); + aic1_tmr_register_ce(cpu); return 0; } @@ -888,6 +941,129 @@ static int aic1_tmr_cpu_dying(unsigned int cpu) return 0; } +#ifdef CONFIG_SMP +/* + * On a secondary CPU, from its own hotplug thread with interrupts on: put + * this CPU's timer in @win, arm a 10 ms shot and wait up to 200 ms of AIC + * timebase for the event to come back to THIS CPU (timer_events[cpu]). An + * event that went to the other core instead is only an early tick there. + */ +static bool aic1_tmr_cpu_try(struct apple_aic1 *aic, unsigned int cpu, u32 win, + const char *what) +{ + unsigned int before = READ_ONCE(timer_events[cpu]); + unsigned int other = READ_ONCE(timer_events[!cpu]); + u32 cfg0, cnt_a, cnt_b; + u64 t0, t; + + this_cpu_write(aic1_tmr_cpu_win, win); + cfg0 = aic1_tmr_read(aic, AIC1_TMR_CFG); + aic1_tmr_write(aic, AIC1_TMR_CFG, AIC1_TMR_CFG_IBOOT); + + t0 = aic1_time(aic); + aic1_tmr_arm(aic, AIC1_TIMER_HZ / 100); + cnt_a = aic1_tmr_read(aic, AIC1_TMR_CNT); + do { + if (READ_ONCE(timer_events[cpu]) != before) + break; + cpu_relax(); + t = aic1_time(aic); + } while (t - t0 < AIC1_TIMER_HZ / 5); + cnt_b = aic1_tmr_read(aic, AIC1_TMR_CNT); + + if (READ_ONCE(timer_events[cpu]) != before) { + pr_info("AIC-TIMER: CPU%u %s window %#x: a 10 ms shot fired on CPU%u after %llu us\n", + cpu, what, win, cpu, + div_u64((aic1_tmr_cpu_last[cpu] - t0) * 1000000ULL, + AIC1_TIMER_HZ)); + return true; + } + + pr_err("AIC-TIMER: CPU%u %s window %#x: nothing on CPU%u in 200 ms (CPU%u took %u timer events meanwhile). CFG was %#x, CNT %#x -> %#x, STAT %#x\n", + cpu, what, win, cpu, !cpu, READ_ONCE(timer_events[!cpu]) - other, + cfg0, cnt_a, cnt_b, aic1_tmr_read(aic, AIC1_TMR_STAT)); + /* Stop it through the window that is this CPU's for certain. Not + * through @win: if the banked window turned out to reach CPU0's timer, + * a disarm there would kill CPU0's tick, while the shot it got was + * only an early tick that CPU0 has re-armed since. */ + this_cpu_write(aic1_tmr_cpu_win, AIC1_CPU_WINDOW(cpu)); + aic1_tmr_disarm(aic); + this_cpu_write(aic1_tmr_cpu_win, 0); + return false; +} + +/* + * CPU hotplug ONLINE (dynamic state), A6 only, on a secondary CPU: give it + * the AIC timer of its own core as its tick. Until this runs the CPU has + * only the dummy clockevent, and with no broadcast device on this SoC a CPU + * left like that never ticks: RCU stalls on it with idle=poll, and in WFI + * the first wait for it hangs the system. The timer is tested before it is + * trusted, through the banked window first (the one CPU0 runs on), then the + * CPU's explicit window. + */ +static int aic1_tmr_cpu_online(unsigned int cpu) +{ + struct apple_aic1 *aic = apple_aic1; + u32 win; + + if (!cpu || cpu >= AIC1_NR_CPUS || !aic) + return 0; + + win = aic1_tmr_cpu_ok[cpu]; + if (!win) { + if (aic1_tmr_cpu_try(aic, cpu, AIC1_ALIAS_WINDOW, "banked")) + win = AIC1_ALIAS_WINDOW; + else if (aic1_tmr_cpu_try(aic, cpu, AIC1_CPU_WINDOW(cpu), "explicit")) + win = AIC1_CPU_WINDOW(cpu); + } + if (!win) { + pr_err("AIC-TIMER: FAIL -- CPU%u: its own AIC timer never fired; CPU%u has no tick (expect RCU stalls; boot with maxcpus=1)\n", + cpu, cpu); + return 0; + } + + aic1_tmr_cpu_ok[cpu] = win; + this_cpu_write(aic1_tmr_cpu_win, win); + aic1_tmr_write(aic, AIC1_TMR_CFG, AIC1_TMR_CFG_IBOOT); + aic1_tmr_disarm(aic); + aic1_tmr_register_ce(cpu); + pr_info("AIC-TIMER: PASS -- CPU%u has its own clockevent (window %#x)\n", + cpu, win); + return 0; +} + +/* + * No teardown: going offline, the CPU's timer is still its tick device until + * the tick code lets go of it, and apple_aic1_secondary_init() quiesces the + * window before the CPU comes back. + */ +static bool __init aic1_tmr_setup_secondaries(void) +{ + int ret; + + /* + * Only the A5's Cortex-A9 has the ARM PMU whose tick covers the other + * core; it keeps that and the CPU0-only AIC timer as they were. Apple's + * own cores (Swift on the A6 and A6X) have no PMU, so every further + * CPU takes its own AIC timer, whatever the board. + */ + if (num_possible_cpus() < 2 || read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) + return false; + + ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, + "irqchip/apple-aic1/timer:online", + aic1_tmr_cpu_online, NULL); + if (ret < 0) { + pr_err("AIC-TIMER: no hotplug state for the secondary timers (%d)\n", + ret); + return false; + } + return true; +} +#else +static inline bool aic1_tmr_setup_secondaries(void) { return false; } +#endif + /* * Arm a 10 ms shot in one window and wait up to 200 ms of timebase for the * event to come back through the dispatcher. IRQs are on before any initcall; @@ -941,6 +1117,7 @@ static bool aic1_tmr_tried __initdata; static int __init aic1_timer_init(void) { struct apple_aic1 *aic = apple_aic1; + bool secondaries = false; if (!aic || aic1_tmr_tried) return 0; @@ -963,8 +1140,10 @@ static int __init aic1_timer_init(void) "irqchip/apple-aic1/timer:starting", aic1_tmr_cpu_starting, aic1_tmr_cpu_dying); } else { - /* The alias fired: one timer, CPU0's. */ + /* The banked window fired: CPU0's timer. On the A6 each further + * CPU tests and takes its own as it comes online. */ aic1_tmr_cpu_starting(0); + secondaries = aic1_tmr_setup_secondaries(); } #ifdef CONFIG_ARCH_APPLE_S5L { @@ -976,7 +1155,9 @@ static int __init aic1_timer_init(void) } #endif pr_err("AIC-TIMER: PASS -- clockevent registered at 24 MHz, %s. The tick no longer needs a USB host.\n", - aic1_tmr_percpu ? "one per CPU" : "CPU0 only"); + aic1_tmr_percpu ? "one per CPU" : + secondaries ? "CPU0 now, each other CPU its own once online" : + "CPU0 only"); return 0; } diff --git a/drivers/phy/phy-apple-s5l-usb.c b/drivers/phy/phy-apple-s5l-usb.c index 91f50b21df104e..97a6b4a068711d 100644 --- a/drivers/phy/phy-apple-s5l-usb.c +++ b/drivers/phy/phy-apple-s5l-usb.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -35,7 +36,12 @@ #define OPHY_UOTGTUNE1 0x40 #define OPHY_UOTGTUNE2 0x44 #define OPHY_UOTGTUNE1_DEVICE 0x549 +#define OPHY_UOTGTUNE1_S5L8950X_DEVICE 0x749 #define OPHY_UOTGTUNE2_DEVICE 0x2ff3 +/* PHY version 4 (S5L8950X): ADT otgphyctrl hsic-tuning-val, written to +0x5c + * by AppleS5L8930XUSBPhy (14G61). */ +#define OPHY_HSICTUNE 0x5c +#define OPHY_HSICTUNE_S5L8950X 0xa30a3a3 #define PMGR_BASE 0x3F100000 #define PMGR_GATE_ON 0xF @@ -111,10 +117,54 @@ struct s5l_usbphy_soc_data { bool cold_init; + u32 pmgr_uperf; + u32 pmgr_usb_otg; + u32 pmgr_usbreg; + u32 pmgr_usb_ehci; + u32 pmgr_usb_ohci0; + u32 uotgtune1_device; + u32 hsic_tuning; /* OPHY_HSICTUNE, when non-zero */ +}; + +static const struct s5l_usbphy_soc_data s5l8940x_usbphy_data = { + .cold_init = false, + .pmgr_uperf = PMGR_UPERF, + .pmgr_usb_otg = PMGR_USB_OTG, + .pmgr_usbreg = PMGR_USBREG, + .pmgr_usb_ehci = PMGR_USB_EHCI, + .pmgr_usb_ohci0 = PMGR_USB_OHCI0, + .uotgtune1_device = OPHY_UOTGTUNE1_DEVICE, }; static const struct s5l_usbphy_soc_data s5l8942x_usbphy_data = { .cold_init = true, + .pmgr_uperf = PMGR_UPERF, + .pmgr_usb_otg = PMGR_USB_OTG, + .pmgr_usbreg = PMGR_USBREG, + .pmgr_usb_ehci = PMGR_USB_EHCI, + .pmgr_usb_ohci0 = PMGR_USB_OHCI0, + .uotgtune1_device = OPHY_UOTGTUNE1_DEVICE, +}; + +/* + * S5L8950X (Apple A6): verified from iPhone5,2 iOS 8.4.1 ADT device-clocks + * (81 entries x 44 bytes) and iBEC USB init: + * UPERF id 0x04, idx 0x21 -> PMGR + 0x1084 + * USB-OTG id 0x35, idx 0x22 -> PMGR + 0x1088 + * USB-EHCI id 0x36, idx 0x23 -> PMGR + 0x108c + * OHCI0 id 0x37, idx 0x25 -> PMGR + 0x1094 + * USBREG id 0x06, idx 0x27 -> PMGR + 0x109c + * OPHY_UOTGTUNE1 = 0x749, OPHY_UOTGTUNE2 = 0x2ff3. + */ +static const struct s5l_usbphy_soc_data s5l8950x_usbphy_data = { + .cold_init = true, + .pmgr_uperf = 0x1084, + .pmgr_usb_otg = 0x1088, + .pmgr_usbreg = 0x109c, + .pmgr_usb_ehci = 0x108c, + .pmgr_usb_ohci0 = 0x1094, + .uotgtune1_device = OPHY_UOTGTUNE1_S5L8950X_DEVICE, + .hsic_tuning = OPHY_HSICTUNE_S5L8950X, }; struct s5l_usbphy { @@ -127,6 +177,7 @@ struct s5l_usbphy { bool lpo_supply_on; struct device *dev; struct clk *refclk; + struct clk_bulk_data gates[3]; /* uperf, otg, usbreg; optional */ const struct s5l_usbphy_soc_data *data; struct mutex lock; unsigned int init_users; @@ -151,6 +202,44 @@ static int s5l_pmgr_on(struct s5l_usbphy *p, u32 off) return -ETIMEDOUT; } +/* + * The OTG side's PMGR gates, when the tree names them as clocks (S5L8950X: + * UPERF, USB-OTG and USBREG, ADT ids 0x04, 0x35 and 0x06): switched on at + * probe in the order native firmware uses, and held from then on. The + * gadget is the console and the network, so they are never switched off, + * not on a failed probe and not on unbind; the enable count also keeps + * clk_disable_unused away from them. s5l_usbphy_init() still checks the + * same registers directly, which is all a tree without these clocks gets. + */ +static const char * const s5l_usbphy_gate_names[] = { "uperf", "otg", "usbreg" }; + +static int s5l_usbphy_hold_gates(struct s5l_usbphy *p) +{ + int i, n = ARRAY_SIZE(s5l_usbphy_gate_names), ret; + bool any = false; + + BUILD_BUG_ON(ARRAY_SIZE(s5l_usbphy_gate_names) != ARRAY_SIZE(p->gates)); + for (i = 0; i < n; i++) + p->gates[i].id = s5l_usbphy_gate_names[i]; + ret = devm_clk_bulk_get_optional(p->dev, n, p->gates); + if (ret) + return dev_err_probe(p->dev, ret, "PMGR gates\n"); + for (i = 0; i < n; i++) + any |= !!p->gates[i].clk; + if (!any) + return 0; + + for (i = 0; i < n; i++) + if (p->gates[i].clk) + dev_dbg(p->dev, "PMGR gate %s was %s\n", + __clk_get_name(p->gates[i].clk), + __clk_is_enabled(p->gates[i].clk) ? "on" : "off"); + ret = clk_bulk_prepare_enable(n, p->gates); + if (ret) + return dev_err_probe(p->dev, ret, "enabling the PMGR gates\n"); + return 0; +} + static int s5l_usbphy_clk_sel(unsigned long rate) { switch (rate) { @@ -173,7 +262,7 @@ static bool s5l_usbphy_is_ready(struct s5l_usbphy *p) (readl(p->base + OPHYCLK) & OPHYCLK_CLKSEL_MASK) == clksel && readl(p->base + OPHYPWR) == OPHYPWR_ACTIVE && !(readl(p->base + ORSTCON) & ORSTCON_PHYSWRESET) && - readl(p->base + OPHY_UOTGTUNE1) == OPHY_UOTGTUNE1_DEVICE && + readl(p->base + OPHY_UOTGTUNE1) == p->data->uotgtune1_device && readl(p->base + OPHY_UOTGTUNE2) == OPHY_UOTGTUNE2_DEVICE && readl(p->base + OPHYUNK4) == OPHYUNK4_START; } @@ -192,14 +281,21 @@ static int s5l_usbphy_cold_init(struct s5l_usbphy *p) writel(OPHYUNK4_START, p->base + OPHYUNK4); writel(OPHYPWR_ACTIVE, p->base + OPHYPWR); writel(OPHYUNK1_START, p->base + OPHYUNK1); - writel(OPHY_UOTGTUNE1_DEVICE, p->base + OPHY_UOTGTUNE1); + writel(p->data->uotgtune1_device, p->base + OPHY_UOTGTUNE1); writel(OPHY_UOTGTUNE2_DEVICE, p->base + OPHY_UOTGTUNE2); + if (p->data->hsic_tuning) + writel(p->data->hsic_tuning, p->base + OPHY_HSICTUNE); udelay(10); v = readl(p->base + OPHYCLK); writel((v & ~OPHYCLK_CLKSEL_MASK) | clksel, p->base + OPHYCLK); - if ((readl(p->base + OPHYCLK) & OPHYCLK_CLKSEL_MASK) != clksel) { - dev_err(p->dev, "PHY reference clock selection did not latch\n"); + v = readl(p->base + OPHYCLK); + if ((v & OPHYCLK_CLKSEL_MASK) != clksel) { + dev_err(p->dev, "PHY reference clock selection did not latch: OPHYCLK 0x%08x OPHYPWR 0x%08x PMGR uperf 0x%08x otg 0x%08x usbreg 0x%08x\n", + v, readl(p->base + OPHYPWR), + readl(p->pmgr + p->data->pmgr_uperf), + readl(p->pmgr + p->data->pmgr_usb_otg), + readl(p->pmgr + p->data->pmgr_usbreg)); return -EIO; } @@ -218,37 +314,39 @@ static int s5l_usbphy_init(struct phy *phy) goto out; } - if (p->data && p->data->cold_init) { + if (p->data->cold_init) { ret = clk_prepare_enable(p->refclk); if (ret) goto out; } /* Native firmware enables these parents in this order. */ - if ((readl(p->pmgr + PMGR_UPERF) & 0xff) != 0xff || - (readl(p->pmgr + PMGR_USB_OTG) & 0xff) != 0xff || - (readl(p->pmgr + PMGR_USBREG) & 0xff) != 0xff) + if ((readl(p->pmgr + p->data->pmgr_uperf) & 0xff) != 0xff || + (readl(p->pmgr + p->data->pmgr_usb_otg) & 0xff) != 0xff || + (readl(p->pmgr + p->data->pmgr_usbreg) & 0xff) != 0xff) usleep_range(10000, 11000); /* The legacy compatibles also name the A5X, whose power-state registers * are elsewhere: for them a parent that does not answer is not fatal. */ - ret = s5l_pmgr_on(p, PMGR_UPERF); - if (ret && p->data && p->data->cold_init) + ret = s5l_pmgr_on(p, p->data->pmgr_uperf); + if (ret && p->data->cold_init) goto disable_clock; - ret = s5l_pmgr_on(p, PMGR_USB_OTG); + ret = s5l_pmgr_on(p, p->data->pmgr_usb_otg); if (ret) goto disable_clock; - ret = s5l_pmgr_on(p, PMGR_USBREG); - if (ret && p->data && p->data->cold_init) + ret = s5l_pmgr_on(p, p->data->pmgr_usbreg); + if (ret && p->data->cold_init) goto disable_clock; ret = 0; udelay(100); - if (p->data && p->data->cold_init) { + if (p->data->cold_init) { if (!s5l_usbphy_is_ready(p)) { ret = s5l_usbphy_cold_init(p); if (ret) goto disable_clock; + } else if (p->data->hsic_tuning) { + writel(p->data->hsic_tuning, p->base + OPHY_HSICTUNE); } } else if (readl(p->base + OPHYPWR) != OPHYPWR_ACTIVE) { /* Legacy compatibles keep the tuning firmware leaves, unless @@ -259,7 +357,7 @@ static int s5l_usbphy_init(struct phy *phy) writel(0xc, p->base + 0x14); writel(OPHYUNK1_START | OPHYUNK1_OTG_ENABLE, p->base + OPHYUNK1); writel(0xc00, p->base + 0x20); - writel(OPHY_UOTGTUNE1_DEVICE, p->base + OPHY_UOTGTUNE1); + writel(p->data->uotgtune1_device, p->base + OPHY_UOTGTUNE1); writel(OPHY_UOTGTUNE2_DEVICE, p->base + OPHY_UOTGTUNE2); writel(OPHYUNK4_START, p->base + OPHYUNK4); writel(OPHYPWR_ACTIVE, p->base + OPHYPWR); @@ -279,7 +377,7 @@ static int s5l_usbphy_init(struct phy *phy) dev_err(p->dev, "PHY reset did not clear: 0x%08x\n", v); goto disable_clock; } - if (p->data && p->data->cold_init && !s5l_usbphy_is_ready(p)) { + if (p->data->cold_init && !s5l_usbphy_is_ready(p)) { dev_err(p->dev, "PHY power or tuning did not latch\n"); ret = -EIO; goto disable_clock; @@ -288,7 +386,7 @@ static int s5l_usbphy_init(struct phy *phy) goto out; disable_clock: - if (p->data && p->data->cold_init) + if (p->data->cold_init) clk_disable_unprepare(p->refclk); out: mutex_unlock(&p->lock); @@ -406,18 +504,19 @@ static int s5l_hostphy_power_on(struct phy *phy) msleep(10); } - ret = s5l_pmgr_on(p, PMGR_USB_EHCI); + ret = s5l_pmgr_on(p, p->data->pmgr_usb_ehci); if (ret) goto err_disable_hsic; - ret = s5l_pmgr_on(p, PMGR_USB_OHCI0); + ret = s5l_pmgr_on(p, p->data->pmgr_usb_ohci0); if (ret) goto err_disable_hsic; if (p->usbcplx) writel(readl(p->usbcplx) | USBCPLX_HSIC_EN, p->usbcplx); - dev_dbg(p->dev, "host PHY on: EHCI(89)=0x%08x OHCI0(90)=0x%08x usb-complex=0x%08x\n", - readl(p->pmgr + PMGR_USB_EHCI), readl(p->pmgr + PMGR_USB_OHCI0), - p->usbcplx ? readl(p->usbcplx) : 0); + dev_dbg(p->dev, "host PHY on: EHCI=0x%08x OHCI0=0x%08x usb-complex=0x%08x\n", + readl(p->pmgr + p->data->pmgr_usb_ehci), + readl(p->pmgr + p->data->pmgr_usb_ohci0), + p->usbcplx ? readl(p->usbcplx) : 0); return 0; err_disable_hsic: @@ -610,6 +709,7 @@ static int s5l_usbphy_probe(struct platform_device *pdev) struct s5l_usbphy *p; struct phy *phy; struct phy_provider *provider; + int ret; if (of_device_is_compatible(pdev->dev.of_node, "apple,s5l8945x-usb1-phy")) return s5l_usb1phy_probe(pdev); @@ -620,8 +720,10 @@ static int s5l_usbphy_probe(struct platform_device *pdev) p->dev = &pdev->dev; p->data = device_get_match_data(&pdev->dev); + if (!p->data) + p->data = &s5l8940x_usbphy_data; mutex_init(&p->lock); - if (p->data && p->data->cold_init) { + if (p->data->cold_init) { p->refclk = devm_clk_get(&pdev->dev, "ref"); if (IS_ERR(p->refclk)) return dev_err_probe(&pdev->dev, PTR_ERR(p->refclk), @@ -640,6 +742,10 @@ static int s5l_usbphy_probe(struct platform_device *pdev) return -ENOMEM; } + ret = s5l_usbphy_hold_gates(p); + if (ret) + return ret; + /* usb-complex, for the HSIC enable bit: optional, the second reg. */ if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) { p->usbcplx = devm_platform_ioremap_resource(pdev, 1); @@ -672,9 +778,10 @@ static int s5l_usbphy_probe(struct platform_device *pdev) } static const struct of_device_id s5l_usbphy_of_match[] = { + { .compatible = "apple,s5l8950x-otgphy", .data = &s5l8950x_usbphy_data }, { .compatible = "apple,s5l8942x-otgphy", .data = &s5l8942x_usbphy_data }, - { .compatible = "apple,s5l8940x-otgphy" }, - { .compatible = "apple,s5l8930x-otgphy" }, + { .compatible = "apple,s5l8940x-otgphy", .data = &s5l8940x_usbphy_data }, + { .compatible = "apple,s5l8930x-otgphy", .data = &s5l8940x_usbphy_data }, { .compatible = "apple,s5l8945x-usb1-phy" }, { }, };