| 
									
										
										
										
											2007-06-05 16:36:55 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * TI DaVinci clock definitions | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  |  * Copyright (C) 2006-2007 Texas Instruments. | 
					
						
							|  |  |  |  * Copyright (C) 2008-2009 Deep Root Systems, LLC | 
					
						
							| 
									
										
										
										
											2007-06-05 16:36:55 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License version 2 as | 
					
						
							|  |  |  |  * published by the Free Software Foundation. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __ARCH_ARM_DAVINCI_CLOCK_H
 | 
					
						
							|  |  |  | #define __ARCH_ARM_DAVINCI_CLOCK_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | #define DAVINCI_PLL1_BASE 0x01c40800
 | 
					
						
							|  |  |  | #define DAVINCI_PLL2_BASE 0x01c40c00
 | 
					
						
							|  |  |  | #define MAX_PLL 2
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* PLL/Reset register offsets */ | 
					
						
							|  |  |  | #define PLLCTL          0x100
 | 
					
						
							|  |  |  | #define PLLCTL_PLLEN    BIT(0)
 | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:03 +05:30
										 |  |  | #define PLLCTL_PLLPWRDN	BIT(1)
 | 
					
						
							|  |  |  | #define PLLCTL_PLLRST	BIT(3)
 | 
					
						
							|  |  |  | #define PLLCTL_PLLDIS	BIT(4)
 | 
					
						
							|  |  |  | #define PLLCTL_PLLENSRC	BIT(5)
 | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | #define PLLCTL_CLKMODE  BIT(8)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PLLM		0x110
 | 
					
						
							|  |  |  | #define PLLM_PLLM_MASK  0xff
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PREDIV          0x114
 | 
					
						
							|  |  |  | #define PLLDIV1         0x118
 | 
					
						
							|  |  |  | #define PLLDIV2         0x11c
 | 
					
						
							|  |  |  | #define PLLDIV3         0x120
 | 
					
						
							|  |  |  | #define POSTDIV         0x128
 | 
					
						
							|  |  |  | #define BPDIV           0x12c
 | 
					
						
							|  |  |  | #define PLLCMD		0x138
 | 
					
						
							|  |  |  | #define PLLSTAT		0x13c
 | 
					
						
							|  |  |  | #define PLLALNCTL	0x140
 | 
					
						
							|  |  |  | #define PLLDCHANGE	0x144
 | 
					
						
							|  |  |  | #define PLLCKEN		0x148
 | 
					
						
							|  |  |  | #define PLLCKSTAT	0x14c
 | 
					
						
							|  |  |  | #define PLLSYSTAT	0x150
 | 
					
						
							|  |  |  | #define PLLDIV4         0x160
 | 
					
						
							|  |  |  | #define PLLDIV5         0x164
 | 
					
						
							|  |  |  | #define PLLDIV6         0x168
 | 
					
						
							|  |  |  | #define PLLDIV7         0x16c
 | 
					
						
							|  |  |  | #define PLLDIV8         0x170
 | 
					
						
							|  |  |  | #define PLLDIV9         0x174
 | 
					
						
							|  |  |  | #define PLLDIV_EN       BIT(15)
 | 
					
						
							|  |  |  | #define PLLDIV_RATIO_MASK 0x1f
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-16 17:21:33 +05:30
										 |  |  | /*
 | 
					
						
							|  |  |  |  * OMAP-L138 system reference guide recommends a wait for 4 OSCIN/CLKIN | 
					
						
							|  |  |  |  * cycles to ensure that the PLLC has switched to bypass mode. Delay of 1us | 
					
						
							|  |  |  |  * ensures we are good for all > 4MHz OSCIN/CLKIN inputs. Typically the input | 
					
						
							|  |  |  |  * is ~25MHz. Units are micro seconds. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define PLL_BYPASS_TIME		1
 | 
					
						
							|  |  |  | /* From OMAP-L138 datasheet table 6-4. Units are micro seconds */ | 
					
						
							|  |  |  | #define PLL_RESET_TIME		1
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * From OMAP-L138 datasheet table 6-4; assuming prediv = 1, sqrt(pllm) = 4 | 
					
						
							|  |  |  |  * Units are micro seconds. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define PLL_LOCK_TIME		20
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-16 17:21:36 +05:30
										 |  |  | #ifndef __ASSEMBLER__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/list.h>
 | 
					
						
							| 
									
										
										
										
											2010-11-17 10:04:33 +01:00
										 |  |  | #include <linux/clkdev.h>
 | 
					
						
							| 
									
										
										
										
											2009-11-16 17:21:36 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-20 16:46:49 +05:30
										 |  |  | #define PLLSTAT_GOSTAT	BIT(0)
 | 
					
						
							|  |  |  | #define PLLCMD_GOSET	BIT(0)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | struct pll_data { | 
					
						
							|  |  |  | 	u32 phys_base; | 
					
						
							|  |  |  | 	void __iomem *base; | 
					
						
							|  |  |  | 	u32 num; | 
					
						
							|  |  |  | 	u32 flags; | 
					
						
							|  |  |  | 	u32 input_rate; | 
					
						
							| 
									
										
										
										
											2010-04-14 14:44:49 -04:00
										 |  |  | 	u32 div_ratio_mask; | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | #define PLL_HAS_PREDIV          0x01
 | 
					
						
							|  |  |  | #define PLL_HAS_POSTDIV         0x02
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-05 16:36:55 +01:00
										 |  |  | struct clk { | 
					
						
							|  |  |  | 	struct list_head	node; | 
					
						
							|  |  |  | 	struct module		*owner; | 
					
						
							|  |  |  | 	const char		*name; | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | 	unsigned long		rate; | 
					
						
							| 
									
										
										
										
											2010-07-20 16:46:49 +05:30
										 |  |  | 	unsigned long		maxrate;	/* H/W supported max rate */ | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | 	u8			usecount; | 
					
						
							|  |  |  | 	u8			lpsc; | 
					
						
							| 
									
										
										
										
											2009-09-30 19:48:03 +04:00
										 |  |  | 	u8			gpsc; | 
					
						
							| 
									
										
										
										
											2011-11-15 01:42:09 +05:30
										 |  |  | 	u8			domain; | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:05 +05:30
										 |  |  | 	u32			flags; | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | 	struct clk              *parent; | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:01 +05:30
										 |  |  | 	struct list_head	children; 	/* list of children */ | 
					
						
							|  |  |  | 	struct list_head	childnode;	/* parent's child list node */ | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | 	struct pll_data         *pll_data; | 
					
						
							|  |  |  | 	u32                     div_reg; | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:02 +05:30
										 |  |  | 	unsigned long (*recalc) (struct clk *); | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:03 +05:30
										 |  |  | 	int (*set_rate) (struct clk *clk, unsigned long rate); | 
					
						
							|  |  |  | 	int (*round_rate) (struct clk *clk, unsigned long rate); | 
					
						
							| 
									
										
										
										
											2013-01-10 16:23:23 -08:00
										 |  |  | 	int (*reset) (struct clk *clk, bool reset); | 
					
						
							| 
									
										
										
										
											2007-06-05 16:36:55 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:05 +05:30
										 |  |  | /* Clock flags: SoC-specific flags start at BIT(16) */ | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | #define ALWAYS_ENABLED		BIT(1)
 | 
					
						
							| 
									
										
										
										
											2010-03-25 17:43:47 -04:00
										 |  |  | #define CLK_PSC			BIT(2)
 | 
					
						
							| 
									
										
										
										
											2011-11-15 01:42:09 +05:30
										 |  |  | #define CLK_PLL			BIT(3) /* PLL-derived clock */
 | 
					
						
							|  |  |  | #define PRE_PLL			BIT(4) /* source is before PLL mult/div */
 | 
					
						
							|  |  |  | #define PSC_SWRSTDISABLE	BIT(5) /* Disable state is SwRstDisable */
 | 
					
						
							|  |  |  | #define PSC_FORCE		BIT(6) /* Force module state transtition */
 | 
					
						
							| 
									
										
										
										
											2013-01-10 16:23:23 -08:00
										 |  |  | #define PSC_LRST		BIT(8) /* Use local reset on enable/disable */
 | 
					
						
							| 
									
										
										
										
											2009-03-20 17:29:01 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-11 08:22:23 -08:00
										 |  |  | #define CLK(dev, con, ck) 	\
 | 
					
						
							|  |  |  | 	{			\ | 
					
						
							|  |  |  | 		.dev_id = dev,	\ | 
					
						
							|  |  |  | 		.con_id = con,	\ | 
					
						
							|  |  |  | 		.clk = ck,	\ | 
					
						
							|  |  |  | 	}			\ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int davinci_clk_init(struct clk_lookup *clocks); | 
					
						
							| 
									
										
										
										
											2009-08-31 15:48:03 +05:30
										 |  |  | int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, | 
					
						
							|  |  |  | 				unsigned int mult, unsigned int postdiv); | 
					
						
							| 
									
										
										
										
											2010-07-20 16:46:49 +05:30
										 |  |  | int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate); | 
					
						
							| 
									
										
										
										
											2011-06-14 15:33:20 +00:00
										 |  |  | int davinci_set_refclk_rate(unsigned long rate); | 
					
						
							|  |  |  | int davinci_simple_set_rate(struct clk *clk, unsigned long rate); | 
					
						
							| 
									
										
										
										
											2013-01-10 16:23:23 -08:00
										 |  |  | int davinci_clk_reset(struct clk *clk, bool reset); | 
					
						
							| 
									
										
										
										
											2009-04-29 16:23:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern struct platform_device davinci_wdt_device; | 
					
						
							| 
									
										
										
										
											2010-05-01 18:38:28 -04:00
										 |  |  | extern void davinci_watchdog_reset(struct platform_device *); | 
					
						
							| 
									
										
										
										
											2009-04-29 16:23:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-05 16:36:55 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-11-16 17:21:36 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | #endif
 |