diff options
author | Stephen Boyd <sboyd@kernel.org> | 2023-10-30 14:12:53 -0700 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2023-10-30 14:12:53 -0700 |
commit | 0a6d7f8275f255eda823c0f0b61d024f6f5b483d (patch) | |
tree | 522e0998b8f42fe935d00de153962c6de8152aab /drivers/clk/clk-si544.c | |
parent | 720e4a4a68670dfda638da236d374fc7a4be0a28 (diff) | |
parent | 7e52b1164a474dc7b90f68fbb40e35ccd7f7e2e2 (diff) |
Merge branch 'clk-cleanup' into clk-next
* clk-cleanup:
clk: si521xx: Increase stack based print buffer size in probe
clk: Use device_get_match_data()
clk: cdce925: Extend match support for OF tables
clk: si570: Simplify probe
clk: si5351: Simplify probe
clk: rs9: Use i2c_get_match_data() instead of device_get_match_data()
clk: clk-si544: Simplify probe() and is_valid_frequency()
clk: si521xx: Use i2c_get_match_data() instead of device_get_match_data()
clk: npcm7xx: Fix incorrect kfree
clk: at91: remove unnecessary conditions
clk: ti: fix double free in of_ti_divider_clk_setup()
clk: keystone: pll: fix a couple NULL vs IS_ERR() checks
clk: ralink: mtmips: quiet unused variable warning
clk: gate: fix comment typo and grammar
clk: asm9620: Remove 'hw' local variable that isn't checked
Diffstat (limited to 'drivers/clk/clk-si544.c')
-rw-r--r-- | drivers/clk/clk-si544.c | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/drivers/clk/clk-si544.c b/drivers/clk/clk-si544.c index c4288cf83f9f..c88650558f32 100644 --- a/drivers/clk/clk-si544.c +++ b/drivers/clk/clk-si544.c @@ -56,17 +56,11 @@ #define DELTA_M_FRAC_NUM 19 #define DELTA_M_FRAC_DEN 20000 -enum si544_speed_grade { - si544a, - si544b, - si544c, -}; - struct clk_si544 { struct clk_hw hw; struct regmap *regmap; struct i2c_client *i2c_client; - enum si544_speed_grade speed_grade; + unsigned long max_freq; }; #define to_clk_si544(_hw) container_of(_hw, struct clk_si544, hw) @@ -196,24 +190,10 @@ static int si544_set_muldiv(struct clk_si544 *data, static bool is_valid_frequency(const struct clk_si544 *data, unsigned long frequency) { - unsigned long max_freq = 0; - if (frequency < SI544_MIN_FREQ) return false; - switch (data->speed_grade) { - case si544a: - max_freq = 1500000000; - break; - case si544b: - max_freq = 800000000; - break; - case si544c: - max_freq = 350000000; - break; - } - - return frequency <= max_freq; + return frequency <= data->max_freq; } /* Calculate divider settings for a given frequency */ @@ -451,19 +431,10 @@ static const struct regmap_config si544_regmap_config = { .volatile_reg = si544_regmap_is_volatile, }; -static const struct i2c_device_id si544_id[] = { - { "si544a", si544a }, - { "si544b", si544b }, - { "si544c", si544c }, - { } -}; -MODULE_DEVICE_TABLE(i2c, si544_id); - static int si544_probe(struct i2c_client *client) { struct clk_si544 *data; struct clk_init_data init; - const struct i2c_device_id *id = i2c_match_id(si544_id, client); int err; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); @@ -475,7 +446,7 @@ static int si544_probe(struct i2c_client *client) init.num_parents = 0; data->hw.init = &init; data->i2c_client = client; - data->speed_grade = id->driver_data; + data->max_freq = (uintptr_t)i2c_get_match_data(client); if (of_property_read_string(client->dev.of_node, "clock-output-names", &init.name)) @@ -507,11 +478,19 @@ static int si544_probe(struct i2c_client *client) return 0; } +static const struct i2c_device_id si544_id[] = { + { "si544a", 1500000000 }, + { "si544b", 800000000 }, + { "si544c", 350000000 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, si544_id); + static const struct of_device_id clk_si544_of_match[] = { - { .compatible = "silabs,si544a" }, - { .compatible = "silabs,si544b" }, - { .compatible = "silabs,si544c" }, - { }, + { .compatible = "silabs,si544a", .data = (void *)1500000000 }, + { .compatible = "silabs,si544b", .data = (void *)800000000 }, + { .compatible = "silabs,si544c", .data = (void *)350000000 }, + { } }; MODULE_DEVICE_TABLE(of, clk_si544_of_match); |