History log of /u-boot/include/ns16550.h
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# f69d3d6d 26-Sep-2023 Simon Glass <sjg@chromium.org>

pci: serial: Support reading PCI-register size with base

The PCI helpers read only the base address for a PCI region. In some cases
the size is needed as well, e.g. to pass along to a driver which needs to
know the size of its register area.

Update the functions to allow the size to be returned. For serial, record
the information and provided it with the serial_info() call.

A limitation still exists in that the size is not available when OF_LIVE
is enabled, so take account of that in the tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5bbf9c92 17-Jan-2023 Tom Rini <trini@konsulko.com>

dm: ns16550: Restore how we define UART_REG

Prior to commit 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to
Kconfig") we had defined CONFIG_SYS_NS16550_REG_SIZE to -1 with
DM_SERIAL such that we would then have a size 0 character array. This
resulted in functionally no padding. The confusion on my part came from
dealing with the constraints around platforms that do not use DM_SERIAL
in SPL/TPL. After Andre Przywara reported that sunxi was broken, I've
re-read the code and comments again and thought on this harder. What we
want I believe is what this patch does now.

If DM_SERIAL is defined for this stage, regardless of
CONFIG_SYS_NS16550_REG_SIZE then we will dynamically handle reg shifts
and 'struct ns16550' needs no padding (which is functionally what
unsigned char foo[0] provides). This is the same case as NS16550_DYNAMIC
and DEBUG_UART. Expand the existing comment here slightly.

Otherwise, we will have CONFIG_SYS_NS16550_REG_SIZE set to a non-zero
value, and handle padding within the struct.

Cc: Simon Glass <sjg@chromium.org>
Cc: Sergei Antonov <saproj@gmail.com>
Cc: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Fixes: 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>

# 7b84c973 05-Jan-2023 Tom Rini <trini@konsulko.com>

ns16650: Correct CONFIG_SYS_NS16550_MEM32 platforms

There are currently no platform that are both CONFIG_SYS_NS16550_MEM32
and not (per how the logic was prior to being broken in 0478dac62a9a
("kbuild: Remove uncmd_spl logic")) enabled in CONFIG_DM_SERIAL. We drop
this line out now so that platforms which do use
CONFIG_SYS_NS16550_MEM32 and depending on stage may or may not have
DM_SERIAL set.

Fixes: 0478dac62a9a ("kbuild: Remove uncmd_spl logic")
Reported-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Tested-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> #on Ringneck PX30, Puma RK3399

# 0478dac6 04-Dec-2022 Tom Rini <trini@konsulko.com>

kbuild: Remove uncmd_spl logic

At this point in the conversion there should be no need to have logic to
disable some symbol during the SPL build as all symbols should have an
SPL counterpart.

The main real changes done here are that we now must make proper use of
CONFIG_IS_ENABLED(DM_SERIAL) rather than many of the odd tricks we
developed prior to CONFIG_IS_ENABLED() being available.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 9591b635 04-Dec-2022 Tom Rini <trini@konsulko.com>

Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig

This converts the following to Kconfig:
CONFIG_SPL_NS16550_MIN_FUNCTIONS
CONFIG_SYS_NS16550_MEM32
CONFIG_SYS_NS16550_PORT_MAPPED
CONFIG_SYS_NS16550_REG_SIZE
CONFIG_SYS_NS16550_SERIAL

To do this we also introduce CONFIG_SPL_SYS_NS16550_SERIAL so that
platforms can enable the legacy driver here for SPL.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 2d6bf754 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Rename ns16550 functions to lower case

Lower case should be used for function names. Update this driver and its
callers accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# d30c7209 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Update NS16550_t and struct NS16550

Typedefs should not be used in U-Boot and structs should be lower case.
Update the code to use struct ns16550 consistently.

Put a header guard on the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# 8a8d24bd 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ..._platdata variables to just ..._plat

Try to maintain some consistency between these variables by using _plat as
a suffix for them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d1998a9f 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ofdata_to_platdata() to of_to_plat()

This name is far too long. Rename it to remove the 'data' bits. This makes
it consistent with the platdata->plat rename.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 62cbde4c 19-Dec-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Support run-time configuration

