radstone_ppc7d.c 46 KB

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