prep_setup.c 25 KB

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