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

Masahiro Yamada yamada.m at jp.panasonic.com
Fri Oct 3 15:04:23 CEST 2014


Simon,



I am totally being confused.



As far as I looked at the dm code,
the private data is calloc'ed in device_probe() function

	if (drv->priv_auto_alloc_size) {
		dev->priv = calloc(1, drv->priv_auto_alloc_size);
		if (!dev->priv) {
			ret = -ENOMEM;
			goto fail;
		}
	}



So,  dev->priv is storing the address of the allocated memory.

Am I understanding correctly?



If so, I can't understand the following code:


static int ns16550_serial_getc(struct udevice *dev)
{
	struct NS16550 *const com_port = dev_get_priv(dev);

	if (!serial_in(&com_port->lsr) & UART_LSR_DR)
		return -EAGAIN;



"com_port" is dev->priv, so it is pointing to the allocated area on RAM,
I guess.


It looks like
serial_in(&com_port->lsr)  is trying to read from the hardware register ?

Or reading from malloc area RAM ??





Best Regards
Masahiro Yamada



More information about the U-Boot mailing list