[U-Boot] [PATCH] serial: ns16550: fix different reg size access

Lei Wen
2011-04-01T13:58:49Z

Hi Wolfgang,

On Fri, Apr 1, 2011 at 9:55 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Lei Wen,
>
> In message <AANLkTinqAyDx7=61FMgPdCg3ULt9nk93jF-y0Sdi=5uX@mail.gmail.com> you wrote:
>>
>> >> I think my code also could handle this. They only could set the
>> >> CONFIG_SYS_NS16550_REG_SIZE =A0to be 1
>> >> and CONFIG_SYS_NS16550_MAX_REG_SIZE to be 4. Then
>> >> the other bits is untouched by this driver.
>> >
>> > I don't think so. You still use just a single writel() call then. =A0To
>> > leave the other bits untouched, you would have to perform a readl()
>> > first, then insert one data byte, and then write it back. =A0Your patch
>> > does not do that.
>>
>> My original patch is like below, so where it call writel?...
>> +#elif (CONFIG_SYS_NS16550_REG_SIZE == 1) || (CONFIG_SYS_NS16550_REG_SIZE == -1)
>> +#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
>> +#define serial_out(x, y) ? ? ? outb(x, y)
>> +#define serial_in(y) ? ? ? ? ? inb(y)
>> +#else
>> +#define serial_out(x, y) ? ? ? writeb(x, y)
>> +#define serial_in(y) ? ? ? ? ? readb(y)
>
> If you use writeb() [as the current driver would do as well}, then how
> do you expect to set this bit 8 (which is in the next byte) to 0 as
> you claim you have to?

As I explain, if set CONFIG_SYS_NS16550_REG_SIZE to 4, and
set CONFIG_SYS_NS16550_MAX_REG_SIZE also to 4, then the serial_out
becomes writel. :)
+#if (CONFIG_SYS_NS16550_REG_SIZE == 4) || (CONFIG_SYS_NS16550_REG_SIZE == -4)
+#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
+#define serial_out(x, y) outl(x, y)
+#define serial_in(y) inl(y)
+#else
+#define serial_out(x, y) writel(x, y)
+#define serial_in(y) readl(y)
+#endif

Best regards,
Lei