prep_setup.c 28 KB

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