At present this driver uses an assortment of CONFIG options to control
how it accesses the hardware. This is painful for platforms that are
supposed to be controlled by a device tree or a previous-stage bootloader.

Add a new CONFIG option to enable fully dynamic configuration. This
controls register spacing, size, offset and endianness.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aiden Park <aiden.park@intel.com>
Tested-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: squashed in http://patchwork.ozlabs.org/patch/1232929/]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@amd.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@amd.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <masahiroy@kernel.org>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 Wolfgang Denk <wd@denx.de>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 Wolfgang Denk <wd@denx.de>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 Wolfgang Denk <wd@denx.de>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 Wolfgang Denk <wd@denx.de>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 Wolfgang Denk <wd@denx.de>

Initial revision

# 5bbf9c92 17-Jan-2023 Tom Rini <trini@konsulko.com>

dm: ns16550: Restore how we define UART_REG

Prior to commit 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to
Kconfig") we had defined CONFIG_SYS_NS16550_REG_SIZE to -1 with
DM_SERIAL such that we would then have a size 0 character array. This
resulted in functionally no padding. The confusion on my part came from
dealing with the constraints around platforms that do not use DM_SERIAL
in SPL/TPL. After Andre Przywara reported that sunxi was broken, I've
re-read the code and comments again and thought on this harder. What we
want I believe is what this patch does now.

If DM_SERIAL is defined for this stage, regardless of
CONFIG_SYS_NS16550_REG_SIZE then we will dynamically handle reg shifts
and 'struct ns16550' needs no padding (which is functionally what
unsigned char foo[0] provides). This is the same case as NS16550_DYNAMIC
and DEBUG_UART. Expand the existing comment here slightly.

Otherwise, we will have CONFIG_SYS_NS16550_REG_SIZE set to a non-zero
value, and handle padding within the struct.

Cc: Simon Glass <sjg@chromium.org>
Cc: Sergei Antonov <saproj@gmail.com>
Cc: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Fixes: 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig")
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Andre Przywara <andre.przywara@arm.com>
Tested-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>

# 7b84c973 05-Jan-2023 Tom Rini <trini@konsulko.com>

ns16650: Correct CONFIG_SYS_NS16550_MEM32 platforms

There are currently no platform that are both CONFIG_SYS_NS16550_MEM32
and not (per how the logic was prior to being broken in 0478dac62a9a
("kbuild: Remove uncmd_spl logic")) enabled in CONFIG_DM_SERIAL. We drop
this line out now so that platforms which do use
CONFIG_SYS_NS16550_MEM32 and depending on stage may or may not have
DM_SERIAL set.

Fixes: 0478dac62a9a ("kbuild: Remove uncmd_spl logic")
Reported-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Tested-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> #on Ringneck PX30, Puma RK3399

# 0478dac6 04-Dec-2022 Tom Rini <trini@konsulko.com>

kbuild: Remove uncmd_spl logic

At this point in the conversion there should be no need to have logic to
disable some symbol during the SPL build as all symbols should have an
SPL counterpart.

The main real changes done here are that we now must make proper use of
CONFIG_IS_ENABLED(DM_SERIAL) rather than many of the odd tricks we
developed prior to CONFIG_IS_ENABLED() being available.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 9591b635 04-Dec-2022 Tom Rini <trini@konsulko.com>

Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig

This converts the following to Kconfig:
CONFIG_SPL_NS16550_MIN_FUNCTIONS
CONFIG_SYS_NS16550_MEM32
CONFIG_SYS_NS16550_PORT_MAPPED
CONFIG_SYS_NS16550_REG_SIZE
CONFIG_SYS_NS16550_SERIAL

To do this we also introduce CONFIG_SPL_SYS_NS16550_SERIAL so that
platforms can enable the legacy driver here for SPL.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 2d6bf754 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Rename ns16550 functions to lower case

Lower case should be used for function names. Update this driver and its
callers accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# d30c7209 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Update NS16550_t and struct NS16550

Typedefs should not be used in U-Boot and structs should be lower case.
Update the code to use struct ns16550 consistently.

