diff --git a/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml b/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml index 663c43b67f..e70bda177c 100644 --- a/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml +++ b/Documentation/devicetree/bindings/display/samsung/google,gs201-dsim.yaml @@ -14,14 +14,19 @@ description: pipeline. It takes pixel data from a DECON and drives up to four data lanes through a combined D-PHY/C-PHY, in video or command mode, with DSC slice packing and TE-based command scheduling. Panels are described - as child nodes. + as child nodes. The Tensor G4 (zumapro) has the same DSIM, at the same + register layout. allOf: - $ref: /schemas/display/dsi-controller.yaml# properties: compatible: - const: google,gs201-dsim + oneOf: + - const: google,gs201-dsim + - items: + - const: google,zumapro-dsim + - const: google,gs201-dsim reg: minItems: 1 diff --git a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml index 38e9a0444f..be1765aa4d 100644 --- a/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml +++ b/Documentation/devicetree/bindings/net/wireless/brcm,bcm4329-fmac.yaml @@ -56,6 +56,7 @@ properties: - pci14e4,4433 # BCM4387 - pci14e4,4434 # BCM4388 - pci14e4,4441 # BCM4389 + - pci14e4,4449 # BCM4383 - pci14e4,449d # BCM43752 reg: @@ -125,6 +126,11 @@ properties: NVRAM. This would normally be filled in by the bootloader from platform configuration data. + memory-region: + maxItems: 1 + description: A restricted-dma-pool region that all DMA of a PCIe device + bounces through, for platforms that limit the device's DMA to it. + clocks: items: - description: External Low Power Clock input (32.768KHz) diff --git a/Documentation/devicetree/bindings/pci/google,zumapro-pcie.yaml b/Documentation/devicetree/bindings/pci/google,zumapro-pcie.yaml new file mode 100644 index 0000000000..d4767d8249 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/google,zumapro-pcie.yaml @@ -0,0 +1,200 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/google,zumapro-pcie.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Google zumapro (Tensor G4) PCIe host controller + +maintainers: + - W4HO <87742609+W4HO-ham@users.noreply.github.com> + +description: + The second PCIe channel (channel 1) of the Google zumapro (Tensor G4) SoC, + one lane in the HSI2 block, is a Synopsys DesignWare core in a Samsung + wrapper. The wrapper adds an external local bus interface (ELBI) with link + training control and status, a sub-system control block, the PHY's debug + (UDBG), PMA and PCS register blocks, and an I/A sequencer. The PHY sits + behind an isolation switch in the PMU, which has to be opened before any + of these registers is accessed. MSIs are received by the + DesignWare core's own MSI controller and signalled on five interrupt + lines, one per group of 32 vectors. + +allOf: + - $ref: /schemas/pci/pci-host-bridge.yaml# + +properties: + compatible: + const: google,zumapro-pcie + + reg: + items: + - description: External local bus interface (ELBI) registers + - description: Sub-system control registers + - description: PHY debug (UDBG) registers + - description: PHY PMA registers + - description: PHY PCS registers + - description: I/A sequencer registers + - description: Data Bus Interface (DBI) registers, with the unrolled + iATU at offset 0x300000 + - description: PCIe configuration space region + + reg-names: + items: + - const: elbi + - const: soc + - const: udbg + - const: phy + - const: pcs + - const: ia + - const: dbi + - const: config + + interrupts: + items: + - description: Controller interrupt + - description: MSI vectors 0 to 31 + - description: MSI vectors 32 to 63 + - description: MSI vectors 64 to 95 + - description: MSI vectors 96 to 127 + - description: MSI vectors 128 to 159 + + interrupt-names: + items: + - const: ctrl + - const: msi0 + - const: msi1 + - const: msi2 + - const: msi3 + - const: msi4 + + clocks: + items: + - description: Controller APB clock + - description: DBI AXI clock + - description: AXI slave clock + - description: AXI master clock + - description: PHY UDBG APB clock + - description: PHY PAL APB clock + - description: PHY reference clock + - description: PHY bridge APB clock + - description: PHY test APB clock + - description: I/A sequencer clock + - description: I/A SSMT AXI clock + - description: I/A SSMT APB clock + - description: System MMU clock + - description: PMMU clock + + clock-names: + items: + - const: ctl-apb + - const: dbi-aclk + - const: slv-aclk + - const: mstr-aclk + - const: phy-udbg-apb + - const: phy-pal-apb + - const: phy-ref + - const: phy-bridge-apb + - const: phy-test-apb + - const: ia-clk + - const: ssmt-ia-aclk + - const: ssmt-ia-pclk + - const: sysmmu-clk + - const: pmmu-clk + + reset-gpios: + description: PERST# of the endpoint. + maxItems: 1 + + samsung,pmu-syscon: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: phandle of the PMU system controller + - description: offset of the PCIe PHY control register + description: + The PMU register that isolates the PCIe PHY. Bit 0 opens the isolation, + bit 10 is set once the PHY is configured. + + num-lanes: + const: 1 + +required: + - compatible + - reg + - reg-names + - interrupts + - interrupt-names + - clocks + - clock-names + - reset-gpios + - samsung,pmu-syscon + +unevaluatedProperties: false + +examples: + - | + #include + #include + #include + + soc { + #address-cells = <2>; + #size-cells = <1>; + + pcie@13120000 { + compatible = "google,zumapro-pcie"; + reg = <0x0 0x13120000 0x2000>, <0x0 0x13130000 0x5000>, + <0x0 0x13150000 0xd000>, <0x0 0x13160000 0x3000>, + <0x0 0x13140000 0x5000>, <0x0 0x13100000 0x1000>, + <0x0 0x13400000 0x381000>, <0x0 0x60ffe000 0x2000>; + reg-names = "elbi", "soc", "udbg", "phy", "pcs", "ia", "dbi", + "config"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x60000000 0x0 0x60000000 0x0 0xff0000>; + bus-range = <0x00 0xff>; + interrupts = , + , + , + , + , + ; + interrupt-names = "ctrl", "msi0", "msi1", "msi2", "msi3", "msi4"; + clocks = <&cmu_hsi2 CLK_GOUT_PCIE1_CTL_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_DBI_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SLV_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_MSTR_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_UDBG_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_PAL_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_REF>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_BRIDGE_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_TEST_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_IA_CLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SSMT_IA_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SSMT_IA_PCLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SYSMMU_CLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PMMU_CLK>; + clock-names = "ctl-apb", "dbi-aclk", "slv-aclk", "mstr-aclk", + "phy-udbg-apb", "phy-pal-apb", "phy-ref", + "phy-bridge-apb", "phy-test-apb", "ia-clk", + "ssmt-ia-aclk", "ssmt-ia-pclk", "sysmmu-clk", + "pmmu-clk"; + reset-gpios = <&gph3 0 GPIO_ACTIVE_LOW>; + samsung,pmu-syscon = <&pmu_system_controller 0x3ec8>; + num-lanes = <1>; + max-link-speed = <2>; + + pcie@0,0 { + compatible = "pciclass,0604"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + bus-range = <0x01 0xff>; + ranges; + vpcie3v3-supply = <&wlan_reg_on>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 4841af951f..35f8c8a312 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11167,6 +11167,7 @@ C: irc://irc.oftc.net/pixel6-kernel-dev F: Documentation/devicetree/bindings/clock/google,gs101-clock.yaml F: Documentation/devicetree/bindings/clock/google,gs201-clock.yaml F: Documentation/devicetree/bindings/clock/google,zumapro* +F: Documentation/devicetree/bindings/pci/google,zumapro-pcie.yaml F: Documentation/devicetree/bindings/phy/google,lga-usb-phy.yaml F: Documentation/devicetree/bindings/soc/google/google,gs101-dtzpc.yaml F: Documentation/devicetree/bindings/soc/google/google,gs101-pmu.yaml @@ -11176,6 +11177,7 @@ F: arch/arm64/boot/dts/exynos/google/ F: drivers/clk/samsung/clk-gs101.c F: drivers/clk/samsung/clk-gs201.c F: drivers/clk/samsung/clk-zumapro.c +F: drivers/pci/controller/dwc/pcie-zumapro.c F: drivers/phy/phy-google-usb.c F: drivers/soc/samsung/gs101-pmu.c F: drivers/phy/samsung/phy-gs101-ufs.c diff --git a/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts b/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts index c8e150e529..d5c0d94a49 100644 --- a/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts +++ b/arch/arm64/boot/dts/exynos/google/zumapro-tegu.dts @@ -8,8 +8,11 @@ /dts-v1/; +#include #include #include +#include +#include #include "../exynos-pinctrl.h" #include "zumapro.dtsi" #include "zumapro-reserved-memory.dtsi" @@ -73,6 +76,68 @@ }; }; + /* + * The GPU's levels: the shader rates of the Pixel 9a's GPU DVFS table + * up to 890 MHz, each with its paired L2 rate through the ACPM "gpu" + * clock; gpu-thermal throttles them from 85 C. 940 MHz, the table's + * top, is left out until it has run on the 9a. + */ + gpu_opp: opp-table-gpu { + compatible = "operating-points-v2"; + + opp-150000000 { + opp-hz = /bits/ 64 <150000000>; + }; + + opp-302000000 { + opp-hz = /bits/ 64 <302000000>; + }; + + opp-337000000 { + opp-hz = /bits/ 64 <337000000>; + }; + + opp-376000000 { + opp-hz = /bits/ 64 <376000000>; + }; + + opp-419000000 { + opp-hz = /bits/ 64 <419000000>; + }; + + opp-467000000 { + opp-hz = /bits/ 64 <467000000>; + }; + + opp-521000000 { + opp-hz = /bits/ 64 <521000000>; + }; + + opp-580000000 { + opp-hz = /bits/ 64 <580000000>; + }; + + opp-649000000 { + opp-hz = /bits/ 64 <649000000>; + }; + + opp-723000000 { + opp-hz = /bits/ 64 <723000000>; + }; + + opp-807000000 { + opp-hz = /bits/ 64 <807000000>; + }; + + opp-850000000 { + opp-hz = /bits/ 64 <850000000>; + }; + + opp-890000000 { + opp-hz = /bits/ 64 <890000000>; + }; + }; + /* UFS VCC, switched by gpp0-1 as on stock. */ ufs_vcc: regulator-ufs-vcc { compatible = "regulator-fixed"; @@ -82,6 +147,18 @@ regulator-boot-on; regulator-always-on; }; + + /* + * WL_REG_ON (gph3-4), the Wi-Fi chip's power enable (stock's + * pcie,wlan-gpio), raised 150 ms before the PCIe PHY is configured. + */ + wlan_reg_on: regulator-wlan-reg-on { + compatible = "regulator-fixed"; + regulator-name = "wlan-reg-on"; + gpio = <&gph3 4 GPIO_ACTIVE_HIGH>; + enable-active-high; + startup-delay-us = <150000>; + }; }; &{/reserved-memory} { @@ -95,6 +172,28 @@ reg = <0x0 0xfac00000 0x009fc900>; no-map; }; + + /* DECON's scanout buffers, below 4 GiB for its 32-bit DMA. */ + display_pool: display-pool { + compatible = "shared-dma-pool"; + reusable; + size = <0x04000000>; + alignment = <0x0 0x00200000>; + alloc-ranges = <0x0 0x98000000 0x06000000>; + }; + + /* + * All of the Wi-Fi chip's DMA buffers come from this pool. It keeps + * driver bugs away from the rest of RAM; it does not confine the + * chip's own firmware, as the HSI2 System MMU and S2MPU see PCIe and + * UFS on the same VID and cannot enforce on it. + */ + wifi_dma_pool: wifi-dma-pool { + compatible = "restricted-dma-pool"; + size = <0x01000000>; + alignment = <0x0 0x00200000>; + alloc-ranges = <0x0 0x80000000 0x80000000>; + }; }; &acpm_ipc { @@ -135,6 +234,10 @@ status = "okay"; }; +&cmu_g3d { + status = "okay"; +}; + &cmu_hsi0 { status = "okay"; }; @@ -163,6 +266,37 @@ status = "okay"; }; +/* + * DECON0 scans out to DSIM0, so gs-decon can switch the link and the + * panel between 60 and 120 Hz. + */ +&decon0 { + memory-region = <&display_pool>, <&cont_splash_mem>; + memory-region-names = "pool", "boot-framebuffer"; + status = "okay"; + + port { + decon0_out: endpoint { + remote-endpoint = <&dsi0_in>; + }; + }; +}; + +&dsi0 { + status = "okay"; + + panel@0 { + compatible = "google,tg4c"; + reg = <0>; + }; + + port { + dsi0_in: endpoint { + remote-endpoint = <&decon0_out>; + }; + }; +}; + /* The keys' banks and the touchscreen's raise their own interrupts. */ &gpa4 { interrupt-controller; @@ -182,14 +316,149 @@ ; }; +/* The USB-C port controller's interrupt (gpa8-3). */ +&gpa8 { + interrupt-controller; + #interrupt-cells = <2>; + interrupts = , + , + , + ; +}; + &gpn0 { interrupt-controller; #interrupt-cells = <2>; interrupts = ; }; +/* + * The GPU's core clock is ACPM's paired "gpu" clock, which sets the shader + * (G3D) and L2 (G3DL2) domains together; coregroup and stacks stay on + * CMU_G3D's gates. + */ +&gpu { + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_GPU>, + <&cmu_g3d CLK_GOUT_G3D_COREGROUP>, + <&cmu_g3d CLK_GOUT_G3D_STACKS>; + operating-points-v2 = <&gpu_opp>; + status = "okay"; +}; + +/* The torch: a TI LM3644 flash driver, both LED outputs on one white LED. */ +&hsi2c4 { + clock-frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&hsi2c4_bus>; + status = "okay"; + + led-controller@63 { + compatible = "ti,lm3644"; + reg = <0x63>; + enable-gpios = <&gpp24 1 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&torch_enable>; + + led { + function = LED_FUNCTION_TORCH; + color = ; + led-sources = <1 2>; + /* A dim flashlight, far below the part's and the LED's limits. */ + led-max-microamp = <75000>; + }; + }; +}; + +/* + * The MAX77779's bus: its USB-C port controller, a sink with no link to the + * USB controller's role yet, its fuel gauge and its charger. + */ +&hsi2c6 { + clock-frequency = <950000>; + pinctrl-names = "default"; + pinctrl-0 = <&hsi2c6_bus>; + status = "okay"; + + usb_tcpc: tcpc@25 { + compatible = "maxim,max77779-tcpc"; + reg = <0x25>; + interrupt-parent = <&gpa8>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&usb_pd_irq>; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "sink"; + self-powered; + op-sink-microwatt = <2600000>; + sink-pdos = ; + }; + }; + + fuel_gauge: fuel-gauge@36 { + compatible = "maxim,max77779-fg"; + reg = <0x36>; + shunt-resistor-micro-ohms = <2000>; + power-supplies = <&charger>; + }; + + charger: charger@69 { + compatible = "maxim,max77779-charger"; + reg = <0x69>; + }; +}; + +/* The haptics: a CS40L26 on the 9a's LRA, with Google's limits for it. */ +&hsi2c9 { + clock-frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&hsi2c9_bus>; + status = "okay"; + + haptic-driver@43 { + compatible = "cirrus,cs40l26a"; + reg = <0x43>; + interrupt-parent = <&gpa6>; + interrupts = <3 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&gph2 3 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&haptic_reset>; + cirrus,boost-peak-microamp = <2500000>; + cirrus,boost-ctl-microvolt = <10000000>; + cirrus,lra-f0-hz = <162>; + cirrus,lra-redc-micro-ohms = <14100007>; + cirrus,vpbr-threshold-microvolt = <3008000>; + }; +}; + +&pcie_1 { + reset-gpios = <&gph3 0 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +&pcie_1_rp { + vpcie3v3-supply = <&wlan_reg_on>; + + wifi@0,0 { + compatible = "pci14e4,4449"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + brcm,board-type = "google,zumapro-tegu"; + memory-region = <&wifi_dma_pool>; + }; +}; + &pinctrl_alive { status = "okay"; + + usb_pd_irq: usb-pd-irq-pins { + samsung,pins = "gpa8-3"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = <0>; + }; }; &pinctrl_custom_alive { @@ -202,6 +471,13 @@ &pinctrl_hsi1 { status = "okay"; + + haptic_reset: haptic-reset-pins { + samsung,pins = "gph2-3"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = <0>; + }; }; &pinctrl_hsi2 { @@ -215,6 +491,20 @@ &pinctrl_peric0 { status = "okay"; + hsi2c4_bus: hsi2c4-bus-pins { + samsung,pins = "gpp8-0", "gpp8-1"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = <0>; + }; + + hsi2c6_bus: hsi2c6-bus-pins { + samsung,pins = "gpp12-0", "gpp12-1"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = <0>; + }; + touch_reset_held: touch-reset-held-pins { samsung,pins = "gpp1-1"; samsung,pin-function = ; @@ -224,6 +514,20 @@ &pinctrl_peric1 { status = "okay"; + + hsi2c9_bus: hsi2c9-bus-pins { + samsung,pins = "gpp19-4", "gpp19-5"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = <0>; + }; + + torch_enable: torch-enable-pins { + samsung,pins = "gpp24-1"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = <0>; + }; }; &pmu_system_controller { @@ -321,6 +625,18 @@ status = "okay"; }; +&usi4 { + status = "okay"; +}; + +&usi6 { + status = "okay"; +}; + +&usi9 { + status = "okay"; +}; + &watchdog_cl0 { status = "okay"; }; diff --git a/arch/arm64/boot/dts/exynos/google/zumapro.dtsi b/arch/arm64/boot/dts/exynos/google/zumapro.dtsi index 10b018b180..6316ca1cc8 100644 --- a/arch/arm64/boot/dts/exynos/google/zumapro.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zumapro.dtsi @@ -7,6 +7,7 @@ */ #include +#include #include #include @@ -104,6 +105,11 @@ compatible = "arm,cortex-a520"; reg = <0x000>; enable-method = "psci"; + capacity-dmips-mhz = <193>; + dynamic-power-coefficient = <70>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL0>; + operating-points-v2 = <&cpucl0_opp>; }; cpu1: cpu@100 { @@ -111,6 +117,11 @@ compatible = "arm,cortex-a520"; reg = <0x100>; enable-method = "psci"; + capacity-dmips-mhz = <193>; + dynamic-power-coefficient = <70>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL0>; + operating-points-v2 = <&cpucl0_opp>; }; cpu2: cpu@200 { @@ -118,6 +129,11 @@ compatible = "arm,cortex-a520"; reg = <0x200>; enable-method = "psci"; + capacity-dmips-mhz = <193>; + dynamic-power-coefficient = <70>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL0>; + operating-points-v2 = <&cpucl0_opp>; }; cpu3: cpu@300 { @@ -125,6 +141,11 @@ compatible = "arm,cortex-a520"; reg = <0x300>; enable-method = "psci"; + capacity-dmips-mhz = <193>; + dynamic-power-coefficient = <70>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL0>; + operating-points-v2 = <&cpucl0_opp>; }; cpu4: cpu@400 { @@ -132,6 +153,11 @@ compatible = "arm,cortex-a720"; reg = <0x400>; enable-method = "psci"; + capacity-dmips-mhz = <927>; + dynamic-power-coefficient = <513>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL1>; + operating-points-v2 = <&cpucl1_opp>; }; cpu5: cpu@500 { @@ -139,6 +165,11 @@ compatible = "arm,cortex-a720"; reg = <0x500>; enable-method = "psci"; + capacity-dmips-mhz = <927>; + dynamic-power-coefficient = <513>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL1>; + operating-points-v2 = <&cpucl1_opp>; }; cpu6: cpu@600 { @@ -146,6 +177,11 @@ compatible = "arm,cortex-a720"; reg = <0x600>; enable-method = "psci"; + capacity-dmips-mhz = <927>; + dynamic-power-coefficient = <513>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL1>; + operating-points-v2 = <&cpucl1_opp>; }; cpu7: cpu@700 { @@ -153,6 +189,11 @@ compatible = "arm,cortex-x4"; reg = <0x700>; enable-method = "psci"; + capacity-dmips-mhz = <1024>; + dynamic-power-coefficient = <757>; + #cooling-cells = <2>; + clocks = <&acpm_ipc ZUMAPRO_CLK_ACPM_DVFS_CPUCL2>; + operating-points-v2 = <&cpucl2_opp>; }; }; @@ -214,6 +255,342 @@ mboxes = <&ap2apm_mailbox>; shmem = <&apm_sram>; status = "disabled"; + + acpm_tmu: thermal-sensor { + compatible = "google,zumapro-acpm-tmu"; + #thermal-sensor-cells = <1>; + }; + }; + }; + + /* + * CPU levels: the APM firmware's own DVFS levels, read on the Pixel 9a + * (the little cluster's 324 and 610 MHz are below stock's 820 MHz + * floor), up to the 9a's thermal headroom: the levels above each table's + * top, listed in it, are left out for that board. A board with more + * headroom can add them. The little cluster stops at 1950 MHz, Google's + * max-freq for it. + */ + cpucl0_opp: opp-table-cpucl0 { + compatible = "operating-points-v2"; + opp-shared; + + opp-324000000 { + opp-hz = /bits/ 64 <324000000>; + }; + + opp-610000000 { + opp-hz = /bits/ 64 <610000000>; + }; + + opp-820000000 { + opp-hz = /bits/ 64 <820000000>; + }; + + opp-955000000 { + opp-hz = /bits/ 64 <955000000>; + }; + + opp-1098000000 { + opp-hz = /bits/ 64 <1098000000>; + }; + + opp-1197000000 { + opp-hz = /bits/ 64 <1197000000>; + }; + + opp-1328000000 { + opp-hz = /bits/ 64 <1328000000>; + }; + + opp-1425000000 { + opp-hz = /bits/ 64 <1425000000>; + }; + + opp-1548000000 { + opp-hz = /bits/ 64 <1548000000>; + }; + + opp-1696000000 { + opp-hz = /bits/ 64 <1696000000>; + }; + + opp-1849000000 { + opp-hz = /bits/ 64 <1849000000>; + }; + + opp-1950000000 { + opp-hz = /bits/ 64 <1950000000>; + }; + + }; + + cpucl1_opp: opp-table-cpucl1 { + compatible = "operating-points-v2"; + opp-shared; + + opp-357000000 { + opp-hz = /bits/ 64 <357000000>; + }; + + opp-578000000 { + opp-hz = /bits/ 64 <578000000>; + }; + + opp-648000000 { + opp-hz = /bits/ 64 <648000000>; + }; + + opp-787000000 { + opp-hz = /bits/ 64 <787000000>; + }; + + opp-910000000 { + opp-hz = /bits/ 64 <910000000>; + }; + + opp-1065000000 { + opp-hz = /bits/ 64 <1065000000>; + }; + + opp-1221000000 { + opp-hz = /bits/ 64 <1221000000>; + }; + + opp-1328000000 { + opp-hz = /bits/ 64 <1328000000>; + }; + + opp-1418000000 { + opp-hz = /bits/ 64 <1418000000>; + }; + + opp-1549000000 { + opp-hz = /bits/ 64 <1549000000>; + }; + + opp-1795000000 { + opp-hz = /bits/ 64 <1795000000>; + }; + + opp-1945000000 { + opp-hz = /bits/ 64 <1945000000>; + }; + + opp-2130000000 { + opp-hz = /bits/ 64 <2130000000>; + }; + + opp-2245000000 { + opp-hz = /bits/ 64 <2245000000>; + }; + + opp-2367000000 { + opp-hz = /bits/ 64 <2367000000>; + }; + + /* 2450 and 2600 MHz stay off: above the cluster's thermal headroom. */ + }; + + cpucl2_opp: opp-table-cpucl2 { + compatible = "operating-points-v2"; + opp-shared; + + opp-700000000 { + opp-hz = /bits/ 64 <700000000>; + }; + + opp-1164000000 { + opp-hz = /bits/ 64 <1164000000>; + }; + + opp-1396000000 { + opp-hz = /bits/ 64 <1396000000>; + }; + + opp-1557000000 { + opp-hz = /bits/ 64 <1557000000>; + }; + + opp-1745000000 { + opp-hz = /bits/ 64 <1745000000>; + }; + + opp-1885000000 { + opp-hz = /bits/ 64 <1885000000>; + }; + + opp-1999000000 { + opp-hz = /bits/ 64 <1999000000>; + }; + + opp-2147000000 { + opp-hz = /bits/ 64 <2147000000>; + }; + + opp-2294000000 { + opp-hz = /bits/ 64 <2294000000>; + }; + + opp-2363000000 { + opp-hz = /bits/ 64 <2363000000>; + }; + + opp-2499000000 { + opp-hz = /bits/ 64 <2499000000>; + }; + + opp-2687000000 { + opp-hz = /bits/ 64 <2687000000>; + }; + + /* + * 2802, 2914, 2943, 2970, 3015 and 3105 MHz stay off: above the + * cluster's thermal headroom. + */ + }; + + thermal-zones { + big-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&acpm_tmu 0>; + + trips { + big_alert: big-alert { + temperature = <80000>; + hysteresis = <5000>; + type = "passive"; + }; + + big_hot: big-hot { + temperature = <95000>; + hysteresis = <10000>; + type = "passive"; + }; + + big_crit: big-crit { + temperature = <105000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&big_alert>; + cooling-device = <&cpu7 0xffffffff 0xffffffff>; + }; + + map1 { + trip = <&big_hot>; + cooling-device = <&cpu7 11 0xffffffff>; + }; + }; + }; + + mid-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&acpm_tmu 1>; + + trips { + mid_alert: mid-alert { + temperature = <80000>; + hysteresis = <5000>; + type = "passive"; + }; + + mid_hot: mid-hot { + temperature = <95000>; + hysteresis = <10000>; + type = "passive"; + }; + + mid_crit: mid-crit { + temperature = <105000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&mid_alert>; + cooling-device = <&cpu4 0xffffffff 0xffffffff>; + }; + + map1 { + trip = <&mid_hot>; + cooling-device = <&cpu4 14 0xffffffff>; + }; + }; + }; + + little-thermal { + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&acpm_tmu 2>; + + trips { + little_alert: little-alert { + temperature = <80000>; + hysteresis = <5000>; + type = "passive"; + }; + + little_hot: little-hot { + temperature = <95000>; + hysteresis = <10000>; + type = "passive"; + }; + + little_crit: little-crit { + temperature = <105000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&little_alert>; + cooling-device = <&cpu0 0xffffffff 0xffffffff>; + }; + + map1 { + trip = <&little_hot>; + cooling-device = <&cpu0 11 0xffffffff>; + }; + }; + }; + + gpu-thermal { + polling-delay-passive = <1000>; + polling-delay = <2000>; + thermal-sensors = <&acpm_tmu 3>; + + trips { + gpu_alert: gpu-alert { + temperature = <85000>; + hysteresis = <5000>; + type = "passive"; + }; + + gpu_crit: gpu-crit { + temperature = <105000>; + hysteresis = <2000>; + type = "critical"; + }; + }; + + /* panthor's devfreq cooling: step_wise walks the GPU down its OPPs. */ + cooling-maps { + map0 { + trip = <&gpu_alert>; + cooling-device = <&gpu 0xffffffff 0xffffffff>; + }; + }; }; }; @@ -808,6 +1185,62 @@ }; }; + pcie_1: pcie@13120000 { + compatible = "google,zumapro-pcie"; + reg = <0x0 0x13120000 0x2000>, <0x0 0x13130000 0x5000>, + <0x0 0x13150000 0xd000>, <0x0 0x13160000 0x3000>, + <0x0 0x13140000 0x5000>, <0x0 0x13100000 0x1000>, + <0x0 0x13400000 0x381000>, <0x0 0x60ffe000 0x2000>; + reg-names = "elbi", "soc", "udbg", "phy", "pcs", "ia", "dbi", + "config"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x60000000 0x0 0x60000000 0x0 0xff0000>; + bus-range = <0x00 0xff>; + interrupts = , + , + , + , + , + ; + interrupt-names = "ctrl", "msi0", "msi1", "msi2", "msi3", + "msi4"; + clocks = <&cmu_hsi2 CLK_GOUT_PCIE1_CTL_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_DBI_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SLV_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_MSTR_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_UDBG_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_PAL_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_REF>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_BRIDGE_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PHY_TEST_APB>, + <&cmu_hsi2 CLK_GOUT_PCIE1_IA_CLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SSMT_IA_ACLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SSMT_IA_PCLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_SYSMMU_CLK>, + <&cmu_hsi2 CLK_GOUT_PCIE1_PMMU_CLK>; + clock-names = "ctl-apb", "dbi-aclk", "slv-aclk", "mstr-aclk", + "phy-udbg-apb", "phy-pal-apb", "phy-ref", + "phy-bridge-apb", "phy-test-apb", "ia-clk", + "ssmt-ia-aclk", "ssmt-ia-pclk", "sysmmu-clk", + "pmmu-clk"; + samsung,pmu-syscon = <&pmu_system_controller 0x3ec8>; + num-lanes = <1>; + max-link-speed = <2>; + status = "disabled"; + + pcie_1_rp: pcie@0,0 { + compatible = "pciclass,0604"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + bus-range = <0x01 0xff>; + ranges; + }; + }; + ufs: ufs@13200000 { compatible = "google,zumapro-ufs"; reg = <0x0 0x13200000 0x200>, @@ -1080,6 +1513,18 @@ }; }; + dsi0: dsi@19440000 { + compatible = "google,zumapro-dsim", "google,gs201-dsim"; + reg = <0x0 0x19440000 0x300>, + <0x0 0x19460100 0x700>, + <0x0 0x19460000 0x100>; + reg-names = "dsi", "dphy", "dphy-extra"; + interrupts = ; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + /* Scans out what the bootloader set up; no panel or clock control. */ decon0: display-controller@19470000 { compatible = "google,zumapro-decon"; @@ -1115,6 +1560,7 @@ <&cmu_g3d CLK_GOUT_G3D_COREGROUP>, <&cmu_g3d CLK_GOUT_G3D_STACKS>; clock-names = "core", "coregroup", "stacks"; + #cooling-cells = <2>; status = "disabled"; }; diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index dcfbe7e229..0b6303acb8 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -577,4 +577,19 @@ config PCIE_ULTRARISC By default, this symbol is enabled when ARCH_ULTRARISC is active, requiring no further configuration on that platform. +config PCIE_ZUMAPRO + tristate "Google zumapro PCIe controller (host mode)" + depends on OF && (ARCH_EXYNOS || COMPILE_TEST) + depends on PCI_MSI + select PCIE_DW_HOST + select PCI_PWRCTRL_GENERIC + help + Say Y here to enable support for PCIe channel 1 of the Google + zumapro (Tensor G4) SoC in host mode. The Pixel 9a connects its + Wi-Fi chip to it. The controller is a DesignWare core in a Samsung + wrapper, with its PHY programmed by this driver. + + To compile this driver as a module, choose M here: the module + will be called pcie-zumapro. + endmenu diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile index d4f88cfc62..736fbf5cb2 100644 --- a/drivers/pci/controller/dwc/Makefile +++ b/drivers/pci/controller/dwc/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_PCIE_SPACEMIT_K1) += pcie-spacemit-k1.o obj-$(CONFIG_PCIE_STM32_HOST) += pcie-stm32.o obj-$(CONFIG_PCIE_STM32_EP) += pcie-stm32-ep.o obj-$(CONFIG_PCIE_ULTRARISC) += pcie-ultrarisc.o +obj-$(CONFIG_PCIE_ZUMAPRO) += pcie-zumapro.o # The following drivers are for devices that use the generic ACPI # pci_root.c driver but don't support standard ECAM config access. diff --git a/drivers/pci/controller/dwc/pcie-zumapro.c b/drivers/pci/controller/dwc/pcie-zumapro.c new file mode 100644 index 0000000000..3f7b299643 --- /dev/null +++ b/drivers/pci/controller/dwc/pcie-zumapro.c @@ -0,0 +1,612 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * PCIe host controller driver for channel 1 of the Google zumapro (Tensor G4) + * + * Channel 1 is a one-lane Synopsys DesignWare core in a Samsung wrapper, with + * its PHY behind an isolation switch in the PMU. On the Pixel 9a it carries + * the Wi-Fi chip. The sequence follows the root-complex driver Google builds + * for zumapro, google-modules/soc/gs drivers/pci/controller/dwc/ + * pcie-exynos-rc.c and pcie-exynos-zuma-rc-cal.c ("PCIe CAL ver 0.2"), for + * channel 1 with a Broadcom Wi-Fi endpoint, reduced to what the DesignWare + * core does not do itself. + * + * Nothing in the wrapper, the PHY or the DBI may be accessed while the PHY is + * isolated, so every register access happens between opening the isolation + * in host_init and closing it again on the way down. + * + * Not handled yet: L1 substates and ASPM L1 exit (the I/A sequencer is not + * programmed, so ASPM is kept off by clearing it from the root port's link + * capabilities), INTx, the System MMU, and system suspend with the link + * powered down. + * + * Copyright (C) 2020 Samsung Electronics Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcie-designware.h" + +/* ELBI (sub-control) registers */ +#define ZUMAPRO_ELBI_IRQ0 0x000 +#define ZUMAPRO_ELBI_IRQ1 0x004 +#define ZUMAPRO_ELBI_IRQ2 0x008 +#define ZUMAPRO_ELBI_LTSSM_EN 0x054 +#define ZUMAPRO_ELBI_XFER_PENDING 0x074 +#define ZUMAPRO_ELBI_LTSSM_STATE 0x2c8 +#define ZUMAPRO_ELBI_LTSSM_STATE_MASK GENMASK(5, 0) +#define ZUMAPRO_ELBI_LINKDOWN_RST_SEL 0x3a0 +#define ZUMAPRO_ELBI_LINKDOWN_RST_MANUAL BIT(1) +#define ZUMAPRO_ELBI_SOFT_RESET 0x3a4 +#define ZUMAPRO_ELBI_SOFT_PWR_RESET BIT(1) +#define ZUMAPRO_ELBI_QCH_SEL 0x3a8 +#define ZUMAPRO_ELBI_QCH_GATING_MASK GENMASK(11, 0) +#define ZUMAPRO_ELBI_REQ_EXIT_L1_MODE 0x3bc +#define ZUMAPRO_ELBI_APP_REQ_EXIT_L1_MODE BIT(0) +#define ZUMAPRO_ELBI_L1_REQ_NAK_MASTER BIT(4) +#define ZUMAPRO_ELBI_MSTR_PEND_SEL_NAK 0x474 +#define ZUMAPRO_ELBI_DBI_L1_EXIT_DISABLE 0x1078 + +/* Sub-system control; clearing SEL switches to the OSC clock, in SW mode */ +#define ZUMAPRO_SOC_CLK_CTRL 0x4000 +#define ZUMAPRO_SOC_CLK_CTRL_ON 0x15 +#define ZUMAPRO_SOC_CLK_CTRL_SEL GENMASK(1, 0) + +/* Values Google's driver writes outside the CAL tables, for channel 1 */ +#define ZUMAPRO_UDBG_C800 0xc800 +#define ZUMAPRO_UDBG_C800_VAL 0x421 +#define ZUMAPRO_PHY_032C 0x032c + +/* DBI port logic */ +#define ZUMAPRO_DBI_AUX_CLK_FREQ 0xb40 +#define ZUMAPRO_DBI_AUX_CLK_26MHZ 0x1a + +/* PMU PHY control */ +#define ZUMAPRO_PMU_PHY_ISO_BYPASS BIT(0) +#define ZUMAPRO_PMU_PHY_CONFIGURED BIT(10) + +/* What Google's driver waits after PERST# goes high, before training */ +#define ZUMAPRO_PERST_DELAY_US 15000 +#define ZUMAPRO_L0_TIMEOUT_US 100000 +#define ZUMAPRO_PHY_POLL_TIMEOUT_US 10000 + +enum zumapro_pcie_blk { + ZUMAPRO_BLK_ELBI, + ZUMAPRO_BLK_SOC, + ZUMAPRO_BLK_UDBG, + ZUMAPRO_BLK_PHY, + ZUMAPRO_BLK_PCS, + ZUMAPRO_BLK_COUNT, +}; + +enum zumapro_pcie_opcode { + ZUMAPRO_OP_WRITE, + ZUMAPRO_OP_SET, + ZUMAPRO_OP_CLEAR, + ZUMAPRO_OP_DELAY_US, + ZUMAPRO_OP_POLL_BIT, +}; + +/* + * One step of a CAL table: write a value, set or clear bits, wait a number of + * microseconds, or wait for one bit to read 1. + */ +struct zumapro_pcie_op { + u8 op; + u8 blk; + u16 offset; + u32 value; +}; + +#define ZP_WR(b, o, v) { ZUMAPRO_OP_WRITE, ZUMAPRO_BLK_##b, o, v } +#define ZP_SET(b, o, v) { ZUMAPRO_OP_SET, ZUMAPRO_BLK_##b, o, v } +#define ZP_CLR(b, o, v) { ZUMAPRO_OP_CLEAR, ZUMAPRO_BLK_##b, o, v } +#define ZP_POLL(b, o, v) { ZUMAPRO_OP_POLL_BIT, ZUMAPRO_BLK_##b, o, v } +#define ZP_DELAY(us) { ZUMAPRO_OP_DELAY_US, 0, 0, us } + +/* exynos_pcie_rc_phy_all_pwrdn_clear() for channel 1 */ +static const struct zumapro_pcie_op zumapro_pcie_phy_pwrdn_clear[] = { + ZP_SET(UDBG, 0xc700, BIT(0)), + ZP_DELAY(100), + ZP_WR(PHY, 0x000c, 0x00), + ZP_WR(PHY, 0x0928, 0x55), + ZP_WR(PHY, 0x0580, 0x02), + ZP_WR(PHY, 0x0208, 0x00), + ZP_WR(PHY, 0x1044, 0x00), + ZP_WR(PHY, 0x1048, 0x00), + ZP_WR(PHY, 0x104c, 0x00), + ZP_WR(PHY, 0x1050, 0x00), + ZP_WR(PHY, 0x185c, 0x00), + ZP_DELAY(10), +}; + +/* exynos_pcie_rc_pcie_phy_config() for channel 1, Broadcom Wi-Fi endpoint */ +static const struct zumapro_pcie_op zumapro_pcie_phy_config[] = { + ZP_WR(PHY, 0x032c, 0x03), + ZP_SET(UDBG, 0xc700, BIT(0)), + ZP_CLR(UDBG, 0xc700, BIT(1)), + ZP_POLL(UDBG, 0xc734, 2), /* external PLL lock */ + ZP_CLR(SOC, 0x4004, BIT(2)), + ZP_SET(SOC, 0x4004, GENMASK(5, 4)), + ZP_WR(ELBI, 0x0080, 0x4), /* device type: root complex */ + ZP_WR(ELBI, 0x03a4, 0xf), + ZP_WR(ELBI, 0x03a4, 0xd), + ZP_DELAY(10), + ZP_WR(ELBI, 0x03a4, 0xf), + ZP_DELAY(10), + ZP_WR(ELBI, 0x1404, 0x1), + ZP_WR(ELBI, 0x1408, 0x1), + ZP_WR(ELBI, 0x1400, 0x1), + ZP_WR(ELBI, 0x1404, 0x0), + ZP_WR(ELBI, 0x1408, 0x0), + ZP_WR(ELBI, 0x1400, 0x0), + ZP_WR(ELBI, 0x03d8, 0x1), + ZP_WR(PHY, 0x0000, 0x88), + ZP_WR(PHY, 0x001c, 0x66), + ZP_WR(PHY, 0x01f4, 0x00), + ZP_WR(PHY, 0x0514, 0x59), + ZP_WR(PHY, 0x051c, 0x11), + ZP_WR(PHY, 0x062c, 0x0e), + ZP_WR(PHY, 0x0644, 0x22), + ZP_WR(PHY, 0x0688, 0x03), + ZP_WR(PHY, 0x06d4, 0x28), + ZP_WR(PHY, 0x0788, 0x64), + ZP_WR(PHY, 0x078c, 0x64), + ZP_WR(PHY, 0x0790, 0x50), + ZP_WR(PHY, 0x0794, 0x50), + ZP_WR(PHY, 0x0944, 0x05), + ZP_WR(PHY, 0x0948, 0x05), + ZP_WR(PHY, 0x094c, 0x05), + ZP_WR(PHY, 0x0950, 0x05), + ZP_WR(PHY, 0x0590, 0x02), + ZP_WR(PHY, 0x07f8, 0xb0), + ZP_WR(PHY, 0x0730, 0x08), + ZP_WR(PHY, 0x0344, 0xc0), + ZP_WR(PHY, 0x0040, 0x04), + ZP_WR(PHY, 0x0204, 0x03), + ZP_WR(PHY, 0x02d4, 0x1f), + ZP_WR(PHY, 0x0358, 0x10), + ZP_WR(PHY, 0x0018, 0x01), + ZP_WR(PHY, 0x0514, 0x5b), + ZP_WR(PHY, 0x0608, 0x0c), + ZP_WR(PHY, 0x060c, 0x0f), + ZP_WR(PHY, 0x0610, 0x0f), + ZP_WR(PHY, 0x0614, 0x0f), + ZP_WR(PHY, 0x0618, 0x0f), + ZP_WR(PHY, 0x0510, 0x80), + ZP_WR(PHY, 0x0688, 0x03), + ZP_WR(PHY, 0x0644, 0x23), + ZP_WR(PHY, 0x0624, 0x11), + ZP_WR(PHY, 0x0630, 0x0f), + ZP_WR(PHY, 0x06d0, 0x53), + ZP_WR(PHY, 0x1140, 0x04), + ZP_WR(PHY, 0x1144, 0x04), + ZP_WR(PHY, 0x1148, 0x04), + ZP_WR(PHY, 0x114c, 0x02), + ZP_WR(PHY, 0x1150, 0x00), + ZP_WR(PHY, 0x1154, 0x00), + ZP_WR(PHY, 0x1158, 0x00), + ZP_WR(PHY, 0x115c, 0x00), + ZP_WR(PHY, 0x12cc, 0x1c), + ZP_WR(PHY, 0x12dc, 0x6c), + ZP_WR(PHY, 0x130c, 0x29), + ZP_WR(PHY, 0x13b4, 0x2f), + ZP_WR(PHY, 0x1a64, 0x05), + ZP_WR(PHY, 0x1a68, 0x05), + ZP_WR(PHY, 0x1a84, 0x05), + ZP_WR(PHY, 0x1a88, 0x05), + ZP_WR(PHY, 0x1a98, 0x00), + ZP_WR(PHY, 0x1a9c, 0x00), + ZP_WR(PHY, 0x1aa8, 0x07), + ZP_WR(PHY, 0x1ab8, 0x00), + ZP_WR(PHY, 0x1abc, 0x00), + ZP_WR(PHY, 0x1af8, 0x90), + ZP_WR(PHY, 0x1b34, 0x03), + ZP_WR(PHY, 0x1bb0, 0x03), + ZP_WR(PHY, 0x1bb4, 0x03), + ZP_WR(PHY, 0x1bc0, 0x06), + ZP_WR(PHY, 0x1bc4, 0x06), + ZP_WR(PHY, 0x1be8, 0x01), + ZP_WR(PHY, 0x1bf8, 0x04), + ZP_WR(PHY, 0x1c98, 0x00), + ZP_WR(PHY, 0x1ca4, 0x81), + /* Broadcom Wi-Fi endpoint */ + ZP_WR(PHY, 0x1b20, 0x02), + ZP_WR(PHY, 0x1340, 0x23), + ZP_WR(PHY, 0x002c, 0x3c), + ZP_SET(PHY, 0x1350, BIT(0)), + ZP_WR(PCS, 0x0190, 0x100b0604), + ZP_WR(PCS, 0x0154, 0x000700d5), + ZP_WR(PCS, 0x0100, 0x16400000), + ZP_WR(PCS, 0x0104, 0x08600000), + ZP_WR(PCS, 0x0114, 0x18500000), + ZP_WR(PCS, 0x0124, 0x60700000), + ZP_WR(PCS, 0x0174, 0x00000007), + ZP_WR(PCS, 0x0178, 0x00000100), + ZP_WR(PCS, 0x017c, 0x00000700), /* Broadcom Wi-Fi endpoint */ + ZP_WR(PCS, 0x0110, 0x01600202), /* Broadcom Wi-Fi endpoint */ + ZP_WR(ELBI, 0x1404, 0x1), + ZP_DELAY(10), + ZP_WR(ELBI, 0x1408, 0x1), + ZP_WR(ELBI, 0x1400, 0x1), + ZP_POLL(PHY, 0x0a80, 0), /* PLL lock */ + ZP_POLL(PHY, 0x15c0, 4), /* CDR lock */ + ZP_POLL(PHY, 0x140c, 7), /* offset calibration done */ + ZP_WR(PHY, 0x032c, 0x00), + ZP_WR(ELBI, 0x1078, 0x1), +}; + +/* exynos_pcie_rc_phy_all_pwrdn() for channel 1 */ +static const struct zumapro_pcie_op zumapro_pcie_phy_pwrdn[] = { + ZP_CLR(PHY, 0x0204, GENMASK(3, 2)), + ZP_WR(PHY, 0x1044, 0x2a), + ZP_WR(PHY, 0x1048, 0xaa), + ZP_WR(PHY, 0x104c, 0xa8), + ZP_WR(PHY, 0x1050, 0x80), + ZP_WR(PHY, 0x185c, 0x0a), + ZP_DELAY(1), + ZP_WR(PHY, 0x0208, 0xff), + ZP_DELAY(1), + ZP_WR(PHY, 0x0580, 0x0a), + ZP_WR(PHY, 0x0928, 0xaa), + ZP_WR(PHY, 0x000c, 0x0a), + ZP_DELAY(50), + ZP_CLR(UDBG, 0xc700, BIT(0)), + ZP_DELAY(10), +}; + +static const char * const zumapro_pcie_blk_names[ZUMAPRO_BLK_COUNT] = { + [ZUMAPRO_BLK_ELBI] = "elbi", + [ZUMAPRO_BLK_SOC] = "soc", + [ZUMAPRO_BLK_UDBG] = "udbg", + [ZUMAPRO_BLK_PHY] = "phy", + [ZUMAPRO_BLK_PCS] = "pcs", +}; + +struct zumapro_pcie { + struct dw_pcie pci; + void __iomem *blk[ZUMAPRO_BLK_COUNT]; + struct clk_bulk_data *clks; + int num_clks; + struct regmap *pmu; + u32 pmu_offset; + struct gpio_desc *perst; +}; + +#define to_zumapro_pcie(x) container_of(x, struct zumapro_pcie, pci) + +static int zumapro_pcie_run(struct zumapro_pcie *zp, + const struct zumapro_pcie_op *ops, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + const struct zumapro_pcie_op *o = &ops[i]; + void __iomem *reg = zp->blk[o->blk] + o->offset; + u32 val; + int ret; + + switch (o->op) { + case ZUMAPRO_OP_WRITE: + writel(o->value, reg); + break; + case ZUMAPRO_OP_SET: + writel(readl(reg) | o->value, reg); + break; + case ZUMAPRO_OP_CLEAR: + writel(readl(reg) & ~o->value, reg); + break; + case ZUMAPRO_OP_DELAY_US: + udelay(o->value); + break; + case ZUMAPRO_OP_POLL_BIT: + ret = readl_poll_timeout(reg, val, val & BIT(o->value), + 10, ZUMAPRO_PHY_POLL_TIMEOUT_US); + if (ret) { + dev_err(zp->pci.dev, + "%s+%#x bit %u did not set (%#010x)\n", + zumapro_pcie_blk_names[o->blk], + o->offset, o->value, val); + return ret; + } + break; + } + } + + return 0; +} + +static u32 zumapro_pcie_ltssm(struct zumapro_pcie *zp) +{ + return readl(zp->pci.elbi_base + ZUMAPRO_ELBI_LTSSM_STATE) & + ZUMAPRO_ELBI_LTSSM_STATE_MASK; +} + +static enum dw_pcie_ltssm zumapro_pcie_get_ltssm(struct dw_pcie *pci) +{ + return zumapro_pcie_ltssm(to_zumapro_pcie(pci)); +} + +/* + * As Google's driver: recovery, L0, L0s and L1 all count as up. An endpoint + * in D3hot parks the link in L1, and with an L0-only check the DesignWare + * core would refuse the configuration write that brings it back to D0. + */ +static bool zumapro_pcie_link_up(struct dw_pcie *pci) +{ + u32 ltssm = zumapro_pcie_ltssm(to_zumapro_pcie(pci)); + + return ltssm >= DW_PCIE_LTSSM_RCVRY_LOCK && ltssm <= DW_PCIE_LTSSM_L1_IDLE; +} + +static int zumapro_pcie_start_link(struct dw_pcie *pci) +{ + struct zumapro_pcie *zp = to_zumapro_pcie(pci); + void __iomem *elbi = pci->elbi_base; + u32 ltssm; + int ret; + + writel(1, elbi + ZUMAPRO_ELBI_LTSSM_EN); + + /* + * Google's driver waits for L0, acknowledges the ELBI interrupt status + * and only then drops XFER_PENDING, which host_init raised before + * training. With it left raised, configuration works but every memory + * read of the endpoint returns all ones. + */ + ret = readl_poll_timeout(elbi + ZUMAPRO_ELBI_LTSSM_STATE, ltssm, + (ltssm & ZUMAPRO_ELBI_LTSSM_STATE_MASK) == + DW_PCIE_LTSSM_L0, 10, ZUMAPRO_L0_TIMEOUT_US); + if (ret) + dev_dbg(pci->dev, "LTSSM %#x, not L0 yet\n", + zumapro_pcie_ltssm(zp)); + + writel(readl(elbi + ZUMAPRO_ELBI_IRQ0), elbi + ZUMAPRO_ELBI_IRQ0); + writel(readl(elbi + ZUMAPRO_ELBI_IRQ1), elbi + ZUMAPRO_ELBI_IRQ1); + writel(readl(elbi + ZUMAPRO_ELBI_IRQ2), elbi + ZUMAPRO_ELBI_IRQ2); + writel(0, elbi + ZUMAPRO_ELBI_XFER_PENDING); + + return 0; +} + +static void zumapro_pcie_stop_link(struct dw_pcie *pci) +{ + writel(0, pci->elbi_base + ZUMAPRO_ELBI_LTSSM_EN); +} + +/* ASPM L1 exit needs the I/A sequencer, which is not programmed */ +static void zumapro_pcie_disable_aspm(struct dw_pcie *pci) +{ + u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); + u32 val; + + dw_pcie_dbi_ro_wr_en(pci); + val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP); + val &= ~PCI_EXP_LNKCAP_ASPMS; + dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, val); + dw_pcie_dbi_ro_wr_dis(pci); +} + +/* + * Undo host_init in the order of Google's exynos_pcie_rc_poweroff(), the PHY + * isolation last: nothing here may be touched once it is closed. + */ +static void zumapro_pcie_power_off(struct zumapro_pcie *zp) +{ + struct dw_pcie *pci = &zp->pci; + void __iomem *elbi = pci->elbi_base; + void __iomem *soc = zp->blk[ZUMAPRO_BLK_SOC]; + u32 val; + + gpiod_set_value_cansleep(zp->perst, 1); + writel(readl(soc + ZUMAPRO_SOC_CLK_CTRL) & ~ZUMAPRO_SOC_CLK_CTRL_SEL, + soc + ZUMAPRO_SOC_CLK_CTRL); + writel(0, elbi + ZUMAPRO_ELBI_LTSSM_EN); + + val = readl(elbi + ZUMAPRO_ELBI_SOFT_RESET); + writel(val & ~ZUMAPRO_ELBI_SOFT_PWR_RESET, elbi + ZUMAPRO_ELBI_SOFT_RESET); + usleep_range(20, 40); + writel(val | ZUMAPRO_ELBI_SOFT_PWR_RESET, elbi + ZUMAPRO_ELBI_SOFT_RESET); + + zumapro_pcie_run(zp, zumapro_pcie_phy_pwrdn, + ARRAY_SIZE(zumapro_pcie_phy_pwrdn)); + clk_bulk_disable_unprepare(zp->num_clks, zp->clks); + pci_pwrctrl_power_off_devices(pci->dev); + regmap_update_bits(zp->pmu, zp->pmu_offset, ZUMAPRO_PMU_PHY_ISO_BYPASS, 0); +} + +static int zumapro_pcie_host_init(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct zumapro_pcie *zp = to_zumapro_pcie(pci); + struct device *dev = pci->dev; + void __iomem *elbi = pci->elbi_base; + u32 val; + int ret; + + ret = regmap_update_bits(zp->pmu, zp->pmu_offset, + ZUMAPRO_PMU_PHY_ISO_BYPASS, + ZUMAPRO_PMU_PHY_ISO_BYPASS); + if (ret) + return dev_err_probe(dev, ret, "failed to open the PHY isolation\n"); + + ret = clk_bulk_prepare_enable(zp->num_clks, zp->clks); + if (ret) { + dev_err(dev, "failed to enable the clocks: %d\n", ret); + goto err_isolate; + } + + /* The endpoint's power enable, held until PERST# is released below */ + ret = pci_pwrctrl_power_on_devices(dev); + if (ret) { + dev_err_probe(dev, ret, "failed to power the endpoint on\n"); + goto err_clocks; + } + + writel(ZUMAPRO_SOC_CLK_CTRL_ON, zp->blk[ZUMAPRO_BLK_SOC] + ZUMAPRO_SOC_CLK_CTRL); + zumapro_pcie_run(zp, zumapro_pcie_phy_pwrdn_clear, + ARRAY_SIZE(zumapro_pcie_phy_pwrdn_clear)); + ret = zumapro_pcie_run(zp, zumapro_pcie_phy_config, + ARRAY_SIZE(zumapro_pcie_phy_config)); + if (ret) + goto err_power_off; + + ret = regmap_update_bits(zp->pmu, zp->pmu_offset, + ZUMAPRO_PMU_PHY_CONFIGURED, + ZUMAPRO_PMU_PHY_CONFIGURED); + if (ret) { + dev_err(dev, "failed to mark the PHY configured: %d\n", ret); + goto err_power_off; + } + writel(ZUMAPRO_UDBG_C800_VAL, zp->blk[ZUMAPRO_BLK_UDBG] + ZUMAPRO_UDBG_C800); + writel(0, zp->blk[ZUMAPRO_BLK_PHY] + ZUMAPRO_PHY_032C); + dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, + GEN3_RELATED_OFF_GEN3_EQ_DISABLE | + GEN3_RELATED_OFF_RXEQ_RGRDLESS_RXTS); + + gpiod_set_value_cansleep(zp->perst, 0); + usleep_range(ZUMAPRO_PERST_DELAY_US, ZUMAPRO_PERST_DELAY_US + 2000); + + val = readl(elbi + ZUMAPRO_ELBI_REQ_EXIT_L1_MODE); + val |= ZUMAPRO_ELBI_APP_REQ_EXIT_L1_MODE | ZUMAPRO_ELBI_L1_REQ_NAK_MASTER; + writel(val, elbi + ZUMAPRO_ELBI_REQ_EXIT_L1_MODE); + writel(ZUMAPRO_ELBI_LINKDOWN_RST_MANUAL, elbi + ZUMAPRO_ELBI_LINKDOWN_RST_SEL); + writel(1, elbi + ZUMAPRO_ELBI_XFER_PENDING); + val = readl(elbi + ZUMAPRO_ELBI_QCH_SEL) & ~ZUMAPRO_ELBI_QCH_GATING_MASK; + writel(val, elbi + ZUMAPRO_ELBI_QCH_SEL); + writel(1, elbi + ZUMAPRO_ELBI_MSTR_PEND_SEL_NAK); + writel(1, elbi + ZUMAPRO_ELBI_DBI_L1_EXIT_DISABLE); + + dw_pcie_writel_dbi(pci, ZUMAPRO_DBI_AUX_CLK_FREQ, ZUMAPRO_DBI_AUX_CLK_26MHZ); + zumapro_pcie_disable_aspm(pci); + + return 0; + +err_power_off: + zumapro_pcie_power_off(zp); + return ret; + +err_clocks: + clk_bulk_disable_unprepare(zp->num_clks, zp->clks); +err_isolate: + regmap_update_bits(zp->pmu, zp->pmu_offset, ZUMAPRO_PMU_PHY_ISO_BYPASS, 0); + return ret; +} + +static void zumapro_pcie_host_deinit(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + + zumapro_pcie_power_off(to_zumapro_pcie(pci)); +} + +static const struct dw_pcie_host_ops zumapro_pcie_host_ops = { + .init = zumapro_pcie_host_init, + .deinit = zumapro_pcie_host_deinit, +}; + +static const struct dw_pcie_ops zumapro_pcie_dw_ops = { + .link_up = zumapro_pcie_link_up, + .get_ltssm = zumapro_pcie_get_ltssm, + .start_link = zumapro_pcie_start_link, + .stop_link = zumapro_pcie_stop_link, +}; + +static int zumapro_pcie_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct of_phandle_args args; + struct zumapro_pcie *zp; + int i, ret; + + zp = devm_kzalloc(dev, sizeof(*zp), GFP_KERNEL); + if (!zp) + return -ENOMEM; + + zp->pci.dev = dev; + zp->pci.ops = &zumapro_pcie_dw_ops; + zp->pci.pp.ops = &zumapro_pcie_host_ops; + platform_set_drvdata(pdev, zp); + + /* Mapped here rather than by the DesignWare core, which would too */ + for (i = 0; i < ZUMAPRO_BLK_COUNT; i++) { + const char *name = zumapro_pcie_blk_names[i]; + + zp->blk[i] = devm_platform_ioremap_resource_byname(pdev, name); + if (IS_ERR(zp->blk[i])) + return PTR_ERR(zp->blk[i]); + } + zp->pci.elbi_base = zp->blk[ZUMAPRO_BLK_ELBI]; + + zp->num_clks = devm_clk_bulk_get_all(dev, &zp->clks); + if (zp->num_clks < 0) + return dev_err_probe(dev, zp->num_clks, "failed to get the clocks\n"); + + ret = of_parse_phandle_with_fixed_args(dev->of_node, "samsung,pmu-syscon", + 1, 0, &args); + if (ret) + return dev_err_probe(dev, ret, "no samsung,pmu-syscon\n"); + zp->pmu_offset = args.args[0]; + of_node_put(args.np); + + zp->pmu = exynos_get_pmu_regmap_by_phandle(dev->of_node, "samsung,pmu-syscon"); + if (IS_ERR(zp->pmu)) + return dev_err_probe(dev, PTR_ERR(zp->pmu), "failed to get the PMU\n"); + + /* PERST# asserted until the PHY is configured */ + zp->perst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(zp->perst)) + return dev_err_probe(dev, PTR_ERR(zp->perst), "failed to get PERST#\n"); + + ret = pci_pwrctrl_create_devices(dev); + if (ret) + return dev_err_probe(dev, ret, "failed to create pwrctrl devices\n"); + + ret = dw_pcie_host_init(&zp->pci.pp); + if (ret) { + pci_pwrctrl_destroy_devices(dev); + return dev_err_probe(dev, ret, "failed to initialize the host\n"); + } + + return 0; +} + +static void zumapro_pcie_remove(struct platform_device *pdev) +{ + struct zumapro_pcie *zp = platform_get_drvdata(pdev); + + dw_pcie_host_deinit(&zp->pci.pp); + pci_pwrctrl_destroy_devices(&pdev->dev); +} + +static const struct of_device_id zumapro_pcie_of_match[] = { + { .compatible = "google,zumapro-pcie" }, + { } +}; +MODULE_DEVICE_TABLE(of, zumapro_pcie_of_match); + +static struct platform_driver zumapro_pcie_driver = { + .driver = { + .name = "zumapro-pcie", + .of_match_table = zumapro_pcie_of_match, + .suppress_bind_attrs = true, + }, + .probe = zumapro_pcie_probe, + .remove = zumapro_pcie_remove, +}; +module_platform_driver(zumapro_pcie_driver); + +MODULE_DESCRIPTION("Google zumapro PCIe host controller driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/soc/samsung/gs101-pmu.c b/drivers/soc/samsung/gs101-pmu.c index e357744d4a..a1fbaa2ecd 100644 --- a/drivers/soc/samsung/gs101-pmu.c +++ b/drivers/soc/samsung/gs101-pmu.c @@ -343,6 +343,7 @@ const struct exynos_pmu_data gs101_pmu_data = { #define ZUMA_CLUSTER1_NONCPU_INT_EN 0x1544 #define ZUMA_HSI0_STATUS 0x2a84 #define ZUMA_PHY_CTRL_UFS 0x3ec0 +#define ZUMA_PHY_CTRL_PCIE1 0x3ec8 static const struct regmap_range zuma_pmu_registers[] = { /* reboot mode */ @@ -358,6 +359,7 @@ static const struct regmap_range zuma_pmu_registers[] = { /* PHY isolation */ regmap_reg_range(GS101_PHY_CTRL_USB20, GS101_PHY_CTRL_USB20), regmap_reg_range(ZUMA_PHY_CTRL_UFS, ZUMA_PHY_CTRL_UFS), + regmap_reg_range(ZUMA_PHY_CTRL_PCIE1, ZUMA_PHY_CTRL_PCIE1), /* a hint TF-A reads, not a status register: see zuma_pmu_regmap_init() */ regmap_reg_range(ZUMA_PMU_INFORM0, ZUMA_PMU_INFORM0), };