Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * TI DaVinci clock definitions |
| 3 | * |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 4 | * Copyright (C) 2006-2007 Texas Instruments. |
| 5 | * Copyright (C) 2008-2009 Deep Root Systems, LLC |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #ifndef __ARCH_ARM_DAVINCI_CLOCK_H |
| 13 | #define __ARCH_ARM_DAVINCI_CLOCK_H |
| 14 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 15 | #define DAVINCI_PLL1_BASE 0x01c40800 |
| 16 | #define DAVINCI_PLL2_BASE 0x01c40c00 |
| 17 | #define MAX_PLL 2 |
| 18 | |
| 19 | /* PLL/Reset register offsets */ |
| 20 | #define PLLCTL 0x100 |
| 21 | #define PLLCTL_PLLEN BIT(0) |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 22 | #define PLLCTL_PLLPWRDN BIT(1) |
| 23 | #define PLLCTL_PLLRST BIT(3) |
| 24 | #define PLLCTL_PLLDIS BIT(4) |
| 25 | #define PLLCTL_PLLENSRC BIT(5) |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 26 | #define PLLCTL_CLKMODE BIT(8) |
| 27 | |
| 28 | #define PLLM 0x110 |
| 29 | #define PLLM_PLLM_MASK 0xff |
| 30 | |
| 31 | #define PREDIV 0x114 |
| 32 | #define PLLDIV1 0x118 |
| 33 | #define PLLDIV2 0x11c |
| 34 | #define PLLDIV3 0x120 |
| 35 | #define POSTDIV 0x128 |
| 36 | #define BPDIV 0x12c |
| 37 | #define PLLCMD 0x138 |
| 38 | #define PLLSTAT 0x13c |
| 39 | #define PLLALNCTL 0x140 |
| 40 | #define PLLDCHANGE 0x144 |
| 41 | #define PLLCKEN 0x148 |
| 42 | #define PLLCKSTAT 0x14c |
| 43 | #define PLLSYSTAT 0x150 |
| 44 | #define PLLDIV4 0x160 |
| 45 | #define PLLDIV5 0x164 |
| 46 | #define PLLDIV6 0x168 |
| 47 | #define PLLDIV7 0x16c |
| 48 | #define PLLDIV8 0x170 |
| 49 | #define PLLDIV9 0x174 |
| 50 | #define PLLDIV_EN BIT(15) |
| 51 | #define PLLDIV_RATIO_MASK 0x1f |
| 52 | |
Sekhar Nori | 9a219a9 | 2009-11-16 17:21:33 +0530 | [diff] [blame] | 53 | /* |
| 54 | * OMAP-L138 system reference guide recommends a wait for 4 OSCIN/CLKIN |
| 55 | * cycles to ensure that the PLLC has switched to bypass mode. Delay of 1us |
| 56 | * ensures we are good for all > 4MHz OSCIN/CLKIN inputs. Typically the input |
| 57 | * is ~25MHz. Units are micro seconds. |
| 58 | */ |
| 59 | #define PLL_BYPASS_TIME 1 |
| 60 | /* From OMAP-L138 datasheet table 6-4. Units are micro seconds */ |
| 61 | #define PLL_RESET_TIME 1 |
| 62 | /* |
| 63 | * From OMAP-L138 datasheet table 6-4; assuming prediv = 1, sqrt(pllm) = 4 |
| 64 | * Units are micro seconds. |
| 65 | */ |
| 66 | #define PLL_LOCK_TIME 20 |
| 67 | |
Sekhar Nori | e2da3aa | 2009-11-16 17:21:36 +0530 | [diff] [blame] | 68 | #ifndef __ASSEMBLER__ |
| 69 | |
| 70 | #include <linux/list.h> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 71 | #include <linux/clkdev.h> |
Sekhar Nori | e2da3aa | 2009-11-16 17:21:36 +0530 | [diff] [blame] | 72 | |
Sekhar Nori | b39639b | 2010-07-20 16:46:49 +0530 | [diff] [blame] | 73 | #define PLLSTAT_GOSTAT BIT(0) |
| 74 | #define PLLCMD_GOSET BIT(0) |
| 75 | |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 76 | struct pll_data { |
| 77 | u32 phys_base; |
| 78 | void __iomem *base; |
| 79 | u32 num; |
| 80 | u32 flags; |
| 81 | u32 input_rate; |
Cyril Chemparathy | d6961e6 | 2010-04-14 14:44:49 -0400 | [diff] [blame] | 82 | u32 div_ratio_mask; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 83 | }; |
| 84 | #define PLL_HAS_PREDIV 0x01 |
| 85 | #define PLL_HAS_POSTDIV 0x02 |
| 86 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 87 | struct clk { |
| 88 | struct list_head node; |
| 89 | struct module *owner; |
| 90 | const char *name; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 91 | unsigned long rate; |
Sekhar Nori | b39639b | 2010-07-20 16:46:49 +0530 | [diff] [blame] | 92 | unsigned long maxrate; /* H/W supported max rate */ |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 93 | u8 usecount; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 94 | u8 lpsc; |
Sergei Shtylyov | 789a785 | 2009-09-30 19:48:03 +0400 | [diff] [blame] | 95 | u8 gpsc; |
Murali Karicheri | 12221d4 | 2011-11-15 01:42:09 +0530 | [diff] [blame] | 96 | u8 domain; |
Sekhar Nori | 5d36a33 | 2009-08-31 15:48:05 +0530 | [diff] [blame] | 97 | u32 flags; |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 98 | struct clk *parent; |
Sekhar Nori | f02bf3b | 2009-08-31 15:48:01 +0530 | [diff] [blame] | 99 | struct list_head children; /* list of children */ |
| 100 | struct list_head childnode; /* parent's child list node */ |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 101 | struct pll_data *pll_data; |
| 102 | u32 div_reg; |
Sekhar Nori | de381a9 | 2009-08-31 15:48:02 +0530 | [diff] [blame] | 103 | unsigned long (*recalc) (struct clk *); |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 104 | int (*set_rate) (struct clk *clk, unsigned long rate); |
| 105 | int (*round_rate) (struct clk *clk, unsigned long rate); |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 106 | }; |
| 107 | |
Sekhar Nori | 5d36a33 | 2009-08-31 15:48:05 +0530 | [diff] [blame] | 108 | /* Clock flags: SoC-specific flags start at BIT(16) */ |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 109 | #define ALWAYS_ENABLED BIT(1) |
Cyril Chemparathy | 52958be | 2010-03-25 17:43:47 -0400 | [diff] [blame] | 110 | #define CLK_PSC BIT(2) |
Murali Karicheri | 12221d4 | 2011-11-15 01:42:09 +0530 | [diff] [blame] | 111 | #define CLK_PLL BIT(3) /* PLL-derived clock */ |
| 112 | #define PRE_PLL BIT(4) /* source is before PLL mult/div */ |
| 113 | #define PSC_SWRSTDISABLE BIT(5) /* Disable state is SwRstDisable */ |
| 114 | #define PSC_FORCE BIT(6) /* Force module state transtition */ |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 115 | |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 116 | #define CLK(dev, con, ck) \ |
| 117 | { \ |
| 118 | .dev_id = dev, \ |
| 119 | .con_id = con, \ |
| 120 | .clk = ck, \ |
| 121 | } \ |
Kevin Hilman | c5b736d | 2009-03-20 17:29:01 -0700 | [diff] [blame] | 122 | |
Kevin Hilman | 08aca08 | 2010-01-11 08:22:23 -0800 | [diff] [blame] | 123 | int davinci_clk_init(struct clk_lookup *clocks); |
Sekhar Nori | d6a6156 | 2009-08-31 15:48:03 +0530 | [diff] [blame] | 124 | int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, |
| 125 | unsigned int mult, unsigned int postdiv); |
Sekhar Nori | b39639b | 2010-07-20 16:46:49 +0530 | [diff] [blame] | 126 | int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate); |
Sekhar Nori | 56e580d | 2011-06-14 15:33:20 +0000 | [diff] [blame] | 127 | int davinci_set_refclk_rate(unsigned long rate); |
| 128 | int davinci_simple_set_rate(struct clk *clk, unsigned long rate); |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 129 | |
| 130 | extern struct platform_device davinci_wdt_device; |
Cyril Chemparathy | c78a5bc | 2010-05-01 18:38:28 -0400 | [diff] [blame] | 131 | extern void davinci_watchdog_reset(struct platform_device *); |
Kevin Hilman | fb63138 | 2009-04-29 16:23:59 -0700 | [diff] [blame] | 132 | |
Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 133 | #endif |
Sekhar Nori | e2da3aa | 2009-11-16 17:21:36 +0530 | [diff] [blame] | 134 | |
| 135 | #endif |