Put a header guard on the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# 8a8d24bd 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ..._platdata variables to just ..._plat

Try to maintain some consistency between these variables by using _plat as
a suffix for them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d1998a9f 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ofdata_to_platdata() to of_to_plat()

This name is far too long. Rename it to remove the 'data' bits. This makes
it consistent with the platdata->plat rename.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 62cbde4c 19-Dec-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Support run-time configuration

At present this driver uses an assortment of CONFIG options to control
how it accesses the hardware. This is painful for platforms that are
supposed to be controlled by a device tree or a previous-stage bootloader.

Add a new CONFIG option to enable fully dynamic configuration. This
controls register spacing, size, offset and endianness.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aiden Park <aiden.park@intel.com>
Tested-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: squashed in http://patchwork.ozlabs.org/patch/1232929/]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@amd.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@amd.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.masahiro@socionext.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 Wolfgang Denk <wd@denx.de>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 Wolfgang Denk <wd@denx.de>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 Wolfgang Denk <wd@denx.de>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 Wolfgang Denk <wd@denx.de>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 Wolfgang Denk <wd@denx.de>

Initial revision

# 7b84c973 05-Jan-2023 Tom Rini <trini@konsulko.com>

ns16650: Correct CONFIG_SYS_NS16550_MEM32 platforms

There are currently no platform that are both CONFIG_SYS_NS16550_MEM32
and not (per how the logic was prior to being broken in 0478dac62a9a
("kbuild: Remove uncmd_spl logic")) enabled in CONFIG_DM_SERIAL. We drop
this line out now so that platforms which do use
CONFIG_SYS_NS16550_MEM32 and depending on stage may or may not have
DM_SERIAL set.

Fixes: 0478dac62a9a ("kbuild: Remove uncmd_spl logic")
Reported-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Tested-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> #on Ringneck PX30, Puma RK3399

# 0478dac6 04-Dec-2022 Tom Rini <trini@konsulko.com>

kbuild: Remove uncmd_spl logic

At this point in the conversion there should be no need to have logic to
disable some symbol during the SPL build as all symbols should have an
SPL counterpart.

The main real changes done here are that we now must make proper use of
CONFIG_IS_ENABLED(DM_SERIAL) rather than many of the odd tricks we
developed prior to CONFIG_IS_ENABLED() being available.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 9591b635 04-Dec-2022 Tom Rini <trini@konsulko.com>

Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig

This converts the following to Kconfig:
CONFIG_SPL_NS16550_MIN_FUNCTIONS
CONFIG_SYS_NS16550_MEM32
CONFIG_SYS_NS16550_PORT_MAPPED
CONFIG_SYS_NS16550_REG_SIZE
CONFIG_SYS_NS16550_SERIAL

To do this we also introduce CONFIG_SPL_SYS_NS16550_SERIAL so that
platforms can enable the legacy driver here for SPL.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 2d6bf754 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Rename ns16550 functions to lower case

Lower case should be used for function names. Update this driver and its
callers accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# d30c7209 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Update NS16550_t and struct NS16550

Typedefs should not be used in U-Boot and structs should be lower case.
Update the code to use struct ns16550 consistently.

Put a header guard on the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# 8a8d24bd 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ..._platdata variables to just ..._plat

Try to maintain some consistency between these variables by using _plat as
a suffix for them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d1998a9f 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ofdata_to_platdata() to of_to_plat()

This name is far too long. Rename it to remove the 'data' bits. This makes
it consistent with the platdata->plat rename.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 62cbde4c 19-Dec-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Support run-time configuration

At present this driver uses an assortment of CONFIG options to control
how it accesses the hardware. This is painful for platforms that are
supposed to be controlled by a device tree or a previous-stage bootloader.

Add a new CONFIG option to enable fully dynamic configuration. This
controls register spacing, size, offset and endianness.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aiden Park <aiden.park@intel.com>
Tested-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: squashed in http://patchwork.ozlabs.org/patch/1232929/]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@amd.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@amd.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.masahiro@socionext.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 Wolfgang Denk <wd@denx.de>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 Wolfgang Denk <wd@denx.de>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 Wolfgang Denk <wd@denx.de>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 Wolfgang Denk <wd@denx.de>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 Wolfgang Denk <wd@denx.de>

