serial: add uart driver for MediaTek MT7620 SoC
PATCH 8/18 serial: add uart driver for MediaTek MT7620 SoC
This patch adds uart support for MediaTek MT7620 and earlier SoCs.
The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).
The driver can be built without DM which is useful for tiny SPL.
--- drivers/serial/Kconfig | 20 ++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 350 +++++++++++++++++++++++++++++++++ 4 files changed, 373 insertions(+) create mode 100644 drivers/serial/serial_mt7620.c
drivers/serial/Kconfig +20 -0
@@ -401,6 +401,16 @@ config DEBUG_UART_MTK driver will be available until the real driver model serial is running. +config DEBUG_UART_MT7620 + bool "UART driver for MediaTek MT7620 and earlier SoCs" + depends on MT7620_SERIAL + help + Select this to enable a debug UART using the UART driver for + MediaTek MT7620 and earlier SoCs. + You will need to provide parameters to make this work. The + driver will be available until the real driver model serial is + running. + endchoice config DEBUG_UART_BASE
@@ -817,6 +827,16 @@ config MTK_SERIAL The High-speed UART is compatible with the ns16550a UART and have its own high-speed registers. +config MT7620_SERIAL + bool "UART driver for MediaTek MT7620 and earlier SoCs" + depends on DM_SERIAL + help + Select this to enable UART support for MediaTek MT7620 and earlier + SoCs. This driver uses driver model and requires a device tree + binding to operate. + The UART driver for MediaTek MT7620 and earlier SoCs is *NOT* + compatible with the ns16550a UART. + config MPC8XX_CONS bool "Console driver for MPC8XX" depends on MPC8xx
drivers/serial/Makefile +1 -0
@@ -69,6 +69,7 @@ obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o obj-$(CONFIG_OWL_SERIAL) += serial_owl.o obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o +obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
drivers/serial/serial.c +2 -0
@@ -127,6 +127,7 @@ serial_initfunc(pl01x_serial_initialize);serial_initfunc (pxa_serial_initialize);serial_initfunc (sh_serial_initialize);serial_initfunc (mtk_serial_initialize); +serial_initfunc (mt7620_serial_initialize);/** * serial_register() - Register serial driver with serial driver core
@@ -181,6 +182,7 @@ int serial_initialize(void)pxa_serial_initialize ();sh_serial_initialize ();mtk_serial_initialize (); +mt7620_serial_initialize ();serial_assign (default_serial_console ()->name);
drivers/serial/serial_mt7620.c new file +350 -0
350 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 8/18 serial: add uart driver for MediaTek MT7620 SoC
Hi Weijie,
Quoted 10 lines · Weijie Gao
This patch adds uart support for MediaTek MT7620 and earlier SoCs.
The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).
The driver can be built without DM which is useful for tiny SPL.
Quoted 8 lines
Signed-off-by Weijie Gao <[email protected]>--- drivers/serial/Kconfig | 20 ++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 350 +++++++++++++++++++++++++++++++++ 4 files changed, 373 insertions(+) create mode 100644 drivers/serial/serial_mt7620.c
Why do you need to build without DM? We have of-platdata which provides for smaller images. What is the SRAM size available?
Regards,
Simon
PATCH 8/18 serial: add uart driver for MediaTek MT7620 SoC
Quoted 22 lines · Simon Glass
Hi Weijie,
Quoted 10 lines · Weijie Gao
This patch adds uart support for MediaTek MT7620 and earlier SoCs.
The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).
The driver can be built without DM which is useful for tiny SPL.
Quoted 8 lines
Signed-off-by Weijie Gao <[email protected]>--- drivers/serial/Kconfig | 20 ++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 350 +++++++++++++++++++++++++++++++++ 4 files changed, 373 insertions(+) create mode 100644 drivers/serial/serial_mt7620.c
Quoted 3 lines
Why do you need to build without DM? We have of-platdata which provides for smaller images. What is the SRAM size available?
Actually it's the total size (spl+u-boot-lzma.img) that matters. mt7620_rfb_defconfig is configured to be compatible with the original u-boot from MTK SDK, and the maximum size is 192KiB.
Currently without SPL_DM, the final image u-boot-with-spl.bin is about 170KiB, the u-boot-spl.bin is only 20KiB.
If SPL_DM is enabled, the total size is 189KiB, which is very close to the limit 192KiB, and the size of spl is almost doubled, 39KiB. (Without DM, only serial_mt7620 is needed. However with DM, both serial_mt7620, clk-mt7620 and misc are needed)
Considering that we may still add some feature to mt7620_rfb_defconfig in the future, only 3KiB left is not enough. Building without DM is apparently better.
I believe using of-platdata can only reduce few KiBs of SPL, because the DM itself is the largest overhead.
Quoted 2 lines
Regards,
Simon
PATCH 8/18 serial: add uart driver for MediaTek MT7620 SoC
Hi Weijie,
Quoted 24 lines · Weijie Gao
Quoted 22 lines · Simon Glass
Hi Weijie,
Quoted 18 lines · Weijie Gao
This patch adds uart support for MediaTek MT7620 and earlier SoCs.
The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).
The driver can be built without DM which is useful for tiny SPL.
Signed-off-by Weijie Gao <[email protected]>--- drivers/serial/Kconfig | 20 ++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 350 +++++++++++++++++++++++++++++++++ 4 files changed, 373 insertions(+) create mode 100644 drivers/serial/serial_mt7620.c
Quoted 7 lines
Quoted 3 lines
Why do you need to build without DM? We have of-platdata which provides for smaller images. What is the SRAM size available?
Actually it's the total size (spl+u-boot-lzma.img) that matters.
mt7620_rfb_defconfigis configured to be compatible with the original u-boot from MTK SDK, and the maximum size is 192KiB.
What is lzma.img ?
Quoted 3 lines
Currently without
SPL_DM, the final image u-boot-with-spl.bin is about 170KiB, the u-boot-spl.bin is only 20KiB.
That is definitely huge.
Quoted 11 lines
If
SPL_DMis enabled, the total size is 189KiB, which is very close to the limit 192KiB, and the size of spl is almost doubled, 39KiB. (Without DM, onlyserial_mt7620is needed. However with DM, bothserial_mt7620, clk-mt7620 and misc are needed)Considering that we may still add some feature to
mt7620_rfb_defconfigin the future, only 3KiB left is not enough. Building without DM is apparently better.I believe using of-platdata can only reduce few KiBs of SPL, because the DM itself is the largest overhead.
That's not my experience. The core DM overhead is fairly small, perhaps 3-4KB. The device tree itself is typically at least another 3KB, depending on how many nodes you mark for inclusion in SPL.
With of-platdata the overhead of DM is not that terrible. You can see some stats here:
Regards,
SImon
PATCH 8/18 serial: add uart driver for MediaTek MT7620 SoC
Quoted 31 lines · Simon Glass
Hi Weijie,
Quoted 28 lines · Weijie Gao
Quoted 25 lines · Simon Glass
Hi Weijie,
Quoted 10 lines · Weijie Gao
This patch adds uart support for MediaTek MT7620 and earlier SoCs.
The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).
The driver can be built without DM which is useful for tiny SPL.
Quoted 8 lines
Signed-off-by Weijie Gao <[email protected]>--- drivers/serial/Kconfig | 20 ++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 350 +++++++++++++++++++++++++++++++++ 4 files changed, 373 insertions(+) create mode 100644 drivers/serial/serial_mt7620.cWhy do you need to build without DM? We have of-platdata which provides for smaller images. What is the SRAM size available?
Quoted 5 lines
Quoted 3 lines
Actually it's the total size (spl+u-boot-lzma.img) that matters.
mt7620_rfb_defconfigis configured to be compatible with the original u-boot from MTK SDK, and the maximum size is 192KiB.What is lzma.img ?
The u-boot.bin is compressed to reduce it's size (395KiB -> 150KiB), and the SPL is responsible to decompress it.
Quoted 6 lines
Quoted 4 lines
Currently without
SPL_DM, the final image u-boot-with-spl.bin is about 170KiB, the u-boot-spl.bin is only 20KiB.That is definitely huge.
Without the decompression code, the size of SPL will be reduced to 9KiB.
Quoted 13 lines
Quoted 6 lines
If
SPL_DMis enabled, the total size is 189KiB, which is very close to the limit 192KiB, and the size of spl is almost doubled, 39KiB. (Without DM, onlyserial_mt7620is needed. However with DM, bothserial_mt7620, clk-mt7620 and misc are needed)Quoted 6 lines
Considering that we may still add some feature to
mt7620_rfb_defconfigin the future, only 3KiB left is not enough. Building without DM is apparently better.I believe using of-platdata can only reduce few KiBs of SPL, because the DM itself is the largest overhead.
Quoted 6 lines
That's not my experience. The core DM overhead is fairly small, perhaps 3-4KB. The device tree itself is typically at least another 3KB, depending on how many nodes you mark for inclusion in SPL.
With of-platdata the overhead of DM is not that terrible. You can see some stats here:
I have tried to optimize drivers and configs used in SPL, and managed to reduce the size of SPL to 22KiB with of-platdata (without DM, the size is 17KiB. So it's only 5KiB used by DM).
I'll switch this driver to of-platdata in the next series.
PATCH 8/18 serial: add uart driver for MediaTek MT7620 SoC
Hi Weijie,
Quoted 44 lines · Weijie Gao
Quoted 31 lines · Simon Glass
Hi Weijie,
Quoted 28 lines · Weijie Gao
Quoted 25 lines · Simon Glass
Hi Weijie,
Quoted 10 lines · Weijie Gao
This patch adds uart support for MediaTek MT7620 and earlier SoCs.
The UART used by MT7620 is incompatible with the ns16550a driver. All registers of this UART have different addresses. A special 16-bit register for Divisor Latch is used to set the baudrate instead of the original two 8-bit registers (DLL and DLM).
The driver can be built without DM which is useful for tiny SPL.
Quoted 8 lines
Signed-off-by Weijie Gao <[email protected]>--- drivers/serial/Kconfig | 20 ++ drivers/serial/Makefile | 1 + drivers/serial/serial.c | 2 + drivers/serial/serial_mt7620.c | 350 +++++++++++++++++++++++++++++++++ 4 files changed, 373 insertions(+) create mode 100644 drivers/serial/serial_mt7620.cWhy do you need to build without DM? We have of-platdata which provides for smaller images. What is the SRAM size available?
Quoted 5 lines
Quoted 3 lines
Actually it's the total size (spl+u-boot-lzma.img) that matters.
mt7620_rfb_defconfigis configured to be compatible with the original u-boot from MTK SDK, and the maximum size is 192KiB.What is lzma.img ?
The u-boot.bin is compressed to reduce it's size (395KiB -> 150KiB), and the SPL is responsible to decompress it.
Quoted 2 lines
Quoted 2 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Currently without
SPL_DM, the final image u-boot-with-spl.bin is about 170KiB, the u-boot-spl.bin is only 20KiB.That is definitely huge.
Without the decompression code, the size of SPL will be reduced to 9KiB.
OK...so is it possible to have SPL load U-Boot, instead of including it in SRAM? That is normally what is done.
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
If
SPL_DMis enabled, the total size is 189KiB, which is very close to the limit 192KiB, and the size of spl is almost doubled, 39KiB. (Without DM, onlyserial_mt7620is needed. However with DM, bothserial_mt7620, clk-mt7620 and misc are needed)Quoted 6 lines
Considering that we may still add some feature to
mt7620_rfb_defconfigin the future, only 3KiB left is not enough. Building without DM is apparently better.I believe using of-platdata can only reduce few KiBs of SPL, because the DM itself is the largest overhead.
That's not my experience. The core DM overhead is fairly small, perhaps 3-4KB. The device tree itself is typically at least another 3KB, depending on how many nodes you mark for inclusion in SPL.
Quoted 8 lines
Quoted 2 lines
With of-platdata the overhead of DM is not that terrible. You can see some stats here:
I have tried to optimize drivers and configs used in SPL, and managed to reduce the size of SPL to 22KiB with of-platdata (without DM, the size is 17KiB. So it's only 5KiB used by DM).
I'll switch this driver to of-platdata in the next series.
Gosh that was quick, nice work!
Quoted 3 lines
Regards,
Simon