-
Notifications
You must be signed in to change notification settings - Fork 216
Enable i2c-xiic and add upstream patches #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
domingo-nexthop
wants to merge
3
commits into
sonic-net:master
Choose a base branch
from
nexthop-ai:domingo.i2c-xiic-patch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
patches-sonic/0001-PM-runtime-Add-new-devm-functions.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| From 69a837b75edcea8861ea3a851d10fd138e7f7406 Mon Sep 17 00:00:00 2001 | ||
| From: =?UTF-8?q?Bence=20Cs=C3=B3k=C3=A1s?= <csokas.bence@prolan.hu> | ||
| Date: Mon, 20 Oct 2025 09:02:38 -0400 | ||
| Subject: [PATCH] PM: runtime: Add new devm functions | ||
| MIME-Version: 1.0 | ||
| Content-Type: text/plain; charset=UTF-8 | ||
| Content-Transfer-Encoding: 8bit | ||
|
|
||
| [ Upstream commit 73db799bf5efc5a04654bb3ff6c9bf63a0dfa473 ] | ||
|
|
||
| Add `devm_pm_runtime_set_active_enabled()` and | ||
| `devm_pm_runtime_get_noresume()` for simplifying | ||
| common cases in drivers. | ||
|
|
||
| Signed-off-by: Bence Csókás <csokas.bence@prolan.hu> | ||
| Link: https://patch.msgid.link/20250327195928.680771-3-csokas.bence@prolan.hu | ||
| Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | ||
| Stable-dep-of: 0792c1984a45 ("iio: imu: inv_icm42600: Simplify pm_runtime setup") | ||
| Signed-off-by: Sasha Levin <sashal@kernel.org> | ||
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
| --- | ||
| drivers/base/power/runtime.c | 44 ++++++++++++++++++++++++++++++++++++ | ||
| include/linux/pm_runtime.h | 4 ++++ | ||
| 2 files changed, 48 insertions(+) | ||
|
|
||
| diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c | ||
| index c7ec69597a95..d8aaa5b61628 100644 | ||
| --- a/drivers/base/power/runtime.c | ||
| +++ b/drivers/base/power/runtime.c | ||
| @@ -1554,6 +1554,32 @@ void pm_runtime_enable(struct device *dev) | ||
| } | ||
| EXPORT_SYMBOL_GPL(pm_runtime_enable); | ||
|
|
||
| +static void pm_runtime_set_suspended_action(void *data) | ||
| +{ | ||
| + pm_runtime_set_suspended(data); | ||
| +} | ||
| + | ||
| +/** | ||
| + * devm_pm_runtime_set_active_enabled - set_active version of devm_pm_runtime_enable. | ||
| + * | ||
| + * @dev: Device to handle. | ||
| + */ | ||
| +int devm_pm_runtime_set_active_enabled(struct device *dev) | ||
| +{ | ||
| + int err; | ||
| + | ||
| + err = pm_runtime_set_active(dev); | ||
| + if (err) | ||
| + return err; | ||
| + | ||
| + err = devm_add_action_or_reset(dev, pm_runtime_set_suspended_action, dev); | ||
| + if (err) | ||
| + return err; | ||
| + | ||
| + return devm_pm_runtime_enable(dev); | ||
| +} | ||
| +EXPORT_SYMBOL_GPL(devm_pm_runtime_set_active_enabled); | ||
| + | ||
| static void pm_runtime_disable_action(void *data) | ||
| { | ||
| pm_runtime_dont_use_autosuspend(data); | ||
| @@ -1576,6 +1602,24 @@ int devm_pm_runtime_enable(struct device *dev) | ||
| } | ||
| EXPORT_SYMBOL_GPL(devm_pm_runtime_enable); | ||
|
|
||
| +static void pm_runtime_put_noidle_action(void *data) | ||
| +{ | ||
| + pm_runtime_put_noidle(data); | ||
| +} | ||
| + | ||
| +/** | ||
| + * devm_pm_runtime_get_noresume - devres-enabled version of pm_runtime_get_noresume. | ||
| + * | ||
| + * @dev: Device to handle. | ||
| + */ | ||
| +int devm_pm_runtime_get_noresume(struct device *dev) | ||
| +{ | ||
| + pm_runtime_get_noresume(dev); | ||
| + | ||
| + return devm_add_action_or_reset(dev, pm_runtime_put_noidle_action, dev); | ||
| +} | ||
| +EXPORT_SYMBOL_GPL(devm_pm_runtime_get_noresume); | ||
| + | ||
| /** | ||
| * pm_runtime_forbid - Block runtime PM of a device. | ||
| * @dev: Device to handle. | ||
| diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h | ||
| index d0b29cd1fd20..142ab39a3b38 100644 | ||
| --- a/include/linux/pm_runtime.h | ||
| +++ b/include/linux/pm_runtime.h | ||
| @@ -94,7 +94,9 @@ extern void pm_runtime_new_link(struct device *dev); | ||
| extern void pm_runtime_drop_link(struct device_link *link); | ||
| extern void pm_runtime_release_supplier(struct device_link *link); | ||
|
|
||
| +int devm_pm_runtime_set_active_enabled(struct device *dev); | ||
| extern int devm_pm_runtime_enable(struct device *dev); | ||
| +int devm_pm_runtime_get_noresume(struct device *dev); | ||
|
|
||
| /** | ||
| * pm_suspend_ignore_children - Set runtime PM behavior regarding children. | ||
| @@ -278,7 +280,9 @@ static inline void __pm_runtime_disable(struct device *dev, bool c) {} | ||
| static inline void pm_runtime_allow(struct device *dev) {} | ||
| static inline void pm_runtime_forbid(struct device *dev) {} | ||
|
|
||
| +static inline int devm_pm_runtime_set_active_enabled(struct device *dev) { return 0; } | ||
| static inline int devm_pm_runtime_enable(struct device *dev) { return 0; } | ||
| +static inline int devm_pm_runtime_get_noresume(struct device *dev) { return 0; } | ||
|
|
||
| static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {} | ||
| static inline void pm_runtime_get_noresume(struct device *dev) {} | ||
| -- | ||
| 2.43.0 | ||
|
|
84 changes: 84 additions & 0 deletions
84
patches-sonic/0007-i2c-xiic-Relocate-xiic_i2c_runtime_suspend-and-xiic_.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| From a085b9385bfbc6b6887a9fa21f3cd40bd3811b37 Mon Sep 17 00:00:00 2001 | ||
| From: Manikanta Guntupalli <manikanta.guntupalli@amd.com> | ||
| Date: Tue, 10 Dec 2024 15:22:41 +0530 | ||
| Subject: [PATCH 07/22] i2c: xiic: Relocate xiic_i2c_runtime_suspend and | ||
| xiic_i2c_runtime_resume to facilitate atomic mode | ||
|
|
||
| Relocate xiic_i2c_runtime_suspend and xiic_i2c_runtime_resume functions | ||
| to avoid prototype statements in atomic mode changes. | ||
|
|
||
| Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com> | ||
| Acked-by: Michal Simek <michal.simek@amd.com> | ||
| Link: https://lore.kernel.org/r/20241210095242.1982770-2-manikanta.guntupalli@amd.com | ||
| Signed-off-by: Andi Shyti <andi.shyti@kernel.org> | ||
| --- | ||
| drivers/i2c/busses/i2c-xiic.c | 46 +++++++++++++++++------------------ | ||
| 1 file changed, 23 insertions(+), 23 deletions(-) | ||
|
|
||
| diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c | ||
| index 1d68177241a6..2d26b6d0721b 100644 | ||
| --- a/drivers/i2c/busses/i2c-xiic.c | ||
| +++ b/drivers/i2c/busses/i2c-xiic.c | ||
| @@ -238,6 +238,29 @@ static const struct timing_regs timing_reg_values[] = { | ||
| static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num); | ||
| static void __xiic_start_xfer(struct xiic_i2c *i2c); | ||
|
|
||
| +static int __maybe_unused xiic_i2c_runtime_suspend(struct device *dev) | ||
| +{ | ||
| + struct xiic_i2c *i2c = dev_get_drvdata(dev); | ||
| + | ||
| + clk_disable(i2c->clk); | ||
| + | ||
| + return 0; | ||
| +} | ||
| + | ||
| +static int __maybe_unused xiic_i2c_runtime_resume(struct device *dev) | ||
| +{ | ||
| + struct xiic_i2c *i2c = dev_get_drvdata(dev); | ||
| + int ret; | ||
| + | ||
| + ret = clk_enable(i2c->clk); | ||
| + if (ret) { | ||
| + dev_err(dev, "Cannot enable clock.\n"); | ||
| + return ret; | ||
| + } | ||
| + | ||
| + return 0; | ||
| +} | ||
| + | ||
| /* | ||
| * For the register read and write functions, a little-endian and big-endian | ||
| * version are necessary. Endianness is detected during the probe function. | ||
| @@ -1365,29 +1388,6 @@ static void xiic_i2c_remove(struct platform_device *pdev) | ||
| pm_runtime_dont_use_autosuspend(&pdev->dev); | ||
| } | ||
|
|
||
| -static int __maybe_unused xiic_i2c_runtime_suspend(struct device *dev) | ||
| -{ | ||
| - struct xiic_i2c *i2c = dev_get_drvdata(dev); | ||
| - | ||
| - clk_disable(i2c->clk); | ||
| - | ||
| - return 0; | ||
| -} | ||
| - | ||
| -static int __maybe_unused xiic_i2c_runtime_resume(struct device *dev) | ||
| -{ | ||
| - struct xiic_i2c *i2c = dev_get_drvdata(dev); | ||
| - int ret; | ||
| - | ||
| - ret = clk_enable(i2c->clk); | ||
| - if (ret) { | ||
| - dev_err(dev, "Cannot enable clock.\n"); | ||
| - return ret; | ||
| - } | ||
| - | ||
| - return 0; | ||
| -} | ||
| - | ||
| static const struct dev_pm_ops xiic_dev_pm_ops = { | ||
| SET_RUNTIME_PM_OPS(xiic_i2c_runtime_suspend, | ||
| xiic_i2c_runtime_resume, NULL) | ||
| -- | ||
| 2.53.0 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having just a subset of a series included, might be confusing, but I won’t object.