Skip to content
Snippets Groups Projects
Commit 45d5add4 authored by Stephan Gerhold's avatar Stephan Gerhold
Browse files

DEBUG: phy: nxp-ptn3222: Add debug register reads


This allows checking if the defined i2c bus is actually correct, since the
driver does not use the i2c register interface otherwise at the moment.

Signed-off-by: default avatarStephan Gerhold <stephan.gerhold@linaro.org>
parent 1846d742
No related merge requests found
......@@ -87,6 +87,7 @@ config PHY_NXP_PTN3222
depends on I2C
depends on OF
select GENERIC_PHY
select REGMAP_I2C
help
Enable this to support NXP PTN3222 1-port eUSB2 to USB2 Redriver.
This redriver performs translation between eUSB2 and USB2 signalling
......
......@@ -15,6 +15,7 @@
struct ptn3222 {
struct i2c_client *client;
struct regmap *regmap;
struct phy *phy;
struct gpio_desc *reset_gpio;
struct regulator_bulk_data *supplies;
......@@ -23,6 +24,8 @@ struct ptn3222 {
static int ptn3222_init(struct phy *phy)
{
struct ptn3222 *ptn3222 = phy_get_drvdata(phy);
struct device *dev = &ptn3222->client->dev;
unsigned int rev_id, chip_id0, chip_id1, chip_id2;
int ret;
ret = regulator_bulk_enable(NUM_SUPPLIES, ptn3222->supplies);
......@@ -31,6 +34,32 @@ static int ptn3222_init(struct phy *phy)
gpiod_set_value_cansleep(ptn3222->reset_gpio, 0);
msleep(20);
ret = regmap_read(ptn3222->regmap, 0x13, &rev_id);
if (ret)
dev_err(dev, "failed to read 0x13: %d\n", ret);
ret = regmap_read(ptn3222->regmap, 0x14, &chip_id0);
if (ret)
dev_err(dev, "failed to read 0x14: %d\n", ret);
ret = regmap_read(ptn3222->regmap, 0x15, &chip_id1);
if (ret)
dev_err(dev, "failed to read 0x15: %d\n", ret);
ret = regmap_read(ptn3222->regmap, 0x16, &chip_id2);
if (ret)
dev_err(dev, "failed to read 0x16: %d\n", ret);
dev_info(dev, "REVISION_ID %#x CHIP_ID %#x %#x %#x\n",
rev_id, chip_id0, chip_id1, chip_id2);
if (rev_id != 0xA2 || chip_id0 != 0x22 || chip_id1 != 0x32)
dev_err(dev, "chip id mismatch\n");
else
dev_info(dev, "chip id matches\n");
return 0;
}
......@@ -59,6 +88,12 @@ static const struct regulator_bulk_data ptn3222_supplies[NUM_SUPPLIES] = {
}
};
static const struct regmap_config ptn3222_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x16,
};
static int ptn3222_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
......@@ -72,6 +107,11 @@ static int ptn3222_probe(struct i2c_client *client)
ptn3222->client = client;
ptn3222->regmap = devm_regmap_init_i2c(client, &ptn3222_regmap_config);
if (IS_ERR(ptn3222->regmap))
return dev_err_probe(dev, PTR_ERR(ptn3222->regmap),
"unable to init regmap\n");
ptn3222->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_HIGH);
if (IS_ERR(ptn3222->reset_gpio))
......
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