2 * Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
3 * Ben. Herrenschmidt (benh@kernel.crashing.org)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
12 * - Replace mdelay with some schedule loop if possible
13 * - Shorten some obfuscated delays on some routines (like modem
15 * - Refcount some clocks (see darwin)
16 * - Split split split...
19 #include <linux/types.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/kernel.h>
23 #include <linux/sched.h>
24 #include <linux/spinlock.h>
25 #include <linux/adb.h>
26 #include <linux/pmu.h>
27 #include <linux/ioport.h>
28 #include <linux/pci.h>
29 #include <asm/sections.h>
30 #include <asm/errno.h>
31 #include <asm/ohare.h>
32 #include <asm/heathrow.h>
33 #include <asm/keylargo.h>
34 #include <asm/uninorth.h>
37 #include <asm/machdep.h>
38 #include <asm/pmac_feature.h>
39 #include <asm/dbdma.h>
40 #include <asm/pci-bridge.h>
41 #include <asm/pmac_low_i2c.h>
46 #define DBG(fmt...) printk(KERN_DEBUG fmt)
52 extern int powersave_lowspeed;
55 extern int powersave_nap;
56 extern struct device_node *k2_skiplist[2];
59 * We use a single global lock to protect accesses. Each driver has
60 * to take care of its own locking
62 DEFINE_SPINLOCK(feature_lock);
64 #define LOCK(flags) spin_lock_irqsave(&feature_lock, flags);
65 #define UNLOCK(flags) spin_unlock_irqrestore(&feature_lock, flags);
69 * Instance of some macio stuffs
71 struct macio_chip macio_chips[MAX_MACIO_CHIPS];
73 struct macio_chip *macio_find(struct device_node *child, int type)
78 for (i=0; i < MAX_MACIO_CHIPS && macio_chips[i].of_node; i++)
79 if (child == macio_chips[i].of_node &&
80 (!type || macio_chips[i].type == type))
81 return &macio_chips[i];
82 child = child->parent;
86 EXPORT_SYMBOL_GPL(macio_find);
88 static const char *macio_names[] =
105 struct device_node *uninorth_node;
106 u32 __iomem *uninorth_base;
108 static u32 uninorth_rev;
109 static int uninorth_maj;
110 static void __iomem *u3_ht_base;
113 * For each motherboard family, we have a table of functions pointers
114 * that handle the various features.
117 typedef long (*feature_call)(struct device_node *node, long param, long value);
119 struct feature_table_entry {
120 unsigned int selector;
121 feature_call function;
126 const char* model_string;
127 const char* model_name;
129 struct feature_table_entry* features;
130 unsigned long board_flags;
132 static struct pmac_mb_def pmac_mb;
135 * Here are the chip specific feature functions
138 static inline int simple_feature_tweak(struct device_node *node, int type,
139 int reg, u32 mask, int value)
141 struct macio_chip* macio;
144 macio = macio_find(node, type);
149 MACIO_BIS(reg, mask);
151 MACIO_BIC(reg, mask);
152 (void)MACIO_IN32(reg);
158 #ifndef CONFIG_POWER4
160 static long ohare_htw_scc_enable(struct device_node *node, long param,
163 struct macio_chip* macio;
164 unsigned long chan_mask;
170 macio = macio_find(node, 0);
173 if (!strcmp(node->name, "ch-a"))
174 chan_mask = MACIO_FLAG_SCCA_ON;
175 else if (!strcmp(node->name, "ch-b"))
176 chan_mask = MACIO_FLAG_SCCB_ON;
180 htw = (macio->type == macio_heathrow || macio->type == macio_paddington
181 || macio->type == macio_gatwick);
182 /* On these machines, the HRW_SCC_TRANS_EN_N bit mustn't be touched */
183 trans = (pmac_mb.model_id != PMAC_TYPE_YOSEMITE &&
184 pmac_mb.model_id != PMAC_TYPE_YIKES);
186 #ifdef CONFIG_ADB_PMU
187 if ((param & 0xfff) == PMAC_SCC_IRDA)
189 #endif /* CONFIG_ADB_PMU */
191 fcr = MACIO_IN32(OHARE_FCR);
192 /* Check if scc cell need enabling */
193 if (!(fcr & OH_SCC_ENABLE)) {
194 fcr |= OH_SCC_ENABLE;
196 /* Side effect: this will also power up the
197 * modem, but it's too messy to figure out on which
198 * ports this controls the tranceiver and on which
199 * it controls the modem
202 fcr &= ~HRW_SCC_TRANS_EN_N;
203 MACIO_OUT32(OHARE_FCR, fcr);
204 fcr |= (rmask = HRW_RESET_SCC);
205 MACIO_OUT32(OHARE_FCR, fcr);
207 fcr |= (rmask = OH_SCC_RESET);
208 MACIO_OUT32(OHARE_FCR, fcr);
211 (void)MACIO_IN32(OHARE_FCR);
215 MACIO_OUT32(OHARE_FCR, fcr);
217 if (chan_mask & MACIO_FLAG_SCCA_ON)
219 if (chan_mask & MACIO_FLAG_SCCB_ON)
221 MACIO_OUT32(OHARE_FCR, fcr);
222 macio->flags |= chan_mask;
224 if (param & PMAC_SCC_FLAG_XMON)
225 macio->flags |= MACIO_FLAG_SCC_LOCKED;
227 if (macio->flags & MACIO_FLAG_SCC_LOCKED)
230 fcr = MACIO_IN32(OHARE_FCR);
231 if (chan_mask & MACIO_FLAG_SCCA_ON)
233 if (chan_mask & MACIO_FLAG_SCCB_ON)
235 MACIO_OUT32(OHARE_FCR, fcr);
236 if ((fcr & (OH_SCCA_IO | OH_SCCB_IO)) == 0) {
237 fcr &= ~OH_SCC_ENABLE;
239 fcr |= HRW_SCC_TRANS_EN_N;
240 MACIO_OUT32(OHARE_FCR, fcr);
242 macio->flags &= ~(chan_mask);
245 #ifdef CONFIG_ADB_PMU
246 if ((param & 0xfff) == PMAC_SCC_IRDA)
248 #endif /* CONFIG_ADB_PMU */
253 static long ohare_floppy_enable(struct device_node *node, long param,
256 return simple_feature_tweak(node, macio_ohare,
257 OHARE_FCR, OH_FLOPPY_ENABLE, value);
260 static long ohare_mesh_enable(struct device_node *node, long param, long value)
262 return simple_feature_tweak(node, macio_ohare,
263 OHARE_FCR, OH_MESH_ENABLE, value);
266 static long ohare_ide_enable(struct device_node *node, long param, long value)
270 /* For some reason, setting the bit in set_initial_features()
271 * doesn't stick. I'm still investigating... --BenH.
274 simple_feature_tweak(node, macio_ohare,
275 OHARE_FCR, OH_IOBUS_ENABLE, 1);
276 return simple_feature_tweak(node, macio_ohare,
277 OHARE_FCR, OH_IDE0_ENABLE, value);
279 return simple_feature_tweak(node, macio_ohare,
280 OHARE_FCR, OH_BAY_IDE_ENABLE, value);
286 static long ohare_ide_reset(struct device_node *node, long param, long value)
290 return simple_feature_tweak(node, macio_ohare,
291 OHARE_FCR, OH_IDE0_RESET_N, !value);
293 return simple_feature_tweak(node, macio_ohare,
294 OHARE_FCR, OH_IDE1_RESET_N, !value);
300 static long ohare_sleep_state(struct device_node *node, long param, long value)
302 struct macio_chip* macio = &macio_chips[0];
304 if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
307 MACIO_BIC(OHARE_FCR, OH_IOBUS_ENABLE);
308 } else if (value == 0) {
309 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
315 static long heathrow_modem_enable(struct device_node *node, long param,
318 struct macio_chip* macio;
322 macio = macio_find(node, macio_unknown);
325 gpio = MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1;
328 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio);
330 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
333 if (pmac_mb.model_id != PMAC_TYPE_YOSEMITE &&
334 pmac_mb.model_id != PMAC_TYPE_YIKES) {
337 MACIO_BIC(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
339 MACIO_BIS(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
341 (void)MACIO_IN32(HEATHROW_FCR);
346 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1);
347 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
348 UNLOCK(flags); mdelay(250); LOCK(flags);
349 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio);
350 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
351 UNLOCK(flags); mdelay(250); LOCK(flags);
352 MACIO_OUT8(HRW_GPIO_MODEM_RESET, gpio | 1);
353 (void)MACIO_IN8(HRW_GPIO_MODEM_RESET);
354 UNLOCK(flags); mdelay(250);
359 static long heathrow_floppy_enable(struct device_node *node, long param,
362 return simple_feature_tweak(node, macio_unknown,
364 HRW_SWIM_ENABLE|HRW_BAY_FLOPPY_ENABLE,
368 static long heathrow_mesh_enable(struct device_node *node, long param,
371 struct macio_chip* macio;
374 macio = macio_find(node, macio_unknown);
378 /* Set clear mesh cell enable */
380 MACIO_BIS(HEATHROW_FCR, HRW_MESH_ENABLE);
382 MACIO_BIC(HEATHROW_FCR, HRW_MESH_ENABLE);
383 (void)MACIO_IN32(HEATHROW_FCR);
385 /* Set/Clear termination power */
387 MACIO_BIC(HEATHROW_MBCR, 0x04000000);
389 MACIO_BIS(HEATHROW_MBCR, 0x04000000);
390 (void)MACIO_IN32(HEATHROW_MBCR);
397 static long heathrow_ide_enable(struct device_node *node, long param,
402 return simple_feature_tweak(node, macio_unknown,
403 HEATHROW_FCR, HRW_IDE0_ENABLE, value);
405 return simple_feature_tweak(node, macio_unknown,
406 HEATHROW_FCR, HRW_BAY_IDE_ENABLE, value);
412 static long heathrow_ide_reset(struct device_node *node, long param,
417 return simple_feature_tweak(node, macio_unknown,
418 HEATHROW_FCR, HRW_IDE0_RESET_N, !value);
420 return simple_feature_tweak(node, macio_unknown,
421 HEATHROW_FCR, HRW_IDE1_RESET_N, !value);
427 static long heathrow_bmac_enable(struct device_node *node, long param,
430 struct macio_chip* macio;
433 macio = macio_find(node, 0);
438 MACIO_BIS(HEATHROW_FCR, HRW_BMAC_IO_ENABLE);
439 MACIO_BIS(HEATHROW_FCR, HRW_BMAC_RESET);
441 (void)MACIO_IN32(HEATHROW_FCR);
444 MACIO_BIC(HEATHROW_FCR, HRW_BMAC_RESET);
446 (void)MACIO_IN32(HEATHROW_FCR);
450 MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE);
456 static long heathrow_sound_enable(struct device_node *node, long param,
459 struct macio_chip* macio;
462 /* B&W G3 and Yikes don't support that properly (the
463 * sound appear to never come back after beeing shut down).
465 if (pmac_mb.model_id == PMAC_TYPE_YOSEMITE ||
466 pmac_mb.model_id == PMAC_TYPE_YIKES)
469 macio = macio_find(node, 0);
474 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
475 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
477 (void)MACIO_IN32(HEATHROW_FCR);
480 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N);
481 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
487 static u32 save_fcr[6];
488 static u32 save_mbcr;
489 static struct dbdma_regs save_dbdma[13];
490 static struct dbdma_regs save_alt_dbdma[13];
492 static void dbdma_save(struct macio_chip *macio, struct dbdma_regs *save)
496 /* Save state & config of DBDMA channels */
497 for (i = 0; i < 13; i++) {
498 volatile struct dbdma_regs __iomem * chan = (void __iomem *)
499 (macio->base + ((0x8000+i*0x100)>>2));
500 save[i].cmdptr_hi = in_le32(&chan->cmdptr_hi);
501 save[i].cmdptr = in_le32(&chan->cmdptr);
502 save[i].intr_sel = in_le32(&chan->intr_sel);
503 save[i].br_sel = in_le32(&chan->br_sel);
504 save[i].wait_sel = in_le32(&chan->wait_sel);
508 static void dbdma_restore(struct macio_chip *macio, struct dbdma_regs *save)
512 /* Save state & config of DBDMA channels */
513 for (i = 0; i < 13; i++) {
514 volatile struct dbdma_regs __iomem * chan = (void __iomem *)
515 (macio->base + ((0x8000+i*0x100)>>2));
516 out_le32(&chan->control, (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);
517 while (in_le32(&chan->status) & ACTIVE)
519 out_le32(&chan->cmdptr_hi, save[i].cmdptr_hi);
520 out_le32(&chan->cmdptr, save[i].cmdptr);
521 out_le32(&chan->intr_sel, save[i].intr_sel);
522 out_le32(&chan->br_sel, save[i].br_sel);
523 out_le32(&chan->wait_sel, save[i].wait_sel);
527 static void heathrow_sleep(struct macio_chip *macio, int secondary)
530 dbdma_save(macio, save_alt_dbdma);
531 save_fcr[2] = MACIO_IN32(0x38);
532 save_fcr[3] = MACIO_IN32(0x3c);
534 dbdma_save(macio, save_dbdma);
535 save_fcr[0] = MACIO_IN32(0x38);
536 save_fcr[1] = MACIO_IN32(0x3c);
537 save_mbcr = MACIO_IN32(0x34);
538 /* Make sure sound is shut down */
539 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_POWER_N);
540 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
541 /* This seems to be necessary as well or the fan
542 * keeps coming up and battery drains fast */
543 MACIO_BIC(HEATHROW_FCR, HRW_IOBUS_ENABLE);
544 MACIO_BIC(HEATHROW_FCR, HRW_IDE0_RESET_N);
545 /* Make sure eth is down even if module or sleep
546 * won't work properly */
547 MACIO_BIC(HEATHROW_FCR, HRW_BMAC_IO_ENABLE | HRW_BMAC_RESET);
549 /* Make sure modem is shut down */
550 MACIO_OUT8(HRW_GPIO_MODEM_RESET,
551 MACIO_IN8(HRW_GPIO_MODEM_RESET) & ~1);
552 MACIO_BIS(HEATHROW_FCR, HRW_SCC_TRANS_EN_N);
553 MACIO_BIC(HEATHROW_FCR, OH_SCCA_IO|OH_SCCB_IO|HRW_SCC_ENABLE);
555 /* Let things settle */
556 (void)MACIO_IN32(HEATHROW_FCR);
559 static void heathrow_wakeup(struct macio_chip *macio, int secondary)
562 MACIO_OUT32(0x38, save_fcr[2]);
563 (void)MACIO_IN32(0x38);
565 MACIO_OUT32(0x3c, save_fcr[3]);
566 (void)MACIO_IN32(0x38);
568 dbdma_restore(macio, save_alt_dbdma);
570 MACIO_OUT32(0x38, save_fcr[0] | HRW_IOBUS_ENABLE);
571 (void)MACIO_IN32(0x38);
573 MACIO_OUT32(0x3c, save_fcr[1]);
574 (void)MACIO_IN32(0x38);
576 MACIO_OUT32(0x34, save_mbcr);
577 (void)MACIO_IN32(0x38);
579 dbdma_restore(macio, save_dbdma);
583 static long heathrow_sleep_state(struct device_node *node, long param,
586 if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
589 if (macio_chips[1].type == macio_gatwick)
590 heathrow_sleep(&macio_chips[0], 1);
591 heathrow_sleep(&macio_chips[0], 0);
592 } else if (value == 0) {
593 heathrow_wakeup(&macio_chips[0], 0);
594 if (macio_chips[1].type == macio_gatwick)
595 heathrow_wakeup(&macio_chips[0], 1);
600 static long core99_scc_enable(struct device_node *node, long param, long value)
602 struct macio_chip* macio;
604 unsigned long chan_mask;
607 macio = macio_find(node, 0);
610 if (!strcmp(node->name, "ch-a"))
611 chan_mask = MACIO_FLAG_SCCA_ON;
612 else if (!strcmp(node->name, "ch-b"))
613 chan_mask = MACIO_FLAG_SCCB_ON;
618 int need_reset_scc = 0;
619 int need_reset_irda = 0;
622 fcr = MACIO_IN32(KEYLARGO_FCR0);
623 /* Check if scc cell need enabling */
624 if (!(fcr & KL0_SCC_CELL_ENABLE)) {
625 fcr |= KL0_SCC_CELL_ENABLE;
628 if (chan_mask & MACIO_FLAG_SCCA_ON) {
629 fcr |= KL0_SCCA_ENABLE;
630 /* Don't enable line drivers for I2S modem */
631 if ((param & 0xfff) == PMAC_SCC_I2S1)
632 fcr &= ~KL0_SCC_A_INTF_ENABLE;
634 fcr |= KL0_SCC_A_INTF_ENABLE;
636 if (chan_mask & MACIO_FLAG_SCCB_ON) {
637 fcr |= KL0_SCCB_ENABLE;
638 /* Perform irda specific inits */
639 if ((param & 0xfff) == PMAC_SCC_IRDA) {
640 fcr &= ~KL0_SCC_B_INTF_ENABLE;
641 fcr |= KL0_IRDA_ENABLE;
642 fcr |= KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE;
643 fcr |= KL0_IRDA_SOURCE1_SEL;
644 fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0);
645 fcr &= ~(KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND);
648 fcr |= KL0_SCC_B_INTF_ENABLE;
650 MACIO_OUT32(KEYLARGO_FCR0, fcr);
651 macio->flags |= chan_mask;
652 if (need_reset_scc) {
653 MACIO_BIS(KEYLARGO_FCR0, KL0_SCC_RESET);
654 (void)MACIO_IN32(KEYLARGO_FCR0);
658 MACIO_BIC(KEYLARGO_FCR0, KL0_SCC_RESET);
660 if (need_reset_irda) {
661 MACIO_BIS(KEYLARGO_FCR0, KL0_IRDA_RESET);
662 (void)MACIO_IN32(KEYLARGO_FCR0);
666 MACIO_BIC(KEYLARGO_FCR0, KL0_IRDA_RESET);
669 if (param & PMAC_SCC_FLAG_XMON)
670 macio->flags |= MACIO_FLAG_SCC_LOCKED;
672 if (macio->flags & MACIO_FLAG_SCC_LOCKED)
675 fcr = MACIO_IN32(KEYLARGO_FCR0);
676 if (chan_mask & MACIO_FLAG_SCCA_ON)
677 fcr &= ~KL0_SCCA_ENABLE;
678 if (chan_mask & MACIO_FLAG_SCCB_ON) {
679 fcr &= ~KL0_SCCB_ENABLE;
680 /* Perform irda specific clears */
681 if ((param & 0xfff) == PMAC_SCC_IRDA) {
682 fcr &= ~KL0_IRDA_ENABLE;
683 fcr &= ~(KL0_IRDA_CLK32_ENABLE | KL0_IRDA_CLK19_ENABLE);
684 fcr &= ~(KL0_IRDA_FAST_CONNECT|KL0_IRDA_DEFAULT1|KL0_IRDA_DEFAULT0);
685 fcr &= ~(KL0_IRDA_SOURCE1_SEL|KL0_IRDA_SOURCE2_SEL|KL0_IRDA_HIGH_BAND);
688 MACIO_OUT32(KEYLARGO_FCR0, fcr);
689 if ((fcr & (KL0_SCCA_ENABLE | KL0_SCCB_ENABLE)) == 0) {
690 fcr &= ~KL0_SCC_CELL_ENABLE;
691 MACIO_OUT32(KEYLARGO_FCR0, fcr);
693 macio->flags &= ~(chan_mask);
701 core99_modem_enable(struct device_node *node, long param, long value)
703 struct macio_chip* macio;
707 /* Hack for internal USB modem */
709 if (macio_chips[0].type != macio_keylargo)
711 node = macio_chips[0].of_node;
713 macio = macio_find(node, 0);
716 gpio = MACIO_IN8(KL_GPIO_MODEM_RESET);
717 gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE;
718 gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA;
722 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
724 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
729 MACIO_BIC(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
731 (void)MACIO_IN32(KEYLARGO_FCR2);
734 MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
739 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
740 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
741 UNLOCK(flags); mdelay(250); LOCK(flags);
742 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
743 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
744 UNLOCK(flags); mdelay(250); LOCK(flags);
745 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
746 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
747 UNLOCK(flags); mdelay(250);
753 pangea_modem_enable(struct device_node *node, long param, long value)
755 struct macio_chip* macio;
759 /* Hack for internal USB modem */
761 if (macio_chips[0].type != macio_pangea &&
762 macio_chips[0].type != macio_intrepid)
764 node = macio_chips[0].of_node;
766 macio = macio_find(node, 0);
769 gpio = MACIO_IN8(KL_GPIO_MODEM_RESET);
770 gpio |= KEYLARGO_GPIO_OUTPUT_ENABLE;
771 gpio &= ~KEYLARGO_GPIO_OUTOUT_DATA;
775 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
777 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
782 MACIO_OUT8(KL_GPIO_MODEM_POWER,
783 KEYLARGO_GPIO_OUTPUT_ENABLE);
785 (void)MACIO_IN32(KEYLARGO_FCR2);
788 MACIO_OUT8(KL_GPIO_MODEM_POWER,
789 KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
794 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
795 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
796 UNLOCK(flags); mdelay(250); LOCK(flags);
797 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio);
798 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
799 UNLOCK(flags); mdelay(250); LOCK(flags);
800 MACIO_OUT8(KL_GPIO_MODEM_RESET, gpio | KEYLARGO_GPIO_OUTOUT_DATA);
801 (void)MACIO_IN8(KL_GPIO_MODEM_RESET);
802 UNLOCK(flags); mdelay(250);
808 core99_ata100_enable(struct device_node *node, long value)
811 struct pci_dev *pdev = NULL;
815 if (uninorth_rev < 0x24)
820 UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_ATA100);
822 UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_ATA100);
823 (void)UN_IN(UNI_N_CLOCK_CNTL);
828 if (pci_device_from_OF_node(node, &pbus, &pid) == 0)
829 pdev = pci_find_slot(pbus, pid);
832 rc = pci_enable_device(pdev);
835 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 np = find_path_device("/cpus");
1059 for (np = np->child; np != NULL; np = np->sibling) {
1060 const u32 *num = get_property(np, "reg", NULL);
1061 const u32 *rst = get_property(np, "soft-reset", NULL);
1062 if (num == NULL || rst == NULL)
1064 if (param == *num) {
1069 if (np == NULL || reset_io == 0)
1070 reset_io = dflt_reset_lines[param];
1073 MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
1074 (void)MACIO_IN8(reset_io);
1076 MACIO_OUT8(reset_io, 0);
1077 (void)MACIO_IN8(reset_io);
1082 #endif /* CONFIG_SMP */
1085 core99_usb_enable(struct device_node *node, long param, long value)
1087 struct macio_chip *macio;
1088 unsigned long flags;
1093 macio = &macio_chips[0];
1094 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1095 macio->type != macio_intrepid)
1098 prop = get_property(node, "AAPL,clock-id", NULL);
1101 if (strncmp(prop, "usb0u048", 8) == 0)
1103 else if (strncmp(prop, "usb1u148", 8) == 0)
1105 else if (strncmp(prop, "usb2u248", 8) == 0)
1110 /* Sorry for the brute-force locking, but this is only used during
1111 * sleep and the timing seem to be critical
1117 MACIO_BIC(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
1118 (void)MACIO_IN32(KEYLARGO_FCR0);
1122 MACIO_BIS(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
1123 } else if (number == 2) {
1124 MACIO_BIC(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
1126 (void)MACIO_IN32(KEYLARGO_FCR0);
1129 MACIO_BIS(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
1130 } else if (number == 4) {
1131 MACIO_BIC(KEYLARGO_FCR1, (KL1_USB2_PAD_SUSPEND0 | KL1_USB2_PAD_SUSPEND1));
1133 (void)MACIO_IN32(KEYLARGO_FCR1);
1136 MACIO_BIS(KEYLARGO_FCR1, KL1_USB2_CELL_ENABLE);
1139 reg = MACIO_IN32(KEYLARGO_FCR4);
1140 reg &= ~(KL4_PORT_WAKEUP_ENABLE(number) | KL4_PORT_RESUME_WAKE_EN(number) |
1141 KL4_PORT_CONNECT_WAKE_EN(number) | KL4_PORT_DISCONNECT_WAKE_EN(number));
1142 reg &= ~(KL4_PORT_WAKEUP_ENABLE(number+1) | KL4_PORT_RESUME_WAKE_EN(number+1) |
1143 KL4_PORT_CONNECT_WAKE_EN(number+1) | KL4_PORT_DISCONNECT_WAKE_EN(number+1));
1144 MACIO_OUT32(KEYLARGO_FCR4, reg);
1145 (void)MACIO_IN32(KEYLARGO_FCR4);
1148 reg = MACIO_IN32(KEYLARGO_FCR3);
1149 reg &= ~(KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1150 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0));
1151 reg &= ~(KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1152 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1));
1153 MACIO_OUT32(KEYLARGO_FCR3, reg);
1154 (void)MACIO_IN32(KEYLARGO_FCR3);
1157 if (macio->type == macio_intrepid) {
1158 /* wait for clock stopped bits to clear */
1159 u32 test0 = 0, test1 = 0;
1160 u32 status0, status1;
1166 test0 = UNI_N_CLOCK_STOPPED_USB0;
1167 test1 = UNI_N_CLOCK_STOPPED_USB0PCI;
1170 test0 = UNI_N_CLOCK_STOPPED_USB1;
1171 test1 = UNI_N_CLOCK_STOPPED_USB1PCI;
1174 test0 = UNI_N_CLOCK_STOPPED_USB2;
1175 test1 = UNI_N_CLOCK_STOPPED_USB2PCI;
1179 if (--timeout <= 0) {
1180 printk(KERN_ERR "core99_usb_enable: "
1181 "Timeout waiting for clocks\n");
1185 status0 = UN_IN(UNI_N_CLOCK_STOP_STATUS0);
1186 status1 = UN_IN(UNI_N_CLOCK_STOP_STATUS1);
1187 } while ((status0 & test0) | (status1 & test1));
1193 reg = MACIO_IN32(KEYLARGO_FCR4);
1194 reg |= KL4_PORT_WAKEUP_ENABLE(number) | KL4_PORT_RESUME_WAKE_EN(number) |
1195 KL4_PORT_CONNECT_WAKE_EN(number) | KL4_PORT_DISCONNECT_WAKE_EN(number);
1196 reg |= KL4_PORT_WAKEUP_ENABLE(number+1) | KL4_PORT_RESUME_WAKE_EN(number+1) |
1197 KL4_PORT_CONNECT_WAKE_EN(number+1) | KL4_PORT_DISCONNECT_WAKE_EN(number+1);
1198 MACIO_OUT32(KEYLARGO_FCR4, reg);
1199 (void)MACIO_IN32(KEYLARGO_FCR4);
1202 reg = MACIO_IN32(KEYLARGO_FCR3);
1203 reg |= KL3_IT_PORT_WAKEUP_ENABLE(0) | KL3_IT_PORT_RESUME_WAKE_EN(0) |
1204 KL3_IT_PORT_CONNECT_WAKE_EN(0) | KL3_IT_PORT_DISCONNECT_WAKE_EN(0);
1205 reg |= KL3_IT_PORT_WAKEUP_ENABLE(1) | KL3_IT_PORT_RESUME_WAKE_EN(1) |
1206 KL3_IT_PORT_CONNECT_WAKE_EN(1) | KL3_IT_PORT_DISCONNECT_WAKE_EN(1);
1207 MACIO_OUT32(KEYLARGO_FCR3, reg);
1208 (void)MACIO_IN32(KEYLARGO_FCR3);
1212 if (macio->type != macio_intrepid)
1213 MACIO_BIC(KEYLARGO_FCR0, KL0_USB0_CELL_ENABLE);
1214 (void)MACIO_IN32(KEYLARGO_FCR0);
1216 MACIO_BIS(KEYLARGO_FCR0, (KL0_USB0_PAD_SUSPEND0 | KL0_USB0_PAD_SUSPEND1));
1217 (void)MACIO_IN32(KEYLARGO_FCR0);
1218 } else if (number == 2) {
1219 if (macio->type != macio_intrepid)
1220 MACIO_BIC(KEYLARGO_FCR0, KL0_USB1_CELL_ENABLE);
1221 (void)MACIO_IN32(KEYLARGO_FCR0);
1223 MACIO_BIS(KEYLARGO_FCR0, (KL0_USB1_PAD_SUSPEND0 | KL0_USB1_PAD_SUSPEND1));
1224 (void)MACIO_IN32(KEYLARGO_FCR0);
1225 } else if (number == 4) {
1227 MACIO_BIS(KEYLARGO_FCR1, (KL1_USB2_PAD_SUSPEND0 | KL1_USB2_PAD_SUSPEND1));
1228 (void)MACIO_IN32(KEYLARGO_FCR1);
1238 core99_firewire_enable(struct device_node *node, long param, long value)
1240 unsigned long flags;
1241 struct macio_chip *macio;
1243 macio = &macio_chips[0];
1244 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1245 macio->type != macio_intrepid)
1247 if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED))
1252 UN_BIS(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
1253 (void)UN_IN(UNI_N_CLOCK_CNTL);
1255 UN_BIC(UNI_N_CLOCK_CNTL, UNI_N_CLOCK_CNTL_FW);
1256 (void)UN_IN(UNI_N_CLOCK_CNTL);
1265 core99_firewire_cable_power(struct device_node *node, long param, long value)
1267 unsigned long flags;
1268 struct macio_chip *macio;
1270 /* Trick: we allow NULL node */
1271 if ((pmac_mb.board_flags & PMAC_MB_HAS_FW_POWER) == 0)
1273 macio = &macio_chips[0];
1274 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1275 macio->type != macio_intrepid)
1277 if (!(macio->flags & MACIO_FLAG_FW_SUPPORTED))
1282 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 0);
1283 MACIO_IN8(KL_GPIO_FW_CABLE_POWER);
1286 MACIO_OUT8(KL_GPIO_FW_CABLE_POWER , 4);
1287 MACIO_IN8(KL_GPIO_FW_CABLE_POWER); udelay(10);
1296 intrepid_aack_delay_enable(struct device_node *node, long param, long value)
1298 unsigned long flags;
1300 if (uninorth_rev < 0xd2)
1305 UN_BIS(UNI_N_AACK_DELAY, UNI_N_AACK_DELAY_ENABLE);
1307 UN_BIC(UNI_N_AACK_DELAY, UNI_N_AACK_DELAY_ENABLE);
1314 #endif /* CONFIG_POWER4 */
1317 core99_read_gpio(struct device_node *node, long param, long value)
1319 struct macio_chip *macio = &macio_chips[0];
1321 return MACIO_IN8(param);
1326 core99_write_gpio(struct device_node *node, long param, long value)
1328 struct macio_chip *macio = &macio_chips[0];
1330 MACIO_OUT8(param, (u8)(value & 0xff));
1334 #ifdef CONFIG_POWER4
1335 static long g5_gmac_enable(struct device_node *node, long param, long value)
1337 struct macio_chip *macio = &macio_chips[0];
1338 unsigned long flags;
1345 MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
1347 k2_skiplist[0] = NULL;
1349 k2_skiplist[0] = node;
1351 MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_GMAC_CLK_ENABLE);
1360 static long g5_fw_enable(struct device_node *node, long param, long value)
1362 struct macio_chip *macio = &macio_chips[0];
1363 unsigned long flags;
1370 MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
1372 k2_skiplist[1] = NULL;
1374 k2_skiplist[1] = node;
1376 MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_FW_CLK_ENABLE);
1385 static long g5_mpic_enable(struct device_node *node, long param, long value)
1387 unsigned long flags;
1388 struct device_node *parent = of_get_parent(node);
1393 is_u3 = strcmp(parent->name, "u3") == 0 ||
1394 strcmp(parent->name, "u4") == 0;
1395 of_node_put(parent);
1400 UN_BIS(U3_TOGGLE_REG, U3_MPIC_RESET | U3_MPIC_OUTPUT_ENABLE);
1406 static long g5_eth_phy_reset(struct device_node *node, long param, long value)
1408 struct macio_chip *macio = &macio_chips[0];
1409 struct device_node *phy;
1413 * We must not reset the combo PHYs, only the BCM5221 found in
1416 phy = of_get_next_child(node, NULL);
1419 need_reset = device_is_compatible(phy, "B5221");
1424 /* PHY reset is GPIO 29, not in device-tree unfortunately */
1425 MACIO_OUT8(K2_GPIO_EXTINT_0 + 29,
1426 KEYLARGO_GPIO_OUTPUT_ENABLE | KEYLARGO_GPIO_OUTOUT_DATA);
1427 /* Thankfully, this is now always called at a time when we can
1428 * schedule by sungem.
1431 MACIO_OUT8(K2_GPIO_EXTINT_0 + 29, 0);
1436 static long g5_i2s_enable(struct device_node *node, long param, long value)
1438 /* Very crude implementation for now */
1439 struct macio_chip *macio = &macio_chips[0];
1440 unsigned long flags;
1444 K2_FCR1_I2S0_CELL_ENABLE |
1445 K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE,
1446 KL3_I2S0_CLK18_ENABLE
1448 { KL0_SCC_A_INTF_ENABLE,
1449 K2_FCR1_I2S1_CELL_ENABLE |
1450 K2_FCR1_I2S1_CLK_ENABLE_BIT | K2_FCR1_I2S1_ENABLE,
1451 KL3_I2S1_CLK18_ENABLE
1453 { KL0_SCC_B_INTF_ENABLE,
1454 SH_FCR1_I2S2_CELL_ENABLE |
1455 SH_FCR1_I2S2_CLK_ENABLE_BIT | SH_FCR1_I2S2_ENABLE,
1456 SH_FCR3_I2S2_CLK18_ENABLE
1460 if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
1462 if (strncmp(node->name, "i2s-", 4))
1464 cell = node->name[4] - 'a';
1470 if (macio->type == macio_shasta)
1478 MACIO_BIC(KEYLARGO_FCR0, fcrs[cell][0]);
1479 MACIO_BIS(KEYLARGO_FCR1, fcrs[cell][1]);
1480 MACIO_BIS(KEYLARGO_FCR3, fcrs[cell][2]);
1482 MACIO_BIC(KEYLARGO_FCR3, fcrs[cell][2]);
1483 MACIO_BIC(KEYLARGO_FCR1, fcrs[cell][1]);
1484 MACIO_BIS(KEYLARGO_FCR0, fcrs[cell][0]);
1494 static long g5_reset_cpu(struct device_node *node, long param, long value)
1496 unsigned int reset_io = 0;
1497 unsigned long flags;
1498 struct macio_chip *macio;
1499 struct device_node *np;
1501 macio = &macio_chips[0];
1502 if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
1505 np = find_path_device("/cpus");
1508 for (np = np->child; np != NULL; np = np->sibling) {
1509 const u32 *num = get_property(np, "reg", NULL);
1510 const u32 *rst = get_property(np, "soft-reset", NULL);
1511 if (num == NULL || rst == NULL)
1513 if (param == *num) {
1518 if (np == NULL || reset_io == 0)
1522 MACIO_OUT8(reset_io, KEYLARGO_GPIO_OUTPUT_ENABLE);
1523 (void)MACIO_IN8(reset_io);
1525 MACIO_OUT8(reset_io, 0);
1526 (void)MACIO_IN8(reset_io);
1531 #endif /* CONFIG_SMP */
1534 * This can be called from pmac_smp so isn't static
1536 * This takes the second CPU off the bus on dual CPU machines
1539 void g5_phy_disable_cpu1(void)
1541 if (uninorth_maj == 3)
1542 UN_OUT(U3_API_PHY_CONFIG_1, 0);
1544 #endif /* CONFIG_POWER4 */
1546 #ifndef CONFIG_POWER4
1550 static u32 save_gpio_levels[2];
1551 static u8 save_gpio_extint[KEYLARGO_GPIO_EXTINT_CNT];
1552 static u8 save_gpio_normal[KEYLARGO_GPIO_CNT];
1553 static u32 save_unin_clock_ctl;
1555 static void keylargo_shutdown(struct macio_chip *macio, int sleep_mode)
1561 MACIO_BIS(KEYLARGO_FCR0, KL0_USB_REF_SUSPEND);
1562 (void)MACIO_IN32(KEYLARGO_FCR0);
1566 MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
1567 KL0_SCC_CELL_ENABLE |
1568 KL0_IRDA_ENABLE | KL0_IRDA_CLK32_ENABLE |
1569 KL0_IRDA_CLK19_ENABLE);
1571 MACIO_BIC(KEYLARGO_MBCR, KL_MBCR_MB0_DEV_MASK);
1572 MACIO_BIS(KEYLARGO_MBCR, KL_MBCR_MB0_IDE_ENABLE);
1574 MACIO_BIC(KEYLARGO_FCR1,
1575 KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT |
1576 KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE |
1577 KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
1578 KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
1579 KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
1580 KL1_EIDE0_ENABLE | KL1_EIDE0_RESET_N |
1581 KL1_EIDE1_ENABLE | KL1_EIDE1_RESET_N |
1584 MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
1585 MACIO_BIC(KEYLARGO_FCR2, KL2_IOBUS_ENABLE);
1587 temp = MACIO_IN32(KEYLARGO_FCR3);
1588 if (macio->rev >= 2) {
1589 temp |= KL3_SHUTDOWN_PLL2X;
1591 temp |= KL3_SHUTDOWN_PLL_TOTAL;
1594 temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 |
1595 KL3_SHUTDOWN_PLLKW35;
1597 temp |= KL3_SHUTDOWN_PLLKW12;
1598 temp &= ~(KL3_CLK66_ENABLE | KL3_CLK49_ENABLE | KL3_CLK45_ENABLE
1599 | KL3_CLK31_ENABLE | KL3_I2S1_CLK18_ENABLE | KL3_I2S0_CLK18_ENABLE);
1601 temp &= ~(KL3_TIMER_CLK18_ENABLE | KL3_VIA_CLK16_ENABLE);
1602 MACIO_OUT32(KEYLARGO_FCR3, temp);
1604 /* Flush posted writes & wait a bit */
1605 (void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
1608 static void pangea_shutdown(struct macio_chip *macio, int sleep_mode)
1612 MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
1613 KL0_SCC_CELL_ENABLE |
1614 KL0_USB0_CELL_ENABLE | KL0_USB1_CELL_ENABLE);
1616 MACIO_BIC(KEYLARGO_FCR1,
1617 KL1_AUDIO_SEL_22MCLK | KL1_AUDIO_CLK_ENABLE_BIT |
1618 KL1_AUDIO_CLK_OUT_ENABLE | KL1_AUDIO_CELL_ENABLE |
1619 KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
1620 KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
1621 KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
1623 if (pmac_mb.board_flags & PMAC_MB_MOBILE)
1624 MACIO_BIC(KEYLARGO_FCR1, KL1_UIDE_RESET_N);
1626 MACIO_BIS(KEYLARGO_FCR2, KL2_ALT_DATA_OUT);
1628 temp = MACIO_IN32(KEYLARGO_FCR3);
1629 temp |= KL3_SHUTDOWN_PLLKW6 | KL3_SHUTDOWN_PLLKW4 |
1630 KL3_SHUTDOWN_PLLKW35;
1631 temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE | KL3_CLK31_ENABLE
1632 | KL3_I2S0_CLK18_ENABLE | KL3_I2S1_CLK18_ENABLE);
1634 temp &= ~(KL3_VIA_CLK16_ENABLE | KL3_TIMER_CLK18_ENABLE);
1635 MACIO_OUT32(KEYLARGO_FCR3, temp);
1637 /* Flush posted writes & wait a bit */
1638 (void)MACIO_IN32(KEYLARGO_FCR0); mdelay(1);
1641 static void intrepid_shutdown(struct macio_chip *macio, int sleep_mode)
1645 MACIO_BIC(KEYLARGO_FCR0,KL0_SCCA_ENABLE | KL0_SCCB_ENABLE |
1646 KL0_SCC_CELL_ENABLE);
1648 MACIO_BIC(KEYLARGO_FCR1,
1649 KL1_I2S0_CELL_ENABLE | KL1_I2S0_CLK_ENABLE_BIT |
1650 KL1_I2S0_ENABLE | KL1_I2S1_CELL_ENABLE |
1651 KL1_I2S1_CLK_ENABLE_BIT | KL1_I2S1_ENABLE |
1653 if (pmac_mb.board_flags & PMAC_MB_MOBILE)
1654 MACIO_BIC(KEYLARGO_FCR1, KL1_UIDE_RESET_N);
1656 temp = MACIO_IN32(KEYLARGO_FCR3);
1657 temp &= ~(KL3_CLK49_ENABLE | KL3_CLK45_ENABLE |
1658 KL3_I2S1_CLK18_ENABLE | KL3_I2S0_CLK18_ENABLE);
1660 temp &= ~(KL3_TIMER_CLK18_ENABLE | KL3_IT_VIA_CLK32_ENABLE);
1661 MACIO_OUT32(KEYLARGO_FCR3, temp);
1663 /* Flush posted writes & wait a bit */
1664 (void)MACIO_IN32(KEYLARGO_FCR0);
1672 struct macio_chip *macio;
1675 macio = &macio_chips[0];
1676 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1677 macio->type != macio_intrepid)
1680 /* We power off the wireless slot in case it was not done
1681 * by the driver. We don't power it on automatically however
1683 if (macio->flags & MACIO_FLAG_AIRPORT_ON)
1684 core99_airport_enable(macio->of_node, 0, 0);
1686 /* We power off the FW cable. Should be done by the driver... */
1687 if (macio->flags & MACIO_FLAG_FW_SUPPORTED) {
1688 core99_firewire_enable(NULL, 0, 0);
1689 core99_firewire_cable_power(NULL, 0, 0);
1692 /* We make sure int. modem is off (in case driver lost it) */
1693 if (macio->type == macio_keylargo)
1694 core99_modem_enable(macio->of_node, 0, 0);
1696 pangea_modem_enable(macio->of_node, 0, 0);
1698 /* We make sure the sound is off as well */
1699 core99_sound_chip_enable(macio->of_node, 0, 0);
1702 * Save various bits of KeyLargo
1705 /* Save the state of the various GPIOs */
1706 save_gpio_levels[0] = MACIO_IN32(KEYLARGO_GPIO_LEVELS0);
1707 save_gpio_levels[1] = MACIO_IN32(KEYLARGO_GPIO_LEVELS1);
1708 for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
1709 save_gpio_extint[i] = MACIO_IN8(KEYLARGO_GPIO_EXTINT_0+i);
1710 for (i=0; i<KEYLARGO_GPIO_CNT; i++)
1711 save_gpio_normal[i] = MACIO_IN8(KEYLARGO_GPIO_0+i);
1714 if (macio->type == macio_keylargo)
1715 save_mbcr = MACIO_IN32(KEYLARGO_MBCR);
1716 save_fcr[0] = MACIO_IN32(KEYLARGO_FCR0);
1717 save_fcr[1] = MACIO_IN32(KEYLARGO_FCR1);
1718 save_fcr[2] = MACIO_IN32(KEYLARGO_FCR2);
1719 save_fcr[3] = MACIO_IN32(KEYLARGO_FCR3);
1720 save_fcr[4] = MACIO_IN32(KEYLARGO_FCR4);
1721 if (macio->type == macio_pangea || macio->type == macio_intrepid)
1722 save_fcr[5] = MACIO_IN32(KEYLARGO_FCR5);
1724 /* Save state & config of DBDMA channels */
1725 dbdma_save(macio, save_dbdma);
1728 * Turn off as much as we can
1730 if (macio->type == macio_pangea)
1731 pangea_shutdown(macio, 1);
1732 else if (macio->type == macio_intrepid)
1733 intrepid_shutdown(macio, 1);
1734 else if (macio->type == macio_keylargo)
1735 keylargo_shutdown(macio, 1);
1738 * Put the host bridge to sleep
1741 save_unin_clock_ctl = UN_IN(UNI_N_CLOCK_CNTL);
1742 /* Note: do not switch GMAC off, driver does it when necessary, WOL must keep it
1745 UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl &
1746 ~(/*UNI_N_CLOCK_CNTL_GMAC|*/UNI_N_CLOCK_CNTL_FW/*|UNI_N_CLOCK_CNTL_PCI*/));
1748 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING);
1749 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_SLEEP);
1753 * FIXME: A bit of black magic with OpenPIC (don't ask me why)
1755 if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) {
1756 MACIO_BIS(0x506e0, 0x00400000);
1757 MACIO_BIS(0x506e0, 0x80000000);
1763 core99_wake_up(void)
1765 struct macio_chip *macio;
1768 macio = &macio_chips[0];
1769 if (macio->type != macio_keylargo && macio->type != macio_pangea &&
1770 macio->type != macio_intrepid)
1774 * Wakeup the host bridge
1776 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL);
1778 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING);
1785 if (macio->type == macio_keylargo) {
1786 MACIO_OUT32(KEYLARGO_MBCR, save_mbcr);
1787 (void)MACIO_IN32(KEYLARGO_MBCR); udelay(10);
1789 MACIO_OUT32(KEYLARGO_FCR0, save_fcr[0]);
1790 (void)MACIO_IN32(KEYLARGO_FCR0); udelay(10);
1791 MACIO_OUT32(KEYLARGO_FCR1, save_fcr[1]);
1792 (void)MACIO_IN32(KEYLARGO_FCR1); udelay(10);
1793 MACIO_OUT32(KEYLARGO_FCR2, save_fcr[2]);
1794 (void)MACIO_IN32(KEYLARGO_FCR2); udelay(10);
1795 MACIO_OUT32(KEYLARGO_FCR3, save_fcr[3]);
1796 (void)MACIO_IN32(KEYLARGO_FCR3); udelay(10);
1797 MACIO_OUT32(KEYLARGO_FCR4, save_fcr[4]);
1798 (void)MACIO_IN32(KEYLARGO_FCR4); udelay(10);
1799 if (macio->type == macio_pangea || macio->type == macio_intrepid) {
1800 MACIO_OUT32(KEYLARGO_FCR5, save_fcr[5]);
1801 (void)MACIO_IN32(KEYLARGO_FCR5); udelay(10);
1804 dbdma_restore(macio, save_dbdma);
1806 MACIO_OUT32(KEYLARGO_GPIO_LEVELS0, save_gpio_levels[0]);
1807 MACIO_OUT32(KEYLARGO_GPIO_LEVELS1, save_gpio_levels[1]);
1808 for (i=0; i<KEYLARGO_GPIO_EXTINT_CNT; i++)
1809 MACIO_OUT8(KEYLARGO_GPIO_EXTINT_0+i, save_gpio_extint[i]);
1810 for (i=0; i<KEYLARGO_GPIO_CNT; i++)
1811 MACIO_OUT8(KEYLARGO_GPIO_0+i, save_gpio_normal[i]);
1813 /* FIXME more black magic with OpenPIC ... */
1814 if (pmac_mb.model_id == PMAC_TYPE_SAWTOOTH) {
1815 MACIO_BIC(0x506e0, 0x00400000);
1816 MACIO_BIC(0x506e0, 0x80000000);
1819 UN_OUT(UNI_N_CLOCK_CNTL, save_unin_clock_ctl);
1825 #endif /* CONFIG_PM */
1828 core99_sleep_state(struct device_node *node, long param, long value)
1830 /* Param == 1 means to enter the "fake sleep" mode that is
1831 * used for CPU speed switch
1835 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_SLEEPING);
1836 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_IDLE2);
1838 UN_OUT(UNI_N_POWER_MGT, UNI_N_POWER_MGT_NORMAL);
1840 UN_OUT(UNI_N_HWINIT_STATE, UNI_N_HWINIT_STATE_RUNNING);
1845 if ((pmac_mb.board_flags & PMAC_MB_CAN_SLEEP) == 0)
1850 return core99_sleep();
1851 else if (value == 0)
1852 return core99_wake_up();
1854 #endif /* CONFIG_PM */
1858 #endif /* CONFIG_POWER4 */
1861 generic_dev_can_wake(struct device_node *node, long param, long value)
1863 /* Todo: eventually check we are really dealing with on-board
1867 if (pmac_mb.board_flags & PMAC_MB_MAY_SLEEP)
1868 pmac_mb.board_flags |= PMAC_MB_CAN_SLEEP;
1872 static long generic_get_mb_info(struct device_node *node, long param, long value)
1875 case PMAC_MB_INFO_MODEL:
1876 return pmac_mb.model_id;
1877 case PMAC_MB_INFO_FLAGS:
1878 return pmac_mb.board_flags;
1879 case PMAC_MB_INFO_NAME:
1880 /* hack hack hack... but should work */
1881 *((const char **)value) = pmac_mb.model_name;
1892 /* Used on any machine
1894 static struct feature_table_entry any_features[] = {
1895 { PMAC_FTR_GET_MB_INFO, generic_get_mb_info },
1896 { PMAC_FTR_DEVICE_CAN_WAKE, generic_dev_can_wake },
1900 #ifndef CONFIG_POWER4
1902 /* OHare based motherboards. Currently, we only use these on the
1903 * 2400,3400 and 3500 series powerbooks. Some older desktops seem
1904 * to have issues with turning on/off those asic cells
1906 static struct feature_table_entry ohare_features[] = {
1907 { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
1908 { PMAC_FTR_SWIM3_ENABLE, ohare_floppy_enable },
1909 { PMAC_FTR_MESH_ENABLE, ohare_mesh_enable },
1910 { PMAC_FTR_IDE_ENABLE, ohare_ide_enable},
1911 { PMAC_FTR_IDE_RESET, ohare_ide_reset},
1912 { PMAC_FTR_SLEEP_STATE, ohare_sleep_state },
1916 /* Heathrow desktop machines (Beige G3).
1917 * Separated as some features couldn't be properly tested
1918 * and the serial port control bits appear to confuse it.
1920 static struct feature_table_entry heathrow_desktop_features[] = {
1921 { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
1922 { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
1923 { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
1924 { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
1925 { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
1929 /* Heathrow based laptop, that is the Wallstreet and mainstreet
1932 static struct feature_table_entry heathrow_laptop_features[] = {
1933 { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
1934 { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable },
1935 { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
1936 { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
1937 { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
1938 { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
1939 { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
1940 { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable },
1941 { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state },
1945 /* Paddington based machines
1946 * The lombard (101) powerbook, first iMac models, B&W G3 and Yikes G4.
1948 static struct feature_table_entry paddington_features[] = {
1949 { PMAC_FTR_SCC_ENABLE, ohare_htw_scc_enable },
1950 { PMAC_FTR_MODEM_ENABLE, heathrow_modem_enable },
1951 { PMAC_FTR_SWIM3_ENABLE, heathrow_floppy_enable },
1952 { PMAC_FTR_MESH_ENABLE, heathrow_mesh_enable },
1953 { PMAC_FTR_IDE_ENABLE, heathrow_ide_enable },
1954 { PMAC_FTR_IDE_RESET, heathrow_ide_reset },
1955 { PMAC_FTR_BMAC_ENABLE, heathrow_bmac_enable },
1956 { PMAC_FTR_SOUND_CHIP_ENABLE, heathrow_sound_enable },
1957 { PMAC_FTR_SLEEP_STATE, heathrow_sleep_state },
1961 /* Core99 & MacRISC 2 machines (all machines released since the
1962 * iBook (included), that is all AGP machines, except pangea
1963 * chipset. The pangea chipset is the "combo" UniNorth/KeyLargo
1964 * used on iBook2 & iMac "flow power".
1966 static struct feature_table_entry core99_features[] = {
1967 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
1968 { PMAC_FTR_MODEM_ENABLE, core99_modem_enable },
1969 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
1970 { PMAC_FTR_IDE_RESET, core99_ide_reset },
1971 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
1972 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
1973 { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
1974 { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
1975 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
1976 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
1977 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
1979 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
1982 { PMAC_FTR_RESET_CPU, core99_reset_cpu },
1983 #endif /* CONFIG_SMP */
1984 { PMAC_FTR_READ_GPIO, core99_read_gpio },
1985 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
1991 static struct feature_table_entry rackmac_features[] = {
1992 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
1993 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
1994 { PMAC_FTR_IDE_RESET, core99_ide_reset },
1995 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
1996 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
1997 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
1998 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
1999 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
2000 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
2002 { PMAC_FTR_RESET_CPU, core99_reset_cpu },
2003 #endif /* CONFIG_SMP */
2004 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2005 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2011 static struct feature_table_entry pangea_features[] = {
2012 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
2013 { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable },
2014 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
2015 { PMAC_FTR_IDE_RESET, core99_ide_reset },
2016 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
2017 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
2018 { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
2019 { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
2020 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
2021 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
2022 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
2023 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
2024 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2025 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2029 /* Intrepid features
2031 static struct feature_table_entry intrepid_features[] = {
2032 { PMAC_FTR_SCC_ENABLE, core99_scc_enable },
2033 { PMAC_FTR_MODEM_ENABLE, pangea_modem_enable },
2034 { PMAC_FTR_IDE_ENABLE, core99_ide_enable },
2035 { PMAC_FTR_IDE_RESET, core99_ide_reset },
2036 { PMAC_FTR_GMAC_ENABLE, core99_gmac_enable },
2037 { PMAC_FTR_GMAC_PHY_RESET, core99_gmac_phy_reset },
2038 { PMAC_FTR_SOUND_CHIP_ENABLE, core99_sound_chip_enable },
2039 { PMAC_FTR_AIRPORT_ENABLE, core99_airport_enable },
2040 { PMAC_FTR_USB_ENABLE, core99_usb_enable },
2041 { PMAC_FTR_1394_ENABLE, core99_firewire_enable },
2042 { PMAC_FTR_1394_CABLE_POWER, core99_firewire_cable_power },
2043 { PMAC_FTR_SLEEP_STATE, core99_sleep_state },
2044 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2045 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2046 { PMAC_FTR_AACK_DELAY_ENABLE, intrepid_aack_delay_enable },
2050 #else /* CONFIG_POWER4 */
2054 static struct feature_table_entry g5_features[] = {
2055 { PMAC_FTR_GMAC_ENABLE, g5_gmac_enable },
2056 { PMAC_FTR_1394_ENABLE, g5_fw_enable },
2057 { PMAC_FTR_ENABLE_MPIC, g5_mpic_enable },
2058 { PMAC_FTR_GMAC_PHY_RESET, g5_eth_phy_reset },
2059 { PMAC_FTR_SOUND_CHIP_ENABLE, g5_i2s_enable },
2061 { PMAC_FTR_RESET_CPU, g5_reset_cpu },
2062 #endif /* CONFIG_SMP */
2063 { PMAC_FTR_READ_GPIO, core99_read_gpio },
2064 { PMAC_FTR_WRITE_GPIO, core99_write_gpio },
2068 #endif /* CONFIG_POWER4 */
2070 static struct pmac_mb_def pmac_mb_defs[] = {
2071 #ifndef CONFIG_POWER4
2076 { "AAPL,8500", "PowerMac 8500/8600",
2077 PMAC_TYPE_PSURGE, NULL,
2080 { "AAPL,9500", "PowerMac 9500/9600",
2081 PMAC_TYPE_PSURGE, NULL,
2084 { "AAPL,7200", "PowerMac 7200",
2085 PMAC_TYPE_PSURGE, NULL,
2088 { "AAPL,7300", "PowerMac 7200/7300",
2089 PMAC_TYPE_PSURGE, NULL,
2092 { "AAPL,7500", "PowerMac 7500",
2093 PMAC_TYPE_PSURGE, NULL,
2096 { "AAPL,ShinerESB", "Apple Network Server",
2097 PMAC_TYPE_ANS, NULL,
2100 { "AAPL,e407", "Alchemy",
2101 PMAC_TYPE_ALCHEMY, NULL,
2104 { "AAPL,e411", "Gazelle",
2105 PMAC_TYPE_GAZELLE, NULL,
2108 { "AAPL,Gossamer", "PowerMac G3 (Gossamer)",
2109 PMAC_TYPE_GOSSAMER, heathrow_desktop_features,
2112 { "AAPL,PowerMac G3", "PowerMac G3 (Silk)",
2113 PMAC_TYPE_SILK, heathrow_desktop_features,
2116 { "PowerMac1,1", "Blue&White G3",
2117 PMAC_TYPE_YOSEMITE, paddington_features,
2120 { "PowerMac1,2", "PowerMac G4 PCI Graphics",
2121 PMAC_TYPE_YIKES, paddington_features,
2124 { "PowerMac2,1", "iMac FireWire",
2125 PMAC_TYPE_FW_IMAC, core99_features,
2126 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2128 { "PowerMac2,2", "iMac FireWire",
2129 PMAC_TYPE_FW_IMAC, core99_features,
2130 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2132 { "PowerMac3,1", "PowerMac G4 AGP Graphics",
2133 PMAC_TYPE_SAWTOOTH, core99_features,
2136 { "PowerMac3,2", "PowerMac G4 AGP Graphics",
2137 PMAC_TYPE_SAWTOOTH, core99_features,
2138 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2140 { "PowerMac3,3", "PowerMac G4 AGP Graphics",
2141 PMAC_TYPE_SAWTOOTH, core99_features,
2142 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2144 { "PowerMac3,4", "PowerMac G4 Silver",
2145 PMAC_TYPE_QUICKSILVER, core99_features,
2148 { "PowerMac3,5", "PowerMac G4 Silver",
2149 PMAC_TYPE_QUICKSILVER, core99_features,
2152 { "PowerMac3,6", "PowerMac G4 Windtunnel",
2153 PMAC_TYPE_WINDTUNNEL, core99_features,
2156 { "PowerMac4,1", "iMac \"Flower Power\"",
2157 PMAC_TYPE_PANGEA_IMAC, pangea_features,
2160 { "PowerMac4,2", "Flat panel iMac",
2161 PMAC_TYPE_FLAT_PANEL_IMAC, pangea_features,
2164 { "PowerMac4,4", "eMac",
2165 PMAC_TYPE_EMAC, core99_features,
2168 { "PowerMac5,1", "PowerMac G4 Cube",
2169 PMAC_TYPE_CUBE, core99_features,
2170 PMAC_MB_MAY_SLEEP | PMAC_MB_OLD_CORE99
2172 { "PowerMac6,1", "Flat panel iMac",
2173 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2176 { "PowerMac6,3", "Flat panel iMac",
2177 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2180 { "PowerMac6,4", "eMac",
2181 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2184 { "PowerMac10,1", "Mac mini",
2185 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2188 { "iMac,1", "iMac (first generation)",
2189 PMAC_TYPE_ORIG_IMAC, paddington_features,
2197 { "RackMac1,1", "XServe",
2198 PMAC_TYPE_RACKMAC, rackmac_features,
2201 { "RackMac1,2", "XServe rev. 2",
2202 PMAC_TYPE_RACKMAC, rackmac_features,
2210 { "AAPL,3400/2400", "PowerBook 3400",
2211 PMAC_TYPE_HOOPER, ohare_features,
2212 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2214 { "AAPL,3500", "PowerBook 3500",
2215 PMAC_TYPE_KANGA, ohare_features,
2216 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2218 { "AAPL,PowerBook1998", "PowerBook Wallstreet",
2219 PMAC_TYPE_WALLSTREET, heathrow_laptop_features,
2220 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2222 { "PowerBook1,1", "PowerBook 101 (Lombard)",
2223 PMAC_TYPE_101_PBOOK, paddington_features,
2224 PMAC_MB_CAN_SLEEP | PMAC_MB_MOBILE
2226 { "PowerBook2,1", "iBook (first generation)",
2227 PMAC_TYPE_ORIG_IBOOK, core99_features,
2228 PMAC_MB_CAN_SLEEP | PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
2230 { "PowerBook2,2", "iBook FireWire",
2231 PMAC_TYPE_FW_IBOOK, core99_features,
2232 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER |
2233 PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
2235 { "PowerBook3,1", "PowerBook Pismo",
2236 PMAC_TYPE_PISMO, core99_features,
2237 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER |
2238 PMAC_MB_OLD_CORE99 | PMAC_MB_MOBILE
2240 { "PowerBook3,2", "PowerBook Titanium",
2241 PMAC_TYPE_TITANIUM, core99_features,
2242 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2244 { "PowerBook3,3", "PowerBook Titanium II",
2245 PMAC_TYPE_TITANIUM2, core99_features,
2246 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2248 { "PowerBook3,4", "PowerBook Titanium III",
2249 PMAC_TYPE_TITANIUM3, core99_features,
2250 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2252 { "PowerBook3,5", "PowerBook Titanium IV",
2253 PMAC_TYPE_TITANIUM4, core99_features,
2254 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2256 { "PowerBook4,1", "iBook 2",
2257 PMAC_TYPE_IBOOK2, pangea_features,
2258 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2260 { "PowerBook4,2", "iBook 2",
2261 PMAC_TYPE_IBOOK2, pangea_features,
2262 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2264 { "PowerBook4,3", "iBook 2 rev. 2",
2265 PMAC_TYPE_IBOOK2, pangea_features,
2266 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE
2268 { "PowerBook5,1", "PowerBook G4 17\"",
2269 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2270 PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2272 { "PowerBook5,2", "PowerBook G4 15\"",
2273 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2274 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2276 { "PowerBook5,3", "PowerBook G4 17\"",
2277 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2278 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2280 { "PowerBook5,4", "PowerBook G4 15\"",
2281 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2282 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2284 { "PowerBook5,5", "PowerBook G4 17\"",
2285 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2286 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2288 { "PowerBook5,6", "PowerBook G4 15\"",
2289 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2290 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2292 { "PowerBook5,7", "PowerBook G4 17\"",
2293 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2294 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2296 { "PowerBook5,8", "PowerBook G4 15\"",
2297 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2298 PMAC_MB_MAY_SLEEP | PMAC_MB_MOBILE,
2300 { "PowerBook5,9", "PowerBook G4 17\"",
2301 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2302 PMAC_MB_MAY_SLEEP | PMAC_MB_MOBILE,
2304 { "PowerBook6,1", "PowerBook G4 12\"",
2305 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2306 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2308 { "PowerBook6,2", "PowerBook G4",
2309 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2310 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2312 { "PowerBook6,3", "iBook G4",
2313 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2314 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2316 { "PowerBook6,4", "PowerBook G4 12\"",
2317 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2318 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2320 { "PowerBook6,5", "iBook G4",
2321 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2322 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2324 { "PowerBook6,7", "iBook G4",
2325 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2326 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2328 { "PowerBook6,8", "PowerBook G4 12\"",
2329 PMAC_TYPE_UNKNOWN_INTREPID, intrepid_features,
2330 PMAC_MB_MAY_SLEEP | PMAC_MB_HAS_FW_POWER | PMAC_MB_MOBILE,
2332 #else /* CONFIG_POWER4 */
2333 { "PowerMac7,2", "PowerMac G5",
2334 PMAC_TYPE_POWERMAC_G5, g5_features,
2338 { "PowerMac7,3", "PowerMac G5",
2339 PMAC_TYPE_POWERMAC_G5, g5_features,
2342 { "PowerMac8,1", "iMac G5",
2343 PMAC_TYPE_IMAC_G5, g5_features,
2346 { "PowerMac9,1", "PowerMac G5",
2347 PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
2350 { "PowerMac11,2", "PowerMac G5 Dual Core",
2351 PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
2354 { "PowerMac12,1", "iMac G5 (iSight)",
2355 PMAC_TYPE_POWERMAC_G5_U3L, g5_features,
2358 { "RackMac3,1", "XServe G5",
2359 PMAC_TYPE_XSERVE_G5, g5_features,
2362 #endif /* CONFIG_PPC64 */
2363 #endif /* CONFIG_POWER4 */
2367 * The toplevel feature_call callback
2369 long pmac_do_feature_call(unsigned int selector, ...)
2371 struct device_node *node;
2374 feature_call func = NULL;
2377 if (pmac_mb.features)
2378 for (i=0; pmac_mb.features[i].function; i++)
2379 if (pmac_mb.features[i].selector == selector) {
2380 func = pmac_mb.features[i].function;
2384 for (i=0; any_features[i].function; i++)
2385 if (any_features[i].selector == selector) {
2386 func = any_features[i].function;
2392 va_start(args, selector);
2393 node = (struct device_node*)va_arg(args, void*);
2394 param = va_arg(args, long);
2395 value = va_arg(args, long);
2398 return func(node, param, value);
2401 static int __init probe_motherboard(void)
2404 struct macio_chip *macio = &macio_chips[0];
2405 const char *model = NULL;
2406 struct device_node *dt;
2408 /* Lookup known motherboard type in device-tree. First try an
2409 * exact match on the "model" property, then try a "compatible"
2410 * match is none is found.
2412 dt = find_devices("device-tree");
2414 model = get_property(dt, "model", NULL);
2415 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
2416 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
2417 pmac_mb = pmac_mb_defs[i];
2421 for(i=0; i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
2422 if (machine_is_compatible(pmac_mb_defs[i].model_string)) {
2423 pmac_mb = pmac_mb_defs[i];
2428 /* Fallback to selection depending on mac-io chip type */
2429 switch(macio->type) {
2430 #ifndef CONFIG_POWER4
2431 case macio_grand_central:
2432 pmac_mb.model_id = PMAC_TYPE_PSURGE;
2433 pmac_mb.model_name = "Unknown PowerSurge";
2436 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_OHARE;
2437 pmac_mb.model_name = "Unknown OHare-based";
2439 case macio_heathrow:
2440 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_HEATHROW;
2441 pmac_mb.model_name = "Unknown Heathrow-based";
2442 pmac_mb.features = heathrow_desktop_features;
2444 case macio_paddington:
2445 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PADDINGTON;
2446 pmac_mb.model_name = "Unknown Paddington-based";
2447 pmac_mb.features = paddington_features;
2449 case macio_keylargo:
2450 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_CORE99;
2451 pmac_mb.model_name = "Unknown Keylargo-based";
2452 pmac_mb.features = core99_features;
2455 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_PANGEA;
2456 pmac_mb.model_name = "Unknown Pangea-based";
2457 pmac_mb.features = pangea_features;
2459 case macio_intrepid:
2460 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_INTREPID;
2461 pmac_mb.model_name = "Unknown Intrepid-based";
2462 pmac_mb.features = intrepid_features;
2464 #else /* CONFIG_POWER4 */
2465 case macio_keylargo2:
2466 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_K2;
2467 pmac_mb.model_name = "Unknown K2-based";
2468 pmac_mb.features = g5_features;
2471 pmac_mb.model_id = PMAC_TYPE_UNKNOWN_SHASTA;
2472 pmac_mb.model_name = "Unknown Shasta-based";
2473 pmac_mb.features = g5_features;
2475 #endif /* CONFIG_POWER4 */
2480 #ifndef CONFIG_POWER4
2481 /* Fixup Hooper vs. Comet */
2482 if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
2483 u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
2486 /* Here, I used to disable the media-bay on comet. It
2487 * appears this is wrong, the floppy connector is actually
2488 * a kind of media-bay and works with the current driver.
2490 if (__raw_readl(mach_id_ptr) & 0x20000000UL)
2491 pmac_mb.model_id = PMAC_TYPE_COMET;
2492 iounmap(mach_id_ptr);
2495 /* Set default value of powersave_nap on machines that support it.
2496 * It appears that uninorth rev 3 has a problem with it, we don't
2497 * enable it on those. In theory, the flush-on-lock property is
2498 * supposed to be set when not supported, but I'm not very confident
2499 * that all Apple OF revs did it properly, I do it the paranoid way.
2501 while (uninorth_base && uninorth_rev > 3) {
2502 struct device_node *np = find_path_device("/cpus");
2503 if (!np || !np->child) {
2504 printk(KERN_WARNING "Can't find CPU(s) in device tree !\n");
2508 /* Nap mode not supported on SMP */
2511 /* Nap mode not supported if flush-on-lock property is present */
2512 if (get_property(np, "flush-on-lock", NULL))
2515 printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
2519 /* On CPUs that support it (750FX), lowspeed by default during
2522 powersave_lowspeed = 1;
2524 #else /* CONFIG_POWER4 */
2526 #endif /* CONFIG_POWER4 */
2528 /* Check for "mobile" machine */
2529 if (model && (strncmp(model, "PowerBook", 9) == 0
2530 || strncmp(model, "iBook", 5) == 0))
2531 pmac_mb.board_flags |= PMAC_MB_MOBILE;
2534 printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name);
2538 /* Initialize the Core99 UniNorth host bridge and memory controller
2540 static void __init probe_uninorth(void)
2543 phys_addr_t address;
2544 unsigned long actrl;
2546 /* Locate core99 Uni-N */
2547 uninorth_node = of_find_node_by_name(NULL, "uni-n");
2549 if (uninorth_node == NULL) {
2550 uninorth_node = of_find_node_by_name(NULL, "u3");
2554 if (uninorth_node == NULL) {
2555 uninorth_node = of_find_node_by_name(NULL, "u4");
2558 if (uninorth_node == NULL)
2561 addrp = get_property(uninorth_node, "reg", NULL);
2564 address = of_translate_address(uninorth_node, addrp);
2567 uninorth_base = ioremap(address, 0x40000);
2568 uninorth_rev = in_be32(UN_REG(UNI_N_VERSION));
2569 if (uninorth_maj == 3 || uninorth_maj == 4)
2570 u3_ht_base = ioremap(address + U3_HT_CONFIG_BASE, 0x1000);
2572 printk(KERN_INFO "Found %s memory controller & host bridge"
2573 " @ 0x%08x revision: 0x%02x\n", uninorth_maj == 3 ? "U3" :
2574 uninorth_maj == 4 ? "U4" : "UniNorth",
2575 (unsigned int)address, uninorth_rev);
2576 printk(KERN_INFO "Mapped at 0x%08lx\n", (unsigned long)uninorth_base);
2578 /* Set the arbitrer QAck delay according to what Apple does
2580 if (uninorth_rev < 0x11) {
2581 actrl = UN_IN(UNI_N_ARB_CTRL) & ~UNI_N_ARB_CTRL_QACK_DELAY_MASK;
2582 actrl |= ((uninorth_rev < 3) ? UNI_N_ARB_CTRL_QACK_DELAY105 :
2583 UNI_N_ARB_CTRL_QACK_DELAY) <<
2584 UNI_N_ARB_CTRL_QACK_DELAY_SHIFT;
2585 UN_OUT(UNI_N_ARB_CTRL, actrl);
2588 /* Some more magic as done by them in recent MacOS X on UniNorth
2589 * revs 1.5 to 2.O and Pangea. Seem to toggle the UniN Maxbus/PCI
2592 if ((uninorth_rev >= 0x11 && uninorth_rev <= 0x24) ||
2593 uninorth_rev == 0xc0)
2594 UN_OUT(0x2160, UN_IN(0x2160) & 0x00ffffff);
2597 static void __init probe_one_macio(const char *name, const char *compat, int type)
2599 struct device_node* node;
2601 volatile u32 __iomem *base;
2602 const u32 *addrp, *revp;
2606 for (node = NULL; (node = of_find_node_by_name(node, name)) != NULL;) {
2609 if (device_is_compatible(node, compat))
2614 for(i=0; i<MAX_MACIO_CHIPS; i++) {
2615 if (!macio_chips[i].of_node)
2617 if (macio_chips[i].of_node == node)
2621 if (i >= MAX_MACIO_CHIPS) {
2622 printk(KERN_ERR "pmac_feature: Please increase MAX_MACIO_CHIPS !\n");
2623 printk(KERN_ERR "pmac_feature: %s skipped\n", node->full_name);
2626 addrp = of_get_pci_address(node, 0, &size, NULL);
2627 if (addrp == NULL) {
2628 printk(KERN_ERR "pmac_feature: %s: can't find base !\n",
2632 addr = of_translate_address(node, addrp);
2634 printk(KERN_ERR "pmac_feature: %s, can't translate base !\n",
2638 base = ioremap(addr, (unsigned long)size);
2640 printk(KERN_ERR "pmac_feature: %s, can't map mac-io chip !\n",
2644 if (type == macio_keylargo || type == macio_keylargo2) {
2645 const u32 *did = get_property(node, "device-id", NULL);
2646 if (*did == 0x00000025)
2647 type = macio_pangea;
2648 if (*did == 0x0000003e)
2649 type = macio_intrepid;
2650 if (*did == 0x0000004f)
2651 type = macio_shasta;
2653 macio_chips[i].of_node = node;
2654 macio_chips[i].type = type;
2655 macio_chips[i].base = base;
2656 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON;
2657 macio_chips[i].name = macio_names[type];
2658 revp = get_property(node, "revision-id", NULL);
2660 macio_chips[i].rev = *revp;
2661 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
2662 macio_names[type], macio_chips[i].rev, macio_chips[i].base);
2668 /* Warning, ordering is important */
2669 probe_one_macio("gc", NULL, macio_grand_central);
2670 probe_one_macio("ohare", NULL, macio_ohare);
2671 probe_one_macio("pci106b,7", NULL, macio_ohareII);
2672 probe_one_macio("mac-io", "keylargo", macio_keylargo);
2673 probe_one_macio("mac-io", "paddington", macio_paddington);
2674 probe_one_macio("mac-io", "gatwick", macio_gatwick);
2675 probe_one_macio("mac-io", "heathrow", macio_heathrow);
2676 probe_one_macio("mac-io", "K2-Keylargo", macio_keylargo2);
2678 /* Make sure the "main" macio chip appear first */
2679 if (macio_chips[0].type == macio_gatwick
2680 && macio_chips[1].type == macio_heathrow) {
2681 struct macio_chip temp = macio_chips[0];
2682 macio_chips[0] = macio_chips[1];
2683 macio_chips[1] = temp;
2685 if (macio_chips[0].type == macio_ohareII
2686 && macio_chips[1].type == macio_ohare) {
2687 struct macio_chip temp = macio_chips[0];
2688 macio_chips[0] = macio_chips[1];
2689 macio_chips[1] = temp;
2691 macio_chips[0].lbus.index = 0;
2692 macio_chips[1].lbus.index = 1;
2694 return (macio_chips[0].of_node == NULL) ? -ENODEV : 0;
2698 initial_serial_shutdown(struct device_node *np)
2701 const struct slot_names_prop {
2706 int port_type = PMAC_SCC_ASYNC;
2709 slots = get_property(np, "slot-names", &len);
2710 conn = get_property(np, "AAPL,connector", &len);
2711 if (conn && (strcmp(conn, "infrared") == 0))
2712 port_type = PMAC_SCC_IRDA;
2713 else if (device_is_compatible(np, "cobalt"))
2715 else if (slots && slots->count > 0) {
2716 if (strcmp(slots->name, "IrDA") == 0)
2717 port_type = PMAC_SCC_IRDA;
2718 else if (strcmp(slots->name, "Modem") == 0)
2722 pmac_call_feature(PMAC_FTR_MODEM_ENABLE, np, 0, 0);
2723 pmac_call_feature(PMAC_FTR_SCC_ENABLE, np, port_type, 0);
2727 set_initial_features(void)
2729 struct device_node *np;
2731 /* That hack appears to be necessary for some StarMax motherboards
2732 * but I'm not too sure it was audited for side-effects on other
2733 * ohare based machines...
2734 * Since I still have difficulties figuring the right way to
2735 * differenciate them all and since that hack was there for a long
2736 * time, I'll keep it around
2738 if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) {
2739 struct macio_chip *macio = &macio_chips[0];
2740 MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);
2741 } else if (macio_chips[0].type == macio_ohare) {
2742 struct macio_chip *macio = &macio_chips[0];
2743 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
2744 } else if (macio_chips[1].type == macio_ohare) {
2745 struct macio_chip *macio = &macio_chips[1];
2746 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
2749 #ifdef CONFIG_POWER4
2750 if (macio_chips[0].type == macio_keylargo2 ||
2751 macio_chips[0].type == macio_shasta) {
2753 /* On SMP machines running UP, we have the second CPU eating
2754 * bus cycles. We need to take it off the bus. This is done
2755 * from pmac_smp for SMP kernels running on one CPU
2757 np = of_find_node_by_type(NULL, "cpu");
2759 np = of_find_node_by_type(np, "cpu");
2761 g5_phy_disable_cpu1();
2764 #endif /* CONFIG_SMP */
2765 /* Enable GMAC for now for PCI probing. It will be disabled
2766 * later on after PCI probe
2768 np = of_find_node_by_name(NULL, "ethernet");
2770 if (device_is_compatible(np, "K2-GMAC"))
2771 g5_gmac_enable(np, 0, 1);
2772 np = of_find_node_by_name(np, "ethernet");
2775 /* Enable FW before PCI probe. Will be disabled later on
2776 * Note: We should have a batter way to check that we are
2777 * dealing with uninorth internal cell and not a PCI cell
2778 * on the external PCI. The code below works though.
2780 np = of_find_node_by_name(NULL, "firewire");
2782 if (device_is_compatible(np, "pci106b,5811")) {
2783 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
2784 g5_fw_enable(np, 0, 1);
2786 np = of_find_node_by_name(np, "firewire");
2789 #else /* CONFIG_POWER4 */
2791 if (macio_chips[0].type == macio_keylargo ||
2792 macio_chips[0].type == macio_pangea ||
2793 macio_chips[0].type == macio_intrepid) {
2794 /* Enable GMAC for now for PCI probing. It will be disabled
2795 * later on after PCI probe
2797 np = of_find_node_by_name(NULL, "ethernet");
2800 && device_is_compatible(np->parent, "uni-north")
2801 && device_is_compatible(np, "gmac"))
2802 core99_gmac_enable(np, 0, 1);
2803 np = of_find_node_by_name(np, "ethernet");
2806 /* Enable FW before PCI probe. Will be disabled later on
2807 * Note: We should have a batter way to check that we are
2808 * dealing with uninorth internal cell and not a PCI cell
2809 * on the external PCI. The code below works though.
2811 np = of_find_node_by_name(NULL, "firewire");
2814 && device_is_compatible(np->parent, "uni-north")
2815 && (device_is_compatible(np, "pci106b,18") ||
2816 device_is_compatible(np, "pci106b,30") ||
2817 device_is_compatible(np, "pci11c1,5811"))) {
2818 macio_chips[0].flags |= MACIO_FLAG_FW_SUPPORTED;
2819 core99_firewire_enable(np, 0, 1);
2821 np = of_find_node_by_name(np, "firewire");
2824 /* Enable ATA-100 before PCI probe. */
2825 np = of_find_node_by_name(NULL, "ata-6");
2828 && device_is_compatible(np->parent, "uni-north")
2829 && device_is_compatible(np, "kauai-ata")) {
2830 core99_ata100_enable(np, 1);
2832 np = of_find_node_by_name(np, "ata-6");
2835 /* Switch airport off */
2836 np = find_devices("radio");
2838 if (np && np->parent == macio_chips[0].of_node) {
2839 macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON;
2840 core99_airport_enable(np, 0, 0);
2846 /* On all machines that support sound PM, switch sound off */
2847 if (macio_chips[0].of_node)
2848 pmac_do_feature_call(PMAC_FTR_SOUND_CHIP_ENABLE,
2849 macio_chips[0].of_node, 0, 0);
2851 /* While on some desktop G3s, we turn it back on */
2852 if (macio_chips[0].of_node && macio_chips[0].type == macio_heathrow
2853 && (pmac_mb.model_id == PMAC_TYPE_GOSSAMER ||
2854 pmac_mb.model_id == PMAC_TYPE_SILK)) {
2855 struct macio_chip *macio = &macio_chips[0];
2856 MACIO_BIS(HEATHROW_FCR, HRW_SOUND_CLK_ENABLE);
2857 MACIO_BIC(HEATHROW_FCR, HRW_SOUND_POWER_N);
2860 #endif /* CONFIG_POWER4 */
2862 /* On all machines, switch modem & serial ports off */
2863 np = find_devices("ch-a");
2865 initial_serial_shutdown(np);
2868 np = find_devices("ch-b");
2870 initial_serial_shutdown(np);
2876 pmac_feature_init(void)
2878 /* Detect the UniNorth memory controller */
2881 /* Probe mac-io controllers */
2882 if (probe_macios()) {
2883 printk(KERN_WARNING "No mac-io chip found\n");
2887 /* Probe machine type */
2888 if (probe_motherboard())
2889 printk(KERN_WARNING "Unknown PowerMac !\n");
2891 /* Set some initial features (turn off some chips that will
2892 * be later turned on)
2894 set_initial_features();
2898 static void dump_HT_speeds(char *name, u32 cfg, u32 frq)
2900 int freqs[16] = { 200,300,400,500,600,800,1000,0,0,0,0,0,0,0,0,0 };
2901 int bits[8] = { 8,16,0,32,2,4,0,0 };
2902 int freq = (frq >> 8) & 0xf;
2904 if (freqs[freq] == 0)
2905 printk("%s: Unknown HT link frequency %x\n", name, freq);
2907 printk("%s: %d MHz on main link, (%d in / %d out) bits width\n",
2909 bits[(cfg >> 28) & 0x7], bits[(cfg >> 24) & 0x7]);
2912 void __init pmac_check_ht_link(void)
2914 u32 ufreq, freq, ucfg, cfg;
2915 struct device_node *pcix_node;
2916 u8 px_bus, px_devfn;
2917 struct pci_controller *px_hose;
2919 (void)in_be32(u3_ht_base + U3_HT_LINK_COMMAND);
2920 ucfg = cfg = in_be32(u3_ht_base + U3_HT_LINK_CONFIG);
2921 ufreq = freq = in_be32(u3_ht_base + U3_HT_LINK_FREQ);
2922 dump_HT_speeds("U3 HyperTransport", cfg, freq);
2924 pcix_node = of_find_compatible_node(NULL, "pci", "pci-x");
2925 if (pcix_node == NULL) {
2926 printk("No PCI-X bridge found\n");
2929 if (pci_device_from_OF_node(pcix_node, &px_bus, &px_devfn) != 0) {
2930 printk("PCI-X bridge found but not matched to pci\n");
2933 px_hose = pci_find_hose_for_OF_device(pcix_node);
2934 if (px_hose == NULL) {
2935 printk("PCI-X bridge found but not matched to host\n");
2938 early_read_config_dword(px_hose, px_bus, px_devfn, 0xc4, &cfg);
2939 early_read_config_dword(px_hose, px_bus, px_devfn, 0xcc, &freq);
2940 dump_HT_speeds("PCI-X HT Uplink", cfg, freq);
2941 early_read_config_dword(px_hose, px_bus, px_devfn, 0xc8, &cfg);
2942 early_read_config_dword(px_hose, px_bus, px_devfn, 0xd0, &freq);
2943 dump_HT_speeds("PCI-X HT Downlink", cfg, freq);
2948 * Early video resume hook
2951 static void (*pmac_early_vresume_proc)(void *data);
2952 static void *pmac_early_vresume_data;
2954 void pmac_set_early_video_resume(void (*proc)(void *data), void *data)
2956 if (!machine_is(powermac))
2959 pmac_early_vresume_proc = proc;
2960 pmac_early_vresume_data = data;
2963 EXPORT_SYMBOL(pmac_set_early_video_resume);
2965 void pmac_call_early_video_resume(void)
2967 if (pmac_early_vresume_proc)
2968 pmac_early_vresume_proc(pmac_early_vresume_data);
2972 * AGP related suspend/resume code
2975 static struct pci_dev *pmac_agp_bridge;
2976 static int (*pmac_agp_suspend)(struct pci_dev *bridge);
2977 static int (*pmac_agp_resume)(struct pci_dev *bridge);
2979 void pmac_register_agp_pm(struct pci_dev *bridge,
2980 int (*suspend)(struct pci_dev *bridge),
2981 int (*resume)(struct pci_dev *bridge))
2983 if (suspend || resume) {
2984 pmac_agp_bridge = bridge;
2985 pmac_agp_suspend = suspend;
2986 pmac_agp_resume = resume;
2989 if (bridge != pmac_agp_bridge)
2991 pmac_agp_suspend = pmac_agp_resume = NULL;
2994 EXPORT_SYMBOL(pmac_register_agp_pm);
2996 void pmac_suspend_agp_for_card(struct pci_dev *dev)
2998 if (pmac_agp_bridge == NULL || pmac_agp_suspend == NULL)
3000 if (pmac_agp_bridge->bus != dev->bus)
3002 pmac_agp_suspend(pmac_agp_bridge);
3004 EXPORT_SYMBOL(pmac_suspend_agp_for_card);
3006 void pmac_resume_agp_for_card(struct pci_dev *dev)
3008 if (pmac_agp_bridge == NULL || pmac_agp_resume == NULL)
3010 if (pmac_agp_bridge->bus != dev->bus)
3012 pmac_agp_resume(pmac_agp_bridge);
3014 EXPORT_SYMBOL(pmac_resume_agp_for_card);