All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Avi.Fishman@nuvoton.com" <Avi.Fishman@nuvoton.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Havard Skinnemoen" <hskinnemoen@google.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>
Cc: "qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"KFTING@nuvoton.com" <KFTING@nuvoton.com>,
	Alexander Bulekov <alxndr@bu.edu>,
	Shengtan Mao <stmao@google.com>, Hao Wu <wuhaotsh@google.com>,
	Chris Rauer <crauer@google.com>,
	"KFTING@nuvoton.com" <KFTING@nuvoton.com>
Subject: RE: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Date: Sun, 5 Mar 2023 07:41:01 +0000	[thread overview]
Message-ID: <TYZPR03MB5678AF48AA1C86E4C96521A7E4B19@TYZPR03MB5678.apcprd03.prod.outlook.com> (raw)
In-Reply-To: <6ccd925d-b965-4da0-13f2-365bd75abe88@linaro.org>

Hi,

Inside


> -----Original Message-----
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Sent: Thursday, December 22, 2022 5:03 PM
> To: Havard Skinnemoen <hskinnemoen@google.com>; peter.maydell@linaro.org
> Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org; IS20 Avi Fishman
> <Avi.Fishman@nuvoton.com>; CS20 KFTing <KFTING@nuvoton.com>; Alexander
> Bulekov <alxndr@bu.edu>; Shengtan Mao <stmao@google.com>; Hao Wu
> <wuhaotsh@google.com>; Chris Rauer <crauer@google.com>; CS20 KFTing
> <KFTING@nuvoton.com>
> Subject: Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
>
> Hi,
>
> (old patch)
>
> On 11/9/20 07:20, Havard Skinnemoen wrote:
> > This supports reading and writing OTP fuses and keys. Only fuse reading
> > has been tested. Protection is not implemented.
> >
> > Reviewed-by: Avi Fishman <avi.fishman@nuvoton.com>
> > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > Tested-by: Alexander Bulekov <alxndr@bu.edu>
> > Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
> > ---
> >   include/hw/arm/npcm7xx.h       |   3 +
> >   include/hw/nvram/npcm7xx_otp.h |  79 ++++++
> >   hw/arm/npcm7xx.c               |  29 +++
> >   hw/nvram/npcm7xx_otp.c         | 440 +++++++++++++++++++++++++++++++++
> >   hw/nvram/meson.build           |   1 +
> >   5 files changed, 552 insertions(+)
> >   create mode 100644 include/hw/nvram/npcm7xx_otp.h
> >   create mode 100644 hw/nvram/npcm7xx_otp.c
>
> > +/**
> > + * npcm7xx_otp_array_write - ECC encode and write data to OTP array.
> > + * @s: OTP module.
> > + * @data: Data to be encoded and written.
> > + * @offset: Offset of first byte to be written in the OTP array.
> > + * @len: Number of bytes before ECC encoding.
> > + *
> > + * Each nibble of data is encoded into a byte, so the number of bytes written
> > + * to the array will be @len * 2.
> > + */
> > +extern void npcm7xx_otp_array_write(NPCM7xxOTPState *s, const void
> *data,
> > +                                    unsigned int offset, unsigned int len);
>
> > +static void npcm7xx_init_fuses(NPCM7xxState *s)
> > +{
> > +    NPCM7xxClass *nc = NPCM7XX_GET_CLASS(s);
> > +    uint32_t value;
> > +
> > +    /*
> > +     * The initial mask of disabled modules indicates the chip derivative (e.g.
> > +     * NPCM750 or NPCM730).
> > +     */
> > +    value = tswap32(nc->disabled_modules);
>
> In which endianness do you want this 32-bit fuse value to be written?

It should be little endian, I am not sure why there is a swap here.
Unless the nc->disabled_modules for some reason is coming swapped so we swap it back.

>
> I suppose you used a little-endian host, so we want it big-endian in
> the OTP? In that case it would be better to use cpu_to_be32(), to
> be able to use the OTP on a big-endian host such s390x.

So according to what I said then use cpu_to_le32()

>
> > +    npcm7xx_otp_array_write(&s->fuse_array, &value,
> NPCM7XX_FUSE_DERIVATIVE,
> > +                            sizeof(value));
> > +}
>
> For completeness:
>
>  > +static void npcm730_class_init(ObjectClass *oc, void *data)
>  > +{
>  > +    NPCM7xxClass *nc = NPCM7XX_CLASS(oc);
>  > +
>  > +    /* NPCM730 is optimized for data center use, so no graphics, etc. */
>  > +    nc->disabled_modules = 0x00300395;
>  > +    nc->num_cpus = 2;
>  > +}
>  > +
>  > +static void npcm750_class_init(ObjectClass *oc, void *data)
>  > +{
>  > +    NPCM7xxClass *nc = NPCM7XX_CLASS(oc);
>  > +
>  > +    /* NPCM750 has 2 cores and a full set of peripherals */
>  > +    nc->disabled_modules = 0x00000000;
>  > +    nc->num_cpus = 2;
>  > +}
>
> Thanks,
>
> Phil.
________________________________
________________________________
 The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

  parent reply	other threads:[~2023-03-05 14:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11  5:20 [PATCH v9 00/14] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 01/14] hw/misc: Add NPCM7xx System Global Control Registers device model Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 02/14] hw/misc: Add NPCM7xx Clock Controller " Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 03/14] hw/timer: Add NPCM7xx Timer " Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 04/14] hw/arm: Add NPCM730 and NPCM750 SoC models Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 05/14] hw/arm: Add two NPCM7xx-based machines Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 06/14] roms: Add virtual Boot ROM for NPCM7xx SoCs Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 07/14] hw/arm: Load -bios image as a boot ROM for npcm7xx Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model Havard Skinnemoen via
2022-12-22 15:03   ` Philippe Mathieu-Daudé
2023-02-23 10:44     ` Philippe Mathieu-Daudé
2023-03-01  3:42       ` KFTING
2023-03-05  7:41     ` Avi.Fishman [this message]
2023-03-06 12:49       ` Philippe Mathieu-Daudé
2020-09-11  5:20 ` [PATCH v9 09/14] hw/mem: Stubbed out NPCM7xx Memory Controller model Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 10/14] hw/ssi: NPCM7xx Flash Interface Unit device model Havard Skinnemoen via
2020-09-11  5:20 ` [PATCH v9 11/14] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj Havard Skinnemoen via
2020-09-11 12:46   ` Philippe Mathieu-Daudé
2020-09-12 22:24     ` Havard Skinnemoen
2020-09-11  5:20 ` [PATCH v9 12/14] hw/arm/npcm7xx: add board setup stub for CPU and UART clocks Havard Skinnemoen via
2020-09-11  5:21 ` [PATCH v9 13/14] docs/system: Add Nuvoton machine documentation Havard Skinnemoen via
2020-09-11  5:21 ` [PATCH v9 14/14] tests/acceptance: console boot tests for quanta-gsj Havard Skinnemoen via
2020-09-11 12:48 ` [PATCH v9 00/14] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines Philippe Mathieu-Daudé
2020-09-14 12:55 ` Peter Maydell

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=TYZPR03MB5678AF48AA1C86E4C96521A7E4B19@TYZPR03MB5678.apcprd03.prod.outlook.com \
    --to=avi.fishman@nuvoton.com \
    --cc=KFTING@nuvoton.com \
    --cc=alxndr@bu.edu \
    --cc=crauer@google.com \
    --cc=hskinnemoen@google.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stmao@google.com \
    --cc=wuhaotsh@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.