From: Marek Vasut <marex@denx.de>
To: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: linux-clk@vger.kernel.org,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Subject: Re: [PATCH] clk: rs9: Fix I2C accessors
Date: Sat, 24 Sep 2022 18:46:42 +0200 [thread overview]
Message-ID: <841e78ae-3ca0-af8f-d5ae-af4ec5d682e8@denx.de> (raw)
In-Reply-To: <12053354.O9o76ZdvQC@steina-w>
On 9/12/22 08:46, Alexander Stein wrote:
Hi,
[...]
>> +static int rs9_regmap_i2c_read(void *context,
>> + unsigned int reg, unsigned int *val)
>> +{
>> + struct i2c_client *i2c = context;
>> + struct i2c_msg xfer[2];
>> + u8 data[2];
>> + int ret;
>> +
>> + xfer[0].addr = i2c->addr;
>> + xfer[0].flags = 0;
>> + xfer[0].len = 1;
>> + xfer[0].buf = (void *)®
>
> This does work only for little-endian machines, right?
Ah, right, fixed in V2.
>> + xfer[1].addr = i2c->addr;
>> + xfer[1].flags = I2C_M_RD | I2C_M_RECV_LEN;
>> + xfer[1].len = 1;
>> + xfer[1].buf = (void *)data;
>> +
>> + ret = i2c_transfer(i2c->adapter, xfer, 2);
>> + if (ret == 2)
>> + return 0;
>
> You are missing setting 'val' here.
Fixed in V2
>> + else if (ret < 0)
>> + return ret;
>> + else
>> + return -EIO;
>> +}
>> +
>> static const struct regmap_config rs9_regmap_config = {
>> .reg_bits = 8,
>> .val_bits = 8,
>> @@ -97,6 +140,8 @@ static const struct regmap_config rs9_regmap_config = {
>> .max_register = 0x8,
>> .rd_table = &rs9_readable_table,
>> .wr_table = &rs9_writeable_table,
>> + .reg_write = rs9_regmap_i2c_write,
>> + .reg_read = rs9_regmap_i2c_read,
>> };
>>
>> static int rs9_get_output_config(struct rs9_driver_data *rs9, int idx)
>> @@ -242,11 +287,17 @@ static int rs9_probe(struct i2c_client *client)
>> return ret;
>> }
>>
>> - rs9->regmap = devm_regmap_init_i2c(client, &rs9_regmap_config);
>> + rs9->regmap = devm_regmap_init(&client->dev, NULL,
>> + client,
> &rs9_regmap_config);
>> if (IS_ERR(rs9->regmap))
>> return dev_err_probe(&client->dev, PTR_ERR(rs9->regmap),
>> "Failed to allocate register
> map\n");
>>
>> + /* Always read back 1 Byte via I2C */
>> + ret = regmap_write(rs9->regmap, RS9_REG_BCP, 1);
>> + if (ret < 0)
>> + return ret;
>> +
>> /* Register clock */
>> for (i = 0; i < rs9->chip_info->num_clks; i++) {
>> snprintf(name, 5, "DIF%d", i);
>
>
> For some reason this doesn't work with cache being enabled. No idea why this
> happens though.
What does this part mean , what does not work with which cache being
enabled ?
prev parent reply other threads:[~2022-09-24 16:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-10 23:20 [PATCH] clk: rs9: Fix I2C accessors Marek Vasut
2022-09-12 6:46 ` Alexander Stein
2022-09-24 16:46 ` Marek Vasut [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=841e78ae-3ca0-af8f-d5ae-af4ec5d682e8@denx.de \
--to=marex@denx.de \
--cc=alexander.stein@ew.tq-group.com \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox