From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87380EB64D7 for ; Tue, 20 Jun 2023 17:49:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0235A85816; Tue, 20 Jun 2023 19:49:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="SmWRgV0w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 743C685816; Tue, 20 Jun 2023 19:49:40 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 219DB84747 for ; Tue, 20 Jun 2023 19:49:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.localnet (mtl.collabora.ca [66.171.169.34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 16A8C6606F65; Tue, 20 Jun 2023 18:49:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687283377; bh=doVob1AoxYMYs0whF0fbPRxP6UWHRNWrie8jr7fd04s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SmWRgV0wDmoOhPVBFa9S+6X29aLlBh/er03TwZ8/lOtq1ED5SiKIo0O570EgVCv9B sgyVb7L6we97C14wfAfZM3CS+4/7tIsUGhBD8+enZy1asBSTyYjAWAXGg7BqIzbNrI Cq64lczhl0yVQldn1XYxG8E2pfgheB7YMeU9Gk2wrxiXE9mvJXb87aDvcwYzkXbU4k 1EL+u6mpcaD4r3Oc9qxnltLUX4O78VghXiJLDJCYyIAhHT5Q8jZIec0m1mhz1ZPodV qJtRM3EHyi8BtnlIkZqz70dcxtVbGxEnVubn1qrGqK2u/vVGMqAtXuHwvQs48K+tX1 SZVS5SyaJJSTA== From: Detlev Casanova To: u-boot@lists.denx.de, Marek Vasut Cc: Marek Vasut , Hai Pham , Tam Nguyen Subject: Re: [PATCH v1 3/4] sysinfo: rcar3: Implement BOARD_ID and BOARD_REVISION Date: Tue, 20 Jun 2023 13:49:41 -0400 Message-ID: <12231072.O9o76ZdvQC@arisu> In-Reply-To: <905aaf1a-1e18-733d-1e93-5a228ae8c611@mailbox.org> References: <20230616152122.588168-1-detlev.casanova@collabora.com> <4842991.GXAFRqVoOG@arisu> <905aaf1a-1e18-733d-1e93-5a228ae8c611@mailbox.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 > >>>>> --- > >>>>> > >>>>> 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 ?