Initial revision

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

Sphinx expects Return: and not @return to indicate a return value.

find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

# 2d6bf754 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Rename ns16550 functions to lower case

Lower case should be used for function names. Update this driver and its
callers accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# d30c7209 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Update NS16550_t and struct NS16550

Typedefs should not be used in U-Boot and structs should be lower case.
Update the code to use struct ns16550 consistently.

Put a header guard on the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# 8a8d24bd 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ..._platdata variables to just ..._plat

Try to maintain some consistency between these variables by using _plat as
a suffix for them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d1998a9f 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ofdata_to_platdata() to of_to_plat()

This name is far too long. Rename it to remove the 'data' bits. This makes
it consistent with the platdata->plat rename.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 62cbde4c 19-Dec-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Support run-time configuration

At present this driver uses an assortment of CONFIG options to control
how it accesses the hardware. This is painful for platforms that are
supposed to be controlled by a device tree or a previous-stage bootloader.

Add a new CONFIG option to enable fully dynamic configuration. This
controls register spacing, size, offset and endianness.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aiden Park <aiden.park@intel.com>
Tested-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: squashed in http://patchwork.ozlabs.org/patch/1232929/]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@pollux.denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@pollux.denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 Wolfgang Denk <wdenk>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 Wolfgang Denk <wdenk>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 Wolfgang Denk <wdenk>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 Wolfgang Denk <wdenk>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 Wolfgang Denk <wdenk>

Initial revision

# 2d6bf754 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Rename ns16550 functions to lower case

Lower case should be used for function names. Update this driver and its
callers accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# d30c7209 22-Dec-2020 Simon Glass <sjg@chromium.org>

serial: Update NS16550_t and struct NS16550

Typedefs should not be used in U-Boot and structs should be lower case.
Update the code to use struct ns16550 consistently.

Put a header guard on the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

# 8a8d24bd 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ..._platdata variables to just ..._plat

Try to maintain some consistency between these variables by using _plat as
a suffix for them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d1998a9f 03-Dec-2020 Simon Glass <sjg@chromium.org>

dm: treewide: Rename ofdata_to_platdata() to of_to_plat()

This name is far too long. Rename it to remove the 'data' bits. This makes
it consistent with the platdata->plat rename.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 62cbde4c 19-Dec-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Support run-time configuration

At present this driver uses an assortment of CONFIG options to control
how it accesses the hardware. This is painful for platforms that are
supposed to be controlled by a device tree or a previous-stage bootloader.

Add a new CONFIG option to enable fully dynamic configuration. This
controls register spacing, size, offset and endianness.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aiden Park <aiden.park@intel.com>
Tested-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: squashed in http://patchwork.ozlabs.org/patch/1232929/]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@pollux.denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@pollux.denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 Wolfgang Denk <wdenk>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 Wolfgang Denk <wdenk>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 Wolfgang Denk <wdenk>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 Wolfgang Denk <wdenk>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 Wolfgang Denk <wdenk>

Initial revision

# 62cbde4c 19-Dec-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Support run-time configuration

At present this driver uses an assortment of CONFIG options to control
how it accesses the hardware. This is painful for platforms that are
supposed to be controlled by a device tree or a previous-stage bootloader.

Add a new CONFIG option to enable fully dynamic configuration. This
controls register spacing, size, offset and endianness.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Aiden Park <aiden.park@intel.com>
Tested-by: Aiden Park <aiden.park@intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: squashed in http://patchwork.ozlabs.org/patch/1232929/]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@pollux.denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@pollux.denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 Wolfgang Denk <wdenk>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 Wolfgang Denk <wdenk>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 Wolfgang Denk <wdenk>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 Wolfgang Denk <wdenk>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 Wolfgang Denk <wdenk>

Initial revision

# 4e8de068 25-Sep-2019 Simon Glass <sjg@chromium.org>

serial: ns16550: Add a PCI device/function field

When this UART is used early in boot (before PCI is set up) it is
convenient to store the PCI BDF of the UART so that it can be manually
configured. This is useful when it is used as a debug UART, for example.

