forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sunxi: import megous kernel patches from armbian repo
- Loading branch information
Showing
29 changed files
with
1,554 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...6.1/798_MEGOUS_0001_clk-sunxi-ng-Set-maximum-P-and-M-factors-to-1-for-H3-pll-cpux-c.patch
This file contains 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 @@ | ||
patches.megous/clk-sunxi-ng-Set-maximum-P-and-M-factors-to-1-for-H3-pll-cpux-c.patch |
1 change: 1 addition & 0 deletions
1
...6.1/798_MEGOUS_0002_clk-sunxi-ng-Don-t-use-CPU-PLL-gating-and-CPUX-reparenting-to-H.patch
This file contains 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 @@ | ||
patches.megous/clk-sunxi-ng-Don-t-use-CPU-PLL-gating-and-CPUX-reparenting-to-H.patch |
1 change: 1 addition & 0 deletions
1
...6.1/798_MEGOUS_0003_ARM-sunxi-sunxi_cpu0_hotplug_support_set-is-not-supported-on-A8.patch
This file contains 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 @@ | ||
patches.megous/ARM-sunxi-sunxi_cpu0_hotplug_support_set-is-not-supported-on-A8.patch |
1 change: 1 addition & 0 deletions
1
...tches-6.1/798_MEGOUS_0004_net-stmmac-sun8i-Use-devm_regulator_get-for-PHY-regulator.patch
This file contains 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 @@ | ||
patches.megous/net-stmmac-sun8i-Use-devm_regulator_get-for-PHY-regulator.patch |
1 change: 1 addition & 0 deletions
1
...6.1/798_MEGOUS_0005_net-stmmac-sun8i-Rename-PHY-regulator-variable-to-regulator_phy.patch
This file contains 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 @@ | ||
patches.megous/net-stmmac-sun8i-Rename-PHY-regulator-variable-to-regulator_phy.patch |
1 change: 1 addition & 0 deletions
1
...6.1/798_MEGOUS_0006_net-stmmac-sun8i-Add-support-for-enabling-a-regulator-for-PHY-I.patch
This file contains 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 @@ | ||
patches.megous/net-stmmac-sun8i-Add-support-for-enabling-a-regulator-for-PHY-I.patch |
1 change: 1 addition & 0 deletions
1
...tches-6.1/798_MEGOUS_0007_clk-Implement-protected-clocks-for-all-OF-clock-providers.patch
This file contains 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 @@ | ||
patches.megous/clk-Implement-protected-clocks-for-all-OF-clock-providers.patch |
1 change: 1 addition & 0 deletions
1
...xi/patches-6.1/798_MEGOUS_0008_bus-sunxi-rsb-Always-check-register-address-validity.patch
This file contains 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 @@ | ||
patches.megous/bus-sunxi-rsb-Always-check-register-address-validity.patch |
1 change: 1 addition & 0 deletions
1
.../sunxi/patches-6.1/798_MEGOUS_0009_bus-sunxi-rsb-Use-devm_platform_ioremap_resource.patch
This file contains 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 @@ | ||
patches.megous/bus-sunxi-rsb-Use-devm_platform_ioremap_resource.patch |
1 change: 1 addition & 0 deletions
1
...nxi/patches-6.1/798_MEGOUS_0010_of-property-fw_devlink-Support-allwinner-sram-links.patch
This file contains 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 @@ | ||
patches.megous/of-property-fw_devlink-Support-allwinner-sram-links.patch |
1 change: 1 addition & 0 deletions
1
...patches-6.1/798_MEGOUS_0011_phy-allwinner-sun4i-usb-Add-support-for-usb_role_switch.patch
This file contains 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 @@ | ||
patches.megous/phy-allwinner-sun4i-usb-Add-support-for-usb_role_switch.patch |
1 change: 1 addition & 0 deletions
1
...i/patches-6.1/798_MEGOUS_0012_sunxi-Use-dev_err_probe-to-handle-EPROBE_DEFER-errors.patch
This file contains 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 @@ | ||
patches.megous/sunxi-Use-dev_err_probe-to-handle-EPROBE_DEFER-errors.patch |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...et/linux/sunxi/patches-6.1/798_MEGOUS_0014_clk-sunxi-ng-Export-CLK_DRAM-for-devfreq.patch
This file contains 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 @@ | ||
patches.megous/clk-sunxi-ng-Export-CLK_DRAM-for-devfreq.patch |
28 changes: 28 additions & 0 deletions
28
...-6.1/patches.megous/ARM-sunxi-sunxi_cpu0_hotplug_support_set-is-not-supported-on-A8.patch
This file contains 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,28 @@ | ||
From 0e980ff22094e30bbfaad7673ce79acf349c6c09 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <[email protected]> | ||
Date: Wed, 23 Oct 2019 05:08:04 +0200 | ||
Subject: [PATCH 035/389] ARM: sunxi: sunxi_cpu0_hotplug_support_set is not | ||
supported on A83T | ||
|
||
Signed-off-by: Ondrej Jirman <[email protected]> | ||
--- | ||
arch/arm/mach-sunxi/mc_smp.c | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/arch/arm/mach-sunxi/mc_smp.c b/arch/arm/mach-sunxi/mc_smp.c | ||
index 26cbce135338..abc1f638c206 100644 | ||
--- a/arch/arm/mach-sunxi/mc_smp.c | ||
+++ b/arch/arm/mach-sunxi/mc_smp.c | ||
@@ -147,6 +147,9 @@ static int sunxi_cpu_power_switch_set(unsigned int cpu, unsigned int cluster, | ||
|
||
static void sunxi_cpu0_hotplug_support_set(bool enable) | ||
{ | ||
+ if (is_a83t) | ||
+ return; | ||
+ | ||
if (enable) { | ||
writel(CPU0_SUPPORT_HOTPLUG_MAGIC0, sram_b_smp_base); | ||
writel(CPU0_SUPPORT_HOTPLUG_MAGIC1, sram_b_smp_base + 0x4); | ||
-- | ||
2.35.3 | ||
|
33 changes: 33 additions & 0 deletions
33
...nxi/patches-6.1/patches.megous/bus-sunxi-rsb-Always-check-register-address-validity.patch
This file contains 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,33 @@ | ||
From 2a60b41c53e7b966d1c8bc5a39efd62af099d72c Mon Sep 17 00:00:00 2001 | ||
From: Samuel Holland <[email protected]> | ||
Date: Mon, 30 Dec 2019 21:56:59 -0600 | ||
Subject: [PATCH 153/389] bus: sunxi-rsb: Always check register address | ||
validity | ||
|
||
The register address was already validated for read operations before | ||
being truncated to a u8. Write operations have the same set of possible | ||
addresses, and the address is being truncated from u32 to u8 here as | ||
well, so the same check is needed. | ||
|
||
Signed-off-by: Samuel Holland <[email protected]> | ||
--- | ||
drivers/bus/sunxi-rsb.c | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c | ||
index 3aa91aed3bf7..a3a9ed5bd3a6 100644 | ||
--- a/drivers/bus/sunxi-rsb.c | ||
+++ b/drivers/bus/sunxi-rsb.c | ||
@@ -442,6 +442,9 @@ static int regmap_sunxi_rsb_reg_write(void *context, unsigned int reg, | ||
struct sunxi_rsb_ctx *ctx = context; | ||
struct sunxi_rsb_device *rdev = ctx->rdev; | ||
|
||
+ if (reg > 0xff) | ||
+ return -EINVAL; | ||
+ | ||
return sunxi_rsb_write(rdev->rsb, rdev->rtaddr, reg, &val, ctx->size); | ||
} | ||
|
||
-- | ||
2.35.3 | ||
|
38 changes: 38 additions & 0 deletions
38
...x/sunxi/patches-6.1/patches.megous/bus-sunxi-rsb-Use-devm_platform_ioremap_resource.patch
This file contains 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,38 @@ | ||
From a271026f0974b35a55c71dda12b736361a0b4893 Mon Sep 17 00:00:00 2001 | ||
From: Samuel Holland <[email protected]> | ||
Date: Mon, 30 Dec 2019 22:09:08 -0600 | ||
Subject: [PATCH 154/389] bus: sunxi-rsb: Use devm_platform_ioremap_resource | ||
|
||
This simplifies the code and removes the need for a "struct resource". | ||
|
||
Signed-off-by: Samuel Holland <[email protected]> | ||
--- | ||
drivers/bus/sunxi-rsb.c | 5 ++--- | ||
1 file changed, 2 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c | ||
index a3a9ed5bd3a6..297f3af19986 100644 | ||
--- a/drivers/bus/sunxi-rsb.c | ||
+++ b/drivers/bus/sunxi-rsb.c | ||
@@ -744,7 +744,6 @@ static int sunxi_rsb_probe(struct platform_device *pdev) | ||
{ | ||
struct device *dev = &pdev->dev; | ||
struct device_node *np = dev->of_node; | ||
- struct resource *r; | ||
struct sunxi_rsb *rsb; | ||
u32 clk_freq = 3000000; | ||
int irq, ret; | ||
@@ -764,8 +763,8 @@ static int sunxi_rsb_probe(struct platform_device *pdev) | ||
rsb->dev = dev; | ||
rsb->clk_freq = clk_freq; | ||
platform_set_drvdata(pdev, rsb); | ||
- r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
- rsb->regs = devm_ioremap_resource(dev, r); | ||
+ | ||
+ rsb->regs = devm_platform_ioremap_resource(pdev, 0); | ||
if (IS_ERR(rsb->regs)) | ||
return PTR_ERR(rsb->regs); | ||
|
||
-- | ||
2.35.3 | ||
|
207 changes: 207 additions & 0 deletions
207
...atches-6.1/patches.megous/clk-Implement-protected-clocks-for-all-OF-clock-providers.patch
This file contains 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,207 @@ | ||
From d3332aa0e2a458964fc958a4dd0ec63e3b11e3a6 Mon Sep 17 00:00:00 2001 | ||
From: Samuel Holland <[email protected]> | ||
Date: Sun, 29 Dec 2019 20:23:28 -0600 | ||
Subject: [PATCH 145/389] clk: Implement protected-clocks for all OF clock | ||
providers | ||
|
||
This is a generic implementation of the "protected-clocks" property from | ||
the common clock binding. It allows firmware to inform the OS about | ||
clocks that must not be disabled while the OS is running. | ||
|
||
This implementation comes with some caveats: | ||
|
||
1) Clocks that have CLK_IS_CRITICAL in their init data are prepared/ | ||
enabled before they are attached to the clock tree. protected-clocks are | ||
only protected once the clock provider is added, which is generally | ||
after all of the clocks it provides have been registered. This leaves a | ||
window of opportunity where something could disable or modify the clock, | ||
such as a driver running on another CPU, or the clock core itself. There | ||
is a comment to this effect in __clk_core_init(): | ||
|
||
/* | ||
* Enable CLK_IS_CRITICAL clocks so newly added critical clocks | ||
* don't get accidentally disabled when walking the orphan tree and | ||
* reparenting clocks | ||
*/ | ||
|
||
Similarly, these clocks will be enabled after they are first reparented, | ||
unlike other CLK_IS_CRITICAL clocks. See the comment in | ||
clk_core_reparent_orphans_nolock(): | ||
|
||
/* | ||
* We need to use __clk_set_parent_before() and _after() to | ||
* to properly migrate any prepare/enable count of the orphan | ||
* clock. This is important for CLK_IS_CRITICAL clocks, which | ||
* are enabled during init but might not have a parent yet. | ||
*/ | ||
|
||
Ideally we could detect protected clocks before they are reparented, but | ||
there are two problems with that: | ||
|
||
a) From the clock core's perspective, hw->init is const. | ||
|
||
b) The clock core doesn't see the device_node until __clk_register is | ||
called on the first clock. | ||
|
||
So the only "race-free" way to detect protected-clocks is to do it in | ||
the middle of __clk_register, between when core->flags is initialized | ||
and calling __clk_core_init(). That requires scanning the device tree | ||
again for each clock, which is part of why I didn't do it that way. | ||
|
||
2) __clk_protect needs to be idempotent, for two reasons: | ||
|
||
a) Clocks with CLK_IS_CRITICAL in their init data are already | ||
prepared/enabled, and we don't want to prepare/enable them again. | ||
|
||
b) of_clk_set_defaults() is called twice for (at least some) clock | ||
controllers registered with CLK_OF_DECLARE. It is called first in | ||
of_clk_add_provider()/of_clk_add_hw_provider() inside clk_init_cb, | ||
and again afterward in of_clk_init(). The second call in | ||
of_clk_init() may be unnecessary, but verifying that would require | ||
auditing all users of CLK_OF_DECLARE to ensure they called one of | ||
the of_clk_add{,_hw}_provider functions. | ||
|
||
Signed-off-by: Samuel Holland <[email protected]> | ||
--- | ||
drivers/clk/clk-conf.c | 54 ++++++++++++++++++++++++++++++++++++++++++ | ||
drivers/clk/clk.c | 31 ++++++++++++++++++++++++ | ||
drivers/clk/clk.h | 2 ++ | ||
3 files changed, 87 insertions(+) | ||
|
||
diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c | ||
index 2ef819606c41..a57d28b0f397 100644 | ||
--- a/drivers/clk/clk-conf.c | ||
+++ b/drivers/clk/clk-conf.c | ||
@@ -11,6 +11,54 @@ | ||
#include <linux/of.h> | ||
#include <linux/printk.h> | ||
|
||
+#include "clk.h" | ||
+ | ||
+static int __set_clk_flags(struct device_node *node) | ||
+{ | ||
+ struct of_phandle_args clkspec; | ||
+ struct property *prop; | ||
+ int i, index = 0, rc; | ||
+ const __be32 *cur; | ||
+ struct clk *clk; | ||
+ u32 nr_cells; | ||
+ | ||
+ rc = of_property_read_u32(node, "#clock-cells", &nr_cells); | ||
+ if (rc < 0) { | ||
+ pr_err("clk: missing #clock-cells property on %pOF\n", node); | ||
+ return rc; | ||
+ } | ||
+ | ||
+ clkspec.np = node; | ||
+ clkspec.args_count = nr_cells; | ||
+ | ||
+ of_property_for_each_u32(node, "protected-clocks", prop, cur, clkspec.args[0]) { | ||
+ /* read the remainder of the clock specifier */ | ||
+ for (i = 1; i < nr_cells; ++i) { | ||
+ cur = of_prop_next_u32(prop, cur, &clkspec.args[i]); | ||
+ if (!cur) { | ||
+ pr_err("clk: invalid value of protected-clocks" | ||
+ " property at %pOF\n", node); | ||
+ return -EINVAL; | ||
+ } | ||
+ } | ||
+ clk = of_clk_get_from_provider(&clkspec); | ||
+ if (IS_ERR(clk)) { | ||
+ if (PTR_ERR(clk) != -EPROBE_DEFER) | ||
+ pr_err("clk: couldn't get protected clock" | ||
+ " %u for %pOF\n", index, node); | ||
+ return PTR_ERR(clk); | ||
+ } | ||
+ | ||
+ rc = __clk_protect(clk); | ||
+ if (rc < 0) | ||
+ pr_warn("clk: failed to protect %s: %d\n", | ||
+ __clk_get_name(clk), rc); | ||
+ clk_put(clk); | ||
+ index++; | ||
+ } | ||
+ return 0; | ||
+} | ||
+ | ||
static int __set_clk_parents(struct device_node *node, bool clk_supplier) | ||
{ | ||
struct of_phandle_args clkspec; | ||
@@ -135,6 +183,12 @@ int of_clk_set_defaults(struct device_node *node, bool clk_supplier) | ||
if (!node) | ||
return 0; | ||
|
||
+ if (clk_supplier) { | ||
+ rc = __set_clk_flags(node); | ||
+ if (rc < 0) | ||
+ return rc; | ||
+ } | ||
+ | ||
rc = __set_clk_parents(node, clk_supplier); | ||
if (rc < 0) | ||
return rc; | ||
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c | ||
index 57b83665e5c3..95f137f4603a 100644 | ||
--- a/drivers/clk/clk.c | ||
+++ b/drivers/clk/clk.c | ||
@@ -4479,6 +4479,37 @@ struct clk *devm_clk_hw_get_clk(struct device *dev, struct clk_hw *hw, | ||
} | ||
EXPORT_SYMBOL_GPL(devm_clk_hw_get_clk); | ||
|
||
+/* | ||
+ * clk-conf helpers | ||
+ */ | ||
+ | ||
+int __clk_protect(struct clk *clk) | ||
+{ | ||
+ struct clk_core *core = clk->core; | ||
+ int ret = 0; | ||
+ | ||
+ clk_prepare_lock(); | ||
+ | ||
+ /* | ||
+ * If CLK_IS_CRITICAL was set in the clock's init data, then | ||
+ * the clock was already prepared/enabled when it was added. | ||
+ */ | ||
+ if (core->flags & CLK_IS_CRITICAL) | ||
+ goto out; | ||
+ | ||
+ core->flags |= CLK_IS_CRITICAL; | ||
+ ret = clk_core_prepare(core); | ||
+ if (ret) | ||
+ goto out; | ||
+ | ||
+ ret = clk_core_enable_lock(core); | ||
+ | ||
+out: | ||
+ clk_prepare_unlock(); | ||
+ | ||
+ return ret; | ||
+} | ||
+ | ||
/* | ||
* clkdev helpers | ||
*/ | ||
diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h | ||
index 2d801900cad5..367a0f036b13 100644 | ||
--- a/drivers/clk/clk.h | ||
+++ b/drivers/clk/clk.h | ||
@@ -24,6 +24,7 @@ struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id); | ||
#ifdef CONFIG_COMMON_CLK | ||
struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, | ||
const char *dev_id, const char *con_id); | ||
+int __clk_protect(struct clk *clk); | ||
void __clk_put(struct clk *clk); | ||
#else | ||
/* All these casts to avoid ifdefs in clkdev... */ | ||
@@ -33,6 +34,7 @@ clk_hw_create_clk(struct device *dev, struct clk_hw *hw, const char *dev_id, | ||
{ | ||
return (struct clk *)hw; | ||
} | ||
+static inline int __clk_protect(struct clk *clk) { return 0; } | ||
static inline void __clk_put(struct clk *clk) { } | ||
|
||
#endif | ||
-- | ||
2.35.3 | ||
|
Oops, something went wrong.