Skip to content

Commit da75172

Browse files
tq-steinabebarino
authored andcommitted
clk: rs9: Check for vendor/device ID
This is in preparation to support additional devices which have different IDs as well as a slightly different register layout. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Reviewed-by: Marek Vasut <marex@denx.de> Link: https://lore.kernel.org/r/20230310075535.3476580-1-alexander.stein@ew.tq-group.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent e724167 commit da75172

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/clk/clk-renesas-pcie.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
#define RS9_REG_DID 0x6
4646
#define RS9_REG_BCP 0x7
4747

48+
#define RS9_REG_VID_IDT 0x01
49+
50+
#define RS9_REG_DID_TYPE_FGV (0x0 << RS9_REG_DID_TYPE_SHIFT)
51+
#define RS9_REG_DID_TYPE_DBV (0x1 << RS9_REG_DID_TYPE_SHIFT)
52+
#define RS9_REG_DID_TYPE_DMV (0x2 << RS9_REG_DID_TYPE_SHIFT)
53+
#define RS9_REG_DID_TYPE_SHIFT 0x6
54+
4855
/* Supported Renesas 9-series models. */
4956
enum rs9_model {
5057
RENESAS_9FGV0241,
@@ -54,6 +61,7 @@ enum rs9_model {
5461
struct rs9_chip_info {
5562
const enum rs9_model model;
5663
unsigned int num_clks;
64+
u8 did;
5765
};
5866

5967
struct rs9_driver_data {
@@ -269,6 +277,7 @@ static int rs9_probe(struct i2c_client *client)
269277
{
270278
unsigned char name[5] = "DIF0";
271279
struct rs9_driver_data *rs9;
280+
unsigned int vid, did;
272281
struct clk_hw *hw;
273282
int i, ret;
274283

@@ -305,6 +314,20 @@ static int rs9_probe(struct i2c_client *client)
305314
if (ret < 0)
306315
return ret;
307316

317+
ret = regmap_read(rs9->regmap, RS9_REG_VID, &vid);
318+
if (ret < 0)
319+
return ret;
320+
321+
ret = regmap_read(rs9->regmap, RS9_REG_DID, &did);
322+
if (ret < 0)
323+
return ret;
324+
325+
if (vid != RS9_REG_VID_IDT || did != rs9->chip_info->did)
326+
return dev_err_probe(&client->dev, -ENODEV,
327+
"Incorrect VID/DID: %#02x, %#02x. Expected %#02x, %#02x\n",
328+
vid, did, RS9_REG_VID_IDT,
329+
rs9->chip_info->did);
330+
308331
/* Register clock */
309332
for (i = 0; i < rs9->chip_info->num_clks; i++) {
310333
snprintf(name, 5, "DIF%d", i);
@@ -348,6 +371,7 @@ static int __maybe_unused rs9_resume(struct device *dev)
348371
static const struct rs9_chip_info renesas_9fgv0241_info = {
349372
.model = RENESAS_9FGV0241,
350373
.num_clks = 2,
374+
.did = RS9_REG_DID_TYPE_FGV | 0x02,
351375
};
352376

353377
static const struct i2c_device_id rs9_id[] = {

0 commit comments

Comments
 (0)