Add a new field to hold this information, so that drivers can simply use
the existing platform data.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@pollux.denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@pollux.denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 wdenk <wdenk>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 wdenk <wdenk>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 wdenk <wdenk>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 wdenk <wdenk>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 wdenk <wdenk>

Initial revision

# 4e720779 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Read reg-io-width from device tree

Cache the value of the reg-io-width property for the future use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 0af76162 20-Nov-2018 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

serial: ns16550: Group reg_* members of ns16550_platdata

Group reg_* members of struct ns16550_platdata together for better maintenance.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>

# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>

# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>

# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>

# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>

# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>

# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>

# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>

# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>

# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>

# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>

# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@pollux.denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup

# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005

# 22814904 11-Mar-2006 Wolfgang Denk <wd@pollux.denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005

# 8ed96046 09-Jan-2005 wdenk <wdenk>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.

# a56bd922 06-Jun-2004 wdenk <wdenk>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.

# 6f21347d 29-Aug-2003 wdenk <wdenk>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board

# 2e5983d2 15-Jul-2003 wdenk <wdenk>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board

# 717b5aad 27-Apr-2002 wdenk <wdenk>

Initial revision

# 7fded0ce 16-Aug-2017 Stefan Roese <sr@denx.de>

Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt
for the RX buffer support at all. Just reading all available characters
into a buffer is sufficient to solve the problem with the dropped
characters upon long lines pasted into the U-Boot prompt. Since this
RX buffer support can be implemented in a generic way, without any
device specifica (e.g. for the ns16550), I'll post a new patch with
a new serial RX buffer support for DM, which all DM based serial
drivers can use.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


# 6822cf3e 14-Jul-2017 Stefan Roese <sr@denx.de>

serial: ns16550: Add RX interrupt buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to
characters missing. One problem here is the small 16-byte FIFO of the
legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX interrupt
buffer support for NS16550 style UARTs. With this option enabled, I was
able paste really long lines into the U-Boot console, without any
characters missing.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
[trini: Guard ns16550_serial_remove with
CONFIG_IS_ENABLED(SERIAL_PRESENT) to match struct assignment]
Signed-off-by: Tom Rini <trini@konsulko.com>


# 17fa0326 18-Jan-2017 Heiko Schocher <hs@denx.de>

serial, ns16550: bugfix: ns16550 fifo not enabled

commit: 65f83802b7a5b "serial: 16550: Add getfcr accessor"
breaks u-boot commandline working with long commands
sending to the board.

Since the above patch, you have to setup the fcr register.

For board/archs which enable OF_PLATDATA, the new field
fcr in struct ns16550_platdata is not filled with a
default value ...

This leads in not setting up the uarts fifo, which ends
in problems, when you send long commands to u-boots
commandline.

Detected this issue with automated tbot tests on am335x
based shc board.

The error does not popup, if you type commands. You need
to copy&paste a long command to u-boots commandshell
(or send a long command with tbot)

Possible boards/plattforms with problems:
./arch/arm/cpu/arm926ejs/lpc32xx/devices.c
./arch/arm/mach-tegra/board.c
./board/overo/overo.c
./board/quipos/cairo/cairo.c
./board/logicpd/omap3som/omap3logic.c
./board/logicpd/zoom1/zoom1.c
./board/timll/devkit8000/devkit8000.c
./board/lg/sniper/sniper.c
./board/ti/beagle/beagle.c
./drivers/serial/serial_rockchip.c

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>


# 0b060eef 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add Ingenic JZ4780 support

Add compatibility string for the Ingenic JZ4780 SoC, the necessary
UART enable bit into FCR and register shift. Neither are encoded
in the DTS coming from Linux, so we need to support it this way.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Simon Glass <sjg@chromium.org>


# 65f83802 30-Nov-2016 Marek Vasut <marex@denx.de>

serial: 16550: Add getfcr accessor

Add function which allows fetching the default FCR register setting
from platform data for DM , while retaining old behavior for non-DM
by returning UART_FCRVAL.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>


