Merge branches 'clk-xilinx', 'clk-broadcom' and 'clk-platform' into clk-next
authorStephen Boyd <sboyd@kernel.org>
Tue, 25 Apr 2023 18:50:36 +0000 (11:50 -0700)
committerStephen Boyd <sboyd@kernel.org>
Tue, 25 Apr 2023 18:50:36 +0000 (11:50 -0700)
 - BCM63268 timer clock and reset controller
 - Convert platform clk drivers to remove_new

* clk-xilinx:
  clocking-wizard: Support higher frequency accuracy
  clk: zynqmp: pll: Remove the limit

* clk-broadcom:
  clk: bcm: Add BCM63268 timer clock and reset driver
  dt-bindings: clock: Add BCM63268 timer binding
  dt-bindings: reset: add BCM63268 timer reset definitions
  dt-bindings: clk: add BCM63268 timer clock definitions

* clk-platform: (25 commits)
  clk: xilinx: Convert to platform remove callback returning void
  clk: x86: Convert to platform remove callback returning void
  clk: uniphier: Convert to platform remove callback returning void
  clk: ti: Convert to platform remove callback returning void
  clk: tegra: Convert to platform remove callback returning void
  clk: stm32: Convert to platform remove callback returning void
  clk: mvebu: Convert to platform remove callback returning void
  clk: mmp: Convert to platform remove callback returning void
  clk: keystone: Convert to platform remove callback returning void
  clk: hisilicon: Convert to platform remove callback returning void
  clk: stm32mp1: Convert to platform remove callback returning void
  clk: scpi: Convert to platform remove callback returning void
  clk: s2mps11: Convert to platform remove callback returning void
  clk: pwm: Convert to platform remove callback returning void
  clk: palmas: Convert to platform remove callback returning void
  clk: hsdk-pll: Convert to platform remove callback returning void
  clk: fixed-rate: Convert to platform remove callback returning void
  clk: fixed-mmio: Convert to platform remove callback returning void
  clk: fixed-factor: Convert to platform remove callback returning void
  clk: axm5516: Convert to platform remove callback returning void
  ...

41 files changed:
Documentation/devicetree/bindings/clock/brcm,bcm63268-timer-clocks.yaml [new file with mode: 0644]
drivers/clk/axs10x/i2s_pll_clock.c
drivers/clk/axs10x/pll_clock.c
drivers/clk/bcm/Kconfig
drivers/clk/bcm/Makefile
drivers/clk/bcm/clk-bcm2711-dvp.c
drivers/clk/bcm/clk-bcm63268-timer.c [new file with mode: 0644]
drivers/clk/bcm/clk-bcm63xx-gate.c
drivers/clk/bcm/clk-raspberrypi.c
drivers/clk/clk-axi-clkgen.c
drivers/clk/clk-axm5516.c
drivers/clk/clk-fixed-factor.c
drivers/clk/clk-fixed-mmio.c
drivers/clk/clk-fixed-rate.c
drivers/clk/clk-hsdk-pll.c
drivers/clk/clk-palmas.c
drivers/clk/clk-pwm.c
drivers/clk/clk-s2mps11.c
drivers/clk/clk-scpi.c
drivers/clk/clk-stm32mp1.c
drivers/clk/hisilicon/clk-hi3519.c
drivers/clk/hisilicon/clk-hi3559a.c
drivers/clk/hisilicon/crg-hi3516cv300.c
drivers/clk/hisilicon/crg-hi3798cv200.c
drivers/clk/keystone/sci-clk.c
drivers/clk/mmp/clk-audio.c
drivers/clk/mvebu/armada-37xx-periph.c
drivers/clk/mvebu/armada-37xx-tbg.c
drivers/clk/mvebu/armada-37xx-xtal.c
drivers/clk/stm32/clk-stm32mp13.c
drivers/clk/tegra/clk-dfll.c
drivers/clk/tegra/clk-tegra124-dfll-fcpu.c
drivers/clk/ti/adpll.c
drivers/clk/uniphier/clk-uniphier-core.c
drivers/clk/x86/clk-fch.c
drivers/clk/x86/clk-pmc-atom.c
drivers/clk/xilinx/clk-xlnx-clock-wizard.c
drivers/clk/xilinx/xlnx_vcu.c
drivers/clk/zynqmp/pll.c
include/dt-bindings/clock/bcm63268-clock.h
include/dt-bindings/reset/bcm63268-reset.h

diff --git a/Documentation/devicetree/bindings/clock/brcm,bcm63268-timer-clocks.yaml b/Documentation/devicetree/bindings/clock/brcm,bcm63268-timer-clocks.yaml
new file mode 100644 (file)
index 0000000..199818b
--- /dev/null
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/brcm,bcm63268-timer-clocks.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM63268 Timer Clock and Reset Device Tree Bindings
+
+maintainers:
+  - Álvaro Fernández Rojas <noltari@gmail.com>
+
+properties:
+  compatible:
+    const: brcm,bcm63268-timer-clocks
+
+  reg:
+    maxItems: 1
+
+  "#clock-cells":
+    const: 1
+
+  "#reset-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#clock-cells"
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    timer_clk: clock-controller@100000ac {
+      compatible = "brcm,bcm63268-timer-clocks";
+      reg = <0x100000ac 0x4>;
+      #clock-cells = <1>;
+      #reset-cells = <1>;
+    };
index e1fda6ad5cd559a1603fb4551dadf77c293c77ec..2334e6c334cf854774b4a81570885976166d65c8 100644 (file)
@@ -198,10 +198,9 @@ static int i2s_pll_clk_probe(struct platform_device *pdev)
        return of_clk_add_provider(node, of_clk_src_simple_get, clk);
 }
 
-static int i2s_pll_clk_remove(struct platform_device *pdev)
+static void i2s_pll_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static const struct of_device_id i2s_pll_clk_id[] = {
@@ -216,7 +215,7 @@ static struct platform_driver i2s_pll_clk_driver = {
                .of_match_table = i2s_pll_clk_id,
        },
        .probe = i2s_pll_clk_probe,
-       .remove = i2s_pll_clk_remove,
+       .remove_new = i2s_pll_clk_remove,
 };
 module_platform_driver(i2s_pll_clk_driver);
 
index 90fb0e6ff573602cbc40f91fd1f547c67c81ad60..dbbfa12e530d9015cc16f352c015720355da4d0b 100644 (file)
@@ -257,10 +257,9 @@ static int axs10x_pll_clk_probe(struct platform_device *pdev)
                        &pll_clk->hw);
 }
 
-static int axs10x_pll_clk_remove(struct platform_device *pdev)
+static void axs10x_pll_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static void __init of_axs10x_pll_clk_setup(struct device_node *node)
@@ -332,7 +331,7 @@ static struct platform_driver axs10x_pll_clk_driver = {
                .of_match_table = axs10x_pll_clk_id,
        },
        .probe = axs10x_pll_clk_probe,
-       .remove = axs10x_pll_clk_remove,
+       .remove_new = axs10x_pll_clk_remove,
 };
 builtin_platform_driver(axs10x_pll_clk_driver);
 
index 77266afb1c79a9a2b2cec3c12d89051c6fb71bde..a972d763eb77d9686c1c1493dc715eb368c5ec16 100644 (file)
@@ -37,6 +37,15 @@ config CLK_BCM_63XX_GATE
          Enable common clock framework support for Broadcom BCM63xx DSL SoCs
          based on the MIPS architecture
 
+config CLK_BCM63268_TIMER
+       bool "Broadcom BCM63268 timer clock and reset support"
+       depends on BMIPS_GENERIC || COMPILE_TEST
+       default BMIPS_GENERIC
+       select RESET_CONTROLLER
+       help
+         Enable timer clock and reset support for Broadcom BCM63268 DSL SoCs
+         based on the MIPS architecture.
+
 config CLK_BCM_KONA
        bool "Broadcom Kona CCU clock support"
        depends on ARCH_BCM_MOBILE || COMPILE_TEST
index edb66b44cb273492d669a3c8af783e5277799955..d0b6f4b1fb089bd38ce4080521823a775b211222 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_CLK_BCM_63XX)     += clk-bcm63xx.o
 obj-$(CONFIG_CLK_BCM_63XX_GATE)        += clk-bcm63xx-gate.o
