prep_setup.c 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. /*
  2. * Copyright (C) 1995 Linus Torvalds
  3. * Adapted from 'alpha' version by Gary Thomas
  4. * Modified by Cort Dougan (cort@cs.nmt.edu)
  5. *
  6. * Support for PReP (Motorola MTX/MVME)
  7. * by Troy Benjegerdes (hozer@drgw.net)
  8. */
  9. /*
  10. * bootup setup stuff..
  11. */
  12. #include <linux/delay.h>
  13. #include <linux/module.h>
  14. #include <linux/errno.h>
  15. #include <linux/sched.h>
  16. #include <linux/kernel.h>
  17. #include <linux/mm.h>
  18. #include <linux/stddef.h>
  19. #include <linux/unistd.h>
  20. #include <linux/ptrace.h>
  21. #include <linux/slab.h>
  22. #include <linux/user.h>
  23. #include <linux/a.out.h>
  24. #include <linux/screen_info.h>
  25. #include <linux/major.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/reboot.h>
  28. #include <linux/init.h>
  29. #include <linux/initrd.h>
  30. #include <linux/ioport.h>
  31. #include <linux/console.h>
  32. #include <linux/timex.h>
  33. #include <linux/pci.h>
  34. #include <linux/ide.h>
  35. #include <linux/seq_file.h>
  36. #include <linux/root_dev.h>
  37. #include <asm/sections.h>
  38. #include <asm/mmu.h>
  39. #include <asm/processor.h>
  40. #include <asm/residual.h>
  41. #include <asm/io.h>
  42. #include <asm/pgtable.h>
  43. #include <asm/cache.h>
  44. #include <asm/dma.h>
  45. #include <asm/machdep.h>
  46. #include <asm/mc146818rtc.h>
  47. #include <asm/mk48t59.h>
  48. #include <asm/prep_nvram.h>
  49. #include <asm/raven.h>
  50. #include <asm/vga.h>
  51. #include <asm/time.h>
  52. #include <asm/mpc10x.h>
  53. #include <asm/i8259.h>
  54. #include <asm/open_pic.h>
  55. #include <asm/pci-bridge.h>
  56. #include <asm/todc.h>
  57. /* prep registers for L2 */
  58. #define CACHECRBA 0x80000823 /* Cache configuration register address */
  59. #define L2CACHE_MASK 0x03 /* Mask for 2 L2 Cache bits */
  60. #define L2CACHE_512KB 0x00 /* 512KB */
  61. #define L2CACHE_256KB 0x01 /* 256KB */
  62. #define L2CACHE_1MB 0x02 /* 1MB */
  63. #define L2CACHE_NONE 0x03 /* NONE */
  64. #define L2CACHE_PARITY 0x08 /* Mask for L2 Cache Parity Protected bit */
  65. TODC_ALLOC();
  66. extern unsigned char prep_nvram_read_val(int addr);
  67. extern void prep_nvram_write_val(int addr,
  68. unsigned char val);
  69. extern unsigned char rs_nvram_read_val(int addr);
  70. extern void rs_nvram_write_val(int addr,
  71. unsigned char val);
  72. extern void ibm_prep_init(void);
  73. extern void prep_find_bridges(void);
  74. int _prep_type;
  75. extern void prep_residual_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi);
  76. extern void prep_sandalfoot_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi);
  77. extern void prep_thinkpad_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi);
  78. extern void prep_carolina_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi);
  79. extern void prep_tiger1_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi);
  80. #define cached_21 (((char *)(ppc_cached_irq_mask))[3])
  81. #define cached_A1 (((char *)(ppc_cached_irq_mask))[2])
  82. extern PTE *Hash, *Hash_end;
  83. extern unsigned long Hash_size, Hash_mask;
  84. extern int probingmem;
  85. extern unsigned long loops_per_jiffy;
  86. /* useful ISA ports */
  87. #define PREP_SYSCTL 0x81c
  88. /* present in the IBM reference design; possibly identical in Mot boxes: */
  89. #define PREP_IBM_SIMM_ID 0x803 /* SIMM size: 32 or 8 MiB */
  90. #define PREP_IBM_SIMM_PRESENCE 0x804
  91. #define PREP_IBM_EQUIPMENT 0x80c
  92. #define PREP_IBM_L2INFO 0x80d
  93. #define PREP_IBM_PM1 0x82a /* power management register 1 */
  94. #define PREP_IBM_PLANAR 0x852 /* planar ID - identifies the motherboard */
  95. #define PREP_IBM_DISP 0x8c0 /* 4-digit LED display */
  96. /* Equipment Present Register masks: */
  97. #define PREP_IBM_EQUIPMENT_RESERVED 0x80
  98. #define PREP_IBM_EQUIPMENT_SCSIFUSE 0x40
  99. #define PREP_IBM_EQUIPMENT_L2_COPYBACK 0x08
  100. #define PREP_IBM_EQUIPMENT_L2_256 0x04
  101. #define PREP_IBM_EQUIPMENT_CPU 0x02
  102. #define PREP_IBM_EQUIPMENT_L2 0x01
  103. /* planar ID values: */
  104. /* Sandalfoot/Sandalbow (6015/7020) */
  105. #define PREP_IBM_SANDALFOOT 0xfc
  106. /* Woodfield, Thinkpad 850/860 (6042/7249) */
  107. #define PREP_IBM_THINKPAD 0xff /* planar ID unimplemented */
  108. /* PowerSeries 830/850 (6050/6070) */
  109. #define PREP_IBM_CAROLINA_IDE_0 0xf0
  110. #define PREP_IBM_CAROLINA_IDE_1 0xf1
  111. #define PREP_IBM_CAROLINA_IDE_2 0xf2
  112. #define PREP_IBM_CAROLINA_IDE_3 0xf3
  113. /* 7248-43P */
  114. #define PREP_IBM_CAROLINA_SCSI_0 0xf4
  115. #define PREP_IBM_CAROLINA_SCSI_1 0xf5
  116. #define PREP_IBM_CAROLINA_SCSI_2 0xf6
  117. #define PREP_IBM_CAROLINA_SCSI_3 0xf7 /* missing from Carolina Tech Spec */
  118. /* Tiger1 (7043-140) */
  119. #define PREP_IBM_TIGER1_133 0xd1
  120. #define PREP_IBM_TIGER1_166 0xd2
  121. #define PREP_IBM_TIGER1_180 0xd3
  122. #define PREP_IBM_TIGER1_xxx 0xd4 /* unknown, but probably exists */
  123. #define PREP_IBM_TIGER1_333 0xd5 /* missing from Tiger Tech Spec */
  124. /* setup_ibm_pci:
  125. * set Motherboard_map_name, Motherboard_map, Motherboard_routes.
  126. * return 8259 edge/level masks.
  127. */
  128. void (*setup_ibm_pci)(char *irq_lo, char *irq_hi);
  129. extern char *Motherboard_map_name; /* for use in *_cpuinfo */
  130. /*
  131. * As found in the PReP reference implementation.
  132. * Used by Thinkpad, Sandalfoot (6015/7020), and all Motorola PReP.
  133. */
  134. static void __init
  135. prep_gen_enable_l2(void)
  136. {
  137. outb(inb(PREP_SYSCTL) | 0x3, PREP_SYSCTL);
  138. }
  139. /* Used by Carolina and Tiger1 */
  140. static void __init
  141. prep_carolina_enable_l2(void)
  142. {
  143. outb(inb(PREP_SYSCTL) | 0xc0, PREP_SYSCTL);
  144. }
  145. /* cpuinfo code common to all IBM PReP */
  146. static void
  147. prep_ibm_cpuinfo(struct seq_file *m)
  148. {
  149. unsigned int equip_reg = inb(PREP_IBM_EQUIPMENT);
  150. seq_printf(m, "machine\t\t: PReP %s\n", Motherboard_map_name);
  151. seq_printf(m, "upgrade cpu\t: ");
  152. if (equip_reg & PREP_IBM_EQUIPMENT_CPU) {
  153. seq_printf(m, "not ");
  154. }
  155. seq_printf(m, "present\n");
  156. /* print info about the SCSI fuse */
  157. seq_printf(m, "scsi fuse\t: ");
  158. if (equip_reg & PREP_IBM_EQUIPMENT_SCSIFUSE)
  159. seq_printf(m, "ok");
  160. else
  161. seq_printf(m, "bad");
  162. seq_printf(m, "\n");
  163. /* print info about SIMMs */
  164. if (have_residual_data) {
  165. int i;
  166. seq_printf(m, "simms\t\t: ");
  167. for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
  168. if (res->Memories[i].SIMMSize != 0)
  169. seq_printf(m, "%d:%ldMiB ", i,
  170. (res->Memories[i].SIMMSize > 1024) ?
  171. res->Memories[i].SIMMSize>>20 :
  172. res->Memories[i].SIMMSize);
  173. }
  174. seq_printf(m, "\n");
  175. }
  176. }
  177. static int
  178. prep_gen_cpuinfo(struct seq_file *m)
  179. {
  180. prep_ibm_cpuinfo(m);
  181. return 0;
  182. }
  183. static int
  184. prep_sandalfoot_cpuinfo(struct seq_file *m)
  185. {
  186. unsigned int equip_reg = inb(PREP_IBM_EQUIPMENT);
  187. prep_ibm_cpuinfo(m);
  188. /* report amount and type of L2 cache present */
  189. seq_printf(m, "L2 cache\t: ");
  190. if (equip_reg & PREP_IBM_EQUIPMENT_L2) {
  191. seq_printf(m, "not present");
  192. } else {
  193. if (equip_reg & PREP_IBM_EQUIPMENT_L2_256)
  194. seq_printf(m, "256KiB");
  195. else
  196. seq_printf(m, "unknown size");
  197. if (equip_reg & PREP_IBM_EQUIPMENT_L2_COPYBACK)
  198. seq_printf(m, ", copy-back");
  199. else
  200. seq_printf(m, ", write-through");
  201. }
  202. seq_printf(m, "\n");
  203. return 0;
  204. }
  205. static int
  206. prep_thinkpad_cpuinfo(struct seq_file *m)
  207. {
  208. unsigned int equip_reg = inb(PREP_IBM_EQUIPMENT);
  209. char *cpubus_speed, *pci_speed;
  210. prep_ibm_cpuinfo(m);
  211. /* report amount and type of L2 cache present */
  212. seq_printf(m, "l2 cache\t: ");
  213. if ((equip_reg & 0x1) == 0) {
  214. switch ((equip_reg & 0xc) >> 2) {
  215. case 0x0:
  216. seq_printf(m, "128KiB look-aside 2-way write-through\n");
  217. break;
  218. case 0x1:
  219. seq_printf(m, "512KiB look-aside direct-mapped write-back\n");
  220. break;
  221. case 0x2:
  222. seq_printf(m, "256KiB look-aside 2-way write-through\n");
  223. break;
  224. case 0x3:
  225. seq_printf(m, "256KiB look-aside direct-mapped write-back\n");
  226. break;
  227. }
  228. } else {
  229. seq_printf(m, "not present\n");
  230. }
  231. /* report bus speeds because we can */
  232. if ((equip_reg & 0x80) == 0) {
  233. switch ((equip_reg & 0x30) >> 4) {
  234. case 0x1:
  235. cpubus_speed = "50";
  236. pci_speed = "25";
  237. break;
  238. case 0x3:
  239. cpubus_speed = "66";
  240. pci_speed = "33";
  241. break;
  242. default:
  243. cpubus_speed = "unknown";
  244. pci_speed = "unknown";
  245. break;
  246. }
  247. } else {
  248. switch ((equip_reg & 0x30) >> 4) {
  249. case 0x1:
  250. cpubus_speed = "25";
  251. pci_speed = "25";
  252. break;
  253. case 0x2:
  254. cpubus_speed = "60";
  255. pci_speed = "30";
  256. break;
  257. case 0x3:
  258. cpubus_speed = "33";
  259. pci_speed = "33";
  260. break;
  261. default:
  262. cpubus_speed = "unknown";
  263. pci_speed = "unknown";
  264. break;
  265. }
  266. }
  267. seq_printf(m, "60x bus\t\t: %sMHz\n", cpubus_speed);
  268. seq_printf(m, "pci bus\t\t: %sMHz\n", pci_speed);
  269. return 0;
  270. }
  271. static int
  272. prep_carolina_cpuinfo(struct seq_file *m)
  273. {
  274. unsigned int equip_reg = inb(PREP_IBM_EQUIPMENT);
  275. prep_ibm_cpuinfo(m);
  276. /* report amount and type of L2 cache present */
  277. seq_printf(m, "l2 cache\t: ");
  278. if ((equip_reg & 0x1) == 0) {
  279. unsigned int l2_reg = inb(PREP_IBM_L2INFO);
  280. /* L2 size */
  281. if ((l2_reg & 0x60) == 0)
  282. seq_printf(m, "256KiB");
  283. else if ((l2_reg & 0x60) == 0x20)
  284. seq_printf(m, "512KiB");
  285. else
  286. seq_printf(m, "unknown size");
  287. /* L2 type */
  288. if ((l2_reg & 0x3) == 0)
  289. seq_printf(m, ", async");
  290. else if ((l2_reg & 0x3) == 1)
  291. seq_printf(m, ", sync");
  292. else
  293. seq_printf(m, ", unknown type");
  294. seq_printf(m, "\n");
  295. } else {
  296. seq_printf(m, "not present\n");
  297. }
  298. return 0;
  299. }
  300. static int
  301. prep_tiger1_cpuinfo(struct seq_file *m)
  302. {
  303. unsigned int l2_reg = inb(PREP_IBM_L2INFO);
  304. prep_ibm_cpuinfo(m);
  305. /* report amount and type of L2 cache present */
  306. seq_printf(m, "l2 cache\t: ");
  307. if ((l2_reg & 0xf) == 0xf) {
  308. seq_printf(m, "not present\n");
  309. } else {
  310. if (l2_reg & 0x8)
  311. seq_printf(m, "async, ");
  312. else
  313. seq_printf(m, "sync burst, ");
  314. if (l2_reg & 0x4)
  315. seq_printf(m, "parity, ");
  316. else
  317. seq_printf(m, "no parity, ");
  318. switch (l2_reg & 0x3) {
  319. case 0x0:
  320. seq_printf(m, "256KiB\n");
  321. break;
  322. case 0x1:
  323. seq_printf(m, "512KiB\n");
  324. break;
  325. case 0x2:
  326. seq_printf(m, "1MiB\n");
  327. break;
  328. default:
  329. seq_printf(m, "unknown size\n");
  330. break;
  331. }
  332. }
  333. return 0;
  334. }
  335. /* Used by all Motorola PReP */
  336. static int
  337. prep_mot_cpuinfo(struct seq_file *m)
  338. {
  339. unsigned int cachew = *((unsigned char *)CACHECRBA);
  340. seq_printf(m, "machine\t\t: PReP %s\n", Motherboard_map_name);
  341. /* report amount and type of L2 cache present */
  342. seq_printf(m, "l2 cache\t: ");
  343. switch (cachew & L2CACHE_MASK) {
  344. case L2CACHE_512KB:
  345. seq_printf(m, "512KiB");
  346. break;
  347. case L2CACHE_256KB:
  348. seq_printf(m, "256KiB");
  349. break;
  350. case L2CACHE_1MB:
  351. seq_printf(m, "1MiB");
  352. break;
  353. case L2CACHE_NONE:
  354. seq_printf(m, "none\n");
  355. goto no_l2;
  356. break;
  357. default:
  358. seq_printf(m, "%x\n", cachew);
  359. }
  360. seq_printf(m, ", parity %s",
  361. (cachew & L2CACHE_PARITY)? "enabled" : "disabled");
  362. seq_printf(m, " SRAM:");
  363. switch ( ((cachew & 0xf0) >> 4) & ~(0x3) ) {
  364. case 1: seq_printf(m, "synchronous, parity, flow-through\n");
  365. break;
  366. case 2: seq_printf(m, "asynchronous, no parity\n");
  367. break;
  368. case 3: seq_printf(m, "asynchronous, parity\n");
  369. break;
  370. default:seq_printf(m, "synchronous, pipelined, no parity\n");
  371. break;
  372. }
  373. no_l2:
  374. /* print info about SIMMs */
  375. if (have_residual_data) {
  376. int i;
  377. seq_printf(m, "simms\t\t: ");
  378. for (i = 0; (res->ActualNumMemories) && (i < MAX_MEMS); i++) {
  379. if (res->Memories[i].SIMMSize != 0)
  380. seq_printf(m, "%d:%ldM ", i,
  381. (res->Memories[i].SIMMSize > 1024) ?
  382. res->Memories[i].SIMMSize>>20 :
  383. res->Memories[i].SIMMSize);
  384. }
  385. seq_printf(m, "\n");
  386. }
  387. return 0;
  388. }
  389. static void
  390. prep_restart(char *cmd)
  391. {
  392. #define PREP_SP92 0x92 /* Special Port 92 */
  393. local_irq_disable(); /* no interrupts */
  394. /* set exception prefix high - to the prom */
  395. _nmask_and_or_msr(0, MSR_IP);
  396. /* make sure bit 0 (reset) is a 0 */
  397. outb( inb(PREP_SP92) & ~1L , PREP_SP92);
  398. /* signal a reset to system control port A - soft reset */
  399. outb( inb(PREP_SP92) | 1 , PREP_SP92);
  400. while ( 1 ) ;
  401. /* not reached */
  402. #undef PREP_SP92
  403. }
  404. static void
  405. prep_halt(void)
  406. {
  407. local_irq_disable(); /* no interrupts */
  408. /* set exception prefix high - to the prom */
  409. _nmask_and_or_msr(0, MSR_IP);
  410. while ( 1 ) ;
  411. /* not reached */
  412. }
  413. /* Carrera is the power manager in the Thinkpads. Unfortunately not much is
  414. * known about it, so we can't power down.
  415. */
  416. static void
  417. prep_carrera_poweroff(void)
  418. {
  419. prep_halt();
  420. }
  421. /*
  422. * On most IBM PReP's, power management is handled by a Signetics 87c750
  423. * behind the Utah component on the ISA bus. To access the 750 you must write
  424. * a series of nibbles to port 0x82a (decoded by the Utah). This is described
  425. * somewhat in the IBM Carolina Technical Specification.
  426. * -Hollis
  427. */
  428. static void
  429. utah_sig87c750_setbit(unsigned int bytenum, unsigned int bitnum, int value)
  430. {
  431. /*
  432. * byte1: 0 0 0 1 0 d a5 a4
  433. * byte2: 0 0 0 1 a3 a2 a1 a0
  434. *
  435. * d = the bit's value, enabled or disabled
  436. * (a5 a4 a3) = the byte number, minus 20
  437. * (a2 a1 a0) = the bit number
  438. *
  439. * example: set the 5th bit of byte 21 (21.5)
  440. * a5 a4 a3 = 001 (byte 1)
  441. * a2 a1 a0 = 101 (bit 5)
  442. *
  443. * byte1 = 0001 0100 (0x14)
  444. * byte2 = 0001 1101 (0x1d)
  445. */
  446. unsigned char byte1=0x10, byte2=0x10;
  447. /* the 750's '20.0' is accessed as '0.0' through Utah (which adds 20) */
  448. bytenum -= 20;
  449. byte1 |= (!!value) << 2; /* set d */
  450. byte1 |= (bytenum >> 1) & 0x3; /* set a5, a4 */
  451. byte2 |= (bytenum & 0x1) << 3; /* set a3 */
  452. byte2 |= bitnum & 0x7; /* set a2, a1, a0 */
  453. outb(byte1, PREP_IBM_PM1); /* first nibble */
  454. mb();
  455. udelay(100); /* important: let controller recover */
  456. outb(byte2, PREP_IBM_PM1); /* second nibble */
  457. mb();
  458. udelay(100); /* important: let controller recover */
  459. }
  460. static void
  461. prep_sig750_poweroff(void)
  462. {
  463. /* tweak the power manager found in most IBM PRePs (except Thinkpads) */
  464. local_irq_disable();
  465. /* set exception prefix high - to the prom */
  466. _nmask_and_or_msr(0, MSR_IP);
  467. utah_sig87c750_setbit(21, 5, 1); /* set bit 21.5, "PMEXEC_OFF" */
  468. while (1) ;
  469. /* not reached */
  470. }
  471. static int
  472. prep_show_percpuinfo(struct seq_file *m, int i)
  473. {
  474. /* PREP's without residual data will give incorrect values here */
  475. seq_printf(m, "clock\t\t: ");
  476. if (have_residual_data)
  477. seq_printf(m, "%ldMHz\n",
  478. (res->VitalProductData.ProcessorHz > 1024) ?
  479. res->VitalProductData.ProcessorHz / 1000000 :
  480. res->VitalProductData.ProcessorHz);
  481. else
  482. seq_printf(m, "???\n");
  483. return 0;
  484. }
  485. /*
  486. * Fill out screen_info according to the residual data. This allows us to use
  487. * at least vesafb.
  488. */
  489. static void __init
  490. prep_init_vesa(void)
  491. {
  492. #if (defined(CONFIG_FB_VGA16) || defined(CONFIG_FB_VGA16_MODULE) || \
  493. defined(CONFIG_FB_VESA))
  494. PPC_DEVICE *vgadev = NULL;
  495. if (have_residual_data)
  496. vgadev = residual_find_device(~0, NULL, DisplayController,
  497. SVGAController, -1, 0);
  498. if (vgadev != NULL) {
  499. PnP_TAG_PACKET *pkt;
  500. pkt = PnP_find_large_vendor_packet(
  501. (unsigned char *)&res->DevicePnPHeap[vgadev->AllocatedOffset],
  502. 0x04, 0); /* 0x04 = Display Tag */
  503. if (pkt != NULL) {
  504. unsigned char *ptr = (unsigned char *)pkt;
  505. if (ptr[4]) {
  506. /* graphics mode */
  507. screen_info.orig_video_isVGA = VIDEO_TYPE_VLFB;
  508. screen_info.lfb_depth = ptr[4] * 8;
  509. screen_info.lfb_width = swab16(*(short *)(ptr+6));
  510. screen_info.lfb_height = swab16(*(short *)(ptr+8));
  511. screen_info.lfb_linelength = swab16(*(short *)(ptr+10));
  512. screen_info.lfb_base = swab32(*(long *)(ptr+12));
  513. screen_info.lfb_size = swab32(*(long *)(ptr+20)) / 65536;
  514. }
  515. }
  516. }
  517. #endif
  518. }
  519. /*
  520. * Set DBAT 2 to access 0x80000000 so early progress messages will work
  521. */
  522. static __inline__ void
  523. prep_set_bat(void)
  524. {
  525. /* wait for all outstanding memory access to complete */
  526. mb();
  527. /* setup DBATs */
  528. mtspr(SPRN_DBAT2U, 0x80001ffe);
  529. mtspr(SPRN_DBAT2L, 0x8000002a);
  530. /* wait for updates */
  531. mb();
  532. }
  533. /*
  534. * IBM 3-digit status LED
  535. */
  536. static unsigned int ibm_statusled_base;
  537. static void
  538. ibm_statusled_progress(char *s, unsigned short hex);
  539. static int
  540. ibm_statusled_panic(struct notifier_block *dummy1, unsigned long dummy2,
  541. void * dummy3)
  542. {
  543. ibm_statusled_progress(NULL, 0x505); /* SOS */
  544. return NOTIFY_DONE;
  545. }
  546. static struct notifier_block ibm_statusled_block = {
  547. ibm_statusled_panic,
  548. NULL,
  549. INT_MAX /* try to do it first */
  550. };
  551. static void
  552. ibm_statusled_progress(char *s, unsigned short hex)
  553. {
  554. static int notifier_installed;
  555. /*
  556. * Progress uses 4 digits and we have only 3. So, we map 0xffff to
  557. * 0xfff for display switch off. Out of range values are mapped to
  558. * 0xeff, as I'm told 0xf00 and above are reserved for hardware codes.
  559. * Install the panic notifier when the display is first switched off.
  560. */
  561. if (hex == 0xffff) {
  562. hex = 0xfff;
  563. if (!notifier_installed) {
  564. ++notifier_installed;
  565. atomic_notifier_chain_register(&panic_notifier_list,
  566. &ibm_statusled_block);
  567. }
  568. }
  569. else
  570. if (hex > 0xfff)
  571. hex = 0xeff;
  572. mb();
  573. outw(hex, ibm_statusled_base);
  574. }
  575. static void __init
  576. ibm_statusled_init(void)
  577. {
  578. /*
  579. * The IBM 3-digit LED display is specified in the residual data
  580. * as an operator panel device, type "System Status LED". Find
  581. * that device and determine its address. We validate all the
  582. * other parameters on the off-chance another, similar device
  583. * exists.
  584. */
  585. if (have_residual_data) {
  586. PPC_DEVICE *led;
  587. PnP_TAG_PACKET *pkt;
  588. led = residual_find_device(~0, NULL, SystemPeripheral,
  589. OperatorPanel, SystemStatusLED, 0);
  590. if (!led)
  591. return;
  592. pkt = PnP_find_packet((unsigned char *)
  593. &res->DevicePnPHeap[led->AllocatedOffset], S8_Packet, 0);
  594. if (!pkt)
  595. return;
  596. if (pkt->S8_Pack.IOInfo != ISAAddr16bit)
  597. return;
  598. if (*(unsigned short *)pkt->S8_Pack.RangeMin !=
  599. *(unsigned short *)pkt->S8_Pack.RangeMax)
  600. return;
  601. if (pkt->S8_Pack.IOAlign != 2)
  602. return;
  603. if (pkt->S8_Pack.IONum != 2)
  604. return;
  605. ibm_statusled_base = ld_le16((unsigned short *)
  606. (pkt->S8_Pack.RangeMin));
  607. ppc_md.progress = ibm_statusled_progress;
  608. }
  609. }
  610. static void __init
  611. prep_setup_arch(void)
  612. {
  613. unsigned char reg;
  614. int is_ide=0;
  615. /* init to some ~sane value until calibrate_delay() runs */
  616. loops_per_jiffy = 50000000;
  617. /* Lookup PCI host bridges */
  618. prep_find_bridges();
  619. /* Set up floppy in PS/2 mode */
  620. outb(0x09, SIO_CONFIG_RA);
  621. reg = inb(SIO_CONFIG_RD);
  622. reg = (reg & 0x3F) | 0x40;
  623. outb(reg, SIO_CONFIG_RD);
  624. outb(reg, SIO_CONFIG_RD); /* Have to write twice to change! */
  625. switch ( _prep_type )
  626. {
  627. case _PREP_IBM:
  628. reg = inb(PREP_IBM_PLANAR);
  629. printk(KERN_INFO "IBM planar ID: %02x", reg);
  630. switch (reg) {
  631. case PREP_IBM_SANDALFOOT:
  632. prep_gen_enable_l2();
  633. setup_ibm_pci = prep_sandalfoot_setup_pci;
  634. ppc_md.power_off = prep_sig750_poweroff;
  635. ppc_md.show_cpuinfo = prep_sandalfoot_cpuinfo;
  636. break;
  637. case PREP_IBM_THINKPAD:
  638. prep_gen_enable_l2();
  639. setup_ibm_pci = prep_thinkpad_setup_pci;
  640. ppc_md.power_off = prep_carrera_poweroff;
  641. ppc_md.show_cpuinfo = prep_thinkpad_cpuinfo;
  642. break;
  643. default:
  644. if (have_residual_data) {
  645. prep_gen_enable_l2();
  646. setup_ibm_pci = prep_residual_setup_pci;
  647. ppc_md.power_off = prep_halt;
  648. ppc_md.show_cpuinfo = prep_gen_cpuinfo;
  649. break;
  650. }
  651. else
  652. printk(" - unknown! Assuming Carolina");
  653. /* fall through */
  654. case PREP_IBM_CAROLINA_IDE_0:
  655. case PREP_IBM_CAROLINA_IDE_1:
  656. case PREP_IBM_CAROLINA_IDE_2:
  657. case PREP_IBM_CAROLINA_IDE_3:
  658. is_ide = 1;
  659. case PREP_IBM_CAROLINA_SCSI_0:
  660. case PREP_IBM_CAROLINA_SCSI_1:
  661. case PREP_IBM_CAROLINA_SCSI_2:
  662. case PREP_IBM_CAROLINA_SCSI_3:
  663. prep_carolina_enable_l2();
  664. setup_ibm_pci = prep_carolina_setup_pci;
  665. ppc_md.power_off = prep_sig750_poweroff;
  666. ppc_md.show_cpuinfo = prep_carolina_cpuinfo;
  667. break;
  668. case PREP_IBM_TIGER1_133:
  669. case PREP_IBM_TIGER1_166:
  670. case PREP_IBM_TIGER1_180:
  671. case PREP_IBM_TIGER1_xxx:
  672. case PREP_IBM_TIGER1_333:
  673. prep_carolina_enable_l2();
  674. setup_ibm_pci = prep_tiger1_setup_pci;
  675. ppc_md.power_off = prep_sig750_poweroff;
  676. ppc_md.show_cpuinfo = prep_tiger1_cpuinfo;
  677. break;
  678. }
  679. printk("\n");
  680. /* default root device */
  681. if (is_ide)
  682. ROOT_DEV = MKDEV(IDE0_MAJOR, 3);
  683. else
  684. ROOT_DEV = MKDEV(SCSI_DISK0_MAJOR, 3);
  685. break;
  686. case _PREP_Motorola:
  687. prep_gen_enable_l2();
  688. ppc_md.power_off = prep_halt;
  689. ppc_md.show_cpuinfo = prep_mot_cpuinfo;
  690. #ifdef CONFIG_BLK_DEV_INITRD
  691. if (initrd_start)
  692. ROOT_DEV = Root_RAM0;
  693. else
  694. #endif
  695. #ifdef CONFIG_ROOT_NFS
  696. ROOT_DEV = Root_NFS;
  697. #else
  698. ROOT_DEV = Root_SDA2;
  699. #endif
  700. break;
  701. }
  702. /* Read in NVRAM data */
  703. init_prep_nvram();
  704. /* if no bootargs, look in NVRAM */
  705. if ( cmd_line[0] == '\0' ) {
  706. char *bootargs;
  707. bootargs = prep_nvram_get_var("bootargs");
  708. if (bootargs != NULL) {
  709. strcpy(cmd_line, bootargs);
  710. /* again.. */
  711. strcpy(boot_command_line, cmd_line);
  712. }
  713. }
  714. prep_init_vesa();
  715. switch (_prep_type) {
  716. case _PREP_Motorola:
  717. raven_init();
  718. break;
  719. case _PREP_IBM:
  720. ibm_prep_init();
  721. break;
  722. }
  723. #ifdef CONFIG_VGA_CONSOLE
  724. /* vgacon.c needs to know where we mapped IO memory in io_block_mapping() */
  725. vgacon_remap_base = 0xf0000000;
  726. conswitchp = &vga_con;
  727. #endif
  728. }
  729. /*
  730. * First, see if we can get this information from the residual data.
  731. * This is important on some IBM PReP systems. If we cannot, we let the
  732. * TODC code handle doing this.
  733. */
  734. static void __init
  735. prep_calibrate_decr(void)
  736. {
  737. if (have_residual_data) {
  738. unsigned long freq, divisor = 4;
  739. if ( res->VitalProductData.ProcessorBusHz ) {
  740. freq = res->VitalProductData.ProcessorBusHz;
  741. printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
  742. (freq/divisor)/1000000,
  743. (freq/divisor)%1000000);
  744. tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
  745. tb_ticks_per_jiffy = freq / HZ / divisor;
  746. }
  747. }
  748. else
  749. todc_calibrate_decr();
  750. }
  751. static void __init
  752. prep_init_IRQ(void)
  753. {
  754. unsigned int pci_viddid, pci_did;
  755. if (OpenPIC_Addr != NULL) {
  756. openpic_init(NUM_8259_INTERRUPTS);
  757. /* We have a cascade on OpenPIC IRQ 0, Linux IRQ 16 */
  758. openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
  759. i8259_irq);
  760. }
  761. if (have_residual_data) {
  762. i8259_init(residual_isapic_addr(), 0);
  763. return;
  764. }
  765. /* If we have a Raven PCI bridge or a Hawk PCI bridge / Memory
  766. * controller, we poll (as they have a different int-ack address). */
  767. early_read_config_dword(NULL, 0, 0, PCI_VENDOR_ID, &pci_viddid);
  768. pci_did = (pci_viddid & 0xffff0000) >> 16;
  769. if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_MOTOROLA)
  770. && ((pci_did == PCI_DEVICE_ID_MOTOROLA_RAVEN)
  771. || (pci_did == PCI_DEVICE_ID_MOTOROLA_HAWK)))
  772. i8259_init(0, 0);
  773. else
  774. /* PCI interrupt ack address given in section 6.1.8 of the
  775. * PReP specification. */
  776. i8259_init(MPC10X_MAPA_PCI_INTACK_ADDR, 0);
  777. }
  778. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  779. /*
  780. * IDE stuff.
  781. */
  782. static int
  783. prep_ide_default_irq(unsigned long base)
  784. {
  785. switch (base) {
  786. case 0x1f0: return 13;
  787. case 0x170: return 13;
  788. case 0x1e8: return 11;
  789. case 0x168: return 10;
  790. case 0xfff0: return 14; /* MCP(N)750 ide0 */
  791. case 0xffe0: return 15; /* MCP(N)750 ide1 */
  792. default: return 0;
  793. }
  794. }
  795. static unsigned long
  796. prep_ide_default_io_base(int index)
  797. {
  798. switch (index) {
  799. case 0: return 0x1f0;
  800. case 1: return 0x170;
  801. case 2: return 0x1e8;
  802. case 3: return 0x168;
  803. default:
  804. return 0;
  805. }
  806. }
  807. #endif
  808. #ifdef CONFIG_SMP
  809. /* PReP (MTX) support */
  810. static int __init
  811. smp_prep_probe(void)
  812. {
  813. extern int mot_multi;
  814. if (mot_multi) {
  815. openpic_request_IPIs();
  816. smp_hw_index[1] = 1;
  817. return 2;
  818. }
  819. return 1;
  820. }
  821. static void __init
  822. smp_prep_kick_cpu(int nr)
  823. {
  824. *(unsigned long *)KERNELBASE = nr;
  825. asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
  826. printk("CPU1 released, waiting\n");
  827. }
  828. static void __init
  829. smp_prep_setup_cpu(int cpu_nr)
  830. {
  831. if (OpenPIC_Addr)
  832. do_openpic_setup_cpu();
  833. }
  834. static struct smp_ops_t prep_smp_ops = {
  835. smp_openpic_message_pass,
  836. smp_prep_probe,
  837. smp_prep_kick_cpu,
  838. smp_prep_setup_cpu,
  839. .give_timebase = smp_generic_give_timebase,
  840. .take_timebase = smp_generic_take_timebase,
  841. };
  842. #endif /* CONFIG_SMP */
  843. /*
  844. * Setup the bat mappings we're going to load that cover
  845. * the io areas. RAM was mapped by mapin_ram().
  846. * -- Cort
  847. */
  848. static void __init
  849. prep_map_io(void)
  850. {
  851. io_block_mapping(0x80000000, PREP_ISA_IO_BASE, 0x10000000, _PAGE_IO);
  852. io_block_mapping(0xf0000000, PREP_ISA_MEM_BASE, 0x08000000, _PAGE_IO);
  853. }
  854. static int __init
  855. prep_request_io(void)
  856. {
  857. #ifdef CONFIG_NVRAM
  858. request_region(PREP_NVRAM_AS0, 0x8, "nvram");
  859. #endif
  860. request_region(0x00,0x20,"dma1");
  861. request_region(0x40,0x20,"timer");
  862. request_region(0x80,0x10,"dma page reg");
  863. request_region(0xc0,0x20,"dma2");
  864. return 0;
  865. }
  866. device_initcall(prep_request_io);
  867. void __init
  868. prep_init(unsigned long r3, unsigned long r4, unsigned long r5,
  869. unsigned long r6, unsigned long r7)
  870. {
  871. #ifdef CONFIG_PREP_RESIDUAL
  872. /* make a copy of residual data */
  873. if ( r3 ) {
  874. memcpy((void *)res,(void *)(r3+KERNELBASE),
  875. sizeof(RESIDUAL));
  876. }
  877. #endif
  878. isa_io_base = PREP_ISA_IO_BASE;
  879. isa_mem_base = PREP_ISA_MEM_BASE;
  880. pci_dram_offset = PREP_PCI_DRAM_OFFSET;
  881. ISA_DMA_THRESHOLD = 0x00ffffff;
  882. DMA_MODE_READ = 0x44;
  883. DMA_MODE_WRITE = 0x48;
  884. ppc_do_canonicalize_irqs = 1;
  885. /* figure out what kind of prep workstation we are */
  886. if (have_residual_data) {
  887. if ( !strncmp(res->VitalProductData.PrintableModel,"IBM",3) )
  888. _prep_type = _PREP_IBM;
  889. else
  890. _prep_type = _PREP_Motorola;
  891. }
  892. else {
  893. /* assume motorola if no residual (netboot?) */
  894. _prep_type = _PREP_Motorola;
  895. }
  896. #ifdef CONFIG_PREP_RESIDUAL
  897. /* Switch off all residual data processing if the user requests it */
  898. if (strstr(cmd_line, "noresidual") != NULL)
  899. res = NULL;
  900. #endif
  901. /* Initialise progress early to get maximum benefit */
  902. prep_set_bat();
  903. ibm_statusled_init();
  904. ppc_md.setup_arch = prep_setup_arch;
  905. ppc_md.show_percpuinfo = prep_show_percpuinfo;
  906. ppc_md.show_cpuinfo = NULL; /* set in prep_setup_arch() */
  907. ppc_md.init_IRQ = prep_init_IRQ;
  908. /* this gets changed later on if we have an OpenPIC -- Cort */
  909. ppc_md.get_irq = i8259_irq;
  910. ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;
  911. ppc_md.restart = prep_restart;
  912. ppc_md.power_off = NULL; /* set in prep_setup_arch() */
  913. ppc_md.halt = prep_halt;
  914. ppc_md.nvram_read_val = prep_nvram_read_val;
  915. ppc_md.nvram_write_val = prep_nvram_write_val;
  916. ppc_md.time_init = todc_time_init;
  917. if (_prep_type == _PREP_IBM) {
  918. ppc_md.rtc_read_val = todc_mc146818_read_val;
  919. ppc_md.rtc_write_val = todc_mc146818_write_val;
  920. TODC_INIT(TODC_TYPE_MC146818, RTC_PORT(0), NULL, RTC_PORT(1),
  921. 8);
  922. } else {
  923. TODC_INIT(TODC_TYPE_MK48T59, PREP_NVRAM_AS0, PREP_NVRAM_AS1,
  924. PREP_NVRAM_DATA, 8);
  925. }
  926. ppc_md.calibrate_decr = prep_calibrate_decr;
  927. ppc_md.set_rtc_time = todc_set_rtc_time;
  928. ppc_md.get_rtc_time = todc_get_rtc_time;
  929. ppc_md.setup_io_mappings = prep_map_io;
  930. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  931. ppc_ide_md.default_irq = prep_ide_default_irq;
  932. ppc_ide_md.default_io_base = prep_ide_default_io_base;
  933. #endif
  934. #ifdef CONFIG_SMP
  935. smp_ops = &prep_smp_ops;
  936. #endif /* CONFIG_SMP */
  937. }