Skip to content

dm_eeprom: look up chosen bootcount device in the device tree#16

Merged
thom-nic merged 3 commits intomasterfrom
tmn-dm-eeprom-support
Nov 2, 2025
Merged

dm_eeprom: look up chosen bootcount device in the device tree#16
thom-nic merged 3 commits intomasterfrom
tmn-dm-eeprom-support

Conversation

@thom-nic
Copy link
Copy Markdown
Contributor

@thom-nic thom-nic commented Oct 7, 2025

instead of using compile-time constants for bus/address/offset

Example device tree definition:

	chosen {
		// see: u-boot/drivers/bootcount/bootcount-uclass.c
		u-boot,bootcount-device = <&bootcount_i2c_eeprom>;
	};
	bootcount_i2c_eeprom: bc_i2c_eeprom {
		// see: u-boot/drivers/bootcount/bootcount_dm_i2c.c
		compatible = "u-boot,bootcount-i2c";
		i2cbcdev = <&eeprom0>;
		offset = <0x30>;
	};

@thom-nic thom-nic self-assigned this Oct 7, 2025
@thom-nic thom-nic added the enhancement New feature or request label Oct 7, 2025
@thom-nic thom-nic force-pushed the tmn-dm-eeprom-support branch 2 times, most recently from c3b9b14 to 85d12ea Compare October 8, 2025 12:11
@thom-nic thom-nic marked this pull request as ready for review October 8, 2025 12:12
@thom-nic
Copy link
Copy Markdown
Contributor Author

thom-nic commented Oct 8, 2025

Example debut output:

DEBUG: Read from /proc/device-tree/compatible: phytec,am625-phyboard-voltserver
DEBUG: Read from /proc/device-tree/compatible: phytec,am62-phycore-som
DEBUG: Read from /proc/device-tree/compatible: ti,am625
DEBUG: Discovering DM I2C EEPROM bootcount device...
DEBUG:  Found bootcount-device phandle 2
DEBUG:  Found bootcount node /sys/firmware/devicetree/base/bc_i2c_eeprom
DEBUG:  Using offset 0x30
DEBUG:  Found i2cbcdev phandle 90
DEBUG:  Found eeprom node /sys/firmware/devicetree/base/bus@f0000/i2c@20000000/eeprom@50
DEBUG:  EEPROM I2C address 0x50
DEBUG:  Checking device 0-0050 ...
DEBUG:  Matched EEPROM device 0-0050 (bus 0 addr 0x50)
Detected DM I2C EEPROM
DEBUG: Action=detect

@thom-nic thom-nic force-pushed the tmn-dm-eeprom-support branch 10 times, most recently from b575384 to f3ef673 Compare October 9, 2025 21:56
@thom-nic
Copy link
Copy Markdown
Contributor Author

thom-nic commented Oct 14, 2025

@passgat I can't request you as a reviewer but I wonder if you'd be interested in looking at this. I am considering whether this implementation is sufficient or should I use libfdt instead.

Edit: upon further reflection I would rather not depend on libfdt unless it can be statically linked, in order to make it easy to include in initramfs. Given that the sysfs method that I'm using now seems to be reliable without any external dependency, I am apt to keep it as-is.

@thom-nic thom-nic force-pushed the tmn-dm-eeprom-support branch 5 times, most recently from 086e6ee to f84decf Compare October 17, 2025 04:01
@thom-nic thom-nic force-pushed the tmn-dm-eeprom-support branch 2 times, most recently from cb9ecb7 to 256efb2 Compare October 24, 2025 14:05
@thom-nic thom-nic force-pushed the tmn-dm-eeprom-support branch from 256efb2 to ce0ebaf Compare October 31, 2025 14:58
@thom-nic thom-nic merged commit 009b70a into master Nov 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant