[U-Boot] How does Driver Model UART work?

Masahiro Yamada yamada.m at jp.panasonic.com
Fri Oct 3 14:45:49 CEST 2014


Simon,



Now I am seeing driver/serial/serial_tegra.c

U_BOOT_DRIVER(serial_ns16550) = {
	.name	= "serial_tegra20",
	.id	= UCLASS_SERIAL,
	.of_match = tegra_serial_ids,
	.ofdata_to_platdata = tegra_serial_ofdata_to_platdata,
	.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
	.priv_auto_alloc_size = sizeof(struct NS16550),
	.probe = ns16550_serial_probe,
	.ops	= &ns16550_serial_ops,





You require sizeof(struct NS16550) (= about 30~ 40 bytes)
for .priv_auto_alloc_size.

Seems strange.


It looks like the private date is used as the base address of the
hardware

Here,

	struct NS16550 *const com_port = dev_get_priv(dev);


If the hardware register has 0x10000 width,
do we need to allocation 0x10000 memory for .priv data?


I think 4 byte (or 8 byte on 64bit architectures) is enough
to store the base address.




It looks like the memory is allocated for .priv in device_probe() function,
but I could not find where .priv is set for pointing to the base address.


Perhaps I am not understanding well yet, but
I'm still not convinced how it is working.





Best Regards
Masahiro Yamada



More information about the U-Boot mailing list