clk-si5341: Support NVM programming through sysfs
PATCH v2 1/1 clk-si5341: Support NVM programming through sysfs
Export an attribute program_nvm_bank that when read reports the current bank value. To program the chip's current state into NVM, write the magic value 0xC7 into this attribute.
This allows the clock chip to be programmed "in system" to reduce boot time by 300ms and allows the clock to be up and running before the kernel boots (e.g. for bootloader usage). Some vendors initialize PLLs only in their bootloader and thus need the clock running at boot.
---
v2: Add description in Documentation/ABI/
Use regmap_read_poll_timeout()
Abort on sysfs_create_group error
.../ABI/testing/sysfs-devices-clk-si5341 | 24 +++++++ drivers/clk/clk-si5341.c | 68 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-devices-clk-si5341
Documentation/ABI/testing/sysfs-devices-clk-si5341 new file +24 -0
@@ -0,0 +1,24 @@ +What: /sys/bus/i2c/devices/.../clk-si534*/program_nvm_bank +Date: Jan 2021 +KernelVersion: 5.12 +Contact: Mike Looijmans <[email protected]> +Description: Allows programming the NVM memory of the clock chip, so it boots + up in the current configuration. This saves boot time (300ms + clock initialization) and allows the clock to be available + before the kernel boots (e.g. u-boot ethernet clock). + + Write the magic value 0xc7 to this attribute to program the + chip's current settings into its NVM storage. This magic value + is taken from the datasheet, it's the same value that must be + written to the hardware to program it. Programming can only be + done twice in the lifetime of the chip. + + Read the value to check the state of the chip. This returns the + raw value as read from the hardware. Possible values: + 0x03: Not programmed + 0x0f: Programmed once + 0x3f: Programmed twice, can no longer be programmed + +Users: User space applications for embedded boards equipped with one + or more Si534x programmable clock devices. Would typically be + used at the end of production stages.
drivers/clk/clk-si5341.c +68 -0
92 lines not on this page · raw message
Signature · 1 line
2.17.1
Stephen Boyd
maintainerQuoting Mike Looijmans (2021-01-05 23:04:36)
Quoted 26 lines
Export an attribute
program_nvm_bankthat when read reports the current bank value. To program the chip's current state into NVM, write the magic value0xC7into this attribute.This allows the clock chip to be programmed "in system" to reduce boot time by 300ms and allows the clock to be up and running before the kernel boots (e.g. for bootloader usage). Some vendors initialize PLLs only in their bootloader and thus need the clock running at boot.
Signed-off-by Mike Looijmans <[email protected]>---
v2: Add description inDocumentation/ABI/
Useregmap_read_poll_timeout()
Abort onsysfs_create_grouperror.../ABI/testing/sysfs-devices-clk-si5341 | 24 +++++++ drivers/clk/clk-si5341.c | 68 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-devices-clk-si5341Documentation/ABI/testing/sysfs-devices-clk-si5341 new file +0
-0
Documentation/ABI/testing/sysfs-devices-clk-si5341 line 1
Quoted 1 line
Documentation/ABI/testing/sysfs-devices-clk-si5341 new file +1
-0@@ -0,0 +1,24 @@ +What: /sys/bus/i2c/devices/.../clk-si534*/program_nvm_bank
I'm still curious why this is exposed here instead of through nvmem framework. I think we talked about it before, but it would be great if the commit text could quiet any concerns about that so we have a record of why using the existing nvmem framework wasn't suitable.
Quoted 23 lines
Documentation/ABI/testing/sysfs-devices-clk-si5341 new file +23
-0+Date: Jan 2021 +KernelVersion: 5.12 +Contact: Mike Looijmans <[email protected]> +Description: Allows programming the NVM memory of the clock chip, so it boots + up in the current configuration. This saves boot time (300ms + clock initialization) and allows the clock to be available + before the kernel boots (e.g. u-boot ethernet clock). + + Write the magic value 0xc7 to this attribute to program the + chip's current settings into its NVM storage. This magic value + is taken from the datasheet, it's the same value that must be + written to the hardware to program it. Programming can only be + done twice in the lifetime of the chip. + + Read the value to check the state of the chip. This returns the + raw value as read from the hardware. Possible values: + 0x03: Not programmed + 0x0f: Programmed once + 0x3f: Programmed twice, can no longer be programmed + +Users: User space applications for embedded boards equipped with one + or more Si534x programmable clock devices. Would typically be + used at the end of production stages.