+obj-$(CONFIG_CLK_BCM63268_TIMER) += clk-bcm63268-timer.o
 obj-$(CONFIG_CLK_BCM_KONA)     += clk-kona.o
 obj-$(CONFIG_CLK_BCM_KONA)     += clk-kona-setup.o
 obj-$(CONFIG_CLK_BCM_KONA)     += clk-bcm281xx.o
index e63a42618ac2cd7e3657ce84770f91b7e5e1b036..e4fbbf3c40fe2b1a3175a089f2f08642340824a3 100644 (file)
@@ -92,15 +92,13 @@ unregister_clk0:
        return ret;
 };
 
-static int clk_dvp_remove(struct platform_device *pdev)
+static void clk_dvp_remove(struct platform_device *pdev)
 {
        struct clk_dvp *dvp = platform_get_drvdata(pdev);
        struct clk_hw_onecell_data *data = dvp->data;
 
        clk_hw_unregister_gate(data->hws[1]);
        clk_hw_unregister_gate(data->hws[0]);
-
-       return 0;
 }
 
 static const struct of_device_id clk_dvp_dt_ids[] = {
@@ -111,7 +109,7 @@ MODULE_DEVICE_TABLE(of, clk_dvp_dt_ids);
 
 static struct platform_driver clk_dvp_driver = {
        .probe  = clk_dvp_probe,
-       .remove = clk_dvp_remove,
+       .remove_new = clk_dvp_remove,
        .driver = {
                .name           = "brcm2711-dvp",
                .of_match_table = clk_dvp_dt_ids,
diff --git a/drivers/clk/bcm/clk-bcm63268-timer.c b/drivers/clk/bcm/clk-bcm63268-timer.c
new file mode 100644 (file)
index 0000000..463710d
--- /dev/null
@@ -0,0 +1,216 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * BCM63268 Timer Clock and Reset Controller Driver
+ *
+ * Copyright (C) 2023 Álvaro Fernández Rojas <noltari@gmail.com>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/container_of.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/reset-controller.h>
+#include <linux/spinlock.h>
+
+#include <dt-bindings/clock/bcm63268-clock.h>
+
+#define BCM63268_TIMER_RESET_SLEEP_MIN_US      10000
+#define BCM63268_TIMER_RESET_SLEEP_MAX_US      20000
+
+struct bcm63268_tclkrst_hw {
+       void __iomem *regs;
+       spinlock_t lock;
+
+       struct reset_controller_dev rcdev;
+       struct clk_hw_onecell_data data;
+};
+
+struct bcm63268_tclk_table_entry {
+       const char * const name;
+       u8 bit;
+};
+
+static const struct bcm63268_tclk_table_entry bcm63268_timer_clocks[] = {
+       {
+               .name = "ephy1",
+               .bit = BCM63268_TCLK_EPHY1,
+       }, {
+               .name = "ephy2",
+               .bit = BCM63268_TCLK_EPHY2,
+       }, {
+               .name = "ephy3",
+               .bit = BCM63268_TCLK_EPHY3,
+       }, {
+               .name = "gphy1",
+               .bit = BCM63268_TCLK_GPHY1,
+       }, {
+               .name = "dsl",
+               .bit = BCM63268_TCLK_DSL,
+       }, {
+               .name = "wakeon_ephy",
+               .bit = BCM63268_TCLK_WAKEON_EPHY,
+       }, {
+               .name = "wakeon_dsl",
+               .bit = BCM63268_TCLK_WAKEON_DSL,
+       }, {
+               .name = "fap1_pll",
+               .bit = BCM63268_TCLK_FAP1,
+       }, {
+               .name = "fap2_pll",
+               .bit = BCM63268_TCLK_FAP2,
+       }, {
+               .name = "uto_50",
+               .bit = BCM63268_TCLK_UTO_50,
+       }, {
+               .name = "uto_extin",
+               .bit = BCM63268_TCLK_UTO_EXTIN,
+       }, {
+               .name = "usb_ref",
+               .bit = BCM63268_TCLK_USB_REF,
+       }, {
+               /* sentinel */
+       }
+};
+
+static inline struct bcm63268_tclkrst_hw *
+to_bcm63268_timer_reset(struct reset_controller_dev *rcdev)
+{
+       return container_of(rcdev, struct bcm63268_tclkrst_hw, rcdev);
+}
+
+static int bcm63268_timer_reset_update(struct reset_controller_dev *rcdev,
+                               unsigned long id, bool assert)
+{
+       struct bcm63268_tclkrst_hw *reset = to_bcm63268_timer_reset(rcdev);
+       unsigned long flags;
+       uint32_t val;
+
+       spin_lock_irqsave(&reset->lock, flags);
+       val = __raw_readl(reset->regs);
+       if (assert)
+               val &= ~BIT(id);
+       else
+               val |= BIT(id);
+       __raw_writel(val, reset->regs);
+       spin_unlock_irqrestore(&reset->lock, flags);
+
+       return 0;
+}
+
+static int bcm63268_timer_reset_assert(struct reset_controller_dev *rcdev,
+                               unsigned long id)
+{
+       return bcm63268_timer_reset_update(rcdev, id, true);
+}
+
+static int bcm63268_timer_reset_deassert(struct reset_controller_dev *rcdev,
+                                 unsigned long id)
+{
+       return bcm63268_timer_reset_update(rcdev, id, false);
+}
+
+static int bcm63268_timer_reset_reset(struct reset_controller_dev *rcdev,
+                              unsigned long id)
+{
+       bcm63268_timer_reset_update(rcdev, id, true);
+       usleep_range(BCM63268_TIMER_RESET_SLEEP_MIN_US,
+                    BCM63268_TIMER_RESET_SLEEP_MAX_US);
+
+       bcm63268_timer_reset_update(rcdev, id, false);
+       /*
+        * Ensure component is taken out reset state by sleeping also after
+        * deasserting the reset. Otherwise, the component may not be ready
+        * for operation.
+        */
+       usleep_range(BCM63268_TIMER_RESET_SLEEP_MIN_US,
+                    BCM63268_TIMER_RESET_SLEEP_MAX_US);
+
+       return 0;
+}
+
+static int bcm63268_timer_reset_status(struct reset_controller_dev *rcdev,
+                               unsigned long id)
+{
+       struct bcm63268_tclkrst_hw *reset = to_bcm63268_timer_reset(rcdev);
+
+       return !(__raw_readl(reset->regs) & BIT(id));
+}
+
+static const struct reset_control_ops bcm63268_timer_reset_ops = {
+       .assert = bcm63268_timer_reset_assert,
+       .deassert = bcm63268_timer_reset_deassert,
+       .reset = bcm63268_timer_reset_reset,
+       .status = bcm63268_timer_reset_status,
+};
+
+static int bcm63268_tclk_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       const struct bcm63268_tclk_table_entry *entry;
+       struct bcm63268_tclkrst_hw *hw;
+       struct clk_hw *clk;
+       u8 maxbit = 0;
+       int i, ret;
+
+       for (entry = bcm63268_timer_clocks; entry->name; entry++)
+               maxbit = max(maxbit, entry->bit);
+       maxbit++;
+
+       hw = devm_kzalloc(&pdev->dev, struct_size(hw, data.hws, maxbit),
+                         GFP_KERNEL);
+       if (!hw)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, hw);
+
+       spin_lock_init(&hw->lock);
+
+       hw->data.num = maxbit;
+       for (i = 0; i < maxbit; i++)
+               hw->data.hws[i] = ERR_PTR(-ENODEV);
+
+       hw->regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(hw->regs))
+               return PTR_ERR(hw->regs);
+
+       for (entry = bcm63268_timer_clocks; entry->name; entry++) {
+               clk = devm_clk_hw_register_gate(dev, entry->name, NULL, 0,
+                                               hw->regs, entry->bit,
+                                               CLK_GATE_BIG_ENDIAN,
+                                               &hw->lock);
+               if (IS_ERR(clk))
+                       return PTR_ERR(clk);
+
+               hw->data.hws[entry->bit] = clk;
+       }
+
+       ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+                                         &hw->data);
+       if (ret)
+               return ret;
+
+       hw->rcdev.of_node = dev->of_node;
+       hw->rcdev.ops = &bcm63268_timer_reset_ops;
+
+       ret = devm_reset_controller_register(dev, &hw->rcdev);
+       if (ret)
+               dev_err(dev, "Failed to register reset controller\n");
+
+       return 0;
+}
+
+static const struct of_device_id bcm63268_tclk_dt_ids[] = {
+       { .compatible = "brcm,bcm63268-timer-clocks" },
+       { /* sentinel */ }
+};
+
+static struct platform_driver bcm63268_tclk = {
+       .probe = bcm63268_tclk_probe,
+       .driver = {
+               .name = "bcm63268-timer-clock",
+               .of_match_table = bcm63268_tclk_dt_ids,
+       },
+};
+builtin_platform_driver(bcm63268_tclk);
index 89297c57881e224c4e40273d894cfa7e8b2b43ec..0769f98767da6a1c33d7494d0a9b1d7f775f77d1 100644 (file)
@@ -541,7 +541,7 @@ out_err:
        return ret;
 }
 
