radstone_ppc7d.c 46 KB

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