From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Avi.Fishman@nuvoton.com" <Avi.Fishman@nuvoton.com>,
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>
Subject: Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Date: Mon, 6 Mar 2023 13:49:50 +0100 [thread overview]
Message-ID: <016f86ca-a703-748c-d44f-7d419a7e9f29@linaro.org> (raw)
In-Reply-To: <TYZPR03MB5678AF48AA1C86E4C96521A7E4B19@TYZPR03MB5678.apcprd03.prod.outlook.com>
On 5/3/23 08:41, Avi.Fishman@nuvoton.com wrote:
> 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()
Thank you Avi!
next prev parent reply other threads:[~2023-03-06 12:50 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
2023-03-06 12:49 ` Philippe Mathieu-Daudé [this message]
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=016f86ca-a703-748c-d44f-7d419a7e9f29@linaro.org \
--to=philmd@linaro.org \
--cc=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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).