mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
Apple Soc driver updates for 7.3
- New driver and dt-bindings for Apple PMGR misc controls, which tweaks various global power related states and saves about 1W of power on M1 Pro/Max/Ultra during s2idle. - A small fix for device links in SART Signed-off-by: Sven Peter <sven@kernel.org> -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQS3vz815OHsEaWy0u9EEX0kKnUe6QUCanYDQgAKCRBEEX0kKnUe 6ZuoAP98l5DFnC+mM8Hb58BKTNi0Aj4x+ZS6wUQQyEWGM/x9wAEAg4qGNtuaecIi fZDfSWHUSZ4/mpf7q9OwAtbpbvn3Jw0= =dNHf -----END PGP SIGNATURE----- gpgsig -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmp5hmEACgkQmmx57+YA GNnDiw//bh8x/MOhIM9wObUEZLdO9vLMCI3jnnxeZ7T5FQDKBAnkK3IV0yPo+IJg T2ypxkDkKYvlaN2nOXHIgH96N/K0YQwZMzea9M/ohIU6ftDdKm1YuOjfzAQaRjna uFsY90TUncG/956YY+iamGom+sUFwlGx64zniYL5WXEfQ80wHGhwNCtz1lmrX/ng 9wSBAzPMy8mZ9GUEbq5z6R2Dz7zs/9vRosOkhPAO2EnFKWEsviiVz7RT0w6pIZ6s VPtCTsC8re2Uu+UkqM/jg8xoH06Wb39HCHWLL655U34P6Bob0CCeYFmOK/Y9+9fC ndVlEGx30sRmNqcGjwDGEkn4tysnyu3A7ahZCRHPUFJgkEn1LOjFBX/+mPwFDjIV 6DExTuDbdroOI4F4CEJa+knNF5jOiX4IgnUFq1AjF5au4ZT4kEHboQmK67NVD2iJ A7aZqn0OR3da0+Bxa+BLGJd+ZB1mGoRQbf64I7mYRJsCO5iEGM5wuFPKmOZOfy7f 9J2l0lj7Yiw+WD2AnVrwApYVEpZBWvCNjCHpA1ctcgwqafY4psEkoJLt7pIcVaPa zTEh/kRb6LtK4F6m13s9QaWMgoWsoa9TYUou2Aeof2X4Uyg8qNMPMalRnIDB16gf eF/x9PBxRJ8JMDABzuR8TBcac+5ZZfjOuWMWMrvnAs57AqdO5C4= =KWIH -----END PGP SIGNATURE----- Merge tag 'apple-soc-drivers-7.3' of https://git.kernel.org/pub/scm/linux/kernel/git/sven/linux into soc/drivers Apple Soc driver updates for 7.3 - New driver and dt-bindings for Apple PMGR misc controls, which tweaks various global power related states and saves about 1W of power on M1 Pro/Max/Ultra during s2idle. - A small fix for device links in SART Signed-off-by: Sven Peter <sven@kernel.org> * tag 'apple-soc-drivers-7.3' of https://git.kernel.org/pub/scm/linux/kernel/git/sven/linux: soc: apple: Add driver for Apple PMGR misc controls dt-bindings: soc: apple: Add Apple PMGR misc controls soc: apple: sart: require device link for consumers Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
commit
ec833fd504
|
|
@ -0,0 +1,45 @@
|
|||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: http://devicetree.org/schemas/soc/apple/apple,t6000-pmgr-misc.yaml#
|
||||
$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
|
||||
title: Apple SoC PMGR Misc Power States
|
||||
|
||||
maintainers:
|
||||
- Sasha Finkelstein <k@chaosmail.tech>
|
||||
|
||||
description: |
|
||||
Certain Apple SoCs include additional PMGR power states that are controlled
|
||||
via a different "misc" control block. This includes the fabric and memory
|
||||
controller states.
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- apple,t6000-pmgr-misc
|
||||
- apple,t6020-pmgr-misc
|
||||
|
||||
reg:
|
||||
maxItems: 2
|
||||
|
||||
reg-names:
|
||||
items:
|
||||
- const: fabric-ps
|
||||
- const: dcs-ps
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
- reg-names
|
||||
|
||||
additionalProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
power-management@8e20c000 {
|
||||
compatible = "apple,t6000-pmgr-misc";
|
||||
reg = <0x8e20c000 0x400>,
|
||||
<0x8e20c800 0x400>;
|
||||
reg-names = "fabric-ps", "dcs-ps";
|
||||
};
|
||||
|
|
@ -2607,6 +2607,7 @@ F: Documentation/devicetree/bindings/power/apple*
|
|||
F: Documentation/devicetree/bindings/power/reset/apple,smc-reboot.yaml
|
||||
F: Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml
|
||||
F: Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml
|
||||
F: Documentation/devicetree/bindings/soc/apple/apple,t6000-pmgr-misc.yaml
|
||||
F: Documentation/devicetree/bindings/spi/apple,spi.yaml
|
||||
F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml
|
||||
F: Documentation/devicetree/bindings/usb/apple,dwc3.yaml
|
||||
|
|
|
|||
|
|
@ -16,6 +16,16 @@ config APPLE_MAILBOX
|
|||
|
||||
Say Y here if you have an Apple SoC.
|
||||
|
||||
config APPLE_PMGR_MISC
|
||||
tristate "Apple SoC PMGR miscellaneous support"
|
||||
depends on PM
|
||||
help
|
||||
The PMGR block in Apple SoCs provides high-level power state
|
||||
controls for SoC devices. This driver manages miscellaneous
|
||||
power controls.
|
||||
|
||||
Say 'y' here if you have a Pro/Max/Ultra Apple SoC.
|
||||
|
||||
config APPLE_RTKIT
|
||||
tristate "Apple RTKit co-processor IPC protocol"
|
||||
depends on APPLE_MAILBOX
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
obj-$(CONFIG_APPLE_MAILBOX) += apple-mailbox.o
|
||||
apple-mailbox-y = mailbox.o
|
||||
|
||||
obj-$(CONFIG_APPLE_PMGR_MISC) += apple-pmgr-misc.o
|
||||
|
||||
obj-$(CONFIG_APPLE_RTKIT) += apple-rtkit.o
|
||||
apple-rtkit-y = rtkit.o rtkit-crashlog.o
|
||||
|
||||
|
|
|
|||
181
drivers/soc/apple/apple-pmgr-misc.c
Normal file
181
drivers/soc/apple/apple-pmgr-misc.c
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only OR MIT
|
||||
/*
|
||||
* Apple SoC PMGR device power state driver
|
||||
*
|
||||
* Copyright The Asahi Linux Contributors
|
||||
*/
|
||||
|
||||
#include <linux/bitfield.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#define APPLE_CLKGEN_PSTATE 0
|
||||
#define APPLE_CLKGEN_PSTATE_DESIRED GENMASK(3, 0)
|
||||
|
||||
#define DCS_DEV_PSTATE_MIN_T600X 7
|
||||
#define SYS_DEV_PSTATE_SUSPEND 1
|
||||
|
||||
enum sys_device {
|
||||
DEV_FABRIC,
|
||||
DEV_DCS,
|
||||
DEV_MAX,
|
||||
};
|
||||
|
||||
struct apple_pmgr_sys_device {
|
||||
void __iomem *base;
|
||||
u32 active_state;
|
||||
u32 suspend_state;
|
||||
};
|
||||
|
||||
struct apple_pmgr_misc_hw {
|
||||
u32 dev_min_ps[DEV_MAX];
|
||||
};
|
||||
|
||||
struct apple_pmgr_misc {
|
||||
struct device *dev;
|
||||
struct apple_pmgr_sys_device devices[DEV_MAX];
|
||||
};
|
||||
|
||||
static void apple_pmgr_sys_dev_set_pstate(struct apple_pmgr_misc *misc,
|
||||
enum sys_device dev, bool active)
|
||||
{
|
||||
u32 pstate;
|
||||
u32 val;
|
||||
|
||||
if (!misc->devices[dev].base)
|
||||
return;
|
||||
|
||||
if (active)
|
||||
pstate = misc->devices[dev].active_state;
|
||||
else
|
||||
pstate = misc->devices[dev].suspend_state;
|
||||
|
||||
dev_dbg(misc->dev, "set %d ps to pstate %d\n", dev, pstate);
|
||||
|
||||
val = readl_relaxed(misc->devices[dev].base + APPLE_CLKGEN_PSTATE);
|
||||
FIELD_MODIFY(APPLE_CLKGEN_PSTATE_DESIRED, &val, pstate);
|
||||
writel_relaxed(val, misc->devices[dev].base + APPLE_CLKGEN_PSTATE);
|
||||
}
|
||||
|
||||
static int __maybe_unused apple_pmgr_misc_suspend_noirq(struct device *dev)
|
||||
{
|
||||
struct apple_pmgr_misc *misc = dev_get_drvdata(dev);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DEV_MAX; i++)
|
||||
apple_pmgr_sys_dev_set_pstate(misc, i, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused apple_pmgr_misc_resume_noirq(struct device *dev)
|
||||
{
|
||||
struct apple_pmgr_misc *misc = dev_get_drvdata(dev);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < DEV_MAX; i++)
|
||||
apple_pmgr_sys_dev_set_pstate(misc, i, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int apple_pmgr_init_device(struct apple_pmgr_misc *misc,
|
||||
const struct apple_pmgr_misc_hw *hw,
|
||||
enum sys_device dev,
|
||||
const char *device_name)
|
||||
{
|
||||
void __iomem *base;
|
||||
char name[32];
|
||||
u32 val;
|
||||
|
||||
snprintf(name, sizeof(name), "%s-ps", device_name);
|
||||
|
||||
base = devm_platform_ioremap_resource_byname(
|
||||
to_platform_device(misc->dev), name);
|
||||
if (IS_ERR(base))
|
||||
return PTR_ERR(base);
|
||||
|
||||
val = readl_relaxed(base + APPLE_CLKGEN_PSTATE);
|
||||
|
||||
misc->devices[dev].base = base;
|
||||
misc->devices[dev].active_state =
|
||||
FIELD_GET(APPLE_CLKGEN_PSTATE_DESIRED, val);
|
||||
misc->devices[dev].suspend_state = hw->dev_min_ps[dev];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int apple_pmgr_misc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct apple_pmgr_misc_hw *hw;
|
||||
struct apple_pmgr_misc *misc;
|
||||
int ret;
|
||||
|
||||
misc = devm_kzalloc(dev, sizeof(*misc), GFP_KERNEL);
|
||||
if (!misc)
|
||||
return -ENOMEM;
|
||||
|
||||
misc->dev = dev;
|
||||
hw = of_device_get_match_data(dev);
|
||||
if (!hw)
|
||||
return -EINVAL;
|
||||
|
||||
ret = apple_pmgr_init_device(misc, hw, DEV_FABRIC, "fabric");
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = apple_pmgr_init_device(misc, hw, DEV_DCS, "dcs");
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
platform_set_drvdata(pdev, misc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct apple_pmgr_misc_hw apple_pmgr_misc_hw_t600x = {
|
||||
.dev_min_ps = {
|
||||
[DEV_FABRIC] = SYS_DEV_PSTATE_SUSPEND,
|
||||
[DEV_DCS] = DCS_DEV_PSTATE_MIN_T600X,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct apple_pmgr_misc_hw apple_pmgr_misc_hw_t602x = {
|
||||
.dev_min_ps = {
|
||||
[DEV_FABRIC] = SYS_DEV_PSTATE_SUSPEND,
|
||||
[DEV_DCS] = SYS_DEV_PSTATE_SUSPEND,
|
||||
},
|
||||
};
|
||||
|
||||
static const struct of_device_id apple_pmgr_misc_of_match[] = {
|
||||
{ .compatible = "apple,t6000-pmgr-misc", .data = &apple_pmgr_misc_hw_t600x },
|
||||
{ .compatible = "apple,t6020-pmgr-misc", .data = &apple_pmgr_misc_hw_t602x },
|
||||
{}
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, apple_pmgr_misc_of_match);
|
||||
|
||||
static const struct dev_pm_ops apple_pmgr_misc_pm_ops = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(apple_pmgr_misc_suspend_noirq,
|
||||
apple_pmgr_misc_resume_noirq)
|
||||
};
|
||||
|
||||
static struct platform_driver apple_pmgr_misc_driver = {
|
||||
.probe = apple_pmgr_misc_probe,
|
||||
.driver = {
|
||||
.name = "apple-pmgr-misc",
|
||||
.of_match_table = apple_pmgr_misc_of_match,
|
||||
.pm = pm_ptr(&apple_pmgr_misc_pm_ops),
|
||||
},
|
||||
};
|
||||
|
||||
MODULE_AUTHOR("Hector Martin <marcan@marcan.st>");
|
||||
MODULE_DESCRIPTION("PMGR misc driver for Apple SoCs");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_platform_driver(apple_pmgr_misc_driver);
|
||||
|
|
@ -218,6 +218,7 @@ struct apple_sart *devm_apple_sart_get(struct device *dev)
|
|||
{
|
||||
struct device_node *sart_node;
|
||||
struct platform_device *sart_pdev;
|
||||
struct device_link *link;
|
||||
struct apple_sart *sart;
|
||||
|
||||
sart_node = of_parse_phandle(dev->of_node, "apple,sart", 0);
|
||||
|
|
@ -236,8 +237,12 @@ struct apple_sart *devm_apple_sart_get(struct device *dev)
|
|||
return ERR_PTR(-EPROBE_DEFER);
|
||||
}
|
||||
|
||||
device_link_add(dev, &sart_pdev->dev,
|
||||
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
|
||||
link = device_link_add(dev, &sart_pdev->dev,
|
||||
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
|
||||
if (!link) {
|
||||
put_device(&sart_pdev->dev);
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
put_device(&sart_pdev->dev);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user