-static int clk_bcm63xx_remove(struct platform_device *pdev)
+static void clk_bcm63xx_remove(struct platform_device *pdev)
 {
        struct clk_bcm63xx_hw *hw = platform_get_drvdata(pdev);
        int i;
@@ -552,8 +552,6 @@ static int clk_bcm63xx_remove(struct platform_device *pdev)
                if (!IS_ERR(hw->data.hws[i]))
                        clk_hw_unregister_gate(hw->data.hws[i]);
        }
-
-       return 0;
 }
 
 static const struct of_device_id clk_bcm63xx_dt_ids[] = {
@@ -570,7 +568,7 @@ static const struct of_device_id clk_bcm63xx_dt_ids[] = {
 
 static struct platform_driver clk_bcm63xx = {
        .probe = clk_bcm63xx_probe,
-       .remove = clk_bcm63xx_remove,
+       .remove_new = clk_bcm63xx_remove,
        .driver = {
                .name = "bcm63xx-clock",
                .of_match_table = clk_bcm63xx_dt_ids,
index ce2f9347973697eaaa7a672633e987f4f3fc4cfa..eb399a4d141ba24b5656064b3799765666acad7c 100644 (file)
@@ -439,13 +439,11 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int raspberrypi_clk_remove(struct platform_device *pdev)
+static void raspberrypi_clk_remove(struct platform_device *pdev)
 {
        struct raspberrypi_clk *rpi = platform_get_drvdata(pdev);
 
        platform_device_unregister(rpi->cpufreq);
-
-       return 0;
 }
 
 static const struct of_device_id raspberrypi_clk_match[] = {
@@ -460,7 +458,7 @@ static struct platform_driver raspberrypi_clk_driver = {
                .of_match_table = raspberrypi_clk_match,
        },
        .probe          = raspberrypi_clk_probe,
-       .remove         = raspberrypi_clk_remove,
+       .remove_new     = raspberrypi_clk_remove,
 };
 module_platform_driver(raspberrypi_clk_driver);
 
index ac6ff736ac8f6cd598d33554d4c1c3943bdbd2d5..671bee55ceb313c9a71c1b0df1732291c29cdbd4 100644 (file)
@@ -557,11 +557,9 @@ static int axi_clkgen_probe(struct platform_device *pdev)
                                      &axi_clkgen->clk_hw);
 }
 
-static int axi_clkgen_remove(struct platform_device *pdev)
+static void axi_clkgen_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static const struct of_device_id axi_clkgen_ids[] = {
@@ -583,7 +581,7 @@ static struct platform_driver axi_clkgen_driver = {
                .of_match_table = axi_clkgen_ids,
        },
        .probe = axi_clkgen_probe,
-       .remove = axi_clkgen_remove,
+       .remove_new = axi_clkgen_remove,
 };
 module_platform_driver(axi_clkgen_driver);
 
index 07e80fe8c310c9e75b18515e50240e06ff51867f..1dff2017ad9de64dfd8f1c84dc12770c81774210 100644 (file)
@@ -572,15 +572,14 @@ static int axmclk_probe(struct platform_device *pdev)
        return of_clk_add_hw_provider(dev->of_node, of_clk_axmclk_get, NULL);
 }
 
-static int axmclk_remove(struct platform_device *pdev)
+static void axmclk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static struct platform_driver axmclk_driver = {
        .probe          = axmclk_probe,
-       .remove         = axmclk_remove,
+       .remove_new     = axmclk_remove,
        .driver         = {
                .name   = "clk-axm5516",
                .of_match_table = axmclk_match_table,
index f734e34735a99b188cd6b3bf79a63e938cb24467..b3e66202b942422293711ded295e2124ecf00c27 100644 (file)
@@ -297,14 +297,12 @@ void __init of_fixed_factor_clk_setup(struct device_node *node)
 CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
                of_fixed_factor_clk_setup);
 
-static int of_fixed_factor_clk_remove(struct platform_device *pdev)
+static void of_fixed_factor_clk_remove(struct platform_device *pdev)
 {
        struct clk_hw *clk = platform_get_drvdata(pdev);
 
        of_clk_del_provider(pdev->dev.of_node);
        clk_hw_unregister_fixed_factor(clk);
-
-       return 0;
 }
 
 static int of_fixed_factor_clk_probe(struct platform_device *pdev)
@@ -336,7 +334,7 @@ static struct platform_driver of_fixed_factor_clk_driver = {
                .of_match_table = of_fixed_factor_clk_ids,
        },
        .probe = of_fixed_factor_clk_probe,
-       .remove = of_fixed_factor_clk_remove,
+       .remove_new = of_fixed_factor_clk_remove,
 };
 builtin_platform_driver(of_fixed_factor_clk_driver);
 #endif
index 5225d17d6b3f39210dc19de7ffb861f4544e124a..7435055670d202ff11e438db52aacc1a986c465f 100644 (file)
@@ -71,14 +71,12 @@ static int of_fixed_mmio_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int of_fixed_mmio_clk_remove(struct platform_device *pdev)
+static void of_fixed_mmio_clk_remove(struct platform_device *pdev)
 {
        struct clk_hw *clk = platform_get_drvdata(pdev);
 
        of_clk_del_provider(pdev->dev.of_node);
        clk_hw_unregister_fixed_rate(clk);
-
-       return 0;
 }
 
 static const struct of_device_id of_fixed_mmio_clk_ids[] = {
@@ -93,7 +91,7 @@ static struct platform_driver of_fixed_mmio_clk_driver = {
                .of_match_table = of_fixed_mmio_clk_ids,
        },
        .probe = of_fixed_mmio_clk_probe,
-       .remove = of_fixed_mmio_clk_remove,
+       .remove_new = of_fixed_mmio_clk_remove,
 };
 module_platform_driver(of_fixed_mmio_clk_driver);
 
index 7d775954e26da0e53c66c27376eb978cb8710a85..3481eb8cdeb3b994d22f1e73ea8985684c5dcb91 100644 (file)
@@ -196,14 +196,12 @@ void __init of_fixed_clk_setup(struct device_node *node)
 }
 CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup);
 
-static int of_fixed_clk_remove(struct platform_device *pdev)
+static void of_fixed_clk_remove(struct platform_device *pdev)
 {
        struct clk_hw *hw = platform_get_drvdata(pdev);
 
        of_clk_del_provider(pdev->dev.of_node);
        clk_hw_unregister_fixed_rate(hw);
-
-       return 0;
 }
 
 static int of_fixed_clk_probe(struct platform_device *pdev)
@@ -234,7 +232,7 @@ static struct platform_driver of_fixed_clk_driver = {
                .of_match_table = of_fixed_clk_ids,
        },
        .probe = of_fixed_clk_probe,
-       .remove = of_fixed_clk_remove,
+       .remove_new = of_fixed_clk_remove,
 };
 builtin_platform_driver(of_fixed_clk_driver);
 #endif
index 60007b508590414eaa50f95b9bf96ac9c0a3f0c3..766e139972feae8d9b5fd2666fe2e5e34242670f 100644 (file)
@@ -350,10 +350,9 @@ static int hsdk_pll_clk_probe(struct platform_device *pdev)
                        &pll_clk->hw);
 }
 
-static int hsdk_pll_clk_remove(struct platform_device *pdev)
+static void hsdk_pll_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static void __init of_hsdk_pll_clk_setup(struct device_node *node)
@@ -432,6 +431,6 @@ static struct platform_driver hsdk_pll_clk_driver = {
                .of_match_table = hsdk_pll_clk_id,
        },
        .probe = hsdk_pll_clk_probe,
