mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	serial: imx: remove the uart_console() check
The uart_console() check makes the clocks(clk_per and clk_ipg) opened even when we close the console uart. This patch enable/disable the clocks in imx_console_write(), so we can keep the clocks closed when the console uart is closed. Also remove the clock enable/disable oprations in the probe, we do not need them any more. Signed-off-by: Huang Shijie <b32955@freescale.com> Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									43b829b3c1
								
							
						
					
					
						commit
						1cf93e0d54
					
				
					 1 changed files with 43 additions and 26 deletions
				
			
		| 
						 | 
					@ -701,15 +701,13 @@ static int imx_startup(struct uart_port *port)
 | 
				
			||||||
	int retval;
 | 
						int retval;
 | 
				
			||||||
	unsigned long flags, temp;
 | 
						unsigned long flags, temp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!uart_console(port)) {
 | 
						retval = clk_prepare_enable(sport->clk_per);
 | 
				
			||||||
		retval = clk_prepare_enable(sport->clk_per);
 | 
						if (retval)
 | 
				
			||||||
		if (retval)
 | 
							goto error_out1;
 | 
				
			||||||
			goto error_out1;
 | 
						retval = clk_prepare_enable(sport->clk_ipg);
 | 
				
			||||||
		retval = clk_prepare_enable(sport->clk_ipg);
 | 
						if (retval) {
 | 
				
			||||||
		if (retval) {
 | 
							clk_disable_unprepare(sport->clk_per);
 | 
				
			||||||
			clk_disable_unprepare(sport->clk_per);
 | 
							goto error_out1;
 | 
				
			||||||
			goto error_out1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	imx_setup_ufcr(sport, 0);
 | 
						imx_setup_ufcr(sport, 0);
 | 
				
			||||||
| 
						 | 
					@ -900,10 +898,8 @@ static void imx_shutdown(struct uart_port *port)
 | 
				
			||||||
	writel(temp, sport->port.membase + UCR1);
 | 
						writel(temp, sport->port.membase + UCR1);
 | 
				
			||||||
	spin_unlock_irqrestore(&sport->port.lock, flags);
 | 
						spin_unlock_irqrestore(&sport->port.lock, flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!uart_console(&sport->port)) {
 | 
						clk_disable_unprepare(sport->clk_per);
 | 
				
			||||||
		clk_disable_unprepare(sport->clk_per);
 | 
						clk_disable_unprepare(sport->clk_ipg);
 | 
				
			||||||
		clk_disable_unprepare(sport->clk_ipg);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -1250,6 +1246,16 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
 | 
				
			||||||
	unsigned int ucr1;
 | 
						unsigned int ucr1;
 | 
				
			||||||
	unsigned long flags = 0;
 | 
						unsigned long flags = 0;
 | 
				
			||||||
	int locked = 1;
 | 
						int locked = 1;
 | 
				
			||||||
 | 
						int retval;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						retval = clk_enable(sport->clk_per);
 | 
				
			||||||
 | 
						if (retval)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						retval = clk_enable(sport->clk_ipg);
 | 
				
			||||||
 | 
						if (retval) {
 | 
				
			||||||
 | 
							clk_disable(sport->clk_per);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (sport->port.sysrq)
 | 
						if (sport->port.sysrq)
 | 
				
			||||||
		locked = 0;
 | 
							locked = 0;
 | 
				
			||||||
| 
						 | 
					@ -1285,6 +1291,9 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (locked)
 | 
						if (locked)
 | 
				
			||||||
		spin_unlock_irqrestore(&sport->port.lock, flags);
 | 
							spin_unlock_irqrestore(&sport->port.lock, flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						clk_disable(sport->clk_ipg);
 | 
				
			||||||
 | 
						clk_disable(sport->clk_per);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					@ -1358,6 +1367,7 @@ imx_console_setup(struct console *co, char *options)
 | 
				
			||||||
	int bits = 8;
 | 
						int bits = 8;
 | 
				
			||||||
	int parity = 'n';
 | 
						int parity = 'n';
 | 
				
			||||||
	int flow = 'n';
 | 
						int flow = 'n';
 | 
				
			||||||
 | 
						int retval;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Check whether an invalid uart number has been specified, and
 | 
						 * Check whether an invalid uart number has been specified, and
 | 
				
			||||||
| 
						 | 
					@ -1370,6 +1380,11 @@ imx_console_setup(struct console *co, char *options)
 | 
				
			||||||
	if (sport == NULL)
 | 
						if (sport == NULL)
 | 
				
			||||||
		return -ENODEV;
 | 
							return -ENODEV;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* For setting the registers, we only need to enable the ipg clock. */
 | 
				
			||||||
 | 
						retval = clk_prepare_enable(sport->clk_ipg);
 | 
				
			||||||
 | 
						if (retval)
 | 
				
			||||||
 | 
							goto error_console;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (options)
 | 
						if (options)
 | 
				
			||||||
		uart_parse_options(options, &baud, &parity, &bits, &flow);
 | 
							uart_parse_options(options, &baud, &parity, &bits, &flow);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					@ -1377,7 +1392,20 @@ imx_console_setup(struct console *co, char *options)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	imx_setup_ufcr(sport, 0);
 | 
						imx_setup_ufcr(sport, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return uart_set_options(&sport->port, co, baud, parity, bits, flow);
 | 
						retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						clk_disable(sport->clk_ipg);
 | 
				
			||||||
 | 
						if (retval) {
 | 
				
			||||||
 | 
							clk_unprepare(sport->clk_ipg);
 | 
				
			||||||
 | 
							goto error_console;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						retval = clk_prepare(sport->clk_per);
 | 
				
			||||||
 | 
						if (retval)
 | 
				
			||||||
 | 
							clk_disable_unprepare(sport->clk_ipg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error_console:
 | 
				
			||||||
 | 
						return retval;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct uart_driver imx_reg;
 | 
					static struct uart_driver imx_reg;
 | 
				
			||||||
| 
						 | 
					@ -1555,9 +1583,6 @@ static int serial_imx_probe(struct platform_device *pdev)
 | 
				
			||||||
		return ret;
 | 
							return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clk_prepare_enable(sport->clk_per);
 | 
					 | 
				
			||||||
	clk_prepare_enable(sport->clk_ipg);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sport->port.uartclk = clk_get_rate(sport->clk_per);
 | 
						sport->port.uartclk = clk_get_rate(sport->clk_per);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	imx_ports[sport->port.line] = sport;
 | 
						imx_ports[sport->port.line] = sport;
 | 
				
			||||||
| 
						 | 
					@ -1566,7 +1591,7 @@ static int serial_imx_probe(struct platform_device *pdev)
 | 
				
			||||||
	if (pdata && pdata->init) {
 | 
						if (pdata && pdata->init) {
 | 
				
			||||||
		ret = pdata->init(pdev);
 | 
							ret = pdata->init(pdev);
 | 
				
			||||||
		if (ret)
 | 
							if (ret)
 | 
				
			||||||
			goto clkput;
 | 
								return ret;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = uart_add_one_port(&imx_reg, &sport->port);
 | 
						ret = uart_add_one_port(&imx_reg, &sport->port);
 | 
				
			||||||
| 
						 | 
					@ -1574,18 +1599,10 @@ static int serial_imx_probe(struct platform_device *pdev)
 | 
				
			||||||
		goto deinit;
 | 
							goto deinit;
 | 
				
			||||||
	platform_set_drvdata(pdev, sport);
 | 
						platform_set_drvdata(pdev, sport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!uart_console(&sport->port)) {
 | 
					 | 
				
			||||||
		clk_disable_unprepare(sport->clk_per);
 | 
					 | 
				
			||||||
		clk_disable_unprepare(sport->clk_ipg);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
deinit:
 | 
					deinit:
 | 
				
			||||||
	if (pdata && pdata->exit)
 | 
						if (pdata && pdata->exit)
 | 
				
			||||||
		pdata->exit(pdev);
 | 
							pdata->exit(pdev);
 | 
				
			||||||
clkput:
 | 
					 | 
				
			||||||
	clk_disable_unprepare(sport->clk_per);
 | 
					 | 
				
			||||||
	clk_disable_unprepare(sport->clk_ipg);
 | 
					 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue