Commit da751726 authored by Alexander Stein's avatar Alexander Stein Committed by Stephen Boyd

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: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: default avatarMarek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20230310075535.3476580-1-alexander.stein@ew.tq-group.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent e7241670
...@@ -45,6 +45,13 @@ ...@@ -45,6 +45,13 @@
#define RS9_REG_DID 0x6 #define RS9_REG_DID 0x6
#define RS9_REG_BCP 0x7 #define RS9_REG_BCP 0x7
#define RS9_REG_VID_IDT 0x01
#define RS9_REG_DID_TYPE_FGV (0x0 << RS9_REG_DID_TYPE_SHIFT)
#define RS9_REG_DID_TYPE_DBV (0x1 << RS9_REG_DID_TYPE_SHIFT)
#define RS9_REG_DID_TYPE_DMV (0x2 << RS9_REG_DID_TYPE_SHIFT)
#define RS9_REG_DID_TYPE_SHIFT 0x6
/* Supported Renesas 9-series models. */ /* Supported Renesas 9-series models. */
enum rs9_model { enum rs9_model {
RENESAS_9FGV0241, RENESAS_9FGV0241,
...@@ -54,6 +61,7 @@ enum rs9_model { ...@@ -54,6 +61,7 @@ enum rs9_model {
struct rs9_chip_info { struct rs9_chip_info {
const enum rs9_model model; const enum rs9_model model;
unsigned int num_clks; unsigned int num_clks;
u8 did;
}; };
struct rs9_driver_data { struct rs9_driver_data {
...@@ -269,6 +277,7 @@ static int rs9_probe(struct i2c_client *client) ...@@ -269,6 +277,7 @@ static int rs9_probe(struct i2c_client *client)
{ {
unsigned char name[5] = "DIF0"; unsigned char name[5] = "DIF0";
struct rs9_driver_data *rs9; struct rs9_driver_data *rs9;
unsigned int vid, did;
struct clk_hw *hw; struct clk_hw *hw;
int i, ret; int i, ret;
...@@ -305,6 +314,20 @@ static int rs9_probe(struct i2c_client *client) ...@@ -305,6 +314,20 @@ static int rs9_probe(struct i2c_client *client)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = regmap_read(rs9->regmap, RS9_REG_VID, &vid);
if (ret < 0)
return ret;
ret = regmap_read(rs9->regmap, RS9_REG_DID, &did);
if (ret < 0)
return ret;
if (vid != RS9_REG_VID_IDT || did != rs9->chip_info->did)
return dev_err_probe(&client->dev, -ENODEV,
"Incorrect VID/DID: %#02x, %#02x. Expected %#02x, %#02x\n",
vid, did, RS9_REG_VID_IDT,
rs9->chip_info->did);
/* Register clock */ /* Register clock */
for (i = 0; i < rs9->chip_info->num_clks; i++) { for (i = 0; i < rs9->chip_info->num_clks; i++) {
snprintf(name, 5, "DIF%d", i); snprintf(name, 5, "DIF%d", i);
...@@ -348,6 +371,7 @@ static int __maybe_unused rs9_resume(struct device *dev) ...@@ -348,6 +371,7 @@ static int __maybe_unused rs9_resume(struct device *dev)
static const struct rs9_chip_info renesas_9fgv0241_info = { static const struct rs9_chip_info renesas_9fgv0241_info = {
.model = RENESAS_9FGV0241, .model = RENESAS_9FGV0241,
.num_clks = 2, .num_clks = 2,
.did = RS9_REG_DID_TYPE_FGV | 0x02,
}; };
static const struct i2c_device_id rs9_id[] = { static const struct i2c_device_id rs9_id[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment