diff --git a/Documentation/devicetree/bindings/clock/google,zuma-clock.yaml b/Documentation/devicetree/bindings/clock/google,zuma-clock.yaml index cd708ab082..11d78ddd41 100644 --- a/Documentation/devicetree/bindings/clock/google,zuma-clock.yaml +++ b/Documentation/devicetree/bindings/clock/google,zuma-clock.yaml @@ -13,6 +13,8 @@ description: | CMU_TOP supplies the HSI0 NoC and peripheral clocks to CMU_HSI0 from its shared PLLs. CMU_HSI0 supplies USI2, the touchscreen's SPI, from the HSI0 peripheral clock; its NoC path also takes the board-level HSI0 ALT clock. + CMU_TOP also supplies the PERIC1 NoC and USI input clocks to CMU_PERIC1, + which supplies USI11, the I2C bus of the battery, charger and USB-C chips. CMU_APM supplies the APM mailbox, its internal memory and the always-on GPIO banks from the always-on ALV PLL and the oscillator. The external oscillator supplies the PLL reference and the oscillator mux @@ -25,6 +27,7 @@ properties: - google,zuma-cmu-top - google,zuma-cmu-apm - google,zuma-cmu-hsi0 + - google,zuma-cmu-peric1 reg: maxItems: 1 @@ -80,6 +83,22 @@ allOf: - const: bus - const: peri - const: alt + - if: + properties: + compatible: + const: google,zuma-cmu-peric1 + then: + properties: + clocks: + items: + - description: External oscillator reference clock + - description: PERIC1 NoC clock from CMU_TOP + - description: PERIC1 USI input clock from CMU_TOP + clock-names: + items: + - const: oscclk + - const: bus + - const: ip additionalProperties: false @@ -104,4 +123,13 @@ examples: clock-names = "oscclk", "bus", "peri", "alt"; }; + clock-controller@10c00000 { + compatible = "google,zuma-cmu-peric1"; + reg = <0x10c00000 0x8000>; + #clock-cells = <1>; + clocks = <&oscclk>, <&cmu_top CLK_DOUT_PERIC1_NOC>, + <&cmu_top CLK_DOUT_PERIC1_IP>; + clock-names = "oscclk", "bus", "ip"; + }; + ... diff --git a/Documentation/devicetree/bindings/i2c/i2c-exynos5.yaml b/Documentation/devicetree/bindings/i2c/i2c-exynos5.yaml index b4ed5cd251..e15efb553b 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-exynos5.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-exynos5.yaml @@ -41,6 +41,7 @@ properties: - enum: - google,gs101-hsi2c - google,gs201-hsi2c + - google,zuma-hsi2c - google,zumapro-hsi2c - samsung,exynos2200-hsi2c - samsung,exynos850-hsi2c diff --git a/Documentation/devicetree/bindings/soc/samsung/samsung,exynos-sysreg.yaml b/Documentation/devicetree/bindings/soc/samsung/samsung,exynos-sysreg.yaml index 2a181df90c..8cb6ce85da 100644 --- a/Documentation/devicetree/bindings/soc/samsung/samsung,exynos-sysreg.yaml +++ b/Documentation/devicetree/bindings/soc/samsung/samsung,exynos-sysreg.yaml @@ -28,6 +28,7 @@ properties: - google,gs201-peric1-sysreg - google,gs201-vgpio2ap-sysreg - google,zuma-hsi0-sysreg + - google,zuma-peric1-sysreg - google,zuma-ufs-sysreg - google,zumapro-apm-sysreg - google,zumapro-hsi0-sysreg @@ -116,6 +117,7 @@ allOf: - google,gs201-hsi2-sysreg - google,gs201-peric0-sysreg - google,gs201-peric1-sysreg + - google,zuma-peric1-sysreg - google,zumapro-apm-sysreg - google,zumapro-hsi0-sysreg - google,zumapro-peric0-sysreg diff --git a/arch/arm64/boot/dts/exynos/google/zuma-husky.dts b/arch/arm64/boot/dts/exynos/google/zuma-husky.dts index 29b9a11b98..cbfaefbc66 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma-husky.dts +++ b/arch/arm64/boot/dts/exynos/google/zuma-husky.dts @@ -7,6 +7,8 @@ #include #include +#include +#include #include "zuma.dtsi" / { @@ -105,6 +107,21 @@ }; }; + /* + * The 4950 mAh pack (Google's husky battery data). The charger and + * gauge limits are deliberately conservative: stock charges to 4.48 V + * in steps (4.20/4.30/4.35/4.48 V by temperature), which is not + * described here yet. 0.3 C is 1485 mA. + */ + battery: battery { + compatible = "simple-battery"; + charge-full-design-microamp-hours = <4950000>; + voltage-max-design-microvolt = <4480000>; + voltage-min-design-microvolt = <3300000>; + constant-charge-voltage-max-microvolt = <4200000>; + constant-charge-current-max-microamp = <1485000>; + }; + reserved-memory { #address-cells = <2>; #size-cells = <1>; @@ -193,3 +210,87 @@ &usi2_hsi0 { status = "okay"; }; + +/* + * MAX77759 (charger, Type-C port controller, fuel gauge, PMIC) on USI11 / + * hsi2c_11. Like the Pixel 7 Pro's, but the interrupt lines are on gpa7 and + * gpa8. The bus and CMU_PERIC1 stay disabled here, and a bring-up overlay + * enables them. Binding the PMIC at 0x66 also creates its charger cell, + * and the charger driver then programs charge limits from the battery + * node, so max77759_charger, gpio_max77759, nvmem_max77759 and tcpci_maxim + * have to be kept from loading until each step is tested. The husky device + * package does not block them yet (cheetah's omamobile-max77759.conf + * does), and has to before an overlay that enables this bus ships. + * + * The fuel gauge has no battery model yet: the pack (ATL or COS, stock + * reads its ID resistor) is not known, and a wrong model would be written + * if the gauge reports power-on reset. The Type-C controller stays disabled, + * as on the Pixel 7 Pro: USB is the only way into the phone. + */ +&hsi2c_11 { + clock-frequency = <400000>; + + usb-typec@25 { + compatible = "maxim,max77759-tcpci", "maxim,max33359"; + reg = <0x25>; + interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&typec_int>; + pinctrl-names = "default"; + status = "disabled"; + + /* + * Sink only: VBUS for host mode comes from an external boost + * (stock: max77759,ext-otg-only, MAX77759 GPIO5 "bst-on" and + * the TCPC's EXTBST_CTRL), which has no driver yet. MAX77759 + * GPIO6 is the VBUS input switch (stock in-switch-gpio): leave + * it alone. + */ + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + data-role = "dual"; + power-role = "sink"; + self-powered; + op-sink-microwatt = <2600000>; + sink-pdos = ; + pd-disable; + typec-power-opmode = "default"; + }; + }; + + fuel-gauge@36 { + compatible = "maxim,max77759-fg"; + reg = <0x36>; + interrupts-extended = <&gpa7 7 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&if_pmic_fg_int>; + pinctrl-names = "default"; + shunt-resistor-micro-ohms = <5000>; + monitored-battery = <&battery>; + }; + + pmic@66 { + compatible = "maxim,max77759"; + reg = <0x66>; + interrupts-extended = <&gpa8 0 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&if_pmic_int>; + pinctrl-names = "default"; + interrupt-controller; + #interrupt-cells = <2>; + /* for the charger cell */ + monitored-battery = <&battery>; + + gpio { + compatible = "maxim,max77759-gpio"; + gpio-controller; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + }; + }; +}; diff --git a/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi b/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi index a88e0eaa20..dd84a0f1dc 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma-pinctrl.dtsi @@ -158,6 +158,28 @@ samsung,pin-pud = ; samsung,pin-drv = ; }; + + /* MAX77759 interrupt lines, active low with pull-ups (stock: pud 3). */ + if_pmic_int: if-pmic-int-pins { + samsung,pins = "gpa8-0"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + }; + + if_pmic_fg_int: if-pmic-fg-int-pins { + samsung,pins = "gpa7-7"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + }; + + typec_int: typec-int-pins { + samsung,pins = "gpa8-3"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + }; }; &pinctrl_custom_alive { @@ -436,6 +458,18 @@ samsung,pin-pud = ; samsung,pin-drv = ; }; + + /* + * USI11, the battery bus: stock's board file moves it to gpp21-0/1 and + * sets no pull, then zuma-typec.dtsi, applied after it, sets the + * pull-up (pud 3), which is what the pins end up with. + */ + hsi2c11_bus: hsi2c11-bus-pins { + samsung,pins = "gpp21-0", "gpp21-1"; + samsung,pin-function = ; + samsung,pin-pud = ; + samsung,pin-drv = ; + }; }; &pinctrl_hsi2ufs { diff --git a/arch/arm64/boot/dts/exynos/google/zuma.dtsi b/arch/arm64/boot/dts/exynos/google/zuma.dtsi index 2e76d03326..05f407446d 100644 --- a/arch/arm64/boot/dts/exynos/google/zuma.dtsi +++ b/arch/arm64/boot/dts/exynos/google/zuma.dtsi @@ -355,6 +355,58 @@ interrupts = ; }; + /* + * CMU_PERIC1 and USI11, the I2C bus of the MAX77759 gauge, + * charger and Type-C controller. Firmware leaves them running; + * board files enable them. + */ + cmu_peric1: clock-controller@10c00000 { + compatible = "google,zuma-cmu-peric1"; + reg = <0x10c00000 0x8000>; + #clock-cells = <1>; + clocks = <&oscclk>, <&cmu_top CLK_DOUT_PERIC1_NOC>, + <&cmu_top CLK_DOUT_PERIC1_IP>; + clock-names = "oscclk", "bus", "ip"; + status = "disabled"; + }; + + sysreg_peric1: syscon@10c21000 { + compatible = "google,zuma-peric1-sysreg", "syscon"; + reg = <0x10c21000 0x1000>; + clocks = <&cmu_peric1 CLK_GOUT_PERIC1_SYSREG>; + status = "disabled"; + }; + + usi11: usi@10cb00c0 { + compatible = "google,zuma-usi", "samsung,exynos850-usi"; + reg = <0x10cb00c0 0x20>; + clocks = <&cmu_peric1 CLK_GOUT_PERIC1_USI11_PCLK>, + <&cmu_peric1 CLK_GOUT_PERIC1_USI11_IPCLK>; + clock-names = "pclk", "ipclk"; + samsung,sysreg = <&sysreg_peric1 0xc>; + samsung,mode = ; + #address-cells = <1>; + #size-cells = <1>; + ranges; + status = "disabled"; + + hsi2c_11: i2c@10cb0000 { + compatible = "google,zuma-hsi2c", + "samsung,exynosautov9-hsi2c"; + /* USI control starts at 0xc0; do not claim it twice. */ + reg = <0x10cb0000 0xc0>; + interrupts = ; + clocks = <&cmu_peric1 CLK_GOUT_PERIC1_USI11_IPCLK>, + <&cmu_peric1 CLK_GOUT_PERIC1_USI11_PCLK>; + clock-names = "hsi2c", "hsi2c_pclk"; + pinctrl-0 = <&hsi2c11_bus>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + }; + cmu_hsi0: clock-controller@11000000 { compatible = "google,zuma-cmu-hsi0"; reg = <0x11000000 0x8000>; diff --git a/drivers/clk/samsung/clk-zuma.c b/drivers/clk/samsung/clk-zuma.c index ccb80f62e4..962f2ae8e3 100644 --- a/drivers/clk/samsung/clk-zuma.c +++ b/drivers/clk/samsung/clk-zuma.c @@ -1,11 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Google Tensor G3 (zuma) clocks for the touchscreen and its PMIC. + * Google Tensor G3 (zuma) clocks for the touchscreen, its PMIC and the + * battery bus. * * Register layout and parents derived from Google's GPL CMUCAL tables in * cal-if/zuma/cmucal-{sfr,node}.c, Copyright 2022 Samsung Electronics Co., Ltd. * Only the path from CMU_TOP to HSI0's USI2 is described, with CMU_APM's - * clocks for the APM mailbox, its SRAM and the always-on GPIO banks. PLLs, + * clocks for the APM mailbox, its SRAM and the always-on GPIO banks, and + * the path from CMU_TOP to PERIC1's USI11 (the battery, charger and USB-C + * I2C bus). PLLs, * muxes and dividers keep their firmware settings, except USI2's own * divider, which sets the SPI rate. No PLL rate table is supplied. */ @@ -43,6 +46,9 @@ static const struct samsung_fixed_factor_clock top_factors[] __initconst = { FFACTOR(CLK_SHARED3_D2, "zuma_shared3_d2", "zuma_shared3", 1, 2, 0), }; +PNAME(mout_peric1_parents) = { + "zuma_shared0_d4", "zuma_shared2_d2", "zuma_shared3_d2", "zuma_spare", +}; PNAME(mout_hsi0_noc_parents) = { "zuma_shared0_d4", "zuma_shared1_d4", "zuma_shared2_d2", "zuma_shared3_d2", "zuma_spare", "oscclk", "oscclk", "oscclk", @@ -57,14 +63,22 @@ static const struct samsung_mux_clock top_muxes[] __initconst = { 0x1094, 0, 3, 0, CLK_MUX_READ_ONLY), MUX_F(CLK_MOUT_HSI0_PERI, "zuma_mout_hsi0_peri", mout_hsi0_peri_parents, 0x1098, 0, 2, 0, CLK_MUX_READ_ONLY), + MUX_F(CLK_MOUT_PERIC1_NOC, "zuma_mout_peric1_noc", mout_peric1_parents, + 0x10f8, 0, 2, 0, CLK_MUX_READ_ONLY), + MUX_F(CLK_MOUT_PERIC1_IP, "zuma_mout_peric1_ip", mout_peric1_parents, + 0x10f4, 0, 2, 0, CLK_MUX_READ_ONLY), }; -/* The hardware order is mux -> gate -> divider. HSI0 is firmware-owned. */ +/* The hardware order is mux -> gate -> divider. HSI0 and PERIC1 are firmware-owned. */ static const struct samsung_gate_clock top_ro_gates[] __initconst = { GATE(CLK_GOUT_HSI0_NOC, "zuma_gout_hsi0_noc", "zuma_mout_hsi0_noc", 0x20bc, 21, CLK_IGNORE_UNUSED, 0), GATE(CLK_GOUT_HSI0_PERI, "zuma_gout_hsi0_peri", "zuma_mout_hsi0_peri", 0x20c0, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_PERIC1_NOC, "zuma_gout_peric1_noc", "zuma_mout_peric1_noc", + 0x211c, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_PERIC1_IP, "zuma_gout_peric1_ip", "zuma_mout_peric1_ip", + 0x2118, 21, CLK_IGNORE_UNUSED, 0), }; static const struct samsung_div_clock top_dividers[] __initconst = { @@ -72,6 +86,10 @@ static const struct samsung_div_clock top_dividers[] __initconst = { 0x188c, 0, 4, 0, CLK_DIVIDER_READ_ONLY), DIV_F(CLK_DOUT_HSI0_PERI, "zuma_dout_hsi0_peri", "zuma_gout_hsi0_peri", 0x1890, 0, 4, 0, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_PERIC1_NOC, "zuma_dout_peric1_noc", "zuma_gout_peric1_noc", + 0x18f0, 0, 4, 0, CLK_DIVIDER_READ_ONLY), + DIV_F(CLK_DOUT_PERIC1_IP, "zuma_dout_peric1_ip", "zuma_gout_peric1_ip", + 0x18ec, 0, 4, 0, CLK_DIVIDER_READ_ONLY), }; static const struct samsung_cmu_info top_cmu __initconst = { @@ -85,7 +103,7 @@ static const struct samsung_cmu_info top_cmu __initconst = { .nr_ro_gate_clks = ARRAY_SIZE(top_ro_gates), .div_clks = top_dividers, .nr_div_clks = ARRAY_SIZE(top_dividers), - .nr_clk_ids = CLK_DOUT_HSI0_PERI + 1, + .nr_clk_ids = CLK_DOUT_PERIC1_IP + 1, }; static void __init zuma_top_init(struct device_node *np) @@ -223,6 +241,58 @@ static const struct samsung_cmu_info hsi0_cmu __initconst = { .clk_name = "bus", }; +/* + * CMU_PERIC1, 0x10c00000. Firmware sets it up: the user muxes and the USI11 + * divider are read-only, and the GPIO and sysreg gates are read-only gates. + * USI11 is the I2C bus of the MAX77759 gauge, charger and Type-C controller + * and the MAX77729 PMIC. Its gates are the ones Linux turns on, as for the + * Pixel 9a's USI10; their auto/manual mode is left as firmware set it. + */ +PNAME(mout_peric1_noc_user_parents) = { "oscclk", "zuma_dout_peric1_noc" }; +PNAME(mout_peric1_usi11_user_parents) = { "oscclk", "zuma_dout_peric1_ip" }; + +static const struct samsung_mux_clock peric1_muxes[] __initconst = { + MUX_F(CLK_MOUT_PERIC1_NOC_USER, "zuma_mout_peric1_noc_user", + mout_peric1_noc_user_parents, 0x610, 4, 1, 0, CLK_MUX_READ_ONLY), + MUX_F(CLK_MOUT_PERIC1_USI11_USER, "zuma_mout_peric1_usi11_user", + mout_peric1_usi11_user_parents, 0x640, 4, 1, 0, CLK_MUX_READ_ONLY), +}; + +static const struct samsung_div_clock peric1_dividers[] __initconst = { + DIV_F(CLK_DOUT_PERIC1_USI11, "zuma_dout_peric1_usi11", + "zuma_mout_peric1_usi11_user", 0x1810, 0, 4, 0, + CLK_DIVIDER_READ_ONLY), +}; + +static const struct samsung_gate_clock peric1_ro_gates[] __initconst = { + GATE(CLK_GOUT_GPIO_PERIC1, "zuma_gout_gpio_peric1", + "zuma_mout_peric1_noc_user", 0x2080, 21, CLK_IGNORE_UNUSED, 0), + GATE(CLK_GOUT_PERIC1_SYSREG, "zuma_gout_peric1_sysreg", + "zuma_mout_peric1_noc_user", 0x20a4, 21, CLK_IGNORE_UNUSED, 0), +}; + +static const struct samsung_gate_clock peric1_gates[] __initconst = { + GATE(CLK_GOUT_PERIC1_USI11_IPCLK, "zuma_gout_peric1_usi11_ipclk", + "zuma_dout_peric1_usi11", 0x2048, 21, 0, 0), + GATE(CLK_GOUT_PERIC1_USI11_PCLK, "zuma_gout_peric1_usi11_pclk", + "zuma_mout_peric1_noc_user", 0x204c, 21, 0, 0), + GATE(CLK_GOUT_PERIC1_USI11_RSTNSYNC, "zuma_gout_peric1_usi11_rstnsync", + "zuma_dout_peric1_usi11", 0x2094, 21, 0, 0), +}; + +static const struct samsung_cmu_info peric1_cmu __initconst = { + .mux_clks = peric1_muxes, + .nr_mux_clks = ARRAY_SIZE(peric1_muxes), + .div_clks = peric1_dividers, + .nr_div_clks = ARRAY_SIZE(peric1_dividers), + .ro_gate_clks = peric1_ro_gates, + .nr_ro_gate_clks = ARRAY_SIZE(peric1_ro_gates), + .gate_clks = peric1_gates, + .nr_gate_clks = ARRAY_SIZE(peric1_gates), + .nr_clk_ids = CLK_GOUT_PERIC1_USI11_RSTNSYNC + 1, + .clk_name = "bus", +}; + static int __init zuma_cmu_probe(struct platform_device *pdev) { const struct samsung_cmu_info *cmu = device_get_match_data(&pdev->dev); @@ -234,6 +304,7 @@ static int __init zuma_cmu_probe(struct platform_device *pdev) static const struct of_device_id zuma_cmu_match[] = { { .compatible = "google,zuma-cmu-apm", .data = &apm_cmu }, { .compatible = "google,zuma-cmu-hsi0", .data = &hsi0_cmu }, + { .compatible = "google,zuma-cmu-peric1", .data = &peric1_cmu }, { } }; diff --git a/include/dt-bindings/clock/google,zuma.h b/include/dt-bindings/clock/google,zuma.h index 45aef7817c..fbbae0762b 100644 --- a/include/dt-bindings/clock/google,zuma.h +++ b/include/dt-bindings/clock/google,zuma.h @@ -2,7 +2,7 @@ #ifndef _DT_BINDINGS_CLOCK_GOOGLE_ZUMA_H #define _DT_BINDINGS_CLOCK_GOOGLE_ZUMA_H -/* CMU_TOP: the HSI0 NoC and peripheral clock paths. */ +/* CMU_TOP: the HSI0 and PERIC1 NoC and peripheral clock paths. */ #define CLK_FOUT_SHARED0 1 #define CLK_FOUT_SHARED1 2 #define CLK_FOUT_SHARED2 3 @@ -18,6 +18,12 @@ #define CLK_MOUT_HSI0_PERI 13 #define CLK_GOUT_HSI0_PERI 14 #define CLK_DOUT_HSI0_PERI 15 +#define CLK_MOUT_PERIC1_NOC 16 +#define CLK_MOUT_PERIC1_IP 17 +#define CLK_GOUT_PERIC1_NOC 18 +#define CLK_GOUT_PERIC1_IP 19 +#define CLK_DOUT_PERIC1_NOC 20 +#define CLK_DOUT_PERIC1_IP 21 /* CMU_HSI0: USI2, the touchscreen's SPI. */ #define CLK_GOUT_HSI0_ALT 1 @@ -31,6 +37,16 @@ #define CLK_GOUT_HSI0_USI2_IP 9 #define CLK_GOUT_HSI0_USI2_PCLK 10 +/* CMU_PERIC1: USI11, the I2C bus of the battery, charger and USB-C chips. */ +#define CLK_MOUT_PERIC1_NOC_USER 1 +#define CLK_GOUT_GPIO_PERIC1 2 +#define CLK_GOUT_PERIC1_SYSREG 3 +#define CLK_MOUT_PERIC1_USI11_USER 4 +#define CLK_DOUT_PERIC1_USI11 5 +#define CLK_GOUT_PERIC1_USI11_IPCLK 6 +#define CLK_GOUT_PERIC1_USI11_PCLK 7 +#define CLK_GOUT_PERIC1_USI11_RSTNSYNC 8 + /* CMU_APM: the APM mailbox, its SRAM and the always-on GPIO banks. */ #define CLK_APM_PLL_ALV_DIV2 1 #define CLK_APM_PLL_ALV_DIV4 2