Skip to content

Commit faf6b92

Browse files
bijudasbebarino
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 15f5e2e commit faf6b92

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

drivers/clk/clk-cdce925.c

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,11 @@
2525
* Model this as 2 PLL clocks which are parents to the outputs.
2626
*/
2727

28-
enum {
29-
CDCE913,
30-
CDCE925,
31-
CDCE937,
32-
CDCE949,
33-
};
34-
3528
struct clk_cdce925_chip_info {
3629
int num_plls;
3730
int num_outputs;
3831
};
3932

40-
static const struct clk_cdce925_chip_info clk_cdce925_chip_info_tbl[] = {
41-
[CDCE913] = { .num_plls = 1, .num_outputs = 3 },
42-
[CDCE925] = { .num_plls = 2, .num_outputs = 5 },
43-
[CDCE937] = { .num_plls = 3, .num_outputs = 7 },
44-
[CDCE949] = { .num_plls = 4, .num_outputs = 9 },
45-
};
46-
4733
#define MAX_NUMBER_OF_PLLS 4
4834
#define MAX_NUMBER_OF_OUTPUTS 9
4935

@@ -621,20 +607,10 @@ static struct regmap_bus regmap_cdce925_bus = {
621607
.read = cdce925_regmap_i2c_read,
622608
};
623609

624-
static const struct i2c_device_id cdce925_id[] = {
625-
{ "cdce913", CDCE913 },
626-
{ "cdce925", CDCE925 },
627-
{ "cdce937", CDCE937 },
628-
{ "cdce949", CDCE949 },
629-
{ }
630-
};
631-
MODULE_DEVICE_TABLE(i2c, cdce925_id);
632-
633610
static int cdce925_probe(struct i2c_client *client)
634611
{
635612
struct clk_cdce925_chip *data;
636613
struct device_node *node = client->dev.of_node;
637-
const struct i2c_device_id *id = i2c_match_id(cdce925_id, client);
638614
const char *parent_name;
639615
const char *pll_clk_name[MAX_NUMBER_OF_PLLS] = {NULL,};
640616
struct clk_init_data init;
@@ -665,7 +641,7 @@ static int cdce925_probe(struct i2c_client *client)
665641
return -ENOMEM;
666642

667643
data->i2c_client = client;
668-
data->chip_info = &clk_cdce925_chip_info_tbl[id->driver_data];
644+
data->chip_info = i2c_get_match_data(client);
669645
config.max_register = CDCE925_OFFSET_PLL +
670646
data->chip_info->num_plls * 0x10 - 1;
671647
data->regmap = devm_regmap_init(&client->dev, &regmap_cdce925_bus,
@@ -822,12 +798,41 @@ static int cdce925_probe(struct i2c_client *client)
822798
return err;
823799
}
824800

801+
static const struct clk_cdce925_chip_info clk_cdce913_info = {
802+
.num_plls = 1,
803+
.num_outputs = 3,
804+
};
805+
806+
static const struct clk_cdce925_chip_info clk_cdce925_info = {
807+
.num_plls = 2,
808+
.num_outputs = 5,
809+
};
810+
811+
static const struct clk_cdce925_chip_info clk_cdce937_info = {
812+
.num_plls = 3,
813+
.num_outputs = 7,
814+
};
815+
816+
static const struct clk_cdce925_chip_info clk_cdce949_info = {
817+
.num_plls = 4,
818+
.num_outputs = 9,
819+
};
820+
821+
static const struct i2c_device_id cdce925_id[] = {
822+
{ "cdce913", (kernel_ulong_t)&clk_cdce913_info },
823+
{ "cdce925", (kernel_ulong_t)&clk_cdce925_info },
824+
{ "cdce937", (kernel_ulong_t)&clk_cdce937_info },
825+
{ "cdce949", (kernel_ulong_t)&clk_cdce949_info },
826+
{ }
827+
};
828+
MODULE_DEVICE_TABLE(i2c, cdce925_id);
829+
825830
static const struct of_device_id clk_cdce925_of_match[] = {
826-
{ .compatible = "ti,cdce913" },
827-
{ .compatible = "ti,cdce925" },
828-
{ .compatible = "ti,cdce937" },
829-
{ .compatible = "ti,cdce949" },
830-
{ },
831+
{ .compatible = "ti,cdce913", .data = &clk_cdce913_info },
832+
{ .compatible = "ti,cdce925", .data = &clk_cdce925_info },
833+
{ .compatible = "ti,cdce937", .data = &clk_cdce937_info },
834+
{ .compatible = "ti,cdce949", .data = &clk_cdce949_info },
835+
{ }
831836
};
832837
MODULE_DEVICE_TABLE(of, clk_cdce925_of_match);
833838

0 commit comments

Comments
 (0)