Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35456 )
Change subject: [WIP] sconfig: Allow to link devices to other device' drivers ......................................................................
Patch Set 3:
Patch Set 2:
Patch Set 2:
To solve my original problem, I have a more elaborate scheme in mind now:
The piece of code that consumes the device reference would have to be a driver that is hooked up as a `chip` in the dt. In the `chip.h` we'd declare the device reference as part of the config struct, e.g.:
struct some_chip_driver_config { DEVTREE_CONST struct device *needed_eeprom; };
How does one reference this? Driver and chip binding alone?
What about all the SoC devices? We wouldn't have one reference in that case and the code would need to know what device is correct one. I think this handles your drivers/ case well, but I'm missing the SoC part. And you mention the mainboard one below.
Now in the dt, we'd name the referenced device, but only for sconfig's internal use:
device i2c 0x50 alias my_eeprom on end
The author of the dt would be free to choose this name. Later, when configuring the driver in the dt we would associate this given name with the one in the `chip.h`:
chip some/chip/driver use my_eeprom as needed_eeprom end
No global names anymore! I hope you like that, Aaron :)
It is nice that there aren't globals, but my guess is that this may be harder to do.
Meh, https://review.coreboot.org/16080 If we have code at the mainboard level that needs a device reference (e.g. smbios_mainboard_serial_number()) how could that be handled? any ideas? revert to mb/chip.h?
I was thinking in my original questioning that the names used in the mainboards and soc would just become the norm. More so in SoC -- need the consistency. Within a mainboard the namespaces shouldn't collide so they could just use whatever they want (unless one is sharing code then the names need to be consistent). The harder one is the drivers/ situation. But, is there ever a case where the drivers/ need to know a specific alias name? I think my concern is about 'common' or 'library' code utilizing/requiring consistent naming. I'm thinking that would never work and it's the responsibility of the mainboard code to obtain and send the correct reference to the common code itself.