@@ -129,6 +129,15 @@
#define APMU_EMAC0_CLK_RES_CTRL 0x3e4
#define APMU_EMAC1_CLK_RES_CTRL 0x3ec
+struct spacemit_ccu_clk {
+ int id;
+ struct clk_hw *hw;
+};
+
+struct spacemit_ccu_data {
+ struct spacemit_ccu_clk *clk; /* array with sentinel */
+};
+
/* APBS clocks start */
/* Frequency of pll{1,2} should not be updated at runtime */
@@ -1359,11 +1368,6 @@ static CCU_GATE_DEFINE(emmc_bus_clk, CCU_PARENT_HW(pmua_aclk),
0);
/* APMU clocks end */
-struct spacemit_ccu_clk {
- int id;
- struct clk_hw *hw;
-};
-
static struct spacemit_ccu_clk k1_ccu_apbs_clks[] = {
{ CLK_PLL1, &pll1.common.hw },
{ CLK_PLL2, &pll2.common.hw },
@@ -1403,6 +1407,10 @@ static struct spacemit_ccu_clk k1_ccu_apbs_clks[] = {
{ 0, NULL },
};
+static const struct spacemit_ccu_data k1_ccu_apbs_data = {
+ .clk = k1_ccu_apbs_clks,
+};
+
static struct spacemit_ccu_clk k1_ccu_mpmu_clks[] = {
{ CLK_PLL1_307P2, &pll1_d8_307p2.common.hw },
{ CLK_PLL1_76P8, &pll1_d32_76p8.common.hw },
@@ -1440,6 +1448,10 @@ static struct spacemit_ccu_clk k1_ccu_mpmu_clks[] = {
{ 0, NULL },
};
+static const struct spacemit_ccu_data k1_ccu_mpmu_data = {
+ .clk = k1_ccu_mpmu_clks,
+};
+
static struct spacemit_ccu_clk k1_ccu_apbc_clks[] = {
{ CLK_UART0, &uart0_clk.common.hw },
{ CLK_UART2, &uart2_clk.common.hw },
@@ -1544,6 +1556,10 @@ static struct spacemit_ccu_clk k1_ccu_apbc_clks[] = {
{ 0, NULL },
};
+static const struct spacemit_ccu_data k1_ccu_apbc_data = {
+ .clk = k1_ccu_apbc_clks,
+};
+
static struct spacemit_ccu_clk k1_ccu_apmu_clks[] = {
{ CLK_CCI550, &cci550_clk.common.hw },
{ CLK_CPU_C0_HI, &cpu_c0_hi_clk.common.hw },
@@ -1610,9 +1626,13 @@ static struct spacemit_ccu_clk k1_ccu_apmu_clks[] = {
{ 0, NULL },
};
+static const struct spacemit_ccu_data k1_ccu_apmu_data = {
+ .clk = k1_ccu_apmu_clks,
+};
+
static int spacemit_ccu_register(struct device *dev,
struct regmap *regmap, struct regmap *lock_regmap,
- const struct spacemit_ccu_clk *clks)
+ struct spacemit_ccu_clk *clks)
{
const struct spacemit_ccu_clk *clk;
int i, ret, max_id = 0;
@@ -1648,15 +1668,22 @@ static int spacemit_ccu_register(struct device *dev,
clk_data->num = max_id + 1;
- return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data);
+ if (ret)
+ dev_err(dev, "error %d adding clock hardware provider\n", ret);
+
+ return ret;
}
static int k1_ccu_probe(struct platform_device *pdev)
{
struct regmap *base_regmap, *lock_regmap = NULL;
+ const struct spacemit_ccu_data *data;
struct device *dev = &pdev->dev;
int ret;
+ data = of_device_get_match_data(dev);
+
base_regmap = device_node_to_regmap(dev->of_node);
if (IS_ERR(base_regmap))
return dev_err_probe(dev, PTR_ERR(base_regmap),
@@ -1677,32 +1704,32 @@ static int k1_ccu_probe(struct platform_device *pdev)
"failed to get lock regmap\n");
}
- ret = spacemit_ccu_register(dev, base_regmap, lock_regmap,
- of_device_get_match_data(dev));
+ ret = spacemit_ccu_register(dev, base_regmap, lock_regmap, data->clk);
if (ret)
return dev_err_probe(dev, ret, "failed to register clocks\n");
return 0;
}
+/* The match data is required to be non-null, and have a non-null clk pointer */
static const struct of_device_id of_k1_ccu_match[] = {
{
.compatible = "spacemit,k1-pll",
- .data = k1_ccu_apbs_clks,
+ .data = &k1_ccu_apbs_data,
},
{
.compatible = "spacemit,k1-syscon-mpmu",
- .data = k1_ccu_mpmu_clks,
+ .data = &k1_ccu_mpmu_data,
},
{
.compatible = "spacemit,k1-syscon-apbc",
- .data = k1_ccu_apbc_clks,
+ .data = &k1_ccu_apbc_data,
},
{
.compatible = "spacemit,k1-syscon-apmu",
- .data = k1_ccu_apmu_clks,
+ .data = &k1_ccu_apmu_data,
},
- { }
+ { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_k1_ccu_match);
Define a new structure type to be used for describing the OF match data. Rather than using the array of spacemit_ccu_clk structures for match data, we use this structure instead. Move the definition of the spacemit_ccu_clk structure closer to the top of the source file, and add the new structure definition below it. Signed-off-by: Alex Elder <elder@riscstar.com> --- v2: - New structure is called spacemit_ccu_data, not k1_ccu_data - Don't check for a null match data pointer; add a comment instead drivers/clk/spacemit/ccu-k1.c | 55 ++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-)