summaryrefslogtreecommitdiff
path: root/drivers/clk
diff options
context:
space:
mode:
authorBiju Das <biju.das.jz@bp.renesas.com>2023-09-09 16:05:16 +0100
committerStephen Boyd <sboyd@kernel.org>2023-10-23 19:38:51 -0700
commitfaf6b92ee0091ff7a7bba03a1726a1a97112e9db (patch)
treead4b355dbc726eb3f0232a58d093c665111dba68 /drivers/clk
parent15f5e2e4225a94fe76302e87ecdf95e56e571382 (diff)
downloadlwn-faf6b92ee0091ff7a7bba03a1726a1a97112e9db.tar.gz
lwn-faf6b92ee0091ff7a7bba03a1726a1a97112e9db.zip
clk: cdce925: Extend match support for OF tables
The driver has an OF match table, still, it uses an ID lookup table for retrieving match data. Currently, the driver is working on the assumption that an I2C device registered via OF will always match a legacy I2C device ID. The correct approach is to have an OF device ID table using i2c_get_match_data() if the devices are registered via OF/ID. Unify the OF/ID table by using struct clk_cdce925_chip_info as match data for both these tables and replace the ID lookup table for the match data by i2c_get_match_data(). Split the array clk_cdce925_chip_info_tbl[] as individual variables, and make lines shorter by referring to e.g. &clk_cdce913_info instead of &clk_cdce925_chip_info_tbl[CDCE913]. Drop enum related to chip type as there is no user. While at it, remove the trailing comma in the terminator entry for the OF table making code robust against (theoretical) misrebases or other similar things where the new entry goes _after_ the termination without the compiler noticing. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20230909150516.10353-1-biju.das.jz@bp.renesas.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk-cdce925.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/drivers/clk/clk-cdce925.c b/drivers/clk/clk-cdce925.c
index cdee4958f26d..584c103394bb 100644
--- a/drivers/clk/clk-cdce925.c
+++ b/drivers/clk/clk-cdce925.c
@@ -25,25 +25,11 @@
* Model this as 2 PLL clocks which are parents to the outputs.
*/
-enum {
- CDCE913,
- CDCE925,
- CDCE937,
- CDCE949,
-};
-
struct clk_cdce925_chip_info {
int num_plls;
int num_outputs;
};
-static const struct clk_cdce925_chip_info clk_cdce925_chip_info_tbl[] = {
- [CDCE913] = { .num_plls = 1, .num_outputs = 3 },
- [CDCE925] = { .num_plls = 2, .num_outputs = 5 },
- [CDCE937] = { .num_plls = 3, .num_outputs = 7 },
- [CDCE949] = { .num_plls = 4, .num_outputs = 9 },
-};
-
#define MAX_NUMBER_OF_PLLS 4
#define MAX_NUMBER_OF_OUTPUTS 9
@@ -621,20 +607,10 @@ static struct regmap_bus regmap_cdce925_bus = {
.read = cdce925_regmap_i2c_read,
};
-static const struct i2c_device_id cdce925_id[] = {
- { "cdce913", CDCE913 },
- { "cdce925", CDCE925 },
- { "cdce937", CDCE937 },
- { "cdce949", CDCE949 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, cdce925_id);
-
static int cdce925_probe(struct i2c_client *client)
{
struct clk_cdce925_chip *data;
struct device_node *node = client->dev.of_node;
- const struct i2c_device_id *id = i2c_match_id(cdce925_id, client);
const char *parent_name;
const char *pll_clk_name[MAX_NUMBER_OF_PLLS] = {NULL,};
struct clk_init_data init;
@@ -665,7 +641,7 @@ static int cdce925_probe(struct i2c_client *client)
return -ENOMEM;
data->i2c_client = client;
- data->chip_info = &clk_cdce925_chip_info_tbl[id->driver_data];
+ data->chip_info = i2c_get_match_data(client);
config.max_register = CDCE925_OFFSET_PLL +
data->chip_info->num_plls * 0x10 - 1;
data->regmap = devm_regmap_init(&client->dev, &regmap_cdce925_bus,
@@ -822,12 +798,41 @@ error:
return err;
}
+static const struct clk_cdce925_chip_info clk_cdce913_info = {
+ .num_plls = 1,
+ .num_outputs = 3,
+};
+
+static const struct clk_cdce925_chip_info clk_cdce925_info = {
+ .num_plls = 2,
+ .num_outputs = 5,
+};
+
+static const struct clk_cdce925_chip_info clk_cdce937_info = {
+ .num_plls = 3,
+ .num_outputs = 7,
+};
+
+static const struct clk_cdce925_chip_info clk_cdce949_info = {
+ .num_plls = 4,
+ .num_outputs = 9,
+};
+
+static const struct i2c_device_id cdce925_id[] = {
+ { "cdce913", (kernel_ulong_t)&clk_cdce913_info },
+ { "cdce925", (kernel_ulong_t)&clk_cdce925_info },
+ { "cdce937", (kernel_ulong_t)&clk_cdce937_info },
+ { "cdce949", (kernel_ulong_t)&clk_cdce949_info },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, cdce925_id);
+
static const struct of_device_id clk_cdce925_of_match[] = {
- { .compatible = "ti,cdce913" },
- { .compatible = "ti,cdce925" },
- { .compatible = "ti,cdce937" },
- { .compatible = "ti,cdce949" },
- { },
+ { .compatible = "ti,cdce913", .data = &clk_cdce913_info },
+ { .compatible = "ti,cdce925", .data = &clk_cdce925_info },
+ { .compatible = "ti,cdce937", .data = &clk_cdce937_info },
+ { .compatible = "ti,cdce949", .data = &clk_cdce949_info },
+ { }
};
MODULE_DEVICE_TABLE(of, clk_cdce925_of_match);