radstone_ppc7d.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493
  1. /*
  2. * Board setup routines for the Radstone PPC7D boards.
  3. *
  4. * Author: James Chapman <jchapman@katalix.com>
  5. *
  6. * Based on code done by Rabeeh Khoury - rabeeh@galileo.co.il
  7. * Based on code done by - Mark A. Greer <mgreer@mvista.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. /* Radstone PPC7D boards are rugged VME boards with PPC 7447A CPUs,
  15. * Discovery-II, dual gigabit ethernet, dual PMC, USB, keyboard/mouse,
  16. * 4 serial ports, 2 high speed serial ports (MPSCs) and optional
  17. * SCSI / VGA.
  18. */
  19. #include <linux/config.h>
  20. #include <linux/stddef.h>
  21. #include <linux/kernel.h>
  22. #include <linux/init.h>
  23. #include <linux/errno.h>
  24. #include <linux/reboot.h>
  25. #include <linux/pci.h>
  26. #include <linux/kdev_t.h>
  27. #include <linux/major.h>
  28. #include <linux/initrd.h>
  29. #include <linux/console.h>
  30. #include <linux/delay.h>
  31. #include <linux/ide.h>
  32. #include <linux/seq_file.h>
  33. #include <linux/root_dev.h>
  34. #include <linux/serial.h>
  35. #include <linux/tty.h> /* for linux/serial_core.h */
  36. #include <linux/serial_core.h>
  37. #include <linux/mv643xx.h>
  38. #include <linux/netdevice.h>
  39. #include <linux/platform_device.h>
  40. #include <asm/system.h>
  41. #include <asm/pgtable.h>
  42. #include <asm/page.h>
  43. #include <asm/time.h>
  44. #include <asm/dma.h>
  45. #include <asm/io.h>
  46. #include <asm/machdep.h>
  47. #include <asm/prom.h>
  48. #include <asm/smp.h>
  49. #include <asm/vga.h>
  50. #include <asm/open_pic.h>
  51. #include <asm/i8259.h>
  52. #include <asm/todc.h>
  53. #include <asm/bootinfo.h>
  54. #include <asm/mpc10x.h>
  55. #include <asm/pci-bridge.h>
  56. #include <asm/mv64x60.h>
  57. #include "radstone_ppc7d.h"
  58. #undef DEBUG
  59. #define PPC7D_RST_PIN 17 /* GPP17 */
  60. extern u32 mv64360_irq_base;
  61. extern spinlock_t rtc_lock;
  62. static struct mv64x60_handle bh;
  63. static int ppc7d_has_alma;
  64. extern void gen550_progress(char *, unsigned short);
  65. extern void gen550_init(int, struct uart_port *);
  66. /* FIXME - move to h file */
  67. extern int ds1337_do_command(int id, int cmd, void *arg);
  68. #define DS1337_GET_DATE 0
  69. #define DS1337_SET_DATE 1
  70. /* residual data */
  71. unsigned char __res[sizeof(bd_t)];
  72. /*****************************************************************************
  73. * Serial port code
  74. *****************************************************************************/
  75. #if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
  76. static void __init ppc7d_early_serial_map(void)
  77. {
  78. #if defined(CONFIG_SERIAL_MPSC_CONSOLE)
  79. mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
  80. #elif defined(CONFIG_SERIAL_8250)
  81. struct uart_port serial_req;
  82. /* Setup serial port access */
  83. memset(&serial_req, 0, sizeof(serial_req));
  84. serial_req.uartclk = UART_CLK;
  85. serial_req.irq = 4;
  86. serial_req.flags = STD_COM_FLAGS;
  87. serial_req.iotype = UPIO_MEM;
  88. serial_req.membase = (u_char *) PPC7D_SERIAL_0;
  89. gen550_init(0, &serial_req);
  90. if (early_serial_setup(&serial_req) != 0)
  91. printk(KERN_ERR "Early serial init of port 0 failed\n");
  92. /* Assume early_serial_setup() doesn't modify serial_req */
  93. serial_req.line = 1;
  94. serial_req.irq = 3;
  95. serial_req.membase = (u_char *) PPC7D_SERIAL_1;
  96. gen550_init(1, &serial_req);
  97. if (early_serial_setup(&serial_req) != 0)
  98. printk(KERN_ERR "Early serial init of port 1 failed\n");
  99. #else
  100. #error CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG has no supported CONFIG_SERIAL_XXX
  101. #endif
  102. }
  103. #endif /* CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG */
  104. /*****************************************************************************
  105. * Low-level board support code
  106. *****************************************************************************/
  107. static unsigned long __init ppc7d_find_end_of_memory(void)
  108. {
  109. bd_t *bp = (bd_t *) __res;
  110. if (bp->bi_memsize)
  111. return bp->bi_memsize;
  112. return (256 * 1024 * 1024);
  113. }
  114. static void __init ppc7d_map_io(void)
  115. {
  116. /* remove temporary mapping */
  117. mtspr(SPRN_DBAT3U, 0x00000000);
  118. mtspr(SPRN_DBAT3L, 0x00000000);
  119. io_block_mapping(0xe8000000, 0xe8000000, 0x08000000, _PAGE_IO);
  120. io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
  121. }
  122. static void ppc7d_restart(char *cmd)
  123. {
  124. u32 data;
  125. /* Disable GPP17 interrupt */
  126. data = mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
  127. data &= ~(1 << PPC7D_RST_PIN);
  128. mv64x60_write(&bh, MV64x60_GPP_INTR_MASK, data);
  129. /* Configure MPP17 as GPP */
  130. data = mv64x60_read(&bh, MV64x60_MPP_CNTL_2);
  131. data &= ~(0x0000000f << 4);
  132. mv64x60_write(&bh, MV64x60_MPP_CNTL_2, data);
  133. /* Enable pin GPP17 for output */
  134. data = mv64x60_read(&bh, MV64x60_GPP_IO_CNTL);
  135. data |= (1 << PPC7D_RST_PIN);
  136. mv64x60_write(&bh, MV64x60_GPP_IO_CNTL, data);
  137. /* Toggle GPP9 pin to reset the board */
  138. mv64x60_write(&bh, MV64x60_GPP_VALUE_CLR, 1 << PPC7D_RST_PIN);
  139. mv64x60_write(&bh, MV64x60_GPP_VALUE_SET, 1 << PPC7D_RST_PIN);
  140. for (;;) ; /* Spin until reset happens */
  141. /* NOTREACHED */
  142. }
  143. static void ppc7d_power_off(void)
  144. {
  145. u32 data;
  146. local_irq_disable();
  147. /* Ensure that internal MV643XX watchdog is disabled.
  148. * The Disco watchdog uses MPP17 on this hardware.
  149. */
  150. data = mv64x60_read(&bh, MV64x60_MPP_CNTL_2);
  151. data &= ~(0x0000000f << 4);
  152. mv64x60_write(&bh, MV64x60_MPP_CNTL_2, data);
  153. data = mv64x60_read(&bh, MV64x60_WDT_WDC);
  154. if (data & 0x80000000) {
  155. mv64x60_write(&bh, MV64x60_WDT_WDC, 1 << 24);
  156. mv64x60_write(&bh, MV64x60_WDT_WDC, 2 << 24);
  157. }
  158. for (;;) ; /* No way to shut power off with software */
  159. /* NOTREACHED */
  160. }
  161. static void ppc7d_halt(void)
  162. {
  163. ppc7d_power_off();
  164. /* NOTREACHED */
  165. }
  166. static unsigned long ppc7d_led_no_pulse;
  167. static int __init ppc7d_led_pulse_disable(char *str)
  168. {
  169. ppc7d_led_no_pulse = 1;
  170. return 1;
  171. }
  172. /* This kernel option disables the heartbeat pulsing of a board LED */
  173. __setup("ledoff", ppc7d_led_pulse_disable);
  174. static void ppc7d_heartbeat(void)
  175. {
  176. u32 data32;
  177. u8 data8;
  178. static int max706_wdog = 0;
  179. /* Unfortunately we can't access the LED control registers
  180. * during early init because they're on the CPLD which is the
  181. * other side of a PCI bridge which goes unreachable during
  182. * PCI scan. So write the LEDs only if the MV64360 watchdog is
  183. * enabled (i.e. userspace apps are running so kernel is up)..
  184. */
  185. data32 = mv64x60_read(&bh, MV64x60_WDT_WDC);
  186. if (data32 & 0x80000000) {
  187. /* Enable MAX706 watchdog if not done already */
  188. if (!max706_wdog) {
  189. outb(3, PPC7D_CPLD_RESET);
  190. max706_wdog = 1;
  191. }
  192. /* Hit the MAX706 watchdog */
  193. outb(0, PPC7D_CPLD_WATCHDOG_TRIG);
  194. /* Pulse LED DS219 if not disabled */
  195. if (!ppc7d_led_no_pulse) {
  196. static int led_on = 0;
  197. data8 = inb(PPC7D_CPLD_LEDS);
  198. if (led_on)
  199. data8 &= ~PPC7D_CPLD_LEDS_DS219_MASK;
  200. else
  201. data8 |= PPC7D_CPLD_LEDS_DS219_MASK;
  202. outb(data8, PPC7D_CPLD_LEDS);
  203. led_on = !led_on;
  204. }
  205. }
  206. ppc_md.heartbeat_count = ppc_md.heartbeat_reset;
  207. }
  208. static int ppc7d_show_cpuinfo(struct seq_file *m)
  209. {
  210. u8 val;
  211. u8 val1, val2;
  212. static int flash_sizes[4] = { 64, 32, 0, 16 };
  213. static int flash_banks[4] = { 4, 3, 2, 1 };
  214. static int sdram_bank_sizes[4] = { 128, 256, 512, 1 };
  215. int sdram_num_banks = 2;
  216. static char *pci_modes[] = { "PCI33", "PCI66",
  217. "Unknown", "Unknown",
  218. "PCIX33", "PCIX66",
  219. "PCIX100", "PCIX133"
  220. };
  221. seq_printf(m, "vendor\t\t: Radstone Technology\n");
  222. seq_printf(m, "machine\t\t: PPC7D\n");
  223. val = inb(PPC7D_CPLD_BOARD_REVISION);
  224. val1 = (val & PPC7D_CPLD_BOARD_REVISION_NUMBER_MASK) >> 5;
  225. val2 = (val & PPC7D_CPLD_BOARD_REVISION_LETTER_MASK);
  226. seq_printf(m, "revision\t: %hd%c%c\n",
  227. val1,
  228. (val2 <= 0x18) ? 'A' + val2 : 'Y',
  229. (val2 > 0x18) ? 'A' + (val2 - 0x19) : ' ');
  230. val = inb(PPC7D_CPLD_MOTHERBOARD_TYPE);
  231. val1 = val & PPC7D_CPLD_MB_TYPE_PLL_MASK;
  232. val2 = val & (PPC7D_CPLD_MB_TYPE_ECC_FITTED_MASK |
  233. PPC7D_CPLD_MB_TYPE_ECC_ENABLE_MASK);
  234. seq_printf(m, "bus speed\t: %dMHz\n",
  235. (val1 == PPC7D_CPLD_MB_TYPE_PLL_133) ? 133 :
  236. (val1 == PPC7D_CPLD_MB_TYPE_PLL_100) ? 100 :
  237. (val1 == PPC7D_CPLD_MB_TYPE_PLL_64) ? 64 : 0);
  238. val = inb(PPC7D_CPLD_MEM_CONFIG);
  239. if (val & PPC7D_CPLD_SDRAM_BANK_NUM_MASK) sdram_num_banks--;
  240. val = inb(PPC7D_CPLD_MEM_CONFIG_EXTEND);
  241. val1 = (val & PPC7D_CPLD_SDRAM_BANK_SIZE_MASK) >> 6;
  242. seq_printf(m, "SDRAM\t\t: %d banks of %d%c, total %d%c",
  243. sdram_num_banks,
  244. sdram_bank_sizes[val1],
  245. (sdram_bank_sizes[val1] < 128) ? 'G' : 'M',
  246. sdram_num_banks * sdram_bank_sizes[val1],
  247. (sdram_bank_sizes[val1] < 128) ? 'G' : 'M');
  248. if (val2 & PPC7D_CPLD_MB_TYPE_ECC_FITTED_MASK) {
  249. seq_printf(m, " [ECC %sabled]",
  250. (val2 & PPC7D_CPLD_MB_TYPE_ECC_ENABLE_MASK) ? "en" :
  251. "dis");
  252. }
  253. seq_printf(m, "\n");
  254. val1 = (val & PPC7D_CPLD_FLASH_DEV_SIZE_MASK);
  255. val2 = (val & PPC7D_CPLD_FLASH_BANK_NUM_MASK) >> 2;
  256. seq_printf(m, "FLASH\t\t: %d banks of %dM, total %dM\n",
  257. flash_banks[val2], flash_sizes[val1],
  258. flash_banks[val2] * flash_sizes[val1]);
  259. val = inb(PPC7D_CPLD_FLASH_WRITE_CNTL);
  260. val1 = inb(PPC7D_CPLD_SW_FLASH_WRITE_PROTECT);
  261. seq_printf(m, " write links\t: %s%s%s%s\n",
  262. (val & PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK) ? "WRITE " : "",
  263. (val & PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK) ? "BOOT " : "",
  264. (val & PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK) ? "USER " : "",
  265. (val & (PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK |
  266. PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK |
  267. PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK)) ==
  268. 0 ? "NONE" : "");
  269. seq_printf(m, " write sector h/w enables: %s%s%s%s%s\n",
  270. (val & PPD7D_CPLD_FLASH_CNTL_RECO_WR_MASK) ? "RECOVERY " :
  271. "",
  272. (val & PPD7D_CPLD_FLASH_CNTL_BOOT_WR_MASK) ? "BOOT " : "",
  273. (val & PPD7D_CPLD_FLASH_CNTL_USER_WR_MASK) ? "USER " : "",
  274. (val1 & PPC7D_CPLD_FLASH_CNTL_NVRAM_PROT_MASK) ? "NVRAM " :
  275. "",
  276. (((val &
  277. (PPD7D_CPLD_FLASH_CNTL_RECO_WR_MASK |
  278. PPD7D_CPLD_FLASH_CNTL_BOOT_WR_MASK |
  279. PPD7D_CPLD_FLASH_CNTL_BOOT_WR_MASK)) == 0)
  280. && ((val1 & PPC7D_CPLD_FLASH_CNTL_NVRAM_PROT_MASK) ==
  281. 0)) ? "NONE" : "");
  282. val1 =
  283. inb(PPC7D_CPLD_SW_FLASH_WRITE_PROTECT) &
  284. (PPC7D_CPLD_SW_FLASH_WRPROT_SYSBOOT_MASK |
  285. PPC7D_CPLD_SW_FLASH_WRPROT_USER_MASK);
  286. seq_printf(m, " software sector enables: %s%s%s\n",
  287. (val1 & PPC7D_CPLD_SW_FLASH_WRPROT_SYSBOOT_MASK) ? "SYSBOOT "
  288. : "",
  289. (val1 & PPC7D_CPLD_SW_FLASH_WRPROT_USER_MASK) ? "USER " : "",
  290. (val1 == 0) ? "NONE " : "");
  291. seq_printf(m, "Boot options\t: %s%s%s%s\n",
  292. (val & PPC7D_CPLD_FLASH_CNTL_ALTBOOT_LINK_MASK) ?
  293. "ALTERNATE " : "",
  294. (val & PPC7D_CPLD_FLASH_CNTL_VMEBOOT_LINK_MASK) ? "VME " :
  295. "",
  296. (val & PPC7D_CPLD_FLASH_CNTL_RECBOOT_LINK_MASK) ? "RECOVERY "
  297. : "",
  298. ((val &
  299. (PPC7D_CPLD_FLASH_CNTL_ALTBOOT_LINK_MASK |
  300. PPC7D_CPLD_FLASH_CNTL_VMEBOOT_LINK_MASK |
  301. PPC7D_CPLD_FLASH_CNTL_RECBOOT_LINK_MASK)) ==
  302. 0) ? "NONE" : "");
  303. val = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_1);
  304. seq_printf(m, "Fitted modules\t: %s%s%s%s\n",
  305. (val & PPC7D_CPLD_EQPT_PRES_1_PMC1_MASK) ? "" : "PMC1 ",
  306. (val & PPC7D_CPLD_EQPT_PRES_1_PMC2_MASK) ? "" : "PMC2 ",
  307. (val & PPC7D_CPLD_EQPT_PRES_1_AFIX_MASK) ? "AFIX " : "",
  308. ((val & (PPC7D_CPLD_EQPT_PRES_1_PMC1_MASK |
  309. PPC7D_CPLD_EQPT_PRES_1_PMC2_MASK |
  310. PPC7D_CPLD_EQPT_PRES_1_AFIX_MASK)) ==
  311. (PPC7D_CPLD_EQPT_PRES_1_PMC1_MASK |
  312. PPC7D_CPLD_EQPT_PRES_1_PMC2_MASK)) ? "NONE" : "");
  313. if (val & PPC7D_CPLD_EQPT_PRES_1_AFIX_MASK) {
  314. static const char *ids[] = {
  315. "unknown",
  316. "1553 (Dual Channel)",
  317. "1553 (Single Channel)",
  318. "8-bit SCSI + VGA",
  319. "16-bit SCSI + VGA",
  320. "1553 (Single Channel with sideband)",
  321. "1553 (Dual Channel with sideband)",
  322. NULL
  323. };
  324. u8 id = __raw_readb((void *)PPC7D_AFIX_REG_BASE + 0x03);
  325. seq_printf(m, "AFIX module\t: 0x%hx [%s]\n", id,
  326. id < 7 ? ids[id] : "unknown");
  327. }
  328. val = inb(PPC7D_CPLD_PCI_CONFIG);
  329. val1 = (val & PPC7D_CPLD_PCI_CONFIG_PCI0_MASK) >> 4;
  330. val2 = (val & PPC7D_CPLD_PCI_CONFIG_PCI1_MASK);
  331. seq_printf(m, "PCI#0\t\t: %s\nPCI#1\t\t: %s\n",
  332. pci_modes[val1], pci_modes[val2]);
  333. val = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_2);
  334. seq_printf(m, "PMC1\t\t: %s\nPMC2\t\t: %s\n",
  335. (val & PPC7D_CPLD_EQPT_PRES_3_PMC1_V_MASK) ? "3.3v" : "5v",
  336. (val & PPC7D_CPLD_EQPT_PRES_3_PMC2_V_MASK) ? "3.3v" : "5v");
  337. seq_printf(m, "PMC power source: %s\n",
  338. (val & PPC7D_CPLD_EQPT_PRES_3_PMC_POWER_MASK) ? "VME" :
  339. "internal");
  340. val = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_4);
  341. val2 = inb(PPC7D_CPLD_EQUIPMENT_PRESENT_2);
  342. seq_printf(m, "Fit options\t: %s%s%s%s%s%s%s\n",
  343. (val & PPC7D_CPLD_EQPT_PRES_4_LPT_MASK) ? "LPT " : "",
  344. (val & PPC7D_CPLD_EQPT_PRES_4_PS2_FITTED) ? "PS2 " : "",
  345. (val & PPC7D_CPLD_EQPT_PRES_4_USB2_FITTED) ? "USB2 " : "",
  346. (val2 & PPC7D_CPLD_EQPT_PRES_2_UNIVERSE_MASK) ? "VME " : "",
  347. (val2 & PPC7D_CPLD_EQPT_PRES_2_COM36_MASK) ? "COM3-6 " : "",
  348. (val2 & PPC7D_CPLD_EQPT_PRES_2_GIGE_MASK) ? "eth0 " : "",
  349. (val2 & PPC7D_CPLD_EQPT_PRES_2_DUALGIGE_MASK) ? "eth1 " :
  350. "");
  351. val = inb(PPC7D_CPLD_ID_LINK);
  352. val1 = val & (PPC7D_CPLD_ID_LINK_E6_MASK |
  353. PPC7D_CPLD_ID_LINK_E7_MASK |
  354. PPC7D_CPLD_ID_LINK_E12_MASK |
  355. PPC7D_CPLD_ID_LINK_E13_MASK);
  356. val = inb(PPC7D_CPLD_FLASH_WRITE_CNTL) &
  357. (PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK |
  358. PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK |
  359. PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK);
  360. seq_printf(m, "Board links present: %s%s%s%s%s%s%s%s\n",
  361. (val1 & PPC7D_CPLD_ID_LINK_E6_MASK) ? "E6 " : "",
  362. (val1 & PPC7D_CPLD_ID_LINK_E7_MASK) ? "E7 " : "",
  363. (val & PPD7D_CPLD_FLASH_CNTL_WR_LINK_MASK) ? "E9 " : "",
  364. (val & PPD7D_CPLD_FLASH_CNTL_BOOT_LINK_MASK) ? "E10 " : "",
  365. (val & PPD7D_CPLD_FLASH_CNTL_USER_LINK_MASK) ? "E11 " : "",
  366. (val1 & PPC7D_CPLD_ID_LINK_E12_MASK) ? "E12 " : "",
  367. (val1 & PPC7D_CPLD_ID_LINK_E13_MASK) ? "E13 " : "",
  368. ((val == 0) && (val1 == 0)) ? "NONE" : "");
  369. val = inb(PPC7D_CPLD_WDOG_RESETSW_MASK);
  370. seq_printf(m, "Front panel reset switch: %sabled\n",
  371. (val & PPC7D_CPLD_WDOG_RESETSW_MASK) ? "dis" : "en");
  372. return 0;
  373. }
  374. static void __init ppc7d_calibrate_decr(void)
  375. {
  376. ulong freq;
  377. freq = 100000000 / 4;
  378. pr_debug("time_init: decrementer frequency = %lu.%.6lu MHz\n",
  379. freq / 1000000, freq % 1000000);
  380. tb_ticks_per_jiffy = freq / HZ;
  381. tb_to_us = mulhwu_scale_factor(freq, 1000000);
  382. }
  383. /*****************************************************************************
  384. * Interrupt stuff
  385. *****************************************************************************/
  386. static irqreturn_t ppc7d_i8259_intr(int irq, void *dev_id, struct pt_regs *regs)
  387. {
  388. u32 temp = mv64x60_read(&bh, MV64x60_GPP_INTR_CAUSE);
  389. if (temp & (1 << 28)) {
  390. i8259_irq(regs);
  391. mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, temp & (~(1 << 28)));
  392. return IRQ_HANDLED;
  393. }
  394. return IRQ_NONE;
  395. }
  396. /*
  397. * Each interrupt cause is assigned an IRQ number.
  398. * Southbridge has 16*2 (two 8259's) interrupts.
  399. * Discovery-II has 96 interrupts (cause-hi, cause-lo, gpp x 32).
  400. * If multiple interrupts are pending, get_irq() returns the
  401. * lowest pending irq number first.
  402. *
  403. *
  404. * IRQ # Source Trig Active
  405. * =============================================================
  406. *
  407. * Southbridge
  408. * -----------
  409. * IRQ # Source Trig
  410. * =============================================================
  411. * 0 ISA High Resolution Counter Edge
  412. * 1 Keyboard Edge
  413. * 2 Cascade From (IRQ 8-15) Edge
  414. * 3 Com 2 (Uart 2) Edge
  415. * 4 Com 1 (Uart 1) Edge
  416. * 5 PCI Int D/AFIX IRQZ ID4 (2,7) Level
  417. * 6 GPIO Level
  418. * 7 LPT Edge
  419. * 8 RTC Alarm Edge
  420. * 9 PCI Int A/PMC 2/AFIX IRQW ID1 (2,0) Level
  421. * 10 PCI Int B/PMC 1/AFIX IRQX ID2 (2,1) Level
  422. * 11 USB2 Level
  423. * 12 Mouse Edge
  424. * 13 Reserved internally by Ali M1535+
  425. * 14 PCI Int C/VME/AFIX IRQY ID3 (2,6) Level
  426. * 15 COM 5/6 Level
  427. *
  428. * 16..112 Discovery-II...
  429. *
  430. * MPP28 Southbridge Edge High
  431. *
  432. *
  433. * Interrupts are cascaded through to the Discovery-II.
  434. *
  435. * PCI ---
  436. * \
  437. * CPLD --> ALI1535 -------> DISCOVERY-II
  438. * INTF MPP28
  439. */
  440. static void __init ppc7d_init_irq(void)
  441. {
  442. int irq;
  443. pr_debug("%s\n", __FUNCTION__);
  444. i8259_init(0, 0);
  445. mv64360_init_irq();
  446. /* IRQs 5,6,9,10,11,14,15 are level sensitive */
  447. irq_desc[5].status |= IRQ_LEVEL;
  448. irq_desc[6].status |= IRQ_LEVEL;
  449. irq_desc[9].status |= IRQ_LEVEL;
  450. irq_desc[10].status |= IRQ_LEVEL;
  451. irq_desc[11].status |= IRQ_LEVEL;
  452. irq_desc[14].status |= IRQ_LEVEL;
  453. irq_desc[15].status |= IRQ_LEVEL;
  454. /* GPP28 is edge triggered */
  455. irq_desc[mv64360_irq_base + MV64x60_IRQ_GPP28].status &= ~IRQ_LEVEL;
  456. }
  457. static u32 ppc7d_irq_canonicalize(u32 irq)
  458. {
  459. if ((irq >= 16) && (irq < (16 + 96)))
  460. irq -= 16;
  461. return irq;
  462. }
  463. static int ppc7d_get_irq(struct pt_regs *regs)
  464. {
  465. int irq;
  466. irq = mv64360_get_irq(regs);
  467. if (irq == (mv64360_irq_base + MV64x60_IRQ_GPP28))
  468. irq = i8259_irq(regs);
  469. return irq;
  470. }
  471. /*
  472. * 9 PCI Int A/PMC 2/AFIX IRQW ID1 (2,0) Level
  473. * 10 PCI Int B/PMC 1/AFIX IRQX ID2 (2,1) Level
  474. * 14 PCI Int C/VME/AFIX IRQY ID3 (2,6) Level
  475. * 5 PCI Int D/AFIX IRQZ ID4 (2,7) Level
  476. */
  477. static int __init ppc7d_map_irq(struct pci_dev *dev, unsigned char idsel,
  478. unsigned char pin)
  479. {
  480. static const char pci_irq_table[][4] =
  481. /*
  482. * PCI IDSEL/INTPIN->INTLINE
  483. * A B C D
  484. */
  485. {
  486. {10, 14, 5, 9}, /* IDSEL 10 - PMC2 / AFIX IRQW */
  487. {9, 10, 14, 5}, /* IDSEL 11 - PMC1 / AFIX IRQX */
  488. {5, 9, 10, 14}, /* IDSEL 12 - AFIX IRQY */
  489. {14, 5, 9, 10}, /* IDSEL 13 - AFIX IRQZ */
  490. };
  491. const long min_idsel = 10, max_idsel = 14, irqs_per_slot = 4;
  492. pr_debug("%s: %04x/%04x/%x: idsel=%hx pin=%hu\n", __FUNCTION__,
  493. dev->vendor, dev->device, PCI_FUNC(dev->devfn), idsel, pin);
  494. return PCI_IRQ_TABLE_LOOKUP;
  495. }
  496. void __init ppc7d_intr_setup(void)
  497. {
  498. u32 data;
  499. /*
  500. * Define GPP 28 interrupt polarity as active high
  501. * input signal and level triggered
  502. */
  503. data = mv64x60_read(&bh, MV64x60_GPP_LEVEL_CNTL);
  504. data &= ~(1 << 28);
  505. mv64x60_write(&bh, MV64x60_GPP_LEVEL_CNTL, data);
  506. data = mv64x60_read(&bh, MV64x60_GPP_IO_CNTL);
  507. data &= ~(1 << 28);
  508. mv64x60_write(&bh, MV64x60_GPP_IO_CNTL, data);
  509. /* Config GPP intr ctlr to respond to level trigger */
  510. data = mv64x60_read(&bh, MV64x60_COMM_ARBITER_CNTL);
  511. data |= (1 << 10);
  512. mv64x60_write(&bh, MV64x60_COMM_ARBITER_CNTL, data);
  513. /* XXXX Erranum FEr PCI-#8 */
  514. data = mv64x60_read(&bh, MV64x60_PCI0_CMD);
  515. data &= ~((1 << 5) | (1 << 9));
  516. mv64x60_write(&bh, MV64x60_PCI0_CMD, data);
  517. data = mv64x60_read(&bh, MV64x60_PCI1_CMD);
  518. data &= ~((1 << 5) | (1 << 9));
  519. mv64x60_write(&bh, MV64x60_PCI1_CMD, data);
  520. /*
  521. * Dismiss and then enable interrupt on GPP interrupt cause
  522. * for CPU #0
  523. */
  524. mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~(1 << 28));
  525. data = mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
  526. data |= (1 << 28);
  527. mv64x60_write(&bh, MV64x60_GPP_INTR_MASK, data);
  528. /*
  529. * Dismiss and then enable interrupt on CPU #0 high cause reg
  530. * BIT27 summarizes GPP interrupts 23-31
  531. */
  532. mv64x60_write(&bh, MV64360_IC_MAIN_CAUSE_HI, ~(1 << 27));
  533. data = mv64x60_read(&bh, MV64360_IC_CPU0_INTR_MASK_HI);
  534. data |= (1 << 27);
  535. mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_HI, data);
  536. }
  537. /*****************************************************************************
  538. * Platform device data fixup routines.
  539. *****************************************************************************/
  540. #if defined(CONFIG_SERIAL_MPSC)
  541. static void __init ppc7d_fixup_mpsc_pdata(struct platform_device *pdev)
  542. {
  543. struct mpsc_pdata *pdata;
  544. pdata = (struct mpsc_pdata *)pdev->dev.platform_data;
  545. pdata->max_idle = 40;
  546. pdata->default_baud = PPC7D_DEFAULT_BAUD;
  547. pdata->brg_clk_src = PPC7D_MPSC_CLK_SRC;
  548. pdata->brg_clk_freq = PPC7D_MPSC_CLK_FREQ;
  549. return;
  550. }
  551. #endif
  552. #if defined(CONFIG_MV643XX_ETH)
  553. static void __init ppc7d_fixup_eth_pdata(struct platform_device *pdev)
  554. {
  555. struct mv643xx_eth_platform_data *eth_pd;
  556. static u16 phy_addr[] = {
  557. PPC7D_ETH0_PHY_ADDR,
  558. PPC7D_ETH1_PHY_ADDR,
  559. PPC7D_ETH2_PHY_ADDR,
  560. };
  561. int i;
  562. eth_pd = pdev->dev.platform_data;
  563. eth_pd->force_phy_addr = 1;
  564. eth_pd->phy_addr = phy_addr[pdev->id];
  565. eth_pd->tx_queue_size = PPC7D_ETH_TX_QUEUE_SIZE;
  566. eth_pd->rx_queue_size = PPC7D_ETH_RX_QUEUE_SIZE;
  567. /* Adjust IRQ by mv64360_irq_base */
  568. for (i = 0; i < pdev->num_resources; i++) {
  569. struct resource *r = &pdev->resource[i];
  570. if (r->flags & IORESOURCE_IRQ) {
  571. r->start += mv64360_irq_base;
  572. r->end += mv64360_irq_base;
  573. pr_debug("%s, uses IRQ %d\n", pdev->name,
  574. (int)r->start);
  575. }
  576. }
  577. }
  578. #endif
  579. #if defined(CONFIG_I2C_MV64XXX)
  580. static void __init
  581. ppc7d_fixup_i2c_pdata(struct platform_device *pdev)
  582. {
  583. struct mv64xxx_i2c_pdata *pdata;
  584. int i;
  585. pdata = pdev->dev.platform_data;
  586. if (pdata == NULL) {
  587. pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
  588. if (pdata == NULL)
  589. return;
  590. pdev->dev.platform_data = pdata;
  591. }
  592. /* divisors M=8, N=3 for 100kHz I2C from 133MHz system clock */
  593. pdata->freq_m = 8;
  594. pdata->freq_n = 3;
  595. pdata->timeout = 500;
  596. pdata->retries = 3;
  597. /* Adjust IRQ by mv64360_irq_base */
  598. for (i = 0; i < pdev->num_resources; i++) {
  599. struct resource *r = &pdev->resource[i];
  600. if (r->flags & IORESOURCE_IRQ) {
  601. r->start += mv64360_irq_base;
  602. r->end += mv64360_irq_base;
  603. pr_debug("%s, uses IRQ %d\n", pdev->name, (int) r->start);
  604. }
  605. }
  606. }
  607. #endif
  608. static int ppc7d_platform_notify(struct device *dev)
  609. {
  610. static struct {
  611. char *bus_id;
  612. void ((*rtn) (struct platform_device * pdev));
  613. } dev_map[] = {
  614. #if defined(CONFIG_SERIAL_MPSC)
  615. { MPSC_CTLR_NAME ".0", ppc7d_fixup_mpsc_pdata },
  616. { MPSC_CTLR_NAME ".1", ppc7d_fixup_mpsc_pdata },
  617. #endif
  618. #if defined(CONFIG_MV643XX_ETH)
  619. { MV643XX_ETH_NAME ".0", ppc7d_fixup_eth_pdata },
  620. { MV643XX_ETH_NAME ".1", ppc7d_fixup_eth_pdata },
  621. { MV643XX_ETH_NAME ".2", ppc7d_fixup_eth_pdata },
  622. #endif
  623. #if defined(CONFIG_I2C_MV64XXX)
  624. { MV64XXX_I2C_CTLR_NAME ".0", ppc7d_fixup_i2c_pdata },
  625. #endif
  626. };
  627. struct platform_device *pdev;
  628. int i;
  629. if (dev && dev->bus_id)
  630. for (i = 0; i < ARRAY_SIZE(dev_map); i++)
  631. if (!strncmp(dev->bus_id, dev_map[i].bus_id,
  632. BUS_ID_SIZE)) {
  633. pdev = container_of(dev,
  634. struct platform_device,
  635. dev);
  636. dev_map[i].rtn(pdev);
  637. }
  638. return 0;
  639. }
  640. /*****************************************************************************
  641. * PCI device fixups.
  642. * These aren't really fixups per se. They are used to init devices as they
  643. * are found during PCI scan.
  644. *
  645. * The PPC7D has an HB8 PCI-X bridge which must be set up during a PCI
  646. * scan in order to find other devices on its secondary side.
  647. *****************************************************************************/
  648. static void __init ppc7d_fixup_hb8(struct pci_dev *dev)
  649. {
  650. u16 val16;
  651. if (dev->bus->number == 0) {
  652. pr_debug("PCI: HB8 init\n");
  653. pci_write_config_byte(dev, 0x1c,
  654. ((PPC7D_PCI0_IO_START_PCI_ADDR & 0xf000)
  655. >> 8) | 0x01);
  656. pci_write_config_byte(dev, 0x1d,
  657. (((PPC7D_PCI0_IO_START_PCI_ADDR +
  658. PPC7D_PCI0_IO_SIZE -
  659. 1) & 0xf000) >> 8) | 0x01);
  660. pci_write_config_word(dev, 0x30,
  661. PPC7D_PCI0_IO_START_PCI_ADDR >> 16);
  662. pci_write_config_word(dev, 0x32,
  663. ((PPC7D_PCI0_IO_START_PCI_ADDR +
  664. PPC7D_PCI0_IO_SIZE -
  665. 1) >> 16) & 0xffff);
  666. pci_write_config_word(dev, 0x20,
  667. PPC7D_PCI0_MEM0_START_PCI_LO_ADDR >> 16);
  668. pci_write_config_word(dev, 0x22,
  669. ((PPC7D_PCI0_MEM0_START_PCI_LO_ADDR +
  670. PPC7D_PCI0_MEM0_SIZE -
  671. 1) >> 16) & 0xffff);
  672. pci_write_config_word(dev, 0x24, 0);
  673. pci_write_config_word(dev, 0x26, 0);
  674. pci_write_config_dword(dev, 0x28, 0);
  675. pci_write_config_dword(dev, 0x2c, 0);
  676. pci_read_config_word(dev, 0x3e, &val16);
  677. val16 |= ((1 << 5) | (1 << 1)); /* signal master aborts and
  678. * SERR to primary
  679. */
  680. val16 &= ~(1 << 2); /* ISA disable, so all ISA
  681. * ports forwarded to secondary
  682. */
  683. pci_write_config_word(dev, 0x3e, val16);
  684. }
  685. }
  686. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0028, ppc7d_fixup_hb8);
  687. /* This should perhaps be a separate driver as we're actually initializing
  688. * the chip for this board here. It's hardly a fixup...
  689. */
  690. static void __init ppc7d_fixup_ali1535(struct pci_dev *dev)
  691. {
  692. pr_debug("PCI: ALI1535 init\n");
  693. if (dev->bus->number == 1) {
  694. /* Configure the ISA Port Settings */
  695. pci_write_config_byte(dev, 0x43, 0x00);
  696. /* Disable PCI Interrupt polling mode */
  697. pci_write_config_byte(dev, 0x45, 0x00);
  698. /* Multifunction pin select INTFJ -> INTF */
  699. pci_write_config_byte(dev, 0x78, 0x00);
  700. /* Set PCI INT -> IRQ Routing control in for external
  701. * pins south bridge.
  702. */
  703. pci_write_config_byte(dev, 0x48, 0x31); /* [7-4] INT B -> IRQ10
  704. * [3-0] INT A -> IRQ9
  705. */
  706. pci_write_config_byte(dev, 0x49, 0x5D); /* [7-4] INT D -> IRQ5
  707. * [3-0] INT C -> IRQ14
  708. */
  709. /* PPC7D setup */
  710. /* NEC USB device on IRQ 11 (INTE) - INTF disabled */
  711. pci_write_config_byte(dev, 0x4A, 0x09);
  712. /* GPIO on IRQ 6 */
  713. pci_write_config_byte(dev, 0x76, 0x07);
  714. /* SIRQ I (COMS 5/6) use IRQ line 15.
  715. * Positive (not subtractive) address decode.
  716. */
  717. pci_write_config_byte(dev, 0x44, 0x0f);
  718. /* SIRQ II disabled */
  719. pci_write_config_byte(dev, 0x75, 0x0);
  720. /* On board USB and RTC disabled */
  721. pci_write_config_word(dev, 0x52, (1 << 14));
  722. pci_write_config_byte(dev, 0x74, 0x00);
  723. /* On board IDE disabled */
  724. pci_write_config_byte(dev, 0x58, 0x00);
  725. /* Decode 32-bit addresses */
  726. pci_write_config_byte(dev, 0x5b, 0);
  727. /* Disable docking IO */
  728. pci_write_config_word(dev, 0x5c, 0x0000);
  729. /* Disable modem, enable sound */
  730. pci_write_config_byte(dev, 0x77, (1 << 6));
  731. /* Disable hot-docking mode */
  732. pci_write_config_byte(dev, 0x7d, 0x00);
  733. }
  734. }
  735. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1533, ppc7d_fixup_ali1535);
  736. static int ppc7d_pci_exclude_device(u8 bus, u8 devfn)
  737. {
  738. /* Early versions of this board were fitted with IBM ALMA
  739. * PCI-VME bridge chips. The PCI config space of these devices
  740. * was not set up correctly and causes PCI scan problems.
  741. */
  742. if ((bus == 1) && (PCI_SLOT(devfn) == 4) && ppc7d_has_alma)
  743. return PCIBIOS_DEVICE_NOT_FOUND;
  744. return mv64x60_pci_exclude_device(bus, devfn);
  745. }
  746. /* This hook is called when each PCI bus is probed.
  747. */
  748. static void ppc7d_pci_fixup_bus(struct pci_bus *bus)
  749. {
  750. pr_debug("PCI BUS %hu: %lx/%lx %lx/%lx %lx/%lx %lx/%lx\n",
  751. bus->number,
  752. bus->resource[0] ? bus->resource[0]->start : 0,
  753. bus->resource[0] ? bus->resource[0]->end : 0,
  754. bus->resource[1] ? bus->resource[1]->start : 0,
  755. bus->resource[1] ? bus->resource[1]->end : 0,
  756. bus->resource[2] ? bus->resource[2]->start : 0,
  757. bus->resource[2] ? bus->resource[2]->end : 0,
  758. bus->resource[3] ? bus->resource[3]->start : 0,
  759. bus->resource[3] ? bus->resource[3]->end : 0);
  760. if ((bus->number == 1) && (bus->resource[2] != NULL)) {
  761. /* Hide PCI window 2 of Bus 1 which is used only to
  762. * map legacy ISA memory space.
  763. */
  764. bus->resource[2]->start = 0;
  765. bus->resource[2]->end = 0;
  766. bus->resource[2]->flags = 0;
  767. }
  768. }
  769. /*****************************************************************************
  770. * Board device setup code
  771. *****************************************************************************/
  772. void __init ppc7d_setup_peripherals(void)
  773. {
  774. u32 val32;
  775. /* Set up windows for boot CS */
  776. mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
  777. PPC7D_BOOT_WINDOW_BASE, PPC7D_BOOT_WINDOW_SIZE,
  778. 0);
  779. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2BOOT_WIN);
  780. /* Boot firmware configures the following DevCS addresses.
  781. * DevCS0 - board control/status
  782. * DevCS1 - test registers
  783. * DevCS2 - AFIX port/address registers (for identifying)
  784. * DevCS3 - FLASH
  785. *
  786. * We don't use DevCS0, DevCS1.
  787. */
  788. val32 = mv64x60_read(&bh, MV64360_CPU_BAR_ENABLE);
  789. val32 |= ((1 << 4) | (1 << 5));
  790. mv64x60_write(&bh, MV64360_CPU_BAR_ENABLE, val32);
  791. mv64x60_write(&bh, MV64x60_CPU2DEV_0_BASE, 0);
  792. mv64x60_write(&bh, MV64x60_CPU2DEV_0_SIZE, 0);
  793. mv64x60_write(&bh, MV64x60_CPU2DEV_1_BASE, 0);
  794. mv64x60_write(&bh, MV64x60_CPU2DEV_1_SIZE, 0);
  795. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN,
  796. PPC7D_AFIX_REG_BASE, PPC7D_AFIX_REG_SIZE, 0);
  797. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_2_WIN);
  798. mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN,
  799. PPC7D_FLASH_BASE, PPC7D_FLASH_SIZE_ACTUAL, 0);
  800. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_3_WIN);
  801. mv64x60_set_32bit_window(&bh, MV64x60_CPU2SRAM_WIN,
  802. PPC7D_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE,
  803. 0);
  804. bh.ci->enable_window_32bit(&bh, MV64x60_CPU2SRAM_WIN);
  805. /* Set up Enet->SRAM window */
  806. mv64x60_set_32bit_window(&bh, MV64x60_ENET2MEM_4_WIN,
  807. PPC7D_INTERNAL_SRAM_BASE, MV64360_SRAM_SIZE,
  808. 0x2);
  809. bh.ci->enable_window_32bit(&bh, MV64x60_ENET2MEM_4_WIN);
  810. /* Give enet r/w access to memory region */
  811. val32 = mv64x60_read(&bh, MV64360_ENET2MEM_ACC_PROT_0);
  812. val32 |= (0x3 << (4 << 1));
  813. mv64x60_write(&bh, MV64360_ENET2MEM_ACC_PROT_0, val32);
  814. val32 = mv64x60_read(&bh, MV64360_ENET2MEM_ACC_PROT_1);
  815. val32 |= (0x3 << (4 << 1));
  816. mv64x60_write(&bh, MV64360_ENET2MEM_ACC_PROT_1, val32);
  817. val32 = mv64x60_read(&bh, MV64360_ENET2MEM_ACC_PROT_2);
  818. val32 |= (0x3 << (4 << 1));
  819. mv64x60_write(&bh, MV64360_ENET2MEM_ACC_PROT_2, val32);
  820. val32 = mv64x60_read(&bh, MV64x60_TIMR_CNTR_0_3_CNTL);
  821. val32 &= ~((1 << 0) | (1 << 8) | (1 << 16) | (1 << 24));
  822. mv64x60_write(&bh, MV64x60_TIMR_CNTR_0_3_CNTL, val32);
  823. /* Enumerate pci bus.
  824. *
  825. * We scan PCI#0 first (the bus with the HB8 and other
  826. * on-board peripherals). We must configure the 64360 before
  827. * each scan, according to the bus number assignments. Busses
  828. * are assigned incrementally, starting at 0. PCI#0 is
  829. * usually assigned bus#0, the secondary side of the HB8 gets
  830. * bus#1 and PCI#1 (second PMC site) gets bus#2. However, if
  831. * any PMC card has a PCI bridge, these bus assignments will
  832. * change.
  833. */
  834. /* Turn off PCI retries */
  835. val32 = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
  836. val32 |= (1 << 17);
  837. mv64x60_write(&bh, MV64x60_CPU_CONFIG, val32);
  838. /* Scan PCI#0 */
  839. mv64x60_set_bus(&bh, 0, 0);
  840. bh.hose_a->first_busno = 0;
  841. bh.hose_a->last_busno = 0xff;
  842. bh.hose_a->last_busno = pciauto_bus_scan(bh.hose_a, 0);
  843. printk(KERN_INFO "PCI#0: first=%d last=%d\n",
  844. bh.hose_a->first_busno, bh.hose_a->last_busno);
  845. /* Scan PCI#1 */
  846. bh.hose_b->first_busno = bh.hose_a->last_busno + 1;
  847. mv64x60_set_bus(&bh, 1, bh.hose_b->first_busno);
  848. bh.hose_b->last_busno = 0xff;
  849. bh.hose_b->last_busno = pciauto_bus_scan(bh.hose_b,
  850. bh.hose_b->first_busno);
  851. printk(KERN_INFO "PCI#1: first=%d last=%d\n",
  852. bh.hose_b->first_busno, bh.hose_b->last_busno);
  853. /* Turn on PCI retries */
  854. val32 = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
  855. val32 &= ~(1 << 17);
  856. mv64x60_write(&bh, MV64x60_CPU_CONFIG, val32);
  857. /* Setup interrupts */
  858. ppc7d_intr_setup();
  859. }
  860. static void __init ppc7d_setup_bridge(void)
  861. {
  862. struct mv64x60_setup_info si;
  863. int i;
  864. u32 temp;
  865. mv64360_irq_base = 16; /* first 16 intrs are 2 x 8259's */
  866. memset(&si, 0, sizeof(si));
  867. si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
  868. si.pci_0.enable_bus = 1;
  869. si.pci_0.pci_io.cpu_base = PPC7D_PCI0_IO_START_PROC_ADDR;
  870. si.pci_0.pci_io.pci_base_hi = 0;
  871. si.pci_0.pci_io.pci_base_lo = PPC7D_PCI0_IO_START_PCI_ADDR;
  872. si.pci_0.pci_io.size = PPC7D_PCI0_IO_SIZE;
  873. si.pci_0.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
  874. si.pci_0.pci_mem[0].cpu_base = PPC7D_PCI0_MEM0_START_PROC_ADDR;
  875. si.pci_0.pci_mem[0].pci_base_hi = PPC7D_PCI0_MEM0_START_PCI_HI_ADDR;
  876. si.pci_0.pci_mem[0].pci_base_lo = PPC7D_PCI0_MEM0_START_PCI_LO_ADDR;
  877. si.pci_0.pci_mem[0].size = PPC7D_PCI0_MEM0_SIZE;
  878. si.pci_0.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
  879. si.pci_0.pci_mem[1].cpu_base = PPC7D_PCI0_MEM1_START_PROC_ADDR;
  880. si.pci_0.pci_mem[1].pci_base_hi = PPC7D_PCI0_MEM1_START_PCI_HI_ADDR;
  881. si.pci_0.pci_mem[1].pci_base_lo = PPC7D_PCI0_MEM1_START_PCI_LO_ADDR;
  882. si.pci_0.pci_mem[1].size = PPC7D_PCI0_MEM1_SIZE;
  883. si.pci_0.pci_mem[1].swap = MV64x60_CPU2PCI_SWAP_NONE;
  884. si.pci_0.pci_cmd_bits = 0;
  885. si.pci_0.latency_timer = 0x80;
  886. si.pci_1.enable_bus = 1;
  887. si.pci_1.pci_io.cpu_base = PPC7D_PCI1_IO_START_PROC_ADDR;
  888. si.pci_1.pci_io.pci_base_hi = 0;
  889. si.pci_1.pci_io.pci_base_lo = PPC7D_PCI1_IO_START_PCI_ADDR;
  890. si.pci_1.pci_io.size = PPC7D_PCI1_IO_SIZE;
  891. si.pci_1.pci_io.swap = MV64x60_CPU2PCI_SWAP_NONE;
  892. si.pci_1.pci_mem[0].cpu_base = PPC7D_PCI1_MEM0_START_PROC_ADDR;
  893. si.pci_1.pci_mem[0].pci_base_hi = PPC7D_PCI1_MEM0_START_PCI_HI_ADDR;
  894. si.pci_1.pci_mem[0].pci_base_lo = PPC7D_PCI1_MEM0_START_PCI_LO_ADDR;
  895. si.pci_1.pci_mem[0].size = PPC7D_PCI1_MEM0_SIZE;
  896. si.pci_1.pci_mem[0].swap = MV64x60_CPU2PCI_SWAP_NONE;
  897. si.pci_1.pci_mem[1].cpu_base = PPC7D_PCI1_MEM1_START_PROC_ADDR;
  898. si.pci_1.pci_mem[1].pci_base_hi = PPC7D_PCI1_MEM1_START_PCI_HI_ADDR;
  899. si.pci_1.pci_mem[1].pci_base_lo = PPC7D_PCI1_MEM1_START_PCI_LO_ADDR;
  900. si.pci_1.pci_mem[1].size = PPC7D_PCI1_MEM1_SIZE;
  901. si.pci_1.pci_mem[1].swap = MV64x60_CPU2PCI_SWAP_NONE;
  902. si.pci_1.pci_cmd_bits = 0;
  903. si.pci_1.latency_timer = 0x80;
  904. /* Don't clear the SRAM window since we use it for debug */
  905. si.window_preserve_mask_32_lo = (1 << MV64x60_CPU2SRAM_WIN);
  906. printk(KERN_INFO "PCI: MV64360 PCI#0 IO at %x, size %x\n",
  907. si.pci_0.pci_io.cpu_base, si.pci_0.pci_io.size);
  908. printk(KERN_INFO "PCI: MV64360 PCI#1 IO at %x, size %x\n",
  909. si.pci_1.pci_io.cpu_base, si.pci_1.pci_io.size);
  910. for (i = 0; i < MV64x60_CPU2MEM_WINDOWS; i++) {
  911. #if defined(CONFIG_NOT_COHERENT_CACHE)
  912. si.cpu_prot_options[i] = 0;
  913. si.enet_options[i] = MV64360_ENET2MEM_SNOOP_NONE;
  914. si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_NONE;
  915. si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_NONE;
  916. si.pci_0.acc_cntl_options[i] =
  917. MV64360_PCI_ACC_CNTL_SNOOP_NONE |
  918. MV64360_PCI_ACC_CNTL_SWAP_NONE |
  919. MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
  920. MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
  921. si.pci_1.acc_cntl_options[i] =
  922. MV64360_PCI_ACC_CNTL_SNOOP_NONE |
  923. MV64360_PCI_ACC_CNTL_SWAP_NONE |
  924. MV64360_PCI_ACC_CNTL_MBURST_128_BYTES |
  925. MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES;
  926. #else
  927. si.cpu_prot_options[i] = 0;
  928. /* All PPC7D hardware uses B0 or newer MV64360 silicon which
  929. * does not have snoop bugs.
  930. */
  931. si.enet_options[i] = MV64360_ENET2MEM_SNOOP_WB;
  932. si.mpsc_options[i] = MV64360_MPSC2MEM_SNOOP_WB;
  933. si.idma_options[i] = MV64360_IDMA2MEM_SNOOP_WB;
  934. si.pci_0.acc_cntl_options[i] =
  935. MV64360_PCI_ACC_CNTL_SNOOP_WB |
  936. MV64360_PCI_ACC_CNTL_SWAP_NONE |
  937. MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
  938. MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
  939. si.pci_1.acc_cntl_options[i] =
  940. MV64360_PCI_ACC_CNTL_SNOOP_WB |
  941. MV64360_PCI_ACC_CNTL_SWAP_NONE |
  942. MV64360_PCI_ACC_CNTL_MBURST_32_BYTES |
  943. MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES;
  944. #endif
  945. }
  946. /* Lookup PCI host bridges */
  947. if (mv64x60_init(&bh, &si))
  948. printk(KERN_ERR "MV64360 initialization failed.\n");
  949. pr_debug("MV64360 regs @ %lx/%p\n", bh.p_base, bh.v_base);
  950. /* Enable WB Cache coherency on SRAM */
  951. temp = mv64x60_read(&bh, MV64360_SRAM_CONFIG);
  952. pr_debug("SRAM_CONFIG: %x\n", temp);
  953. #if defined(CONFIG_NOT_COHERENT_CACHE)
  954. mv64x60_write(&bh, MV64360_SRAM_CONFIG, temp & ~0x2);
  955. #else
  956. mv64x60_write(&bh, MV64360_SRAM_CONFIG, temp | 0x2);
  957. #endif
  958. /* If system operates with internal bus arbiter (CPU master
  959. * control bit8) clear AACK Delay bit [25] in CPU
  960. * configuration register.
  961. */
  962. temp = mv64x60_read(&bh, MV64x60_CPU_MASTER_CNTL);
  963. if (temp & (1 << 8)) {
  964. temp = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
  965. mv64x60_write(&bh, MV64x60_CPU_CONFIG, (temp & ~(1 << 25)));
  966. }
  967. /* Data and address parity is enabled */
  968. temp = mv64x60_read(&bh, MV64x60_CPU_CONFIG);
  969. mv64x60_write(&bh, MV64x60_CPU_CONFIG,
  970. (temp | (1 << 26) | (1 << 19)));
  971. pci_dram_offset = 0; /* sys mem at same addr on PCI & cpu bus */
  972. ppc_md.pci_swizzle = common_swizzle;
  973. ppc_md.pci_map_irq = ppc7d_map_irq;
  974. ppc_md.pci_exclude_device = ppc7d_pci_exclude_device;
  975. mv64x60_set_bus(&bh, 0, 0);
  976. bh.hose_a->first_busno = 0;
  977. bh.hose_a->last_busno = 0xff;
  978. bh.hose_a->mem_space.start = PPC7D_PCI0_MEM0_START_PCI_LO_ADDR;
  979. bh.hose_a->mem_space.end =
  980. PPC7D_PCI0_MEM0_START_PCI_LO_ADDR + PPC7D_PCI0_MEM0_SIZE;
  981. /* These will be set later, as a result of PCI0 scan */
  982. bh.hose_b->first_busno = 0;
  983. bh.hose_b->last_busno = 0xff;
  984. bh.hose_b->mem_space.start = PPC7D_PCI1_MEM0_START_PCI_LO_ADDR;
  985. bh.hose_b->mem_space.end =
  986. PPC7D_PCI1_MEM0_START_PCI_LO_ADDR + PPC7D_PCI1_MEM0_SIZE;
  987. pr_debug("MV64360: PCI#0 IO decode %08x/%08x IO remap %08x\n",
  988. mv64x60_read(&bh, 0x48), mv64x60_read(&bh, 0x50),
  989. mv64x60_read(&bh, 0xf0));
  990. }
  991. static void __init ppc7d_setup_arch(void)
  992. {
  993. int port;
  994. loops_per_jiffy = 100000000 / HZ;
  995. #ifdef CONFIG_BLK_DEV_INITRD
  996. if (initrd_start)
  997. ROOT_DEV = Root_RAM0;
  998. else
  999. #endif
  1000. #ifdef CONFIG_ROOT_NFS
  1001. ROOT_DEV = Root_NFS;
  1002. #else
  1003. ROOT_DEV = Root_HDA1;
  1004. #endif
  1005. if ((cur_cpu_spec->cpu_features & CPU_FTR_SPEC7450) ||
  1006. (cur_cpu_spec->cpu_features & CPU_FTR_L3CR))
  1007. /* 745x is different. We only want to pass along enable. */
  1008. _set_L2CR(L2CR_L2E);
  1009. else if (cur_cpu_spec->cpu_features & CPU_FTR_L2CR)
  1010. /* All modules have 1MB of L2. We also assume that an
  1011. * L2 divisor of 3 will work.
  1012. */
  1013. _set_L2CR(L2CR_L2E | L2CR_L2SIZ_1MB | L2CR_L2CLK_DIV3
  1014. | L2CR_L2RAM_PIPE | L2CR_L2OH_1_0 | L2CR_L2DF);
  1015. if (cur_cpu_spec->cpu_features & CPU_FTR_L3CR)
  1016. /* No L3 cache */
  1017. _set_L3CR(0);
  1018. #ifdef CONFIG_DUMMY_CONSOLE
  1019. conswitchp = &dummy_con;
  1020. #endif
  1021. /* Lookup PCI host bridges */
  1022. if (ppc_md.progress)
  1023. ppc_md.progress("ppc7d_setup_arch: calling setup_bridge", 0);
  1024. ppc7d_setup_bridge();
  1025. ppc7d_setup_peripherals();
  1026. /* Disable ethernet. It might have been setup by the bootrom */
  1027. for (port = 0; port < 3; port++)
  1028. mv64x60_write(&bh, MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port),
  1029. 0x0000ff00);
  1030. /* Clear queue pointers to ensure they are all initialized,
  1031. * otherwise since queues 1-7 are unused, they have random
  1032. * pointers which look strange in register dumps. Don't bother
  1033. * with queue 0 since it will be initialized later.
  1034. */
  1035. for (port = 0; port < 3; port++) {
  1036. mv64x60_write(&bh,
  1037. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_1(port),
  1038. 0x00000000);
  1039. mv64x60_write(&bh,
  1040. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_2(port),
  1041. 0x00000000);
  1042. mv64x60_write(&bh,
  1043. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_3(port),
  1044. 0x00000000);
  1045. mv64x60_write(&bh,
  1046. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_4(port),
  1047. 0x00000000);
  1048. mv64x60_write(&bh,
  1049. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_5(port),
  1050. 0x00000000);
  1051. mv64x60_write(&bh,
  1052. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_6(port),
  1053. 0x00000000);
  1054. mv64x60_write(&bh,
  1055. MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_7(port),
  1056. 0x00000000);
  1057. }
  1058. printk(KERN_INFO "Radstone Technology PPC7D\n");
  1059. if (ppc_md.progress)
  1060. ppc_md.progress("ppc7d_setup_arch: exit", 0);
  1061. }
  1062. /* Real Time Clock support.
  1063. * PPC7D has a DS1337 accessed by I2C.
  1064. */
  1065. static ulong ppc7d_get_rtc_time(void)
  1066. {
  1067. struct rtc_time tm;
  1068. int result;
  1069. spin_lock(&rtc_lock);
  1070. result = ds1337_do_command(0, DS1337_GET_DATE, &tm);
  1071. spin_unlock(&rtc_lock);
  1072. if (result == 0)
  1073. result = mktime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
  1074. return result;
  1075. }
  1076. static int ppc7d_set_rtc_time(unsigned long nowtime)
  1077. {
  1078. struct rtc_time tm;
  1079. int result;
  1080. spin_lock(&rtc_lock);
  1081. to_tm(nowtime, &tm);
  1082. result = ds1337_do_command(0, DS1337_SET_DATE, &tm);
  1083. spin_unlock(&rtc_lock);
  1084. return result;
  1085. }
  1086. /* This kernel command line parameter can be used to have the target
  1087. * wait for a JTAG debugger to attach. Of course, a JTAG debugger
  1088. * with hardware breakpoint support can have the target stop at any
  1089. * location during init, but this is a convenience feature that makes
  1090. * it easier in the common case of loading the code using the ppcboot
  1091. * bootloader..
  1092. */
  1093. static unsigned long ppc7d_wait_debugger;
  1094. static int __init ppc7d_waitdbg(char *str)
  1095. {
  1096. ppc7d_wait_debugger = 1;
  1097. return 1;
  1098. }
  1099. __setup("waitdbg", ppc7d_waitdbg);
  1100. /* Second phase board init, called after other (architecture common)
  1101. * low-level services have been initialized.
  1102. */
  1103. static void ppc7d_init2(void)
  1104. {
  1105. unsigned long flags;
  1106. u32 data;
  1107. u8 data8;
  1108. pr_debug("%s: enter\n", __FUNCTION__);
  1109. /* Wait for debugger? */
  1110. if (ppc7d_wait_debugger) {
  1111. printk("Waiting for debugger...\n");
  1112. while (readl(&ppc7d_wait_debugger)) ;
  1113. }
  1114. /* Hook up i8259 interrupt which is connected to GPP28 */
  1115. request_irq(mv64360_irq_base + MV64x60_IRQ_GPP28, ppc7d_i8259_intr,
  1116. SA_INTERRUPT, "I8259 (GPP28) interrupt", (void *)0);
  1117. /* Configure MPP16 as watchdog NMI, MPP17 as watchdog WDE */
  1118. spin_lock_irqsave(&mv64x60_lock, flags);
  1119. data = mv64x60_read(&bh, MV64x60_MPP_CNTL_2);
  1120. data &= ~(0x0000000f << 0);
  1121. data |= (0x00000004 << 0);
  1122. data &= ~(0x0000000f << 4);
  1123. data |= (0x00000004 << 4);
  1124. mv64x60_write(&bh, MV64x60_MPP_CNTL_2, data);
  1125. spin_unlock_irqrestore(&mv64x60_lock, flags);
  1126. /* All LEDs off */
  1127. data8 = inb(PPC7D_CPLD_LEDS);
  1128. data8 &= ~0x08;
  1129. data8 |= 0x07;
  1130. outb(data8, PPC7D_CPLD_LEDS);
  1131. /* Hook up RTC. We couldn't do this earlier because we need the I2C subsystem */
  1132. ppc_md.set_rtc_time = ppc7d_set_rtc_time;
  1133. ppc_md.get_rtc_time = ppc7d_get_rtc_time;
  1134. pr_debug("%s: exit\n", __FUNCTION__);
  1135. }
  1136. /* Called from machine_init(), early, before any of the __init functions
  1137. * have run. We must init software-configurable pins before other functions
  1138. * such as interrupt controllers are initialised.
  1139. */
  1140. void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  1141. unsigned long r6, unsigned long r7)
  1142. {
  1143. u8 val8;
  1144. u8 rev_num;
  1145. /* Map 0xe0000000-0xffffffff early because we need access to SRAM
  1146. * and the ISA memory space (for serial port) here. This mapping
  1147. * is redone properly in ppc7d_map_io() later.
  1148. */
  1149. mtspr(SPRN_DBAT3U, 0xe0003fff);
  1150. mtspr(SPRN_DBAT3L, 0xe000002a);
  1151. /*
  1152. * Zero SRAM. Note that this generates parity errors on
  1153. * internal data path in SRAM if it's first time accessing it
  1154. * after reset.
  1155. *
  1156. * We do this ASAP to avoid parity errors when reading
  1157. * uninitialized SRAM.
  1158. */
  1159. memset((void *)PPC7D_INTERNAL_SRAM_BASE, 0, MV64360_SRAM_SIZE);
  1160. pr_debug("platform_init: r3-r7: %lx %lx %lx %lx %lx\n",
  1161. r3, r4, r5, r6, r7);
  1162. parse_bootinfo(find_bootinfo());
  1163. /* ASSUMPTION: If both r3 (bd_t pointer) and r6 (cmdline pointer)
  1164. * are non-zero, then we should use the board info from the bd_t
  1165. * structure and the cmdline pointed to by r6 instead of the
  1166. * information from birecs, if any. Otherwise, use the information
  1167. * from birecs as discovered by the preceeding call to
  1168. * parse_bootinfo(). This rule should work with both PPCBoot, which
  1169. * uses a bd_t board info structure, and the kernel boot wrapper,
  1170. * which uses birecs.
  1171. */
  1172. if (r3 && r6) {
  1173. bd_t *bp = (bd_t *) __res;
  1174. /* copy board info structure */
  1175. memcpy((void *)__res, (void *)(r3 + KERNELBASE), sizeof(bd_t));
  1176. /* copy command line */
  1177. *(char *)(r7 + KERNELBASE) = 0;
  1178. strcpy(cmd_line, (char *)(r6 + KERNELBASE));
  1179. printk(KERN_INFO "Board info data:-\n");
  1180. printk(KERN_INFO " Internal freq: %lu MHz, bus freq: %lu MHz\n",
  1181. bp->bi_intfreq, bp->bi_busfreq);
  1182. printk(KERN_INFO " Memory: %lx, size %lx\n", bp->bi_memstart,
  1183. bp->bi_memsize);
  1184. printk(KERN_INFO " Console baudrate: %lu\n", bp->bi_baudrate);
  1185. printk(KERN_INFO " Ethernet address: "
  1186. "%02x:%02x:%02x:%02x:%02x:%02x\n",
  1187. bp->bi_enetaddr[0], bp->bi_enetaddr[1],
  1188. bp->bi_enetaddr[2], bp->bi_enetaddr[3],
  1189. bp->bi_enetaddr[4], bp->bi_enetaddr[5]);
  1190. }
  1191. #ifdef CONFIG_BLK_DEV_INITRD
  1192. /* take care of initrd if we have one */
  1193. if (r4) {
  1194. initrd_start = r4 + KERNELBASE;
  1195. initrd_end = r5 + KERNELBASE;
  1196. printk(KERN_INFO "INITRD @ %lx/%lx\n", initrd_start, initrd_end);
  1197. }
  1198. #endif /* CONFIG_BLK_DEV_INITRD */
  1199. /* Map in board regs, etc. */
  1200. isa_io_base = 0xe8000000;
  1201. isa_mem_base = 0xe8000000;
  1202. pci_dram_offset = 0x00000000;
  1203. ISA_DMA_THRESHOLD = 0x00ffffff;
  1204. DMA_MODE_READ = 0x44;
  1205. DMA_MODE_WRITE = 0x48;
  1206. ppc_md.setup_arch = ppc7d_setup_arch;
  1207. ppc_md.init = ppc7d_init2;
  1208. ppc_md.show_cpuinfo = ppc7d_show_cpuinfo;
  1209. /* XXX this is broken... */
  1210. ppc_md.irq_canonicalize = ppc7d_irq_canonicalize;
  1211. ppc_md.init_IRQ = ppc7d_init_irq;
  1212. ppc_md.get_irq = ppc7d_get_irq;
  1213. ppc_md.restart = ppc7d_restart;
  1214. ppc_md.power_off = ppc7d_power_off;
  1215. ppc_md.halt = ppc7d_halt;
  1216. ppc_md.find_end_of_memory = ppc7d_find_end_of_memory;
  1217. ppc_md.setup_io_mappings = ppc7d_map_io;
  1218. ppc_md.time_init = NULL;
  1219. ppc_md.set_rtc_time = NULL;
  1220. ppc_md.get_rtc_time = NULL;
  1221. ppc_md.calibrate_decr = ppc7d_calibrate_decr;
  1222. ppc_md.nvram_read_val = NULL;
  1223. ppc_md.nvram_write_val = NULL;
  1224. ppc_md.heartbeat = ppc7d_heartbeat;
  1225. ppc_md.heartbeat_reset = HZ;
  1226. ppc_md.heartbeat_count = ppc_md.heartbeat_reset;
  1227. ppc_md.pcibios_fixup_bus = ppc7d_pci_fixup_bus;
  1228. #if defined(CONFIG_SERIAL_MPSC) || defined(CONFIG_MV643XX_ETH) || \
  1229. defined(CONFIG_I2C_MV64XXX)
  1230. platform_notify = ppc7d_platform_notify;
  1231. #endif
  1232. #ifdef CONFIG_SERIAL_MPSC
  1233. /* On PPC7D, we must configure MPSC support via CPLD control
  1234. * registers.
  1235. */
  1236. outb(PPC7D_CPLD_RTS_COM4_SCLK |
  1237. PPC7D_CPLD_RTS_COM56_ENABLED, PPC7D_CPLD_RTS);
  1238. outb(PPC7D_CPLD_COMS_COM3_TCLKEN |
  1239. PPC7D_CPLD_COMS_COM3_TXEN |
  1240. PPC7D_CPLD_COMS_COM4_TCLKEN |
  1241. PPC7D_CPLD_COMS_COM4_TXEN, PPC7D_CPLD_COMS);
  1242. #endif /* CONFIG_SERIAL_MPSC */
  1243. #if defined(CONFIG_KGDB) || defined(CONFIG_SERIAL_TEXT_DEBUG)
  1244. ppc7d_early_serial_map();
  1245. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  1246. #if defined(CONFIG_SERIAL_MPSC_CONSOLE)
  1247. ppc_md.progress = mv64x60_mpsc_progress;
  1248. #elif defined(CONFIG_SERIAL_8250)
  1249. ppc_md.progress = gen550_progress;
  1250. #else
  1251. #error CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG has no supported CONFIG_SERIAL_XXX
  1252. #endif /* CONFIG_SERIAL_8250 */
  1253. #endif /* CONFIG_SERIAL_TEXT_DEBUG */
  1254. #endif /* CONFIG_KGDB || CONFIG_SERIAL_TEXT_DEBUG */
  1255. /* Enable write access to user flash. This is necessary for
  1256. * flash probe.
  1257. */
  1258. val8 = readb((void *)isa_io_base + PPC7D_CPLD_SW_FLASH_WRITE_PROTECT);
  1259. writeb(val8 | (PPC7D_CPLD_SW_FLASH_WRPROT_ENABLED &
  1260. PPC7D_CPLD_SW_FLASH_WRPROT_USER_MASK),
  1261. (void *)isa_io_base + PPC7D_CPLD_SW_FLASH_WRITE_PROTECT);
  1262. /* Determine if this board has IBM ALMA VME devices */
  1263. val8 = readb((void *)isa_io_base + PPC7D_CPLD_BOARD_REVISION);
  1264. rev_num = (val8 & PPC7D_CPLD_BOARD_REVISION_NUMBER_MASK) >> 5;
  1265. if (rev_num <= 1)
  1266. ppc7d_has_alma = 1;
  1267. #ifdef DEBUG
  1268. console_printk[0] = 8;
  1269. #endif
  1270. }