mirror of
				git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
				synced 2025-10-31 16:54:21 +00:00 
			
		
		
		
	cpm_uart: Add generic clock API support to set baudrates
This patch introduces baudrate setting support via the generic clock API. When present the optional device tree clock property is used instead of fsl-cpm-brg. Platforms can then define complex clock schemes, to output the serial clock on an external pin for instance. Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
		
							parent
							
								
									7485d26b7e
								
							
						
					
					
						commit
						80776554b6
					
				
					 3 changed files with 21 additions and 7 deletions
				
			
		|  | @ -283,6 +283,7 @@ config FSL_ULI1575 | |||
| 
 | ||||
| config CPM | ||||
| 	bool | ||||
| 	select PPC_CLOCK | ||||
| 
 | ||||
| config OF_RTC | ||||
| 	bool | ||||
|  |  | |||
|  | @ -77,6 +77,7 @@ struct uart_cpm_port { | |||
| 	unsigned char		*rx_buf; | ||||
| 	u32			flags; | ||||
| 	void			(*set_lineif)(struct uart_cpm_port *); | ||||
| 	struct clk		*clk; | ||||
| 	u8			brg; | ||||
| 	uint			 dp_addr; | ||||
| 	void			*mem_addr; | ||||
|  |  | |||
|  | @ -45,6 +45,7 @@ | |||
| #include <linux/of_platform.h> | ||||
| #include <linux/gpio.h> | ||||
| #include <linux/of_gpio.h> | ||||
| #include <linux/clk.h> | ||||
| 
 | ||||
| #include <asm/io.h> | ||||
| #include <asm/irq.h> | ||||
|  | @ -596,6 +597,9 @@ static void cpm_uart_set_termios(struct uart_port *port, | |||
| 		out_be16(&sccp->scc_psmr, (sbits << 12) | scval); | ||||
| 	} | ||||
| 
 | ||||
| 	if (pinfo->clk) | ||||
| 		clk_set_rate(pinfo->clk, baud); | ||||
| 	else | ||||
| 		cpm_set_brg(pinfo->brg - 1, baud); | ||||
| 	spin_unlock_irqrestore(&port->lock, flags); | ||||
| } | ||||
|  | @ -1023,6 +1027,13 @@ static int cpm_uart_init_port(struct device_node *np, | |||
| 	int ret; | ||||
| 	int i; | ||||
| 
 | ||||
| 	data = of_get_property(np, "clock", NULL); | ||||
| 	if (data) { | ||||
| 		struct clk *clk = clk_get(NULL, (const char*)data); | ||||
| 		if (!IS_ERR(clk)) | ||||
| 			pinfo->clk = clk; | ||||
| 	} | ||||
| 	if (!pinfo->clk) { | ||||
| 		data = of_get_property(np, "fsl,cpm-brg", &len); | ||||
| 		if (!data || len != 4) { | ||||
| 			printk(KERN_ERR "CPM UART %s has no/invalid " | ||||
|  | @ -1030,6 +1041,7 @@ static int cpm_uart_init_port(struct device_node *np, | |||
| 			return -EINVAL; | ||||
| 		} | ||||
| 		pinfo->brg = *data; | ||||
| 	} | ||||
| 
 | ||||
| 	data = of_get_property(np, "fsl,cpm-command", &len); | ||||
| 	if (!data || len != 4) { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Laurent Pinchart
						Laurent Pinchart