radstone_ppc7d.c 46 KB

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