diff options
-rw-r--r-- | arch/arm/mach-davinci/clock.c | 39 | ||||
-rw-r--r-- | arch/arm/mach-davinci/clock.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/clock.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/psc.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-davinci/psc.c | 25 |
5 files changed, 72 insertions, 1 deletions
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c index 34668ead53c7..d458558ee84a 100644 --- a/arch/arm/mach-davinci/clock.c +++ b/arch/arm/mach-davinci/clock.c | |||
@@ -52,6 +52,40 @@ static void __clk_disable(struct clk *clk) | |||
52 | __clk_disable(clk->parent); | 52 | __clk_disable(clk->parent); |
53 | } | 53 | } |
54 | 54 | ||
55 | int davinci_clk_reset(struct clk *clk, bool reset) | ||
56 | { | ||
57 | unsigned long flags; | ||
58 | |||
59 | if (clk == NULL || IS_ERR(clk)) | ||
60 | return -EINVAL; | ||
61 | |||
62 | spin_lock_irqsave(&clockfw_lock, flags); | ||
63 | if (clk->flags & CLK_PSC) | ||
64 | davinci_psc_reset(clk->gpsc, clk->lpsc, reset); | ||
65 | spin_unlock_irqrestore(&clockfw_lock, flags); | ||
66 | |||
67 | return 0; | ||
68 | } | ||
69 | EXPORT_SYMBOL(davinci_clk_reset); | ||
70 | |||
71 | int davinci_clk_reset_assert(struct clk *clk) | ||
72 | { | ||
73 | if (clk == NULL || IS_ERR(clk) || !clk->reset) | ||
74 | return -EINVAL; | ||
75 | |||
76 | return clk->reset(clk, true); | ||
77 | } | ||
78 | EXPORT_SYMBOL(davinci_clk_reset_assert); | ||
79 | |||
80 | int davinci_clk_reset_deassert(struct clk *clk) | ||
81 | { | ||
82 | if (clk == NULL || IS_ERR(clk) || !clk->reset) | ||
83 | return -EINVAL; | ||
84 | |||
85 | return clk->reset(clk, false); | ||
86 | } | ||
87 | EXPORT_SYMBOL(davinci_clk_reset_deassert); | ||
88 | |||
55 | int clk_enable(struct clk *clk) | 89 | int clk_enable(struct clk *clk) |
56 | { | 90 | { |
57 | unsigned long flags; | 91 | unsigned long flags; |
@@ -535,7 +569,7 @@ int davinci_set_refclk_rate(unsigned long rate) | |||
535 | } | 569 | } |
536 | 570 | ||
537 | int __init davinci_clk_init(struct clk_lookup *clocks) | 571 | int __init davinci_clk_init(struct clk_lookup *clocks) |
538 | { | 572 | { |
539 | struct clk_lookup *c; | 573 | struct clk_lookup *c; |
540 | struct clk *clk; | 574 | struct clk *clk; |
541 | size_t num_clocks = 0; | 575 | size_t num_clocks = 0; |
@@ -576,6 +610,9 @@ int __init davinci_clk_init(struct clk_lookup *clocks) | |||
576 | if (clk->lpsc) | 610 | if (clk->lpsc) |
577 | clk->flags |= CLK_PSC; | 611 | clk->flags |= CLK_PSC; |
578 | 612 | ||
613 | if (clk->flags & PSC_LRST) | ||
614 | clk->reset = davinci_clk_reset; | ||
615 | |||
579 | clk_register(clk); | 616 | clk_register(clk); |
580 | num_clocks++; | 617 | num_clocks++; |
581 | 618 | ||
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h index 46f0f1bf1a4c..8694b395fc92 100644 --- a/arch/arm/mach-davinci/clock.h +++ b/arch/arm/mach-davinci/clock.h | |||
@@ -103,6 +103,7 @@ struct clk { | |||
103 | unsigned long (*recalc) (struct clk *); | 103 | unsigned long (*recalc) (struct clk *); |
104 | int (*set_rate) (struct clk *clk, unsigned long rate); | 104 | int (*set_rate) (struct clk *clk, unsigned long rate); |
105 | int (*round_rate) (struct clk *clk, unsigned long rate); | 105 | int (*round_rate) (struct clk *clk, unsigned long rate); |
106 | int (*reset) (struct clk *clk, bool reset); | ||
106 | }; | 107 | }; |
107 | 108 | ||
108 | /* Clock flags: SoC-specific flags start at BIT(16) */ | 109 | /* Clock flags: SoC-specific flags start at BIT(16) */ |
@@ -112,6 +113,7 @@ struct clk { | |||
112 | #define PRE_PLL BIT(4) /* source is before PLL mult/div */ | 113 | #define PRE_PLL BIT(4) /* source is before PLL mult/div */ |
113 | #define PSC_SWRSTDISABLE BIT(5) /* Disable state is SwRstDisable */ | 114 | #define PSC_SWRSTDISABLE BIT(5) /* Disable state is SwRstDisable */ |
114 | #define PSC_FORCE BIT(6) /* Force module state transtition */ | 115 | #define PSC_FORCE BIT(6) /* Force module state transtition */ |
116 | #define PSC_LRST BIT(8) /* Use local reset on enable/disable */ | ||
115 | 117 | ||
116 | #define CLK(dev, con, ck) \ | 118 | #define CLK(dev, con, ck) \ |
117 | { \ | 119 | { \ |
@@ -126,6 +128,7 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv, | |||
126 | int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate); | 128 | int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate); |
127 | int davinci_set_refclk_rate(unsigned long rate); | 129 | int davinci_set_refclk_rate(unsigned long rate); |
128 | int davinci_simple_set_rate(struct clk *clk, unsigned long rate); | 130 | int davinci_simple_set_rate(struct clk *clk, unsigned long rate); |
131 | int davinci_clk_reset(struct clk *clk, bool reset); | ||
129 | 132 | ||
130 | extern struct platform_device davinci_wdt_device; | 133 | extern struct platform_device davinci_wdt_device; |
131 | extern void davinci_watchdog_reset(struct platform_device *); | 134 | extern void davinci_watchdog_reset(struct platform_device *); |
diff --git a/arch/arm/mach-davinci/include/mach/clock.h b/arch/arm/mach-davinci/include/mach/clock.h index a3b040219876..3e8af6a0b64c 100644 --- a/arch/arm/mach-davinci/include/mach/clock.h +++ b/arch/arm/mach-davinci/include/mach/clock.h | |||
@@ -18,4 +18,7 @@ struct clk; | |||
18 | extern int clk_register(struct clk *clk); | 18 | extern int clk_register(struct clk *clk); |
19 | extern void clk_unregister(struct clk *clk); | 19 | extern void clk_unregister(struct clk *clk); |
20 | 20 | ||
21 | int davinci_clk_reset_assert(struct clk *c); | ||
22 | int davinci_clk_reset_deassert(struct clk *c); | ||
23 | |||
21 | #endif | 24 | #endif |
diff --git a/arch/arm/mach-davinci/include/mach/psc.h b/arch/arm/mach-davinci/include/mach/psc.h index 40a0027838e8..0a22710493fd 100644 --- a/arch/arm/mach-davinci/include/mach/psc.h +++ b/arch/arm/mach-davinci/include/mach/psc.h | |||
@@ -246,6 +246,7 @@ | |||
246 | 246 | ||
247 | #define MDSTAT_STATE_MASK 0x3f | 247 | #define MDSTAT_STATE_MASK 0x3f |
248 | #define PDSTAT_STATE_MASK 0x1f | 248 | #define PDSTAT_STATE_MASK 0x1f |
249 | #define MDCTL_LRST BIT(8) | ||
249 | #define MDCTL_FORCE BIT(31) | 250 | #define MDCTL_FORCE BIT(31) |
250 | #define PDCTL_NEXT BIT(0) | 251 | #define PDCTL_NEXT BIT(0) |
251 | #define PDCTL_EPCGOOD BIT(8) | 252 | #define PDCTL_EPCGOOD BIT(8) |
@@ -253,6 +254,8 @@ | |||
253 | #ifndef __ASSEMBLER__ | 254 | #ifndef __ASSEMBLER__ |
254 | 255 | ||
255 | extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id); | 256 | extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id); |
257 | extern void davinci_psc_reset(unsigned int ctlr, unsigned int id, | ||
258 | bool reset); | ||
256 | extern void davinci_psc_config(unsigned int domain, unsigned int ctlr, | 259 | extern void davinci_psc_config(unsigned int domain, unsigned int ctlr, |
257 | unsigned int id, bool enable, u32 flags); | 260 | unsigned int id, bool enable, u32 flags); |
258 | 261 | ||
diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c index bddaba9628e1..82fdc69d5728 100644 --- a/arch/arm/mach-davinci/psc.c +++ b/arch/arm/mach-davinci/psc.c | |||
@@ -48,6 +48,31 @@ int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id) | |||
48 | return mdstat & BIT(12); | 48 | return mdstat & BIT(12); |
49 | } | 49 | } |
50 | 50 | ||
51 | /* Control "reset" line associated with PSC domain */ | ||
52 | void davinci_psc_reset(unsigned int ctlr, unsigned int id, bool reset) | ||
53 | { | ||
54 | u32 mdctl; | ||
55 | void __iomem *psc_base; | ||
56 | struct davinci_soc_info *soc_info = &davinci_soc_info; | ||
57 | |||
58 | if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) { | ||
59 | pr_warn("PSC: Bad psc data: 0x%x[%d]\n", | ||
60 | (int)soc_info->psc_bases, ctlr); | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | psc_base = ioremap(soc_info->psc_bases[ctlr], SZ_4K); | ||
65 | |||
66 | mdctl = readl(psc_base + MDCTL + 4 * id); | ||
67 | if (reset) | ||
68 | mdctl &= ~MDCTL_LRST; | ||
69 | else | ||
70 | mdctl |= MDCTL_LRST; | ||
71 | writel(mdctl, psc_base + MDCTL + 4 * id); | ||
72 | |||
73 | iounmap(psc_base); | ||
74 | } | ||
75 | |||
51 | /* Enable or disable a PSC domain */ | 76 | /* Enable or disable a PSC domain */ |
52 | void davinci_psc_config(unsigned int domain, unsigned int ctlr, | 77 | void davinci_psc_config(unsigned int domain, unsigned int ctlr, |
53 | unsigned int id, bool enable, u32 flags) | 78 | unsigned int id, bool enable, u32 flags) |