input/vmmouse: Update the backdoor call with support for new instructions
[sfrench/cifs-2.6.git] / arch / arm / mach-w90x900 / clock.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * linux/arch/arm/mach-w90x900/clock.c
4  *
5  * Copyright (c) 2008 Nuvoton technology corporation
6  *
7  * Wan ZongShun <mcuos.com@gmail.com>
8  */
9
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/list.h>
13 #include <linux/errno.h>
14 #include <linux/err.h>
15 #include <linux/string.h>
16 #include <linux/clk.h>
17 #include <linux/spinlock.h>
18 #include <linux/platform_device.h>
19 #include <linux/io.h>
20
21 #include <mach/hardware.h>
22
23 #include "clock.h"
24
25 #define SUBCLK 0x24
26
27 static DEFINE_SPINLOCK(clocks_lock);
28
29 int clk_enable(struct clk *clk)
30 {
31         unsigned long flags;
32
33         spin_lock_irqsave(&clocks_lock, flags);
34         if (clk->enabled++ == 0)
35                 (clk->enable)(clk, 1);
36         spin_unlock_irqrestore(&clocks_lock, flags);
37
38         return 0;
39 }
40 EXPORT_SYMBOL(clk_enable);
41
42 void clk_disable(struct clk *clk)
43 {
44         unsigned long flags;
45
46         if (!clk)
47                 return;
48
49         WARN_ON(clk->enabled == 0);
50
51         spin_lock_irqsave(&clocks_lock, flags);
52         if (--clk->enabled == 0)
53                 (clk->enable)(clk, 0);
54         spin_unlock_irqrestore(&clocks_lock, flags);
55 }
56 EXPORT_SYMBOL(clk_disable);
57
58 unsigned long clk_get_rate(struct clk *clk)
59 {
60         return 15000000;
61 }
62 EXPORT_SYMBOL(clk_get_rate);
63
64 void nuc900_clk_enable(struct clk *clk, int enable)
65 {
66         unsigned int clocks = clk->cken;
67         unsigned long clken;
68
69         clken = __raw_readl(W90X900_VA_CLKPWR);
70
71         if (enable)
72                 clken |= clocks;
73         else
74                 clken &= ~clocks;
75
76         __raw_writel(clken, W90X900_VA_CLKPWR);
77 }
78
79 void nuc900_subclk_enable(struct clk *clk, int enable)
80 {
81         unsigned int clocks = clk->cken;
82         unsigned long clken;
83
84         clken = __raw_readl(W90X900_VA_CLKPWR + SUBCLK);
85
86         if (enable)
87                 clken |= clocks;
88         else
89                 clken &= ~clocks;
90
91         __raw_writel(clken, W90X900_VA_CLKPWR + SUBCLK);
92 }
93
94 /* dummy functions, should not be called */
95 long clk_round_rate(struct clk *clk, unsigned long rate)
96 {
97         WARN_ON(clk);
98         return 0;
99 }
100 EXPORT_SYMBOL(clk_round_rate);
101
102 int clk_set_rate(struct clk *clk, unsigned long rate)
103 {
104         WARN_ON(clk);
105         return 0;
106 }
107 EXPORT_SYMBOL(clk_set_rate);
108
109 int clk_set_parent(struct clk *clk, struct clk *parent)
110 {
111         WARN_ON(clk);
112         return 0;
113 }
114 EXPORT_SYMBOL(clk_set_parent);
115
116 struct clk *clk_get_parent(struct clk *clk)
117 {
118         WARN_ON(clk);
119         return NULL;
120 }
121 EXPORT_SYMBOL(clk_get_parent);