Skip to content

Commit cd9a5c9

Browse files
Marek Vasutbebarino
authored andcommitted
clk: rs9: Replace model check with bitshift from chip data
Adjust rs9_calc_dif() to special-case the 9FGV0241 where DIFx bits start at 1, encode this shift into chip data and drop the model check entirely. Signed-off-by: Marek Vasut <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 780da7f commit cd9a5c9

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

drivers/clk/clk-renesas-pcie.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,10 @@
5050
#define RS9_REG_DID_TYPE_DMV (0x2 << RS9_REG_DID_TYPE_SHIFT)
5151
#define RS9_REG_DID_TYPE_SHIFT 0x6
5252

53-
/* Supported Renesas 9-series models. */
54-
enum rs9_model {
55-
RENESAS_9FGV0241,
56-
RENESAS_9FGV0441,
57-
};
58-
5953
/* Structure to describe features of a particular 9-series model */
6054
struct rs9_chip_info {
61-
const enum rs9_model model;
6255
unsigned int num_clks;
56+
u8 outshift;
6357
u8 did;
6458
};
6559

@@ -161,14 +155,12 @@ static const struct regmap_config rs9_regmap_config = {
161155

162156
static u8 rs9_calc_dif(const struct rs9_driver_data *rs9, int idx)
163157
{
164-
enum rs9_model model = rs9->chip_info->model;
165-
166-
if (model == RENESAS_9FGV0241)
167-
return BIT(idx) + 1;
168-
else if (model == RENESAS_9FGV0441)
169-
return BIT(idx);
170-
171-
return 0;
158+
/*
159+
* On 9FGV0241, the DIF OE0 is BIT(1) and DIF OE(1) is BIT(2),
160+
* on 9FGV0441 and 9FGV0841 the DIF OE0 is BIT(0) and so on.
161+
* Increment the index in the 9FGV0241 special case here.
162+
*/
163+
return BIT(idx + rs9->chip_info->outshift);
172164
}
173165

174166
static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx)
@@ -382,14 +374,14 @@ static int __maybe_unused rs9_resume(struct device *dev)
382374
}
383375

384376
static const struct rs9_chip_info renesas_9fgv0241_info = {
385-
.model = RENESAS_9FGV0241,
386377
.num_clks = 2,
378+
.outshift = 1,
387379
.did = RS9_REG_DID_TYPE_FGV | 0x02,
388380
};
389381

390382
static const struct rs9_chip_info renesas_9fgv0441_info = {
391-
.model = RENESAS_9FGV0441,
392383
.num_clks = 4,
384+
.outshift = 0,
393385
.did = RS9_REG_DID_TYPE_FGV | 0x04,
394386
};
395387

0 commit comments

Comments
 (0)