cpm2: Reset the CPM at startup and fix the cpm_uart driver accordingly.
Subsystems (2)
v4 cover cpm2: Reset the CPM at startup and fix the cpm_uart driver accordingly.
Hi everybody,
these 5 patches reset the CPM in cpm2_reset() and fix the cpm_uart driver to initialise SMC ports correctly without relying on any initialisation performed by the boot loader/wrapper. They update the boot wrapper code and the EP8248E device tree to match the new SMC registers description.
Patches 2/5, 3/5 and 4/5 (boot wrapper and EP8248E device tree updates) haven't been tested due to lack of hardware.
Signature · 9 lines
Laurent Pinchart CSE Semaphore Belgium Chaussée de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75
PATCH v4 1/5 cpm_uart: Allocate DPRAM memory for SMC ports on CPM2-based platforms.
This patch allocates parameter RAM for SMC serial ports without relying on previous initialisation by a boot loader or a wrapper layer.
SMC parameter RAM on CPM2-based platforms can be allocated anywhere in the general-purpose areas of the dual-port RAM. The current code relies on the boot loader to allocate a section of general-purpose CPM RAM and gets the section address from the device tree.
This patch modifies the device tree address usage to reference the SMC parameter RAM base pointer instead of a pre-allocated RAM section and allocates memory from the CPM dual-port RAM when initialising the SMC port. CPM1-based platforms are not affected.
--- drivers/serial/cpm_uart/cpm_uart.h | 3 ++ drivers/serial/cpm_uart/cpm_uart_core.c | 19 +++++------ drivers/serial/cpm_uart/cpm_uart_cpm1.c | 12 +++++++ drivers/serial/cpm_uart/cpm_uart_cpm2.c | 52 +++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 10 deletions(-)
drivers/serial/cpm_uart/cpm_uart.h +3 -0
@@ -93,6 +93,9 @@ extern struct uart_cpm_port cpm_uart_ports[UART_NR];/* these are located in their respective files */ void cpm_line_cr_cmd (struct uart_cpm_port *port,int cmd); +void __iomem *cpm_uart_map_pram (struct uart_cpm_port *port, +struct device_node *np); +void cpm_uart_unmap_pram (struct uart_cpm_port *port,void __iomem *pram);int cpm_uart_init_portdesc (void );int cpm_uart_allocbuf (struct uart_cpm_port *pinfo,unsigned int is_con);void cpm_uart_freebuf (struct uart_cpm_port *pinfo);
drivers/serial/cpm_uart/cpm_uart_core.c +9 -10
@@ -997,24 +997,23 @@ static int cpm_uart_init_port(struct device_node *np,if (!mem)return -ENOMEM ; - pram =of_iomap (np,1 ); -if (!pram) { - ret = -ENOMEM ; - goto out_mem; - } -if (of_device_is_compatible (np,"fsl,cpm1-scc-uart" ) ||of_device_is_compatible (np,"fsl,cpm2-scc-uart" )) { pinfo->sccp = mem; - pinfo->sccup = pram; + pinfo->sccup = pram =cpm_uart_map_pram (pinfo, np); }else if (of_device_is_compatible (np,"fsl,cpm1-smc-uart" ) ||of_device_is_compatible (np,"fsl,cpm2-smc-uart" )) { pinfo->flags |=FLAG_SMC ; pinfo->smcp = mem; - pinfo->smcup = pram; + pinfo->smcup = pram =cpm_uart_map_pram (pinfo, np); }else { ret = -ENODEV ; - goto out_pram; + goto out_mem; + } + +if (!pram) { + ret = -ENOMEM ; + goto out_mem; } pinfo->tx_nrfifos =TX_NUM_FIFO ;
@@ -1038,7 +1037,7 @@ static int cpm_uart_init_port(struct device_node *np,return cpm_uart_request_port (&pinfo->port); out_pram: -iounmap (pram); +cpm_uart_unmap_pram (pinfo, pram); out_mem:iounmap (mem);return ret;
drivers/serial/cpm_uart/cpm_uart_cpm1.c +12 -0
@@ -54,6 +54,18 @@ void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) {cpm_command (port->command, cmd); } + +void __iomem *cpm_uart_map_pram (struct uart_cpm_port *port, +struct device_node *np) +{ +return of_iomap (np,1 ); +} + +void cpm_uart_unmap_pram (struct uart_cpm_port *port,void __iomem *pram) +{ +iounmap (pram); +} +#else void cpm_line_cr_cmd (struct uart_cpm_port *port,int cmd) {
drivers/serial/cpm_uart/cpm_uart_cpm2.c +52 -0
64 lines not on this page · raw message
Signature · 13 lines
1.5.0 -- Laurent Pinchart CSE Semaphore Belgium Chaussée de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75
PATCH v4 2/5 powerpc: Add bootwrapper function to get virtual reg from the device tree.
In reply to Laurent PinchartThis patch adds a new generic device tree processing function that retrieves virtual reg addresses from the device tree to the bootwrapper code. It also updates the bootwrapper code to use the new function.
dt_get_virtual_reg() retrieves the virtual reg addresses from the "virtual-reg" property. If the property can't be found, it uses the "reg" property and walks the tree to translate it to absolute addresses.
--- arch/powerpc/boot/cpm-serial.c | 34 ++++++---------------------------- arch/powerpc/boot/devtree.c | 20 ++++++++++++++++++++ arch/powerpc/boot/mpc52xx-psc.c | 9 ++------- arch/powerpc/boot/ns16550.c | 10 ++-------- arch/powerpc/boot/ops.h | 1 + 5 files changed, 31 insertions(+), 43 deletions(-)
arch/powerpc/boot/cpm-serial.c +6 -28
@@ -177,7 +177,6 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp) {void *reg_virt[2 ];int is_smc =0 , is_cpm2 =0 , n; -unsigned long reg_phys;void *parent, *muram;if (dt_is_compatible (devp,"fsl,cpm1-smc-uart" )) {
@@ -206,15 +205,8 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)if (n <4 )return -1 ; - n =getprop (devp,"virtual-reg" , reg_virt,sizeof (reg_virt)); -if (n < (int )sizeof (reg_virt)) { -for (n =0 ; n <2 ; n++) { -if (!dt_xlate_reg (devp, n, ®_phys,NULL )) -return -1 ; - - reg_virt[n] = (void *)reg_phys; - } - } +if (dt_get_virtual_reg (devp, reg_virt,2 ) <2 ) +return -1 ;if (is_smc) smc = reg_virt[0 ];
@@ -227,15 +219,8 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)if (!parent)return -1 ; - n =getprop (parent,"virtual-reg" , reg_virt,sizeof (reg_virt)); -if (n < (int )sizeof (reg_virt)) { -if (!dt_xlate_reg (parent,0 , ®_phys,NULL )) -return -1 ; - - reg_virt[0 ] = (void *)reg_phys; - } - - cpcr = reg_virt[0 ]; +if (dt_get_virtual_reg (parent, &cpcr,1 ) <1 ) +return -1 ; muram =finddevice ("/soc/cpm/muram/data" );if (!muram)
@@ -246,15 +231,8 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)* is one for both parent and child. */ - n =getprop (muram,"virtual-reg" , reg_virt,sizeof (reg_virt)); -if (n < (int )sizeof (reg_virt)) { -if (!dt_xlate_reg (muram,0 , ®_phys,NULL )) -return -1 ; - - reg_virt[0 ] = (void *)reg_phys; - } - - muram_start = reg_virt[0 ]; +if (dt_get_virtual_reg (muram, (void **)&muram_start,1 ) <1 ) +return -1 ; n =getprop (muram,"reg" , &muram_offset,4 );if (n <4 )
arch/powerpc/boot/devtree.c +20 -0
@@ -350,3 +350,23 @@ int dt_is_compatible(void *node, const char *compat)return 0 ; } + +int dt_get_virtual_reg (void *node,void **addr,int nres) +{ +unsigned long xaddr; +int n; + + n =getprop (node,"virtual-reg" , addr, nres *4 ); +if (n >0 ) +return n /4 ; + +for (n =0 ; n < nres; n++) { +if (!dt_xlate_reg (node, n, &xaddr,NULL )) +break ; + + addr[n] = (void *)xaddr; + } + +return n; +} +
arch/powerpc/boot/mpc52xx-psc.c +2 -7
@@ -51,14 +51,9 @@ static unsigned char psc_getc(void)int mpc5200_psc_console_init (void *devp,struct serial_console_data *scdp) { -int n; -/* Get the base address of the psc registers */ - n =getprop (devp,"virtual-reg" , &psc,sizeof (psc)); -if (n !=sizeof (psc)) { -if (!dt_xlate_reg (devp,0 , (void *)&psc,NULL )) -return -1 ; - } +if (dt_get_virtual_reg (devp, &psc,1 ) <1 ) +return -1 ; scdp->open = psc_open; scdp->putc = psc_putc;
arch/powerpc/boot/ns16550.c +2 -8
@@ -55,15 +55,9 @@ static u8 ns16550_tstc(void)int ns16550_console_init (void *devp,struct serial_console_data *scdp) {int n; -unsigned long reg_phys; - n =getprop (devp,"virtual-reg" , ®_base,sizeof (reg_base)); -if (n !=sizeof (reg_base)) { -if (!dt_xlate_reg (devp,0 , ®_phys,NULL )) -return -1 ; - - reg_base = (void *)reg_phys; - } +if (dt_get_virtual_reg (devp, (void **)®_base,1 ) <1 ) +return -1 ; n =getprop (devp,"reg-shift" , ®_shift,sizeof (reg_shift));if (n !=sizeof (reg_shift))
arch/powerpc/boot/ops.h +1 -0
@@ -95,6 +95,7 @@ int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);int dt_xlate_addr (void *node,u32 *buf,int buflen,unsigned long *xlated_addr);int dt_is_compatible (void *node,const char *compat);void dt_get_reg_format (void *node,u32 *naddr,u32 *nsize); +int dt_get_virtual_reg (void *node,void **addr,int nres);static inline void *finddevice (const char *name) {
Signature · 13 lines
1.5.0 -- Laurent Pinchart CSE Semaphore Belgium Chaussée de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75
PATCH v4 3/5 cpm-serial: Relocate CPM buffer descriptors and SMC parameter ram.
In reply to Laurent PinchartThis patch relocates the buffer descriptors and the SMC parameter RAM at the end of the first CPM muram chunk, as described in the device tree. This allows device trees to stop excluding SMC parameter ram allocated by the boot loader from the CPM muram node.
--- arch/powerpc/Kconfig.debug | 2 +- arch/powerpc/boot/cpm-serial.c | 89 ++++++++++++++++++++++++++++++--------- 2 files changed, 69 insertions(+), 22 deletions(-)
arch/powerpc/Kconfig.debug +1 -1
@@ -269,7 +269,7 @@ config PPC_EARLY_DEBUG_CPM_ADDR hex "CPM UART early debug transmit descriptor address" depends on PPC_EARLY_DEBUG_CPM default "0xfa202008" if PPC_EP88XC - default "0xf0000008" if CPM2 + default "0xf0001ff8" if CPM2 default "0xff002008" if CPM1 help This specifies the address of the transmit descriptor
arch/powerpc/boot/cpm-serial.c +68 -21
155 lines not on this page · raw message
Signature · 13 lines
1.5.0 -- Laurent Pinchart CSE Semaphore Belgium Chaussée de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75
PATCH v4 4/5 ep8248e: Reference SMC parameter RAM base in the device tree.
In reply to Laurent PinchartThis patch modifies the Embedded Planet EP8248E device tree to reference the SMC paramater RAM base register instead of the parameter RAM allocated by the boot loader.
The cpm_uart driver will allocate parameter RAM itself, making the serial port initialisation independent of the boot loader.
The patch adds the parameter RAM allocated by the boot loader in the CPM muram node, making it available to the kernel.
--- arch/powerpc/boot/dts/ep8248e.dts | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/boot/dts/ep8248e.dts +2 -3
@@ -121,8 +121,7 @@ data@0 { compatible = "fsl,cpm-muram-data"; - reg = <0 0x1100 0x1140 - 0xec0 0x9800 0x800>; + reg = <0 0x2000 0x9800 0x800>; }; };
@@ -138,7 +137,7 @@ device_type = "serial"; compatible = "fsl,mpc8248-smc-uart", "fsl,cpm2-smc-uart"; - reg = <0x11a80 0x20 0x1100 0x40>; + reg = <0x11a80 0x20 0x87fc 2>; interrupts = <4 8>; interrupt-parent = <&PIC>; fsl,cpm-brg = <7>;
Signature · 13 lines
1.5.0 -- Laurent Pinchart CSE Semaphore Belgium Chaussée de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75
PATCH v4 5/5 cpm2: Reset the CPM when early debugging is not enabled.
In reply to Laurent PinchartSimilarly to what is done for PQ1-based platforms, this patch resets the PQ2 Communication Processor Module in cpm2_reset() when early debugging is not enabled. This helps avoiding conflicts when the boot loader configured the CPM in an unexpected way.
--- arch/powerpc/sysdev/cpm2.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
arch/powerpc/sysdev/cpm2.c +6 -0
@@ -80,6 +80,12 @@ void __init cpm2_reset(void)/* Tell everyone where the comm processor resides. */ cpmp = &cpm2_immr->im_cpm; + +#ifndef CONFIG_PPC_EARLY_DEBUG_CPM +/* Reset the CPM. +*/ +cpm_command (CPM_CR_RST ,0 ); +#endif }static DEFINE_SPINLOCK (cmd_lock);
Signature · 13 lines
1.5.0 -- Laurent Pinchart CSE Semaphore Belgium Chaussée de Bruxelles, 732A B-1410 Waterloo Belgium T +32 (2) 387 42 59 F +32 (2) 387 42 75
Quoted 6 lines · Laurent Pinchart
Hi everybody,
these 5 patches reset the CPM in
cpm2_reset()and fix thecpm_uartdriver to initialise SMC ports correctly without relying on any initialisation performed by the boot loader/wrapper. They update the boot wrapper code and the EP8248E device tree to match the new SMC registers description.Patches 2/5, 3/5 and 4/5 (boot wrapper and EP8248E device tree updates) haven't been tested due to lack of hardware.
Tested OK on ep8248e.
ACK 1-5
-Scott
Kumar Gala
AppliedQuoted 9 lines · Laurent Pinchart
Hi everybody,
these 5 patches reset the CPM in
cpm2_reset()and fix thecpm_uartdriver to initialise SMC ports correctly without relying on any initialisation performed by the boot loader/wrapper. They update the boot wrapper code and the EP8248E device tree to match the new SMC registers description.Patches 2/5, 3/5 and 4/5 (boot wrapper and EP8248E device tree updates) haven't been tested due to lack of hardware.
applied.
- k