[PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION
Marek Vasut
marek.vasut at mailbox.org
Tue Jun 20 22:03:18 CEST 2023
On 6/20/23 19:49, Detlev Casanova wrote:
> On Monday, June 19, 2023 5:54:44 P.M. EDT Marek Vasut wrote:
>> On 6/19/23 20:27, Detlev Casanova wrote:
>>> On Monday, June 19, 2023 12:11:18 P.M. EDT Marek Vasut wrote:
>>>> On 6/19/23 16:42, Detlev Casanova wrote:
>>>>> On Friday, June 16, 2023 8:43:33 P.M. EDT Marek Vasut wrote:
>>>>>> On 6/16/23 17:21, Detlev Casanova wrote:
>>>>>>> Expose that information to the command shell to let scripts select the
>>>>>>> correct devicetree name.
>>>>>>>
>>>>>>> Signed-off-by: Detlev Casanova <detlev.casanova at collabora.com>
>>>>>>> ---
>>>>>>>
>>>>>>> drivers/sysinfo/rcar3.c | 46
>>>>>>> ++++++++++++++++++++++++++++++++---------
>>>>>>> 1 file changed, 36 insertions(+), 10 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
>>>>>>> index 7b127986da7..89ad46c5422 100644
>>>>>>> --- a/drivers/sysinfo/rcar3.c
>>>>>>> +++ b/drivers/sysinfo/rcar3.c
>>>>>>> @@ -32,6 +32,8 @@
>>>>>>>
>>>>>>> */
>>>>>>>
>>>>>>> struct sysinfo_rcar_priv {
>>>>>>>
>>>>>>> char boardmodel[64];
>>>>>>>
>>>>>>> + u8 id;
>>>>>>> + char revision[4];
>>>>>>>
>>>>>>> u8 val;
>>>>>>>
>>>>>>> };
>>>>>>>
>>>>>>> @@ -48,17 +50,37 @@ static int sysinfo_rcar_get_str(struct udevice
>>>>>>> *dev,
>>>>>>> int id, size_t size, char *>
>>>>>>>
>>>>>>> switch (id) {
>>>>>>>
>>>>>>> case SYSINFO_ID_BOARD_MODEL:
>>>>>>> - strncpy(val, priv->boardmodel, size);
>>>>>>> - val[size - 1] = '\0';
>>>>>>> + strlcpy(val, priv->boardmodel, size);
>>>>>>> + break;
>>>>>>> + case SYSINFO_ID_BOARD_REVISION:
>>>>>>> + strlcpy(val, priv->revision, size);
>>>>>>> + break;
>>>>>>> + default:
>>>>>>> + return -EINVAL;
>>>>>>> + };
>>>>>>> +
>>>>>>> + val[size - 1] = '\0';
>>>>>>> + return 0;
>>>>>>> +}
>>>>>>> +
>>>>>>> +static int sysinfo_rcar_get_int(struct udevice *dev, int id, int
>>>>>>> *val)
>>>>>>> +{
>>>>>>> + struct sysinfo_rcar_priv *priv = dev_get_priv(dev);
>>>>>>> +
>>>>>>> + switch (id) {
>>>>>>> + case SYSINFO_ID_BOARD_ID:
>>>>>>> + *val = priv->id;
>>>>>>>
>>>>>>> return 0;
>>>>>>
>>>>>> Why not return SYSINFO_ID_BOARD_REVISION as integer here ?
>>>>>
>>>>> Because the revision (on r-car3 boards at least) is in the format X.Y.
>>>>> It
>>>>> could be returned as "(X << 8) | Y" or split in major/minor. But
>>>>> different
>>>>> boards will use different revisions and I think that having a str is
>>>>> easier to deal with in a shell script.
>>>>
>>>> With rcar they are numbers, so lets go with major/minor integers please.
>>>
>>> Ok for this part, but shouldn't the sysinfo command use a common interface
>>> for all boards ? Or should it also have rev_major/rev_minor arguments ?
>> I would expect other boards to either report rev_major/rev_minor if
>> implemented, or errno if those boards don't implement this property.
>
> Another thing on rcar is that the revision is stored as 2 char values. Would
> you oppose a change form using a char (e.g. rev_major = '1') to using u8
> values (e.g. rev_major = 1) instead ?
Shouldn't those rev fields just be integer(s) to cover the generic case?
More information about the U-Boot
mailing list