diff options
author | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2014-01-25 15:48:31 -0500 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-01-27 14:20:22 -0500 |
commit | 9d43dc7f403dbe5da25c7eb488a5975b08d95496 (patch) | |
tree | ed6f88dedda06a1a6d25ebbf5c75eea0e0a6e692 /drivers/clk | |
parent | 8e31d19b93377e2e6ad67bc2e898186327cb0308 (diff) |
clk: si5351: remove variant from platform_data
Commit 9807362bfe1748d9bb48eecb9261f1b1aaafea1c
"clk: si5351: declare all device IDs for module loading"
removed the common i2c_device_id and introduced new ones for each variant
of the clock generator. Instead of exploiting that information in the driver,
it still depends on platform_data passing the chips .variant.
This removes the now redundant .variant from the platform_data and puts it in
i2c_device_id's .driver_data instead.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk-si5351.c | 28 | ||||
-rw-r--r-- | drivers/clk/clk-si5351.h | 14 |
2 files changed, 26 insertions, 16 deletions
diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c index c50e83744b0a..b95aa09b7aed 100644 --- a/drivers/clk/clk-si5351.c +++ b/drivers/clk/clk-si5351.c | |||
@@ -1111,11 +1111,11 @@ static const struct of_device_id si5351_dt_ids[] = { | |||
1111 | }; | 1111 | }; |
1112 | MODULE_DEVICE_TABLE(of, si5351_dt_ids); | 1112 | MODULE_DEVICE_TABLE(of, si5351_dt_ids); |
1113 | 1113 | ||
1114 | static int si5351_dt_parse(struct i2c_client *client) | 1114 | static int si5351_dt_parse(struct i2c_client *client, |
1115 | enum si5351_variant variant) | ||
1115 | { | 1116 | { |
1116 | struct device_node *child, *np = client->dev.of_node; | 1117 | struct device_node *child, *np = client->dev.of_node; |
1117 | struct si5351_platform_data *pdata; | 1118 | struct si5351_platform_data *pdata; |
1118 | const struct of_device_id *match; | ||
1119 | struct property *prop; | 1119 | struct property *prop; |
1120 | const __be32 *p; | 1120 | const __be32 *p; |
1121 | int num = 0; | 1121 | int num = 0; |
@@ -1124,15 +1124,10 @@ static int si5351_dt_parse(struct i2c_client *client) | |||
1124 | if (np == NULL) | 1124 | if (np == NULL) |
1125 | return 0; | 1125 | return 0; |
1126 | 1126 | ||
1127 | match = of_match_node(si5351_dt_ids, np); | ||
1128 | if (match == NULL) | ||
1129 | return -EINVAL; | ||
1130 | |||
1131 | pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); | 1127 | pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); |
1132 | if (!pdata) | 1128 | if (!pdata) |
1133 | return -ENOMEM; | 1129 | return -ENOMEM; |
1134 | 1130 | ||
1135 | pdata->variant = (enum si5351_variant)match->data; | ||
1136 | pdata->clk_xtal = of_clk_get(np, 0); | 1131 | pdata->clk_xtal = of_clk_get(np, 0); |
1137 | if (!IS_ERR(pdata->clk_xtal)) | 1132 | if (!IS_ERR(pdata->clk_xtal)) |
1138 | clk_put(pdata->clk_xtal); | 1133 | clk_put(pdata->clk_xtal); |
@@ -1163,7 +1158,7 @@ static int si5351_dt_parse(struct i2c_client *client) | |||
1163 | pdata->pll_src[num] = SI5351_PLL_SRC_XTAL; | 1158 | pdata->pll_src[num] = SI5351_PLL_SRC_XTAL; |
1164 | break; | 1159 | break; |
1165 | case 1: | 1160 | case 1: |
1166 | if (pdata->variant != SI5351_VARIANT_C) { | 1161 | if (variant != SI5351_VARIANT_C) { |
1167 | dev_err(&client->dev, | 1162 | dev_err(&client->dev, |
1168 | "invalid parent %d for pll %d\n", | 1163 | "invalid parent %d for pll %d\n", |
1169 | val, num); | 1164 | val, num); |
@@ -1187,7 +1182,7 @@ static int si5351_dt_parse(struct i2c_client *client) | |||
1187 | } | 1182 | } |
1188 | 1183 | ||
1189 | if (num >= 8 || | 1184 | if (num >= 8 || |
1190 | (pdata->variant == SI5351_VARIANT_A3 && num >= 3)) { | 1185 | (variant == SI5351_VARIANT_A3 && num >= 3)) { |
1191 | dev_err(&client->dev, "invalid clkout %d\n", num); | 1186 | dev_err(&client->dev, "invalid clkout %d\n", num); |
1192 | return -EINVAL; | 1187 | return -EINVAL; |
1193 | } | 1188 | } |
@@ -1226,7 +1221,7 @@ static int si5351_dt_parse(struct i2c_client *client) | |||
1226 | SI5351_CLKOUT_SRC_XTAL; | 1221 | SI5351_CLKOUT_SRC_XTAL; |
1227 | break; | 1222 | break; |
1228 | case 3: | 1223 | case 3: |
1229 | if (pdata->variant != SI5351_VARIANT_C) { | 1224 | if (variant != SI5351_VARIANT_C) { |
1230 | dev_err(&client->dev, | 1225 | dev_err(&client->dev, |
1231 | "invalid parent %d for clkout %d\n", | 1226 | "invalid parent %d for clkout %d\n", |
1232 | val, num); | 1227 | val, num); |
@@ -1307,6 +1302,7 @@ static int si5351_dt_parse(struct i2c_client *client) | |||
1307 | static int si5351_i2c_probe(struct i2c_client *client, | 1302 | static int si5351_i2c_probe(struct i2c_client *client, |
1308 | const struct i2c_device_id *id) | 1303 | const struct i2c_device_id *id) |
1309 | { | 1304 | { |
1305 | enum si5351_variant variant = (enum si5351_variant)id->driver_data; | ||
1310 | struct si5351_platform_data *pdata; | 1306 | struct si5351_platform_data *pdata; |
1311 | struct si5351_driver_data *drvdata; | 1307 | struct si5351_driver_data *drvdata; |
1312 | struct clk_init_data init; | 1308 | struct clk_init_data init; |
@@ -1315,7 +1311,7 @@ static int si5351_i2c_probe(struct i2c_client *client, | |||
1315 | u8 num_parents, num_clocks; | 1311 | u8 num_parents, num_clocks; |
1316 | int ret, n; | 1312 | int ret, n; |
1317 | 1313 | ||
1318 | ret = si5351_dt_parse(client); | 1314 | ret = si5351_dt_parse(client, variant); |
1319 | if (ret) | 1315 | if (ret) |
1320 | return ret; | 1316 | return ret; |
1321 | 1317 | ||
@@ -1331,7 +1327,7 @@ static int si5351_i2c_probe(struct i2c_client *client, | |||
1331 | 1327 | ||
1332 | i2c_set_clientdata(client, drvdata); | 1328 | i2c_set_clientdata(client, drvdata); |
1333 | drvdata->client = client; | 1329 | drvdata->client = client; |
1334 | drvdata->variant = pdata->variant; | 1330 | drvdata->variant = variant; |
1335 | drvdata->pxtal = pdata->clk_xtal; | 1331 | drvdata->pxtal = pdata->clk_xtal; |
1336 | drvdata->pclkin = pdata->clk_clkin; | 1332 | drvdata->pclkin = pdata->clk_clkin; |
1337 | 1333 | ||
@@ -1568,10 +1564,10 @@ static int si5351_i2c_probe(struct i2c_client *client, | |||
1568 | } | 1564 | } |
1569 | 1565 | ||
1570 | static const struct i2c_device_id si5351_i2c_ids[] = { | 1566 | static const struct i2c_device_id si5351_i2c_ids[] = { |
1571 | { "si5351a", 0 }, | 1567 | { "si5351a", SI5351_VARIANT_A }, |
1572 | { "si5351a-msop", 0 }, | 1568 | { "si5351a-msop", SI5351_VARIANT_A3 }, |
1573 | { "si5351b", 0 }, | 1569 | { "si5351b", SI5351_VARIANT_B }, |
1574 | { "si5351c", 0 }, | 1570 | { "si5351c", SI5351_VARIANT_C }, |
1575 | { } | 1571 | { } |
1576 | }; | 1572 | }; |
1577 | MODULE_DEVICE_TABLE(i2c, si5351_i2c_ids); | 1573 | MODULE_DEVICE_TABLE(i2c, si5351_i2c_ids); |
diff --git a/drivers/clk/clk-si5351.h b/drivers/clk/clk-si5351.h index c0dbf2676872..4d0746b50c32 100644 --- a/drivers/clk/clk-si5351.h +++ b/drivers/clk/clk-si5351.h | |||
@@ -153,4 +153,18 @@ | |||
153 | #define SI5351_XTAL_ENABLE (1<<6) | 153 | #define SI5351_XTAL_ENABLE (1<<6) |
154 | #define SI5351_MULTISYNTH_ENABLE (1<<4) | 154 | #define SI5351_MULTISYNTH_ENABLE (1<<4) |
155 | 155 | ||
156 | /** | ||
157 | * enum si5351_variant - SiLabs Si5351 chip variant | ||
158 | * @SI5351_VARIANT_A: Si5351A (8 output clocks, XTAL input) | ||
159 | * @SI5351_VARIANT_A3: Si5351A MSOP10 (3 output clocks, XTAL input) | ||
160 | * @SI5351_VARIANT_B: Si5351B (8 output clocks, XTAL/VXCO input) | ||
161 | * @SI5351_VARIANT_C: Si5351C (8 output clocks, XTAL/CLKIN input) | ||
162 | */ | ||
163 | enum si5351_variant { | ||
164 | SI5351_VARIANT_A = 1, | ||
165 | SI5351_VARIANT_A3 = 2, | ||
166 | SI5351_VARIANT_B = 3, | ||
167 | SI5351_VARIANT_C = 4, | ||
168 | }; | ||
169 | |||
156 | #endif | 170 | #endif |