2 * arch/ppc/platforms/pmac_feature.c
4 * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
5 * Ben. Herrenschmidt (benh@kernel.crashing.org)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
14 * - Replace mdelay with some schedule loop if possible
15 * - Shorten some obfuscated delays on some routines (like modem
17 * - Refcount some clocks (see darwin)
18 * - Split split split...
21 #include <linux/config.h>
22 #include <linux/types.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/kernel.h>
26 #include <linux/sched.h>
27 #include <linux/spinlock.h>
28 #include <linux/adb.h>
29 #include <linux/pmu.h>
30 #include <linux/ioport.h>
31 #include <linux/pci.h>
32 #include <asm/sections.h>
33 #include <asm/errno.h>
34 #include <asm/ohare.h>
35 #include <asm/heathrow.h>
36 #include <asm/keylargo.h>
37 #include <asm/uninorth.h>
40 #include <asm/machdep.h>
41 #include <asm/pmac_feature.h>
42 #include <asm/dbdma.h>
43 #include <asm/pci-bridge.h>
44 #include <asm/pmac_low_i2c.h>
49 #define DBG(fmt...) printk(KERN_DEBUG fmt)
55 extern int powersave_lowspeed
;
58 extern int powersave_nap
;
59 extern struct device_node
*k2_skiplist
[2];
63 * We use a single global lock to protect accesses. Each driver has
64 * to take care of its own locking
66 static DEFINE_SPINLOCK(feature_lock
);
68 #define LOCK(flags) spin_lock_irqsave(&feature_lock, flags);
69 #define UNLOCK(flags) spin_unlock_irqrestore(&feature_lock, flags);
73 * Instance of some macio stuffs
75 struct macio_chip macio_chips
[MAX_MACIO_CHIPS
];
77 struct macio_chip
*macio_find(struct device_node
*child
, int type
)
82 for (i
=0; i
< MAX_MACIO_CHIPS
&& macio_chips
[i
].of_node
; i
++)
83 if (child
== macio_chips
[i
].of_node
&&
84 (!type
|| macio_chips
[i
].type
== type
))
85 return &macio_chips
[i
];
86 child
= child
->parent
;
90 EXPORT_SYMBOL_GPL(macio_find
);
92 static const char *macio_names
[] =
111 * Uninorth reg. access. Note that Uni-N regs are big endian
114 #define UN_REG(r) (uninorth_base + ((r) >> 2))
115 #define UN_IN(r) (in_be32(UN_REG(r)))
116 #define UN_OUT(r,v) (out_be32(UN_REG(r), (v)))
117 #define UN_BIS(r,v) (UN_OUT((r), UN_IN(r) | (v)))
118 #define UN_BIC(r,v) (UN_OUT((r), UN_IN(r) & ~(v)))
120 static struct device_node
*uninorth_node
;
121 static u32 __iomem
*uninorth_base
;
122 static u32 uninorth_rev
;
123 static int uninorth_maj
;
124 static void __iomem
*u3_ht
;
127 * For each motherboard family, we have a table of functions pointers
128 * that handle the various features.
131 typedef long (*feature_call
)(struct device_node
*node
, long param
, long value
);
133 struct feature_table_entry
{
134 unsigned int selector
;
135 feature_call function
;
140 const char* model_string
;
141 const char* model_name
;
143 struct feature_table_entry
* features
;
144 unsigned long board_flags
;
146 static struct pmac_mb_def pmac_mb
;
149 * Here are the chip specific feature functions
152 static inline int simple_feature_tweak(struct device_node
*node
, int type
,
153 int reg
, u32 mask
, int value
)
155 struct macio_chip
* macio
;
158 macio
= macio_find(node
, type
);
163 MACIO_BIS(reg
, mask
);
165 MACIO_BIC(reg
, mask
);
166 (void)MACIO_IN32(reg
);
172 #ifndef CONFIG_POWER4
174 static long ohare_htw_scc_enable(struct device_node
*node
, long param
,
177 struct macio_chip
* macio
;
178 unsigned long chan_mask
;
184 macio
= macio_find(node
, 0);
187 if (!strcmp(node
->name
, "ch-a"))
188 chan_mask
= MACIO_FLAG_SCCA_ON
;
189 else if (!strcmp(node
->name
, "ch-b"))
190 chan_mask
= MACIO_FLAG_SCCB_ON
;
194 htw
= (macio
->type
== macio_heathrow
|| macio
->type
== macio_paddington
195 || macio
->type
== macio_gatwick
);
196 /* On these machines, the HRW_SCC_TRANS_EN_N bit mustn't be touched */
197 trans
= (pmac_mb
.model_id
!= PMAC_TYPE_YOSEMITE
&&
198 pmac_mb
.model_id
!= PMAC_TYPE_YIKES
);
200 #ifdef CONFIG_ADB_PMU
201 if ((param
& 0xfff) == PMAC_SCC_IRDA
)
203 #endif /* CONFIG_ADB_PMU */
205 fcr
= MACIO_IN32(OHARE_FCR
);
206 /* Check if scc cell need enabling */
207 if (!(fcr
& OH_SCC_ENABLE
)) {
208 fcr
|= OH_SCC_ENABLE
;
210 /* Side effect: this will also power up the
211 * modem, but it's too messy to figure out on which
212 * ports this controls the tranceiver and on which
213 * it controls the modem
216 fcr
&= ~HRW_SCC_TRANS_EN_N
;
217 MACIO_OUT32(OHARE_FCR
, fcr
);
218 fcr
|= (rmask
= HRW_RESET_SCC
);
219 MACIO_OUT32(OHARE_FCR
, fcr
);
221 fcr
|= (rmask
= OH_SCC_RESET
);
222 MACIO_OUT32(OHARE_FCR
, fcr
);
225 (void)MACIO_IN32(OHARE_FCR
);
229 MACIO_OUT32(OHARE_FCR
, fcr
);
231 if (chan_mask
& MACIO_FLAG_SCCA_ON
)
233 if (chan_mask
& MACIO_FLAG_SCCB_ON
)
235 MACIO_OUT32(OHARE_FCR
, fcr
);
236 macio
->flags
|= chan_mask
;
238 if (param
& PMAC_SCC_FLAG_XMON
)
239 macio
->flags
|= MACIO_FLAG_SCC_LOCKED
;
241 if (macio
->flags
& MACIO_FLAG_SCC_LOCKED
)
244 fcr
= MACIO_IN32(OHARE_FCR
);
245 if (chan_mask
& MACIO_FLAG_SCCA_ON
)
247 if (chan_mask
& MACIO_FLAG_SCCB_ON
)
249 MACIO_OUT32(OHARE_FCR
, fcr
);
250 if ((fcr
& (OH_SCCA_IO
| OH_SCCB_IO
)) == 0) {
251 fcr
&= ~OH_SCC_ENABLE
;
253 fcr
|= HRW_SCC_TRANS_EN_N
;
254 MACIO_OUT32(OHARE_FCR
, fcr
);
256 macio
->flags
&= ~(chan_mask
);
259 #ifdef CONFIG_ADB_PMU
260 if ((param
& 0xfff) == PMAC_SCC_IRDA
)
262 #endif /* CONFIG_ADB_PMU */
267 static long ohare_floppy_enable(struct device_node
*node
, long param
,
270 return simple_feature_tweak(node
, macio_ohare
,
271 OHARE_FCR
, OH_FLOPPY_ENABLE
, value
);
274 static long ohare_mesh_enable(struct device_node
*node
, long param
, long value
)
276 return simple_feature_tweak(node
, macio_ohare
,
277 OHARE_FCR
, OH_MESH_ENABLE
, value
);
280 static long ohare_ide_enable(struct device_node
*node
, long param
, long value
)
284 /* For some reason, setting the bit in set_initial_features()
285 * doesn't stick. I'm still investigating... --BenH.
288 simple_feature_tweak(node
, macio_ohare
,
289 OHARE_FCR
, OH_IOBUS_ENABLE
, 1);
290 return simple_feature_tweak(node
, macio_ohare
,
291 OHARE_FCR
, OH_IDE0_ENABLE
, value
);
293 return simple_feature_tweak(node
, macio_ohare
,
294 OHARE_FCR
, OH_BAY_IDE_ENABLE
, value
);
300 static long ohare_ide_reset(struct device_node
*node
, long param
, long value
)
304 return simple_feature_tweak(node
, macio_ohare
,
305 OHARE_FCR
, OH_IDE0_RESET_N
, !value
);
307 return simple_feature_tweak(node
, macio_ohare
,
308 OHARE_FCR
, OH_IDE1_RESET_N
, !value
);
314 static long ohare_sleep_state(struct device_node
*node
, long param
, long value
)
316 struct macio_chip
* macio
= &macio_chips
[0];
318 if ((pmac_mb
.board_flags
& PMAC_MB_CAN_SLEEP
) == 0)
321 MACIO_BIC(OHARE_FCR
, OH_IOBUS_ENABLE
);
322 } else if (value
== 0) {
323 MACIO_BIS(OHARE_FCR
, OH_IOBUS_ENABLE
);
329 static long heathrow_modem_enable(struct device_node
*node
, long param
,
332 struct macio_chip
* macio
;
336 macio
= macio_find(node
, macio_unknown
);
339 gpio
= MACIO_IN8(HRW_GPIO_MODEM_RESET
) & ~1;
342 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
);
344 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
347 if (pmac_mb
.model_id
!= PMAC_TYPE_YOSEMITE
&&
348 pmac_mb
.model_id
!= PMAC_TYPE_YIKES
) {
351 MACIO_BIC(HEATHROW_FCR
, HRW_SCC_TRANS_EN_N
);
353 MACIO_BIS(HEATHROW_FCR
, HRW_SCC_TRANS_EN_N
);
355 (void)MACIO_IN32(HEATHROW_FCR
);
360 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
| 1);
361 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
362 UNLOCK(flags
); mdelay(250); LOCK(flags
);
363 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
);
364 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
365 UNLOCK(flags
); mdelay(250); LOCK(flags
);
366 MACIO_OUT8(HRW_GPIO_MODEM_RESET
, gpio
| 1);
367 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET
);
368 UNLOCK(flags
); mdelay(250);
373 static long heathrow_floppy_enable(struct device_node
*node
, long param
,
376 return simple_feature_tweak(node
, macio_unknown
,
378 HRW_SWIM_ENABLE
|HRW_BAY_FLOPPY_ENABLE
,
382 static long heathrow_mesh_enable(struct device_node
*node
, long param
,
385 struct macio_chip
* macio
;
388 macio
= macio_find(node
, macio_unknown
);
392 /* Set clear mesh cell enable */
394 MACIO_BIS(HEATHROW_FCR
, HRW_MESH_ENABLE
);
396 MACIO_BIC(HEATHROW_FCR
, HRW_MESH_ENABLE
);
397 (void)MACIO_IN32(HEATHROW_FCR
);
399 /* Set/Clear termination power */
401 MACIO_BIC(HEATHROW_MBCR
, 0x04000000);
403 MACIO_BIS(HEATHROW_MBCR
, 0x04000000);
404 (void)MACIO_IN32(HEATHROW_MBCR
);
411 static long heathrow_ide_enable(struct device_node
*node
, long param
,
416 return simple_feature_tweak(node
, macio_unknown
,
417 HEATHROW_FCR
, HRW_IDE0_ENABLE
, value
);
419 return simple_feature_tweak(node
, macio_unknown
,
420 HEATHROW_FCR
, HRW_BAY_IDE_ENABLE
, value
);
426 static long heathrow_ide_reset(struct device_node
*node
, long param
,
431 return simple_feature_tweak(node
, macio_unknown
,
432 HEATHROW_FCR
, HRW_IDE0_RESET_N
, !value
);
434 return simple_feature_tweak(node
, macio_unknown
,
435 HEATHROW_FCR
, HRW_IDE1_RESET_N
, !value
);
441 static long heathrow_bmac_enable(struct device_node
*node
, long param
,
444 struct macio_chip
* macio
;
447 macio
= macio_find(node
, 0);
452 MACIO_BIS(HEATHROW_FCR
, HRW_BMAC_IO_ENABLE
);
453 MACIO_BIS(HEATHROW_FCR
, HRW_BMAC_RESET
);
455 (void)MACIO_IN32(HEATHROW_FCR
);
458 MACIO_BIC(HEATHROW_FCR
, HRW_BMAC_RESET
);
460 (void)MACIO_IN32(HEATHROW_FCR
);
464 MACIO_BIC(HEATHROW_FCR
, HRW_BMAC_IO_ENABLE
);
470 static long heathrow_sound_enable(struct device_node
*node
, long param
,
473 struct macio_chip
* macio
;
476 /* B&W G3 and Yikes don't support that properly (the
477 * sound appear to never come back after beeing shut down).
479 if (pmac_mb
.model_id
== PMAC_TYPE_YOSEMITE
||
480 pmac_mb
.model_id
== PMAC_TYPE_YIKES
)
483 macio
= macio_find(node
, 0);
488 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
489 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
491 (void)MACIO_IN32(HEATHROW_FCR
);
494 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
495 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
501 static u32 save_fcr
[6];
502 static u32 save_mbcr
;
503 static u32 save_gpio_levels
[2];
504 static u8 save_gpio_extint
[KEYLARGO_GPIO_EXTINT_CNT
];
505 static u8 save_gpio_normal
[KEYLARGO_GPIO_CNT
];
506 static u32 save_unin_clock_ctl
;
507 static struct dbdma_regs save_dbdma
[13];
508 static struct dbdma_regs save_alt_dbdma
[13];
510 static void dbdma_save(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 save
[i
].cmdptr_hi
= in_le32(&chan
->cmdptr_hi
);
519 save
[i
].cmdptr
= in_le32(&chan
->cmdptr
);
520 save
[i
].intr_sel
= in_le32(&chan
->intr_sel
);
521 save
[i
].br_sel
= in_le32(&chan
->br_sel
);
522 save
[i
].wait_sel
= in_le32(&chan
->wait_sel
);
526 static void dbdma_restore(struct macio_chip
*macio
, struct dbdma_regs
*save
)
530 /* Save state & config of DBDMA channels */
531 for (i
= 0; i
< 13; i
++) {
532 volatile struct dbdma_regs __iomem
* chan
= (void __iomem
*)
533 (macio
->base
+ ((0x8000+i
*0x100)>>2));
534 out_le32(&chan
->control
, (ACTIVE
|DEAD
|WAKE
|FLUSH
|PAUSE
|RUN
)<<16);
535 while (in_le32(&chan
->status
) & ACTIVE
)
537 out_le32(&chan
->cmdptr_hi
, save
[i
].cmdptr_hi
);
538 out_le32(&chan
->cmdptr
, save
[i
].cmdptr
);
539 out_le32(&chan
->intr_sel
, save
[i
].intr_sel
);
540 out_le32(&chan
->br_sel
, save
[i
].br_sel
);
541 out_le32(&chan
->wait_sel
, save
[i
].wait_sel
);
545 static void heathrow_sleep(struct macio_chip
*macio
, int secondary
)
548 dbdma_save(macio
, save_alt_dbdma
);
549 save_fcr
[2] = MACIO_IN32(0x38);
550 save_fcr
[3] = MACIO_IN32(0x3c);
552 dbdma_save(macio
, save_dbdma
);
553 save_fcr
[0] = MACIO_IN32(0x38);
554 save_fcr
[1] = MACIO_IN32(0x3c);
555 save_mbcr
= MACIO_IN32(0x34);
556 /* Make sure sound is shut down */
557 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
558 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
559 /* This seems to be necessary as well or the fan
560 * keeps coming up and battery drains fast */
561 MACIO_BIC(HEATHROW_FCR
, HRW_IOBUS_ENABLE
);
562 MACIO_BIC(HEATHROW_FCR
, HRW_IDE0_RESET_N
);
563 /* Make sure eth is down even if module or sleep
564 * won't work properly */
565 MACIO_BIC(HEATHROW_FCR
, HRW_BMAC_IO_ENABLE
| HRW_BMAC_RESET
);
567 /* Make sure modem is shut down */
568 MACIO_OUT8(HRW_GPIO_MODEM_RESET
,
569 MACIO_IN8(HRW_GPIO_MODEM_RESET
) & ~1);
570 MACIO_BIS(HEATHROW_FCR
, HRW_SCC_TRANS_EN_N
);
571 MACIO_BIC(HEATHROW_FCR
, OH_SCCA_IO
|OH_SCCB_IO
|HRW_SCC_ENABLE
);
573 /* Let things settle */
574 (void)MACIO_IN32(HEATHROW_FCR
);
577 static void heathrow_wakeup(struct macio_chip
*macio
, int secondary
)
580 MACIO_OUT32(0x38, save_fcr
[2]);
581 (void)MACIO_IN32(0x38);
583 MACIO_OUT32(0x3c, save_fcr
[3]);
584 (void)MACIO_IN32(0x38);
586 dbdma_restore(macio
, save_alt_dbdma
);
588 MACIO_OUT32(0x38, save_fcr
[0] | HRW_IOBUS_ENABLE
);
589 (void)MACIO_IN32(0x38);
591 MACIO_OUT32(0x3c, save_fcr
[1]);
592 (void)MACIO_IN32(0x38);
594 MACIO_OUT32(0x34, save_mbcr
);
595 (void)MACIO_IN32(0x38);
597 dbdma_restore(macio
, save_dbdma
);
601 static long heathrow_sleep_state(struct device_node
*node
, long param
,
604 if ((pmac_mb
.board_flags
& PMAC_MB_CAN_SLEEP
) == 0)
607 if (macio_chips
[1].type
== macio_gatwick
)
608 heathrow_sleep(&macio_chips
[0], 1);
609 heathrow_sleep(&macio_chips
[0], 0);
610 } else if (value
== 0) {
611 heathrow_wakeup(&macio_chips
[0], 0);
612 if (macio_chips
[1].type
== macio_gatwick
)
613 heathrow_wakeup(&macio_chips
[0], 1);
618 static long core99_scc_enable(struct device_node
*node
, long param
, long value
)
620 struct macio_chip
* macio
;
622 unsigned long chan_mask
;
625 macio
= macio_find(node
, 0);
628 if (!strcmp(node
->name
, "ch-a"))
629 chan_mask
= MACIO_FLAG_SCCA_ON
;
630 else if (!strcmp(node
->name
, "ch-b"))
631 chan_mask
= MACIO_FLAG_SCCB_ON
;
636 int need_reset_scc
= 0;
637 int need_reset_irda
= 0;
640 fcr
= MACIO_IN32(KEYLARGO_FCR0
);
641 /* Check if scc cell need enabling */
642 if (!(fcr
& KL0_SCC_CELL_ENABLE
)) {
643 fcr
|= KL0_SCC_CELL_ENABLE
;
646 if (chan_mask
& MACIO_FLAG_SCCA_ON
) {
647 fcr
|= KL0_SCCA_ENABLE
;
648 /* Don't enable line drivers for I2S modem */
649 if ((param
& 0xfff) == PMAC_SCC_I2S1
)
650 fcr
&= ~KL0_SCC_A_INTF_ENABLE
;
652 fcr
|= KL0_SCC_A_INTF_ENABLE
;
654 if (chan_mask
& MACIO_FLAG_SCCB_ON
) {
655 fcr
|= KL0_SCCB_ENABLE
;
656 /* Perform irda specific inits */
657 if ((param
& 0xfff) == PMAC_SCC_IRDA
) {
658 fcr
&= ~KL0_SCC_B_INTF_ENABLE
;
659 fcr
|= KL0_IRDA_ENABLE
;
660 fcr
|= KL0_IRDA_CLK32_ENABLE
| KL0_IRDA_CLK19_ENABLE
;
661 fcr
|= KL0_IRDA_SOURCE1_SEL
;
662 fcr
&= ~(KL0_IRDA_FAST_CONNECT
|KL0_IRDA_DEFAULT1
|KL0_IRDA_DEFAULT0
);
663 fcr
&= ~(KL0_IRDA_SOURCE2_SEL
|KL0_IRDA_HIGH_BAND
);
666 fcr
|= KL0_SCC_B_INTF_ENABLE
;
668 MACIO_OUT32(KEYLARGO_FCR0
, fcr
);
669 macio
->flags
|= chan_mask
;
670 if (need_reset_scc
) {
671 MACIO_BIS(KEYLARGO_FCR0
, KL0_SCC_RESET
);
672 (void)MACIO_IN32(KEYLARGO_FCR0
);
676 MACIO_BIC(KEYLARGO_FCR0
, KL0_SCC_RESET
);
678 if (need_reset_irda
) {
679 MACIO_BIS(KEYLARGO_FCR0
, KL0_IRDA_RESET
);
680 (void)MACIO_IN32(KEYLARGO_FCR0
);
684 MACIO_BIC(KEYLARGO_FCR0
, KL0_IRDA_RESET
);
687 if (param
& PMAC_SCC_FLAG_XMON
)
688 macio
->flags
|= MACIO_FLAG_SCC_LOCKED
;
690 if (macio
->flags
& MACIO_FLAG_SCC_LOCKED
)
693 fcr
= MACIO_IN32(KEYLARGO_FCR0
);
694 if (chan_mask
& MACIO_FLAG_SCCA_ON
)
695 fcr
&= ~KL0_SCCA_ENABLE
;
696 if (chan_mask
& MACIO_FLAG_SCCB_ON
) {
697 fcr
&= ~KL0_SCCB_ENABLE
;
698 /* Perform irda specific clears */
699 if ((param
& 0xfff) == PMAC_SCC_IRDA
) {
700 fcr
&= ~KL0_IRDA_ENABLE
;
701 fcr
&= ~(KL0_IRDA_CLK32_ENABLE
| KL0_IRDA_CLK19_ENABLE
);
702 fcr
&= ~(KL0_IRDA_FAST_CONNECT
|KL0_IRDA_DEFAULT1
|KL0_IRDA_DEFAULT0
);
703 fcr
&= ~(KL0_IRDA_SOURCE1_SEL
|KL0_IRDA_SOURCE2_SEL
|KL0_IRDA_HIGH_BAND
);
706 MACIO_OUT32(KEYLARGO_FCR0
, fcr
);
707 if ((fcr
& (KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
)) == 0) {
708 fcr
&= ~KL0_SCC_CELL_ENABLE
;
709 MACIO_OUT32(KEYLARGO_FCR0
, fcr
);
711 macio
->flags
&= ~(chan_mask
);
719 core99_modem_enable(struct device_node
*node
, long param
, long value
)
721 struct macio_chip
* macio
;
725 /* Hack for internal USB modem */
727 if (macio_chips
[0].type
!= macio_keylargo
)
729 node
= macio_chips
[0].of_node
;
731 macio
= macio_find(node
, 0);
734 gpio
= MACIO_IN8(KL_GPIO_MODEM_RESET
);
735 gpio
|= KEYLARGO_GPIO_OUTPUT_ENABLE
;
736 gpio
&= ~KEYLARGO_GPIO_OUTOUT_DATA
;
740 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
742 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
747 MACIO_BIC(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
749 (void)MACIO_IN32(KEYLARGO_FCR2
);
752 MACIO_BIS(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
757 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
758 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
759 UNLOCK(flags
); mdelay(250); LOCK(flags
);
760 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
761 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
762 UNLOCK(flags
); mdelay(250); LOCK(flags
);
763 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
764 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
765 UNLOCK(flags
); mdelay(250);
771 pangea_modem_enable(struct device_node
*node
, long param
, long value
)
773 struct macio_chip
* macio
;
777 /* Hack for internal USB modem */
779 if (macio_chips
[0].type
!= macio_pangea
&&
780 macio_chips
[0].type
!= macio_intrepid
)
782 node
= macio_chips
[0].of_node
;
784 macio
= macio_find(node
, 0);
787 gpio
= MACIO_IN8(KL_GPIO_MODEM_RESET
);
788 gpio
|= KEYLARGO_GPIO_OUTPUT_ENABLE
;
789 gpio
&= ~KEYLARGO_GPIO_OUTOUT_DATA
;
793 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
795 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
800 MACIO_OUT8(KL_GPIO_MODEM_POWER
,
801 KEYLARGO_GPIO_OUTPUT_ENABLE
);
803 (void)MACIO_IN32(KEYLARGO_FCR2
);
806 MACIO_OUT8(KL_GPIO_MODEM_POWER
,
807 KEYLARGO_GPIO_OUTPUT_ENABLE
| KEYLARGO_GPIO_OUTOUT_DATA
);
812 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
813 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
814 UNLOCK(flags
); mdelay(250); LOCK(flags
);
815 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
);
816 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
817 UNLOCK(flags
); mdelay(250); LOCK(flags
);
818 MACIO_OUT8(KL_GPIO_MODEM_RESET
, gpio
| KEYLARGO_GPIO_OUTOUT_DATA
);
819 (void)MACIO_IN8(KL_GPIO_MODEM_RESET
);
820 UNLOCK(flags
); mdelay(250);
826 core99_ata100_enable(struct device_node
*node
, long value
)
829 struct pci_dev
*pdev
= NULL
;
832 if (uninorth_rev
< 0x24)
837 UN_BIS(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_ATA100
);
839 UN_BIC(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_ATA100
);
840 (void)UN_IN(UNI_N_CLOCK_CNTL
);
845 if (pci_device_from_OF_node(node
, &pbus
, &pid
) == 0)
846 pdev
= pci_find_slot(pbus
, pid
);
849 pci_enable_device(pdev
);
850 pci_set_master(pdev
);
856 core99_ide_enable(struct device_node
*node
, long param
, long value
)
858 /* Bus ID 0 to 2 are KeyLargo based IDE, busID 3 is U2
863 return simple_feature_tweak(node
, macio_unknown
,
864 KEYLARGO_FCR1
, KL1_EIDE0_ENABLE
, value
);
866 return simple_feature_tweak(node
, macio_unknown
,
867 KEYLARGO_FCR1
, KL1_EIDE1_ENABLE
, value
);
869 return simple_feature_tweak(node
, macio_unknown
,
870 KEYLARGO_FCR1
, KL1_UIDE_ENABLE
, value
);
872 return core99_ata100_enable(node
, value
);
879 core99_ide_reset(struct device_node
*node
, long param
, long value
)
883 return simple_feature_tweak(node
, macio_unknown
,
884 KEYLARGO_FCR1
, KL1_EIDE0_RESET_N
, !value
);
886 return simple_feature_tweak(node
, macio_unknown
,
887 KEYLARGO_FCR1
, KL1_EIDE1_RESET_N
, !value
);
889 return simple_feature_tweak(node
, macio_unknown
,
890 KEYLARGO_FCR1
, KL1_UIDE_RESET_N
, !value
);
897 core99_gmac_enable(struct device_node
*node
, long param
, long value
)
903 UN_BIS(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_GMAC
);
905 UN_BIC(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_GMAC
);
906 (void)UN_IN(UNI_N_CLOCK_CNTL
);
914 core99_gmac_phy_reset(struct device_node
*node
, long param
, long value
)
917 struct macio_chip
*macio
;
919 macio
= &macio_chips
[0];
920 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
921 macio
->type
!= macio_intrepid
)
925 MACIO_OUT8(KL_GPIO_ETH_PHY_RESET
, KEYLARGO_GPIO_OUTPUT_ENABLE
);
926 (void)MACIO_IN8(KL_GPIO_ETH_PHY_RESET
);
930 MACIO_OUT8(KL_GPIO_ETH_PHY_RESET
, /*KEYLARGO_GPIO_OUTPUT_ENABLE | */
931 KEYLARGO_GPIO_OUTOUT_DATA
);
939 core99_sound_chip_enable(struct device_node
*node
, long param
, long value
)
941 struct macio_chip
* macio
;
944 macio
= macio_find(node
, 0);
948 /* Do a better probe code, screamer G4 desktops &
949 * iMacs can do that too, add a recalibrate in
952 if (pmac_mb
.model_id
== PMAC_TYPE_PISMO
||
953 pmac_mb
.model_id
== PMAC_TYPE_TITANIUM
) {
956 MACIO_OUT8(KL_GPIO_SOUND_POWER
,
957 KEYLARGO_GPIO_OUTPUT_ENABLE
|
958 KEYLARGO_GPIO_OUTOUT_DATA
);
960 MACIO_OUT8(KL_GPIO_SOUND_POWER
,
961 KEYLARGO_GPIO_OUTPUT_ENABLE
);
962 (void)MACIO_IN8(KL_GPIO_SOUND_POWER
);
969 core99_airport_enable(struct device_node
*node
, long param
, long value
)
971 struct macio_chip
* macio
;
975 macio
= macio_find(node
, 0);
979 /* Hint: we allow passing of macio itself for the sake of the
982 if (node
!= macio
->of_node
&&
983 (!node
->parent
|| node
->parent
!= macio
->of_node
))
985 state
= (macio
->flags
& MACIO_FLAG_AIRPORT_ON
) != 0;
989 /* This code is a reproduction of OF enable-cardslot
990 * and init-wireless methods, slightly hacked until
994 MACIO_OUT8(KEYLARGO_GPIO_0
+0xf, 5);
995 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xf);
999 MACIO_OUT8(KEYLARGO_GPIO_0
+0xf, 4);
1000 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xf);
1006 MACIO_BIC(KEYLARGO_FCR2
, KL2_CARDSEL_16
);
1007 (void)MACIO_IN32(KEYLARGO_FCR2
);
1009 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+0xb, 0);
1010 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+0xb);
1012 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+0xa, 0x28);
1013 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+0xa);
1015 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+0xd, 0x28);
1016 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+0xd);
1018 MACIO_OUT8(KEYLARGO_GPIO_0
+0xd, 0x28);
1019 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xd);
1021 MACIO_OUT8(KEYLARGO_GPIO_0
+0xe, 0x28);
1022 (void)MACIO_IN8(KEYLARGO_GPIO_0
+0xe);
1025 MACIO_OUT32(0x1c000, 0);
1027 MACIO_OUT8(0x1a3e0, 0x41);
1028 (void)MACIO_IN8(0x1a3e0);
1031 MACIO_BIS(KEYLARGO_FCR2
, KL2_CARDSEL_16
);
1032 (void)MACIO_IN32(KEYLARGO_FCR2
);
1036 macio
->flags
|= MACIO_FLAG_AIRPORT_ON
;
1039 MACIO_BIC(KEYLARGO_FCR2
, KL2_CARDSEL_16
);
1040 (void)MACIO_IN32(KEYLARGO_FCR2
);
1041 MACIO_OUT8(KL_GPIO_AIRPORT_0
, 0);
1042 MACIO_OUT8(KL_GPIO_AIRPORT_1
, 0);
1043 MACIO_OUT8(KL_GPIO_AIRPORT_2
, 0);
1044 MACIO_OUT8(KL_GPIO_AIRPORT_3
, 0);
1045 MACIO_OUT8(KL_GPIO_AIRPORT_4
, 0);
1046 (void)MACIO_IN8(KL_GPIO_AIRPORT_4
);
1049 macio
->flags
&= ~MACIO_FLAG_AIRPORT_ON
;
1056 core99_reset_cpu(struct device_node
*node
, long param
, long value
)
1058 unsigned int reset_io
= 0;
1059 unsigned long flags
;
1060 struct macio_chip
*macio
;
1061 struct device_node
*np
;
1062 const int dflt_reset_lines
[] = { KL_GPIO_RESET_CPU0
,
1065 KL_GPIO_RESET_CPU3
};
1067 macio
= &macio_chips
[0];
1068 if (macio
->type
!= macio_keylargo
)
1071 np
= find_path_device("/cpus");
1074 for (np
= np
->child
; np
!= NULL
; np
= np
->sibling
) {
1075 u32
*num
= (u32
*)get_property(np
, "reg", NULL
);
1076 u32
*rst
= (u32
*)get_property(np
, "soft-reset", NULL
);
1077 if (num
== NULL
|| rst
== NULL
)
1079 if (param
== *num
) {
1084 if (np
== NULL
|| reset_io
== 0)
1085 reset_io
= dflt_reset_lines
[param
];
1088 MACIO_OUT8(reset_io
, KEYLARGO_GPIO_OUTPUT_ENABLE
);
1089 (void)MACIO_IN8(reset_io
);
1091 MACIO_OUT8(reset_io
, 0);
1092 (void)MACIO_IN8(reset_io
);
1097 #endif /* CONFIG_SMP */
1100 core99_usb_enable(struct device_node
*node
, long param
, long value
)
1102 struct macio_chip
*macio
;
1103 unsigned long flags
;
1108 macio
= &macio_chips
[0];
1109 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1110 macio
->type
!= macio_intrepid
)
1113 prop
= (char *)get_property(node
, "AAPL,clock-id", NULL
);
1116 if (strncmp(prop
, "usb0u048", 8) == 0)
1118 else if (strncmp(prop
, "usb1u148", 8) == 0)
1120 else if (strncmp(prop
, "usb2u248", 8) == 0)
1125 /* Sorry for the brute-force locking, but this is only used during
1126 * sleep and the timing seem to be critical
1132 MACIO_BIC(KEYLARGO_FCR0
, (KL0_USB0_PAD_SUSPEND0
| KL0_USB0_PAD_SUSPEND1
));
1133 (void)MACIO_IN32(KEYLARGO_FCR0
);
1137 MACIO_BIS(KEYLARGO_FCR0
, KL0_USB0_CELL_ENABLE
);
1138 } else if (number
== 2) {
1139 MACIO_BIC(KEYLARGO_FCR0
, (KL0_USB1_PAD_SUSPEND0
| KL0_USB1_PAD_SUSPEND1
));
1141 (void)MACIO_IN32(KEYLARGO_FCR0
);
1144 MACIO_BIS(KEYLARGO_FCR0
, KL0_USB1_CELL_ENABLE
);
1145 } else if (number
== 4) {
1146 MACIO_BIC(KEYLARGO_FCR1
, (KL1_USB2_PAD_SUSPEND0
| KL1_USB2_PAD_SUSPEND1
));
1148 (void)MACIO_IN32(KEYLARGO_FCR1
);
1151 MACIO_BIS(KEYLARGO_FCR1
, KL1_USB2_CELL_ENABLE
);
1154 reg
= MACIO_IN32(KEYLARGO_FCR4
);
1155 reg
&= ~(KL4_PORT_WAKEUP_ENABLE(number
) | KL4_PORT_RESUME_WAKE_EN(number
) |
1156 KL4_PORT_CONNECT_WAKE_EN(number
) | KL4_PORT_DISCONNECT_WAKE_EN(number
));
1157 reg
&= ~(KL4_PORT_WAKEUP_ENABLE(number
+1) | KL4_PORT_RESUME_WAKE_EN(number
+1) |
1158 KL4_PORT_CONNECT_WAKE_EN(number
+1) | KL4_PORT_DISCONNECT_WAKE_EN(number
+1));
1159 MACIO_OUT32(KEYLARGO_FCR4
, reg
);
1160 (void)MACIO_IN32(KEYLARGO_FCR4
);
1163 reg
= MACIO_IN32(KEYLARGO_FCR3
);
1164 reg
&= ~(KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1165 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0));
1166 reg
&= ~(KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1167 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1));
1168 MACIO_OUT32(KEYLARGO_FCR3
, reg
);
1169 (void)MACIO_IN32(KEYLARGO_FCR3
);
1172 if (macio
->type
== macio_intrepid
) {
1173 /* wait for clock stopped bits to clear */
1174 u32 test0
= 0, test1
= 0;
1175 u32 status0
, status1
;
1181 test0
= UNI_N_CLOCK_STOPPED_USB0
;
1182 test1
= UNI_N_CLOCK_STOPPED_USB0PCI
;
1185 test0
= UNI_N_CLOCK_STOPPED_USB1
;
1186 test1
= UNI_N_CLOCK_STOPPED_USB1PCI
;
1189 test0
= UNI_N_CLOCK_STOPPED_USB2
;
1190 test1
= UNI_N_CLOCK_STOPPED_USB2PCI
;
1194 if (--timeout
<= 0) {
1195 printk(KERN_ERR
"core99_usb_enable: "
1196 "Timeout waiting for clocks\n");
1200 status0
= UN_IN(UNI_N_CLOCK_STOP_STATUS0
);
1201 status1
= UN_IN(UNI_N_CLOCK_STOP_STATUS1
);
1202 } while ((status0
& test0
) | (status1
& test1
));
1208 reg
= MACIO_IN32(KEYLARGO_FCR4
);
1209 reg
|= KL4_PORT_WAKEUP_ENABLE(number
) | KL4_PORT_RESUME_WAKE_EN(number
) |
1210 KL4_PORT_CONNECT_WAKE_EN(number
) | KL4_PORT_DISCONNECT_WAKE_EN(number
);
1211 reg
|= KL4_PORT_WAKEUP_ENABLE(number
+1) | KL4_PORT_RESUME_WAKE_EN(number
+1) |
1212 KL4_PORT_CONNECT_WAKE_EN(number
+1) | KL4_PORT_DISCONNECT_WAKE_EN(number
+1);
1213 MACIO_OUT32(KEYLARGO_FCR4
, reg
);
1214 (void)MACIO_IN32(KEYLARGO_FCR4
);
1217 reg
= MACIO_IN32(KEYLARGO_FCR3
);
1218 reg
|= KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1219 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0);
1220 reg
|= KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1221 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1);
1222 MACIO_OUT32(KEYLARGO_FCR3
, reg
);
1223 (void)MACIO_IN32(KEYLARGO_FCR3
);
1227 if (macio
->type
!= macio_intrepid
)
1228 MACIO_BIC(KEYLARGO_FCR0
, KL0_USB0_CELL_ENABLE
);
1229 (void)MACIO_IN32(KEYLARGO_FCR0
);
1231 MACIO_BIS(KEYLARGO_FCR0
, (KL0_USB0_PAD_SUSPEND0
| KL0_USB0_PAD_SUSPEND1
));
1232 (void)MACIO_IN32(KEYLARGO_FCR0
);
1233 } else if (number
== 2) {
1234 if (macio
->type
!= macio_intrepid
)
1235 MACIO_BIC(KEYLARGO_FCR0
, KL0_USB1_CELL_ENABLE
);
1236 (void)MACIO_IN32(KEYLARGO_FCR0
);
1238 MACIO_BIS(KEYLARGO_FCR0
, (KL0_USB1_PAD_SUSPEND0
| KL0_USB1_PAD_SUSPEND1
));
1239 (void)MACIO_IN32(KEYLARGO_FCR0
);
1240 } else if (number
== 4) {
1242 MACIO_BIS(KEYLARGO_FCR1
, (KL1_USB2_PAD_SUSPEND0
| KL1_USB2_PAD_SUSPEND1
));
1243 (void)MACIO_IN32(KEYLARGO_FCR1
);
1253 core99_firewire_enable(struct device_node
*node
, long param
, long value
)
1255 unsigned long flags
;
1256 struct macio_chip
*macio
;
1258 macio
= &macio_chips
[0];
1259 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1260 macio
->type
!= macio_intrepid
)
1262 if (!(macio
->flags
& MACIO_FLAG_FW_SUPPORTED
))
1267 UN_BIS(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_FW
);
1268 (void)UN_IN(UNI_N_CLOCK_CNTL
);
1270 UN_BIC(UNI_N_CLOCK_CNTL
, UNI_N_CLOCK_CNTL_FW
);
1271 (void)UN_IN(UNI_N_CLOCK_CNTL
);
1280 core99_firewire_cable_power(struct device_node
*node
, long param
, long value
)
1282 unsigned long flags
;
1283 struct macio_chip
*macio
;
1285 /* Trick: we allow NULL node */
1286 if ((pmac_mb
.board_flags
& PMAC_MB_HAS_FW_POWER
) == 0)
1288 macio
= &macio_chips
[0];
1289 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1290 macio
->type
!= macio_intrepid
)
1292 if (!(macio
->flags
& MACIO_FLAG_FW_SUPPORTED
))
1297 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER
, 0);
1298 MACIO_IN8(KL_GPIO_FW_CABLE_POWER
);
1301 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER
, 4);
1302 MACIO_IN8(KL_GPIO_FW_CABLE_POWER
); udelay(10);
1311 intrepid_aack_delay_enable(struct device_node
*node
, long param
, long value
)
1313 unsigned long flags
;
1315 if (uninorth_rev
< 0xd2)
1320 UN_BIS(UNI_N_AACK_DELAY
, UNI_N_AACK_DELAY_ENABLE
);
1322 UN_BIC(UNI_N_AACK_DELAY
, UNI_N_AACK_DELAY_ENABLE
);
1329 #endif /* CONFIG_POWER4 */
1332 core99_read_gpio(struct device_node
*node
, long param
, long value
)
1334 struct macio_chip
*macio
= &macio_chips
[0];
1336 return MACIO_IN8(param
);
1341 core99_write_gpio(struct device_node
*node
, long param
, long value
)
1343 struct macio_chip
*macio
= &macio_chips
[0];
1345 MACIO_OUT8(param
, (u8
)(value
& 0xff));
1349 #ifdef CONFIG_POWER4
1350 static long g5_gmac_enable(struct device_node
*node
, long param
, long value
)
1352 struct macio_chip
*macio
= &macio_chips
[0];
1353 unsigned long flags
;
1360 MACIO_BIS(KEYLARGO_FCR1
, K2_FCR1_GMAC_CLK_ENABLE
);
1362 k2_skiplist
[0] = NULL
;
1364 k2_skiplist
[0] = node
;
1366 MACIO_BIC(KEYLARGO_FCR1
, K2_FCR1_GMAC_CLK_ENABLE
);
1375 static long g5_fw_enable(struct device_node
*node
, long param
, long value
)
1377 struct macio_chip
*macio
= &macio_chips
[0];
1378 unsigned long flags
;
1385 MACIO_BIS(KEYLARGO_FCR1
, K2_FCR1_FW_CLK_ENABLE
);
1387 k2_skiplist
[1] = NULL
;
1389 k2_skiplist
[1] = node
;
1391 MACIO_BIC(KEYLARGO_FCR1
, K2_FCR1_FW_CLK_ENABLE
);
1400 static long g5_mpic_enable(struct device_node
*node
, long param
, long value
)
1402 unsigned long flags
;
1403 struct device_node
*parent
= of_get_parent(node
);
1408 is_u3
= strcmp(parent
->name
, "u3") == 0 ||
1409 strcmp(parent
->name
, "u4") == 0;
1410 of_node_put(parent
);
1415 UN_BIS(U3_TOGGLE_REG
, U3_MPIC_RESET
| U3_MPIC_OUTPUT_ENABLE
);
1421 static long g5_eth_phy_reset(struct device_node
*node
, long param
, long value
)
1423 struct macio_chip
*macio
= &macio_chips
[0];
1424 struct device_node
*phy
;
1428 * We must not reset the combo PHYs, only the BCM5221 found in
1431 phy
= of_get_next_child(node
, NULL
);
1434 need_reset
= device_is_compatible(phy
, "B5221");
1439 /* PHY reset is GPIO 29, not in device-tree unfortunately */
1440 MACIO_OUT8(K2_GPIO_EXTINT_0
+ 29,
1441 KEYLARGO_GPIO_OUTPUT_ENABLE
| KEYLARGO_GPIO_OUTOUT_DATA
);
1442 /* Thankfully, this is now always called at a time when we can
1443 * schedule by sungem.
1446 MACIO_OUT8(K2_GPIO_EXTINT_0
+ 29, 0);
1451 static long g5_i2s_enable(struct device_node
*node
, long param
, long value
)
1453 /* Very crude implementation for now */
1454 struct macio_chip
*macio
= &macio_chips
[0];
1455 unsigned long flags
;
1459 K2_FCR1_I2S0_CELL_ENABLE
|
1460 K2_FCR1_I2S0_CLK_ENABLE_BIT
| K2_FCR1_I2S0_ENABLE
,
1461 KL3_I2S0_CLK18_ENABLE
1463 { KL0_SCC_A_INTF_ENABLE
,
1464 K2_FCR1_I2S1_CELL_ENABLE
|
1465 K2_FCR1_I2S1_CLK_ENABLE_BIT
| K2_FCR1_I2S1_ENABLE
,
1466 KL3_I2S1_CLK18_ENABLE
1468 { KL0_SCC_B_INTF_ENABLE
,
1469 SH_FCR1_I2S2_CELL_ENABLE
|
1470 SH_FCR1_I2S2_CLK_ENABLE_BIT
| SH_FCR1_I2S2_ENABLE
,
1471 SH_FCR3_I2S2_CLK18_ENABLE
1475 if (macio
->type
!= macio_keylargo2
&& macio
->type
!= macio_shasta
)
1477 if (strncmp(node
->name
, "i2s-", 4))
1479 cell
= node
->name
[4] - 'a';
1485 if (macio
->type
== macio_shasta
)
1493 MACIO_BIC(KEYLARGO_FCR0
, fcrs
[cell
][0]);
1494 MACIO_BIS(KEYLARGO_FCR1
, fcrs
[cell
][1]);
1495 MACIO_BIS(KEYLARGO_FCR3
, fcrs
[cell
][2]);
1497 MACIO_BIC(KEYLARGO_FCR3
, fcrs
[cell
][2]);
1498 MACIO_BIC(KEYLARGO_FCR1
, fcrs
[cell
][1]);
1499 MACIO_BIS(KEYLARGO_FCR0
, fcrs
[cell
][0]);
1509 static long g5_reset_cpu(struct device_node
*node
, long param
, long value
)
1511 unsigned int reset_io
= 0;
1512 unsigned long flags
;
1513 struct macio_chip
*macio
;
1514 struct device_node
*np
;
1516 macio
= &macio_chips
[0];
1517 if (macio
->type
!= macio_keylargo2
&& macio
->type
!= macio_shasta
)
1520 np
= find_path_device("/cpus");
1523 for (np
= np
->child
; np
!= NULL
; np
= np
->sibling
) {
1524 u32
*num
= (u32
*)get_property(np
, "reg", NULL
);
1525 u32
*rst
= (u32
*)get_property(np
, "soft-reset", NULL
);
1526 if (num
== NULL
|| rst
== NULL
)
1528 if (param
== *num
) {
1533 if (np
== NULL
|| reset_io
== 0)
1537 MACIO_OUT8(reset_io
, KEYLARGO_GPIO_OUTPUT_ENABLE
);
1538 (void)MACIO_IN8(reset_io
);
1540 MACIO_OUT8(reset_io
, 0);
1541 (void)MACIO_IN8(reset_io
);
1546 #endif /* CONFIG_SMP */
1549 * This can be called from pmac_smp so isn't static
1551 * This takes the second CPU off the bus on dual CPU machines
1554 void g5_phy_disable_cpu1(void)
1556 if (uninorth_maj
== 3)
1557 UN_OUT(U3_API_PHY_CONFIG_1
, 0);
1559 #endif /* CONFIG_POWER4 */
1561 #ifndef CONFIG_POWER4
1564 keylargo_shutdown(struct macio_chip
*macio
, int sleep_mode
)
1570 MACIO_BIS(KEYLARGO_FCR0
, KL0_USB_REF_SUSPEND
);
1571 (void)MACIO_IN32(KEYLARGO_FCR0
);
1575 MACIO_BIC(KEYLARGO_FCR0
,KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
|
1576 KL0_SCC_CELL_ENABLE
|
1577 KL0_IRDA_ENABLE
| KL0_IRDA_CLK32_ENABLE
|
1578 KL0_IRDA_CLK19_ENABLE
);
1580 MACIO_BIC(KEYLARGO_MBCR
, KL_MBCR_MB0_DEV_MASK
);
1581 MACIO_BIS(KEYLARGO_MBCR
, KL_MBCR_MB0_IDE_ENABLE
);
1583 MACIO_BIC(KEYLARGO_FCR1
,
1584 KL1_AUDIO_SEL_22MCLK
| KL1_AUDIO_CLK_ENABLE_BIT
|
1585 KL1_AUDIO_CLK_OUT_ENABLE
| KL1_AUDIO_CELL_ENABLE
|
1586 KL1_I2S0_CELL_ENABLE
| KL1_I2S0_CLK_ENABLE_BIT
|
1587 KL1_I2S0_ENABLE
| KL1_I2S1_CELL_ENABLE
|
1588 KL1_I2S1_CLK_ENABLE_BIT
| KL1_I2S1_ENABLE
|
1589 KL1_EIDE0_ENABLE
| KL1_EIDE0_RESET_N
|
1590 KL1_EIDE1_ENABLE
| KL1_EIDE1_RESET_N
|
1593 MACIO_BIS(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
1594 MACIO_BIC(KEYLARGO_FCR2
, KL2_IOBUS_ENABLE
);
1596 temp
= MACIO_IN32(KEYLARGO_FCR3
);
1597 if (macio
->rev
>= 2) {
1598 temp
|= KL3_SHUTDOWN_PLL2X
;
1600 temp
|= KL3_SHUTDOWN_PLL_TOTAL
;
1603 temp
|= KL3_SHUTDOWN_PLLKW6
| KL3_SHUTDOWN_PLLKW4
|
1604 KL3_SHUTDOWN_PLLKW35
;
1606 temp
|= KL3_SHUTDOWN_PLLKW12
;
1607 temp
&= ~(KL3_CLK66_ENABLE
| KL3_CLK49_ENABLE
| KL3_CLK45_ENABLE
1608 | KL3_CLK31_ENABLE
| KL3_I2S1_CLK18_ENABLE
| KL3_I2S0_CLK18_ENABLE
);
1610 temp
&= ~(KL3_TIMER_CLK18_ENABLE
| KL3_VIA_CLK16_ENABLE
);
1611 MACIO_OUT32(KEYLARGO_FCR3
, temp
);
1613 /* Flush posted writes & wait a bit */
1614 (void)MACIO_IN32(KEYLARGO_FCR0
); mdelay(1);
1618 pangea_shutdown(struct macio_chip
*macio
, int sleep_mode
)
1622 MACIO_BIC(KEYLARGO_FCR0
,KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
|
1623 KL0_SCC_CELL_ENABLE
|
1624 KL0_USB0_CELL_ENABLE
| KL0_USB1_CELL_ENABLE
);
1626 MACIO_BIC(KEYLARGO_FCR1
,
1627 KL1_AUDIO_SEL_22MCLK
| KL1_AUDIO_CLK_ENABLE_BIT
|
1628 KL1_AUDIO_CLK_OUT_ENABLE
| KL1_AUDIO_CELL_ENABLE
|
1629 KL1_I2S0_CELL_ENABLE
| KL1_I2S0_CLK_ENABLE_BIT
|
1630 KL1_I2S0_ENABLE
| KL1_I2S1_CELL_ENABLE
|
1631 KL1_I2S1_CLK_ENABLE_BIT
| KL1_I2S1_ENABLE
|
1633 if (pmac_mb
.board_flags
& PMAC_MB_MOBILE
)
1634 MACIO_BIC(KEYLARGO_FCR1
, KL1_UIDE_RESET_N
);
1636 MACIO_BIS(KEYLARGO_FCR2
, KL2_ALT_DATA_OUT
);
1638 temp
= MACIO_IN32(KEYLARGO_FCR3
);
1639 temp
|= KL3_SHUTDOWN_PLLKW6
| KL3_SHUTDOWN_PLLKW4
|
1640 KL3_SHUTDOWN_PLLKW35
;
1641 temp
&= ~(KL3_CLK49_ENABLE
| KL3_CLK45_ENABLE
| KL3_CLK31_ENABLE
1642 | KL3_I2S0_CLK18_ENABLE
| KL3_I2S1_CLK18_ENABLE
);
1644 temp
&= ~(KL3_VIA_CLK16_ENABLE
| KL3_TIMER_CLK18_ENABLE
);
1645 MACIO_OUT32(KEYLARGO_FCR3
, temp
);
1647 /* Flush posted writes & wait a bit */
1648 (void)MACIO_IN32(KEYLARGO_FCR0
); mdelay(1);
1652 intrepid_shutdown(struct macio_chip
*macio
, int sleep_mode
)
1656 MACIO_BIC(KEYLARGO_FCR0
,KL0_SCCA_ENABLE
| KL0_SCCB_ENABLE
|
1657 KL0_SCC_CELL_ENABLE
);
1659 MACIO_BIC(KEYLARGO_FCR1
,
1660 /*KL1_USB2_CELL_ENABLE |*/
1661 KL1_I2S0_CELL_ENABLE
| KL1_I2S0_CLK_ENABLE_BIT
|
1662 KL1_I2S0_ENABLE
| KL1_I2S1_CELL_ENABLE
|
1663 KL1_I2S1_CLK_ENABLE_BIT
| KL1_I2S1_ENABLE
);
1664 if (pmac_mb
.board_flags
& PMAC_MB_MOBILE
)
1665 MACIO_BIC(KEYLARGO_FCR1
, KL1_UIDE_RESET_N
);
1667 temp
= MACIO_IN32(KEYLARGO_FCR3
);
1668 temp
&= ~(KL3_CLK49_ENABLE
| KL3_CLK45_ENABLE
|
1669 KL3_I2S1_CLK18_ENABLE
| KL3_I2S0_CLK18_ENABLE
);
1671 temp
&= ~(KL3_TIMER_CLK18_ENABLE
| KL3_IT_VIA_CLK32_ENABLE
);
1672 MACIO_OUT32(KEYLARGO_FCR3
, temp
);
1674 /* Flush posted writes & wait a bit */
1675 (void)MACIO_IN32(KEYLARGO_FCR0
);
1680 void pmac_tweak_clock_spreading(int enable
)
1682 struct macio_chip
*macio
= &macio_chips
[0];
1684 /* Hack for doing clock spreading on some machines PowerBooks and
1685 * iBooks. This implements the "platform-do-clockspreading" OF
1686 * property as decoded manually on various models. For safety, we also
1687 * check the product ID in the device-tree in cases we'll whack the i2c
1688 * chip to make reasonably sure we won't set wrong values in there
1690 * Of course, ultimately, we have to implement a real parser for
1691 * the platform-do-* stuff...
1694 if (macio
->type
== macio_intrepid
) {
1695 struct device_node
*clock
=
1696 of_find_node_by_path("/uni-n@f8000000/hw-clock");
1697 if (clock
&& get_property(clock
, "platform-do-clockspreading",
1699 printk(KERN_INFO
"%sabling clock spreading on Intrepid"
1700 " ASIC\n", enable
? "En" : "Dis");
1702 UN_OUT(UNI_N_CLOCK_SPREADING
, 2);
1704 UN_OUT(UNI_N_CLOCK_SPREADING
, 0);
1710 while (machine_is_compatible("PowerBook5,2") ||
1711 machine_is_compatible("PowerBook5,3") ||
1712 machine_is_compatible("PowerBook6,2") ||
1713 machine_is_compatible("PowerBook6,3")) {
1714 struct device_node
*ui2c
= of_find_node_by_type(NULL
, "i2c");
1715 struct device_node
*dt
= of_find_node_by_name(NULL
, "device-tree");
1718 int i
, rc
, changed
= 0;
1722 productID
= (u32
*)get_property(dt
, "pid#", NULL
);
1723 if (productID
== NULL
)
1726 struct device_node
*p
= of_get_parent(ui2c
);
1727 if (p
&& !strcmp(p
->name
, "uni-n"))
1729 ui2c
= of_find_node_by_type(ui2c
, "i2c");
1733 DBG("Trying to bump clock speed for PID: %08x...\n", *productID
);
1734 rc
= pmac_low_i2c_open(ui2c
, 1);
1737 pmac_low_i2c_setmode(ui2c
, pmac_low_i2c_mode_combined
);
1738 rc
= pmac_low_i2c_xfer(ui2c
, 0xd2 | pmac_low_i2c_read
, 0x80, buffer
, 9);
1739 DBG("read result: %d,", rc
);
1741 pmac_low_i2c_close(ui2c
);
1745 DBG(" %02x", buffer
[i
]);
1748 switch(*productID
) {
1749 case 0x1182: /* AlBook 12" rev 2 */
1750 case 0x1183: /* iBook G4 12" */
1751 buffer
[0] = (buffer
[0] & 0x8f) | 0x70;
1752 buffer
[2] = (buffer
[2] & 0x7f) | 0x00;
1753 buffer
[5] = (buffer
[5] & 0x80) | 0x31;
1754 buffer
[6] = (buffer
[6] & 0x40) | 0xb0;
1755 buffer
[7] = (buffer
[7] & 0x00) | (enable
? 0xc0 : 0xba);
1756 buffer
[8] = (buffer
[8] & 0x00) | 0x30;
1759 case 0x3142: /* AlBook 15" (ATI M10) */
1760 case 0x3143: /* AlBook 17" (ATI M10) */
1761 buffer
[0] = (buffer
[0] & 0xaf) | 0x50;
1762 buffer
[2] = (buffer
[2] & 0x7f) | 0x00;
1763 buffer
[5] = (buffer
[5] & 0x80) | 0x31;
1764 buffer
[6] = (buffer
[6] & 0x40) | 0xb0;
1765 buffer
[7] = (buffer
[7] & 0x00) | (enable
? 0xd0 : 0xc0);
1766 buffer
[8] = (buffer
[8] & 0x00) | 0x30;
1770 DBG("i2c-hwclock: Machine model not handled\n");
1774 pmac_low_i2c_close(ui2c
);
1777 printk(KERN_INFO
"%sabling clock spreading on i2c clock chip\n",
1778 enable
? "En" : "Dis");
1780 pmac_low_i2c_setmode(ui2c
, pmac_low_i2c_mode_stdsub
);
1781 rc
= pmac_low_i2c_xfer(ui2c
, 0xd2 | pmac_low_i2c_write
, 0x80, buffer
, 9);
1782 DBG("write result: %d,", rc
);
1783 pmac_low_i2c_setmode(ui2c
, pmac_low_i2c_mode_combined
);
1784 rc
= pmac_low_i2c_xfer(ui2c
, 0xd2 | pmac_low_i2c_read
, 0x80, buffer
, 9);
1785 DBG("read result: %d,", rc
);
1787 pmac_low_i2c_close(ui2c
);
1791 DBG(" %02x", buffer
[i
]);
1792 pmac_low_i2c_close(ui2c
);
1801 struct macio_chip
*macio
;
1804 macio
= &macio_chips
[0];
1805 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1806 macio
->type
!= macio_intrepid
)
1809 /* We power off the wireless slot in case it was not done
1810 * by the driver. We don't power it on automatically however
1812 if (macio
->flags
& MACIO_FLAG_AIRPORT_ON
)
1813 core99_airport_enable(macio
->of_node
, 0, 0);
1815 /* We power off the FW cable. Should be done by the driver... */
1816 if (macio
->flags
& MACIO_FLAG_FW_SUPPORTED
) {
1817 core99_firewire_enable(NULL
, 0, 0);
1818 core99_firewire_cable_power(NULL
, 0, 0);
1821 /* We make sure int. modem is off (in case driver lost it) */
1822 if (macio
->type
== macio_keylargo
)
1823 core99_modem_enable(macio
->of_node
, 0, 0);
1825 pangea_modem_enable(macio
->of_node
, 0, 0);
1827 /* We make sure the sound is off as well */
1828 core99_sound_chip_enable(macio
->of_node
, 0, 0);
1831 * Save various bits of KeyLargo
1834 /* Save the state of the various GPIOs */
1835 save_gpio_levels
[0] = MACIO_IN32(KEYLARGO_GPIO_LEVELS0
);
1836 save_gpio_levels
[1] = MACIO_IN32(KEYLARGO_GPIO_LEVELS1
);
1837 for (i
=0; i
<KEYLARGO_GPIO_EXTINT_CNT
; i
++)
1838 save_gpio_extint
[i
] = MACIO_IN8(KEYLARGO_GPIO_EXTINT_0
+i
);
1839 for (i
=0; i
<KEYLARGO_GPIO_CNT
; i
++)
1840 save_gpio_normal
[i
] = MACIO_IN8(KEYLARGO_GPIO_0
+i
);
1843 if (macio
->type
== macio_keylargo
)
1844 save_mbcr
= MACIO_IN32(KEYLARGO_MBCR
);
1845 save_fcr
[0] = MACIO_IN32(KEYLARGO_FCR0
);
1846 save_fcr
[1] = MACIO_IN32(KEYLARGO_FCR1
);
1847 save_fcr
[2] = MACIO_IN32(KEYLARGO_FCR2
);
1848 save_fcr
[3] = MACIO_IN32(KEYLARGO_FCR3
);
1849 save_fcr
[4] = MACIO_IN32(KEYLARGO_FCR4
);
1850 if (macio
->type
== macio_pangea
|| macio
->type
== macio_intrepid
)
1851 save_fcr
[5] = MACIO_IN32(KEYLARGO_FCR5
);
1853 /* Save state & config of DBDMA channels */
1854 dbdma_save(macio
, save_dbdma
);
1857 * Turn off as much as we can
1859 if (macio
->type
== macio_pangea
)
1860 pangea_shutdown(macio
, 1);
1861 else if (macio
->type
== macio_intrepid
)
1862 intrepid_shutdown(macio
, 1);
1863 else if (macio
->type
== macio_keylargo
)
1864 keylargo_shutdown(macio
, 1);
1867 * Put the host bridge to sleep
1870 save_unin_clock_ctl
= UN_IN(UNI_N_CLOCK_CNTL
);
1871 /* Note: do not switch GMAC off, driver does it when necessary, WOL must keep it
1874 UN_OUT(UNI_N_CLOCK_CNTL
, save_unin_clock_ctl
&
1875 ~(/*UNI_N_CLOCK_CNTL_GMAC|*/UNI_N_CLOCK_CNTL_FW
/*|UNI_N_CLOCK_CNTL_PCI*/));
1877 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_SLEEPING
);
1878 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_SLEEP
);
1882 * FIXME: A bit of black magic with OpenPIC (don't ask me why)
1884 if (pmac_mb
.model_id
== PMAC_TYPE_SAWTOOTH
) {
1885 MACIO_BIS(0x506e0, 0x00400000);
1886 MACIO_BIS(0x506e0, 0x80000000);
1892 core99_wake_up(void)
1894 struct macio_chip
*macio
;
1897 macio
= &macio_chips
[0];
1898 if (macio
->type
!= macio_keylargo
&& macio
->type
!= macio_pangea
&&
1899 macio
->type
!= macio_intrepid
)
1903 * Wakeup the host bridge
1905 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_NORMAL
);
1907 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_RUNNING
);
1914 if (macio
->type
== macio_keylargo
) {
1915 MACIO_OUT32(KEYLARGO_MBCR
, save_mbcr
);
1916 (void)MACIO_IN32(KEYLARGO_MBCR
); udelay(10);
1918 MACIO_OUT32(KEYLARGO_FCR0
, save_fcr
[0]);
1919 (void)MACIO_IN32(KEYLARGO_FCR0
); udelay(10);
1920 MACIO_OUT32(KEYLARGO_FCR1
, save_fcr
[1]);
1921 (void)MACIO_IN32(KEYLARGO_FCR1
); udelay(10);
1922 MACIO_OUT32(KEYLARGO_FCR2
, save_fcr
[2]);
1923 (void)MACIO_IN32(KEYLARGO_FCR2
); udelay(10);
1924 MACIO_OUT32(KEYLARGO_FCR3
, save_fcr
[3]);
1925 (void)MACIO_IN32(KEYLARGO_FCR3
); udelay(10);
1926 MACIO_OUT32(KEYLARGO_FCR4
, save_fcr
[4]);
1927 (void)MACIO_IN32(KEYLARGO_FCR4
); udelay(10);
1928 if (macio
->type
== macio_pangea
|| macio
->type
== macio_intrepid
) {
1929 MACIO_OUT32(KEYLARGO_FCR5
, save_fcr
[5]);
1930 (void)MACIO_IN32(KEYLARGO_FCR5
); udelay(10);
1933 dbdma_restore(macio
, save_dbdma
);
1935 MACIO_OUT32(KEYLARGO_GPIO_LEVELS0
, save_gpio_levels
[0]);
1936 MACIO_OUT32(KEYLARGO_GPIO_LEVELS1
, save_gpio_levels
[1]);
1937 for (i
=0; i
<KEYLARGO_GPIO_EXTINT_CNT
; i
++)
1938 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0
+i
, save_gpio_extint
[i
]);
1939 for (i
=0; i
<KEYLARGO_GPIO_CNT
; i
++)
1940 MACIO_OUT8(KEYLARGO_GPIO_0
+i
, save_gpio_normal
[i
]);
1942 /* FIXME more black magic with OpenPIC ... */
1943 if (pmac_mb
.model_id
== PMAC_TYPE_SAWTOOTH
) {
1944 MACIO_BIC(0x506e0, 0x00400000);
1945 MACIO_BIC(0x506e0, 0x80000000);
1948 UN_OUT(UNI_N_CLOCK_CNTL
, save_unin_clock_ctl
);
1955 core99_sleep_state(struct device_node
*node
, long param
, long value
)
1957 /* Param == 1 means to enter the "fake sleep" mode that is
1958 * used for CPU speed switch
1962 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_SLEEPING
);
1963 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_IDLE2
);
1965 UN_OUT(UNI_N_POWER_MGT
, UNI_N_POWER_MGT_NORMAL
);
1967 UN_OUT(UNI_N_HWINIT_STATE
, UNI_N_HWINIT_STATE_RUNNING
);
1972 if ((pmac_mb
.board_flags
& PMAC_MB_CAN_SLEEP
) == 0)
1976 return core99_sleep();
1977 else if (value
== 0)
1978 return core99_wake_up();
1982 #endif /* CONFIG_POWER4 */
1985 generic_dev_can_wake(struct device_node
*node
, long param
, long value
)
1987 /* Todo: eventually check we are really dealing with on-board
1991 if (pmac_mb
.board_flags
& PMAC_MB_MAY_SLEEP
)
1992 pmac_mb
.board_flags
|= PMAC_MB_CAN_SLEEP
;
1996 static long generic_get_mb_info(struct device_node
*node
, long param
, long value
)
1999 case PMAC_MB_INFO_MODEL
:
2000 return pmac_mb
.model_id
;
2001 case PMAC_MB_INFO_FLAGS
:
2002 return pmac_mb
.board_flags
;
2003 case PMAC_MB_INFO_NAME
:
2004 /* hack hack hack... but should work */
2005 *((const char **)value
) = pmac_mb
.model_name
;
2016 /* Used on any machine
2018 static struct feature_table_entry any_features
[] = {
2019 { PMAC_FTR_GET_MB_INFO
, generic_get_mb_info
},
2020 { PMAC_FTR_DEVICE_CAN_WAKE
, generic_dev_can_wake
},
2024 #ifndef CONFIG_POWER4
2026 /* OHare based motherboards. Currently, we only use these on the
2027 * 2400,3400 and 3500 series powerbooks. Some older desktops seem
2028 * to have issues with turning on/off those asic cells
2030 static struct feature_table_entry ohare_features
[] = {
2031 { PMAC_FTR_SCC_ENABLE
, ohare_htw_scc_enable
},
2032 { PMAC_FTR_SWIM3_ENABLE
, ohare_floppy_enable
},
2033 { PMAC_FTR_MESH_ENABLE
, ohare_mesh_enable
},
2034 { PMAC_FTR_IDE_ENABLE
, ohare_ide_enable
},
2035 { PMAC_FTR_IDE_RESET
, ohare_ide_reset
},
2036 { PMAC_FTR_SLEEP_STATE
, ohare_sleep_state
},
2040 /* Heathrow desktop machines (Beige G3).
2041 * Separated as some features couldn't be properly tested
2042 * and the serial port control bits appear to confuse it.
2044 static struct feature_table_entry heathrow_desktop_features
[] = {
2045 { PMAC_FTR_SWIM3_ENABLE
, heathrow_floppy_enable
},
2046 { PMAC_FTR_MESH_ENABLE
, heathrow_mesh_enable
},
2047 { PMAC_FTR_IDE_ENABLE
, heathrow_ide_enable
},
2048 { PMAC_FTR_IDE_RESET
, heathrow_ide_reset
},
2049 { PMAC_FTR_BMAC_ENABLE
, heathrow_bmac_enable
},
2053 /* Heathrow based laptop, that is the Wallstreet and mainstreet
2056 static struct feature_table_entry heathrow_laptop_features
[] = {
2057 { PMAC_FTR_SCC_ENABLE
, ohare_htw_scc_enable
},
2058 { PMAC_FTR_MODEM_ENABLE
, heathrow_modem_enable
},
2059 { PMAC_FTR_SWIM3_ENABLE
, heathrow_floppy_enable
},
2060 { PMAC_FTR_MESH_ENABLE
, heathrow_mesh_enable
},
2061 { PMAC_FTR_IDE_ENABLE
, heathrow_ide_enable
},
2062 { PMAC_FTR_IDE_RESET
, heathrow_ide_reset
},
2063 { PMAC_FTR_BMAC_ENABLE
, heathrow_bmac_enable
},
2064 { PMAC_FTR_SOUND_CHIP_ENABLE
, heathrow_sound_enable
},
2065 { PMAC_FTR_SLEEP_STATE
, heathrow_sleep_state
},
2069 /* Paddington based machines
2070 * The lombard (101) powerbook, first iMac models, B&W G3 and Yikes G4.
2072 static struct feature_table_entry paddington_features
[] = {
2073 { PMAC_FTR_SCC_ENABLE
, ohare_htw_scc_enable
},
2074 { PMAC_FTR_MODEM_ENABLE
, heathrow_modem_enable
},
2075 { PMAC_FTR_SWIM3_ENABLE
, heathrow_floppy_enable
},
2076 { PMAC_FTR_MESH_ENABLE
, heathrow_mesh_enable
},
2077 { PMAC_FTR_IDE_ENABLE
, heathrow_ide_enable
},
2078 { PMAC_FTR_IDE_RESET
, heathrow_ide_reset
},
2079 { PMAC_FTR_BMAC_ENABLE
, heathrow_bmac_enable
},
2080 { PMAC_FTR_SOUND_CHIP_ENABLE
, heathrow_sound_enable
},
2081 { PMAC_FTR_SLEEP_STATE
, heathrow_sleep_state
},
2085 /* Core99 & MacRISC 2 machines (all machines released since the
2086 * iBook (included), that is all AGP machines, except pangea
2087 * chipset. The pangea chipset is the "combo" UniNorth/KeyLargo
2088 * used on iBook2 & iMac "flow power".
2090 static struct feature_table_entry core99_features
[] = {
2091 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2092 { PMAC_FTR_MODEM_ENABLE
, core99_modem_enable
},
2093 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2094 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2095 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2096 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2097 { PMAC_FTR_SOUND_CHIP_ENABLE
, core99_sound_chip_enable
},
2098 { PMAC_FTR_AIRPORT_ENABLE
, core99_airport_enable
},
2099 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2100 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2101 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2102 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2104 { PMAC_FTR_RESET_CPU
, core99_reset_cpu
},
2105 #endif /* CONFIG_SMP */
2106 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2107 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2113 static struct feature_table_entry rackmac_features
[] = {
2114 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2115 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2116 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2117 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2118 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2119 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2120 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2121 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2122 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2124 { PMAC_FTR_RESET_CPU
, core99_reset_cpu
},
2125 #endif /* CONFIG_SMP */
2126 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2127 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2133 static struct feature_table_entry pangea_features
[] = {
2134 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2135 { PMAC_FTR_MODEM_ENABLE
, pangea_modem_enable
},
2136 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2137 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2138 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2139 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2140 { PMAC_FTR_SOUND_CHIP_ENABLE
, core99_sound_chip_enable
},
2141 { PMAC_FTR_AIRPORT_ENABLE
, core99_airport_enable
},
2142 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2143 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2144 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2145 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2146 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2147 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2151 /* Intrepid features
2153 static struct feature_table_entry intrepid_features
[] = {
2154 { PMAC_FTR_SCC_ENABLE
, core99_scc_enable
},
2155 { PMAC_FTR_MODEM_ENABLE
, pangea_modem_enable
},
2156 { PMAC_FTR_IDE_ENABLE
, core99_ide_enable
},
2157 { PMAC_FTR_IDE_RESET
, core99_ide_reset
},
2158 { PMAC_FTR_GMAC_ENABLE
, core99_gmac_enable
},
2159 { PMAC_FTR_GMAC_PHY_RESET
, core99_gmac_phy_reset
},
2160 { PMAC_FTR_SOUND_CHIP_ENABLE
, core99_sound_chip_enable
},
2161 { PMAC_FTR_AIRPORT_ENABLE
, core99_airport_enable
},
2162 { PMAC_FTR_USB_ENABLE
, core99_usb_enable
},
2163 { PMAC_FTR_1394_ENABLE
, core99_firewire_enable
},
2164 { PMAC_FTR_1394_CABLE_POWER
, core99_firewire_cable_power
},
2165 { PMAC_FTR_SLEEP_STATE
, core99_sleep_state
},
2166 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2167 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2168 { PMAC_FTR_AACK_DELAY_ENABLE
, intrepid_aack_delay_enable
},
2172 #else /* CONFIG_POWER4 */
2176 static struct feature_table_entry g5_features
[] = {
2177 { PMAC_FTR_GMAC_ENABLE
, g5_gmac_enable
},
2178 { PMAC_FTR_1394_ENABLE
, g5_fw_enable
},
2179 { PMAC_FTR_ENABLE_MPIC
, g5_mpic_enable
},
2180 { PMAC_FTR_GMAC_PHY_RESET
, g5_eth_phy_reset
},
2181 { PMAC_FTR_SOUND_CHIP_ENABLE
, g5_i2s_enable
},
2183 { PMAC_FTR_RESET_CPU
, g5_reset_cpu
},
2184 #endif /* CONFIG_SMP */
2185 { PMAC_FTR_READ_GPIO
, core99_read_gpio
},
2186 { PMAC_FTR_WRITE_GPIO
, core99_write_gpio
},
2190 #endif /* CONFIG_POWER4 */
2192 static struct pmac_mb_def pmac_mb_defs
[] = {
2193 #ifndef CONFIG_POWER4
2198 { "AAPL,8500", "PowerMac 8500/8600",
2199 PMAC_TYPE_PSURGE
, NULL
,
2202 { "AAPL,9500", "PowerMac 9500/9600",
2203 PMAC_TYPE_PSURGE
, NULL
,
2206 { "AAPL,7200", "PowerMac 7200",
2207 PMAC_TYPE_PSURGE
, NULL
,
2210 { "AAPL,7300", "PowerMac 7200/7300",
2211 PMAC_TYPE_PSURGE
, NULL
,
2214 { "AAPL,7500", "PowerMac 7500",
2215 PMAC_TYPE_PSURGE
, NULL
,
2218 { "AAPL,ShinerESB", "Apple Network Server",
2219 PMAC_TYPE_ANS
, NULL
,
2222 { "AAPL,e407", "Alchemy",
2223 PMAC_TYPE_ALCHEMY
, NULL
,
2226 { "AAPL,e411", "Gazelle",
2227 PMAC_TYPE_GAZELLE
, NULL
,
2230 { "AAPL,Gossamer", "PowerMac G3 (Gossamer)",
2231 PMAC_TYPE_GOSSAMER
, heathrow_desktop_features
,
2234 { "AAPL,PowerMac G3", "PowerMac G3 (Silk)",
2235 PMAC_TYPE_SILK
, heathrow_desktop_features
,
2238 { "PowerMac1,1", "Blue&White G3",
2239 PMAC_TYPE_YOSEMITE
, paddington_features
,
2242 { "PowerMac1,2", "PowerMac G4 PCI Graphics",
2243 PMAC_TYPE_YIKES
, paddington_features
,
2246 { "PowerMac2,1", "iMac FireWire",
2247 PMAC_TYPE_FW_IMAC
, core99_features
,
2248 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2250 { "PowerMac2,2", "iMac FireWire",
2251 PMAC_TYPE_FW_IMAC
, core99_features
,
2252 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2254 { "PowerMac3,1", "PowerMac G4 AGP Graphics",
2255 PMAC_TYPE_SAWTOOTH
, core99_features
,
2258 { "PowerMac3,2", "PowerMac G4 AGP Graphics",
2259 PMAC_TYPE_SAWTOOTH
, core99_features
,
2260 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2262 { "PowerMac3,3", "PowerMac G4 AGP Graphics",
2263 PMAC_TYPE_SAWTOOTH
, core99_features
,
2264 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2266 { "PowerMac3,4", "PowerMac G4 Silver",
2267 PMAC_TYPE_QUICKSILVER
, core99_features
,
2270 { "PowerMac3,5", "PowerMac G4 Silver",
2271 PMAC_TYPE_QUICKSILVER
, core99_features
,
2274 { "PowerMac3,6", "PowerMac G4 Windtunnel",
2275 PMAC_TYPE_WINDTUNNEL
, core99_features
,
2278 { "PowerMac4,1", "iMac \"Flower Power\"",
2279 PMAC_TYPE_PANGEA_IMAC
, pangea_features
,
2282 { "PowerMac4,2", "Flat panel iMac",
2283 PMAC_TYPE_FLAT_PANEL_IMAC
, pangea_features
,
2286 { "PowerMac4,4", "eMac",
2287 PMAC_TYPE_EMAC
, core99_features
,
2290 { "PowerMac5,1", "PowerMac G4 Cube",
2291 PMAC_TYPE_CUBE
, core99_features
,
2292 PMAC_MB_MAY_SLEEP
| PMAC_MB_OLD_CORE99
2294 { "PowerMac6,1", "Flat panel iMac",
2295 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2298 { "PowerMac6,3", "Flat panel iMac",
2299 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2302 { "PowerMac6,4", "eMac",
2303 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2306 { "PowerMac10,1", "Mac mini",
2307 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2308 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
,
2310 { "iMac,1", "iMac (first generation)",
2311 PMAC_TYPE_ORIG_IMAC
, paddington_features
,
2319 { "RackMac1,1", "XServe",
2320 PMAC_TYPE_RACKMAC
, rackmac_features
,
2323 { "RackMac1,2", "XServe rev. 2",
2324 PMAC_TYPE_RACKMAC
, rackmac_features
,
2332 { "AAPL,3400/2400", "PowerBook 3400",
2333 PMAC_TYPE_HOOPER
, ohare_features
,
2334 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2336 { "AAPL,3500", "PowerBook 3500",
2337 PMAC_TYPE_KANGA
, ohare_features
,
2338 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2340 { "AAPL,PowerBook1998", "PowerBook Wallstreet",
2341 PMAC_TYPE_WALLSTREET
, heathrow_laptop_features
,
2342 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2344 { "PowerBook1,1", "PowerBook 101 (Lombard)",
2345 PMAC_TYPE_101_PBOOK
, paddington_features
,
2346 PMAC_MB_CAN_SLEEP
| PMAC_MB_MOBILE
2348 { "PowerBook2,1", "iBook (first generation)",
2349 PMAC_TYPE_ORIG_IBOOK
, core99_features
,
2350 PMAC_MB_CAN_SLEEP
| PMAC_MB_OLD_CORE99
| PMAC_MB_MOBILE
2352 { "PowerBook2,2", "iBook FireWire",
2353 PMAC_TYPE_FW_IBOOK
, core99_features
,
2354 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
|
2355 PMAC_MB_OLD_CORE99
| PMAC_MB_MOBILE
2357 { "PowerBook3,1", "PowerBook Pismo",
2358 PMAC_TYPE_PISMO
, core99_features
,
2359 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
|
2360 PMAC_MB_OLD_CORE99
| PMAC_MB_MOBILE
2362 { "PowerBook3,2", "PowerBook Titanium",
2363 PMAC_TYPE_TITANIUM
, core99_features
,
2364 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2366 { "PowerBook3,3", "PowerBook Titanium II",
2367 PMAC_TYPE_TITANIUM2
, core99_features
,
2368 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2370 { "PowerBook3,4", "PowerBook Titanium III",
2371 PMAC_TYPE_TITANIUM3
, core99_features
,
2372 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2374 { "PowerBook3,5", "PowerBook Titanium IV",
2375 PMAC_TYPE_TITANIUM4
, core99_features
,
2376 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2378 { "PowerBook4,1", "iBook 2",
2379 PMAC_TYPE_IBOOK2
, pangea_features
,
2380 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2382 { "PowerBook4,2", "iBook 2",
2383 PMAC_TYPE_IBOOK2
, pangea_features
,
2384 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2386 { "PowerBook4,3", "iBook 2 rev. 2",
2387 PMAC_TYPE_IBOOK2
, pangea_features
,
2388 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
2390 { "PowerBook5,1", "PowerBook G4 17\"",
2391 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2392 PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2394 { "PowerBook5,2", "PowerBook G4 15\"",
2395 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2396 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2398 { "PowerBook5,3", "PowerBook G4 17\"",
2399 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2400 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2402 { "PowerBook5,4", "PowerBook G4 15\"",
2403 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2404 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2406 { "PowerBook5,5", "PowerBook G4 17\"",
2407 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2408 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2410 { "PowerBook5,6", "PowerBook G4 15\"",
2411 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2412 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2414 { "PowerBook5,7", "PowerBook G4 17\"",
2415 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2416 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2418 { "PowerBook5,8", "PowerBook G4 15\"",
2419 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2420 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2422 { "PowerBook5,9", "PowerBook G4 17\"",
2423 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2424 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2426 { "PowerBook6,1", "PowerBook G4 12\"",
2427 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2428 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2430 { "PowerBook6,2", "PowerBook G4",
2431 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2432 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2434 { "PowerBook6,3", "iBook G4",
2435 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2436 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2438 { "PowerBook6,4", "PowerBook G4 12\"",
2439 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2440 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2442 { "PowerBook6,5", "iBook G4",
2443 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2444 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2446 { "PowerBook6,7", "iBook G4",
2447 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2448 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2450 { "PowerBook6,8", "PowerBook G4 12\"",
2451 PMAC_TYPE_UNKNOWN_INTREPID
, intrepid_features
,
2452 PMAC_MB_MAY_SLEEP
| PMAC_MB_HAS_FW_POWER
| PMAC_MB_MOBILE
,
2454 #else /* CONFIG_POWER4 */
2455 { "PowerMac7,2", "PowerMac G5",
2456 PMAC_TYPE_POWERMAC_G5
, g5_features
,
2460 { "PowerMac7,3", "PowerMac G5",
2461 PMAC_TYPE_POWERMAC_G5
, g5_features
,
2464 { "PowerMac8,1", "iMac G5",
2465 PMAC_TYPE_IMAC_G5
, g5_features
,
2468 { "PowerMac9,1", "PowerMac G5",
2469 PMAC_TYPE_POWERMAC_G5_U3L
, g5_features
,
2472 { "PowerMac11,2", "PowerMac G5 Dual Core",
2473 PMAC_TYPE_POWERMAC_G5_U3L
, g5_features
,
2476 { "PowerMac12,1", "iMac G5 (iSight)",
2477 PMAC_TYPE_POWERMAC_G5_U3L
, g5_features
,
2480 { "RackMac3,1", "XServe G5",
2481 PMAC_TYPE_XSERVE_G5
, g5_features
,
2484 #endif /* CONFIG_PPC64 */
2485 #endif /* CONFIG_POWER4 */
2489 * The toplevel feature_call callback
2491 long pmac_do_feature_call(unsigned int selector
, ...)
2493 struct device_node
*node
;
2496 feature_call func
= NULL
;
2499 if (pmac_mb
.features
)
2500 for (i
=0; pmac_mb
.features
[i
].function
; i
++)
2501 if (pmac_mb
.features
[i
].selector
== selector
) {
2502 func
= pmac_mb
.features
[i
].function
;
2506 for (i
=0; any_features
[i
].function
; i
++)
2507 if (any_features
[i
].selector
== selector
) {
2508 func
= any_features
[i
].function
;
2514 va_start(args
, selector
);
2515 node
= (struct device_node
*)va_arg(args
, void*);
2516 param
= va_arg(args
, long);
2517 value
= va_arg(args
, long);
2520 return func(node
, param
, value
);
2523 static int __init
probe_motherboard(void)
2526 struct macio_chip
*macio
= &macio_chips
[0];
2527 const char *model
= NULL
;
2528 struct device_node
*dt
;
2530 /* Lookup known motherboard type in device-tree. First try an
2531 * exact match on the "model" property, then try a "compatible"
2532 * match is none is found.
2534 dt
= find_devices("device-tree");
2536 model
= (const char *) get_property(dt
, "model", NULL
);
2537 for(i
=0; model
&& i
<(sizeof(pmac_mb_defs
)/sizeof(struct pmac_mb_def
)); i
++) {
2538 if (strcmp(model
, pmac_mb_defs
[i
].model_string
) == 0) {
2539 pmac_mb
= pmac_mb_defs
[i
];
2543 for(i
=0; i
<(sizeof(pmac_mb_defs
)/sizeof(struct pmac_mb_def
)); i
++) {
2544 if (machine_is_compatible(pmac_mb_defs
[i
].model_string
)) {
2545 pmac_mb
= pmac_mb_defs
[i
];
2550 /* Fallback to selection depending on mac-io chip type */
2551 switch(macio
->type
) {
2552 #ifndef CONFIG_POWER4
2553 case macio_grand_central
:
2554 pmac_mb
.model_id
= PMAC_TYPE_PSURGE
;
2555 pmac_mb
.model_name
= "Unknown PowerSurge";
2558 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_OHARE
;
2559 pmac_mb
.model_name
= "Unknown OHare-based";
2561 case macio_heathrow
:
2562 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_HEATHROW
;
2563 pmac_mb
.model_name
= "Unknown Heathrow-based";
2564 pmac_mb
.features
= heathrow_desktop_features
;
2566 case macio_paddington
:
2567 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_PADDINGTON
;
2568 pmac_mb
.model_name
= "Unknown Paddington-based";
2569 pmac_mb
.features
= paddington_features
;
2571 case macio_keylargo
:
2572 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_CORE99
;
2573 pmac_mb
.model_name
= "Unknown Keylargo-based";
2574 pmac_mb
.features
= core99_features
;
2577 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_PANGEA
;
2578 pmac_mb
.model_name
= "Unknown Pangea-based";
2579 pmac_mb
.features
= pangea_features
;
2581 case macio_intrepid
:
2582 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_INTREPID
;
2583 pmac_mb
.model_name
= "Unknown Intrepid-based";
2584 pmac_mb
.features
= intrepid_features
;
2586 #else /* CONFIG_POWER4 */
2587 case macio_keylargo2
:
2588 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_K2
;
2589 pmac_mb
.model_name
= "Unknown K2-based";
2590 pmac_mb
.features
= g5_features
;
2593 pmac_mb
.model_id
= PMAC_TYPE_UNKNOWN_SHASTA
;
2594 pmac_mb
.model_name
= "Unknown Shasta-based";
2595 pmac_mb
.features
= g5_features
;
2597 #endif /* CONFIG_POWER4 */
2602 #ifndef CONFIG_POWER4
2603 /* Fixup Hooper vs. Comet */
2604 if (pmac_mb
.model_id
== PMAC_TYPE_HOOPER
) {
2605 u32 __iomem
* mach_id_ptr
= ioremap(0xf3000034, 4);
2608 /* Here, I used to disable the media-bay on comet. It
2609 * appears this is wrong, the floppy connector is actually
2610 * a kind of media-bay and works with the current driver.
2612 if (__raw_readl(mach_id_ptr
) & 0x20000000UL
)
2613 pmac_mb
.model_id
= PMAC_TYPE_COMET
;
2614 iounmap(mach_id_ptr
);
2616 #endif /* CONFIG_POWER4 */
2619 /* Set default value of powersave_nap on machines that support it.
2620 * It appears that uninorth rev 3 has a problem with it, we don't
2621 * enable it on those. In theory, the flush-on-lock property is
2622 * supposed to be set when not supported, but I'm not very confident
2623 * that all Apple OF revs did it properly, I do it the paranoid way.
2625 while (uninorth_base
&& uninorth_rev
> 3) {
2626 struct device_node
*np
= find_path_device("/cpus");
2627 if (!np
|| !np
->child
) {
2628 printk(KERN_WARNING
"Can't find CPU(s) in device tree !\n");
2632 /* Nap mode not supported on SMP */
2635 /* Nap mode not supported if flush-on-lock property is present */
2636 if (get_property(np
, "flush-on-lock", NULL
))
2639 printk(KERN_INFO
"Processor NAP mode on idle enabled.\n");
2643 /* On CPUs that support it (750FX), lowspeed by default during
2646 powersave_lowspeed
= 1;
2647 #endif /* CONFIG_6xx */
2648 #ifdef CONFIG_POWER4
2651 /* Check for "mobile" machine */
2652 if (model
&& (strncmp(model
, "PowerBook", 9) == 0
2653 || strncmp(model
, "iBook", 5) == 0))
2654 pmac_mb
.board_flags
|= PMAC_MB_MOBILE
;
2657 printk(KERN_INFO
"PowerMac motherboard: %s\n", pmac_mb
.model_name
);
2661 /* Initialize the Core99 UniNorth host bridge and memory controller
2663 static void __init
probe_uninorth(void)
2666 phys_addr_t address
;
2667 unsigned long actrl
;
2669 /* Locate core99 Uni-N */
2670 uninorth_node
= of_find_node_by_name(NULL
, "uni-n");
2672 if (uninorth_node
== NULL
) {
2673 uninorth_node
= of_find_node_by_name(NULL
, "u3");
2677 if (uninorth_node
== NULL
) {
2678 uninorth_node
= of_find_node_by_name(NULL
, "u4");
2681 if (uninorth_node
== NULL
)
2684 addrp
= (u32
*)get_property(uninorth_node
, "reg", NULL
);
2687 address
= of_translate_address(uninorth_node
, addrp
);
2690 uninorth_base
= ioremap(address
, 0x40000);
2691 uninorth_rev
= in_be32(UN_REG(UNI_N_VERSION
));
2692 if (uninorth_maj
== 3 || uninorth_maj
== 4)
2693 u3_ht
= ioremap(address
+ U3_HT_CONFIG_BASE
, 0x1000);
2695 printk(KERN_INFO
"Found %s memory controller & host bridge"
2696 " @ 0x%08x revision: 0x%02x\n", uninorth_maj
== 3 ? "U3" :
2697 uninorth_maj
== 4 ? "U4" : "UniNorth",
2698 (unsigned int)address
, uninorth_rev
);
2699 printk(KERN_INFO
"Mapped at 0x%08lx\n", (unsigned long)uninorth_base
);
2701 /* Set the arbitrer QAck delay according to what Apple does
2703 if (uninorth_rev
< 0x11) {
2704 actrl
= UN_IN(UNI_N_ARB_CTRL
) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK
;
2705 actrl
|= ((uninorth_rev
< 3) ? UNI_N_ARB_CTRL_QACK_DELAY105
:
2706 UNI_N_ARB_CTRL_QACK_DELAY
) <<
2707 UNI_N_ARB_CTRL_QACK_DELAY_SHIFT
;
2708 UN_OUT(UNI_N_ARB_CTRL
, actrl
);
2711 /* Some more magic as done by them in recent MacOS X on UniNorth
2712 * revs 1.5 to 2.O and Pangea. Seem to toggle the UniN Maxbus/PCI
2715 if ((uninorth_rev
>= 0x11 && uninorth_rev
<= 0x24) ||
2716 uninorth_rev
== 0xc0)
2717 UN_OUT(0x2160, UN_IN(0x2160) & 0x00ffffff);
2720 static void __init
probe_one_macio(const char *name
, const char *compat
, int type
)
2722 struct device_node
* node
;
2724 volatile u32 __iomem
*base
;
2729 for (node
= NULL
; (node
= of_find_node_by_name(node
, name
)) != NULL
;) {
2732 if (device_is_compatible(node
, compat
))
2737 for(i
=0; i
<MAX_MACIO_CHIPS
; i
++) {
2738 if (!macio_chips
[i
].of_node
)
2740 if (macio_chips
[i
].of_node
== node
)
2744 if (i
>= MAX_MACIO_CHIPS
) {
2745 printk(KERN_ERR
"pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
2746 printk(KERN_ERR
"pmac_feature: %s skipped\n", node
->full_name
);
2749 addrp
= of_get_pci_address(node
, 0, &size
, NULL
);
2750 if (addrp
== NULL
) {
2751 printk(KERN_ERR
"pmac_feature: %s: can't find base !\n",
2755 addr
= of_translate_address(node
, addrp
);
2757 printk(KERN_ERR
"pmac_feature: %s, can't translate base !\n",
2761 base
= ioremap(addr
, (unsigned long)size
);
2763 printk(KERN_ERR
"pmac_feature: %s, can't map mac-io chip !\n",
2767 if (type
== macio_keylargo
|| type
== macio_keylargo2
) {
2768 u32
*did
= (u32
*)get_property(node
, "device-id", NULL
);
2769 if (*did
== 0x00000025)
2770 type
= macio_pangea
;
2771 if (*did
== 0x0000003e)
2772 type
= macio_intrepid
;
2773 if (*did
== 0x0000004f)
2774 type
= macio_shasta
;
2776 macio_chips
[i
].of_node
= node
;
2777 macio_chips
[i
].type
= type
;
2778 macio_chips
[i
].base
= base
;
2779 macio_chips
[i
].flags
= MACIO_FLAG_SCCB_ON
| MACIO_FLAG_SCCB_ON
;
2780 macio_chips
[i
].name
= macio_names
[type
];
2781 revp
= (u32
*)get_property(node
, "revision-id", NULL
);
2783 macio_chips
[i
].rev
= *revp
;
2784 printk(KERN_INFO
"Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
2785 macio_names
[type
], macio_chips
[i
].rev
, macio_chips
[i
].base
);
2791 /* Warning, ordering is important */
2792 probe_one_macio("gc", NULL
, macio_grand_central
);
2793 probe_one_macio("ohare", NULL
, macio_ohare
);
2794 probe_one_macio("pci106b,7", NULL
, macio_ohareII
);
2795 probe_one_macio("mac-io", "keylargo", macio_keylargo
);
2796 probe_one_macio("mac-io", "paddington", macio_paddington
);
2797 probe_one_macio("mac-io", "gatwick", macio_gatwick
);
2798 probe_one_macio("mac-io", "heathrow", macio_heathrow
);
2799 probe_one_macio("mac-io", "K2-Keylargo", macio_keylargo2
);
2801 /* Make sure the "main" macio chip appear first */
2802 if (macio_chips
[0].type
== macio_gatwick
2803 && macio_chips
[1].type
== macio_heathrow
) {
2804 struct macio_chip temp
= macio_chips
[0];
2805 macio_chips
[0] = macio_chips
[1];
2806 macio_chips
[1] = temp
;
2808 if (macio_chips
[0].type
== macio_ohareII
2809 && macio_chips
[1].type
== macio_ohare
) {
2810 struct macio_chip temp
= macio_chips
[0];
2811 macio_chips
[0] = macio_chips
[1];
2812 macio_chips
[1] = temp
;
2814 macio_chips
[0].lbus
.index
= 0;
2815 macio_chips
[1].lbus
.index
= 1;
2817 return (macio_chips
[0].of_node
== NULL
) ? -ENODEV
: 0;
2821 initial_serial_shutdown(struct device_node
*np
)
2824 struct slot_names_prop
{
2829 int port_type
= PMAC_SCC_ASYNC
;
2832 slots
= (struct slot_names_prop
*)get_property(np
, "slot-names", &len
);
2833 conn
= get_property(np
, "AAPL,connector", &len
);
2834 if (conn
&& (strcmp(conn
, "infrared") == 0))
2835 port_type
= PMAC_SCC_IRDA
;
2836 else if (device_is_compatible(np
, "cobalt"))
2838 else if (slots
&& slots
->count
> 0) {
2839 if (strcmp(slots
->name
, "IrDA") == 0)
2840 port_type
= PMAC_SCC_IRDA
;
2841 else if (strcmp(slots
->name
, "Modem") == 0)
2845 pmac_call_feature(PMAC_FTR_MODEM_ENABLE
, np
, 0, 0);
2846 pmac_call_feature(PMAC_FTR_SCC_ENABLE
, np
, port_type
, 0);
2850 set_initial_features(void)
2852 struct device_node
*np
;
2854 /* That hack appears to be necessary for some StarMax motherboards
2855 * but I'm not too sure it was audited for side-effects on other
2856 * ohare based machines...
2857 * Since I still have difficulties figuring the right way to
2858 * differenciate them all and since that hack was there for a long
2859 * time, I'll keep it around
2861 if (macio_chips
[0].type
== macio_ohare
&& !find_devices("via-pmu")) {
2862 struct macio_chip
*macio
= &macio_chips
[0];
2863 MACIO_OUT32(OHARE_FCR
, STARMAX_FEATURES
);
2864 } else if (macio_chips
[0].type
== macio_ohare
) {
2865 struct macio_chip
*macio
= &macio_chips
[0];
2866 MACIO_BIS(OHARE_FCR
, OH_IOBUS_ENABLE
);
2867 } else if (macio_chips
[1].type
== macio_ohare
) {
2868 struct macio_chip
*macio
= &macio_chips
[1];
2869 MACIO_BIS(OHARE_FCR
, OH_IOBUS_ENABLE
);
2872 #ifdef CONFIG_POWER4
2873 if (macio_chips
[0].type
== macio_keylargo2
||
2874 macio_chips
[0].type
== macio_shasta
) {
2876 /* On SMP machines running UP, we have the second CPU eating
2877 * bus cycles. We need to take it off the bus. This is done
2878 * from pmac_smp for SMP kernels running on one CPU
2880 np
= of_find_node_by_type(NULL
, "cpu");
2882 np
= of_find_node_by_type(np
, "cpu");
2884 g5_phy_disable_cpu1();
2887 #endif /* CONFIG_SMP */
2888 /* Enable GMAC for now for PCI probing. It will be disabled
2889 * later on after PCI probe
2891 np
= of_find_node_by_name(NULL
, "ethernet");
2893 if (device_is_compatible(np
, "K2-GMAC"))
2894 g5_gmac_enable(np
, 0, 1);
2895 np
= of_find_node_by_name(np
, "ethernet");
2898 /* Enable FW before PCI probe. Will be disabled later on
2899 * Note: We should have a batter way to check that we are
2900 * dealing with uninorth internal cell and not a PCI cell
2901 * on the external PCI. The code below works though.
2903 np
= of_find_node_by_name(NULL
, "firewire");
2905 if (device_is_compatible(np
, "pci106b,5811")) {
2906 macio_chips
[0].flags
|= MACIO_FLAG_FW_SUPPORTED
;
2907 g5_fw_enable(np
, 0, 1);
2909 np
= of_find_node_by_name(np
, "firewire");
2912 #else /* CONFIG_POWER4 */
2914 if (macio_chips
[0].type
== macio_keylargo
||
2915 macio_chips
[0].type
== macio_pangea
||
2916 macio_chips
[0].type
== macio_intrepid
) {
2917 /* Enable GMAC for now for PCI probing. It will be disabled
2918 * later on after PCI probe
2920 np
= of_find_node_by_name(NULL
, "ethernet");
2923 && device_is_compatible(np
->parent
, "uni-north")
2924 && device_is_compatible(np
, "gmac"))
2925 core99_gmac_enable(np
, 0, 1);
2926 np
= of_find_node_by_name(np
, "ethernet");
2929 /* Enable FW before PCI probe. Will be disabled later on
2930 * Note: We should have a batter way to check that we are
2931 * dealing with uninorth internal cell and not a PCI cell
2932 * on the external PCI. The code below works though.
2934 np
= of_find_node_by_name(NULL
, "firewire");
2937 && device_is_compatible(np
->parent
, "uni-north")
2938 && (device_is_compatible(np
, "pci106b,18") ||
2939 device_is_compatible(np
, "pci106b,30") ||
2940 device_is_compatible(np
, "pci11c1,5811"))) {
2941 macio_chips
[0].flags
|= MACIO_FLAG_FW_SUPPORTED
;
2942 core99_firewire_enable(np
, 0, 1);
2944 np
= of_find_node_by_name(np
, "firewire");
2947 /* Enable ATA-100 before PCI probe. */
2948 np
= of_find_node_by_name(NULL
, "ata-6");
2951 && device_is_compatible(np
->parent
, "uni-north")
2952 && device_is_compatible(np
, "kauai-ata")) {
2953 core99_ata100_enable(np
, 1);
2955 np
= of_find_node_by_name(np
, "ata-6");
2958 /* Switch airport off */
2959 np
= find_devices("radio");
2961 if (np
&& np
->parent
== macio_chips
[0].of_node
) {
2962 macio_chips
[0].flags
|= MACIO_FLAG_AIRPORT_ON
;
2963 core99_airport_enable(np
, 0, 0);
2969 /* On all machines that support sound PM, switch sound off */
2970 if (macio_chips
[0].of_node
)
2971 pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE
,
2972 macio_chips
[0].of_node
, 0, 0);
2974 /* While on some desktop G3s, we turn it back on */
2975 if (macio_chips
[0].of_node
&& macio_chips
[0].type
== macio_heathrow
2976 && (pmac_mb
.model_id
== PMAC_TYPE_GOSSAMER
||
2977 pmac_mb
.model_id
== PMAC_TYPE_SILK
)) {
2978 struct macio_chip
*macio
= &macio_chips
[0];
2979 MACIO_BIS(HEATHROW_FCR
, HRW_SOUND_CLK_ENABLE
);
2980 MACIO_BIC(HEATHROW_FCR
, HRW_SOUND_POWER_N
);
2983 /* Some machine models need the clock chip to be properly setup for
2984 * clock spreading now. This should be a platform function but we
2985 * don't do these at the moment
2987 pmac_tweak_clock_spreading(1);
2989 #endif /* CONFIG_POWER4 */
2991 /* On all machines, switch modem & serial ports off */
2992 np
= find_devices("ch-a");
2994 initial_serial_shutdown(np
);
2997 np
= find_devices("ch-b");
2999 initial_serial_shutdown(np
);
3005 pmac_feature_init(void)
3007 /* Detect the UniNorth memory controller */
3010 /* Probe mac-io controllers */
3011 if (probe_macios()) {
3012 printk(KERN_WARNING
"No mac-io chip found\n");
3016 /* Setup low-level i2c stuffs */
3017 pmac_init_low_i2c();
3019 /* Probe machine type */
3020 if (probe_motherboard())
3021 printk(KERN_WARNING
"Unknown PowerMac !\n");
3023 /* Set some initial features (turn off some chips that will
3024 * be later turned on)
3026 set_initial_features();
3030 static void dump_HT_speeds(char *name
, u32 cfg
, u32 frq
)
3032 int freqs
[16] = { 200,300,400,500,600,800,1000,0,0,0,0,0,0,0,0,0 };
3033 int bits
[8] = { 8,16,0,32,2,4,0,0 };
3034 int freq
= (frq
>> 8) & 0xf;
3036 if (freqs
[freq
] == 0)
3037 printk("%s: Unknown HT link frequency %x\n", name
, freq
);
3039 printk("%s: %d MHz on main link, (%d in / %d out) bits width\n",
3041 bits
[(cfg
>> 28) & 0x7], bits
[(cfg
>> 24) & 0x7]);
3044 void __init
pmac_check_ht_link(void)
3046 u32 ufreq
, freq
, ucfg
, cfg
;
3047 struct device_node
*pcix_node
;
3048 u8 px_bus
, px_devfn
;
3049 struct pci_controller
*px_hose
;
3051 (void)in_be32(u3_ht
+ U3_HT_LINK_COMMAND
);
3052 ucfg
= cfg
= in_be32(u3_ht
+ U3_HT_LINK_CONFIG
);
3053 ufreq
= freq
= in_be32(u3_ht
+ U3_HT_LINK_FREQ
);
3054 dump_HT_speeds("U3 HyperTransport", cfg
, freq
);
3056 pcix_node
= of_find_compatible_node(NULL
, "pci", "pci-x");
3057 if (pcix_node
== NULL
) {
3058 printk("No PCI-X bridge found\n");
3061 if (pci_device_from_OF_node(pcix_node
, &px_bus
, &px_devfn
) != 0) {
3062 printk("PCI-X bridge found but not matched to pci\n");
3065 px_hose
= pci_find_hose_for_OF_device(pcix_node
);
3066 if (px_hose
== NULL
) {
3067 printk("PCI-X bridge found but not matched to host\n");
3070 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xc4, &cfg
);
3071 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xcc, &freq
);
3072 dump_HT_speeds("PCI-X HT Uplink", cfg
, freq
);
3073 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xc8, &cfg
);
3074 early_read_config_dword(px_hose
, px_bus
, px_devfn
, 0xd0, &freq
);
3075 dump_HT_speeds("PCI-X HT Downlink", cfg
, freq
);
3080 * Early video resume hook
3083 static void (*pmac_early_vresume_proc
)(void *data
);
3084 static void *pmac_early_vresume_data
;
3086 void pmac_set_early_video_resume(void (*proc
)(void *data
), void *data
)
3088 if (_machine
!= _MACH_Pmac
)
3091 pmac_early_vresume_proc
= proc
;
3092 pmac_early_vresume_data
= data
;
3095 EXPORT_SYMBOL(pmac_set_early_video_resume
);
3097 void pmac_call_early_video_resume(void)
3099 if (pmac_early_vresume_proc
)
3100 pmac_early_vresume_proc(pmac_early_vresume_data
);
3104 * AGP related suspend/resume code
3107 static struct pci_dev
*pmac_agp_bridge
;
3108 static int (*pmac_agp_suspend
)(struct pci_dev
*bridge
);
3109 static int (*pmac_agp_resume
)(struct pci_dev
*bridge
);
3111 void pmac_register_agp_pm(struct pci_dev
*bridge
,
3112 int (*suspend
)(struct pci_dev
*bridge
),
3113 int (*resume
)(struct pci_dev
*bridge
))
3115 if (suspend
|| resume
) {
3116 pmac_agp_bridge
= bridge
;
3117 pmac_agp_suspend
= suspend
;
3118 pmac_agp_resume
= resume
;
3121 if (bridge
!= pmac_agp_bridge
)
3123 pmac_agp_suspend
= pmac_agp_resume
= NULL
;
3126 EXPORT_SYMBOL(pmac_register_agp_pm
);
3128 void pmac_suspend_agp_for_card(struct pci_dev
*dev
)
3130 if (pmac_agp_bridge
== NULL
|| pmac_agp_suspend
== NULL
)
3132 if (pmac_agp_bridge
->bus
!= dev
->bus
)
3134 pmac_agp_suspend(pmac_agp_bridge
);
3136 EXPORT_SYMBOL(pmac_suspend_agp_for_card
);
3138 void pmac_resume_agp_for_card(struct pci_dev
*dev
)
3140 if (pmac_agp_bridge
== NULL
|| pmac_agp_resume
== NULL
)
3142 if (pmac_agp_bridge
->bus
!= dev
->bus
)
3144 pmac_agp_resume(pmac_agp_bridge
);
3146 EXPORT_SYMBOL(pmac_resume_agp_for_card
);