-       .remove = hsdk_pll_clk_remove,
+       .remove_new = hsdk_pll_clk_remove,
 };
 builtin_platform_driver(hsdk_pll_clk_driver);
index b8c3d0da1918b719c2f3ba2c642d87ea51fd44f3..74a241b1e1f49aa46937a3f541579fc118eddf7e 100644 (file)
@@ -271,10 +271,9 @@ static int palmas_clks_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int palmas_clks_remove(struct platform_device *pdev)
+static void palmas_clks_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-       return 0;
 }
 
 static struct platform_driver palmas_clks_driver = {
@@ -283,7 +282,7 @@ static struct platform_driver palmas_clks_driver = {
                .of_match_table = palmas_clks_of_match,
        },
        .probe = palmas_clks_probe,
-       .remove = palmas_clks_remove,
+       .remove_new = palmas_clks_remove,
 };
 
 module_platform_driver(palmas_clks_driver);
index da2c8eddfd9ff6a0114f4ca7ec6f8d60ec65e058..3dd2b83d0404a93e237d5efa3b868ed28db98964 100644 (file)
@@ -129,11 +129,9 @@ static int clk_pwm_probe(struct platform_device *pdev)
        return of_clk_add_hw_provider(node, of_clk_hw_simple_get, &clk_pwm->hw);
 }
 
-static int clk_pwm_remove(struct platform_device *pdev)
+static void clk_pwm_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static const struct of_device_id clk_pwm_dt_ids[] = {
@@ -144,7 +142,7 @@ MODULE_DEVICE_TABLE(of, clk_pwm_dt_ids);
 
 static struct platform_driver clk_pwm_driver = {
        .probe = clk_pwm_probe,
-       .remove = clk_pwm_remove,
+       .remove_new = clk_pwm_remove,
        .driver = {
                .name = "pwm-clock",
                .of_match_table = clk_pwm_dt_ids,
index a3e883a9f4067191f0f97071516fdb0b6a3bbf81..38c456540d1b98cca0fc0370c185b03b497fd3ca 100644 (file)
@@ -202,7 +202,7 @@ err_reg:
        return ret;
 }
 
-static int s2mps11_clk_remove(struct platform_device *pdev)
+static void s2mps11_clk_remove(struct platform_device *pdev)
 {
        struct s2mps11_clk *s2mps11_clks = platform_get_drvdata(pdev);
        int i;
@@ -217,8 +217,6 @@ static int s2mps11_clk_remove(struct platform_device *pdev)
                        continue;
                clkdev_drop(s2mps11_clks[i].lookup);
        }
-
-       return 0;
 }
 
 static const struct platform_device_id s2mps11_clk_id[] = {
@@ -265,7 +263,7 @@ static struct platform_driver s2mps11_clk_driver = {
                .name  = "s2mps11-clk",
        },
        .probe = s2mps11_clk_probe,
-       .remove = s2mps11_clk_remove,
+       .remove_new = s2mps11_clk_remove,
        .id_table = s2mps11_clk_id,
 };
 module_platform_driver(s2mps11_clk_driver);
index a39af7616b13c5fc3b0adf56e3adeaca1ae77bd0..3fb4003453eebac59503398101b0e4530ba4eb13 100644 (file)
@@ -246,7 +246,7 @@ static int scpi_clk_add(struct device *dev, struct device_node *np,
        return of_clk_add_hw_provider(np, scpi_of_clk_src_get, clk_data);
 }
 
-static int scpi_clocks_remove(struct platform_device *pdev)
+static void scpi_clocks_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *child, *np = dev->of_node;
@@ -258,7 +258,6 @@ static int scpi_clocks_remove(struct platform_device *pdev)
 
        for_each_available_child_of_node(np, child)
                of_clk_del_provider(np);
-       return 0;
 }
 
 static int scpi_clocks_probe(struct platform_device *pdev)
@@ -305,7 +304,7 @@ static struct platform_driver scpi_clocks_driver = {
                .of_match_table = scpi_clocks_ids,
        },
        .probe = scpi_clocks_probe,
-       .remove = scpi_clocks_remove,
+       .remove_new = scpi_clocks_remove,
 };
 module_platform_driver(scpi_clocks_driver);
 
index 01e5a466897f8e4f80e99f39a764500e3ddc853d..939779f66867e01af304e9a3c68aa459298ca565 100644 (file)
@@ -2434,15 +2434,13 @@ static int stm32mp1_rcc_clocks_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
+static void stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *child, *np = dev_of_node(dev);
 
        for_each_available_child_of_node(np, child)
                of_clk_del_provider(child);
-
-       return 0;
 }
 
 static struct platform_driver stm32mp1_rcc_clocks_driver = {
@@ -2451,7 +2449,7 @@ static struct platform_driver stm32mp1_rcc_clocks_driver = {
                .of_match_table = stm32mp1_match_data,
        },
        .probe = stm32mp1_rcc_clocks_probe,
-       .remove = stm32mp1_rcc_clocks_remove,
+       .remove_new = stm32mp1_rcc_clocks_remove,
 };
 
 static int __init stm32mp1_clocks_init(void)
index ad0c7f350cf0314845edff48b053accd0a187b3b..b871872d9960db03e1493bbc64d5b1499f0f6367 100644 (file)
@@ -162,13 +162,12 @@ static int hi3519_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3519_clk_remove(struct platform_device *pdev)
+static void hi3519_clk_remove(struct platform_device *pdev)
 {
        struct hi3519_crg_data *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        hi3519_clk_unregister(pdev);
-       return 0;
 }
 
 
