diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-11 19:31:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-11 19:31:41 -0500 |
commit | 5a62f995446be44811fefa48f91f9efb7ea172d7 (patch) | |
tree | e297371f0d513dc6278bb67d582d2216eb7d74ed /arch/powerpc/sysdev | |
parent | f1d6d6cd9029daa7e7d4a0b14347b5392320f22a (diff) | |
parent | 5d7d8072edc11080a7cf6cc37c9f4e61ca1e93c9 (diff) |
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (72 commits)
powerpc/pseries: Fix build of topology stuff without CONFIG_NUMA
powerpc/pseries: Fix VPHN build errors on non-SMP systems
powerpc/83xx: add mpc8308_p1m DMA controller device-tree node
powerpc/83xx: add DMA controller to mpc8308 device-tree node
powerpc/512x: try to free dma descriptors in case of allocation failure
powerpc/512x: add MPC8308 dma support
powerpc/512x: fix the hanged dma transfer issue
powerpc/512x: scatter/gather dma fix
powerpc/powermac: Make auto-loading of therm_pm72 possible
of/address: Use propper endianess in get_flags
powerpc/pci: Use printf extension %pR for struct resource
powerpc: Remove unnecessary casts of void ptr
powerpc: Disable VPHN polling during a suspend operation
powerpc/pseries: Poll VPA for topology changes and update NUMA maps
powerpc: iommu: Add device name to iommu error printks
powerpc: Record vma->phys_addr in ioremap()
powerpc: Update compat_arch_ptrace
powerpc: Fix PPC_PTRACE_SETHWDEBUG on PPC_BOOK3S
powerpc/time: printk time stamp init not correct
powerpc: Minor cleanups for machdep.h
...
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r-- | arch/powerpc/sysdev/Makefile | 1 | ||||
-rw-r--r-- | arch/powerpc/sysdev/dart_iommu.c | 9 | ||||
-rw-r--r-- | arch/powerpc/sysdev/mpc8xxx_gpio.c | 75 | ||||
-rw-r--r-- | arch/powerpc/sysdev/ppc4xx_cpm.c | 346 | ||||
-rw-r--r-- | arch/powerpc/sysdev/tsi108_dev.c | 8 |
5 files changed, 419 insertions, 20 deletions
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile index 0bef9dacb64e..9c2973479142 100644 --- a/arch/powerpc/sysdev/Makefile +++ b/arch/powerpc/sysdev/Makefile | |||
@@ -41,6 +41,7 @@ obj-$(CONFIG_OF_RTC) += of_rtc.o | |||
41 | ifeq ($(CONFIG_PCI),y) | 41 | ifeq ($(CONFIG_PCI),y) |
42 | obj-$(CONFIG_4xx) += ppc4xx_pci.o | 42 | obj-$(CONFIG_4xx) += ppc4xx_pci.o |
43 | endif | 43 | endif |
44 | obj-$(CONFIG_PPC4xx_CPM) += ppc4xx_cpm.o | ||
44 | obj-$(CONFIG_PPC4xx_GPIO) += ppc4xx_gpio.o | 45 | obj-$(CONFIG_PPC4xx_GPIO) += ppc4xx_gpio.o |
45 | 46 | ||
46 | obj-$(CONFIG_CPM) += cpm_common.o | 47 | obj-$(CONFIG_CPM) += cpm_common.o |
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c index 17cf15ec38be..8e9e06a7ca59 100644 --- a/arch/powerpc/sysdev/dart_iommu.c +++ b/arch/powerpc/sysdev/dart_iommu.c | |||
@@ -312,17 +312,10 @@ static void pci_dma_dev_setup_dart(struct pci_dev *dev) | |||
312 | 312 | ||
313 | static void pci_dma_bus_setup_dart(struct pci_bus *bus) | 313 | static void pci_dma_bus_setup_dart(struct pci_bus *bus) |
314 | { | 314 | { |
315 | struct device_node *dn; | ||
316 | |||
317 | if (!iommu_table_dart_inited) { | 315 | if (!iommu_table_dart_inited) { |
318 | iommu_table_dart_inited = 1; | 316 | iommu_table_dart_inited = 1; |
319 | iommu_table_dart_setup(); | 317 | iommu_table_dart_setup(); |
320 | } | 318 | } |
321 | |||
322 | dn = pci_bus_to_OF_node(bus); | ||
323 | |||
324 | if (dn) | ||
325 | PCI_DN(dn)->iommu_table = &iommu_table_dart; | ||
326 | } | 319 | } |
327 | 320 | ||
328 | static bool dart_device_on_pcie(struct device *dev) | 321 | static bool dart_device_on_pcie(struct device *dev) |
@@ -373,7 +366,7 @@ void __init iommu_init_early_dart(void) | |||
373 | if (dn == NULL) { | 366 | if (dn == NULL) { |
374 | dn = of_find_compatible_node(NULL, "dart", "u4-dart"); | 367 | dn = of_find_compatible_node(NULL, "dart", "u4-dart"); |
375 | if (dn == NULL) | 368 | if (dn == NULL) |
376 | goto bail; | 369 | return; /* use default direct_dma_ops */ |
377 | dart_is_u4 = 1; | 370 | dart_is_u4 = 1; |
378 | } | 371 | } |
379 | 372 | ||
diff --git a/arch/powerpc/sysdev/mpc8xxx_gpio.c b/arch/powerpc/sysdev/mpc8xxx_gpio.c index c0ea05e87f1d..c48cd8178079 100644 --- a/arch/powerpc/sysdev/mpc8xxx_gpio.c +++ b/arch/powerpc/sysdev/mpc8xxx_gpio.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * GPIOs on MPC8349/8572/8610 and compatible | 2 | * GPIOs on MPC512x/8349/8572/8610 and compatible |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Peter Korsgaard <jacmet@sunsite.dk> | 4 | * Copyright (C) 2008 Peter Korsgaard <jacmet@sunsite.dk> |
5 | * | 5 | * |
@@ -26,6 +26,7 @@ | |||
26 | #define GPIO_IER 0x0c | 26 | #define GPIO_IER 0x0c |
27 | #define GPIO_IMR 0x10 | 27 | #define GPIO_IMR 0x10 |
28 | #define GPIO_ICR 0x14 | 28 | #define GPIO_ICR 0x14 |
29 | #define GPIO_ICR2 0x18 | ||
29 | 30 | ||
30 | struct mpc8xxx_gpio_chip { | 31 | struct mpc8xxx_gpio_chip { |
31 | struct of_mm_gpio_chip mm_gc; | 32 | struct of_mm_gpio_chip mm_gc; |
@@ -37,6 +38,7 @@ struct mpc8xxx_gpio_chip { | |||
37 | */ | 38 | */ |
38 | u32 data; | 39 | u32 data; |
39 | struct irq_host *irq; | 40 | struct irq_host *irq; |
41 | void *of_dev_id_data; | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | static inline u32 mpc8xxx_gpio2mask(unsigned int gpio) | 44 | static inline u32 mpc8xxx_gpio2mask(unsigned int gpio) |
@@ -215,6 +217,51 @@ static int mpc8xxx_irq_set_type(unsigned int virq, unsigned int flow_type) | |||
215 | return 0; | 217 | return 0; |
216 | } | 218 | } |
217 | 219 | ||
220 | static int mpc512x_irq_set_type(unsigned int virq, unsigned int flow_type) | ||
221 | { | ||
222 | struct mpc8xxx_gpio_chip *mpc8xxx_gc = get_irq_chip_data(virq); | ||
223 | struct of_mm_gpio_chip *mm = &mpc8xxx_gc->mm_gc; | ||
224 | unsigned long gpio = virq_to_hw(virq); | ||
225 | void __iomem *reg; | ||
226 | unsigned int shift; | ||
227 | unsigned long flags; | ||
228 | |||
229 | if (gpio < 16) { | ||
230 | reg = mm->regs + GPIO_ICR; | ||
231 | shift = (15 - gpio) * 2; | ||
232 | } else { | ||
233 | reg = mm->regs + GPIO_ICR2; | ||
234 | shift = (15 - (gpio % 16)) * 2; | ||
235 | } | ||
236 | |||
237 | switch (flow_type) { | ||
238 | case IRQ_TYPE_EDGE_FALLING: | ||
239 | case IRQ_TYPE_LEVEL_LOW: | ||
240 | spin_lock_irqsave(&mpc8xxx_gc->lock, flags); | ||
241 | clrsetbits_be32(reg, 3 << shift, 2 << shift); | ||
242 | spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); | ||
243 | break; | ||
244 | |||
245 | case IRQ_TYPE_EDGE_RISING: | ||
246 | case IRQ_TYPE_LEVEL_HIGH: | ||
247 | spin_lock_irqsave(&mpc8xxx_gc->lock, flags); | ||
248 | clrsetbits_be32(reg, 3 << shift, 1 << shift); | ||
249 | spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); | ||
250 | break; | ||
251 | |||
252 | case IRQ_TYPE_EDGE_BOTH: | ||
253 | spin_lock_irqsave(&mpc8xxx_gc->lock, flags); | ||
254 | clrbits32(reg, 3 << shift); | ||
255 | spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); | ||
256 | break; | ||
257 | |||
258 | default: | ||
259 | return -EINVAL; | ||
260 | } | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
218 | static struct irq_chip mpc8xxx_irq_chip = { | 265 | static struct irq_chip mpc8xxx_irq_chip = { |
219 | .name = "mpc8xxx-gpio", | 266 | .name = "mpc8xxx-gpio", |
220 | .unmask = mpc8xxx_irq_unmask, | 267 | .unmask = mpc8xxx_irq_unmask, |
@@ -226,6 +273,11 @@ static struct irq_chip mpc8xxx_irq_chip = { | |||
226 | static int mpc8xxx_gpio_irq_map(struct irq_host *h, unsigned int virq, | 273 | static int mpc8xxx_gpio_irq_map(struct irq_host *h, unsigned int virq, |
227 | irq_hw_number_t hw) | 274 | irq_hw_number_t hw) |
228 | { | 275 | { |
276 | struct mpc8xxx_gpio_chip *mpc8xxx_gc = h->host_data; | ||
277 | |||
278 | if (mpc8xxx_gc->of_dev_id_data) | ||
279 | mpc8xxx_irq_chip.set_type = mpc8xxx_gc->of_dev_id_data; | ||
280 | |||
229 | set_irq_chip_data(virq, h->host_data); | 281 | set_irq_chip_data(virq, h->host_data); |
230 | set_irq_chip_and_handler(virq, &mpc8xxx_irq_chip, handle_level_irq); | 282 | set_irq_chip_and_handler(virq, &mpc8xxx_irq_chip, handle_level_irq); |
231 | set_irq_type(virq, IRQ_TYPE_NONE); | 283 | set_irq_type(virq, IRQ_TYPE_NONE); |
@@ -253,11 +305,20 @@ static struct irq_host_ops mpc8xxx_gpio_irq_ops = { | |||
253 | .xlate = mpc8xxx_gpio_irq_xlate, | 305 | .xlate = mpc8xxx_gpio_irq_xlate, |
254 | }; | 306 | }; |
255 | 307 | ||
308 | static struct of_device_id mpc8xxx_gpio_ids[] __initdata = { | ||
309 | { .compatible = "fsl,mpc8349-gpio", }, | ||
310 | { .compatible = "fsl,mpc8572-gpio", }, | ||
311 | { .compatible = "fsl,mpc8610-gpio", }, | ||
312 | { .compatible = "fsl,mpc5121-gpio", .data = mpc512x_irq_set_type, }, | ||
313 | {} | ||
314 | }; | ||
315 | |||
256 | static void __init mpc8xxx_add_controller(struct device_node *np) | 316 | static void __init mpc8xxx_add_controller(struct device_node *np) |
257 | { | 317 | { |
258 | struct mpc8xxx_gpio_chip *mpc8xxx_gc; | 318 | struct mpc8xxx_gpio_chip *mpc8xxx_gc; |
259 | struct of_mm_gpio_chip *mm_gc; | 319 | struct of_mm_gpio_chip *mm_gc; |
260 | struct gpio_chip *gc; | 320 | struct gpio_chip *gc; |
321 | const struct of_device_id *id; | ||
261 | unsigned hwirq; | 322 | unsigned hwirq; |
262 | int ret; | 323 | int ret; |
263 | 324 | ||
@@ -297,6 +358,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np) | |||
297 | if (!mpc8xxx_gc->irq) | 358 | if (!mpc8xxx_gc->irq) |
298 | goto skip_irq; | 359 | goto skip_irq; |
299 | 360 | ||
361 | id = of_match_node(mpc8xxx_gpio_ids, np); | ||
362 | if (id) | ||
363 | mpc8xxx_gc->of_dev_id_data = id->data; | ||
364 | |||
300 | mpc8xxx_gc->irq->host_data = mpc8xxx_gc; | 365 | mpc8xxx_gc->irq->host_data = mpc8xxx_gc; |
301 | 366 | ||
302 | /* ack and mask all irqs */ | 367 | /* ack and mask all irqs */ |
@@ -321,13 +386,7 @@ static int __init mpc8xxx_add_gpiochips(void) | |||
321 | { | 386 | { |
322 | struct device_node *np; | 387 | struct device_node *np; |
323 | 388 | ||
324 | for_each_compatible_node(np, NULL, "fsl,mpc8349-gpio") | 389 | for_each_matching_node(np, mpc8xxx_gpio_ids) |
325 | mpc8xxx_add_controller(np); | ||
326 | |||
327 | for_each_compatible_node(np, NULL, "fsl,mpc8572-gpio") | ||
328 | mpc8xxx_add_controller(np); | ||
329 | |||
330 | for_each_compatible_node(np, NULL, "fsl,mpc8610-gpio") | ||
331 | mpc8xxx_add_controller(np); | 390 | mpc8xxx_add_controller(np); |
332 | 391 | ||
333 | for_each_compatible_node(np, NULL, "fsl,qoriq-gpio") | 392 | for_each_compatible_node(np, NULL, "fsl,qoriq-gpio") |
diff --git a/arch/powerpc/sysdev/ppc4xx_cpm.c b/arch/powerpc/sysdev/ppc4xx_cpm.c new file mode 100644 index 000000000000..73b86cc5ea74 --- /dev/null +++ b/arch/powerpc/sysdev/ppc4xx_cpm.c | |||
@@ -0,0 +1,346 @@ | |||
1 | /* | ||
2 | * PowerPC 4xx Clock and Power Management | ||
3 | * | ||
4 | * Copyright (C) 2010, Applied Micro Circuits Corporation | ||
5 | * Victor Gallardo (vgallardo@apm.com) | ||
6 | * | ||
7 | * Based on arch/powerpc/platforms/44x/idle.c: | ||
8 | * Jerone Young <jyoung5@us.ibm.com> | ||
9 | * Copyright 2008 IBM Corp. | ||
10 | * | ||
11 | * Based on arch/powerpc/sysdev/fsl_pmc.c: | ||
12 | * Anton Vorontsov <avorontsov@ru.mvista.com> | ||
13 | * Copyright 2009 MontaVista Software, Inc. | ||
14 | * | ||
15 | * See file CREDITS for list of people who contributed to this | ||
16 | * project. | ||
17 | * | ||
18 | * This program is free software; you can redistribute it and/or | ||
19 | * modify it under the terms of the GNU General Public License as | ||
20 | * published by the Free Software Foundation; either version 2 of | ||
21 | * the License, or (at your option) any later version. | ||
22 | * | ||
23 | * This program is distributed in the hope that it will be useful, | ||
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
26 | * GNU General Public License for more details. | ||
27 | * | ||
28 | * You should have received a copy of the GNU General Public License | ||
29 | * along with this program; if not, write to the Free Software | ||
30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | ||
31 | * MA 02111-1307 USA | ||
32 | */ | ||
33 | |||
34 | #include <linux/kernel.h> | ||
35 | #include <linux/of_platform.h> | ||
36 | #include <linux/sysfs.h> | ||
37 | #include <linux/cpu.h> | ||
38 | #include <linux/suspend.h> | ||
39 | #include <asm/dcr.h> | ||
40 | #include <asm/dcr-native.h> | ||
41 | #include <asm/machdep.h> | ||
42 | |||
43 | #define CPM_ER 0 | ||
44 | #define CPM_FR 1 | ||
45 | #define CPM_SR 2 | ||
46 | |||
47 | #define CPM_IDLE_WAIT 0 | ||
48 | #define CPM_IDLE_DOZE 1 | ||
49 | |||
50 | struct cpm { | ||
51 | dcr_host_t dcr_host; | ||
52 | unsigned int dcr_offset[3]; | ||
53 | unsigned int powersave_off; | ||
54 | unsigned int unused; | ||
55 | unsigned int idle_doze; | ||
56 | unsigned int standby; | ||
57 | unsigned int suspend; | ||
58 | }; | ||
59 | |||
60 | static struct cpm cpm; | ||
61 | |||
62 | struct cpm_idle_mode { | ||
63 | unsigned int enabled; | ||
64 | const char *name; | ||
65 | }; | ||
66 | |||
67 | static struct cpm_idle_mode idle_mode[] = { | ||
68 | [CPM_IDLE_WAIT] = { 1, "wait" }, /* default */ | ||
69 | [CPM_IDLE_DOZE] = { 0, "doze" }, | ||
70 | }; | ||
71 | |||
72 | static unsigned int cpm_set(unsigned int cpm_reg, unsigned int mask) | ||
73 | { | ||
74 | unsigned int value; | ||
75 | |||
76 | /* CPM controller supports 3 different types of sleep interface | ||
77 | * known as class 1, 2 and 3. For class 1 units, they are | ||
78 | * unconditionally put to sleep when the corresponding CPM bit is | ||
79 | * set. For class 2 and 3 units this is not case; if they can be | ||
80 | * put to to sleep, they will. Here we do not verify, we just | ||
81 | * set them and expect them to eventually go off when they can. | ||
82 | */ | ||
83 | value = dcr_read(cpm.dcr_host, cpm.dcr_offset[cpm_reg]); | ||
84 | dcr_write(cpm.dcr_host, cpm.dcr_offset[cpm_reg], value | mask); | ||
85 | |||
86 | /* return old state, to restore later if needed */ | ||
87 | return value; | ||
88 | } | ||
89 | |||
90 | static void cpm_idle_wait(void) | ||
91 | { | ||
92 | unsigned long msr_save; | ||
93 | |||
94 | /* save off initial state */ | ||
95 | msr_save = mfmsr(); | ||
96 | /* sync required when CPM0_ER[CPU] is set */ | ||
97 | mb(); | ||
98 | /* set wait state MSR */ | ||
99 | mtmsr(msr_save|MSR_WE|MSR_EE|MSR_CE|MSR_DE); | ||
100 | isync(); | ||
101 | /* return to initial state */ | ||
102 | mtmsr(msr_save); | ||
103 | isync(); | ||
104 | } | ||
105 | |||
106 | static void cpm_idle_sleep(unsigned int mask) | ||
107 | { | ||
108 | unsigned int er_save; | ||
109 | |||
110 | /* update CPM_ER state */ | ||
111 | er_save = cpm_set(CPM_ER, mask); | ||
112 | |||
113 | /* go to wait state so that CPM0_ER[CPU] can take effect */ | ||
114 | cpm_idle_wait(); | ||
115 | |||
116 | /* restore CPM_ER state */ | ||
117 | dcr_write(cpm.dcr_host, cpm.dcr_offset[CPM_ER], er_save); | ||
118 | } | ||
119 | |||
120 | static void cpm_idle_doze(void) | ||
121 | { | ||
122 | cpm_idle_sleep(cpm.idle_doze); | ||
123 | } | ||
124 | |||
125 | static void cpm_idle_config(int mode) | ||
126 | { | ||
127 | int i; | ||
128 | |||
129 | if (idle_mode[mode].enabled) | ||
130 | return; | ||
131 | |||
132 | for (i = 0; i < ARRAY_SIZE(idle_mode); i++) | ||
133 | idle_mode[i].enabled = 0; | ||
134 | |||
135 | idle_mode[mode].enabled = 1; | ||
136 | } | ||
137 | |||
138 | static ssize_t cpm_idle_show(struct kobject *kobj, | ||
139 | struct kobj_attribute *attr, char *buf) | ||
140 | { | ||
141 | char *s = buf; | ||
142 | int i; | ||
143 | |||
144 | for (i = 0; i < ARRAY_SIZE(idle_mode); i++) { | ||
145 | if (idle_mode[i].enabled) | ||
146 | s += sprintf(s, "[%s] ", idle_mode[i].name); | ||
147 | else | ||
148 | s += sprintf(s, "%s ", idle_mode[i].name); | ||
149 | } | ||
150 | |||
151 | *(s-1) = '\n'; /* convert the last space to a newline */ | ||
152 | |||
153 | return s - buf; | ||
154 | } | ||
155 | |||
156 | static ssize_t cpm_idle_store(struct kobject *kobj, | ||
157 | struct kobj_attribute *attr, | ||
158 | const char *buf, size_t n) | ||
159 | { | ||
160 | int i; | ||
161 | char *p; | ||
162 | int len; | ||
163 | |||
164 | p = memchr(buf, '\n', n); | ||
165 | len = p ? p - buf : n; | ||
166 | |||
167 | for (i = 0; i < ARRAY_SIZE(idle_mode); i++) { | ||
168 | if (strncmp(buf, idle_mode[i].name, len) == 0) { | ||
169 | cpm_idle_config(i); | ||
170 | return n; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | return -EINVAL; | ||
175 | } | ||
176 | |||
177 | static struct kobj_attribute cpm_idle_attr = | ||
178 | __ATTR(idle, 0644, cpm_idle_show, cpm_idle_store); | ||
179 | |||
180 | static void cpm_idle_config_sysfs(void) | ||
181 | { | ||
182 | struct sys_device *sys_dev; | ||
183 | unsigned long ret; | ||
184 | |||
185 | sys_dev = get_cpu_sysdev(0); | ||
186 | |||
187 | ret = sysfs_create_file(&sys_dev->kobj, | ||
188 | &cpm_idle_attr.attr); | ||
189 | if (ret) | ||
190 | printk(KERN_WARNING | ||
191 | "cpm: failed to create idle sysfs entry\n"); | ||
192 | } | ||
193 | |||
194 | static void cpm_idle(void) | ||
195 | { | ||
196 | if (idle_mode[CPM_IDLE_DOZE].enabled) | ||
197 | cpm_idle_doze(); | ||
198 | else | ||
199 | cpm_idle_wait(); | ||
200 | } | ||
201 | |||
202 | static int cpm_suspend_valid(suspend_state_t state) | ||
203 | { | ||
204 | switch (state) { | ||
205 | case PM_SUSPEND_STANDBY: | ||
206 | return !!cpm.standby; | ||
207 | case PM_SUSPEND_MEM: | ||
208 | return !!cpm.suspend; | ||
209 | default: | ||
210 | return 0; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | static void cpm_suspend_standby(unsigned int mask) | ||
215 | { | ||
216 | unsigned long tcr_save; | ||
217 | |||
218 | /* disable decrement interrupt */ | ||
219 | tcr_save = mfspr(SPRN_TCR); | ||
220 | mtspr(SPRN_TCR, tcr_save & ~TCR_DIE); | ||
221 | |||
222 | /* go to sleep state */ | ||
223 | cpm_idle_sleep(mask); | ||
224 | |||
225 | /* restore decrement interrupt */ | ||
226 | mtspr(SPRN_TCR, tcr_save); | ||
227 | } | ||
228 | |||
229 | static int cpm_suspend_enter(suspend_state_t state) | ||
230 | { | ||
231 | switch (state) { | ||
232 | case PM_SUSPEND_STANDBY: | ||
233 | cpm_suspend_standby(cpm.standby); | ||
234 | break; | ||
235 | case PM_SUSPEND_MEM: | ||
236 | cpm_suspend_standby(cpm.suspend); | ||
237 | break; | ||
238 | } | ||
239 | |||
240 | return 0; | ||
241 | } | ||
242 | |||
243 | static struct platform_suspend_ops cpm_suspend_ops = { | ||
244 | .valid = cpm_suspend_valid, | ||
245 | .enter = cpm_suspend_enter, | ||
246 | }; | ||
247 | |||
248 | static int cpm_get_uint_property(struct device_node *np, | ||
249 | const char *name) | ||
250 | { | ||
251 | int len; | ||
252 | const unsigned int *prop = of_get_property(np, name, &len); | ||
253 | |||
254 | if (prop == NULL || len < sizeof(u32)) | ||
255 | return 0; | ||
256 | |||
257 | return *prop; | ||
258 | } | ||
259 | |||
260 | static int __init cpm_init(void) | ||
261 | { | ||
262 | struct device_node *np; | ||
263 | int dcr_base, dcr_len; | ||
264 | int ret = 0; | ||
265 | |||
266 | if (!cpm.powersave_off) { | ||
267 | cpm_idle_config(CPM_IDLE_WAIT); | ||
268 | ppc_md.power_save = &cpm_idle; | ||
269 | } | ||
270 | |||
271 | np = of_find_compatible_node(NULL, NULL, "ibm,cpm"); | ||
272 | if (!np) { | ||
273 | ret = -EINVAL; | ||
274 | goto out; | ||
275 | } | ||
276 | |||
277 | dcr_base = dcr_resource_start(np, 0); | ||
278 | dcr_len = dcr_resource_len(np, 0); | ||
279 | |||
280 | if (dcr_base == 0 || dcr_len == 0) { | ||
281 | printk(KERN_ERR "cpm: could not parse dcr property for %s\n", | ||
282 | np->full_name); | ||
283 | ret = -EINVAL; | ||
284 | goto out; | ||
285 | } | ||
286 | |||
287 | cpm.dcr_host = dcr_map(np, dcr_base, dcr_len); | ||
288 | |||
289 | if (!DCR_MAP_OK(cpm.dcr_host)) { | ||
290 | printk(KERN_ERR "cpm: failed to map dcr property for %s\n", | ||
291 | np->full_name); | ||
292 | ret = -EINVAL; | ||
293 | goto out; | ||
294 | } | ||
295 | |||
296 | /* All 4xx SoCs with a CPM controller have one of two | ||
297 | * different order for the CPM registers. Some have the | ||
298 | * CPM registers in the following order (ER,FR,SR). The | ||
299 | * others have them in the following order (SR,ER,FR). | ||
300 | */ | ||
301 | |||
302 | if (cpm_get_uint_property(np, "er-offset") == 0) { | ||
303 | cpm.dcr_offset[CPM_ER] = 0; | ||
304 | cpm.dcr_offset[CPM_FR] = 1; | ||
305 | cpm.dcr_offset[CPM_SR] = 2; | ||
306 | } else { | ||
307 | cpm.dcr_offset[CPM_ER] = 1; | ||
308 | cpm.dcr_offset[CPM_FR] = 2; | ||
309 | cpm.dcr_offset[CPM_SR] = 0; | ||
310 | } | ||
311 | |||
312 | /* Now let's see what IPs to turn off for the following modes */ | ||
313 | |||
314 | cpm.unused = cpm_get_uint_property(np, "unused-units"); | ||
315 | cpm.idle_doze = cpm_get_uint_property(np, "idle-doze"); | ||
316 | cpm.standby = cpm_get_uint_property(np, "standby"); | ||
317 | cpm.suspend = cpm_get_uint_property(np, "suspend"); | ||
318 | |||
319 | /* If some IPs are unused let's turn them off now */ | ||
320 | |||
321 | if (cpm.unused) { | ||
322 | cpm_set(CPM_ER, cpm.unused); | ||
323 | cpm_set(CPM_FR, cpm.unused); | ||
324 | } | ||
325 | |||
326 | /* Now let's export interfaces */ | ||
327 | |||
328 | if (!cpm.powersave_off && cpm.idle_doze) | ||
329 | cpm_idle_config_sysfs(); | ||
330 | |||
331 | if (cpm.standby || cpm.suspend) | ||
332 | suspend_set_ops(&cpm_suspend_ops); | ||
333 | out: | ||
334 | if (np) | ||
335 | of_node_put(np); | ||
336 | return ret; | ||
337 | } | ||
338 | |||
339 | late_initcall(cpm_init); | ||
340 | |||
341 | static int __init cpm_powersave_off(char *arg) | ||
342 | { | ||
343 | cpm.powersave_off = 1; | ||
344 | return 0; | ||
345 | } | ||
346 | __setup("powersave=off", cpm_powersave_off); | ||
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c index c2d675b6392c..ee056807b52c 100644 --- a/arch/powerpc/sysdev/tsi108_dev.c +++ b/arch/powerpc/sysdev/tsi108_dev.c | |||
@@ -84,8 +84,8 @@ static int __init tsi108_eth_of_init(void) | |||
84 | memset(&tsi_eth_data, 0, sizeof(tsi_eth_data)); | 84 | memset(&tsi_eth_data, 0, sizeof(tsi_eth_data)); |
85 | 85 | ||
86 | ret = of_address_to_resource(np, 0, &r[0]); | 86 | ret = of_address_to_resource(np, 0, &r[0]); |
87 | DBG("%s: name:start->end = %s:0x%lx-> 0x%lx\n", | 87 | DBG("%s: name:start->end = %s:%pR\n", |
88 | __func__,r[0].name, r[0].start, r[0].end); | 88 | __func__, r[0].name, &r[0]); |
89 | if (ret) | 89 | if (ret) |
90 | goto err; | 90 | goto err; |
91 | 91 | ||
@@ -93,8 +93,8 @@ static int __init tsi108_eth_of_init(void) | |||
93 | r[1].start = irq_of_parse_and_map(np, 0); | 93 | r[1].start = irq_of_parse_and_map(np, 0); |
94 | r[1].end = irq_of_parse_and_map(np, 0); | 94 | r[1].end = irq_of_parse_and_map(np, 0); |
95 | r[1].flags = IORESOURCE_IRQ; | 95 | r[1].flags = IORESOURCE_IRQ; |
96 | DBG("%s: name:start->end = %s:0x%lx-> 0x%lx\n", | 96 | DBG("%s: name:start->end = %s:%pR\n", |
97 | __func__,r[1].name, r[1].start, r[1].end); | 97 | __func__, r[1].name, &r[1]); |
98 | 98 | ||
99 | tsi_eth_dev = | 99 | tsi_eth_dev = |
100 | platform_device_register_simple("tsi-ethernet", i++, &r[0], | 100 | platform_device_register_simple("tsi-ethernet", i++, &r[0], |