ucc_uart: add support for Freescale QUICCEngine UART
Subsystems (3)
PATCH v2 1/1 ucc_uart: add support for Freescale QUICCEngine UART
Add support for UART serial ports using a Freescale QUICC Engine (found on some MPC83xx and MPC85xx SOCs).
Updated booting-without-of.txt to define new properties for a QE UART node, and a new node definition that describes uploaded QE firmware.
Because of a silicon bug in some QE-enabled SOCs (e.g. 8323 and 8360), a new microcode is required. This microcode implements UART via a work-around, hence it's called "Soft-UART". This driver can use the QE firmware upload feature to upload the correct microcode to the QE.
---
Made selection of Soft-UART dynamic. Updated to reflect changes in prerequisite patches. Added support for 'firmware' node in device tree.
This patch is for Kumar's for-2.6.25 branch, and it applies on top of my previous patches, "qe: add ability to upload QE firmware" and "qe: add function qe_clock_source()".
Documentation/powerpc/booting-without-of.txt | 9 +- arch/powerpc/boot/dts/mpc832x_mds.dts | 49 + arch/powerpc/sysdev/qe_lib/Kconfig | 2 +- arch/powerpc/sysdev/qe_lib/ucc_slow.c | 10 +- drivers/serial/Kconfig | 10 + drivers/serial/Makefile | 1 + drivers/serial/ucc_uart.c | 1498 ++++++++++++++++++++++++++ 7 files changed, 1576 insertions(+), 3 deletions(-) create mode 100644 drivers/serial/ucc_uart.c
Documentation/powerpc/booting-without-of.txt +8 -1
@@ -1616,7 +1616,7 @@ platforms are moved over to use the flattened-device-tree model. Required properties: - device_type : should be "network", "hldc", "uart", "transparent" - "bisync" or "atm". + "bisync", "atm", or "serial". - compatible : could be "ucc_geth" or "fsl_atm" and so on. - model : should be "UCC". - device-id : the ucc number(1-8), corresponding to UCCx in UM.
@@ -1629,6 +1629,13 @@ platforms are moved over to use the flattened-device-tree model. - interrupt-parent : the phandle for the interrupt controller that services interrupts for this device. - pio-handle : The phandle for the Parallel I/O port configuration. + - port-number : for UART drivers, the port number to use, between 0 and 3. + This usually corresponds to the /dev/ttyQE device, e.g. <0> = /dev/ttyQE0. + The port number is added to the minor number of the device. Unlike the + CPM UART driver, the port-number is required for the QE UART driver. + - soft-uart : for UART drivers, if specified this means the QE UART device + driver should use "Soft-UART" mode, which is needed on some SOCs that have + broken UART hardware. Soft-UART is provided via a microcode upload. - rx-clock-name: the UCC receive clock source "none": clock source is disabled "brg1" through "brg16": clock source is BRG1-BRG16, respectively
arch/powerpc/boot/dts/mpc832x_mds.dts +49 -0
67 lines not on this page · raw message
arch/powerpc/sysdev/qe_lib/Kconfig +1 -1
@@ -4,7 +4,7 @@ config UCC_SLOW bool - default n + default y if SERIAL_QE help This option provides qe_lib support to UCC slow protocols: UART, BISYNC, QMC
arch/powerpc/sysdev/qe_lib/ucc_slow.c +9 -1
@@ -19,6 +19,7 @@#include <linux/stddef.h> #include <linux/interrupt.h> #include <linux/err.h> +#include <linux/module.h> #include <asm/io.h> #include <asm/immap_qe.h>
@@ -41,6 +42,7 @@ u32 ucc_slow_get_qe_cr_subblock(int uccs_num)default :return QE_CR_SUBBLOCK_INVALID ; } } +EXPORT_SYMBOL (ucc_slow_get_qe_cr_subblock);void ucc_slow_poll_transmitter_now (struct ucc_slow_private * uccs) {
@@ -56,6 +58,7 @@ void ucc_slow_graceful_stop_tx(struct ucc_slow_private * uccs)qe_issue_cmd (QE_GRACEFUL_STOP_TX , id,QE_CR_PROTOCOL_UNSPECIFIED ,0 ); } +EXPORT_SYMBOL (ucc_slow_graceful_stop_tx);void ucc_slow_stop_tx (struct ucc_slow_private * uccs) {
@@ -65,6 +68,7 @@ void ucc_slow_stop_tx(struct ucc_slow_private * uccs) id =ucc_slow_get_qe_cr_subblock (us_info->ucc_num);qe_issue_cmd (QE_STOP_TX , id,QE_CR_PROTOCOL_UNSPECIFIED ,0 ); } +EXPORT_SYMBOL (ucc_slow_stop_tx);void ucc_slow_restart_tx (struct ucc_slow_private * uccs) {
@@ -74,6 +78,7 @@ void ucc_slow_restart_tx(struct ucc_slow_private * uccs) id =ucc_slow_get_qe_cr_subblock (us_info->ucc_num);qe_issue_cmd (QE_RESTART_TX , id,QE_CR_PROTOCOL_UNSPECIFIED ,0 ); } +EXPORT_SYMBOL (ucc_slow_restart_tx);void ucc_slow_enable (struct ucc_slow_private * uccs,enum comm_dir mode) {
@@ -94,6 +99,7 @@ void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode) }out_be32 (&us_regs->gumr_l, gumr_l); } +EXPORT_SYMBOL (ucc_slow_enable);void ucc_slow_disable (struct ucc_slow_private * uccs,enum comm_dir mode) {
@@ -114,6 +120,7 @@ void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode) }out_be32 (&us_regs->gumr_l, gumr_l); } +EXPORT_SYMBOL (ucc_slow_disable);/* Initialize the UCC for Slow operations *
@@ -347,6 +354,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc *uccs_ret = uccs;return 0 ; } +EXPORT_SYMBOL (ucc_slow_init);void ucc_slow_free (struct ucc_slow_private * uccs) {
@@ -366,5 +374,5 @@ void ucc_slow_free(struct ucc_slow_private * uccs)kfree (uccs); } - +EXPORT_SYMBOL (ucc_slow_free);
drivers/serial/Kconfig +10 -0
@@ -1284,4 +1284,14 @@ config SERIAL_OF_PLATFORM Currently, only 8250 compatible ports are supported, but others can easily be added. +config SERIAL_QE + tristate "Freescale QUICC Engine serial port support" + depends on QUICC_ENGINE + select SERIAL_CORE + select FW_LOADER + default n + help + This driver supports the QE serial ports on Freescale embedded + PowerPC that contain a QUICC Engine. + endmenu
drivers/serial/Makefile +1 -0
@@ -64,3 +64,4 @@ obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o obj-$(CONFIG_SERIAL_NETX) += netx-serial.o obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o +obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
drivers/serial/ucc_uart.c new file +1498 -0
1,498 lines not on this page · raw message
Signature · 1 line
1.5.2.4
Quoted 15 lines · Timur Tabi
Add support for UART serial ports using a Freescale QUICC Engine (found on some MPC83xx and MPC85xx SOCs).
Updated booting-without-of.txt to define new properties for a QE UART node, and a new node definition that describes uploaded QE firmware.
Because of a silicon bug in some QE-enabled SOCs (e.g. 8323 and 8360), a new microcode is required. This microcode implements UART via a work-around, hence it's called "Soft-UART". This driver can use the QE firmware upload feature to upload the correct microcode to the QE.
Signed-off-by Timur Tabi <[email protected]>---
arch/powerpc/boot/dts/mpc832x_mds.dts line 285
Quoted 7 lines
arch/powerpc/boot/dts/mpc832x_mds.dts +4
-0@@ -250,6 +279,26 @@ pio-handle = < &pio4 >; }; + ucc@2400 { + device_type = "serial"; + compatible = "ucc_uart"; + model = "UCC";
model isn't used, is it needed at all?
Quoted 13 lines
arch/powerpc/boot/dts/mpc832x_mds.dts +13
-0+ device-id = <5>; /* The UCC number, 1-7*/ + port-number = <0>; /* Which ttyQEx device */ + soft-uart; /* We need Soft-UART */ + reg = <2400 200>; + interrupts = <28>; /* From Table 18-12 */ + interrupt-parent = < &qeic >; + /* + * For Soft-UART, we need to set TX to 1X, which + * means specifying separate clock sources. + */ + rx-clock-name = "brg5"; + tx-clock-name = "brg6"; + pio-handle = < &pio5 >;
[...]
drivers/serial/ucc_uart.c line 1206
Quoted 7 lines
drivers/serial/ucc_uart.c new file +7
-0+if (soft_uart) { +struct qe_firmware_info *qe_fw_info; + + qe_fw_info =qe_get_firmware_info (); + +/* Check if the firmware has been uploaded. */ +if (strstr (qe_fw_info->id,"Soft-UART" )) {
qe_fw_info used w/o NULL checking.
Quoted 23 lines
drivers/serial/ucc_uart.c new file +23
-0+ firmware_loaded =1 ; + }else { +char filename[32 ]; +unsigned int soc; +unsigned int rev_h; +unsigned int rev_l; + + soc =soc_info (&rev_h, &rev_l); +if (!soc) { +dev_err (&ofdev->dev,"unknown CPU model\n" ); +return -ENXIO ; + } +sprintf (filename,"fsl_qe_ucode_uart_%u_%u%u.bin" , + soc, rev_h, rev_l); + +dev_info (&ofdev->dev,"waiting for firmware %s\n" , + filename); + +/* +* We call request_firmware_nowait instead of +* request_firmware so that the driver can load and +* initialize the ports without holding up the rest of +* the kernel. If hotplug support is enabled in the
[...]
drivers/serial/ucc_uart.c line 1337
Quoted 10 lines
drivers/serial/ucc_uart.c new file +10
-0+ + qe_port->port.irq =irq_of_parse_and_map (np,0 ); +if (qe_port->port.irq ==NO_IRQ ) { +dev_err (&ofdev->dev,"could not map IRQ for UCC%u\n" , + qe_port->ucc_num +1 ); +kfree (qe_port); +return -EINVAL ; + } + + np =of_find_node_by_type (NULL ,"qe" );
Please, add "fsl,qe" compatible matching.
Quoted 6 lines
drivers/serial/ucc_uart.c new file +6
-0+if (!np) { +dev_err (&ofdev->dev,"could not find parent 'qe' node\n" ); +kfree (qe_port); +return -EINVAL ; + } +
[...]
drivers/serial/ucc_uart.c line 1453
Quoted 3 lines
drivers/serial/ucc_uart.c new file +3
-0+static struct of_platform_driver ucc_uart_of_driver = { + .owner =THIS_MODULE , + .name ="ucc_uart" ,
Maybe better fsl,ucc_uart?
Thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2
Quoted 6 lines · Anton Vorontsov
arch/powerpc/boot/dts/mpc832x_mds.dts line 285
Quoted 4 lines
arch/powerpc/boot/dts/mpc832x_mds.dts +4
-0+ ucc@2400 { + device_type = "serial"; + compatible = "ucc_uart"; + model = "UCC";model isn't used, is it needed at all?
I have no idea, but all the other UCC nodes have it, so I'm going to keep it. Maybe one day we'll merge QE and CPM drivers, so this would be useful.
Quoted 9 lines
drivers/serial/ucc_uart.c line 1206
Quoted 7 lines
drivers/serial/ucc_uart.c new file +7
-0+if (soft_uart) { +struct qe_firmware_info *qe_fw_info; + + qe_fw_info =qe_get_firmware_info (); + +/* Check if the firmware has been uploaded. */ +if (strstr (qe_fw_info->id,"Soft-UART" )) {
qe_fw_infoused w/o NULL checking.
Ok.
Quoted 13 lines
[...]
drivers/serial/ucc_uart.c line 1337
Quoted 10 lines
drivers/serial/ucc_uart.c new file +10
-0+ + qe_port->port.irq =irq_of_parse_and_map (np,0 ); +if (qe_port->port.irq ==NO_IRQ ) { +dev_err (&ofdev->dev,"could not map IRQ for UCC%u\n" , + qe_port->ucc_num +1 ); +kfree (qe_port); +return -EINVAL ; + } + + np =of_find_node_by_type (NULL ,"qe" );Please, add "fsl,qe" compatible matching.
Ok.
Quoted 5 lines
drivers/serial/ucc_uart.c line 1453
Quoted 3 lines
drivers/serial/ucc_uart.c new file +3
-0+static struct of_platform_driver ucc_uart_of_driver = { + .owner =THIS_MODULE , + .name ="ucc_uart" ,Maybe better fsl,ucc_uart?
The CPM serial driver uses "cpm_uart" and the QE ethernet driver uses "ucc_geth", so ucc_uart matches the pattern.
Quoted 9 lines · Timur Tabi
Quoted 6 lines · Anton Vorontsov
arch/powerpc/boot/dts/mpc832x_mds.dts line 285
Quoted 4 lines
arch/powerpc/boot/dts/mpc832x_mds.dts +4
-0+ ucc@2400 { + device_type = "serial"; + compatible = "ucc_uart"; + model = "UCC";model isn't used, is it needed at all?
Quoted 3 lines
I have no idea, but all the other UCC nodes have it, so I'm going to keep it. Maybe one day we'll merge QE and CPM drivers, so this would be useful.
No, it wouldn't -- that's what compatible is for.
Quoted 5 lines
Quoted 5 lines
drivers/serial/ucc_uart.c line 1453
Quoted 3 lines
drivers/serial/ucc_uart.c new file +3
-0+static struct of_platform_driver ucc_uart_of_driver = { + .owner =THIS_MODULE , + .name ="ucc_uart" ,Maybe better fsl,ucc_uart?
fsl,qe-uart is defined by Documentation/powerpc/booting-without-of.txt.
Quoted 2 lines
The CPM serial driver uses "
cpm_uart" and the QE ethernet driver uses "ucc_geth", soucc_uartmatches the pattern.
cpm_uart is a legacy match -- the current binding specifies fsl,cpm1-smc-uart, fsl,cpm2-scc-uart, etc.
-Scott
Quoted 6 lines · Scott Wood
Quoted 4 lines
Quoted 4 lines
drivers/serial/ucc_uart.c line 1453
Quoted 3 lines
drivers/serial/ucc_uart.c new file +3
-0+static struct of_platform_driver ucc_uart_of_driver = { + .owner =THIS_MODULE , + .name ="ucc_uart" ,Maybe better fsl,ucc_uart?
fsl,qe-uart is defined by
Documentation/powerpc/booting-without-of.txt.
Wait, I'm confused. What does the of_platform_driver.name string have to do with the compatible field in the device tree? Like I said earlier, I'm just following the example of the other QE device drivers. If you want me to break that example, I'm going to need an explanation why the other drivers do it wrong.
Signature · 2 lines
Timur Tabi Linux Kernel Developer @ Freescale
Quoted 10 lines · Timur Tabi
Quoted 6 lines · Scott Wood
Quoted 4 lines
Quoted 4 lines
drivers/serial/ucc_uart.c line 1453
Quoted 3 lines
drivers/serial/ucc_uart.c new file +3
-0+static struct of_platform_driver ucc_uart_of_driver = { + .owner =THIS_MODULE , + .name ="ucc_uart" ,Maybe better fsl,ucc_uart?
fsl,qe-uart is defined by
Documentation/powerpc/booting-without-of.txt.Wait, I'm confused. What does the of_platform_driver.name string have to do with the compatible field in the device tree?
Bah. Details.
/me resolves to read the context next time.
-Scott
Quoted 11 lines · Timur Tabi
Quoted 6 lines · Scott Wood
Quoted 4 lines
Quoted 4 lines
drivers/serial/ucc_uart.c line 1453
Quoted 3 lines
drivers/serial/ucc_uart.c new file +3
-0+static struct of_platform_driver ucc_uart_of_driver = { + .owner =THIS_MODULE , + .name ="ucc_uart" ,Maybe better fsl,ucc_uart?
fsl,qe-uart is defined by
Documentation/powerpc/booting-without-of.txt.Wait, I'm confused. What does the of_platform_driver.name string have to do with the compatible field in the device tree? Like I said earlier, I'm just
Eh, initially I meant compatible stuff, not the driver name. I've quoted wrong code snippet, thus the confusion.
You're using "ucc_uart" for compatible matching:
drivers/serial/ucc_uart.c line 1445
Quoted 4 lines
drivers/serial/ucc_uart.c new file +4
-0+static struct of_device_id ucc_uart_match[] = { + { + .type ="serial" , + .compatible ="ucc_uart" ,
here "fsl,qe-uart" will look better, no?
drivers/serial/ucc_uart.c line 1449
Quoted 4 lines
drivers/serial/ucc_uart.c new file +4
-0+ }, + {}, +}; +MODULE_DEVICE_TABLE (of, ucc_uart_match);
Thanks,
Signature · 4 lines
Anton Vorontsov email: [email protected] backup email: [email protected] irc://irc.freenode.net/bd2