linux_dsm_epyc7002/drivers/clk/sunxi/clk-sun6i-ar100.c
Paul Gortmaker 439a36d7d9 clk: sunxi: make clk-* explicitly non-modular
We have the following file --> Kconfig mapping:

sunxi/clk-factors.c              obj-y
sunxi/clk-sun6i-apb0-gates.c     CONFIG_MFD_SUN6I_PRCM (bool)
sunxi/clk-sun6i-apb0.c           CONFIG_MFD_SUN6I_PRCM
sunxi/clk-sun6i-ar100.c          CONFIG_MFD_SUN6I_PRCM
sunxi/clk-sun8i-apb0.c           CONFIG_MFD_SUN6I_PRCM
sunxi/clk-sun9i-mmc.c            obj-y

Hence none of these are being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that
when reading the drivers there is no doubt they are builtin-only.  All
drivers get mostly the same changes, so they are handled in batch.

Changes are (1) convert to builtin_platform_register, (2) use the
init.h header, (3) delete the MODULE_LICENCE/MODULE_AUTHOR and
associated tags, and (4) delete any ".remove" functions.

There was a stray module.h in a file not using any init.h or
module.h stuff, so we simply removed that one.

In two cases, we explicitly disallow a driver unbind, since that
doesn't have a sensible use case anyway, and it allows us to drop
the ".remove" code for non-modular drivers.

Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.

We delete the MODULE_LICENSE etc. tags since all that information
is already contained at the top of each file in the comments.

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: "Emilio López" <emilio@elopez.com.ar>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: linux-clk@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
Link: lkml.kernel.org/r/20160704211220.5685-9-paul.gortmaker@windriver.com
2016-07-06 15:20:34 -07:00

108 lines
2.2 KiB
C

/*
* Copyright (C) 2014 Free Electrons
*
* License Terms: GNU General Public License v2
* Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
*
* Allwinner A31 AR100 clock driver
*
*/
#include <linux/bitops.h>
#include <linux/clk-provider.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include "clk-factors.h"
/**
* sun6i_get_ar100_factors - Calculates factors p, m for AR100
*
* AR100 rate is calculated as follows
* rate = (parent_rate >> p) / (m + 1);
*/
static void sun6i_get_ar100_factors(struct factors_request *req)
{
unsigned long div;
int shift;
/* clock only divides */
if (req->rate > req->parent_rate)
req->rate = req->parent_rate;
div = DIV_ROUND_UP(req->parent_rate, req->rate);
if (div < 32)
shift = 0;
else if (div >> 1 < 32)
shift = 1;
else if (div >> 2 < 32)
shift = 2;
else
shift = 3;
div >>= shift;
if (div > 32)
div = 32;
req->rate = (req->parent_rate >> shift) / div;
req->m = div - 1;
req->p = shift;
}
static const struct clk_factors_config sun6i_ar100_config = {
.mwidth = 5,
.mshift = 8,
.pwidth = 2,
.pshift = 4,
};
static const struct factors_data sun6i_ar100_data = {
.mux = 16,
.muxmask = GENMASK(1, 0),
.table = &sun6i_ar100_config,
.getter = sun6i_get_ar100_factors,
};
static DEFINE_SPINLOCK(sun6i_ar100_lock);
static int sun6i_a31_ar100_clk_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct resource *r;
void __iomem *reg;
struct clk *clk;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
reg = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(reg))
return PTR_ERR(reg);
clk = sunxi_factors_register(np, &sun6i_ar100_data, &sun6i_ar100_lock,
reg);
if (!clk)
return -ENOMEM;
platform_set_drvdata(pdev, clk);
return 0;
}
static const struct of_device_id sun6i_a31_ar100_clk_dt_ids[] = {
{ .compatible = "allwinner,sun6i-a31-ar100-clk" },
{ /* sentinel */ }
};
static struct platform_driver sun6i_a31_ar100_clk_driver = {
.driver = {
.name = "sun6i-a31-ar100-clk",
.of_match_table = sun6i_a31_ar100_clk_dt_ids,
.suppress_bind_attrs = true,
},
.probe = sun6i_a31_ar100_clk_probe,
};
builtin_platform_driver(sun6i_a31_ar100_clk_driver);