|
7 | 7 | * Currently supported: |
8 | 8 | * - 9FGV0241 |
9 | 9 | * - 9FGV0441 |
| 10 | + * - 9FGV0841 |
10 | 11 | * |
11 | 12 | * Copyright (C) 2022 Marek Vasut <marex@denx.de> |
12 | 13 | */ |
|
42 | 43 | #define RS9_REG_DID 0x6 |
43 | 44 | #define RS9_REG_BCP 0x7 |
44 | 45 |
|
| 46 | +#define RS9_REG_VID_MASK GENMASK(3, 0) |
45 | 47 | #define RS9_REG_VID_IDT 0x01 |
46 | 48 |
|
47 | 49 | #define RS9_REG_DID_TYPE_FGV (0x0 << RS9_REG_DID_TYPE_SHIFT) |
48 | 50 | #define RS9_REG_DID_TYPE_DBV (0x1 << RS9_REG_DID_TYPE_SHIFT) |
49 | 51 | #define RS9_REG_DID_TYPE_DMV (0x2 << RS9_REG_DID_TYPE_SHIFT) |
50 | 52 | #define RS9_REG_DID_TYPE_SHIFT 0x6 |
51 | 53 |
|
52 | | -/* Supported Renesas 9-series models. */ |
53 | | -enum rs9_model { |
54 | | - RENESAS_9FGV0241, |
55 | | - RENESAS_9FGV0441, |
56 | | -}; |
57 | | - |
58 | 54 | /* Structure to describe features of a particular 9-series model */ |
59 | 55 | struct rs9_chip_info { |
60 | | - const enum rs9_model model; |
61 | 56 | unsigned int num_clks; |
| 57 | + u8 outshift; |
62 | 58 | u8 did; |
63 | 59 | }; |
64 | 60 |
|
@@ -160,14 +156,12 @@ static const struct regmap_config rs9_regmap_config = { |
160 | 156 |
|
161 | 157 | static u8 rs9_calc_dif(const struct rs9_driver_data *rs9, int idx) |
162 | 158 | { |
163 | | - enum rs9_model model = rs9->chip_info->model; |
164 | | - |
165 | | - if (model == RENESAS_9FGV0241) |
166 | | - return BIT(idx + 1); |
167 | | - else if (model == RENESAS_9FGV0441) |
168 | | - return BIT(idx); |
169 | | - |
170 | | - return 0; |
| 159 | + /* |
| 160 | + * On 9FGV0241, the DIF OE0 is BIT(1) and DIF OE(1) is BIT(2), |
| 161 | + * on 9FGV0441 and 9FGV0841 the DIF OE0 is BIT(0) and so on. |
| 162 | + * Increment the index in the 9FGV0241 special case here. |
| 163 | + */ |
| 164 | + return BIT(idx + rs9->chip_info->outshift); |
171 | 165 | } |
172 | 166 |
|
173 | 167 | static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx) |
@@ -333,6 +327,7 @@ static int rs9_probe(struct i2c_client *client) |
333 | 327 | if (ret < 0) |
334 | 328 | return ret; |
335 | 329 |
|
| 330 | + vid &= RS9_REG_VID_MASK; |
336 | 331 | if (vid != RS9_REG_VID_IDT || did != rs9->chip_info->did) |
337 | 332 | return dev_err_probe(&client->dev, -ENODEV, |
338 | 333 | "Incorrect VID/DID: %#02x, %#02x. Expected %#02x, %#02x\n", |
@@ -380,27 +375,35 @@ static int __maybe_unused rs9_resume(struct device *dev) |
380 | 375 | } |
381 | 376 |
|
382 | 377 | static const struct rs9_chip_info renesas_9fgv0241_info = { |
383 | | - .model = RENESAS_9FGV0241, |
384 | 378 | .num_clks = 2, |
| 379 | + .outshift = 1, |
385 | 380 | .did = RS9_REG_DID_TYPE_FGV | 0x02, |
386 | 381 | }; |
387 | 382 |
|
388 | 383 | static const struct rs9_chip_info renesas_9fgv0441_info = { |
389 | | - .model = RENESAS_9FGV0441, |
390 | 384 | .num_clks = 4, |
| 385 | + .outshift = 0, |
391 | 386 | .did = RS9_REG_DID_TYPE_FGV | 0x04, |
392 | 387 | }; |
393 | 388 |
|
| 389 | +static const struct rs9_chip_info renesas_9fgv0841_info = { |
| 390 | + .num_clks = 8, |
| 391 | + .outshift = 0, |
| 392 | + .did = RS9_REG_DID_TYPE_FGV | 0x08, |
| 393 | +}; |
| 394 | + |
394 | 395 | static const struct i2c_device_id rs9_id[] = { |
395 | 396 | { "9fgv0241", .driver_data = (kernel_ulong_t)&renesas_9fgv0241_info }, |
396 | 397 | { "9fgv0441", .driver_data = (kernel_ulong_t)&renesas_9fgv0441_info }, |
| 398 | + { "9fgv0841", .driver_data = (kernel_ulong_t)&renesas_9fgv0841_info }, |
397 | 399 | { } |
398 | 400 | }; |
399 | 401 | MODULE_DEVICE_TABLE(i2c, rs9_id); |
400 | 402 |
|
401 | 403 | static const struct of_device_id clk_rs9_of_match[] = { |
402 | 404 | { .compatible = "renesas,9fgv0241", .data = &renesas_9fgv0241_info }, |
403 | 405 | { .compatible = "renesas,9fgv0441", .data = &renesas_9fgv0441_info }, |
| 406 | + { .compatible = "renesas,9fgv0841", .data = &renesas_9fgv0841_info }, |
404 | 407 | { } |
405 | 408 | }; |
406 | 409 | MODULE_DEVICE_TABLE(of, clk_rs9_of_match); |
|
0 commit comments