# 59b35ddd 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Moved the new field to the end of the struct to avoid problems:
Signed-off-by: Simon Glass <sjg@chromium.org>


# e5e88c65 29-Feb-2016 Tom Rini <trini@konsulko.com>

Revert "dm: ns16550: Add support for reg-offset property"

This reverts commit d9a3bec682f9756621615f4306718a356a3230e3.

While this is a correct change to do long term it unfortunately breaks a
number of platforms that are using pdata and not named struct members so
they are getting all of their data after 'base' incorrect.

Acked-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Tom Rini <trini@konsulko.com>


# d9a3bec6 16-Feb-2016 Michal Simek <michal.simek@xilinx.com>

dm: ns16550: Add support for reg-offset property

reg-offset is the part of standard 8250 binding in the kernel.
It is shifting start of address space by reg-offset.
On Xilinx platform this offset is typically 0x1000.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>


# 90914008 12-May-2015 Simon Glass <sjg@chromium.org>

dm: ns16550: Support CONFIG_SYS_NS16550_MEM32 with driver model

This option is used by some boards, so support it with driver model. This
is really ugly - we should rewrite this driver once all users are moved to
driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 167efe01 22-Oct-2014 Simon Glass <sjg@chromium.org>

dm: ns16550: Use an address instead of a pointer for the uart base

It is inconvenient to have to use casts when specifying platform data. Also
it is not strictly correct, since we should use map_sysmem() to convert an
address to a pointer.

Adjust the platform data to use an address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@ti.com>


# 12e431b2 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Add driver model support for ns16550

Add driver model support so that ns16550 can support operation both with
and without driver model.

The driver needs a clock frequency so cannot stand alone unfortunately. The
clock frequency must be provided by a separate driver.

Signed-off-by: Simon Glass <sjg@chromium.org>


# fa54eb12 04-Sep-2014 Simon Glass <sjg@chromium.org>

dm: serial: Move baud rate calculation to ns16550.c

Move the function that calculates the baud rate divisor into ns16550.c so
it can be used by that file.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 8ac22a60 30-Jul-2014 Masahiro Yamada <yamada.m@jp.panasonic.com>

omap: clean-up dead configs

The following configs are not defined at all.

- CONFIG_OMAP1510
- CONFIG_OMAP_1510P1
- CONFIG_OMAP_SX1
- CONFIG_OMAP3_DMA
- CONFIG_OMAP3_ZOOM2
- CONFIG_OMAP_INNOVATOR

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>


# d57dee57 09-Apr-2014 Karicheri, Muralidharan <m-karicheri2@ti.com>

serial: nsl16550: add hw flow control support

keystone serial hw support hw flow control. This patch
enables hw flow control for keystone EVMs as an optional
feature based on CONFIG_SERIAL_HW_FLOW_CONTROL.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>


# 99b603e7 09-Jul-2012 Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>

serial/ns16550: ns16550 has a different register layout on SOC_DA8XX

also fix NS16550_init() as we need 16x divider

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
Acked-by: Christian Riesch <christian.riesch@omicron.at>
Tested-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Sughosh Ganu <urwithsughosh@gmail.com>
Tested-by: Sughosh Ganu <urwithsughosh@gmail.com>


# f8df9d0d 15-Oct-2011 Simon Glass <sjg@chromium.org>

NS16550: trivial code clean for checkpatch

This removes most checkpatch warnings from the ns16550 driver and its
header.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 79df1208 01-Sep-2011 Dave Aldridge <fovsoft@gmail.com>

ns16550: change to allow 32 bit access to registers

If CONFIG_SYS_NS16550_MEM32 is defined then 32 bit memory
mapped access will be used to read/write the uart registers.

This is especially useful for SoC devices that implement 16550
compatible uarts but that have peripheral access width constraints.

Signed-off-by: Dave Aldridge <fovsoft@gmail.com>


# a47a12be 15-Apr-2010 Stefan Roese <sr@denx.de>

Move arch/ppc to arch/powerpc

As discussed on the list, move "arch/ppc" to "arch/powerpc" to
better match the Linux directory structure.

