radstone_ppc7d.c 46 KB

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