All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] serial: ns16550: Add register shift variable
@ 2018-07-13 14:43 Felix Brack
  2018-07-13 15:08 ` Alexander Graf
  2018-07-14 10:47 ` Wolfgang Denk
  0 siblings, 2 replies; 26+ messages in thread
From: Felix Brack @ 2018-07-13 14:43 UTC (permalink / raw)
  To: u-boot

This patch adds a new Kconfig variable that allows setting
the register shift value for the ns16550 driver to some other
value then 0 if not defined by the DT. All credit for this
patch goes to Lokesh Vutla as it was his idea.

The motivation for writing this patch originates in the
effort of synchronizing U-Boot DT to Linux DT for am33xx SOCs.
The current am33xx.dtsi file from U-Boot defines the <reg-shift>
property for all UART nodes. The actual (4.18+) am33xx.dtsi
file from Linux does not define <reg-shift> anymore. To prevent
(probably difficult) changes in many .dts and .dtsi files once
the synchronization is done, one can use this new variable. For
the pdu001 board, for example, SYS_NS16550_REG_SHIFT is set
to 2; no need to clutter U-Boot and board specific dts files
with <reg-shift> properties.

Signed-off-by: Felix Brack <fb@ltec.ch>
---

 drivers/serial/Kconfig   | 12 ++++++++++++
 drivers/serial/ns16550.c |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 766e5ce..c80ad4d 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -530,6 +530,18 @@ config SYS_NS16550
 	  be used. It can be a constant or a function to get clock, eg,
 	  get_serial_clock().
 
+config SYS_NS16550_REG_SHIFT
+	int "Number of bytes to shift register offsets"
+	default 0
+	depends on SYS_NS16550
+	help
+	  Use this to specify the amount of bytes between discrete
+	  device registers. If, for example, the device registers are
+	  located at 0x00, 0x04, 0x08, 0x0C and so forth than set
+	  this to 2. The default value is 0.
+	  Note that a <reg-shift> property defined in a UART node of
+	  the device tree will always take precedence.
+
 config INTEL_MID_SERIAL
 	bool "Intel MID platform UART support"
 	depends on DM_SERIAL && OF_CONTROL
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 9c80090..9ff6dbe 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -442,7 +442,8 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
 #endif
 
 	plat->reg_offset = dev_read_u32_default(dev, "reg-offset", 0);
-	plat->reg_shift = dev_read_u32_default(dev, "reg-shift", 0);
+	plat->reg_shift = dev_read_u32_default(dev, "reg-shift",
+					       CONFIG_SYS_NS16550_REG_SHIFT);
 
 	err = clk_get_by_index(dev, 0, &clk);
 	if (!err) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2018-07-18  8:26 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-13 14:43 [U-Boot] [PATCH] serial: ns16550: Add register shift variable Felix Brack
2018-07-13 15:08 ` Alexander Graf
2018-07-14 10:47 ` Wolfgang Denk
2018-07-14 15:49   ` Tom Rini
2018-07-15  8:43     ` Alexey Brodkin
2018-07-15 14:02       ` Felix Brack
2018-07-16 15:04         ` Alexey Brodkin
2018-07-16 15:47           ` Andy Shevchenko
2018-07-17 13:24             ` Tom Rini
2018-07-17  6:51           ` Felix Brack
2018-07-17 13:34             ` Alexander Graf
2018-07-15 11:17     ` Felix Brack
2018-07-16 12:42       ` Wolfgang Denk
2018-07-16 12:48         ` Felix Brack
2018-07-16 12:53     ` Alexander Graf
2018-07-17 13:25       ` Tom Rini
2018-07-17 13:33         ` Alexander Graf
2018-07-17 13:34           ` Alexey Brodkin
2018-07-17 13:41             ` Tom Rini
2018-07-17 13:43               ` Alexander Graf
2018-07-18  8:26                 ` Lokesh Vutla
2018-07-17 21:23             ` Andy Shevchenko
2018-07-17 21:30               ` Adam Ford
2018-07-17 21:46                 ` Andy Shevchenko
2018-07-17 13:39           ` Tom Rini
2018-07-15 11:05   ` Felix Brack

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.