Please note that this patch also changes the "ppc" target in
MAKEALL to "powerpc" to match this new infrastructure. But "ppc"
is kept as an alias for now, to not break compatibility with
scripts using this name.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Cc: Peter Tyser <ptyser@xes-inc.com>
Cc: Anatolij Gustschin <agust@denx.de>


# 453c0d75 03-Apr-2009 Detlev Zundel <dzu@denx.de>

include/ns16550.h: Unify structure declaration for registers

Instead of special casing the different access patterns, use common
code with light macros sprinkled in to accomodate for the different
layouts of the register structure.

Note that this also changes the types of the registers for the
"positively packed (>1)" cases. As the registers truly are unsigned
chars, this is surely the Right Thing, but it is a semantic change.
Note that for this case depending on the endianness on the bus, we may
see a change of behaviour.

Signed-off-by: Detlev Zundel <dzu@denx.de>


# 200779e3 03-Apr-2009 Detlev Zundel <dzu@denx.de>

Rename common ns16550 constants with UART_ prefix to prevent conflicts

Fix problems introduced in commit
7b5611cdd12ca0cc33f994f0d4a4454788fc3124 [inka4x0: Add hardware
diagnosis functions for inka4x0] which redefined MSR_RI which is
already used on PowerPC systems.

Also eliminate redundant definitions in ps2mult.h. More cleanup will
be needed for other redundant occurrences though.

Signed-off-by: Detlev Zundel <dzu@denx.de>


# 7b5611cd 29-Mar-2009 Detlev Zundel <dzu@denx.de>

inka4x0: Add hardware diagnosis functions for inka4x0

This patch adds advanced diagnosis functions for the inka4x0 board.

Signed-off-by: Andreas Pfefferle <ap@denx.de>
Signed-off-by: Detlev Zundel <dzu@denx.de>


# 6d0f6bcf 16-Oct-2008 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

rename CFG_ macros to CONFIG_SYS

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>


# b87dfd28 19-Jul-2006 Wolfgang Denk <wd@pollux.denx.de>

Add support for TB5200 board
The TB5200 ("Tinybox") is a small baseboard for the TQM5200 module
integrated in a little aluminium case.
Patch by Martin Krause, 8 Jun 2006

Some code cleanup


# f5e0d039 19-Jun-2006 Heiko Schocher <hs@pollux.denx.de>

Add support for wrPPMC7xx/74xx boards
Patch from Richard Danter, 12 Aug 2005


# 22814904 11-Mar-2006 Wolfgang Denk <wd@pollux.denx.de>

Word alignment fixes for word aligned NS16550 UART
Patch by Jean-Paul Saman, 01 Mar 2005


# 8ed96046 09-Jan-2005 wdenk <wdenk>

* Patches by Richard Woodruff, 01 Oct 2004:
add support for the TI OMAP2420 processor and its H4 reference
board

* Patch by Christian Pellegrin, 24 Sep 2004:
Added support for NE2000 compatible (DP8390, DP83902) NICs.


# a56bd922 06-Jun-2004 wdenk <wdenk>

* Patch by Dave Peverley, 30 Apr 2004:
Add support for OMAP730 Perseus2 Development board

* Patch by Alan J. Luse, 29 Apr 2004:
Fix flash chip-select (OR0) option register setting on FADS boards.

* Patch by Alan J. Luse, 29 Apr 2004:
Report MII network speed and duplex setting properly when
auto-negotiate is not enabled.

* Patch by Jarrett Redd, 29 Apr 2004:
Fix hang on reset on Ocotea board due to flash in wrong mode.


# 6f21347d 29-Aug-2003 wdenk <wdenk>

* Patch by George G. Davis, 19 Aug 2003:
fix TI Innovator/OMAP1510 pin configs

* Patches by Kshitij, 18 Aug 2003
- add support for arm926ejs cpu core
- add support for TI OMAP 1610 Innovator Board


# 2e5983d2 15-Jul-2003 wdenk <wdenk>

Patches by Kshitij, 04 Jul 2003
- added support for arm925t cpu core
- added support for TI OMAP 1510 Innovator Board


# 717b5aad 27-Apr-2002 wdenk <wdenk>

Initial revision