1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
4 * Ben. Herrenschmidt (benh@kernel.crashing.org)
8 * - Replace mdelay with some schedule loop if possible
9 * - Shorten some obfuscated delays on some routines (like modem
11 * - Refcount some clocks (see darwin)
12 * - Split split split...
14 #include <linux/types.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
20 #include <linux/of_address.h>
21 #include <linux/spinlock.h>
22 #include <linux/adb.h>
23 #include <linux/pmu.h>
24 #include <linux/ioport.h>
25 #include <linux/export.h>
26 #include <linux/pci.h>
27 #include <asm/sections.h>
28 #include <asm/errno.h>
29 #include <asm/ohare.h>
30 #include <asm/heathrow.h>
31 #include <asm/keylargo.h>
32 #include <asm/uninorth.h>
35 #include <asm/machdep.h>
36 #include <asm/pmac_feature.h>
37 #include <asm/dbdma.h>
38 #include <asm/pci-bridge.h>
39 #include <asm/pmac_low_i2c.h>
44 #define DBG(fmt...) printk(KERN_DEBUG fmt)
49 #ifdef CONFIG_PPC_BOOK3S_32
50 extern int powersave_lowspeed;
53 extern int powersave_nap;
54 extern struct device_node *k2_skiplist[2];
57 * We use a single global lock to protect accesses. Each driver has
58 * to take care of its own locking
60 DEFINE_RAW_SPINLOCK(feature_lock);
62 #define LOCK(flags) raw_spin_lock_irqsave(&feature_lock, flags);
63 #define UNLOCK(flags) raw_spin_unlock_irqrestore(&feature_lock, flags);
67 * Instance of some macio stuffs
69 struct macio_chip macio_chips[MAX_MACIO_CHIPS];
71 struct macio_chip *macio_find(struct device_node *child, int type)
76 for (i=0; i < MAX_MACIO_CHIPS && macio_chips[i].of_node; i++)
77 if (child == macio_chips[i].of_node &&
78 (!type || macio_chips[i].type == type))
79 return &macio_chips[i];
80 child = child->parent;
84 EXPORT_SYMBOL_GPL(macio_find);
86 static const char *macio_names[] =
103 struct device_node *uninorth_node;
104 u32 __iomem *uninorth_base;
106 static u32 uninorth_rev;
107 static int uninorth_maj;
108 static void __iomem *u3_ht_base;
111 * For each motherboard family, we have a table of functions pointers
112 * that handle the various features.
115 typedef long (*feature_call)(struct device_node *node, long param, long value);
117 struct feature_table_entry {
118 unsigned int selector;
119 feature_call function;
124 const char* model_string;
125 const char* model_name;
127 struct feature_table_entry* features;
128 unsigned long board_flags;
130 static struct pmac_mb_def pmac_mb;
133 * Here are the chip specific feature functions
136 static inline int simple_feature_tweak(struct device_node *node, int type,
137 int reg, u32 mask, int value)
139 struct macio_chip* macio;
142 macio = macio_find(node, type);
147 MACIO_BIS(reg, mask);
149 MACIO_BIC(reg, mask);
150 (void)MACIO_IN32(reg);
158 static long ohare_htw_scc_enable(struct device_node *node, long param,
161 struct macio_chip* macio;
162 unsigned long chan_mask;
168 macio = macio_find(node, 0);
171 if (of_node_name_eq(node, "ch-a"))
172 chan_mask = MACIO_FLAG_SCCA_ON;
173 else if (of_node_name_eq(node, "ch-b"))
174 chan_mask = MACIO_FLAG_SCCB_ON;
178 htw = (macio->type == macio_heathrow || macio->type == macio_paddington
179 || macio->type == macio_gatwick);
180 /* On these machines, the HRW_SCC_TRANS_EN_N bit mustn't be touched */
181 trans = (pmac_mb.model_id != PMAC_TYPE_YOSEMITE &&
182 pmac_mb.model_id != PMAC_TYPE_YIKES);
184 #ifdef CONFIG_ADB_PMU
185 if ((param & 0xfff) == PMAC_SCC_IRDA)
187 #endif /* CONFIG_ADB_PMU */
189 fcr = MACIO_IN32(OHARE_FCR);
190 /* Check if scc cell need enabling */
191 if (!(fcr & OH_SCC_ENABLE)) {
192 fcr |= OH_SCC_ENABLE;
194 /* Side effect: this will also power up the
195 * modem, but it's too messy to figure out on which
196 * ports this controls the transceiver and on which
197 * it controls the modem
200 fcr &= ~HRW_SCC_TRANS_EN_N;
201 MACIO_OUT32(OHARE_FCR, fcr);
202 fcr |= (rmask = HRW_RESET_SCC);
203 MACIO_OUT32(OHARE_FCR, fcr);
205 fcr |= (rmask = OH_SCC_RESET);
206 MACIO_OUT32(OHARE_FCR, fcr);
209 (void)MACIO_IN32(OHARE_FCR);
213 MACIO_OUT32(OHARE_FCR, fcr);
215 if (chan_mask & MACIO_FLAG_SCCA_ON)
217 if (chan_mask & MACIO_FLAG_SCCB_ON)
219 MACIO_OUT32(OHARE_FCR, fcr);
220 macio->flags |= chan_mask;
222 if (param & PMAC_SCC_FLAG_XMON)
223 macio->flags |= MACIO_FLAG_SCC_LOCKED;
225 if (macio->flags & MACIO_FLAG_SCC_LOCKED)
228 fcr = MACIO_IN32(OHARE_FCR);
229 if (chan_mask & MACIO_FLAG_SCCA_ON)
231 if (chan_mask & MACIO_FLAG_SCCB_ON)
233 MACIO_OUT32(OHARE_FCR, fcr);
234 if ((fcr & (OH_SCCA_IO | OH_SCCB_IO)) == 0) {
235 fcr &= ~OH_SCC_ENABLE;
237 fcr |= HRW_SCC_TRANS_EN_N;
238 MACIO_OUT32(OHARE_FCR, fcr);
240 macio->flags &= ~(chan_mask);
243 #ifdef CONFIG_ADB_PMU
244 if ((param & 0xfff) == PMAC_SCC_IRDA)
246 #endif /* CONFIG_ADB_PMU */
251 static long ohare_floppy_enable(struct device_node *node, long param,
254 return simple_feature_tweak(node, macio_ohare,
255 OHARE_FCR, OH_FLOPPY_ENABLE, value);
258 static long ohare_mesh_enable(struct device_node *node, long param, long value)
260 return simple_feature_tweak(node, macio_ohare,
261 OHARE_FCR, OH_MESH_ENABLE, value);
264 static long ohare_ide_enable(struct device_node *node, long param, long value)
268 /* For some reason, setting the bit in set_initial_features()
269 * doesn't stick. I'm still investigating... --BenH.
272 simple_feature_tweak(node, macio_ohare,
273 OHARE_FCR, OH_IOBUS_ENABLE, 1);
274 return simple_feature_tweak(node, macio_ohare,
275 OHARE_FCR, OH_IDE0_ENABLE, value);
277 return simple_feature_tweak(node, macio_ohare,
278 OHARE_FCR, OH_BAY_IDE_ENABLE, value);
284 static long ohare_ide_reset(struct device_node *node, long param, long value)
288 return simple_feature_tweak(node, macio_ohare,
289 OHARE_FCR, OH_IDE0_RESET_N, !value);
291 return simple_feature_tweak(node, macio_ohare,
292 OHARE_FCR, OH_IDE1_RESET_N, !value);
298 static long ohare_sleep_state(struct device_node *node, long param, long value)
300 struct macio_chip* macio = &macio_chips[0];
302 if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
305 MACIO_BIC(OHARE_FCR, OH_IOBUS_ENABLE);
306 } else if (value == 0) {
307 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
313 static long heathrow_modem_enable(struct device_node *node, long param,
316 struct macio_chip* macio;
320 macio = macio_find(node, macio_unknown);
323 gpio = MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1;
326 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio);
328 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
331 if (pmac_mb.model_id != PMAC_TYPE_YOSEMITE &&
332 pmac_mb.model_id != PMAC_TYPE_YIKES) {
335 MACIO_BIC(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
337 MACIO_BIS(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
339 (void)MACIO_IN32(HEATHROW_FCR);
344 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1);
345 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
346 UNLOCK(flags); mdelay(250); LOCK(flags);
347 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio);
348 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
349 UNLOCK(flags); mdelay(250); LOCK(flags);
350 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1);
351 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
352 UNLOCK(flags); mdelay(250);
357 static long heathrow_floppy_enable(struct device_node *node, long param,
360 return simple_feature_tweak(node, macio_unknown,
362 HRW_SWIM_ENABLE|HRW_BAY_FLOPPY_ENABLE,
366 static long heathrow_mesh_enable(struct device_node *node, long param,
369 struct macio_chip* macio;
372 macio = macio_find(node, macio_unknown);
376 /* Set clear mesh cell enable */
378 MACIO_BIS(HEATHROW_FCR, HRW_MESH_ENABLE);
380 MACIO_BIC(HEATHROW_FCR, HRW_MESH_ENABLE);
381 (void)MACIO_IN32(HEATHROW_FCR);
383 /* Set/Clear termination power */
385 MACIO_BIC(HEATHROW_MBCR, 0x04000000);
387 MACIO_BIS(HEATHROW_MBCR, 0x04000000);
388 (void)MACIO_IN32(HEATHROW_MBCR);
395 static long heathrow_ide_enable(struct device_node *node, long param,
400 return simple_feature_tweak(node, macio_unknown,
401 HEATHROW_FCR, HRW_IDE0_ENABLE, value);
403 return simple_feature_tweak(node, macio_unknown,
404 HEATHROW_FCR, HRW_BAY_IDE_ENABLE, value);
410 static long heathrow_ide_reset(struct device_node *node, long param,
415 return simple_feature_tweak(node, macio_unknown,
416 HEATHROW_FCR, HRW_IDE0_RESET_N, !value);
418 return simple_feature_tweak(node, macio_unknown,
419 HEATHROW_FCR, HRW_IDE1_RESET_N, !value);
425 static long heathrow_bmac_enable(struct device_node *node, long param,
428 struct macio_chip* macio;
431 macio = macio_find(node, 0);
436 MACIO_BIS(HEATHROW_FCR, HRW_BMAC_IO_ENABLE);
437 MACIO_BIS(HEATHROW_FCR, HRW_BMAC_RESET);
439 (void)MACIO_IN32(HEATHROW_FCR);
442 MACIO_BIC(HEATHROW_FCR, HRW_BMAC_RESET);
444 (void)MACIO_IN32(HEATHROW_FCR);
448 MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE);
454 static long heathrow_sound_enable(struct device_node *node, long param,
457 struct macio_chip* macio;
460 /* B&W G3 and Yikes don't support that properly (the
461 * sound appear to never come back after being shut down).
463 if (pmac_mb.model_id == PMAC_TYPE_YOSEMITE ||
464 pmac_mb.model_id == PMAC_TYPE_YIKES)
467 macio = macio_find(node, 0);
472 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
473 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
475 (void)MACIO_IN32(HEATHROW_FCR);
478 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N);
479 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
485 static u32 save_fcr[6];
486 static u32 save_mbcr;
487 static struct dbdma_regs save_dbdma[13];
488 static struct dbdma_regs save_alt_dbdma[13];
490 static void dbdma_save(struct macio_chip *macio, struct dbdma_regs *save)
494 /* Save state & config of DBDMA channels */
495 for (i = 0; i < 13; i++) {
496 volatile struct dbdma_regs __iomem * chan = (void __iomem *)
497 (macio->base + ((0x8000+i*0x100)>>2));
498 save[i].cmdptr_hi = in_le32(&chan->cmdptr_hi);
499 save[i].cmdptr = in_le32(&chan->cmdptr);
500 save[i].intr_sel = in_le32(&chan->intr_sel);
501 save[i].br_sel = in_le32(&chan->br_sel);
502 save[i].wait_sel = in_le32(&chan->wait_sel);
506 static void dbdma_restore(struct macio_chip *macio, struct dbdma_regs *save)
510 /* Save state & config of DBDMA channels */
511 for (i = 0; i < 13; i++) {
512 volatile struct dbdma_regs __iomem * chan = (void __iomem *)
513 (macio->base + ((0x8000+i*0x100)>>2));
514 out_le32(&chan->control, (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);
515 while (in_le32(&chan->status) & ACTIVE)
517 out_le32(&chan->cmdptr_hi, save[i].cmdptr_hi);
518 out_le32(&chan->cmdptr, save[i].cmdptr);
519 out_le32(&chan->intr_sel, save[i].intr_sel);
520 out_le32(&chan->br_sel, save[i].br_sel);
521 out_le32(&chan->wait_sel, save[i].wait_sel);
525 static void heathrow_sleep(struct macio_chip *macio, int secondary)
528 dbdma_save(macio, save_alt_dbdma);
529 save_fcr[2] = MACIO_IN32(0x38);
530 save_fcr[3] = MACIO_IN32(0x3c);
532 dbdma_save(macio, save_dbdma);
533 save_fcr[0] = MACIO_IN32(0x38);
534 save_fcr[1] = MACIO_IN32(0x3c);
535 save_mbcr = MACIO_IN32(0x34);
536 /* Make sure sound is shut down */
537 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N);
538 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
539 /* This seems to be necessary as well or the fan
540 * keeps coming up and battery drains fast */
541 MACIO_BIC(HEATHROW_FCR, HRW_IOBUS_ENABLE);
542 MACIO_BIC(HEATHROW_FCR, HRW_IDE0_RESET_N);
543 /* Make sure eth is down even if module or sleep
544 * won't work properly */
545 MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE | HRW_BMAC_RESET);
547 /* Make sure modem is shut down */
548 MACIO_OUT8(HRW_GPIO_MODEM_RESET,
549 MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1);
550 MACIO_BIS(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
551 MACIO_BIC(HEATHROW_FCR, OH_SCCA_IO|OH_SCCB_IO|HRW_SCC_ENABLE);
553 /* Let things settle */
554 (void)MACIO_IN32(HEATHROW_FCR);
557 static void heathrow_wakeup(struct macio_chip *macio, int secondary)
560 MACIO_OUT32(0x38, save_fcr[2]);
561 (void)MACIO_IN32(0x38);
563 MACIO_OUT32(0x3c, save_fcr[3]);
564 (void)MACIO_IN32(0x38);
566 dbdma_restore(macio, save_alt_dbdma);
568 MACIO_OUT32(0x38, save_fcr[0] | HRW_IOBUS_ENABLE);
569 (void)MACIO_IN32(0x38);
571 MACIO_OUT32(0x3c, save_fcr[1]);
572 (void)MACIO_IN32(0x38);
574 MACIO_OUT32(0x34, save_mbcr);
575 (void)MACIO_IN32(0x38);
577 dbdma_restore(macio, save_dbdma);
581 static long heathrow_sleep_state(struct device_node *node, long param,
584 if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
587 if (macio_chips[1].type == macio_gatwick)
588 heathrow_sleep(&macio_chips[0], 1);
589 heathrow_sleep(&macio_chips[0], 0);
590 } else if (value == 0) {
591 heathrow_wakeup(&macio_chips[0], 0);
592 if (macio_chips[1].type == macio_gatwick)
593 heathrow_wakeup(&macio_chips[0], 1);
598 static long core99_scc_enable(struct device_node *node, long param, long value)
600 struct macio_chip* macio;
602 unsigned long chan_mask;
605 macio = macio_find(node, 0);
608 if (of_node_name_eq(node, "ch-a"))
609 chan_mask = MACIO_FLAG_SCCA_ON;
610 else if (of_node_name_eq(node, "ch-b"))
611 chan_mask = MACIO_FLAG_SCCB_ON;
616 int need_reset_scc = 0;
617 int need_reset_irda = 0;
620 fcr = MACIO_IN32(KEYLARGO_FCR0);
621 /* Check if scc cell need enabling */
622 if (!(fcr & KL0_SCC_CELL_ENABLE)) {
623 fcr |= KL0_SCC_CELL_ENABLE;
626 if (chan_mask & MACIO_FLAG_SCCA_ON) {
627 fcr |= KL0_SCCA_ENABLE;
628 /* Don't enable line drivers for I2S modem */
629 if ((param & 0xfff) == PMAC_SCC_I2S1)
630 fcr &= ~KL0_SCC_A_INTF_ENABLE;
632 fcr |= KL0_SCC_A_INTF_ENABLE;
634 if (chan_mask & MACIO_FLAG_SCCB_ON) {
635 fcr |= KL0_SCCB_ENABLE;
636 /* Perform irda specific inits */
637 if ((param & 0xfff) == PMAC_SCC_IRDA) {
638 fcr &= ~KL0_SCC_B_INTF_ENABLE;
639 fcr |= KL0_IRDA_ENABLE;
640 fcr |= KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE;
641 fcr |= KL0_IRDA_SOURCE1_SEL;
642 fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0);
643 fcr &= ~(KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND);
646 fcr |= KL0_SCC_B_INTF_ENABLE;
648 MACIO_OUT32(KEYLARGO_FCR0, fcr);
649 macio->flags |= chan_mask;
650 if (need_reset_scc) {
651 MACIO_BIS(KEYLARGO_FCR0, KL0_SCC_RESET);
652 (void)MACIO_IN32(KEYLARGO_FCR0);
656 MACIO_BIC(KEYLARGO_FCR0, KL0_SCC_RESET);
658 if (need_reset_irda) {
659 MACIO_BIS(KEYLARGO_FCR0, KL0_IRDA_RESET);
660 (void)MACIO_IN32(KEYLARGO_FCR0);
664 MACIO_BIC(KEYLARGO_FCR0, KL0_IRDA_RESET);
667 if (param & PMAC_SCC_FLAG_XMON)
668 macio->flags |= MACIO_FLAG_SCC_LOCKED;
670 if (macio->flags & MACIO_FLAG_SCC_LOCKED)
673 fcr = MACIO_IN32(KEYLARGO_FCR0);
674 if (chan_mask & MACIO_FLAG_SCCA_ON)
675 fcr &= ~KL0_SCCA_ENABLE;
676 if (chan_mask & MACIO_FLAG_SCCB_ON) {
677 fcr &= ~KL0_SCCB_ENABLE;
678 /* Perform irda specific clears */
679 if ((param & 0xfff) == PMAC_SCC_IRDA) {
680 fcr &= ~KL0_IRDA_ENABLE;
681 fcr &= ~(KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE);
682 fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0);
683 fcr &= ~(KL0_IRDA_SOURCE1_SEL|KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND);
686 MACIO_OUT32(KEYLARGO_FCR0, fcr);
687 if ((fcr & (KL0_SCCA_ENABLE | KL0_SCCB_ENABLE)) == 0) {
688 fcr &= ~KL0_SCC_CELL_ENABLE;
689 MACIO_OUT32(KEYLARGO_FCR0, fcr);
691 macio->flags &= ~(chan_mask);
699 core99_modem_enable(struct device_node *node, long param, long value)
701 struct macio_chip* macio;
705 /* Hack for internal USB modem */
707 if (macio_chips[0].type != macio_keylargo)
709 node = macio_chips[0].of_node;
711 macio = macio_find(node, 0);
714 gpio = MACIO_IN8(KL_GPIO_MODEM_RESET);
715 gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE;
716 gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA;
720 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
722 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
727 MACIO_BIC(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
729 (void)MACIO_IN32(KEYLARGO_FCR2);
732 MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
737 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
738 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
739 UNLOCK(flags); mdelay(250); LOCK(flags);
740 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
741 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
742 UNLOCK(flags); mdelay(250); LOCK(flags);
743 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
744 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
745 UNLOCK(flags); mdelay(250);
751 pangea_modem_enable(struct device_node *node, long param, long value)
753 struct macio_chip* macio;
757 /* Hack for internal USB modem */
759 if (macio_chips[0].type != macio_pangea &&
760 macio_chips[0].type != macio_intrepid)
762 node = macio_chips[0].of_node;
764 macio = macio_find(node, 0);
767 gpio = MACIO_IN8(KL_GPIO_MODEM_RESET);
768 gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE;
769 gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA;
773 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
775 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
780 MACIO_OUT8(KL_GPIO_MODEM_POWER,
781 KEYLARGO_GPIO_OUTPUT_ENABLE);
783 (void)MACIO_IN32(KEYLARGO_FCR2);
786 MACIO_OUT8(KL_GPIO_MODEM_POWER,
787 KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
792 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
793 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
794 UNLOCK(flags); mdelay(250); LOCK(flags);
795 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
796 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
797 UNLOCK(flags); mdelay(250); LOCK(flags);
798 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
799 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
800 UNLOCK(flags); mdelay(250);
806 core99_ata100_enable(struct device_node *node, long value)
809 struct pci_dev *pdev = NULL;
813 if (uninorth_rev < 0x24)
818 UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_ATA100);
820 UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_ATA100);
821 (void)UN_IN(UNI_N_CLOCK_CNTL);
826 if (pci_device_from_OF_node(node, &pbus, &pid) == 0)
827 pdev = pci_get_domain_bus_and_slot(0, pbus, pid);
830 rc = pci_enable_device(pdev);
832 pci_set_master(pdev);
841 core99_ide_enable(struct device_node *node, long param, long value)
843 /* Bus ID 0 to 2 are KeyLargo based IDE, busID 3 is U2
848 return simple_feature_tweak(node, macio_unknown,
849 KEYLARGO_FCR1, KL1_EIDE0_ENABLE, value);
851 return simple_feature_tweak(node, macio_unknown,
852 KEYLARGO_FCR1, KL1_EIDE1_ENABLE, value);
854 return simple_feature_tweak(node, macio_unknown,
855 KEYLARGO_FCR1, KL1_UIDE_ENABLE, value);
857 return core99_ata100_enable(node, value);
864 core99_ide_reset(struct device_node *node, long param, long value)
868 return simple_feature_tweak(node, macio_unknown,
869 KEYLARGO_FCR1, KL1_EIDE0_RESET_N, !value);
871 return simple_feature_tweak(node, macio_unknown,
872 KEYLARGO_FCR1, KL1_EIDE1_RESET_N, !value);
874 return simple_feature_tweak(node, macio_unknown,
875 KEYLARGO_FCR1, KL1_UIDE_RESET_N, !value);
882 core99_gmac_enable(struct device_node *node, long param, long value)
888 UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC);
890 UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_GMAC);
891 (void)UN_IN(UNI_N_CLOCK_CNTL);
899 core99_gmac_phy_reset(struct device_node *node, long param, long value)
902 struct macio_chip *macio;
904 macio = &macio_chips[0];
905 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
906 macio->type != macio_intrepid)
910 MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, KEYLARGO_GPIO_OUTPUT_ENABLE);
911 (void)MACIO_IN8(KL_GPIO_ETH_PHY_RESET);
915 MACIO_OUT8(KL_GPIO_ETH_PHY_RESET, /*KEYLARGO_GPIO_OUTPUT_ENABLE | */
916 KEYLARGO_GPIO_OUTOUT_DATA);
924 core99_sound_chip_enable(struct device_node *node, long param, long value)
926 struct macio_chip* macio;
929 macio = macio_find(node, 0);
933 /* Do a better probe code, screamer G4 desktops &
934 * iMacs can do that too, add a recalibrate in
937 if (pmac_mb.model_id == PMAC_TYPE_PISMO ||
938 pmac_mb.model_id == PMAC_TYPE_TITANIUM) {
941 MACIO_OUT8(KL_GPIO_SOUND_POWER,
942 KEYLARGO_GPIO_OUTPUT_ENABLE |
943 KEYLARGO_GPIO_OUTOUT_DATA);
945 MACIO_OUT8(KL_GPIO_SOUND_POWER,
946 KEYLARGO_GPIO_OUTPUT_ENABLE);
947 (void)MACIO_IN8(KL_GPIO_SOUND_POWER);
954 core99_airport_enable(struct device_node *node, long param, long value)
956 struct macio_chip* macio;
960 macio = macio_find(node, 0);
964 /* Hint: we allow passing of macio itself for the sake of the
967 if (node != macio->of_node &&
968 (!node->parent || node->parent != macio->of_node))
970 state = (macio->flags & MACIO_FLAG_AIRPORT_ON) != 0;
974 /* This code is a reproduction of OF enable-cardslot
975 * and init-wireless methods, slightly hacked until
979 MACIO_OUT8(KEYLARGO_GPIO_0+0xf, 5);
980 (void)MACIO_IN8(KEYLARGO_GPIO_0+0xf);
984 MACIO_OUT8(KEYLARGO_GPIO_0+0xf, 4);
985 (void)MACIO_IN8(KEYLARGO_GPIO_0+0xf);
991 MACIO_BIC(KEYLARGO_FCR2, KL2_CARDSEL_16);
992 (void)MACIO_IN32(KEYLARGO_FCR2);
994 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xb, 0);
995 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xb);
997 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xa, 0x28);
998 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xa);
1000 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+0xd, 0x28);
1001 (void)MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+0xd);
1003 MACIO_OUT8(KEYLARGO_GPIO_0+0xd, 0x28);
1004 (void)MACIO_IN8(KEYLARGO_GPIO_0+0xd);
1006 MACIO_OUT8(KEYLARGO_GPIO_0+0xe, 0x28);
1007 (void)MACIO_IN8(KEYLARGO_GPIO_0+0xe);
1010 MACIO_OUT32(0x1c000, 0);
1012 MACIO_OUT8(0x1a3e0, 0x41);
1013 (void)MACIO_IN8(0x1a3e0);
1016 MACIO_BIS(KEYLARGO_FCR2, KL2_CARDSEL_16);
1017 (void)MACIO_IN32(KEYLARGO_FCR2);
1021 macio->flags |= MACIO_FLAG_AIRPORT_ON;
1024 MACIO_BIC(KEYLARGO_FCR2, KL2_CARDSEL_16);
1025 (void)MACIO_IN32(KEYLARGO_FCR2);
1026 MACIO_OUT8(KL_GPIO_AIRPORT_0, 0);
1027 MACIO_OUT8(KL_GPIO_AIRPORT_1, 0);
1028 MACIO_OUT8(KL_GPIO_AIRPORT_2, 0);
1029 MACIO_OUT8(KL_GPIO_AIRPORT_3, 0);
1030 MACIO_OUT8(KL_GPIO_AIRPORT_4, 0);
1031 (void)MACIO_IN8(KL_GPIO_AIRPORT_4);
1034 macio->flags &= ~MACIO_FLAG_AIRPORT_ON;
1041 core99_reset_cpu(struct device_node *node, long param, long value)
1043 unsigned int reset_io = 0;
1044 unsigned long flags;
1045 struct macio_chip *macio;
1046 struct device_node *np;
1047 const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0,
1050 KL_GPIO_RESET_CPU3 };
1052 macio = &macio_chips[0];
1053 if (macio->type != macio_keylargo)
1056 for_each_of_cpu_node(np) {
1057 const u32 *num = of_get_property(np, "reg", NULL);
1058 const u32 *rst = of_get_property(np, "soft-reset", NULL);
1059 if (num == NULL || rst == NULL)
1061 if (param == *num) {
1066 if (np == NULL || reset_io == 0)
1067 reset_io = dflt_reset_lines[param];
1070 MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
1071 (void)MACIO_IN8(reset_io);
1073 MACIO_OUT8(reset_io, 0);
1074 (void)MACIO_IN8(reset_io);
1079 #endif /* CONFIG_SMP */
1082 core99_usb_enable(struct device_node *node, long param, long value)
1084 struct macio_chip *macio;
1085 unsigned long flags;
1090 macio = &macio_chips[0];
1091 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1092 macio->type != macio_intrepid)
1095 prop = of_get_property(node, "AAPL,clock-id", NULL);
1098 if (strncmp(prop, "usb0u048", 8) == 0)
1100 else if (strncmp(prop, "usb1u148", 8) == 0)
1102 else if (strncmp(prop, "usb2u248", 8) == 0)
1107 /* Sorry for the brute-force locking, but this is only used during
1108 * sleep and the timing seem to be critical
1114 MACIO_BIC(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
1115 (void)MACIO_IN32(KEYLARGO_FCR0);
1119 MACIO_BIS(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
1120 } else if (number == 2) {
1121 MACIO_BIC(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
1123 (void)MACIO_IN32(KEYLARGO_FCR0);
1126 MACIO_BIS(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
1127 } else if (number == 4) {
1128 MACIO_BIC(KEYLARGO_FCR1, (KL1_USB2_PAD_SUSPEND0 | KL1_USB2_PAD_SUSPEND1));
1130 (void)MACIO_IN32(KEYLARGO_FCR1);
1133 MACIO_BIS(KEYLARGO_FCR1, KL1_USB2_CELL_ENABLE);
1136 reg = MACIO_IN32(KEYLARGO_FCR4);
1137 reg &= ~(KL4_PORT_WAKEUP_ENABLE(number) | KL4_PORT_RESUME_WAKE_EN(number) |
1138 KL4_PORT_CONNECT_WAKE_EN(number) | KL4_PORT_DISCONNECT_WAKE_EN(number));
1139 reg &= ~(KL4_PORT_WAKEUP_ENABLE(number+1) | KL4_PORT_RESUME_WAKE_EN(number+1) |
1140 KL4_PORT_CONNECT_WAKE_EN(number+1) | KL4_PORT_DISCONNECT_WAKE_EN(number+1));
1141 MACIO_OUT32(KEYLARGO_FCR4, reg);
1142 (void)MACIO_IN32(KEYLARGO_FCR4);
1145 reg = MACIO_IN32(KEYLARGO_FCR3);
1146 reg &= ~(KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1147 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0));
1148 reg &= ~(KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1149 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1));
1150 MACIO_OUT32(KEYLARGO_FCR3, reg);
1151 (void)MACIO_IN32(KEYLARGO_FCR3);
1154 if (macio->type == macio_intrepid) {
1155 /* wait for clock stopped bits to clear */
1156 u32 test0 = 0, test1 = 0;
1157 u32 status0, status1;
1163 test0 = UNI_N_CLOCK_STOPPED_USB0;
1164 test1 = UNI_N_CLOCK_STOPPED_USB0PCI;
1167 test0 = UNI_N_CLOCK_STOPPED_USB1;
1168 test1 = UNI_N_CLOCK_STOPPED_USB1PCI;
1171 test0 = UNI_N_CLOCK_STOPPED_USB2;
1172 test1 = UNI_N_CLOCK_STOPPED_USB2PCI;
1176 if (--timeout <= 0) {
1177 printk(KERN_ERR "core99_usb_enable: "
1178 "Timeout waiting for clocks\n");
1182 status0 = UN_IN(UNI_N_CLOCK_STOP_STATUS0);
1183 status1 = UN_IN(UNI_N_CLOCK_STOP_STATUS1);
1184 } while ((status0 & test0) | (status1 & test1));
1190 reg = MACIO_IN32(KEYLARGO_FCR4);
1191 reg |= KL4_PORT_WAKEUP_ENABLE(number) | KL4_PORT_RESUME_WAKE_EN(number) |
1192 KL4_PORT_CONNECT_WAKE_EN(number) | KL4_PORT_DISCONNECT_WAKE_EN(number);
1193 reg |= KL4_PORT_WAKEUP_ENABLE(number+1) | KL4_PORT_RESUME_WAKE_EN(number+1) |
1194 KL4_PORT_CONNECT_WAKE_EN(number+1) | KL4_PORT_DISCONNECT_WAKE_EN(number+1);
1195 MACIO_OUT32(KEYLARGO_FCR4, reg);
1196 (void)MACIO_IN32(KEYLARGO_FCR4);
1199 reg = MACIO_IN32(KEYLARGO_FCR3);
1200 reg |= KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1201 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0);
1202 reg |= KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1203 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1);
1204 MACIO_OUT32(KEYLARGO_FCR3, reg);
1205 (void)MACIO_IN32(KEYLARGO_FCR3);
1209 if (macio->type != macio_intrepid)
1210 MACIO_BIC(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
1211 (void)MACIO_IN32(KEYLARGO_FCR0);
1213 MACIO_BIS(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
1214 (void)MACIO_IN32(KEYLARGO_FCR0);
1215 } else if (number == 2) {
1216 if (macio->type != macio_intrepid)
1217 MACIO_BIC(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
1218 (void)MACIO_IN32(KEYLARGO_FCR0);
1220 MACIO_BIS(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
1221 (void)MACIO_IN32(KEYLARGO_FCR0);
1222 } else if (number == 4) {
1224 MACIO_BIS(KEYLARGO_FCR1, (KL1_USB2_PAD_SUSPEND0 | KL1_USB2_PAD_SUSPEND1));
1225 (void)MACIO_IN32(KEYLARGO_FCR1);
1235 core99_firewire_enable(struct device_node *node, long param, long value)
1237 unsigned long flags;
1238 struct macio_chip *macio;
1240 macio = &macio_chips[0];
1241 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1242 macio->type != macio_intrepid)
1244 if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED))
1249 UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
1250 (void)UN_IN(UNI_N_CLOCK_CNTL);
1252 UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
1253 (void)UN_IN(UNI_N_CLOCK_CNTL);
1262 core99_firewire_cable_power(struct device_node *node, long param, long value)
1264 unsigned long flags;
1265 struct macio_chip *macio;
1267 /* Trick: we allow NULL node */
1268 if ((pmac_mb.board_flags & PMAC_MB_HAS_FW_POWER) == 0)
1270 macio = &macio_chips[0];
1271 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1272 macio->type != macio_intrepid)
1274 if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED))
1279 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 0);
1280 MACIO_IN8(KL_GPIO_FW_CABLE_POWER);
1283 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 4);
1284 MACIO_IN8(KL_GPIO_FW_CABLE_POWER); udelay(10);
1293 intrepid_aack_delay_enable(struct device_node *node, long param, long value)
1295 unsigned long flags;
1297 if (uninorth_rev < 0xd2)
1302 UN_BIS(UNI_N_AACK_DELAY, UNI_N_AACK_DELAY_ENABLE);
1304 UN_BIC(UNI_N_AACK_DELAY, UNI_N_AACK_DELAY_ENABLE);
1311 #endif /* CONFIG_PPC64 */
1314 core99_read_gpio(struct device_node *node, long param, long value)
1316 struct macio_chip *macio = &macio_chips[0];
1318 return MACIO_IN8(param);
1323 core99_write_gpio(struct device_node *node, long param, long value)
1325 struct macio_chip *macio = &macio_chips[0];
1327 MACIO_OUT8(param, (u8)(value & 0xff));
1332 static long g5_gmac_enable(struct device_node *node, long param, long value)
1334 struct macio_chip *macio = &macio_chips[0];
1335 unsigned long flags;
1342 MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
1344 k2_skiplist[0] = NULL;
1346 k2_skiplist[0] = node;
1348 MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
1357 static long g5_fw_enable(struct device_node *node, long param, long value)
1359 struct macio_chip *macio = &macio_chips[0];
1360 unsigned long flags;
1367 MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
1369 k2_skiplist[1] = NULL;
1371 k2_skiplist[1] = node;
1373 MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
1382 static long g5_mpic_enable(struct device_node *node, long param, long value)
1384 unsigned long flags;
1385 struct device_node *parent = of_get_parent(node);
1390 is_u3 = of_node_name_eq(parent, "u3") || of_node_name_eq(parent, "u4");
1391 of_node_put(parent);
1396 UN_BIS(U3_TOGGLE_REG, U3_MPIC_RESET | U3_MPIC_OUTPUT_ENABLE);
1402 static long g5_eth_phy_reset(struct device_node *node, long param, long value)
1404 struct macio_chip *macio = &macio_chips[0];
1405 struct device_node *phy;
1409 * We must not reset the combo PHYs, only the BCM5221 found in
1412 phy = of_get_next_child(node, NULL);
1415 need_reset = of_device_is_compatible(phy, "B5221");
1420 /* PHY reset is GPIO 29, not in device-tree unfortunately */
1421 MACIO_OUT8(K2_GPIO_EXTINT_0 + 29,
1422 KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
1423 /* Thankfully, this is now always called at a time when we can
1424 * schedule by sungem.
1427 MACIO_OUT8(K2_GPIO_EXTINT_0 + 29, 0);
1432 static long g5_i2s_enable(struct device_node *node, long param, long value)
1434 /* Very crude implementation for now */
1435 struct macio_chip *macio = &macio_chips[0];
1436 unsigned long flags;
1440 K2_FCR1_I2S0_CELL_ENABLE |
1441 K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE,
1442 KL3_I2S0_CLK18_ENABLE
1444 { KL0_SCC_A_INTF_ENABLE,
1445 K2_FCR1_I2S1_CELL_ENABLE |
1446 K2_FCR1_I2S1_CLK_ENABLE_BIT | K2_FCR1_I2S1_ENABLE,
1447 KL3_I2S1_CLK18_ENABLE
1449 { KL0_SCC_B_INTF_ENABLE,
1450 SH_FCR1_I2S2_CELL_ENABLE |
1451 SH_FCR1_I2S2_CLK_ENABLE_BIT | SH_FCR1_I2S2_ENABLE,
1452 SH_FCR3_I2S2_CLK18_ENABLE
1456 if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
1458 if (strncmp(node->name, "i2s-", 4))
1460 cell = node->name[4] - 'a';
1466 if (macio->type == macio_shasta)
1475 MACIO_BIC(KEYLARGO_FCR0, fcrs[cell][0]);
1476 MACIO_BIS(KEYLARGO_FCR1, fcrs[cell][1]);
1477 MACIO_BIS(KEYLARGO_FCR3, fcrs[cell][2]);
1479 MACIO_BIC(KEYLARGO_FCR3, fcrs[cell][2]);
1480 MACIO_BIC(KEYLARGO_FCR1, fcrs[cell][1]);
1481 MACIO_BIS(KEYLARGO_FCR0, fcrs[cell][0]);
1491 static long g5_reset_cpu(struct device_node *node, long param, long value)
1493 unsigned int reset_io = 0;
1494 unsigned long flags;
1495 struct macio_chip *macio;
1496 struct device_node *np;
1498 macio = &macio_chips[0];
1499 if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
1502 for_each_of_cpu_node(np) {
1503 const u32 *num = of_get_property(np, "reg", NULL);
1504 const u32 *rst = of_get_property(np, "soft-reset", NULL);
1505 if (num == NULL || rst == NULL)
1507 if (param == *num) {
1512 if (np == NULL || reset_io == 0)
1516 MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
1517 (void)MACIO_IN8(reset_io);
1519 MACIO_OUT8(reset_io, 0);
1520 (void)MACIO_IN8(reset_io);
1525 #endif /* CONFIG_SMP */
1528 * This can be called from pmac_smp so isn't static
1530 * This takes the second CPU off the bus on dual CPU machines
1533 void g5_phy_disable_cpu1(void)
1535 if (uninorth_maj == 3)
1536 UN_OUT(U3_API_PHY_CONFIG_1, 0);
1538 #endif /* CONFIG_PPC64 */
1540 #ifndef CONFIG_PPC64
1544 static u32 save_gpio_levels[2];
1545 static u8 save_gpio_extint[KEYLARGO_GPIO_EXTINT_CNT];
1546 static u8 save_gpio_normal[KEYLARGO_GPIO_CNT];
1547 static u32 save_unin_clock_ctl;
1549 static void keylargo_shutdown(struct macio_chip *macio, int sleep_mode)
1555 MACIO_BIS(KEYLARGO_FCR0, KL0_USB_REF_SUSPEND);
1556 (void)MACIO_IN32(KEYLARGO_FCR0);
1560 MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
1561 KL0_SCC_CELL_ENABLE |
1562 KL0_IRDA_ENABLE | KL0_IRDA_CLK32_ENABLE |
1563 KL0_IRDA_CLK19_ENABLE);
1565 MACIO_BIC(KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK);
1566 MACIO_BIS(KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE);
1568 MACIO_BIC(KEYLARGO_FCR1,
1569 KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT |
1570 KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE |
1571 KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
1572 KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
1573 KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
1574 KL1_EIDE0_ENABLE | KL1_EIDE0_RESET_N |
1575 KL1_EIDE1_ENABLE | KL1_EIDE1_RESET_N |
1578 MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
1579 MACIO_BIC(KEYLARGO_FCR2, KL2_IOBUS_ENABLE);
1581 temp = MACIO_IN32(KEYLARGO_FCR3);
1582 if (macio->rev >= 2) {
1583 temp |= KL3_SHUTDOWN_PLL2X;
1585 temp |= KL3_SHUTDOWN_PLL_TOTAL;
1588 temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 |
1589 KL3_SHUTDOWN_PLLKW35;
1591 temp |= KL3_SHUTDOWN_PLLKW12;
1592 temp &= ~(KL3_CLK66_ENABLE | KL3_CLK49_ENABLE | KL3_CLK45_ENABLE
1593 | KL3_CLK31_ENABLE | KL3_I2S1_CLK18_ENABLE | KL3_I2S0_CLK18_ENABLE);
1595 temp &= ~(KL3_TIMER_CLK18_ENABLE | KL3_VIA_CLK16_ENABLE);
1596 MACIO_OUT32(KEYLARGO_FCR3, temp);
1598 /* Flush posted writes & wait a bit */
1599 (void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
1602 static void pangea_shutdown(struct macio_chip *macio, int sleep_mode)
1606 MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
1607 KL0_SCC_CELL_ENABLE |
1608 KL0_USB0_CELL_ENABLE | KL0_USB1_CELL_ENABLE);
1610 MACIO_BIC(KEYLARGO_FCR1,
1611 KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT |
1612 KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE |
1613 KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
1614 KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
1615 KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
1617 if (pmac_mb.board_flags & PMAC_MB_MOBILE)
1618 MACIO_BIC(KEYLARGO_FCR1, KL1_UIDE_RESET_N);
1620 MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
1622 temp = MACIO_IN32(KEYLARGO_FCR3);
1623 temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 |
1624 KL3_SHUTDOWN_PLLKW35;
1625 temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE | KL3_CLK31_ENABLE
1626 | KL3_I2S0_CLK18_ENABLE | KL3_I2S1_CLK18_ENABLE);
1628 temp &= ~(KL3_VIA_CLK16_ENABLE | KL3_TIMER_CLK18_ENABLE);
1629 MACIO_OUT32(KEYLARGO_FCR3, temp);
1631 /* Flush posted writes & wait a bit */
1632 (void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
1635 static void intrepid_shutdown(struct macio_chip *macio, int sleep_mode)
1639 MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
1640 KL0_SCC_CELL_ENABLE);
1642 MACIO_BIC(KEYLARGO_FCR1,
1643 KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
1644 KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
1645 KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
1647 if (pmac_mb.board_flags & PMAC_MB_MOBILE)
1648 MACIO_BIC(KEYLARGO_FCR1, KL1_UIDE_RESET_N);
1650 temp = MACIO_IN32(KEYLARGO_FCR3);
1651 temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE |
1652 KL3_I2S1_CLK18_ENABLE | KL3_I2S0_CLK18_ENABLE);
1654 temp &= ~(KL3_TIMER_CLK18_ENABLE | KL3_IT_VIA_CLK32_ENABLE);
1655 MACIO_OUT32(KEYLARGO_FCR3, temp);
1657 /* Flush posted writes & wait a bit */
1658 (void)MACIO_IN32(KEYLARGO_FCR0);
1666 struct macio_chip *macio;
1669 macio = &macio_chips[0];
1670 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1671 macio->type != macio_intrepid)
1674 /* We power off the wireless slot in case it was not done
1675 * by the driver. We don't power it on automatically however
1677 if (macio->flags & MACIO_FLAG_AIRPORT_ON)
1678 core99_airport_enable(macio->of_node, 0, 0);
1680 /* We power off the FW cable. Should be done by the driver... */
1681 if (macio->flags & MACIO_FLAG_FW_SUPPORTED) {
1682 core99_firewire_enable(NULL, 0, 0);
1683 core99_firewire_cable_power(NULL, 0, 0);
1686 /* We make sure int. modem is off (in case driver lost it) */
1687 if (macio->type == macio_keylargo)
1688 core99_modem_enable(macio->of_node, 0, 0);
1690 pangea_modem_enable(macio->of_node, 0, 0);
1692 /* We make sure the sound is off as well */
1693 core99_sound_chip_enable(macio->of_node, 0, 0);
1696 * Save various bits of KeyLargo
1699 /* Save the state of the various GPIOs */
1700 save_gpio_levels[0] = MACIO_IN32(KEYLARGO_GPIO_LEVELS0);
1701 save_gpio_levels[1] = MACIO_IN32(KEYLARGO_GPIO_LEVELS1);
1702 for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
1703 save_gpio_extint[i] = MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+i);
1704 for (i=0; i<KEYLARGO_GPIO_CNT; i++)
1705 save_gpio_normal[i] = MACIO_IN8(KEYLARGO_GPIO_0+i);
1708 if (macio->type == macio_keylargo)
1709 save_mbcr = MACIO_IN32(KEYLARGO_MBCR);
1710 save_fcr[0] = MACIO_IN32(KEYLARGO_FCR0);
1711 save_fcr[1] = MACIO_IN32(KEYLARGO_FCR1);
1712 save_fcr[2] = MACIO_IN32(KEYLARGO_FCR2);
1713 save_fcr[3] = MACIO_IN32(KEYLARGO_FCR3);
1714 save_fcr[4] = MACIO_IN32(KEYLARGO_FCR4);
1715 if (macio->type == macio_pangea || macio->type == macio_intrepid)
1716 save_fcr[5] = MACIO_IN32(KEYLARGO_FCR5);
1718 /* Save state & config of DBDMA channels */
1719 dbdma_save(macio, save_dbdma);
1722 * Turn off as much as we can
1724 if (macio->type == macio_pangea)
1725 pangea_shutdown(macio, 1);
1726 else if (macio->type == macio_intrepid)
1727 intrepid_shutdown(macio, 1);
1728 else if (macio->type == macio_keylargo)
1729 keylargo_shutdown(macio, 1);
1732 * Put the host bridge to sleep
1735 save_unin_clock_ctl = UN_IN(UNI_N_CLOCK_CNTL);
1736 /* Note: do not switch GMAC off, driver does it when necessary, WOL must keep it
1739 UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl &
1740 ~(/*UNI_N_CLOCK_CNTL_GMAC|*/UNI_N_CLOCK_CNTL_FW/*|UNI_N_CLOCK_CNTL_PCI*/));
1742 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING);
1743 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_SLEEP);
1747 * FIXME: A bit of black magic with OpenPIC (don't ask me why)
1749 if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) {
1750 MACIO_BIS(0x506e0, 0x00400000);
1751 MACIO_BIS(0x506e0, 0x80000000);
1757 core99_wake_up(void)
1759 struct macio_chip *macio;
1762 macio = &macio_chips[0];
1763 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1764 macio->type != macio_intrepid)
1768 * Wakeup the host bridge
1770 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL);
1772 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING);
1779 if (macio->type == macio_keylargo) {
1780 MACIO_OUT32(KEYLARGO_MBCR, save_mbcr);
1781 (void)MACIO_IN32(KEYLARGO_MBCR); udelay(10);
1783 MACIO_OUT32(KEYLARGO_FCR0, save_fcr[0]);
1784 (void)MACIO_IN32(KEYLARGO_FCR0); udelay(10);
1785 MACIO_OUT32(KEYLARGO_FCR1, save_fcr[1]);
1786 (void)MACIO_IN32(KEYLARGO_FCR1); udelay(10);
1787 MACIO_OUT32(KEYLARGO_FCR2, save_fcr[2]);
1788 (void)MACIO_IN32(KEYLARGO_FCR2); udelay(10);
1789 MACIO_OUT32(KEYLARGO_FCR3, save_fcr[3]);
1790 (void)MACIO_IN32(KEYLARGO_FCR3); udelay(10);
1791 MACIO_OUT32(KEYLARGO_FCR4, save_fcr[4]);
1792 (void)MACIO_IN32(KEYLARGO_FCR4); udelay(10);
1793 if (macio->type == macio_pangea || macio->type == macio_intrepid) {
1794 MACIO_OUT32(KEYLARGO_FCR5, save_fcr[5]);
1795 (void)MACIO_IN32(KEYLARGO_FCR5); udelay(10);
1798 dbdma_restore(macio, save_dbdma);
1800 MACIO_OUT32(KEYLARGO_GPIO_LEVELS0, save_gpio_levels[0]);
1801 MACIO_OUT32(KEYLARGO_GPIO_LEVELS1, save_gpio_levels[1]);
1802 for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
1803 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+i, save_gpio_extint[i]);
1804 for (i=0; i<KEYLARGO_GPIO_CNT; i++)
1805 MACIO_OUT8(KEYLARGO_GPIO_0+i, save_gpio_normal[i]);
1807 /* FIXME more black magic with OpenPIC ... */
1808 if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) {
1809 MACIO_BIC(0x506e0, 0x00400000);
1810 MACIO_BIC(0x506e0, 0x80000000);
1813 UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl);
1819 #endif /* CONFIG_PM */
1822 core99_sleep_state(struct device_node *node, long param, long value)
1824 /* Param == 1 means to enter the "fake sleep" mode that is
1825 * used for CPU speed switch
1829 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING);
1830 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_IDLE2);
1832 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL);
1834 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING);
1839 if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
1844 return core99_sleep();
1845 else if (value == 0)
1846 return core99_wake_up();
1848 #endif /* CONFIG_PM */
1852 #endif /* CONFIG_PPC64 */
1855 generic_dev_can_wake(struct device_node *node, long param, long value)
1857 /* Todo: eventually check we are really dealing with on-board
1861 if (pmac_mb.board_flags & PMAC_MB_MAY_SLEEP)
1862 pmac_mb.board_flags |= PMAC_MB_CAN_SLEEP;
1866 static long generic_get_mb_info(struct device_node *node, long param, long value)
1869 case PMAC_MB_INFO_MODEL:
1870 return pmac_mb.model_id;
1871 case PMAC_MB_INFO_FLAGS:
1872 return pmac_mb.board_flags;
1873 case PMAC_MB_INFO_NAME:
1874 /* hack hack hack... but should work */
1875 *((const char **)value) = pmac_mb.model_name;
1886 /* Used on any machine
1888 static struct feature_table_entry any_features[] = {
1889 { PMAC_FTR_GET_MB_INFO, generic_get_mb_info },
1890 { PMAC_FTR_DEVICE_CAN_WAKE, generic_dev_can_wake },
1894 #ifndef CONFIG_PPC64
1896 /* OHare based motherboards. Currently, we only use these on the
1897 * 2400,3400 and 3500 series powerbooks. Some older desktops seem
1898 * to have issues with turning on/off those asic cells
1900 static struct feature_table_entry ohare_features[] = {
1901 { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
1902 { PMAC_FTR_SWIM3_ENABLE, ohare_floppy_enable },
1903 { PMAC_FTR_MESH_ENABLE, ohare_mesh_enable },
1904 { PMAC_FTR_IDE_ENABLE, ohare_ide_enable},
1905 { PMAC_FTR_IDE_RESET, ohare_ide_reset},
1906 { PMAC_FTR_SLEEP_STATE, ohare_sleep_state },
1910 /* Heathrow desktop machines (Beige G3).
1911 * Separated as some features couldn't be properly tested
1912 * and the serial port control bits appear to confuse it.
1914 static struct feature_table_entry heathrow_desktop_features[] = {
1915 { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
1916 { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
1917 { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
1918 { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
1919 { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
1923 /* Heathrow based laptop, that is the Wallstreet and mainstreet
1926 static struct feature_table_entry heathrow_laptop_features[] = {
1927 { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
1928 { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable },
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 },
1934 { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable },
1935 { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state },
1939 /* Paddington based machines
1940 * The lombard (101) powerbook, first iMac models, B&W G3 and Yikes G4.
1942 static struct feature_table_entry paddington_features[] = {
1943 { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
1944 { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable },
1945 { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
1946 { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
1947 { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
1948 { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
1949 { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
1950 { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable },
1951 { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state },
1955 /* Core99 & MacRISC 2 machines (all machines released since the
1956 * iBook (included), that is all AGP machines, except pangea
1957 * chipset. The pangea chipset is the "combo" UniNorth/KeyLargo
1958 * used on iBook2 & iMac "flow power".
1960 static struct feature_table_entry core99_features[] = {
1961 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
1962 { PMAC_FTR_MODEM_ENABLE, core99_modem_enable },
1963 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
1964 { PMAC_FTR_IDE_RESET, core99_ide_reset },
1965 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
1966 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
1967 { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
1968 { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
1969 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
1970 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
1971 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
1973 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
1976 { PMAC_FTR_RESET_CPU, core99_reset_cpu },
1977 #endif /* CONFIG_SMP */
1978 { PMAC_FTR_READ_GPIO, core99_read_gpio },
1979 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
1985 static struct feature_table_entry rackmac_features[] = {
1986 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
1987 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
1988 { PMAC_FTR_IDE_RESET, core99_ide_reset },
1989 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
1990 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
1991 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
1992 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
1993 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
1994 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
1996 { PMAC_FTR_RESET_CPU, core99_reset_cpu },
1997 #endif /* CONFIG_SMP */
1998 { PMAC_FTR_READ_GPIO, core99_read_gpio },
1999 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2005 static struct feature_table_entry pangea_features[] = {
2006 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
2007 { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable },
2008 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
2009 { PMAC_FTR_IDE_RESET, core99_ide_reset },
2010 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
2011 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
2012 { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
2013 { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
2014 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
2015 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
2016 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
2017 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
2018 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2019 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2023 /* Intrepid features
2025 static struct feature_table_entry intrepid_features[] = {
2026 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
2027 { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable },
2028 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
2029 { PMAC_FTR_IDE_RESET, core99_ide_reset },
2030 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
2031 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
2032 { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
2033 { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
2034 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
2035 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
2036 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
2037 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
2038 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2039 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2040 { PMAC_FTR_AACK_DELAY_ENABLE, intrepid_aack_delay_enable },
2044 #else /* CONFIG_PPC64 */
2048 static struct feature_table_entry g5_features[] = {
2049 { PMAC_FTR_GMAC_ENABLE, g5_gmac_enable },
2050 { PMAC_FTR_1394_ENABLE, g5_fw_enable },
2051 { PMAC_FTR_ENABLE_MPIC, g5_mpic_enable },
2052 { PMAC_FTR_GMAC_PHY_RESET, g5_eth_phy_reset },
2053 { PMAC_FTR_SOUND_CHIP_ENABLE, g5_i2s_enable },
2055 { PMAC_FTR_RESET_CPU, g5_reset_cpu },
2056 #endif /* CONFIG_SMP */
2057 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2058 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2062 #endif /* CONFIG_PPC64 */
2064 static struct pmac_mb_def pmac_mb_defs[] = {
2065 #ifndef CONFIG_PPC64
2070 { "AAPL,8500", "PowerMac 8500/8600",
2071 PMAC_TYPE_PSURGE, NULL,
2074 { "AAPL,9500", "PowerMac 9500/9600",
2075 PMAC_TYPE_PSURGE, NULL,
2078 { "AAPL,7200", "PowerMac 7200",
2079 PMAC_TYPE_PSURGE, NULL,
2082 { "AAPL,7300", "PowerMac 7200/7300",
2083 PMAC_TYPE_PSURGE, NULL,
2086 { "AAPL,7500", "PowerMac 7500",
2087 PMAC_TYPE_PSURGE, NULL,
2090 { "AAPL,ShinerESB", "Apple Network Server",
2091 PMAC_TYPE_ANS, NULL,
2094 { "AAPL,e407", "Alchemy",
2095 PMAC_TYPE_ALCHEMY, NULL,
2098 { "AAPL,e411", "Gazelle",
2099 PMAC_TYPE_GAZELLE, NULL,
2102 { "AAPL,Gossamer", "PowerMac G3 (Gossamer)",
2103 PMAC_TYPE_GOSSAMER, heathrow_desktop_features,
2106 { "AAPL,PowerMac G3", "PowerMac G3 (Silk)",
2107 PMAC_TYPE_SILK, heathrow_desktop_features,
2110 { "PowerMac1,1", "Blue&White G3",
2111 PMAC_TYPE_YOSEMITE, paddington_features,
2114 { "PowerMac1,2", "PowerMac G4 PCI Graphics",
2115 PMAC_TYPE_YIKES, paddington_features,
2118 { "PowerMac2,1", "iMac FireWire",
2119 PMAC_TYPE_FW_IMAC, core99_features,
2120 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2122 { "PowerMac2,2", "iMac FireWire",
2123 PMAC_TYPE_FW_IMAC, core99_features,
2124 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2126 { "PowerMac3,1", "PowerMac G4 AGP Graphics",
2127 PMAC_TYPE_SAWTOOTH, core99_features,
2130 { "PowerMac3,2", "PowerMac G4 AGP Graphics",
2131 PMAC_TYPE_SAWTOOTH, core99_features,
2132 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2134 { "PowerMac3,3", "PowerMac G4 AGP Graphics",
2135 PMAC_TYPE_SAWTOOTH, core99_features,
2136 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2138 { "PowerMac3,4", "PowerMac G4 Silver",
2139 PMAC_TYPE_QUICKSILVER, core99_features,
2142 { "PowerMac3,5", "PowerMac G4 Silver",
2143 PMAC_TYPE_QUICKSILVER, core99_features,
2146 { "PowerMac3,6", "PowerMac G4 Windtunnel",
2147 PMAC_TYPE_WINDTUNNEL, core99_features,
2150 { "PowerMac4,1", "iMac \"Flower Power\"",
2151 PMAC_TYPE_PANGEA_IMAC, pangea_features,
2154 { "PowerMac4,2", "Flat panel iMac",
2155 PMAC_TYPE_FLAT_PANEL_IMAC, pangea_features,
2158 { "PowerMac4,4", "eMac",
2159 PMAC_TYPE_EMAC, core99_features,
2162 { "PowerMac5,1", "PowerMac G4 Cube",
2163 PMAC_TYPE_CUBE, core99_features,
2164 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2166 { "PowerMac6,1", "Flat panel iMac",
2167 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2170 { "PowerMac6,3", "Flat panel iMac",
2171 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2174 { "PowerMac6,4", "eMac",
2175 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2178 { "PowerMac10,1", "Mac mini",
2179 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2182 { "PowerMac10,2", "Mac mini (Late 2005)",
2183 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2186 { "iMac,1", "iMac (first generation)",
2187 PMAC_TYPE_ORIG_IMAC, paddington_features,
2195 { "RackMac1,1", "XServe",
2196 PMAC_TYPE_RACKMAC, rackmac_features,
2199 { "RackMac1,2", "XServe rev. 2",
2200 PMAC_TYPE_RACKMAC, rackmac_features,
2208 { "AAPL,3400/2400", "PowerBook 3400",
2209 PMAC_TYPE_HOOPER, ohare_features,
2210 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2212 { "AAPL,3500", "PowerBook 3500",
2213 PMAC_TYPE_KANGA, ohare_features,
2214 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2216 { "AAPL,PowerBook1998", "PowerBook Wallstreet",
2217 PMAC_TYPE_WALLSTREET, heathrow_laptop_features,
2218 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2220 { "PowerBook1,1", "PowerBook 101 (Lombard)",
2221 PMAC_TYPE_101_PBOOK, paddington_features,
2222 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2224 { "PowerBook2,1", "iBook (first generation)",
2225 PMAC_TYPE_ORIG_IBOOK, core99_features,
2226 PMAC_MB_CAN_SLEEP | PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
2228 { "PowerBook2,2", "iBook FireWire",
2229 PMAC_TYPE_FW_IBOOK, core99_features,
2230 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER |
2231 PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
2233 { "PowerBook3,1", "PowerBook Pismo",
2234 PMAC_TYPE_PISMO, core99_features,
2235 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER |
2236 PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
2238 { "PowerBook3,2", "PowerBook Titanium",
2239 PMAC_TYPE_TITANIUM, core99_features,
2240 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2242 { "PowerBook3,3", "PowerBook Titanium II",
2243 PMAC_TYPE_TITANIUM2, core99_features,
2244 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2246 { "PowerBook3,4", "PowerBook Titanium III",
2247 PMAC_TYPE_TITANIUM3, core99_features,
2248 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2250 { "PowerBook3,5", "PowerBook Titanium IV",
2251 PMAC_TYPE_TITANIUM4, core99_features,
2252 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2254 { "PowerBook4,1", "iBook 2",
2255 PMAC_TYPE_IBOOK2, pangea_features,
2256 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2258 { "PowerBook4,2", "iBook 2",
2259 PMAC_TYPE_IBOOK2, pangea_features,
2260 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2262 { "PowerBook4,3", "iBook 2 rev. 2",
2263 PMAC_TYPE_IBOOK2, pangea_features,
2264 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2266 { "PowerBook5,1", "PowerBook G4 17\"",
2267 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2268 PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2270 { "PowerBook5,2", "PowerBook G4 15\"",
2271 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2272 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2274 { "PowerBook5,3", "PowerBook G4 17\"",
2275 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2276 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2278 { "PowerBook5,4", "PowerBook G4 15\"",
2279 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2280 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2282 { "PowerBook5,5", "PowerBook G4 17\"",
2283 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2284 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2286 { "PowerBook5,6", "PowerBook G4 15\"",
2287 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2288 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2290 { "PowerBook5,7", "PowerBook G4 17\"",
2291 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2292 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2294 { "PowerBook5,8", "PowerBook G4 15\"",
2295 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2296 PMAC_MB_MAY_SLEEP | PMAC_MB_MOBILE,
2298 { "PowerBook5,9", "PowerBook G4 17\"",
2299 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2300 PMAC_MB_MAY_SLEEP | PMAC_MB_MOBILE,
2302 { "PowerBook6,1", "PowerBook G4 12\"",
2303 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2304 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2306 { "PowerBook6,2", "PowerBook G4",
2307 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2308 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2310 { "PowerBook6,3", "iBook G4",
2311 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2312 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2314 { "PowerBook6,4", "PowerBook G4 12\"",
2315 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2316 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2318 { "PowerBook6,5", "iBook G4",
2319 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2320 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2322 { "PowerBook6,7", "iBook G4",
2323 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2324 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2326 { "PowerBook6,8", "PowerBook G4 12\"",
2327 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2328 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2330 #else /* CONFIG_PPC64 */
2331 { "PowerMac7,2", "PowerMac G5",
2332 PMAC_TYPE_POWERMAC_G5, g5_features,
2336 { "PowerMac7,3", "PowerMac G5",
2337 PMAC_TYPE_POWERMAC_G5, g5_features,
2340 { "PowerMac8,1", "iMac G5",
2341 PMAC_TYPE_IMAC_G5, g5_features,
2344 { "PowerMac9,1", "PowerMac G5",
2345 PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
2348 { "PowerMac11,2", "PowerMac G5 Dual Core",
2349 PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
2352 { "PowerMac12,1", "iMac G5 (iSight)",
2353 PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
2356 { "RackMac3,1", "XServe G5",
2357 PMAC_TYPE_XSERVE_G5, g5_features,
2360 #endif /* CONFIG_PPC64 */
2361 #endif /* CONFIG_PPC64 */
2365 * The toplevel feature_call callback
2367 long pmac_do_feature_call(unsigned int selector, ...)
2369 struct device_node *node;
2372 feature_call func = NULL;
2375 if (pmac_mb.features)
2376 for (i=0; pmac_mb.features[i].function; i++)
2377 if (pmac_mb.features[i].selector == selector) {
2378 func = pmac_mb.features[i].function;
2382 for (i=0; any_features[i].function; i++)
2383 if (any_features[i].selector == selector) {
2384 func = any_features[i].function;
2390 va_start(args, selector);
2391 node = (struct device_node*)va_arg(args, void*);
2392 param = va_arg(args, long);
2393 value = va_arg(args, long);
2396 return func(node, param, value);
2399 static int __init probe_motherboard(void)
2402 struct macio_chip *macio = &macio_chips[0];
2403 const char *model = NULL;
2404 struct device_node *dt;
2407 /* Lookup known motherboard type in device-tree. First try an
2408 * exact match on the "model" property, then try a "compatible"
2409 * match is none is found.
2411 dt = of_find_node_by_name(NULL, "device-tree");
2413 model = of_get_property(dt, "model", NULL);
2414 for(i=0; model && i<ARRAY_SIZE(pmac_mb_defs); i++) {
2415 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
2416 pmac_mb = pmac_mb_defs[i];
2420 for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) {
2421 if (of_machine_is_compatible(pmac_mb_defs[i].model_string)) {
2422 pmac_mb = pmac_mb_defs[i];
2427 /* Fallback to selection depending on mac-io chip type */
2428 switch(macio->type) {
2429 #ifndef CONFIG_PPC64
2430 case macio_grand_central:
2431 pmac_mb.model_id = PMAC_TYPE_PSURGE;
2432 pmac_mb.model_name = "Unknown PowerSurge";
2435 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_OHARE;
2436 pmac_mb.model_name = "Unknown OHare-based";
2438 case macio_heathrow:
2439 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_HEATHROW;
2440 pmac_mb.model_name = "Unknown Heathrow-based";
2441 pmac_mb.features = heathrow_desktop_features;
2443 case macio_paddington:
2444 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PADDINGTON;
2445 pmac_mb.model_name = "Unknown Paddington-based";
2446 pmac_mb.features = paddington_features;
2448 case macio_keylargo:
2449 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_CORE99;
2450 pmac_mb.model_name = "Unknown Keylargo-based";
2451 pmac_mb.features = core99_features;
2454 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PANGEA;
2455 pmac_mb.model_name = "Unknown Pangea-based";
2456 pmac_mb.features = pangea_features;
2458 case macio_intrepid:
2459 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_INTREPID;
2460 pmac_mb.model_name = "Unknown Intrepid-based";
2461 pmac_mb.features = intrepid_features;
2463 #else /* CONFIG_PPC64 */
2464 case macio_keylargo2:
2465 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_K2;
2466 pmac_mb.model_name = "Unknown K2-based";
2467 pmac_mb.features = g5_features;
2470 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_SHASTA;
2471 pmac_mb.model_name = "Unknown Shasta-based";
2472 pmac_mb.features = g5_features;
2474 #endif /* CONFIG_PPC64 */
2480 #ifndef CONFIG_PPC64
2481 /* Fixup Hooper vs. Comet */
2482 if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
2483 u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
2488 /* Here, I used to disable the media-bay on comet. It
2489 * appears this is wrong, the floppy connector is actually
2490 * a kind of media-bay and works with the current driver.
2492 if (__raw_readl(mach_id_ptr) & 0x20000000UL)
2493 pmac_mb.model_id = PMAC_TYPE_COMET;
2494 iounmap(mach_id_ptr);
2497 /* Set default value of powersave_nap on machines that support it.
2498 * It appears that uninorth rev 3 has a problem with it, we don't
2499 * enable it on those. In theory, the flush-on-lock property is
2500 * supposed to be set when not supported, but I'm not very confident
2501 * that all Apple OF revs did it properly, I do it the paranoid way.
2503 if (uninorth_base && uninorth_rev > 3) {
2504 struct device_node *np;
2506 for_each_of_cpu_node(np) {
2509 /* Nap mode not supported on SMP */
2510 if (of_get_property(np, "flush-on-lock", NULL) ||
2522 printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
2524 /* On CPUs that support it (750FX), lowspeed by default during
2527 powersave_lowspeed = 1;
2529 #else /* CONFIG_PPC64 */
2531 #endif /* CONFIG_PPC64 */
2533 /* Check for "mobile" machine */
2534 if (model && (strncmp(model, "PowerBook", 9) == 0
2535 || strncmp(model, "iBook", 5) == 0))
2536 pmac_mb.board_flags |= PMAC_MB_MOBILE;
2539 printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name);
2545 /* Initialize the Core99 UniNorth host bridge and memory controller
2547 static void __init probe_uninorth(void)
2550 phys_addr_t address;
2551 unsigned long actrl;
2553 /* Locate core99 Uni-N */
2554 uninorth_node = of_find_node_by_name(NULL, "uni-n");
2558 if (uninorth_node == NULL) {
2559 uninorth_node = of_find_node_by_name(NULL, "u3");
2563 if (uninorth_node == NULL) {
2564 uninorth_node = of_find_node_by_name(NULL, "u4");
2567 if (uninorth_node == NULL) {
2572 addrp = of_get_property(uninorth_node, "reg", NULL);
2575 address = of_translate_address(uninorth_node, addrp);
2578 uninorth_base = ioremap(address, 0x40000);
2579 if (uninorth_base == NULL)
2581 uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
2582 if (uninorth_maj == 3 || uninorth_maj == 4) {
2583 u3_ht_base = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
2584 if (u3_ht_base == NULL) {
2585 iounmap(uninorth_base);
2590 printk(KERN_INFO "Found %s memory controller & host bridge"
2591 " @ 0x%08x revision: 0x%02x\n", uninorth_maj == 3 ? "U3" :
2592 uninorth_maj == 4 ? "U4" : "UniNorth",
2593 (unsigned int)address, uninorth_rev);
2594 printk(KERN_INFO "Mapped at 0x%08lx\n", (unsigned long)uninorth_base);
2596 /* Set the arbitrer QAck delay according to what Apple does
2598 if (uninorth_rev < 0x11) {
2599 actrl = UN_IN(UNI_N_ARB_CTRL) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK;
2600 actrl |= ((uninorth_rev < 3) ? UNI_N_ARB_CTRL_QACK_DELAY105 :
2601 UNI_N_ARB_CTRL_QACK_DELAY) <<
2602 UNI_N_ARB_CTRL_QACK_DELAY_SHIFT;
2603 UN_OUT(UNI_N_ARB_CTRL, actrl);
2606 /* Some more magic as done by them in recent MacOS X on UniNorth
2607 * revs 1.5 to 2.O and Pangea. Seem to toggle the UniN Maxbus/PCI
2610 if ((uninorth_rev >= 0x11 && uninorth_rev <= 0x24) ||
2611 uninorth_rev == 0xc0)
2612 UN_OUT(0x2160, UN_IN(0x2160) & 0x00ffffff);
2615 static void __init probe_one_macio(const char *name, const char *compat, int type)
2617 struct device_node* node;
2619 volatile u32 __iomem *base;
2620 const u32 *addrp, *revp;
2624 for_each_node_by_name(node, name) {
2627 if (of_device_is_compatible(node, compat))
2632 for(i=0; i<MAX_MACIO_CHIPS; i++) {
2633 if (!macio_chips[i].of_node)
2635 if (macio_chips[i].of_node == node)
2639 if (i >= MAX_MACIO_CHIPS) {
2640 printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
2641 printk(KERN_ERR "pmac_feature: %pOF skipped\n", node);
2644 addrp = of_get_pci_address(node, 0, &size, NULL);
2645 if (addrp == NULL) {
2646 printk(KERN_ERR "pmac_feature: %pOF: can't find base !\n",
2650 addr = of_translate_address(node, addrp);
2652 printk(KERN_ERR "pmac_feature: %pOF, can't translate base !\n",
2656 base = ioremap(addr, (unsigned long)size);
2658 printk(KERN_ERR "pmac_feature: %pOF, can't map mac-io chip !\n",
2662 if (type == macio_keylargo || type == macio_keylargo2) {
2663 const u32 *did = of_get_property(node, "device-id", NULL);
2664 if (*did == 0x00000025)
2665 type = macio_pangea;
2666 if (*did == 0x0000003e)
2667 type = macio_intrepid;
2668 if (*did == 0x0000004f)
2669 type = macio_shasta;
2671 macio_chips[i].of_node = node;
2672 macio_chips[i].type = type;
2673 macio_chips[i].base = base;
2674 macio_chips[i].flags = MACIO_FLAG_SCCA_ON | MACIO_FLAG_SCCB_ON;
2675 macio_chips[i].name = macio_names[type];
2676 revp = of_get_property(node, "revision-id", NULL);
2678 macio_chips[i].rev = *revp;
2679 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
2680 macio_names[type], macio_chips[i].rev, macio_chips[i].base);
2686 /* Warning, ordering is important */
2687 probe_one_macio("gc", NULL, macio_grand_central);
2688 probe_one_macio("ohare", NULL, macio_ohare);
2689 probe_one_macio("pci106b,7", NULL, macio_ohareII);
2690 probe_one_macio("mac-io", "keylargo", macio_keylargo);
2691 probe_one_macio("mac-io", "paddington", macio_paddington);
2692 probe_one_macio("mac-io", "gatwick", macio_gatwick);
2693 probe_one_macio("mac-io", "heathrow", macio_heathrow);
2694 probe_one_macio("mac-io", "K2-Keylargo", macio_keylargo2);
2696 /* Make sure the "main" macio chip appear first */
2697 if (macio_chips[0].type == macio_gatwick
2698 && macio_chips[1].type == macio_heathrow) {
2699 struct macio_chip temp = macio_chips[0];
2700 macio_chips[0] = macio_chips[1];
2701 macio_chips[1] = temp;
2703 if (macio_chips[0].type == macio_ohareII
2704 && macio_chips[1].type == macio_ohare) {
2705 struct macio_chip temp = macio_chips[0];
2706 macio_chips[0] = macio_chips[1];
2707 macio_chips[1] = temp;
2709 macio_chips[0].lbus.index = 0;
2710 macio_chips[1].lbus.index = 1;
2712 return (macio_chips[0].of_node == NULL) ? -ENODEV : 0;
2716 initial_serial_shutdown(struct device_node *np)
2719 const struct slot_names_prop {
2724 int port_type = PMAC_SCC_ASYNC;
2727 slots = of_get_property(np, "slot-names", &len);
2728 conn = of_get_property(np, "AAPL,connector", &len);
2729 if (conn && (strcmp(conn, "infrared") == 0))
2730 port_type = PMAC_SCC_IRDA;
2731 else if (of_device_is_compatible(np, "cobalt"))
2733 else if (slots && slots->count > 0) {
2734 if (strcmp(slots->name, "IrDA") == 0)
2735 port_type = PMAC_SCC_IRDA;
2736 else if (strcmp(slots->name, "Modem") == 0)
2740 pmac_call_feature(PMAC_FTR_MODEM_ENABLE, np, 0, 0);
2741 pmac_call_feature(PMAC_FTR_SCC_ENABLE, np, port_type, 0);
2745 set_initial_features(void)
2747 struct device_node *np;
2749 /* That hack appears to be necessary for some StarMax motherboards
2750 * but I'm not too sure it was audited for side-effects on other
2751 * ohare based machines...
2752 * Since I still have difficulties figuring the right way to
2753 * differentiate them all and since that hack was there for a long
2754 * time, I'll keep it around
2756 if (macio_chips[0].type == macio_ohare) {
2757 struct macio_chip *macio = &macio_chips[0];
2758 np = of_find_node_by_name(NULL, "via-pmu");
2760 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
2762 MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);
2764 } else if (macio_chips[1].type == macio_ohare) {
2765 struct macio_chip *macio = &macio_chips[1];
2766 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
2770 if (macio_chips[0].type == macio_keylargo2 ||
2771 macio_chips[0].type == macio_shasta) {
2773 /* On SMP machines running UP, we have the second CPU eating
2774 * bus cycles. We need to take it off the bus. This is done
2775 * from pmac_smp for SMP kernels running on one CPU
2777 np = of_find_node_by_type(NULL, "cpu");
2779 np = of_find_node_by_type(np, "cpu");
2781 g5_phy_disable_cpu1();
2784 #endif /* CONFIG_SMP */
2785 /* Enable GMAC for now for PCI probing. It will be disabled
2786 * later on after PCI probe
2788 for_each_node_by_name(np, "ethernet")
2789 if (of_device_is_compatible(np, "K2-GMAC"))
2790 g5_gmac_enable(np, 0, 1);
2792 /* Enable FW before PCI probe. Will be disabled later on
2793 * Note: We should have a batter way to check that we are
2794 * dealing with uninorth internal cell and not a PCI cell
2795 * on the external PCI. The code below works though.
2797 for_each_node_by_name(np, "firewire") {
2798 if (of_device_is_compatible(np, "pci106b,5811")) {
2799 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
2800 g5_fw_enable(np, 0, 1);
2804 #else /* CONFIG_PPC64 */
2806 if (macio_chips[0].type == macio_keylargo ||
2807 macio_chips[0].type == macio_pangea ||
2808 macio_chips[0].type == macio_intrepid) {
2809 /* Enable GMAC for now for PCI probing. It will be disabled
2810 * later on after PCI probe
2812 for_each_node_by_name(np, "ethernet") {
2814 && of_device_is_compatible(np->parent, "uni-north")
2815 && of_device_is_compatible(np, "gmac"))
2816 core99_gmac_enable(np, 0, 1);
2819 /* Enable FW before PCI probe. Will be disabled later on
2820 * Note: We should have a batter way to check that we are
2821 * dealing with uninorth internal cell and not a PCI cell
2822 * on the external PCI. The code below works though.
2824 for_each_node_by_name(np, "firewire") {
2826 && of_device_is_compatible(np->parent, "uni-north")
2827 && (of_device_is_compatible(np, "pci106b,18") ||
2828 of_device_is_compatible(np, "pci106b,30") ||
2829 of_device_is_compatible(np, "pci11c1,5811"))) {
2830 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
2831 core99_firewire_enable(np, 0, 1);
2835 /* Enable ATA-100 before PCI probe. */
2836 for_each_node_by_name(np, "ata-6") {
2838 && of_device_is_compatible(np->parent, "uni-north")
2839 && of_device_is_compatible(np, "kauai-ata")) {
2840 core99_ata100_enable(np, 1);
2844 /* Switch airport off */
2845 for_each_node_by_name(np, "radio") {
2846 if (np->parent == macio_chips[0].of_node) {
2847 macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON;
2848 core99_airport_enable(np, 0, 0);
2853 /* On all machines that support sound PM, switch sound off */
2854 if (macio_chips[0].of_node)
2855 pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE,
2856 macio_chips[0].of_node, 0, 0);
2858 /* While on some desktop G3s, we turn it back on */
2859 if (macio_chips[0].of_node && macio_chips[0].type == macio_heathrow
2860 && (pmac_mb.model_id == PMAC_TYPE_GOSSAMER ||
2861 pmac_mb.model_id == PMAC_TYPE_SILK)) {
2862 struct macio_chip *macio = &macio_chips[0];
2863 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
2864 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
2867 #endif /* CONFIG_PPC64 */
2869 /* On all machines, switch modem & serial ports off */
2870 for_each_node_by_name(np, "ch-a")
2871 initial_serial_shutdown(np);
2872 for_each_node_by_name(np, "ch-b")
2873 initial_serial_shutdown(np);
2877 pmac_feature_init(void)
2879 /* Detect the UniNorth memory controller */
2882 /* Probe mac-io controllers */
2883 if (probe_macios()) {
2884 printk(KERN_WARNING "No mac-io chip found\n");
2888 /* Probe machine type */
2889 if (probe_motherboard())
2890 printk(KERN_WARNING "Unknown PowerMac !\n");
2892 /* Set some initial features (turn off some chips that will
2893 * be later turned on)
2895 set_initial_features();
2899 static void dump_HT_speeds(char *name, u32 cfg, u32 frq)
2901 int freqs[16] = { 200,300,400,500,600,800,1000,0,0,0,0,0,0,0,0,0 };
2902 int bits[8] = { 8,16,0,32,2,4,0,0 };
2903 int freq = (frq >> 8) & 0xf;
2905 if (freqs[freq] == 0)
2906 printk("%s: Unknown HT link frequency %x\n", name, freq);
2908 printk("%s: %d MHz on main link, (%d in / %d out) bits width\n",
2910 bits[(cfg >> 28) & 0x7], bits[(cfg >> 24) & 0x7]);
2913 void __init pmac_check_ht_link(void)
2915 u32 ufreq, freq, ucfg, cfg;
2916 struct device_node *pcix_node;
2917 u8 px_bus, px_devfn;
2918 struct pci_controller *px_hose;
2920 (void)in_be32(u3_ht_base + U3_HT_LINK_COMMAND);
2921 ucfg = cfg = in_be32(u3_ht_base + U3_HT_LINK_CONFIG);
2922 ufreq = freq = in_be32(u3_ht_base + U3_HT_LINK_FREQ);
2923 dump_HT_speeds("U3 HyperTransport", cfg, freq);
2925 pcix_node = of_find_compatible_node(NULL, "pci", "pci-x");
2926 if (pcix_node == NULL) {
2927 printk("No PCI-X bridge found\n");
2930 if (pci_device_from_OF_node(pcix_node, &px_bus, &px_devfn) != 0) {
2931 printk("PCI-X bridge found but not matched to pci\n");
2934 px_hose = pci_find_hose_for_OF_device(pcix_node);
2935 if (px_hose == NULL) {
2936 printk("PCI-X bridge found but not matched to host\n");
2939 early_read_config_dword(px_hose, px_bus, px_devfn, 0xc4, &cfg);
2940 early_read_config_dword(px_hose, px_bus, px_devfn, 0xcc, &freq);
2941 dump_HT_speeds("PCI-X HT Uplink", cfg, freq);
2942 early_read_config_dword(px_hose, px_bus, px_devfn, 0xc8, &cfg);
2943 early_read_config_dword(px_hose, px_bus, px_devfn, 0xd0, &freq);
2944 dump_HT_speeds("PCI-X HT Downlink", cfg, freq);
2949 * Early video resume hook
2952 static void (*pmac_early_vresume_proc)(void *data);
2953 static void *pmac_early_vresume_data;
2955 void pmac_set_early_video_resume(void (*proc)(void *data), void *data)
2957 if (!machine_is(powermac))
2960 pmac_early_vresume_proc = proc;
2961 pmac_early_vresume_data = data;
2964 EXPORT_SYMBOL(pmac_set_early_video_resume);
2966 void pmac_call_early_video_resume(void)
2968 if (pmac_early_vresume_proc)
2969 pmac_early_vresume_proc(pmac_early_vresume_data);
2973 * AGP related suspend/resume code
2976 static struct pci_dev *pmac_agp_bridge;
2977 static int (*pmac_agp_suspend)(struct pci_dev *bridge);
2978 static int (*pmac_agp_resume)(struct pci_dev *bridge);
2980 void pmac_register_agp_pm(struct pci_dev *bridge,
2981 int (*suspend)(struct pci_dev *bridge),
2982 int (*resume)(struct pci_dev *bridge))
2984 if (suspend || resume) {
2985 pmac_agp_bridge = bridge;
2986 pmac_agp_suspend = suspend;
2987 pmac_agp_resume = resume;
2990 if (bridge != pmac_agp_bridge)
2992 pmac_agp_suspend = pmac_agp_resume = NULL;
2995 EXPORT_SYMBOL(pmac_register_agp_pm);
2997 void pmac_suspend_agp_for_card(struct pci_dev *dev)
2999 if (pmac_agp_bridge == NULL || pmac_agp_suspend == NULL)
3001 if (pmac_agp_bridge->bus != dev->bus)
3003 pmac_agp_suspend(pmac_agp_bridge);
3005 EXPORT_SYMBOL(pmac_suspend_agp_for_card);
3007 void pmac_resume_agp_for_card(struct pci_dev *dev)
3009 if (pmac_agp_bridge == NULL || pmac_agp_resume == NULL)
3011 if (pmac_agp_bridge->bus != dev->bus)
3013 pmac_agp_resume(pmac_agp_bridge);
3015 EXPORT_SYMBOL(pmac_resume_agp_for_card);
3017 int pmac_get_uninorth_variant(void)
3019 return uninorth_maj;