2 * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
3 * Ben. Herrenschmidt (benh@kernel.crashing.org)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
12 * - Replace mdelay with some schedule loop if possible
13 * - Shorten some obfuscated delays on some routines (like modem
15 * - Refcount some clocks (see darwin)
16 * - Split split split...
19 #include <linux/types.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/kernel.h>
23 #include <linux/sched.h>
25 #include <linux/of_address.h>
26 #include <linux/spinlock.h>
27 #include <linux/adb.h>
28 #include <linux/pmu.h>
29 #include <linux/ioport.h>
30 #include <linux/pci.h>
31 #include <asm/sections.h>
32 #include <asm/errno.h>
33 #include <asm/ohare.h>
34 #include <asm/heathrow.h>
35 #include <asm/keylargo.h>
36 #include <asm/uninorth.h>
39 #include <asm/machdep.h>
40 #include <asm/pmac_feature.h>
41 #include <asm/dbdma.h>
42 #include <asm/pci-bridge.h>
43 #include <asm/pmac_low_i2c.h>
48 #define DBG(fmt...) printk(KERN_DEBUG fmt)
54 extern int powersave_lowspeed
;
57 extern int powersave_nap
;
58 extern struct device_node
*k2_skiplist
[2];
61 * We use a single global lock to protect accesses. Each driver has
62 * to take care of its own locking
64 DEFINE_RAW_SPINLOCK(feature_lock
);
66 #define LOCK(flags) raw_spin_lock_irqsave(&feature_lock, flags);
67 #define UNLOCK(flags) raw_spin_unlock_irqrestore(&feature_lock, flags);
71 * Instance of some macio stuffs
73 struct macio_chip macio_chips
[MAX_MACIO_CHIPS
];
75 struct macio_chip
*macio_find(struct device_node
*child
, int type
)
80 for (i
=0; i
< MAX_MACIO_CHIPS
&& macio_chips
[i
].of_node
; i
++)
81 if (child
== macio_chips
[i
].of_node
&&
82 (!type
|| macio_chips
[i
].type
== type
))
83 return &macio_chips
[i
];
84 child
= child
->parent
;
88 EXPORT_SYMBOL_GPL(macio_find
);
90 static const char *macio_names
[] =
107 struct device_node
*uninorth_node
;
108 u32 __iomem
*uninorth_base
;
110 static u32 uninorth_rev
;
111 static int uninorth_maj
;
112 static void __iomem
*u3_ht_base
;
115 * For each motherboard family, we have a table of functions pointers
116 * that handle the various features.
119 typedef long (*feature_call
)(struct device_node
*node
, long param
, long value
);
121 struct feature_table_entry
{
122 unsigned int selector
;
123 feature_call function
;
128 const char* model_string
;
129 const char* model_name
;
131 struct feature_table_entry
* features
;
132 unsigned long board_flags
;
134 static struct pmac_mb_def pmac_mb
;
137 * Here are the chip specific feature functions
140 static inline int simple_feature_tweak(struct device_node
*node
, int type
,
141 int reg
, u32 mask
, int value
)
143 struct macio_chip
* macio
;
146 macio
= macio_find(node
, type
);
151 MACIO_BIS(reg
, mask
);
153 MACIO_BIC(reg
, mask
);
154 (void)MACIO_IN32(reg
);
160 #ifndef CONFIG_POWER4
162 static long ohare_htw_scc_enable(struct device_node
*node
, long param
,
165 struct macio_chip
* macio
;
166 unsigned long chan_mask
;
172 macio
= macio_find(node
, 0);
175 if (!strcmp(node
->name
, "ch-a"))
176 chan_mask
= MACIO_FLAG_SCCA_ON
;
177 else if (!strcmp(node
->name
, "ch-b"))
178 chan_mask
= MACIO_FLAG_SCCB_ON
;
182 htw
= (macio
->type
== macio_heathrow
|| macio
->type
== macio_paddington
183 || macio
->type
== macio_gatwick
);
184 /* On these machines, the HRW_SCC_TRANS_EN_N bit mustn't be touched */
185 trans
= (pmac_mb
.model_id
!= PMAC_TYPE_YOSEMITE
&&
186 pmac_mb
.model_id
!= PMAC_TYPE_YIKES
);
188 #ifdef CONFIG_ADB_PMU
189 if ((param
& 0xfff) == PMAC_SCC_IRDA
)
191 #endif /* CONFIG_ADB_PMU */
193 fcr
= MACIO_IN32(OHARE_FCR
);
194 /* Check if scc cell need enabling */
195 if (!(fcr
& OH_SCC_ENABLE
)) {
196 fcr
|= OH_SCC_ENABLE
;
198 /* Side effect: this will also power up the
199 * modem, but it's too messy to figure out on which
200 * ports this controls the tranceiver and on which
201 * it controls the modem
204 fcr
&= ~HRW_SCC_TRANS_EN_N
;
205 MACIO_OUT32(OHARE_FCR
, fcr
);
206 fcr
|= (rmask
= HRW_RESET_SCC
);
207 MACIO_OUT32(OHARE_FCR
, fcr
);
209 fcr
|= (rmask
= OH_SCC_RESET
);
210 MACIO_OUT32(OHARE_FCR
, fcr
);
213 (void)MACIO_IN32(OHARE_FCR
);
217 MACIO_OUT32(OHARE_FCR
, fcr
);
219 if (chan_mask
& MACIO_FLAG_SCCA_ON
)
221 if (chan_mask
& MACIO_FLAG_SCCB_ON
)
223 MACIO_OUT32(OHARE_FCR
, fcr
);
224 macio
->flags
|= chan_mask
;
226 if (param
& PMAC_SCC_FLAG_XMON
)
227 macio
->flags
|= MACIO_FLAG_SCC_LOCKED
;
229 if (macio
->flags
& MACIO_FLAG_SCC_LOCKED
)
232 fcr
= MACIO_IN32(OHARE_FCR
);
233 if (chan_mask
& MACIO_FLAG_SCCA_ON
)
235 if (chan_mask
& MACIO_FLAG_SCCB_ON
)
237 MACIO_OUT32(OHARE_FCR
, fcr
);
238 if ((fcr
& (OH_SCCA_IO
| OH_SCCB_IO
)) == 0) {
239 fcr
&= ~OH_SCC_ENABLE
;
241 fcr
|= HRW_SCC_TRANS_EN_N
;
242 MACIO_OUT32(OHARE_FCR
, fcr
);
244 macio
->flags
&= ~(chan_mask
);
247 #ifdef CONFIG_ADB_PMU
248 if ((param
& 0xfff) == PMAC_SCC_IRDA
)
250 #endif /* CONFIG_ADB_PMU */
255 static long ohare_floppy_enable(struct device_node
*node
, long param
,
258 return simple_feature_tweak(node
, macio_ohare
,
259 OHARE_FCR
, OH_FLOPPY_ENABLE
, value
);
262 static long ohare_mesh_enable(struct device_node
*node
, long param
, long value
)
264 return simple_feature_tweak(node
, macio_ohare
,
265 OHARE_FCR
, OH_MESH_ENABLE
, value
);
268 static long ohare_ide_enable(struct device_node
*node
, long param
, long value
)
272 /* For some reason, setting the bit in set_initial_features()
273 * doesn't stick. I'm still investigating... --BenH.
276 simple_feature_tweak(node
, macio_ohare
,
277 OHARE_FCR
, OH_IOBUS_ENABLE
, 1);
278 return simple_feature_tweak(node
, macio_ohare
,
279 OHARE_FCR
, OH_IDE0_ENABLE
, value
);
281 return simple_feature_tweak(node
, macio_ohare
,
282 OHARE_FCR
, OH_BAY_IDE_ENABLE
, value
);
288 static long ohare_ide_reset(struct device_node
*node
, long param
, long value
)
292 return simple_feature_tweak(node
, macio_ohare
,
293 OHARE_FCR
, OH_IDE0_RESET_N
, !value
);
295 return simple_feature_tweak(node
, macio_ohare
,
296 OHARE_FCR
, OH_IDE1_RESET_N
, !value
);
302 static long ohare_sleep_state(struct device_node
*node
, long param
, long value
)
304 struct macio_chip
* macio
= &macio_chips
[0];
306 if ((pmac_mb
.board_flags
& PMAC_MB_CAN_SLEEP
) == 0)
309 MACIO_BIC(OHARE_FCR
, OH_IOBUS_ENABLE
);
310 } else if (value
== 0) {
311 MACIO_BIS(OHARE_FCR
, OH_IOBUS_ENABLE
);
317 static long heathrow_modem_enable(struct device_node
*node
, long param
,
320 struct macio_chip
* macio
;
324 macio
= macio_find(node
, macio_unknown
);
327 gpio
= MACIO_IN8(HRW_GPIO_MODEM_RESET
) & ~1;
330 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
);
332 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
335 if (pmac_mb
.model_id
!= PMAC_TYPE_YOSEMITE
&&
336 pmac_mb
.model_id
!= PMAC_TYPE_YIKES
) {
339 MACIO_BIC(HEATHROW_FCR
, HRW_SCC_TRANS_EN_N
);
341 MACIO_BIS(HEATHROW_FCR
, HRW_SCC_TRANS_EN_N
);
343 (void)MACIO_IN32(HEATHROW_FCR
);
348 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
| 1);
349 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
350 UNLOCK(flags
); mdelay(250); LOCK(flags
);
351 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
);
352 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
353 UNLOCK(flags
); mdelay(250); LOCK(flags
);
354 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
| 1);
355 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
356 UNLOCK(flags
); mdelay(250);
361 static long heathrow_floppy_enable(struct device_node
*node
, long param
,
364 return simple_feature_tweak(node
, macio_unknown
,
366 HRW_SWIM_ENABLE
|HRW_BAY_FLOPPY_ENABLE
,
370 static long heathrow_mesh_enable(struct device_node
*node
, long param
,
373 struct macio_chip
* macio
;
376 macio
= macio_find(node
, macio_unknown
);
380 /* Set clear mesh cell enable */
382 MACIO_BIS(HEATHROW_FCR
, HRW_MESH_ENABLE
);
384 MACIO_BIC(HEATHROW_FCR
, HRW_MESH_ENABLE
);
385 (void)MACIO_IN32(HEATHROW_FCR
);
387 /* Set/Clear termination power */
389 MACIO_BIC(HEATHROW_MBCR
, 0x04000000);
391 MACIO_BIS(HEATHROW_MBCR
, 0x04000000);
392 (void)MACIO_IN32(HEATHROW_MBCR
);
399 static long heathrow_ide_enable(struct device_node
*node
, long param
,
404 return simple_feature_tweak(node
, macio_unknown
,
405 HEATHROW_FCR
, HRW_IDE0_ENABLE
, value
);
407 return simple_feature_tweak(node
, macio_unknown
,
408 HEATHROW_FCR
, HRW_BAY_IDE_ENABLE
, value
);
414 static long heathrow_ide_reset(struct device_node
*node
, long param
,
419 return simple_feature_tweak(node
, macio_unknown
,
420 HEATHROW_FCR
, HRW_IDE0_RESET_N
, !value
);
422 return simple_feature_tweak(node
, macio_unknown
,
423 HEATHROW_FCR
, HRW_IDE1_RESET_N
, !value
);
429 static long heathrow_bmac_enable(struct device_node
*node
, long param
,
432 struct macio_chip
* macio
;
435 macio
= macio_find(node
, 0);
440 MACIO_BIS(HEATHROW_FCR
, HRW_BMAC_IO_ENABLE
);
441 MACIO_BIS(HEATHROW_FCR
, HRW_BMAC_RESET
);
443 (void)MACIO_IN32(HEATHROW_FCR
);
446 MACIO_BIC(HEATHROW_FCR
, HRW_BMAC_RESET
);
448 (void)MACIO_IN32(HEATHROW_FCR
);
452 MACIO_BIC(HEATHROW_FCR
, HRW_BMAC_IO_ENABLE
);
458 static long heathrow_sound_enable(struct device_node
*node
, long param
,
461 struct macio_chip
* macio
;
464 /* B&W G3 and Yikes don't support that properly (the
465 * sound appear to never come back after beeing shut down).
467 if (pmac_mb
.model_id
== PMAC_TYPE_YOSEMITE
||
468 pmac_mb
.model_id
== PMAC_TYPE_YIKES
)
471 macio
= macio_find(node
, 0);
476 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
477 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
479 (void)MACIO_IN32(HEATHROW_FCR
);
482 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
483 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
489 static u32 save_fcr
[6];
490 static u32 save_mbcr
;
491 static struct dbdma_regs save_dbdma
[13];
492 static struct dbdma_regs save_alt_dbdma
[13];
494 static void dbdma_save(struct macio_chip
*macio
, struct dbdma_regs
*save
)
498 /* Save state & config of DBDMA channels */
499 for (i
= 0; i
< 13; i
++) {
500 volatile struct dbdma_regs __iomem
* chan
= (void __iomem
*)
501 (macio
->base
+ ((0x8000+i
*0x100)>>2));
502 save
[i
].cmdptr_hi
= in_le32(&chan
->cmdptr_hi
);
503 save
[i
].cmdptr
= in_le32(&chan
->cmdptr
);
504 save
[i
].intr_sel
= in_le32(&chan
->intr_sel
);
505 save
[i
].br_sel
= in_le32(&chan
->br_sel
);
506 save
[i
].wait_sel
= in_le32(&chan
->wait_sel
);
510 static void dbdma_restore(struct macio_chip
*macio
, struct dbdma_regs
*save
)
514 /* Save state & config of DBDMA channels */
515 for (i
= 0; i
< 13; i
++) {
516 volatile struct dbdma_regs __iomem
* chan
= (void __iomem
*)
517 (macio
->base
+ ((0x8000+i
*0x100)>>2));
518 out_le32(&chan
->control
, (ACTIVE
|DEAD
|WAKE
|FLUSH
|PAUSE
|RUN
)<<16);
519 while (in_le32(&chan
->status
) & ACTIVE
)
521 out_le32(&chan
->cmdptr_hi
, save
[i
].cmdptr_hi
);
522 out_le32(&chan
->cmdptr
, save
[i
].cmdptr
);
523 out_le32(&chan
->intr_sel
, save
[i
].intr_sel
);
524 out_le32(&chan
->br_sel
, save
[i
].br_sel
);
525 out_le32(&chan
->wait_sel
, save
[i
].wait_sel
);
529 static void heathrow_sleep(struct macio_chip
*macio
, int secondary
)
532 dbdma_save(macio
, save_alt_dbdma
);
533 save_fcr
[2] = MACIO_IN32(0x38);
534 save_fcr
[3] = MACIO_IN32(0x3c);
536 dbdma_save(macio
, save_dbdma
);
537 save_fcr
[0] = MACIO_IN32(0x38);
538 save_fcr
[1] = MACIO_IN32(0x3c);
539 save_mbcr
= MACIO_IN32(0x34);
540 /* Make sure sound is shut down */
541 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
542 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
543 /* This seems to be necessary as well or the fan
544 * keeps coming up and battery drains fast */
545 MACIO_BIC(HEATHROW_FCR
, HRW_IOBUS_ENABLE
);
546 MACIO_BIC(HEATHROW_FCR
, HRW_IDE0_RESET_N
);
547 /* Make sure eth is down even if module or sleep
548 * won't work properly */
549 MACIO_BIC(HEATHROW_FCR
, HRW_BMAC_IO_ENABLE
| HRW_BMAC_RESET
);
551 /* Make sure modem is shut down */
552 MACIO_OUT8(HRW_GPIO_MODEM_RESET
,
553 MACIO_IN8(HRW_GPIO_MODEM_RESET
) & ~1);
554 MACIO_BIS(HEATHROW_FCR
, HRW_SCC_TRANS_EN_N
);
555 MACIO_BIC(HEATHROW_FCR
, OH_SCCA_IO
|OH_SCCB_IO
|HRW_SCC_ENABLE
);
557 /* Let things settle */
558 (void)MACIO_IN32(HEATHROW_FCR
);
561 static void heathrow_wakeup(struct macio_chip
*macio
, int secondary
)
564 MACIO_OUT32(0x38, save_fcr
[2]);
565 (void)MACIO_IN32(0x38);
567 MACIO_OUT32(0x3c, save_fcr
[3]);
568 (void)MACIO_IN32(0x38);
570 dbdma_restore(macio
, save_alt_dbdma
);
572 MACIO_OUT32(0x38, save_fcr
[0] | HRW_IOBUS_ENABLE
);
573 (void)MACIO_IN32(0x38);
575 MACIO_OUT32(0x3c, save_fcr
[1]);
576 (void)MACIO_IN32(0x38);
578 MACIO_OUT32(0x34, save_mbcr
);
579 (void)MACIO_IN32(0x38);
581 dbdma_restore(macio
, save_dbdma
);
585 static long heathrow_sleep_state(struct device_node
*node
, long param
,
588 if ((pmac_mb
.board_flags
& PMAC_MB_CAN_SLEEP
) == 0)
591 if (macio_chips
[1].type
== macio_gatwick
)
592 heathrow_sleep(&macio_chips
[0], 1);
593 heathrow_sleep(&macio_chips
[0], 0);
594 } else if (value
== 0) {
595 heathrow_wakeup(&macio_chips
[0], 0);
596 if (macio_chips
[1].type
== macio_gatwick
)
597 heathrow_wakeup(&macio_chips
[0], 1);
602 static long core99_scc_enable(struct device_node
*node
, long param
, long value
)
604 struct macio_chip
* macio
;
606 unsigned long chan_mask
;
609 macio
= macio_find(node
, 0);
612 if (!strcmp(node
->name
, "ch-a"))
613 chan_mask
= MACIO_FLAG_SCCA_ON
;
614 else if (!strcmp(node
->name
, "ch-b"))
615 chan_mask
= MACIO_FLAG_SCCB_ON
;
620 int need_reset_scc
= 0;
621 int need_reset_irda
= 0;
624 fcr
= MACIO_IN32(KEYLARGO_FCR0
);
625 /* Check if scc cell need enabling */
626 if (!(fcr
& KL0_SCC_CELL_ENABLE
)) {
627 fcr
|= KL0_SCC_CELL_ENABLE
;
630 if (chan_mask
& MACIO_FLAG_SCCA_ON
) {
631 fcr
|= KL0_SCCA_ENABLE
;
632 /* Don't enable line drivers for I2S modem */
633 if ((param
& 0xfff) == PMAC_SCC_I2S1
)
634 fcr
&= ~KL0_SCC_A_INTF_ENABLE
;
636 fcr
|= KL0_SCC_A_INTF_ENABLE
;
638 if (chan_mask
& MACIO_FLAG_SCCB_ON
) {
639 fcr
|= KL0_SCCB_ENABLE
;
640 /* Perform irda specific inits */
641 if ((param
& 0xfff) == PMAC_SCC_IRDA
) {
642 fcr
&= ~KL0_SCC_B_INTF_ENABLE
;
643 fcr
|= KL0_IRDA_ENABLE
;
644 fcr
|= KL0_IRDA_CLK32_ENABLE
| KL0_IRDA_CLK19_ENABLE
;
645 fcr
|= KL0_IRDA_SOURCE1_SEL
;
646 fcr
&= ~(KL0_IRDA_FAST_CONNECT
|KL0_IRDA_DEFAULT1
|KL0_IRDA_DEFAULT0
);
647 fcr
&= ~(KL0_IRDA_SOURCE2_SEL
|KL0_IRDA_HIGH_BAND
);
650 fcr
|= KL0_SCC_B_INTF_ENABLE
;
652 MACIO_OUT32(KEYLARGO_FCR0
, fcr
);
653 macio
->flags
|= chan_mask
;
654 if (need_reset_scc
) {
655 MACIO_BIS(KEYLARGO_FCR0
, KL0_SCC_RESET
);
656 (void)MACIO_IN32(KEYLARGO_FCR0
);
660 MACIO_BIC(KEYLARGO_FCR0
, KL0_SCC_RESET
);
662 if (need_reset_irda
) {
663 MACIO_BIS(KEYLARGO_FCR0
, KL0_IRDA_RESET
);
664 (void)MACIO_IN32(KEYLARGO_FCR0
);
668 MACIO_BIC(KEYLARGO_FCR0
, KL0_IRDA_RESET
);
671 if (param
& PMAC_SCC_FLAG_XMON
)
672 macio
->flags
|= MACIO_FLAG_SCC_LOCKED
;
674 if (macio
->flags
& MACIO_FLAG_SCC_LOCKED
)
677 fcr
= MACIO_IN32(KEYLARGO_FCR0
);
678 if (chan_mask
& MACIO_FLAG_SCCA_ON
)
679 fcr
&= ~KL0_SCCA_ENABLE
;
680 if (chan_mask
& MACIO_FLAG_SCCB_ON
) {
681 fcr
&= ~KL0_SCCB_ENABLE
;
682 /* Perform irda specific clears */
683 if ((param
& 0xfff) == PMAC_SCC_IRDA
) {
684 fcr
&= ~KL0_IRDA_ENABLE
;
685 fcr
&= ~(KL0_IRDA_CLK32_ENABLE
| KL0_IRDA_CLK19_ENABLE
);
686 fcr
&= ~(KL0_IRDA_FAST_CONNECT
|KL0_IRDA_DEFAULT1
|KL0_IRDA_DEFAULT0
);
687 fcr
&= ~(KL0_IRDA_SOURCE1_SEL
|KL0_IRDA_SOURCE2_SEL
|KL0_IRDA_HIGH_BAND
);
690 MACIO_OUT32(KEYLARGO_FCR0
, fcr
);
691 if ((fcr
& (KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
)) == 0) {
692 fcr
&= ~KL0_SCC_CELL_ENABLE
;
693 MACIO_OUT32(KEYLARGO_FCR0
, fcr
);
695 macio
->flags
&= ~(chan_mask
);
703 core99_modem_enable(struct device_node
*node
, long param
, long value
)
705 struct macio_chip
* macio
;
709 /* Hack for internal USB modem */
711 if (macio_chips
[0].type
!= macio_keylargo
)
713 node
= macio_chips
[0].of_node
;
715 macio
= macio_find(node
, 0);
718 gpio
= MACIO_IN8(KL_GPIO_MODEM_RESET
);
719 gpio
|= KEYLARGO_GPIO_OUTPUT_ENABLE
;
720 gpio
&= ~KEYLARGO_GPIO_OUTOUT_DATA
;
724 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
726 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
731 MACIO_BIC(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
733 (void)MACIO_IN32(KEYLARGO_FCR2
);
736 MACIO_BIS(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
741 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
742 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
743 UNLOCK(flags
); mdelay(250); LOCK(flags
);
744 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
745 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
746 UNLOCK(flags
); mdelay(250); LOCK(flags
);
747 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
748 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
749 UNLOCK(flags
); mdelay(250);
755 pangea_modem_enable(struct device_node
*node
, long param
, long value
)
757 struct macio_chip
* macio
;
761 /* Hack for internal USB modem */
763 if (macio_chips
[0].type
!= macio_pangea
&&
764 macio_chips
[0].type
!= macio_intrepid
)
766 node
= macio_chips
[0].of_node
;
768 macio
= macio_find(node
, 0);
771 gpio
= MACIO_IN8(KL_GPIO_MODEM_RESET
);
772 gpio
|= KEYLARGO_GPIO_OUTPUT_ENABLE
;
773 gpio
&= ~KEYLARGO_GPIO_OUTOUT_DATA
;
777 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
779 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
784 MACIO_OUT8(KL_GPIO_MODEM_POWER
,
785 KEYLARGO_GPIO_OUTPUT_ENABLE
);
787 (void)MACIO_IN32(KEYLARGO_FCR2
);
790 MACIO_OUT8(KL_GPIO_MODEM_POWER
,
791 KEYLARGO_GPIO_OUTPUT_ENABLE
| KEYLARGO_GPIO_OUTOUT_DATA
);
796 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
797 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
798 UNLOCK(flags
); mdelay(250); LOCK(flags
);
799 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
800 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
801 UNLOCK(flags
); mdelay(250); LOCK(flags
);
802 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
803 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
804 UNLOCK(flags
); mdelay(250);
810 core99_ata100_enable(struct device_node
*node
, long value
)
813 struct pci_dev
*pdev
= NULL
;
817 if (uninorth_rev
< 0x24)
822 UN_BIS(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_ATA100
);
824 UN_BIC(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_ATA100
);
825 (void)UN_IN(UNI_N_CLOCK_CNTL
);
830 if (pci_device_from_OF_node(node
, &pbus
, &pid
) == 0)
831 pdev
= pci_get_bus_and_slot(pbus
, pid
);
834 rc
= pci_enable_device(pdev
);
836 pci_set_master(pdev
);
845 core99_ide_enable(struct device_node
*node
, long param
, long value
)
847 /* Bus ID 0 to 2 are KeyLargo based IDE, busID 3 is U2
852 return simple_feature_tweak(node
, macio_unknown
,
853 KEYLARGO_FCR1
, KL1_EIDE0_ENABLE
, value
);
855 return simple_feature_tweak(node
, macio_unknown
,
856 KEYLARGO_FCR1
, KL1_EIDE1_ENABLE
, value
);
858 return simple_feature_tweak(node
, macio_unknown
,
859 KEYLARGO_FCR1
, KL1_UIDE_ENABLE
, value
);
861 return core99_ata100_enable(node
, value
);
868 core99_ide_reset(struct device_node
*node
, long param
, long value
)
872 return simple_feature_tweak(node
, macio_unknown
,
873 KEYLARGO_FCR1
, KL1_EIDE0_RESET_N
, !value
);
875 return simple_feature_tweak(node
, macio_unknown
,
876 KEYLARGO_FCR1
, KL1_EIDE1_RESET_N
, !value
);
878 return simple_feature_tweak(node
, macio_unknown
,
879 KEYLARGO_FCR1
, KL1_UIDE_RESET_N
, !value
);
886 core99_gmac_enable(struct device_node
*node
, long param
, long value
)
892 UN_BIS(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_GMAC
);
894 UN_BIC(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_GMAC
);
895 (void)UN_IN(UNI_N_CLOCK_CNTL
);
903 core99_gmac_phy_reset(struct device_node
*node
, long param
, long value
)
906 struct macio_chip
*macio
;
908 macio
= &macio_chips
[0];
909 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
910 macio
->type
!= macio_intrepid
)
914 MACIO_OUT8(KL_GPIO_ETH_PHY_RESET
, KEYLARGO_GPIO_OUTPUT_ENABLE
);
915 (void)MACIO_IN8(KL_GPIO_ETH_PHY_RESET
);
919 MACIO_OUT8(KL_GPIO_ETH_PHY_RESET
, /*KEYLARGO_GPIO_OUTPUT_ENABLE | */
920 KEYLARGO_GPIO_OUTOUT_DATA
);
928 core99_sound_chip_enable(struct device_node
*node
, long param
, long value
)
930 struct macio_chip
* macio
;
933 macio
= macio_find(node
, 0);
937 /* Do a better probe code, screamer G4 desktops &
938 * iMacs can do that too, add a recalibrate in
941 if (pmac_mb
.model_id
== PMAC_TYPE_PISMO
||
942 pmac_mb
.model_id
== PMAC_TYPE_TITANIUM
) {
945 MACIO_OUT8(KL_GPIO_SOUND_POWER
,
946 KEYLARGO_GPIO_OUTPUT_ENABLE
|
947 KEYLARGO_GPIO_OUTOUT_DATA
);
949 MACIO_OUT8(KL_GPIO_SOUND_POWER
,
950 KEYLARGO_GPIO_OUTPUT_ENABLE
);
951 (void)MACIO_IN8(KL_GPIO_SOUND_POWER
);
958 core99_airport_enable(struct device_node
*node
, long param
, long value
)
960 struct macio_chip
* macio
;
964 macio
= macio_find(node
, 0);
968 /* Hint: we allow passing of macio itself for the sake of the
971 if (node
!= macio
->of_node
&&
972 (!node
->parent
|| node
->parent
!= macio
->of_node
))
974 state
= (macio
->flags
& MACIO_FLAG_AIRPORT_ON
) != 0;
978 /* This code is a reproduction of OF enable-cardslot
979 * and init-wireless methods, slightly hacked until
983 MACIO_OUT8(KEYLARGO_GPIO_0
+0xf, 5);
984 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xf);
988 MACIO_OUT8(KEYLARGO_GPIO_0
+0xf, 4);
989 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xf);
995 MACIO_BIC(KEYLARGO_FCR2
, KL2_CARDSEL_16
);
996 (void)MACIO_IN32(KEYLARGO_FCR2
);
998 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+0xb, 0);
999 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+0xb);
1001 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+0xa, 0x28);
1002 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+0xa);
1004 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+0xd, 0x28);
1005 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+0xd);
1007 MACIO_OUT8(KEYLARGO_GPIO_0
+0xd, 0x28);
1008 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xd);
1010 MACIO_OUT8(KEYLARGO_GPIO_0
+0xe, 0x28);
1011 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xe);
1014 MACIO_OUT32(0x1c000, 0);
1016 MACIO_OUT8(0x1a3e0, 0x41);
1017 (void)MACIO_IN8(0x1a3e0);
1020 MACIO_BIS(KEYLARGO_FCR2
, KL2_CARDSEL_16
);
1021 (void)MACIO_IN32(KEYLARGO_FCR2
);
1025 macio
->flags
|= MACIO_FLAG_AIRPORT_ON
;
1028 MACIO_BIC(KEYLARGO_FCR2
, KL2_CARDSEL_16
);
1029 (void)MACIO_IN32(KEYLARGO_FCR2
);
1030 MACIO_OUT8(KL_GPIO_AIRPORT_0
, 0);
1031 MACIO_OUT8(KL_GPIO_AIRPORT_1
, 0);
1032 MACIO_OUT8(KL_GPIO_AIRPORT_2
, 0);
1033 MACIO_OUT8(KL_GPIO_AIRPORT_3
, 0);
1034 MACIO_OUT8(KL_GPIO_AIRPORT_4
, 0);
1035 (void)MACIO_IN8(KL_GPIO_AIRPORT_4
);
1038 macio
->flags
&= ~MACIO_FLAG_AIRPORT_ON
;
1045 core99_reset_cpu(struct device_node
*node
, long param
, long value
)
1047 unsigned int reset_io
= 0;
1048 unsigned long flags
;
1049 struct macio_chip
*macio
;
1050 struct device_node
*np
;
1051 struct device_node
*cpus
;
1052 const int dflt_reset_lines
[] = { KL_GPIO_RESET_CPU0
,
1055 KL_GPIO_RESET_CPU3
};
1057 macio
= &macio_chips
[0];
1058 if (macio
->type
!= macio_keylargo
)
1061 cpus
= of_find_node_by_path("/cpus");
1064 for (np
= cpus
->child
; np
!= NULL
; np
= np
->sibling
) {
1065 const u32
*num
= of_get_property(np
, "reg", NULL
);
1066 const u32
*rst
= of_get_property(np
, "soft-reset", NULL
);
1067 if (num
== NULL
|| rst
== NULL
)
1069 if (param
== *num
) {
1075 if (np
== NULL
|| reset_io
== 0)
1076 reset_io
= dflt_reset_lines
[param
];
1079 MACIO_OUT8(reset_io
, KEYLARGO_GPIO_OUTPUT_ENABLE
);
1080 (void)MACIO_IN8(reset_io
);
1082 MACIO_OUT8(reset_io
, 0);
1083 (void)MACIO_IN8(reset_io
);
1088 #endif /* CONFIG_SMP */
1091 core99_usb_enable(struct device_node
*node
, long param
, long value
)
1093 struct macio_chip
*macio
;
1094 unsigned long flags
;
1099 macio
= &macio_chips
[0];
1100 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1101 macio
->type
!= macio_intrepid
)
1104 prop
= of_get_property(node
, "AAPL,clock-id", NULL
);
1107 if (strncmp(prop
, "usb0u048", 8) == 0)
1109 else if (strncmp(prop
, "usb1u148", 8) == 0)
1111 else if (strncmp(prop
, "usb2u248", 8) == 0)
1116 /* Sorry for the brute-force locking, but this is only used during
1117 * sleep and the timing seem to be critical
1123 MACIO_BIC(KEYLARGO_FCR0
, (KL0_USB0_PAD_SUSPEND0
| KL0_USB0_PAD_SUSPEND1
));
1124 (void)MACIO_IN32(KEYLARGO_FCR0
);
1128 MACIO_BIS(KEYLARGO_FCR0
, KL0_USB0_CELL_ENABLE
);
1129 } else if (number
== 2) {
1130 MACIO_BIC(KEYLARGO_FCR0
, (KL0_USB1_PAD_SUSPEND0
| KL0_USB1_PAD_SUSPEND1
));
1132 (void)MACIO_IN32(KEYLARGO_FCR0
);
1135 MACIO_BIS(KEYLARGO_FCR0
, KL0_USB1_CELL_ENABLE
);
1136 } else if (number
== 4) {
1137 MACIO_BIC(KEYLARGO_FCR1
, (KL1_USB2_PAD_SUSPEND0
| KL1_USB2_PAD_SUSPEND1
));
1139 (void)MACIO_IN32(KEYLARGO_FCR1
);
1142 MACIO_BIS(KEYLARGO_FCR1
, KL1_USB2_CELL_ENABLE
);
1145 reg
= MACIO_IN32(KEYLARGO_FCR4
);
1146 reg
&= ~(KL4_PORT_WAKEUP_ENABLE(number
) | KL4_PORT_RESUME_WAKE_EN(number
) |
1147 KL4_PORT_CONNECT_WAKE_EN(number
) | KL4_PORT_DISCONNECT_WAKE_EN(number
));
1148 reg
&= ~(KL4_PORT_WAKEUP_ENABLE(number
+1) | KL4_PORT_RESUME_WAKE_EN(number
+1) |
1149 KL4_PORT_CONNECT_WAKE_EN(number
+1) | KL4_PORT_DISCONNECT_WAKE_EN(number
+1));
1150 MACIO_OUT32(KEYLARGO_FCR4
, reg
);
1151 (void)MACIO_IN32(KEYLARGO_FCR4
);
1154 reg
= MACIO_IN32(KEYLARGO_FCR3
);
1155 reg
&= ~(KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1156 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0));
1157 reg
&= ~(KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1158 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1));
1159 MACIO_OUT32(KEYLARGO_FCR3
, reg
);
1160 (void)MACIO_IN32(KEYLARGO_FCR3
);
1163 if (macio
->type
== macio_intrepid
) {
1164 /* wait for clock stopped bits to clear */
1165 u32 test0
= 0, test1
= 0;
1166 u32 status0
, status1
;
1172 test0
= UNI_N_CLOCK_STOPPED_USB0
;
1173 test1
= UNI_N_CLOCK_STOPPED_USB0PCI
;
1176 test0
= UNI_N_CLOCK_STOPPED_USB1
;
1177 test1
= UNI_N_CLOCK_STOPPED_USB1PCI
;
1180 test0
= UNI_N_CLOCK_STOPPED_USB2
;
1181 test1
= UNI_N_CLOCK_STOPPED_USB2PCI
;
1185 if (--timeout
<= 0) {
1186 printk(KERN_ERR
"core99_usb_enable: "
1187 "Timeout waiting for clocks\n");
1191 status0
= UN_IN(UNI_N_CLOCK_STOP_STATUS0
);
1192 status1
= UN_IN(UNI_N_CLOCK_STOP_STATUS1
);
1193 } while ((status0
& test0
) | (status1
& test1
));
1199 reg
= MACIO_IN32(KEYLARGO_FCR4
);
1200 reg
|= KL4_PORT_WAKEUP_ENABLE(number
) | KL4_PORT_RESUME_WAKE_EN(number
) |
1201 KL4_PORT_CONNECT_WAKE_EN(number
) | KL4_PORT_DISCONNECT_WAKE_EN(number
);
1202 reg
|= KL4_PORT_WAKEUP_ENABLE(number
+1) | KL4_PORT_RESUME_WAKE_EN(number
+1) |
1203 KL4_PORT_CONNECT_WAKE_EN(number
+1) | KL4_PORT_DISCONNECT_WAKE_EN(number
+1);
1204 MACIO_OUT32(KEYLARGO_FCR4
, reg
);
1205 (void)MACIO_IN32(KEYLARGO_FCR4
);
1208 reg
= MACIO_IN32(KEYLARGO_FCR3
);
1209 reg
|= KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1210 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0);
1211 reg
|= KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1212 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1);
1213 MACIO_OUT32(KEYLARGO_FCR3
, reg
);
1214 (void)MACIO_IN32(KEYLARGO_FCR3
);
1218 if (macio
->type
!= macio_intrepid
)
1219 MACIO_BIC(KEYLARGO_FCR0
, KL0_USB0_CELL_ENABLE
);
1220 (void)MACIO_IN32(KEYLARGO_FCR0
);
1222 MACIO_BIS(KEYLARGO_FCR0
, (KL0_USB0_PAD_SUSPEND0
| KL0_USB0_PAD_SUSPEND1
));
1223 (void)MACIO_IN32(KEYLARGO_FCR0
);
1224 } else if (number
== 2) {
1225 if (macio
->type
!= macio_intrepid
)
1226 MACIO_BIC(KEYLARGO_FCR0
, KL0_USB1_CELL_ENABLE
);
1227 (void)MACIO_IN32(KEYLARGO_FCR0
);
1229 MACIO_BIS(KEYLARGO_FCR0
, (KL0_USB1_PAD_SUSPEND0
| KL0_USB1_PAD_SUSPEND1
));
1230 (void)MACIO_IN32(KEYLARGO_FCR0
);
1231 } else if (number
== 4) {
1233 MACIO_BIS(KEYLARGO_FCR1
, (KL1_USB2_PAD_SUSPEND0
| KL1_USB2_PAD_SUSPEND1
));
1234 (void)MACIO_IN32(KEYLARGO_FCR1
);
1244 core99_firewire_enable(struct device_node
*node
, long param
, long value
)
1246 unsigned long flags
;
1247 struct macio_chip
*macio
;
1249 macio
= &macio_chips
[0];
1250 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1251 macio
->type
!= macio_intrepid
)
1253 if (!(macio
->flags
& MACIO_FLAG_FW_SUPPORTED
))
1258 UN_BIS(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_FW
);
1259 (void)UN_IN(UNI_N_CLOCK_CNTL
);
1261 UN_BIC(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_FW
);
1262 (void)UN_IN(UNI_N_CLOCK_CNTL
);
1271 core99_firewire_cable_power(struct device_node
*node
, long param
, long value
)
1273 unsigned long flags
;
1274 struct macio_chip
*macio
;
1276 /* Trick: we allow NULL node */
1277 if ((pmac_mb
.board_flags
& PMAC_MB_HAS_FW_POWER
) == 0)
1279 macio
= &macio_chips
[0];
1280 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1281 macio
->type
!= macio_intrepid
)
1283 if (!(macio
->flags
& MACIO_FLAG_FW_SUPPORTED
))
1288 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER
, 0);
1289 MACIO_IN8(KL_GPIO_FW_CABLE_POWER
);
1292 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER
, 4);
1293 MACIO_IN8(KL_GPIO_FW_CABLE_POWER
); udelay(10);
1302 intrepid_aack_delay_enable(struct device_node
*node
, long param
, long value
)
1304 unsigned long flags
;
1306 if (uninorth_rev
< 0xd2)
1311 UN_BIS(UNI_N_AACK_DELAY
, UNI_N_AACK_DELAY_ENABLE
);
1313 UN_BIC(UNI_N_AACK_DELAY
, UNI_N_AACK_DELAY_ENABLE
);
1320 #endif /* CONFIG_POWER4 */
1323 core99_read_gpio(struct device_node
*node
, long param
, long value
)
1325 struct macio_chip
*macio
= &macio_chips
[0];
1327 return MACIO_IN8(param
);
1332 core99_write_gpio(struct device_node
*node
, long param
, long value
)
1334 struct macio_chip
*macio
= &macio_chips
[0];
1336 MACIO_OUT8(param
, (u8
)(value
& 0xff));
1340 #ifdef CONFIG_POWER4
1341 static long g5_gmac_enable(struct device_node
*node
, long param
, long value
)
1343 struct macio_chip
*macio
= &macio_chips
[0];
1344 unsigned long flags
;
1351 MACIO_BIS(KEYLARGO_FCR1
, K2_FCR1_GMAC_CLK_ENABLE
);
1353 k2_skiplist
[0] = NULL
;
1355 k2_skiplist
[0] = node
;
1357 MACIO_BIC(KEYLARGO_FCR1
, K2_FCR1_GMAC_CLK_ENABLE
);
1366 static long g5_fw_enable(struct device_node
*node
, long param
, long value
)
1368 struct macio_chip
*macio
= &macio_chips
[0];
1369 unsigned long flags
;
1376 MACIO_BIS(KEYLARGO_FCR1
, K2_FCR1_FW_CLK_ENABLE
);
1378 k2_skiplist
[1] = NULL
;
1380 k2_skiplist
[1] = node
;
1382 MACIO_BIC(KEYLARGO_FCR1
, K2_FCR1_FW_CLK_ENABLE
);
1391 static long g5_mpic_enable(struct device_node
*node
, long param
, long value
)
1393 unsigned long flags
;
1394 struct device_node
*parent
= of_get_parent(node
);
1399 is_u3
= strcmp(parent
->name
, "u3") == 0 ||
1400 strcmp(parent
->name
, "u4") == 0;
1401 of_node_put(parent
);
1406 UN_BIS(U3_TOGGLE_REG
, U3_MPIC_RESET
| U3_MPIC_OUTPUT_ENABLE
);
1412 static long g5_eth_phy_reset(struct device_node
*node
, long param
, long value
)
1414 struct macio_chip
*macio
= &macio_chips
[0];
1415 struct device_node
*phy
;
1419 * We must not reset the combo PHYs, only the BCM5221 found in
1422 phy
= of_get_next_child(node
, NULL
);
1425 need_reset
= of_device_is_compatible(phy
, "B5221");
1430 /* PHY reset is GPIO 29, not in device-tree unfortunately */
1431 MACIO_OUT8(K2_GPIO_EXTINT_0
+ 29,
1432 KEYLARGO_GPIO_OUTPUT_ENABLE
| KEYLARGO_GPIO_OUTOUT_DATA
);
1433 /* Thankfully, this is now always called at a time when we can
1434 * schedule by sungem.
1437 MACIO_OUT8(K2_GPIO_EXTINT_0
+ 29, 0);
1442 static long g5_i2s_enable(struct device_node
*node
, long param
, long value
)
1444 /* Very crude implementation for now */
1445 struct macio_chip
*macio
= &macio_chips
[0];
1446 unsigned long flags
;
1450 K2_FCR1_I2S0_CELL_ENABLE
|
1451 K2_FCR1_I2S0_CLK_ENABLE_BIT
| K2_FCR1_I2S0_ENABLE
,
1452 KL3_I2S0_CLK18_ENABLE
1454 { KL0_SCC_A_INTF_ENABLE
,
1455 K2_FCR1_I2S1_CELL_ENABLE
|
1456 K2_FCR1_I2S1_CLK_ENABLE_BIT
| K2_FCR1_I2S1_ENABLE
,
1457 KL3_I2S1_CLK18_ENABLE
1459 { KL0_SCC_B_INTF_ENABLE
,
1460 SH_FCR1_I2S2_CELL_ENABLE
|
1461 SH_FCR1_I2S2_CLK_ENABLE_BIT
| SH_FCR1_I2S2_ENABLE
,
1462 SH_FCR3_I2S2_CLK18_ENABLE
1466 if (macio
->type
!= macio_keylargo2
&& macio
->type
!= macio_shasta
)
1468 if (strncmp(node
->name
, "i2s-", 4))
1470 cell
= node
->name
[4] - 'a';
1476 if (macio
->type
== macio_shasta
)
1484 MACIO_BIC(KEYLARGO_FCR0
, fcrs
[cell
][0]);
1485 MACIO_BIS(KEYLARGO_FCR1
, fcrs
[cell
][1]);
1486 MACIO_BIS(KEYLARGO_FCR3
, fcrs
[cell
][2]);
1488 MACIO_BIC(KEYLARGO_FCR3
, fcrs
[cell
][2]);
1489 MACIO_BIC(KEYLARGO_FCR1
, fcrs
[cell
][1]);
1490 MACIO_BIS(KEYLARGO_FCR0
, fcrs
[cell
][0]);
1500 static long g5_reset_cpu(struct device_node
*node
, long param
, long value
)
1502 unsigned int reset_io
= 0;
1503 unsigned long flags
;
1504 struct macio_chip
*macio
;
1505 struct device_node
*np
;
1506 struct device_node
*cpus
;
1508 macio
= &macio_chips
[0];
1509 if (macio
->type
!= macio_keylargo2
&& macio
->type
!= macio_shasta
)
1512 cpus
= of_find_node_by_path("/cpus");
1515 for (np
= cpus
->child
; np
!= NULL
; np
= np
->sibling
) {
1516 const u32
*num
= of_get_property(np
, "reg", NULL
);
1517 const u32
*rst
= of_get_property(np
, "soft-reset", NULL
);
1518 if (num
== NULL
|| rst
== NULL
)
1520 if (param
== *num
) {
1526 if (np
== NULL
|| reset_io
== 0)
1530 MACIO_OUT8(reset_io
, KEYLARGO_GPIO_OUTPUT_ENABLE
);
1531 (void)MACIO_IN8(reset_io
);
1533 MACIO_OUT8(reset_io
, 0);
1534 (void)MACIO_IN8(reset_io
);
1539 #endif /* CONFIG_SMP */
1542 * This can be called from pmac_smp so isn't static
1544 * This takes the second CPU off the bus on dual CPU machines
1547 void g5_phy_disable_cpu1(void)
1549 if (uninorth_maj
== 3)
1550 UN_OUT(U3_API_PHY_CONFIG_1
, 0);
1552 #endif /* CONFIG_POWER4 */
1554 #ifndef CONFIG_POWER4
1558 static u32 save_gpio_levels
[2];
1559 static u8 save_gpio_extint
[KEYLARGO_GPIO_EXTINT_CNT
];
1560 static u8 save_gpio_normal
[KEYLARGO_GPIO_CNT
];
1561 static u32 save_unin_clock_ctl
;
1563 static void keylargo_shutdown(struct macio_chip
*macio
, int sleep_mode
)
1569 MACIO_BIS(KEYLARGO_FCR0
, KL0_USB_REF_SUSPEND
);
1570 (void)MACIO_IN32(KEYLARGO_FCR0
);
1574 MACIO_BIC(KEYLARGO_FCR0
,KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
|
1575 KL0_SCC_CELL_ENABLE
|
1576 KL0_IRDA_ENABLE
| KL0_IRDA_CLK32_ENABLE
|
1577 KL0_IRDA_CLK19_ENABLE
);
1579 MACIO_BIC(KEYLARGO_MBCR
, KL_MBCR_MB0_DEV_MASK
);
1580 MACIO_BIS(KEYLARGO_MBCR
, KL_MBCR_MB0_IDE_ENABLE
);
1582 MACIO_BIC(KEYLARGO_FCR1
,
1583 KL1_AUDIO_SEL_22MCLK
| KL1_AUDIO_CLK_ENABLE_BIT
|
1584 KL1_AUDIO_CLK_OUT_ENABLE
| KL1_AUDIO_CELL_ENABLE
|
1585 KL1_I2S0_CELL_ENABLE
| KL1_I2S0_CLK_ENABLE_BIT
|
1586 KL1_I2S0_ENABLE
| KL1_I2S1_CELL_ENABLE
|
1587 KL1_I2S1_CLK_ENABLE_BIT
| KL1_I2S1_ENABLE
|
1588 KL1_EIDE0_ENABLE
| KL1_EIDE0_RESET_N
|
1589 KL1_EIDE1_ENABLE
| KL1_EIDE1_RESET_N
|
1592 MACIO_BIS(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
1593 MACIO_BIC(KEYLARGO_FCR2
, KL2_IOBUS_ENABLE
);
1595 temp
= MACIO_IN32(KEYLARGO_FCR3
);
1596 if (macio
->rev
>= 2) {
1597 temp
|= KL3_SHUTDOWN_PLL2X
;
1599 temp
|= KL3_SHUTDOWN_PLL_TOTAL
;
1602 temp
|= KL3_SHUTDOWN_PLLKW6
| KL3_SHUTDOWN_PLLKW4
|
1603 KL3_SHUTDOWN_PLLKW35
;
1605 temp
|= KL3_SHUTDOWN_PLLKW12
;
1606 temp
&= ~(KL3_CLK66_ENABLE
| KL3_CLK49_ENABLE
| KL3_CLK45_ENABLE
1607 | KL3_CLK31_ENABLE
| KL3_I2S1_CLK18_ENABLE
| KL3_I2S0_CLK18_ENABLE
);
1609 temp
&= ~(KL3_TIMER_CLK18_ENABLE
| KL3_VIA_CLK16_ENABLE
);
1610 MACIO_OUT32(KEYLARGO_FCR3
, temp
);
1612 /* Flush posted writes & wait a bit */
1613 (void)MACIO_IN32(KEYLARGO_FCR0
); mdelay(1);
1616 static void pangea_shutdown(struct macio_chip
*macio
, int sleep_mode
)
1620 MACIO_BIC(KEYLARGO_FCR0
,KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
|
1621 KL0_SCC_CELL_ENABLE
|
1622 KL0_USB0_CELL_ENABLE
| KL0_USB1_CELL_ENABLE
);
1624 MACIO_BIC(KEYLARGO_FCR1
,
1625 KL1_AUDIO_SEL_22MCLK
| KL1_AUDIO_CLK_ENABLE_BIT
|
1626 KL1_AUDIO_CLK_OUT_ENABLE
| KL1_AUDIO_CELL_ENABLE
|
1627 KL1_I2S0_CELL_ENABLE
| KL1_I2S0_CLK_ENABLE_BIT
|
1628 KL1_I2S0_ENABLE
| KL1_I2S1_CELL_ENABLE
|
1629 KL1_I2S1_CLK_ENABLE_BIT
| KL1_I2S1_ENABLE
|
1631 if (pmac_mb
.board_flags
& PMAC_MB_MOBILE
)
1632 MACIO_BIC(KEYLARGO_FCR1
, KL1_UIDE_RESET_N
);
1634 MACIO_BIS(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
1636 temp
= MACIO_IN32(KEYLARGO_FCR3
);
1637 temp
|= KL3_SHUTDOWN_PLLKW6
| KL3_SHUTDOWN_PLLKW4
|
1638 KL3_SHUTDOWN_PLLKW35
;
1639 temp
&= ~(KL3_CLK49_ENABLE
| KL3_CLK45_ENABLE
| KL3_CLK31_ENABLE
1640 | KL3_I2S0_CLK18_ENABLE
| KL3_I2S1_CLK18_ENABLE
);
1642 temp
&= ~(KL3_VIA_CLK16_ENABLE
| KL3_TIMER_CLK18_ENABLE
);
1643 MACIO_OUT32(KEYLARGO_FCR3
, temp
);
1645 /* Flush posted writes & wait a bit */
1646 (void)MACIO_IN32(KEYLARGO_FCR0
); mdelay(1);
1649 static void intrepid_shutdown(struct macio_chip
*macio
, int sleep_mode
)
1653 MACIO_BIC(KEYLARGO_FCR0
,KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
|
1654 KL0_SCC_CELL_ENABLE
);
1656 MACIO_BIC(KEYLARGO_FCR1
,
1657 KL1_I2S0_CELL_ENABLE
| KL1_I2S0_CLK_ENABLE_BIT
|
1658 KL1_I2S0_ENABLE
| KL1_I2S1_CELL_ENABLE
|
1659 KL1_I2S1_CLK_ENABLE_BIT
| KL1_I2S1_ENABLE
|
1661 if (pmac_mb
.board_flags
& PMAC_MB_MOBILE
)
1662 MACIO_BIC(KEYLARGO_FCR1
, KL1_UIDE_RESET_N
);
1664 temp
= MACIO_IN32(KEYLARGO_FCR3
);
1665 temp
&= ~(KL3_CLK49_ENABLE
| KL3_CLK45_ENABLE
|
1666 KL3_I2S1_CLK18_ENABLE
| KL3_I2S0_CLK18_ENABLE
);
1668 temp
&= ~(KL3_TIMER_CLK18_ENABLE
| KL3_IT_VIA_CLK32_ENABLE
);
1669 MACIO_OUT32(KEYLARGO_FCR3
, temp
);
1671 /* Flush posted writes & wait a bit */
1672 (void)MACIO_IN32(KEYLARGO_FCR0
);
1680 struct macio_chip
*macio
;
1683 macio
= &macio_chips
[0];
1684 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1685 macio
->type
!= macio_intrepid
)
1688 /* We power off the wireless slot in case it was not done
1689 * by the driver. We don't power it on automatically however
1691 if (macio
->flags
& MACIO_FLAG_AIRPORT_ON
)
1692 core99_airport_enable(macio
->of_node
, 0, 0);
1694 /* We power off the FW cable. Should be done by the driver... */
1695 if (macio
->flags
& MACIO_FLAG_FW_SUPPORTED
) {
1696 core99_firewire_enable(NULL
, 0, 0);
1697 core99_firewire_cable_power(NULL
, 0, 0);
1700 /* We make sure int. modem is off (in case driver lost it) */
1701 if (macio
->type
== macio_keylargo
)
1702 core99_modem_enable(macio
->of_node
, 0, 0);
1704 pangea_modem_enable(macio
->of_node
, 0, 0);
1706 /* We make sure the sound is off as well */
1707 core99_sound_chip_enable(macio
->of_node
, 0, 0);
1710 * Save various bits of KeyLargo
1713 /* Save the state of the various GPIOs */
1714 save_gpio_levels
[0] = MACIO_IN32(KEYLARGO_GPIO_LEVELS0
);
1715 save_gpio_levels
[1] = MACIO_IN32(KEYLARGO_GPIO_LEVELS1
);
1716 for (i
=0; i
<KEYLARGO_GPIO_EXTINT_CNT
; i
++)
1717 save_gpio_extint
[i
] = MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+i
);
1718 for (i
=0; i
<KEYLARGO_GPIO_CNT
; i
++)
1719 save_gpio_normal
[i
] = MACIO_IN8(KEYLARGO_GPIO_0
+i
);
1722 if (macio
->type
== macio_keylargo
)
1723 save_mbcr
= MACIO_IN32(KEYLARGO_MBCR
);
1724 save_fcr
[0] = MACIO_IN32(KEYLARGO_FCR0
);
1725 save_fcr
[1] = MACIO_IN32(KEYLARGO_FCR1
);
1726 save_fcr
[2] = MACIO_IN32(KEYLARGO_FCR2
);
1727 save_fcr
[3] = MACIO_IN32(KEYLARGO_FCR3
);
1728 save_fcr
[4] = MACIO_IN32(KEYLARGO_FCR4
);
1729 if (macio
->type
== macio_pangea
|| macio
->type
== macio_intrepid
)
1730 save_fcr
[5] = MACIO_IN32(KEYLARGO_FCR5
);
1732 /* Save state & config of DBDMA channels */
1733 dbdma_save(macio
, save_dbdma
);
1736 * Turn off as much as we can
1738 if (macio
->type
== macio_pangea
)
1739 pangea_shutdown(macio
, 1);
1740 else if (macio
->type
== macio_intrepid
)
1741 intrepid_shutdown(macio
, 1);
1742 else if (macio
->type
== macio_keylargo
)
1743 keylargo_shutdown(macio
, 1);
1746 * Put the host bridge to sleep
1749 save_unin_clock_ctl
= UN_IN(UNI_N_CLOCK_CNTL
);
1750 /* Note: do not switch GMAC off, driver does it when necessary, WOL must keep it
1753 UN_OUT(UNI_N_CLOCK_CNTL
, save_unin_clock_ctl
&
1754 ~(/*UNI_N_CLOCK_CNTL_GMAC|*/UNI_N_CLOCK_CNTL_FW
/*|UNI_N_CLOCK_CNTL_PCI*/));
1756 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_SLEEPING
);
1757 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_SLEEP
);
1761 * FIXME: A bit of black magic with OpenPIC (don't ask me why)
1763 if (pmac_mb
.model_id
== PMAC_TYPE_SAWTOOTH
) {
1764 MACIO_BIS(0x506e0, 0x00400000);
1765 MACIO_BIS(0x506e0, 0x80000000);
1771 core99_wake_up(void)
1773 struct macio_chip
*macio
;
1776 macio
= &macio_chips
[0];
1777 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1778 macio
->type
!= macio_intrepid
)
1782 * Wakeup the host bridge
1784 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_NORMAL
);
1786 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_RUNNING
);
1793 if (macio
->type
== macio_keylargo
) {
1794 MACIO_OUT32(KEYLARGO_MBCR
, save_mbcr
);
1795 (void)MACIO_IN32(KEYLARGO_MBCR
); udelay(10);
1797 MACIO_OUT32(KEYLARGO_FCR0
, save_fcr
[0]);
1798 (void)MACIO_IN32(KEYLARGO_FCR0
); udelay(10);
1799 MACIO_OUT32(KEYLARGO_FCR1
, save_fcr
[1]);
1800 (void)MACIO_IN32(KEYLARGO_FCR1
); udelay(10);
1801 MACIO_OUT32(KEYLARGO_FCR2
, save_fcr
[2]);
1802 (void)MACIO_IN32(KEYLARGO_FCR2
); udelay(10);
1803 MACIO_OUT32(KEYLARGO_FCR3
, save_fcr
[3]);
1804 (void)MACIO_IN32(KEYLARGO_FCR3
); udelay(10);
1805 MACIO_OUT32(KEYLARGO_FCR4
, save_fcr
[4]);
1806 (void)MACIO_IN32(KEYLARGO_FCR4
); udelay(10);
1807 if (macio
->type
== macio_pangea
|| macio
->type
== macio_intrepid
) {
1808 MACIO_OUT32(KEYLARGO_FCR5
, save_fcr
[5]);
1809 (void)MACIO_IN32(KEYLARGO_FCR5
); udelay(10);
1812 dbdma_restore(macio
, save_dbdma
);
1814 MACIO_OUT32(KEYLARGO_GPIO_LEVELS0
, save_gpio_levels
[0]);
1815 MACIO_OUT32(KEYLARGO_GPIO_LEVELS1
, save_gpio_levels
[1]);
1816 for (i
=0; i
<KEYLARGO_GPIO_EXTINT_CNT
; i
++)
1817 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+i
, save_gpio_extint
[i
]);
1818 for (i
=0; i
<KEYLARGO_GPIO_CNT
; i
++)
1819 MACIO_OUT8(KEYLARGO_GPIO_0
+i
, save_gpio_normal
[i
]);
1821 /* FIXME more black magic with OpenPIC ... */
1822 if (pmac_mb
.model_id
== PMAC_TYPE_SAWTOOTH
) {
1823 MACIO_BIC(0x506e0, 0x00400000);
1824 MACIO_BIC(0x506e0, 0x80000000);
1827 UN_OUT(UNI_N_CLOCK_CNTL
, save_unin_clock_ctl
);
1833 #endif /* CONFIG_PM */
1836 core99_sleep_state(struct device_node
*node
, long param
, long value
)
1838 /* Param == 1 means to enter the "fake sleep" mode that is
1839 * used for CPU speed switch
1843 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_SLEEPING
);
1844 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_IDLE2
);
1846 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_NORMAL
);
1848 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_RUNNING
);
1853 if ((pmac_mb
.board_flags
& PMAC_MB_CAN_SLEEP
) == 0)
1858 return core99_sleep();
1859 else if (value
== 0)
1860 return core99_wake_up();
1862 #endif /* CONFIG_PM */
1866 #endif /* CONFIG_POWER4 */
1869 generic_dev_can_wake(struct device_node
*node
, long param
, long value
)
1871 /* Todo: eventually check we are really dealing with on-board
1875 if (pmac_mb
.board_flags
& PMAC_MB_MAY_SLEEP
)
1876 pmac_mb
.board_flags
|= PMAC_MB_CAN_SLEEP
;
1880 static long generic_get_mb_info(struct device_node
*node
, long param
, long value
)
1883 case PMAC_MB_INFO_MODEL
:
1884 return pmac_mb
.model_id
;
1885 case PMAC_MB_INFO_FLAGS
:
1886 return pmac_mb
.board_flags
;
1887 case PMAC_MB_INFO_NAME
:
1888 /* hack hack hack... but should work */
1889 *((const char **)value
) = pmac_mb
.model_name
;
1900 /* Used on any machine
1902 static struct feature_table_entry any_features
[] = {
1903 { PMAC_FTR_GET_MB_INFO
, generic_get_mb_info
},
1904 { PMAC_FTR_DEVICE_CAN_WAKE
, generic_dev_can_wake
},
1908 #ifndef CONFIG_POWER4
1910 /* OHare based motherboards. Currently, we only use these on the
1911 * 2400,3400 and 3500 series powerbooks. Some older desktops seem
1912 * to have issues with turning on/off those asic cells
1914 static struct feature_table_entry ohare_features
[] = {
1915 { PMAC_FTR_SCC_ENABLE
, ohare_htw_scc_enable
},
1916 { PMAC_FTR_SWIM3_ENABLE
, ohare_floppy_enable
},
1917 { PMAC_FTR_MESH_ENABLE
, ohare_mesh_enable
},
1918 { PMAC_FTR_IDE_ENABLE
, ohare_ide_enable
},
1919 { PMAC_FTR_IDE_RESET
, ohare_ide_reset
},
1920 { PMAC_FTR_SLEEP_STATE
, ohare_sleep_state
},
1924 /* Heathrow desktop machines (Beige G3).
1925 * Separated as some features couldn't be properly tested
1926 * and the serial port control bits appear to confuse it.
1928 static struct feature_table_entry heathrow_desktop_features
[] = {
1929 { PMAC_FTR_SWIM3_ENABLE
, heathrow_floppy_enable
},
1930 { PMAC_FTR_MESH_ENABLE
, heathrow_mesh_enable
},
1931 { PMAC_FTR_IDE_ENABLE
, heathrow_ide_enable
},
1932 { PMAC_FTR_IDE_RESET
, heathrow_ide_reset
},
1933 { PMAC_FTR_BMAC_ENABLE
, heathrow_bmac_enable
},
1937 /* Heathrow based laptop, that is the Wallstreet and mainstreet
1940 static struct feature_table_entry heathrow_laptop_features
[] = {
1941 { PMAC_FTR_SCC_ENABLE
, ohare_htw_scc_enable
},
1942 { PMAC_FTR_MODEM_ENABLE
, heathrow_modem_enable
},
1943 { PMAC_FTR_SWIM3_ENABLE
, heathrow_floppy_enable
},
1944 { PMAC_FTR_MESH_ENABLE
, heathrow_mesh_enable
},
1945 { PMAC_FTR_IDE_ENABLE
, heathrow_ide_enable
},
1946 { PMAC_FTR_IDE_RESET
, heathrow_ide_reset
},
1947 { PMAC_FTR_BMAC_ENABLE
, heathrow_bmac_enable
},
1948 { PMAC_FTR_SOUND_CHIP_ENABLE
, heathrow_sound_enable
},
1949 { PMAC_FTR_SLEEP_STATE
, heathrow_sleep_state
},
1953 /* Paddington based machines
1954 * The lombard (101) powerbook, first iMac models, B&W G3 and Yikes G4.
1956 static struct feature_table_entry paddington_features
[] = {
1957 { PMAC_FTR_SCC_ENABLE
, ohare_htw_scc_enable
},
1958 { PMAC_FTR_MODEM_ENABLE
, heathrow_modem_enable
},
1959 { PMAC_FTR_SWIM3_ENABLE
, heathrow_floppy_enable
},
1960 { PMAC_FTR_MESH_ENABLE
, heathrow_mesh_enable
},
1961 { PMAC_FTR_IDE_ENABLE
, heathrow_ide_enable
},
1962 { PMAC_FTR_IDE_RESET
, heathrow_ide_reset
},
1963 { PMAC_FTR_BMAC_ENABLE
, heathrow_bmac_enable
},
1964 { PMAC_FTR_SOUND_CHIP_ENABLE
, heathrow_sound_enable
},
1965 { PMAC_FTR_SLEEP_STATE
, heathrow_sleep_state
},
1969 /* Core99 & MacRISC 2 machines (all machines released since the
1970 * iBook (included), that is all AGP machines, except pangea
1971 * chipset. The pangea chipset is the "combo" UniNorth/KeyLargo
1972 * used on iBook2 & iMac "flow power".
1974 static struct feature_table_entry core99_features
[] = {
1975 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
1976 { PMAC_FTR_MODEM_ENABLE
, core99_modem_enable
},
1977 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
1978 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
1979 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
1980 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
1981 { PMAC_FTR_SOUND_CHIP_ENABLE
, core99_sound_chip_enable
},
1982 { PMAC_FTR_AIRPORT_ENABLE
, core99_airport_enable
},
1983 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
1984 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
1985 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
1987 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
1990 { PMAC_FTR_RESET_CPU
, core99_reset_cpu
},
1991 #endif /* CONFIG_SMP */
1992 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
1993 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
1999 static struct feature_table_entry rackmac_features
[] = {
2000 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2001 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2002 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2003 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2004 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2005 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2006 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2007 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2008 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2010 { PMAC_FTR_RESET_CPU
, core99_reset_cpu
},
2011 #endif /* CONFIG_SMP */
2012 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2013 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2019 static struct feature_table_entry pangea_features
[] = {
2020 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2021 { PMAC_FTR_MODEM_ENABLE
, pangea_modem_enable
},
2022 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2023 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2024 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2025 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2026 { PMAC_FTR_SOUND_CHIP_ENABLE
, core99_sound_chip_enable
},
2027 { PMAC_FTR_AIRPORT_ENABLE
, core99_airport_enable
},
2028 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2029 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2030 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2031 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2032 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2033 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2037 /* Intrepid features
2039 static struct feature_table_entry intrepid_features
[] = {
2040 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2041 { PMAC_FTR_MODEM_ENABLE
, pangea_modem_enable
},
2042 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2043 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2044 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2045 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2046 { PMAC_FTR_SOUND_CHIP_ENABLE
, core99_sound_chip_enable
},
2047 { PMAC_FTR_AIRPORT_ENABLE
, core99_airport_enable
},
2048 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2049 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2050 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2051 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2052 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2053 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2054 { PMAC_FTR_AACK_DELAY_ENABLE
, intrepid_aack_delay_enable
},
2058 #else /* CONFIG_POWER4 */
2062 static struct feature_table_entry g5_features
[] = {
2063 { PMAC_FTR_GMAC_ENABLE
, g5_gmac_enable
},
2064 { PMAC_FTR_1394_ENABLE
, g5_fw_enable
},
2065 { PMAC_FTR_ENABLE_MPIC
, g5_mpic_enable
},
2066 { PMAC_FTR_GMAC_PHY_RESET
, g5_eth_phy_reset
},
2067 { PMAC_FTR_SOUND_CHIP_ENABLE
, g5_i2s_enable
},
2069 { PMAC_FTR_RESET_CPU
, g5_reset_cpu
},
2070 #endif /* CONFIG_SMP */
2071 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2072 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2076 #endif /* CONFIG_POWER4 */
2078 static struct pmac_mb_def pmac_mb_defs
[] = {
2079 #ifndef CONFIG_POWER4
2084 { "AAPL,8500", "PowerMac 8500/8600",
2085 PMAC_TYPE_PSURGE
, NULL
,
2088 { "AAPL,9500", "PowerMac 9500/9600",
2089 PMAC_TYPE_PSURGE
, NULL
,
2092 { "AAPL,7200", "PowerMac 7200",
2093 PMAC_TYPE_PSURGE
, NULL
,
2096 { "AAPL,7300", "PowerMac 7200/7300",
2097 PMAC_TYPE_PSURGE
, NULL
,
2100 { "AAPL,7500", "PowerMac 7500",
2101 PMAC_TYPE_PSURGE
, NULL
,
2104 { "AAPL,ShinerESB", "Apple Network Server",
2105 PMAC_TYPE_ANS
, NULL
,
2108 { "AAPL,e407", "Alchemy",
2109 PMAC_TYPE_ALCHEMY
, NULL
,
2112 { "AAPL,e411", "Gazelle",
2113 PMAC_TYPE_GAZELLE
, NULL
,
2116 { "AAPL,Gossamer", "PowerMac G3 (Gossamer)",
2117 PMAC_TYPE_GOSSAMER
, heathrow_desktop_features
,
2120 { "AAPL,PowerMac G3", "PowerMac G3 (Silk)",
2121 PMAC_TYPE_SILK
, heathrow_desktop_features
,
2124 { "PowerMac1,1", "Blue&White G3",
2125 PMAC_TYPE_YOSEMITE
, paddington_features
,
2128 { "PowerMac1,2", "PowerMac G4 PCI Graphics",
2129 PMAC_TYPE_YIKES
, paddington_features
,
2132 { "PowerMac2,1", "iMac FireWire",
2133 PMAC_TYPE_FW_IMAC
, core99_features
,
2134 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2136 { "PowerMac2,2", "iMac FireWire",
2137 PMAC_TYPE_FW_IMAC
, core99_features
,
2138 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2140 { "PowerMac3,1", "PowerMac G4 AGP Graphics",
2141 PMAC_TYPE_SAWTOOTH
, core99_features
,
2144 { "PowerMac3,2", "PowerMac G4 AGP Graphics",
2145 PMAC_TYPE_SAWTOOTH
, core99_features
,
2146 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2148 { "PowerMac3,3", "PowerMac G4 AGP Graphics",
2149 PMAC_TYPE_SAWTOOTH
, core99_features
,
2150 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2152 { "PowerMac3,4", "PowerMac G4 Silver",
2153 PMAC_TYPE_QUICKSILVER
, core99_features
,
2156 { "PowerMac3,5", "PowerMac G4 Silver",
2157 PMAC_TYPE_QUICKSILVER
, core99_features
,
2160 { "PowerMac3,6", "PowerMac G4 Windtunnel",
2161 PMAC_TYPE_WINDTUNNEL
, core99_features
,
2164 { "PowerMac4,1", "iMac \"Flower Power\"",
2165 PMAC_TYPE_PANGEA_IMAC
, pangea_features
,
2168 { "PowerMac4,2", "Flat panel iMac",
2169 PMAC_TYPE_FLAT_PANEL_IMAC
, pangea_features
,
2172 { "PowerMac4,4", "eMac",
2173 PMAC_TYPE_EMAC
, core99_features
,
2176 { "PowerMac5,1", "PowerMac G4 Cube",
2177 PMAC_TYPE_CUBE
, core99_features
,
2178 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2180 { "PowerMac6,1", "Flat panel iMac",
2181 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2184 { "PowerMac6,3", "Flat panel iMac",
2185 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2188 { "PowerMac6,4", "eMac",
2189 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2192 { "PowerMac10,1", "Mac mini",
2193 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2196 { "PowerMac10,2", "Mac mini (Late 2005)",
2197 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2200 { "iMac,1", "iMac (first generation)",
2201 PMAC_TYPE_ORIG_IMAC
, paddington_features
,
2209 { "RackMac1,1", "XServe",
2210 PMAC_TYPE_RACKMAC
, rackmac_features
,
2213 { "RackMac1,2", "XServe rev. 2",
2214 PMAC_TYPE_RACKMAC
, rackmac_features
,
2222 { "AAPL,3400/2400", "PowerBook 3400",
2223 PMAC_TYPE_HOOPER
, ohare_features
,
2224 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2226 { "AAPL,3500", "PowerBook 3500",
2227 PMAC_TYPE_KANGA
, ohare_features
,
2228 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2230 { "AAPL,PowerBook1998", "PowerBook Wallstreet",
2231 PMAC_TYPE_WALLSTREET
, heathrow_laptop_features
,
2232 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2234 { "PowerBook1,1", "PowerBook 101 (Lombard)",
2235 PMAC_TYPE_101_PBOOK
, paddington_features
,
2236 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2238 { "PowerBook2,1", "iBook (first generation)",
2239 PMAC_TYPE_ORIG_IBOOK
, core99_features
,
2240 PMAC_MB_CAN_SLEEP
| PMAC_MB_OLD_CORE99
| PMAC_MB_MOBILE
2242 { "PowerBook2,2", "iBook FireWire",
2243 PMAC_TYPE_FW_IBOOK
, core99_features
,
2244 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
|
2245 PMAC_MB_OLD_CORE99
| PMAC_MB_MOBILE
2247 { "PowerBook3,1", "PowerBook Pismo",
2248 PMAC_TYPE_PISMO
, core99_features
,
2249 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
|
2250 PMAC_MB_OLD_CORE99
| PMAC_MB_MOBILE
2252 { "PowerBook3,2", "PowerBook Titanium",
2253 PMAC_TYPE_TITANIUM
, core99_features
,
2254 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2256 { "PowerBook3,3", "PowerBook Titanium II",
2257 PMAC_TYPE_TITANIUM2
, core99_features
,
2258 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2260 { "PowerBook3,4", "PowerBook Titanium III",
2261 PMAC_TYPE_TITANIUM3
, core99_features
,
2262 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2264 { "PowerBook3,5", "PowerBook Titanium IV",
2265 PMAC_TYPE_TITANIUM4
, core99_features
,
2266 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2268 { "PowerBook4,1", "iBook 2",
2269 PMAC_TYPE_IBOOK2
, pangea_features
,
2270 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2272 { "PowerBook4,2", "iBook 2",
2273 PMAC_TYPE_IBOOK2
, pangea_features
,
2274 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2276 { "PowerBook4,3", "iBook 2 rev. 2",
2277 PMAC_TYPE_IBOOK2
, pangea_features
,
2278 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2280 { "PowerBook5,1", "PowerBook G4 17\"",
2281 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2282 PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2284 { "PowerBook5,2", "PowerBook G4 15\"",
2285 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2286 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2288 { "PowerBook5,3", "PowerBook G4 17\"",
2289 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2290 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2292 { "PowerBook5,4", "PowerBook G4 15\"",
2293 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2294 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2296 { "PowerBook5,5", "PowerBook G4 17\"",
2297 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2298 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2300 { "PowerBook5,6", "PowerBook G4 15\"",
2301 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2302 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2304 { "PowerBook5,7", "PowerBook G4 17\"",
2305 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2306 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2308 { "PowerBook5,8", "PowerBook G4 15\"",
2309 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2310 PMAC_MB_MAY_SLEEP
| PMAC_MB_MOBILE
,
2312 { "PowerBook5,9", "PowerBook G4 17\"",
2313 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2314 PMAC_MB_MAY_SLEEP
| PMAC_MB_MOBILE
,
2316 { "PowerBook6,1", "PowerBook G4 12\"",
2317 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2318 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2320 { "PowerBook6,2", "PowerBook G4",
2321 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2322 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2324 { "PowerBook6,3", "iBook G4",
2325 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2326 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2328 { "PowerBook6,4", "PowerBook G4 12\"",
2329 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2330 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2332 { "PowerBook6,5", "iBook G4",
2333 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2334 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2336 { "PowerBook6,7", "iBook G4",
2337 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2338 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2340 { "PowerBook6,8", "PowerBook G4 12\"",
2341 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2342 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2344 #else /* CONFIG_POWER4 */
2345 { "PowerMac7,2", "PowerMac G5",
2346 PMAC_TYPE_POWERMAC_G5
, g5_features
,
2350 { "PowerMac7,3", "PowerMac G5",
2351 PMAC_TYPE_POWERMAC_G5
, g5_features
,
2354 { "PowerMac8,1", "iMac G5",
2355 PMAC_TYPE_IMAC_G5
, g5_features
,
2358 { "PowerMac9,1", "PowerMac G5",
2359 PMAC_TYPE_POWERMAC_G5_U3L
, g5_features
,
2362 { "PowerMac11,2", "PowerMac G5 Dual Core",
2363 PMAC_TYPE_POWERMAC_G5_U3L
, g5_features
,
2366 { "PowerMac12,1", "iMac G5 (iSight)",
2367 PMAC_TYPE_POWERMAC_G5_U3L
, g5_features
,
2370 { "RackMac3,1", "XServe G5",
2371 PMAC_TYPE_XSERVE_G5
, g5_features
,
2374 #endif /* CONFIG_PPC64 */
2375 #endif /* CONFIG_POWER4 */
2379 * The toplevel feature_call callback
2381 long pmac_do_feature_call(unsigned int selector
, ...)
2383 struct device_node
*node
;
2386 feature_call func
= NULL
;
2389 if (pmac_mb
.features
)
2390 for (i
=0; pmac_mb
.features
[i
].function
; i
++)
2391 if (pmac_mb
.features
[i
].selector
== selector
) {
2392 func
= pmac_mb
.features
[i
].function
;
2396 for (i
=0; any_features
[i
].function
; i
++)
2397 if (any_features
[i
].selector
== selector
) {
2398 func
= any_features
[i
].function
;
2404 va_start(args
, selector
);
2405 node
= (struct device_node
*)va_arg(args
, void*);
2406 param
= va_arg(args
, long);
2407 value
= va_arg(args
, long);
2410 return func(node
, param
, value
);
2413 static int __init
probe_motherboard(void)
2416 struct macio_chip
*macio
= &macio_chips
[0];
2417 const char *model
= NULL
;
2418 struct device_node
*dt
;
2421 /* Lookup known motherboard type in device-tree. First try an
2422 * exact match on the "model" property, then try a "compatible"
2423 * match is none is found.
2425 dt
= of_find_node_by_name(NULL
, "device-tree");
2427 model
= of_get_property(dt
, "model", NULL
);
2428 for(i
=0; model
&& i
<ARRAY_SIZE(pmac_mb_defs
); i
++) {
2429 if (strcmp(model
, pmac_mb_defs
[i
].model_string
) == 0) {
2430 pmac_mb
= pmac_mb_defs
[i
];
2434 for(i
=0; i
<ARRAY_SIZE(pmac_mb_defs
); i
++) {
2435 if (of_machine_is_compatible(pmac_mb_defs
[i
].model_string
)) {
2436 pmac_mb
= pmac_mb_defs
[i
];
2441 /* Fallback to selection depending on mac-io chip type */
2442 switch(macio
->type
) {
2443 #ifndef CONFIG_POWER4
2444 case macio_grand_central
:
2445 pmac_mb
.model_id
= PMAC_TYPE_PSURGE
;
2446 pmac_mb
.model_name
= "Unknown PowerSurge";
2449 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_OHARE
;
2450 pmac_mb
.model_name
= "Unknown OHare-based";
2452 case macio_heathrow
:
2453 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_HEATHROW
;
2454 pmac_mb
.model_name
= "Unknown Heathrow-based";
2455 pmac_mb
.features
= heathrow_desktop_features
;
2457 case macio_paddington
:
2458 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_PADDINGTON
;
2459 pmac_mb
.model_name
= "Unknown Paddington-based";
2460 pmac_mb
.features
= paddington_features
;
2462 case macio_keylargo
:
2463 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_CORE99
;
2464 pmac_mb
.model_name
= "Unknown Keylargo-based";
2465 pmac_mb
.features
= core99_features
;
2468 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_PANGEA
;
2469 pmac_mb
.model_name
= "Unknown Pangea-based";
2470 pmac_mb
.features
= pangea_features
;
2472 case macio_intrepid
:
2473 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_INTREPID
;
2474 pmac_mb
.model_name
= "Unknown Intrepid-based";
2475 pmac_mb
.features
= intrepid_features
;
2477 #else /* CONFIG_POWER4 */
2478 case macio_keylargo2
:
2479 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_K2
;
2480 pmac_mb
.model_name
= "Unknown K2-based";
2481 pmac_mb
.features
= g5_features
;
2484 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_SHASTA
;
2485 pmac_mb
.model_name
= "Unknown Shasta-based";
2486 pmac_mb
.features
= g5_features
;
2488 #endif /* CONFIG_POWER4 */
2494 #ifndef CONFIG_POWER4
2495 /* Fixup Hooper vs. Comet */
2496 if (pmac_mb
.model_id
== PMAC_TYPE_HOOPER
) {
2497 u32 __iomem
* mach_id_ptr
= ioremap(0xf3000034, 4);
2502 /* Here, I used to disable the media-bay on comet. It
2503 * appears this is wrong, the floppy connector is actually
2504 * a kind of media-bay and works with the current driver.
2506 if (__raw_readl(mach_id_ptr
) & 0x20000000UL
)
2507 pmac_mb
.model_id
= PMAC_TYPE_COMET
;
2508 iounmap(mach_id_ptr
);
2511 /* Set default value of powersave_nap on machines that support it.
2512 * It appears that uninorth rev 3 has a problem with it, we don't
2513 * enable it on those. In theory, the flush-on-lock property is
2514 * supposed to be set when not supported, but I'm not very confident
2515 * that all Apple OF revs did it properly, I do it the paranoid way.
2517 while (uninorth_base
&& uninorth_rev
> 3) {
2518 struct device_node
*cpus
= of_find_node_by_path("/cpus");
2519 struct device_node
*np
;
2521 if (!cpus
|| !cpus
->child
) {
2522 printk(KERN_WARNING
"Can't find CPU(s) in device tree !\n");
2527 /* Nap mode not supported on SMP */
2532 /* Nap mode not supported if flush-on-lock property is present */
2533 if (of_get_property(np
, "flush-on-lock", NULL
)) {
2539 printk(KERN_DEBUG
"Processor NAP mode on idle enabled.\n");
2543 /* On CPUs that support it (750FX), lowspeed by default during
2546 powersave_lowspeed
= 1;
2548 #else /* CONFIG_POWER4 */
2550 #endif /* CONFIG_POWER4 */
2552 /* Check for "mobile" machine */
2553 if (model
&& (strncmp(model
, "PowerBook", 9) == 0
2554 || strncmp(model
, "iBook", 5) == 0))
2555 pmac_mb
.board_flags
|= PMAC_MB_MOBILE
;
2558 printk(KERN_INFO
"PowerMac motherboard: %s\n", pmac_mb
.model_name
);
2564 /* Initialize the Core99 UniNorth host bridge and memory controller
2566 static void __init
probe_uninorth(void)
2569 phys_addr_t address
;
2570 unsigned long actrl
;
2572 /* Locate core99 Uni-N */
2573 uninorth_node
= of_find_node_by_name(NULL
, "uni-n");
2577 if (uninorth_node
== NULL
) {
2578 uninorth_node
= of_find_node_by_name(NULL
, "u3");
2582 if (uninorth_node
== NULL
) {
2583 uninorth_node
= of_find_node_by_name(NULL
, "u4");
2586 if (uninorth_node
== NULL
) {
2591 addrp
= of_get_property(uninorth_node
, "reg", NULL
);
2594 address
= of_translate_address(uninorth_node
, addrp
);
2597 uninorth_base
= ioremap(address
, 0x40000);
2598 if (uninorth_base
== NULL
)
2600 uninorth_rev
= in_be32(UN_REG(UNI_N_VERSION
));
2601 if (uninorth_maj
== 3 || uninorth_maj
== 4) {
2602 u3_ht_base
= ioremap(address
+ U3_HT_CONFIG_BASE
, 0x1000);
2603 if (u3_ht_base
== NULL
) {
2604 iounmap(uninorth_base
);
2609 printk(KERN_INFO
"Found %s memory controller & host bridge"
2610 " @ 0x%08x revision: 0x%02x\n", uninorth_maj
== 3 ? "U3" :
2611 uninorth_maj
== 4 ? "U4" : "UniNorth",
2612 (unsigned int)address
, uninorth_rev
);
2613 printk(KERN_INFO
"Mapped at 0x%08lx\n", (unsigned long)uninorth_base
);
2615 /* Set the arbitrer QAck delay according to what Apple does
2617 if (uninorth_rev
< 0x11) {
2618 actrl
= UN_IN(UNI_N_ARB_CTRL
) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK
;
2619 actrl
|= ((uninorth_rev
< 3) ? UNI_N_ARB_CTRL_QACK_DELAY105
:
2620 UNI_N_ARB_CTRL_QACK_DELAY
) <<
2621 UNI_N_ARB_CTRL_QACK_DELAY_SHIFT
;
2622 UN_OUT(UNI_N_ARB_CTRL
, actrl
);
2625 /* Some more magic as done by them in recent MacOS X on UniNorth
2626 * revs 1.5 to 2.O and Pangea. Seem to toggle the UniN Maxbus/PCI
2629 if ((uninorth_rev
>= 0x11 && uninorth_rev
<= 0x24) ||
2630 uninorth_rev
== 0xc0)
2631 UN_OUT(0x2160, UN_IN(0x2160) & 0x00ffffff);
2634 static void __init
probe_one_macio(const char *name
, const char *compat
, int type
)
2636 struct device_node
* node
;
2638 volatile u32 __iomem
*base
;
2639 const u32
*addrp
, *revp
;
2643 for (node
= NULL
; (node
= of_find_node_by_name(node
, name
)) != NULL
;) {
2646 if (of_device_is_compatible(node
, compat
))
2651 for(i
=0; i
<MAX_MACIO_CHIPS
; i
++) {
2652 if (!macio_chips
[i
].of_node
)
2654 if (macio_chips
[i
].of_node
== node
)
2658 if (i
>= MAX_MACIO_CHIPS
) {
2659 printk(KERN_ERR
"pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
2660 printk(KERN_ERR
"pmac_feature: %s skipped\n", node
->full_name
);
2663 addrp
= of_get_pci_address(node
, 0, &size
, NULL
);
2664 if (addrp
== NULL
) {
2665 printk(KERN_ERR
"pmac_feature: %s: can't find base !\n",
2669 addr
= of_translate_address(node
, addrp
);
2671 printk(KERN_ERR
"pmac_feature: %s, can't translate base !\n",
2675 base
= ioremap(addr
, (unsigned long)size
);
2677 printk(KERN_ERR
"pmac_feature: %s, can't map mac-io chip !\n",
2681 if (type
== macio_keylargo
|| type
== macio_keylargo2
) {
2682 const u32
*did
= of_get_property(node
, "device-id", NULL
);
2683 if (*did
== 0x00000025)
2684 type
= macio_pangea
;
2685 if (*did
== 0x0000003e)
2686 type
= macio_intrepid
;
2687 if (*did
== 0x0000004f)
2688 type
= macio_shasta
;
2690 macio_chips
[i
].of_node
= node
;
2691 macio_chips
[i
].type
= type
;
2692 macio_chips
[i
].base
= base
;
2693 macio_chips
[i
].flags
= MACIO_FLAG_SCCA_ON
| MACIO_FLAG_SCCB_ON
;
2694 macio_chips
[i
].name
= macio_names
[type
];
2695 revp
= of_get_property(node
, "revision-id", NULL
);
2697 macio_chips
[i
].rev
= *revp
;
2698 printk(KERN_INFO
"Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
2699 macio_names
[type
], macio_chips
[i
].rev
, macio_chips
[i
].base
);
2705 /* Warning, ordering is important */
2706 probe_one_macio("gc", NULL
, macio_grand_central
);
2707 probe_one_macio("ohare", NULL
, macio_ohare
);
2708 probe_one_macio("pci106b,7", NULL
, macio_ohareII
);
2709 probe_one_macio("mac-io", "keylargo", macio_keylargo
);
2710 probe_one_macio("mac-io", "paddington", macio_paddington
);
2711 probe_one_macio("mac-io", "gatwick", macio_gatwick
);
2712 probe_one_macio("mac-io", "heathrow", macio_heathrow
);
2713 probe_one_macio("mac-io", "K2-Keylargo", macio_keylargo2
);
2715 /* Make sure the "main" macio chip appear first */
2716 if (macio_chips
[0].type
== macio_gatwick
2717 && macio_chips
[1].type
== macio_heathrow
) {
2718 struct macio_chip temp
= macio_chips
[0];
2719 macio_chips
[0] = macio_chips
[1];
2720 macio_chips
[1] = temp
;
2722 if (macio_chips
[0].type
== macio_ohareII
2723 && macio_chips
[1].type
== macio_ohare
) {
2724 struct macio_chip temp
= macio_chips
[0];
2725 macio_chips
[0] = macio_chips
[1];
2726 macio_chips
[1] = temp
;
2728 macio_chips
[0].lbus
.index
= 0;
2729 macio_chips
[1].lbus
.index
= 1;
2731 return (macio_chips
[0].of_node
== NULL
) ? -ENODEV
: 0;
2735 initial_serial_shutdown(struct device_node
*np
)
2738 const struct slot_names_prop
{
2743 int port_type
= PMAC_SCC_ASYNC
;
2746 slots
= of_get_property(np
, "slot-names", &len
);
2747 conn
= of_get_property(np
, "AAPL,connector", &len
);
2748 if (conn
&& (strcmp(conn
, "infrared") == 0))
2749 port_type
= PMAC_SCC_IRDA
;
2750 else if (of_device_is_compatible(np
, "cobalt"))
2752 else if (slots
&& slots
->count
> 0) {
2753 if (strcmp(slots
->name
, "IrDA") == 0)
2754 port_type
= PMAC_SCC_IRDA
;
2755 else if (strcmp(slots
->name
, "Modem") == 0)
2759 pmac_call_feature(PMAC_FTR_MODEM_ENABLE
, np
, 0, 0);
2760 pmac_call_feature(PMAC_FTR_SCC_ENABLE
, np
, port_type
, 0);
2764 set_initial_features(void)
2766 struct device_node
*np
;
2768 /* That hack appears to be necessary for some StarMax motherboards
2769 * but I'm not too sure it was audited for side-effects on other
2770 * ohare based machines...
2771 * Since I still have difficulties figuring the right way to
2772 * differenciate them all and since that hack was there for a long
2773 * time, I'll keep it around
2775 if (macio_chips
[0].type
== macio_ohare
) {
2776 struct macio_chip
*macio
= &macio_chips
[0];
2777 np
= of_find_node_by_name(NULL
, "via-pmu");
2779 MACIO_BIS(OHARE_FCR
, OH_IOBUS_ENABLE
);
2781 MACIO_OUT32(OHARE_FCR
, STARMAX_FEATURES
);
2783 } else if (macio_chips
[1].type
== macio_ohare
) {
2784 struct macio_chip
*macio
= &macio_chips
[1];
2785 MACIO_BIS(OHARE_FCR
, OH_IOBUS_ENABLE
);
2788 #ifdef CONFIG_POWER4
2789 if (macio_chips
[0].type
== macio_keylargo2
||
2790 macio_chips
[0].type
== macio_shasta
) {
2792 /* On SMP machines running UP, we have the second CPU eating
2793 * bus cycles. We need to take it off the bus. This is done
2794 * from pmac_smp for SMP kernels running on one CPU
2796 np
= of_find_node_by_type(NULL
, "cpu");
2798 np
= of_find_node_by_type(np
, "cpu");
2800 g5_phy_disable_cpu1();
2803 #endif /* CONFIG_SMP */
2804 /* Enable GMAC for now for PCI probing. It will be disabled
2805 * later on after PCI probe
2807 np
= of_find_node_by_name(NULL
, "ethernet");
2809 if (of_device_is_compatible(np
, "K2-GMAC"))
2810 g5_gmac_enable(np
, 0, 1);
2811 np
= of_find_node_by_name(np
, "ethernet");
2814 /* Enable FW before PCI probe. Will be disabled later on
2815 * Note: We should have a batter way to check that we are
2816 * dealing with uninorth internal cell and not a PCI cell
2817 * on the external PCI. The code below works though.
2819 np
= of_find_node_by_name(NULL
, "firewire");
2821 if (of_device_is_compatible(np
, "pci106b,5811")) {
2822 macio_chips
[0].flags
|= MACIO_FLAG_FW_SUPPORTED
;
2823 g5_fw_enable(np
, 0, 1);
2825 np
= of_find_node_by_name(np
, "firewire");
2828 #else /* CONFIG_POWER4 */
2830 if (macio_chips
[0].type
== macio_keylargo
||
2831 macio_chips
[0].type
== macio_pangea
||
2832 macio_chips
[0].type
== macio_intrepid
) {
2833 /* Enable GMAC for now for PCI probing. It will be disabled
2834 * later on after PCI probe
2836 np
= of_find_node_by_name(NULL
, "ethernet");
2839 && of_device_is_compatible(np
->parent
, "uni-north")
2840 && of_device_is_compatible(np
, "gmac"))
2841 core99_gmac_enable(np
, 0, 1);
2842 np
= of_find_node_by_name(np
, "ethernet");
2845 /* Enable FW before PCI probe. Will be disabled later on
2846 * Note: We should have a batter way to check that we are
2847 * dealing with uninorth internal cell and not a PCI cell
2848 * on the external PCI. The code below works though.
2850 np
= of_find_node_by_name(NULL
, "firewire");
2853 && of_device_is_compatible(np
->parent
, "uni-north")
2854 && (of_device_is_compatible(np
, "pci106b,18") ||
2855 of_device_is_compatible(np
, "pci106b,30") ||
2856 of_device_is_compatible(np
, "pci11c1,5811"))) {
2857 macio_chips
[0].flags
|= MACIO_FLAG_FW_SUPPORTED
;
2858 core99_firewire_enable(np
, 0, 1);
2860 np
= of_find_node_by_name(np
, "firewire");
2863 /* Enable ATA-100 before PCI probe. */
2864 np
= of_find_node_by_name(NULL
, "ata-6");
2867 && of_device_is_compatible(np
->parent
, "uni-north")
2868 && of_device_is_compatible(np
, "kauai-ata")) {
2869 core99_ata100_enable(np
, 1);
2871 np
= of_find_node_by_name(np
, "ata-6");
2874 /* Switch airport off */
2875 for_each_node_by_name(np
, "radio") {
2876 if (np
&& np
->parent
== macio_chips
[0].of_node
) {
2877 macio_chips
[0].flags
|= MACIO_FLAG_AIRPORT_ON
;
2878 core99_airport_enable(np
, 0, 0);
2883 /* On all machines that support sound PM, switch sound off */
2884 if (macio_chips
[0].of_node
)
2885 pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE
,
2886 macio_chips
[0].of_node
, 0, 0);
2888 /* While on some desktop G3s, we turn it back on */
2889 if (macio_chips
[0].of_node
&& macio_chips
[0].type
== macio_heathrow
2890 && (pmac_mb
.model_id
== PMAC_TYPE_GOSSAMER
||
2891 pmac_mb
.model_id
== PMAC_TYPE_SILK
)) {
2892 struct macio_chip
*macio
= &macio_chips
[0];
2893 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
2894 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
2897 #endif /* CONFIG_POWER4 */
2899 /* On all machines, switch modem & serial ports off */
2900 for_each_node_by_name(np
, "ch-a")
2901 initial_serial_shutdown(np
);
2903 for_each_node_by_name(np
, "ch-b")
2904 initial_serial_shutdown(np
);
2909 pmac_feature_init(void)
2911 /* Detect the UniNorth memory controller */
2914 /* Probe mac-io controllers */
2915 if (probe_macios()) {
2916 printk(KERN_WARNING
"No mac-io chip found\n");
2920 /* Probe machine type */
2921 if (probe_motherboard())
2922 printk(KERN_WARNING
"Unknown PowerMac !\n");
2924 /* Set some initial features (turn off some chips that will
2925 * be later turned on)
2927 set_initial_features();
2931 static void dump_HT_speeds(char *name
, u32 cfg
, u32 frq
)
2933 int freqs
[16] = { 200,300,400,500,600,800,1000,0,0,0,0,0,0,0,0,0 };
2934 int bits
[8] = { 8,16,0,32,2,4,0,0 };
2935 int freq
= (frq
>> 8) & 0xf;
2937 if (freqs
[freq
] == 0)
2938 printk("%s: Unknown HT link frequency %x\n", name
, freq
);
2940 printk("%s: %d MHz on main link, (%d in / %d out) bits width\n",
2942 bits
[(cfg
>> 28) & 0x7], bits
[(cfg
>> 24) & 0x7]);
2945 void __init
pmac_check_ht_link(void)
2947 u32 ufreq
, freq
, ucfg
, cfg
;
2948 struct device_node
*pcix_node
;
2949 u8 px_bus
, px_devfn
;
2950 struct pci_controller
*px_hose
;
2952 (void)in_be32(u3_ht_base
+ U3_HT_LINK_COMMAND
);
2953 ucfg
= cfg
= in_be32(u3_ht_base
+ U3_HT_LINK_CONFIG
);
2954 ufreq
= freq
= in_be32(u3_ht_base
+ U3_HT_LINK_FREQ
);
2955 dump_HT_speeds("U3 HyperTransport", cfg
, freq
);
2957 pcix_node
= of_find_compatible_node(NULL
, "pci", "pci-x");
2958 if (pcix_node
== NULL
) {
2959 printk("No PCI-X bridge found\n");
2962 if (pci_device_from_OF_node(pcix_node
, &px_bus
, &px_devfn
) != 0) {
2963 printk("PCI-X bridge found but not matched to pci\n");
2966 px_hose
= pci_find_hose_for_OF_device(pcix_node
);
2967 if (px_hose
== NULL
) {
2968 printk("PCI-X bridge found but not matched to host\n");
2971 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xc4, &cfg
);
2972 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xcc, &freq
);
2973 dump_HT_speeds("PCI-X HT Uplink", cfg
, freq
);
2974 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xc8, &cfg
);
2975 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xd0, &freq
);
2976 dump_HT_speeds("PCI-X HT Downlink", cfg
, freq
);
2981 * Early video resume hook
2984 static void (*pmac_early_vresume_proc
)(void *data
);
2985 static void *pmac_early_vresume_data
;
2987 void pmac_set_early_video_resume(void (*proc
)(void *data
), void *data
)
2989 if (!machine_is(powermac
))
2992 pmac_early_vresume_proc
= proc
;
2993 pmac_early_vresume_data
= data
;
2996 EXPORT_SYMBOL(pmac_set_early_video_resume
);
2998 void pmac_call_early_video_resume(void)
3000 if (pmac_early_vresume_proc
)
3001 pmac_early_vresume_proc(pmac_early_vresume_data
);
3005 * AGP related suspend/resume code
3008 static struct pci_dev
*pmac_agp_bridge
;
3009 static int (*pmac_agp_suspend
)(struct pci_dev
*bridge
);
3010 static int (*pmac_agp_resume
)(struct pci_dev
*bridge
);
3012 void pmac_register_agp_pm(struct pci_dev
*bridge
,
3013 int (*suspend
)(struct pci_dev
*bridge
),
3014 int (*resume
)(struct pci_dev
*bridge
))
3016 if (suspend
|| resume
) {
3017 pmac_agp_bridge
= bridge
;
3018 pmac_agp_suspend
= suspend
;
3019 pmac_agp_resume
= resume
;
3022 if (bridge
!= pmac_agp_bridge
)
3024 pmac_agp_suspend
= pmac_agp_resume
= NULL
;
3027 EXPORT_SYMBOL(pmac_register_agp_pm
);
3029 void pmac_suspend_agp_for_card(struct pci_dev
*dev
)
3031 if (pmac_agp_bridge
== NULL
|| pmac_agp_suspend
== NULL
)
3033 if (pmac_agp_bridge
->bus
!= dev
->bus
)
3035 pmac_agp_suspend(pmac_agp_bridge
);
3037 EXPORT_SYMBOL(pmac_suspend_agp_for_card
);
3039 void pmac_resume_agp_for_card(struct pci_dev
*dev
)
3041 if (pmac_agp_bridge
== NULL
|| pmac_agp_resume
== NULL
)
3043 if (pmac_agp_bridge
->bus
!= dev
->bus
)
3045 pmac_agp_resume(pmac_agp_bridge
);
3047 EXPORT_SYMBOL(pmac_resume_agp_for_card
);
3049 int pmac_get_uninorth_variant(void)
3051 return uninorth_maj
;