@@ -180,7 +179,7 @@ MODULE_DEVICE_TABLE(of, hi3519_clk_match_table);
 
 static struct platform_driver hi3519_clk_driver = {
        .probe          = hi3519_clk_probe,
-       .remove         = hi3519_clk_remove,
+       .remove_new     = hi3519_clk_remove,
        .driver         = {
                .name   = "hi3519-clk",
                .of_match_table = hi3519_clk_match_table,
index 9ea1a80acbe8b5be6475d2f729e5609c0a61d3a9..4f97638809b7b6fab648343ee439f879bdbf24f7 100644 (file)
@@ -810,18 +810,17 @@ static int hi3559av100_crg_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3559av100_crg_remove(struct platform_device *pdev)
+static void hi3559av100_crg_remove(struct platform_device *pdev)
 {
        struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        crg->funcs->unregister_clks(pdev);
-       return 0;
 }
 
 static struct platform_driver hi3559av100_crg_driver = {
        .probe          = hi3559av100_crg_probe,
-       .remove         = hi3559av100_crg_remove,
+       .remove_new     = hi3559av100_crg_remove,
        .driver         = {
                .name   = "hi3559av100-clock",
                .of_match_table = hi3559av100_crg_match_table,
index 5d4e61c7a42952a1895e740ab304db7a934946c8..fe1bd3e3f98841324318f2a489f2ba5dbf5a78dc 100644 (file)
@@ -284,18 +284,17 @@ static int hi3516cv300_crg_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3516cv300_crg_remove(struct platform_device *pdev)
+static void hi3516cv300_crg_remove(struct platform_device *pdev)
 {
        struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        crg->funcs->unregister_clks(pdev);
-       return 0;
 }
 
 static struct platform_driver hi3516cv300_crg_driver = {
        .probe          = hi3516cv300_crg_probe,
-       .remove         = hi3516cv300_crg_remove,
+       .remove_new     = hi3516cv300_crg_remove,
        .driver         = {
                .name   = "hi3516cv300-crg",
                .of_match_table = hi3516cv300_crg_match_table,
index 08a19ba776e62efe3dd421a8733fef9fb1007652..a0b16be1e25d9166808b238af3772376eea5e009 100644 (file)
@@ -367,18 +367,17 @@ static int hi3798cv200_crg_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int hi3798cv200_crg_remove(struct platform_device *pdev)
+static void hi3798cv200_crg_remove(struct platform_device *pdev)
 {
        struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
        hisi_reset_exit(crg->rstc);
        crg->funcs->unregister_clks(pdev);
-       return 0;
 }
 
 static struct platform_driver hi3798cv200_crg_driver = {
        .probe          = hi3798cv200_crg_probe,
-       .remove         = hi3798cv200_crg_remove,
+       .remove_new     = hi3798cv200_crg_remove,
        .driver         = {
                .name   = "hi3798cv200-crg",
                .of_match_table = hi3798cv200_crg_match_table,
index d4b4e74e22da60f72cd6a5ad141fe54a762c4fe6..910ecd58c4ca2e7eae7496adf81faca55e97600a 100644 (file)
@@ -689,16 +689,14 @@ static int ti_sci_clk_probe(struct platform_device *pdev)
  * via common clock framework. Any memory allocated for the device will
  * be free'd silently via the devm framework. Returns 0 always.
  */
-static int ti_sci_clk_remove(struct platform_device *pdev)
+static void ti_sci_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static struct platform_driver ti_sci_clk_driver = {
        .probe = ti_sci_clk_probe,
-       .remove = ti_sci_clk_remove,
+       .remove_new = ti_sci_clk_remove,
        .driver = {
                .name = "ti-sci-clk",
                .of_match_table = of_match_ptr(ti_sci_clk_of_match),
index 7aa7f4a9564fde8617f9e2fd5819219dfadbc20d..6fb1aa9487b59c6bed4ff9ad8da8deb2eb298fba 100644 (file)
@@ -384,12 +384,10 @@ disable_pm_runtime:
        return ret;
 }
 
-static int mmp2_audio_clk_remove(struct platform_device *pdev)
+static void mmp2_audio_clk_remove(struct platform_device *pdev)
 {
        pm_clk_destroy(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
-
-       return 0;
 }
 
 #ifdef CONFIG_PM
@@ -436,7 +434,7 @@ static struct platform_driver mmp2_audio_clk_driver = {
                .pm = &mmp2_audio_clk_pm_ops,
        },
        .probe = mmp2_audio_clk_probe,
-       .remove = mmp2_audio_clk_remove,
+       .remove_new = mmp2_audio_clk_remove,
 };
 module_platform_driver(mmp2_audio_clk_driver);
 
index e3777ca659120d52d035b55325a8abf17f1b1e8c..3ae6078f6ff76bff3096ab60b44969d9fd74f6c7 100644 (file)
@@ -781,7 +781,7 @@ static int armada_3700_periph_clock_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int armada_3700_periph_clock_remove(struct platform_device *pdev)
+static void armada_3700_periph_clock_remove(struct platform_device *pdev)
 {
        struct clk_periph_driver_data *data = platform_get_drvdata(pdev);
        struct clk_hw_onecell_data *hw_data = data->hw_data;
@@ -791,13 +791,11 @@ static int armada_3700_periph_clock_remove(struct platform_device *pdev)
 
        for (i = 0; i < hw_data->num; i++)
                clk_hw_unregister(hw_data->hws[i]);
-
-       return 0;
 }
 
 static struct platform_driver armada_3700_periph_clock_driver = {
        .probe = armada_3700_periph_clock_probe,
-       .remove = armada_3700_periph_clock_remove,
+       .remove_new = armada_3700_periph_clock_remove,
        .driver         = {
                .name   = "marvell-armada-3700-periph-clock",
                .of_match_table = armada_3700_periph_clock_of_match,
index fc403ad735adeff8a07a21fe0fa00f567521848f..eccc1aeefbafff5bb58330667fecd909e84d0590 100644 (file)
@@ -126,7 +126,7 @@ static int armada_3700_tbg_clock_probe(struct platform_device *pdev)
        return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, hw_tbg_data);
 }
 
-static int armada_3700_tbg_clock_remove(struct platform_device *pdev)
+static void armada_3700_tbg_clock_remove(struct platform_device *pdev)
 {
        int i;
        struct clk_hw_onecell_data *hw_tbg_data = platform_get_drvdata(pdev);
@@ -134,8 +134,6 @@ static int armada_3700_tbg_clock_remove(struct platform_device *pdev)
        of_clk_del_provider(pdev->dev.of_node);
        for (i = 0; i < hw_tbg_data->num; i++)
                clk_hw_unregister_fixed_factor(hw_tbg_data->hws[i]);
-
-       return 0;
 }
 
 static const struct of_device_id armada_3700_tbg_clock_of_match[] = {
@@ -145,7 +143,7 @@ static const struct of_device_id armada_3700_tbg_clock_of_match[] = {
 
 static struct platform_driver armada_3700_tbg_clock_driver = {
        .probe = armada_3700_tbg_clock_probe,
-       .remove = armada_3700_tbg_clock_remove,
+       .remove_new = armada_3700_tbg_clock_remove,
        .driver         = {
                .name   = "marvell-armada-3700-tbg-clock",
                .of_match_table = armada_3700_tbg_clock_of_match,
index 41271351cf1f4f1349599323a732f565c7b50a2a..0e2e7d00ae113c35b3e5aa967f9766f8107b0dc4 100644 (file)
@@ -65,11 +65,9 @@ static int armada_3700_xtal_clock_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int armada_3700_xtal_clock_remove(struct platform_device *pdev)
+static void armada_3700_xtal_clock_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static const struct of_device_id armada_3700_xtal_clock_of_match[] = {
@@ -79,7 +77,7 @@ static const struct of_device_id armada_3700_xtal_clock_of_match[] = {
 
 static struct platform_driver armada_3700_xtal_clock_driver = {
        .probe = armada_3700_xtal_clock_probe,
-       .remove = armada_3700_xtal_clock_remove,
+       .remove_new = armada_3700_xtal_clock_remove,
        .driver         = {
                .name   = "marvell-armada-3700-xtal-clock",
                .of_match_table = armada_3700_xtal_clock_of_match,
index 1192eee8abe48082828df6c09e4bd915fa341318..c4a737482fe5f153a0206a1b6d549108b65512c3 100644 (file)
@@ -1593,15 +1593,13 @@ static int stm32mp1_rcc_clocks_probe(struct platform_device *pdev)
        return ret;
 }
 
-static int stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
+static void stm32mp1_rcc_clocks_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct device_node *child, *np = dev_of_node(dev);
 
        for_each_available_child_of_node(np, child)
                of_clk_del_provider(child);
-
-       return 0;
 }
 
 static struct platform_driver stm32mp13_rcc_clocks_driver = {
@@ -1610,7 +1608,7 @@ static struct platform_driver stm32mp13_rcc_clocks_driver = {
                .of_match_table = stm32mp13_match_data,
        },
        .probe = stm32mp1_rcc_clocks_probe,
-       .remove = stm32mp1_rcc_clocks_remove,
+       .remove_new = stm32mp1_rcc_clocks_remove,
 };
 
 static int __init stm32mp13_clocks_init(void)
index 41433927b55c58428e33fcbcb21a01d439166281..58fa5a59e0c71efe143d393d0a9c15d46f0c21da 100644 (file)
@@ -2081,7 +2081,10 @@ struct tegra_dfll_soc_data *tegra_dfll_unregister(struct platform_device *pdev)
 {
        struct tegra_dfll *td = platform_get_drvdata(pdev);
 
-       /* Try to prevent removal while the DFLL is active */
+       /*
+        * Note that exiting early here doesn't prevent unbinding the driver.
+        * Exiting early here only leaks some resources.
+        */
        if (td->mode != DFLL_DISABLED) {
                dev_err(&pdev->dev,
                        "must disable DFLL before removing driver\n");
index 5e339ad0a97c398fc90ead6be2a5867b0e244081..2a164e565c864b75984e29f213b9ed6a1bf11ae1 100644 (file)
@@ -612,20 +612,19 @@ static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)
+static void tegra124_dfll_fcpu_remove(struct platform_device *pdev)
 {
        struct tegra_dfll_soc_data *soc;
 
+       /*
+        * Note that exiting early here is dangerous as after this function
+        * returns *soc is freed.
+        */
        soc = tegra_dfll_unregister(pdev);
-       if (IS_ERR(soc)) {
-               dev_err(&pdev->dev, "failed to unregister DFLL: %ld\n",
-                       PTR_ERR(soc));
-               return PTR_ERR(soc);
-       }
+       if (IS_ERR(soc))
+               return;
 
        tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq);
-
-       return 0;
 }
 
 static const struct dev_pm_ops tegra124_dfll_pm_ops = {
@@ -636,7 +635,7 @@ static const struct dev_pm_ops tegra124_dfll_pm_ops = {
 
 static struct platform_driver tegra124_dfll_fcpu_driver = {
        .probe = tegra124_dfll_fcpu_probe,
-       .remove = tegra124_dfll_fcpu_remove,
+       .remove_new = tegra124_dfll_fcpu_remove,
        .driver = {
                .name = "tegra124-dfll",
                .of_match_table = tegra124_dfll_fcpu_of_match,
index f5e7e20492418af7f70247391577a64fe1c37a33..6ecbba4342c58c23de094e18e871d6c33409c79f 100644 (file)
@@ -931,13 +931,11 @@ free:
        return err;
 }
 
-static int ti_adpll_remove(struct platform_device *pdev)
+static void ti_adpll_remove(struct platform_device *pdev)
 {
        struct ti_adpll_data *d = dev_get_drvdata(&pdev->dev);
 
        ti_adpll_free_resources(d);
-
-       return 0;
 }
 
 static struct platform_driver ti_adpll_driver = {
@@ -946,7 +944,7 @@ static struct platform_driver ti_adpll_driver = {
                .of_match_table = ti_adpll_match,
        },
        .probe = ti_adpll_probe,
-       .remove = ti_adpll_remove,
+       .remove_new = ti_adpll_remove,
 };
 
 static int __init ti_adpll_init(void)
index 46c66fac48e6a796bb2efaed527e389980ee0b82..92f4ddc593db25b66d15e8530d13223f503603a3 100644 (file)
@@ -91,11 +91,9 @@ static int uniphier_clk_probe(struct platform_device *pdev)
                                      hw_data);
 }
 
-static int uniphier_clk_remove(struct platform_device *pdev)
+static void uniphier_clk_remove(struct platform_device *pdev)
 {
        of_clk_del_provider(pdev->dev.of_node);
-
-       return 0;
 }
 
 static const struct of_device_id uniphier_clk_match[] = {
@@ -220,7 +218,7 @@ static const struct of_device_id uniphier_clk_match[] = {
 
 static struct platform_driver uniphier_clk_driver = {
        .probe = uniphier_clk_probe,
-       .remove = uniphier_clk_remove,
+       .remove_new = uniphier_clk_remove,
        .driver = {
                .name = "uniphier-clk",
                .of_match_table = uniphier_clk_match,
index fdc060e75839f8cffb7abf43c0aae8de56a49b99..aed7d22fae63130999d7888068407a91792a9134 100644 (file)
@@ -92,14 +92,14 @@ static int fch_clk_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int fch_clk_remove(struct platform_device *pdev)
+static void fch_clk_remove(struct platform_device *pdev)
 {
        int i, clks;
        struct pci_dev *rdev;
 
        rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
        if (!rdev)
-               return -ENODEV;
+               return;
 
        clks = pci_match_id(fch_pci_ids, rdev) ? CLK_MAX_FIXED : ST_MAX_CLKS;
 
@@ -107,7 +107,6 @@ static int fch_clk_remove(struct platform_device *pdev)
                clk_hw_unregister(hws[i]);
 
        pci_dev_put(rdev);
-       return 0;
 }
 
 static struct platform_driver fch_clk_driver = {
@@ -116,6 +115,6 @@ static struct platform_driver fch_clk_driver = {
                .suppress_bind_attrs = true,
        },
        .probe = fch_clk_probe,
-       .remove = fch_clk_remove,
+       .remove_new = fch_clk_remove,
 };
 builtin_platform_driver(fch_clk_driver);
index e746e3f8d05a9c21c5526d6138fdc46600be7077..2974dd0ec6f4d0162dfbeec2b814e94ada5b2035 100644 (file)
@@ -367,7 +367,7 @@ err_unreg_clk_plt:
        return err;
 }
 
-static int plt_clk_remove(struct platform_device *pdev)
+static void plt_clk_remove(struct platform_device *pdev)
 {
        struct clk_plt_data *data;
 
@@ -377,7 +377,6 @@ static int plt_clk_remove(struct platform_device *pdev)
        clkdev_drop(data->mclk_lookup);
        plt_clk_unregister_loop(data, PMC_CLK_NUM);
        plt_clk_unregister_parents(data);
-       return 0;
 }
 
 static struct platform_driver plt_clk_driver = {
@@ -385,6 +384,6 @@ static struct platform_driver plt_clk_driver = {
                .name = "clk-pmc-atom",
        },
        .probe = plt_clk_probe,
-       .remove = plt_clk_remove,
+       .remove_new = plt_clk_remove,
 };
 builtin_platform_driver(plt_clk_driver);
index eb1dfe7ecc1b43edddc1db13ca5b32d99a58e97f..e83f104fad029815ee245531cdac8413eaef2349 100644 (file)
@@ -8,12 +8,14 @@
  *
  */
 
+#include <linux/bitfield.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/of.h>
+#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/iopoll.h>
@@ -37,6 +39,7 @@
 #define WZRD_CLKOUT_DIVIDE_MASK                (0xff << WZRD_DIVCLK_DIVIDE_SHIFT)
 #define WZRD_CLKOUT_FRAC_SHIFT         8
 #define WZRD_CLKOUT_FRAC_MASK          0x3ff
+#define WZRD_CLKOUT0_FRAC_MASK         GENMASK(17, 8)
 
 #define WZRD_DR_MAX_INT_DIV_VALUE      255
 #define WZRD_DR_STATUS_REG_OFFSET      0x04
 
 #define WZRD_USEC_POLL         10
 #define WZRD_TIMEOUT_POLL              1000
+
+/* Divider limits, from UG572 Table 3-4 for Ultrascale+ */
+#define DIV_O                          0x01
+#define DIV_ALL                                0x03
+
+#define WZRD_M_MIN                     2
+#define WZRD_M_MAX                     128
+#define WZRD_D_MIN                     1
+#define WZRD_D_MAX                     106
+#define WZRD_VCO_MIN                   800000000
+#define WZRD_VCO_MAX                   1600000000
+#define WZRD_O_MIN                     1
+#define WZRD_O_MAX                     128
+#define WZRD_MIN_ERR                   20000
+#define WZRD_FRAC_POINTS               1000
+
 /* Get the mask from width */
 #define div_mask(width)                        ((1 << (width)) - 1)
 
@@ -97,6 +116,9 @@ struct clk_wzrd {
  * @width:     width of the divider bit field
  * @flags:     clk_wzrd divider flags
  * @table:     array of value/divider pairs, last entry should have div = 0
+ * @m: value of the multiplier
+ * @d: value of the common divider
+ * @o: value of the leaf divider
  * @lock:      register lock
  */
 struct clk_wzrd_divider {
@@ -107,6 +129,9 @@ struct clk_wzrd_divider {
        u8 width;
        u8 flags;
        const struct clk_div_table *table;
+       u32 m;
+       u32 d;
+       u32 o;
        spinlock_t *lock;  /* divider lock */
 };
 
@@ -198,12 +223,155 @@ static long clk_wzrd_round_rate(struct clk_hw *hw, unsigned long rate,
        return *prate / div;
 }
 
+static int clk_wzrd_get_divisors(struct clk_hw *hw, unsigned long rate,
+                                unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long vco_freq, freq, diff;
+       u32 m, d, o;
+
+       for (m = WZRD_M_MIN; m <= WZRD_M_MAX; m++) {
+               for (d = WZRD_D_MIN; d <= WZRD_D_MAX; d++) {
+                       vco_freq = DIV_ROUND_CLOSEST((parent_rate * m), d);
+                       if (vco_freq >= WZRD_VCO_MIN && vco_freq <= WZRD_VCO_MAX) {
+                               for (o = WZRD_O_MIN; o <= WZRD_O_MAX; o++) {
+                                       freq = DIV_ROUND_CLOSEST_ULL(vco_freq, o);
+                                       diff = abs(freq - rate);
+
+                                       if (diff < WZRD_MIN_ERR) {
+                                               divider->m = m;
+                                               divider->d = d;
+                                               divider->o = o;
+                                               return 0;
+                                       }
+                               }
+                       }
+               }
+       }
+       return -EBUSY;
+}
+
+static int clk_wzrd_dynamic_all_nolock(struct clk_hw *hw, unsigned long rate,
+                                      unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long vco_freq, rate_div, clockout0_div;
+       u32 reg, pre, value, f;
+       int err;
+
+       err = clk_wzrd_get_divisors(hw, rate, parent_rate);
+       if (err)
+               return err;
+
+       vco_freq = DIV_ROUND_CLOSEST(parent_rate * divider->m, divider->d);
+       rate_div = DIV_ROUND_CLOSEST_ULL((vco_freq * WZRD_FRAC_POINTS), rate);
+
+       clockout0_div = div_u64(rate_div,  WZRD_FRAC_POINTS);
+
+       pre = DIV_ROUND_CLOSEST_ULL(vco_freq * WZRD_FRAC_POINTS, rate);
+       f = (pre - (clockout0_div * WZRD_FRAC_POINTS));
+       f &= WZRD_CLKOUT_FRAC_MASK;
+
+       reg = FIELD_PREP(WZRD_CLKOUT_DIVIDE_MASK, clockout0_div) |
+             FIELD_PREP(WZRD_CLKOUT0_FRAC_MASK, f);
+
+       writel(reg, divider->base + WZRD_CLK_CFG_REG(2));
+       /* Set divisor and clear phase offset */
+       reg = FIELD_PREP(WZRD_CLKFBOUT_MULT_MASK, divider->m) |
+             FIELD_PREP(WZRD_DIVCLK_DIVIDE_MASK, divider->d);
+       writel(reg, divider->base + WZRD_CLK_CFG_REG(0));
+       writel(divider->o, divider->base + WZRD_CLK_CFG_REG(2));
+       writel(0, divider->base + WZRD_CLK_CFG_REG(3));
+       /* Check status register */
+       err = readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET, value,
+                                value & WZRD_DR_LOCK_BIT_MASK,
+                                WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+       if (err)
+               return -ETIMEDOUT;
+
+       /* Initiate reconfiguration */
+       writel(WZRD_DR_BEGIN_DYNA_RECONF,
+              divider->base + WZRD_DR_INIT_REG_OFFSET);
+
+       /* Check status register */
+       return readl_poll_timeout(divider->base + WZRD_DR_STATUS_REG_OFFSET, value,
+                                value & WZRD_DR_LOCK_BIT_MASK,
+                                WZRD_USEC_POLL, WZRD_TIMEOUT_POLL);
+}
+
+static int clk_wzrd_dynamic_all(struct clk_hw *hw, unsigned long rate,
+                               unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long flags = 0;
+       int ret;
+
+       spin_lock_irqsave(divider->lock, flags);
+
+       ret = clk_wzrd_dynamic_all_nolock(hw, rate, parent_rate);
+
+       spin_unlock_irqrestore(divider->lock, flags);
+
+       return ret;
+}
+
+static unsigned long clk_wzrd_recalc_rate_all(struct clk_hw *hw,
+                                             unsigned long parent_rate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       u32 m, d, o, div, reg, f;
+
+       reg = readl(divider->base + WZRD_CLK_CFG_REG(0));
+       d = FIELD_GET(WZRD_DIVCLK_DIVIDE_MASK, reg);
+       m = FIELD_GET(WZRD_CLKFBOUT_MULT_MASK, reg);
+       reg = readl(divider->base + WZRD_CLK_CFG_REG(2));
+       o = FIELD_GET(WZRD_DIVCLK_DIVIDE_MASK, reg);
+       f = FIELD_GET(WZRD_CLKOUT0_FRAC_MASK, reg);
+
+       div = DIV_ROUND_CLOSEST(d * (WZRD_FRAC_POINTS * o + f), WZRD_FRAC_POINTS);
+       return divider_recalc_rate(hw, parent_rate * m, div, divider->table,
+                       divider->flags, divider->width);
+}
+
+static long clk_wzrd_round_rate_all(struct clk_hw *hw, unsigned long rate,
+                                   unsigned long *prate)
+{
+       struct clk_wzrd_divider *divider = to_clk_wzrd_divider(hw);
+       unsigned long int_freq;
+       u32 m, d, o, div, f;
+       int err;
+
+       err = clk_wzrd_get_divisors(hw, rate, *prate);
+       if (err)
+               return err;
+
+       m = divider->m;
+       d = divider->d;
+       o = divider->o;
+
+       div = d * o;
+       int_freq =  divider_recalc_rate(hw, *prate * m, div, divider->table,
+                                       divider->flags, divider->width);
+
+       if (rate > int_freq) {
+               f = DIV_ROUND_CLOSEST_ULL(rate * WZRD_FRAC_POINTS, int_freq);
+               rate = DIV_ROUND_CLOSEST(int_freq * f, WZRD_FRAC_POINTS);
+       }
+       return rate;
+}
+
 static const struct clk_ops clk_wzrd_clk_divider_ops = {
        .round_rate = clk_wzrd_round_rate,
        .set_rate = clk_wzrd_dynamic_reconfig,
        .recalc_rate = clk_wzrd_recalc_rate,
 };
 
+static const struct clk_ops clk_wzrd_clk_div_all_ops = {
+       .round_rate = clk_wzrd_round_rate_all,
+       .set_rate = clk_wzrd_dynamic_all,
+       .recalc_rate = clk_wzrd_recalc_rate_all,
+};
+
 static unsigned long clk_wzrd_recalc_ratef(struct clk_hw *hw,
                                           unsigned long parent_rate)
 {
@@ -280,7 +448,7 @@ static struct clk *clk_wzrd_register_divf(struct device *dev,
                                          void __iomem *base, u16 offset,
                                          u8 shift, u8 width,
                                          u8 clk_divider_flags,
-                                         const struct clk_div_table *table,
+                                         u32 div_type,
                                          spinlock_t *lock)
 {
        struct clk_wzrd_divider *div;
@@ -307,7 +475,6 @@ static struct clk *clk_wzrd_register_divf(struct device *dev,
        div->flags = clk_divider_flags;
        div->lock = lock;
        div->hw.init = &init;
-       div->table = table;
 
        hw = &div->hw;
        ret =  devm_clk_hw_register(dev, hw);
@@ -324,7 +491,7 @@ static struct clk *clk_wzrd_register_divider(struct device *dev,
                                             void __iomem *base, u16 offset,
                                             u8 shift, u8 width,
                                             u8 clk_divider_flags,
-                                            const struct clk_div_table *table,
+                                            u32 div_type,
                                             spinlock_t *lock)
 {
        struct clk_wzrd_divider *div;
@@ -337,7 +504,12 @@ static struct clk *clk_wzrd_register_divider(struct device *dev,
                return ERR_PTR(-ENOMEM);
 
        init.name = name;
-       init.ops = &clk_wzrd_clk_divider_ops;
+       if (clk_divider_flags & CLK_DIVIDER_READ_ONLY)
+               init.ops = &clk_divider_ro_ops;
+       else if (div_type == DIV_O)
+               init.ops = &clk_wzrd_clk_divider_ops;
+       else
+               init.ops = &clk_wzrd_clk_div_all_ops;
        init.flags = flags;
        init.parent_names =  &parent_name;
        init.num_parents =  1;
@@ -349,7 +521,6 @@ static struct clk *clk_wzrd_register_divider(struct device *dev,
        div->flags = clk_divider_flags;
        div->lock = lock;
        div->hw.init = &init;
-       div->table = table;
 
        hw = &div->hw;
        ret = devm_clk_hw_register(dev, hw);
@@ -425,6 +596,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
        const char *clk_name;
        void __iomem *ctrl_reg;
        struct clk_wzrd *clk_wzrd;
+       const char *clkout_name;
        struct device_node *np = pdev->dev.of_node;
        int nr_outputs;
        unsigned long flags = 0;
@@ -469,6 +641,26 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                goto err_disable_clk;
        }
 
+       ret = of_property_read_u32(np, "xlnx,nr-outputs", &nr_outputs);
+       if (ret || nr_outputs > WZRD_NUM_OUTPUTS) {
+               ret = -EINVAL;
+               goto err_disable_clk;
+       }
+
+       clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_out0", dev_name(&pdev->dev));
+       if (nr_outputs == 1) {
+               clk_wzrd->clkout[0] = clk_wzrd_register_divider
+                               (&pdev->dev, clkout_name,
+                               __clk_get_name(clk_wzrd->clk_in1), 0,
+                               clk_wzrd->base, WZRD_CLK_CFG_REG(3),
+                               WZRD_CLKOUT_DIVIDE_SHIFT,
+                               WZRD_CLKOUT_DIVIDE_WIDTH,
+                               CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
+                               DIV_ALL, &clkwzrd_lock);
+
+               goto out;
+       }
+
        reg = readl(clk_wzrd->base + WZRD_CLK_CFG_REG(0));
        reg_f = reg & WZRD_CLKFBOUT_FRAC_MASK;
        reg_f =  reg_f >> WZRD_CLKFBOUT_FRAC_SHIFT;
@@ -476,20 +668,11 @@ static int clk_wzrd_probe(struct platform_device *pdev)
        reg = reg & WZRD_CLKFBOUT_MULT_MASK;
        reg =  reg >> WZRD_CLKFBOUT_MULT_SHIFT;
        mult = (reg * 1000) + reg_f;
-       clk_name = kasprintf(GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
+       clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul", dev_name(&pdev->dev));
        if (!clk_name) {
                ret = -ENOMEM;
                goto err_disable_clk;
        }
-
-       ret = of_property_read_u32(np, "xlnx,nr-outputs", &nr_outputs);
-       if (ret || nr_outputs > WZRD_NUM_OUTPUTS) {
-               ret = -EINVAL;
-               goto err_disable_clk;
-       }
-       if (nr_outputs == 1)
-               flags = CLK_SET_RATE_PARENT;
-
        clk_wzrd->clks_internal[wzrd_clk_mul] = clk_register_fixed_factor
                        (&pdev->dev, clk_name,
                         __clk_get_name(clk_wzrd->clk_in1),
@@ -500,7 +683,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                goto err_disable_clk;
        }
 
-       clk_name = kasprintf(GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
+       clk_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_mul_div", dev_name(&pdev->dev));
        if (!clk_name) {
                ret = -ENOMEM;
                goto err_rm_int_clk;
@@ -521,9 +704,8 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 
        /* register div per output */
        for (i = nr_outputs - 1; i >= 0 ; i--) {
-               const char *clkout_name;
-
-               clkout_name = kasprintf(GFP_KERNEL, "%s_out%d", dev_name(&pdev->dev), i);
+               clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
+                                            "%s_out%d", dev_name(&pdev->dev), i);
                if (!clkout_name) {
                        ret = -ENOMEM;
                        goto err_rm_int_clk;
@@ -537,7 +719,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                                WZRD_CLKOUT_DIVIDE_SHIFT,
                                WZRD_CLKOUT_DIVIDE_WIDTH,
                                CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
-                               NULL, &clkwzrd_lock);
+                               DIV_O, &clkwzrd_lock);
                else
                        clk_wzrd->clkout[i] = clk_wzrd_register_divider
                                (&pdev->dev, clkout_name,
@@ -546,7 +728,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                                WZRD_CLKOUT_DIVIDE_SHIFT,
                                WZRD_CLKOUT_DIVIDE_WIDTH,
                                CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
-                               NULL, &clkwzrd_lock);
+                               DIV_O, &clkwzrd_lock);
                if (IS_ERR(clk_wzrd->clkout[i])) {
                        int j;
 
@@ -559,8 +741,7 @@ static int clk_wzrd_probe(struct platform_device *pdev)
                }
        }
 
-       kfree(clk_name);
-
+out:
        clk_wzrd->clk_data.clks = clk_wzrd->clkout;
        clk_wzrd->clk_data.clk_num = ARRAY_SIZE(clk_wzrd->clkout);
        of_clk_add_provider(np, of_clk_src_onecell_get, &clk_wzrd->clk_data);
@@ -585,7 +766,6 @@ static int clk_wzrd_probe(struct platform_device *pdev)
 err_rm_int_clks:
        clk_unregister(clk_wzrd->clks_internal[1]);
 err_rm_int_clk:
-       kfree(clk_name);
        clk_unregister(clk_wzrd->clks_internal[0]);
 err_disable_clk:
        clk_disable_unprepare(clk_wzrd->axi_clk);
@@ -593,7 +773,7 @@ err_disable_clk:
        return ret;
 }
 
-static int clk_wzrd_remove(struct platform_device *pdev)
+static void clk_wzrd_remove(struct platform_device *pdev)
 {
        int i;
        struct clk_wzrd *clk_wzrd = platform_get_drvdata(pdev);
@@ -611,8 +791,6 @@ static int clk_wzrd_remove(struct platform_device *pdev)
        }
 
        clk_disable_unprepare(clk_wzrd->axi_clk);
-
-       return 0;
 }
 
 static const struct of_device_id clk_wzrd_ids[] = {
@@ -630,7 +808,7 @@ static struct platform_driver clk_wzrd_driver = {
                .pm = &clk_wzrd_dev_pm_ops,
        },
        .probe = clk_wzrd_probe,
-       .remove = clk_wzrd_remove,
+       .remove_new = clk_wzrd_remove,
 };
 module_platform_driver(clk_wzrd_driver);
 
index d66b1315114e652370c16768dc3e3b0228800843..0786f15ebbe83fad65c4278b5685be5a4c1f0783 100644 (file)
@@ -702,13 +702,11 @@ error_clk_provider:
  * Return:     Returns 0 on success
  *             Negative error code otherwise
  */
-static int xvcu_remove(struct platform_device *pdev)
+static void xvcu_remove(struct platform_device *pdev)
 {
        struct xvcu_device *xvcu;
 
        xvcu = platform_get_drvdata(pdev);
-       if (!xvcu)
-               return -ENODEV;
 
        xvcu_unregister_clock_provider(xvcu);
 
@@ -716,8 +714,6 @@ static int xvcu_remove(struct platform_device *pdev)
        regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, 0);
 
        clk_disable_unprepare(xvcu->aclk);
-
-       return 0;
 }
 
 static const struct of_device_id xvcu_of_id_table[] = {
@@ -733,7 +729,7 @@ static struct platform_driver xvcu_driver = {
                .of_match_table = xvcu_of_id_table,
        },
        .probe                  = xvcu_probe,
-       .remove                 = xvcu_remove,
+       .remove_new             = xvcu_remove,
 };
 
 module_platform_driver(xvcu_driver);
index 0d3e1377b092ca149885bd0c7d5c92a4edd06916..7411a7fd50acf7b718f789074598c25bec509aa1 100644 (file)
@@ -341,7 +341,5 @@ struct clk_hw *zynqmp_clk_register_pll(const char *name, u32 clk_id,
                return ERR_PTR(ret);
        }
 
-       clk_hw_set_rate_range(hw, PS_PLL_VCO_MIN, PS_PLL_VCO_MAX);
-
        return hw;
 }
index da23e691d359b7d433ea1c11ee96d69e97793d58..dea8adc8510e70051e9be11346df480c1a53850f 100644 (file)
 #define BCM63268_CLK_TBUS      27
 #define BCM63268_CLK_ROBOSW250 31
 
+#define BCM63268_TCLK_EPHY1            0
+#define BCM63268_TCLK_EPHY2            1
+#define BCM63268_TCLK_EPHY3            2
+#define BCM63268_TCLK_GPHY1            3
+#define BCM63268_TCLK_DSL              4
+#define BCM63268_TCLK_WAKEON_EPHY      6
+#define BCM63268_TCLK_WAKEON_DSL       7
+#define BCM63268_TCLK_FAP1             11
+#define BCM63268_TCLK_FAP2             15
+#define BCM63268_TCLK_UTO_50           16
+#define BCM63268_TCLK_UTO_EXTIN                17
+#define BCM63268_TCLK_USB_REF          18
+
 #endif /* __DT_BINDINGS_CLOCK_BCM63268_H */
index 6a6403a4c2d588c76dee9810bbac3bfe048fd278..d87a7882782a6080facb870e8e9416b9d2913fe8 100644 (file)
@@ -23,4 +23,8 @@
 #define BCM63268_RST_PCIE_HARD 17
 #define BCM63268_RST_GPHY      18
 
+#define BCM63268_TRST_SW       29
+#define BCM63268_TRST_HW       30
+#define BCM63268_TRST_POR      31
+
 #endif /* __DT_BINDINGS_RESET_BCM63268_H */