diff --git a/arch/arm64/boot/dts/exynos/google/gs101.dtsi b/arch/arm64/boot/dts/exynos/google/gs101.dtsi index bf3a00cb4e..ad1816b74f 100644 --- a/arch/arm64/boot/dts/exynos/google/gs101.dtsi +++ b/arch/arm64/boot/dts/exynos/google/gs101.dtsi @@ -214,6 +214,59 @@ }; }; + /* + * Google's gs101 GPU levels (gpu_dvfs_table_v2, capped at their + * gpu_dvfs_max_freq of 800 MHz), as shader clock rates. The ACPM GPU + * clock moves the L2 clock to its paired level and sets the voltages. + */ + gpu_opp_table: opp-table-gpu { + compatible = "operating-points-v2"; + + opp-151000000 { + opp-hz = /bits/ 64 <151000000>; + }; + + opp-202000000 { + opp-hz = /bits/ 64 <202000000>; + }; + + opp-251000000 { + opp-hz = /bits/ 64 <251000000>; + }; + + opp-302000000 { + opp-hz = /bits/ 64 <302000000>; + }; + + opp-351000000 { + opp-hz = /bits/ 64 <351000000>; + }; + + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + }; + + opp-471000000 { + opp-hz = /bits/ 64 <471000000>; + }; + + opp-510000000 { + opp-hz = /bits/ 64 <510000000>; + }; + + opp-572000000 { + opp-hz = /bits/ 64 <572000000>; + }; + + opp-701000000 { + opp-hz = /bits/ 64 <701000000>; + }; + + opp-762000000 { + opp-hz = /bits/ 64 <762000000>; + }; + }; + cpucl0_opp_table: opp-table-0 { compatible = "operating-points-v2"; opp-shared; @@ -2073,11 +2126,11 @@ gpu: gpu@1c500000 { compatible = "google,gs101-mali", "arm,mali-valhall-jm"; reg = <0x1c500000 0x5000>; - /* - * TODO: placeholder until a CMU_G3D driver exists. ABL - * leaves the G3D clock running; this is not that clock. - */ - clocks = <&ext_24_5m>; + /* The shader clock, with L2 paired, set by the APM firmware */ + clocks = <&acpm_ipc GS101_CLK_ACPM_GPU>; + clock-names = "core"; + operating-points-v2 = <&gpu_opp_table>; + #cooling-cells = <2>; interrupt-names = "job", "mmu", "gpu"; interrupts = , , @@ -2142,6 +2195,12 @@ cooling-device = <&cpu6 10 THERMAL_NO_LIMIT>, <&cpu7 10 THERMAL_NO_LIMIT>; }; + + /* the GPU heats the whole die: slow it too */ + map2 { + trip = <&big_hotter>; + cooling-device = <&gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; }; }; @@ -2237,12 +2296,36 @@ thermal-sensors = <&acpm_tmu 3>; trips { + gpu_hot: gpu-hot { + temperature = <80000>; + hysteresis = <5000>; + type = "passive"; + }; + + gpu_hotter: gpu-hotter { + temperature = <90000>; + hysteresis = <5000>; + type = "passive"; + }; + gpu_crit: gpu-crit { temperature = <110000>; hysteresis = <0>; type = "critical"; }; }; + + cooling-maps { + map0 { + trip = <&gpu_hot>; + cooling-device = <&gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + + map1 { + trip = <&gpu_hotter>; + cooling-device = <&gpu 5 THERMAL_NO_LIMIT>; + }; + }; }; isp-thermal { diff --git a/drivers/clk/samsung/clk-acpm.c b/drivers/clk/samsung/clk-acpm.c index 82dae93f4f..93f4b89b64 100644 --- a/drivers/clk/samsung/clk-acpm.c +++ b/drivers/clk/samsung/clk-acpm.c @@ -102,9 +102,42 @@ static const struct acpm_clk_variant gs101_acpm_clks[] = { ACPM_CLK("bo"), }; +/* + * gs101 GPU operating points: shader (G3D) rate and the top/L2 (G3DL2) rate + * paired with it, in kHz, from Google's gs101 GPU DVFS table + * (gpu_dvfs_table_v2 in gs101-gpu.dtsi, the levels up to its + * gpu_dvfs_max_freq of 800 MHz). Stock's gpu_dvfs_min_freq of 250 MHz + * leaves out the 151 and 202 MHz rows; they are kept, as gs201's are. + */ +static const struct acpm_clk_pair gs101_gpu_pairs[] = { + { 151000, 302000 }, + { 202000, 302000 }, + { 251000, 434000 }, + { 302000, 434000 }, + { 351000, 603000 }, + { 400000, 603000 }, + { 471000, 603000 }, + { 510000, 750000 }, + { 572000, 750000 }, + { 701000, 885000 }, + { 762000, 996000 }, +}; + +static const struct acpm_clk_paired gs101_acpm_paired[] = { + { + .name = "gpu", + .id = 5, /* G3D: shader cores */ + .id2 = 6, /* G3DL2: top level and L2 */ + .pairs = gs101_gpu_pairs, + .nr_pairs = ARRAY_SIZE(gs101_gpu_pairs), + }, +}; + static const struct acpm_clk_driver_data acpm_clk_gs101 = { .clks = gs101_acpm_clks, .nr_clks = ARRAY_SIZE(gs101_acpm_clks), + .paired = gs101_acpm_paired, + .nr_paired = ARRAY_SIZE(gs101_acpm_paired), .mbox_chan_id = 0, }; diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index b51c307788..bc113f58cb 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -126,8 +126,9 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct thermal_cooling_device *cooling; struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; unsigned long freq = ULONG_MAX; + bool fw_dvfs = pfdev->comp->pm_features & BIT(GPU_PM_FW_DVFS); - if (pfdev->comp->num_supplies > 1) { + if (pfdev->comp->num_supplies > 1 && !fw_dvfs) { /* * GPUs with more than 1 supply require platform-specific handling: * continue without devfreq @@ -140,7 +141,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) if (ret) return ret; - ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names); + ret = fw_dvfs ? 0 : devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names); if (ret) { /* Continue if the optional regulator is missing */ if (ret != -ENODEV) { diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index 1fe1554f26..681d43667c 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -43,11 +43,14 @@ enum panfrost_drv_comp_bits { * @GPU_PM_VREG_OFF: Allow turning off regulators during system suspend * @GPU_PM_RT: Allow disabling clocks and asserting the reset control during * system runtime suspend + * @GPU_PM_FW_DVFS: Firmware sets the GPU voltages with the clock rates, so + * devfreq sets rates only, whatever the number of supplies */ enum panfrost_gpu_pm { GPU_PM_CLK_DIS, GPU_PM_VREG_OFF, - GPU_PM_RT + GPU_PM_RT, + GPU_PM_FW_DVFS, }; /** diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index c7ba908745..ead8412b46 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -1079,13 +1079,17 @@ static const struct panfrost_compatible default_data = { .pm_domain_names = NULL, }; -/* gs101 (Pixel 6): the G3D rails, all always-on; no DVFS yet */ +/* + * gs101 (Pixel 6): the G3D rails, all always-on. The APM firmware (ACPM) + * sets their voltages with the G3D and G3D L2 clock rates. + */ static const char * const gs101_supplies[] = { "mali", "g3d-l2", "g3d-m", "int-m", NULL }; static const struct panfrost_compatible gs101_data = { .num_supplies = ARRAY_SIZE(gs101_supplies) - 1, .supply_names = gs101_supplies, .num_pm_domains = 1, /* optional */ .pm_domain_names = NULL, + .pm_features = BIT(GPU_PM_FW_DVFS), .gpu_quirks = BIT(GPU_QUIRK_FORCE_AARCH64_PGTABLE), }; diff --git a/include/dt-bindings/clock/google,gs101-acpm.h b/include/dt-bindings/clock/google,gs101-acpm.h index e2ba89e09f..0153c652bf 100644 --- a/include/dt-bindings/clock/google,gs101-acpm.h +++ b/include/dt-bindings/clock/google,gs101-acpm.h @@ -23,4 +23,10 @@ #define GS101_CLK_ACPM_DVFS_DISP 12 #define GS101_CLK_ACPM_DVFS_BO 13 +/* + * The GPU as one clock: its rate is the shader (G3D) rate, and setting it + * also moves the top/L2 domain (G3DL2) to the level paired with it. + */ +#define GS101_CLK_ACPM_GPU 14 + #endif /* _DT_BINDINGS_CLOCK_GOOGLE_GS101_ACPM_H */