setup.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. /*
  2. * Toshiba rbtx4927 specific setup
  3. *
  4. * Author: MontaVista Software, Inc.
  5. * source@mvista.com
  6. *
  7. * Copyright 2001-2002 MontaVista Software Inc.
  8. *
  9. * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org)
  10. * Copyright (C) 2000 RidgeRun, Inc.
  11. * Author: RidgeRun, Inc.
  12. * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
  13. *
  14. * Copyright 2001 MontaVista Software Inc.
  15. * Author: jsun@mvista.com or jsun@junsun.net
  16. *
  17. * Copyright 2002 MontaVista Software Inc.
  18. * Author: Michael Pruznick, michael_pruznick@mvista.com
  19. *
  20. * Copyright (C) 2000-2001 Toshiba Corporation
  21. *
  22. * Copyright (C) 2004 MontaVista Software Inc.
  23. * Author: Manish Lachwani, mlachwani@mvista.com
  24. *
  25. * This program is free software; you can redistribute it and/or modify it
  26. * under the terms of the GNU General Public License as published by the
  27. * Free Software Foundation; either version 2 of the License, or (at your
  28. * option) any later version.
  29. *
  30. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  31. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  32. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  33. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  34. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  35. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  36. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  37. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  38. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  39. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. * You should have received a copy of the GNU General Public License along
  42. * with this program; if not, write to the Free Software Foundation, Inc.,
  43. * 675 Mass Ave, Cambridge, MA 02139, USA.
  44. */
  45. #include <linux/init.h>
  46. #include <linux/kernel.h>
  47. #include <linux/types.h>
  48. #include <linux/ioport.h>
  49. #include <linux/interrupt.h>
  50. #include <linux/pci.h>
  51. #include <linux/pm.h>
  52. #include <linux/platform_device.h>
  53. #include <linux/clk.h>
  54. #include <asm/bootinfo.h>
  55. #include <asm/io.h>
  56. #include <asm/processor.h>
  57. #include <asm/reboot.h>
  58. #include <asm/time.h>
  59. #include <asm/txx9tmr.h>
  60. #ifdef CONFIG_TOSHIBA_FPCIB0
  61. #include <asm/txx9/smsc_fdc37m81x.h>
  62. #endif
  63. #include <asm/txx9/rbtx4927.h>
  64. #ifdef CONFIG_SERIAL_TXX9
  65. #include <linux/serial_core.h>
  66. #endif
  67. /* These functions are used for rebooting or halting the machine*/
  68. extern void toshiba_rbtx4927_restart(char *command);
  69. extern void toshiba_rbtx4927_halt(void);
  70. extern void toshiba_rbtx4927_power_off(void);
  71. int tx4927_using_backplane = 0;
  72. extern void toshiba_rbtx4927_irq_setup(void);
  73. char *prom_getcmdline(void);
  74. #ifdef CONFIG_PCI
  75. #undef TX4927_SUPPORT_COMMAND_IO
  76. #undef TX4927_SUPPORT_PCI_66
  77. int tx4927_cpu_clock = 100000000; /* 100MHz */
  78. unsigned long mips_pci_io_base;
  79. unsigned long mips_pci_io_size;
  80. unsigned long mips_pci_mem_base;
  81. unsigned long mips_pci_mem_size;
  82. /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
  83. unsigned long mips_pci_io_pciaddr = 0;
  84. unsigned long mips_memory_upper;
  85. static int tx4927_ccfg_toeon = 1;
  86. static int tx4927_pcic_trdyto = 0; /* default: disabled */
  87. unsigned long tx4927_ce_base[8];
  88. int tx4927_pci66 = 0; /* 0:auto */
  89. #endif
  90. char *toshiba_name = "";
  91. #ifdef CONFIG_PCI
  92. extern struct pci_controller tx4927_controller;
  93. static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
  94. int top_bus, int busnr, int devfn)
  95. {
  96. static struct pci_dev dev;
  97. static struct pci_bus bus;
  98. dev.sysdata = (void *)hose;
  99. dev.devfn = devfn;
  100. bus.number = busnr;
  101. bus.ops = hose->pci_ops;
  102. bus.parent = NULL;
  103. dev.bus = &bus;
  104. return &dev;
  105. }
  106. #define EARLY_PCI_OP(rw, size, type) \
  107. static int early_##rw##_config_##size(struct pci_controller *hose, \
  108. int top_bus, int bus, int devfn, int offset, type value) \
  109. { \
  110. return pci_##rw##_config_##size( \
  111. fake_pci_dev(hose, top_bus, bus, devfn), \
  112. offset, value); \
  113. }
  114. EARLY_PCI_OP(read, byte, u8 *)
  115. EARLY_PCI_OP(read, dword, u32 *)
  116. EARLY_PCI_OP(write, byte, u8)
  117. EARLY_PCI_OP(write, dword, u32)
  118. static int __init tx4927_pcibios_init(void)
  119. {
  120. unsigned int id;
  121. u32 pci_devfn;
  122. int devfn_start = 0;
  123. int devfn_stop = 0xff;
  124. int busno = 0; /* One bus on the Toshiba */
  125. struct pci_controller *hose = &tx4927_controller;
  126. for (pci_devfn = devfn_start; pci_devfn < devfn_stop; pci_devfn++) {
  127. early_read_config_dword(hose, busno, busno, pci_devfn,
  128. PCI_VENDOR_ID, &id);
  129. if (id == 0xffffffff) {
  130. continue;
  131. }
  132. if (id == 0x94601055) {
  133. u8 v08_64;
  134. u32 v32_b0;
  135. u8 v08_e1;
  136. early_read_config_byte(hose, busno, busno,
  137. pci_devfn, 0x64, &v08_64);
  138. early_read_config_dword(hose, busno, busno,
  139. pci_devfn, 0xb0, &v32_b0);
  140. early_read_config_byte(hose, busno, busno,
  141. pci_devfn, 0xe1, &v08_e1);
  142. /* serial irq control */
  143. v08_64 = 0xd0;
  144. /* serial irq pin */
  145. v32_b0 |= 0x00010000;
  146. /* ide irq on isa14 */
  147. v08_e1 &= 0xf0;
  148. v08_e1 |= 0x0d;
  149. early_write_config_byte(hose, busno, busno,
  150. pci_devfn, 0x64, v08_64);
  151. early_write_config_dword(hose, busno, busno,
  152. pci_devfn, 0xb0, v32_b0);
  153. early_write_config_byte(hose, busno, busno,
  154. pci_devfn, 0xe1, v08_e1);
  155. }
  156. if (id == 0x91301055) {
  157. u8 v08_04;
  158. u8 v08_09;
  159. u8 v08_41;
  160. u8 v08_43;
  161. u8 v08_5c;
  162. early_read_config_byte(hose, busno, busno,
  163. pci_devfn, 0x04, &v08_04);
  164. early_read_config_byte(hose, busno, busno,
  165. pci_devfn, 0x09, &v08_09);
  166. early_read_config_byte(hose, busno, busno,
  167. pci_devfn, 0x41, &v08_41);
  168. early_read_config_byte(hose, busno, busno,
  169. pci_devfn, 0x43, &v08_43);
  170. early_read_config_byte(hose, busno, busno,
  171. pci_devfn, 0x5c, &v08_5c);
  172. /* enable ide master/io */
  173. v08_04 |= (PCI_COMMAND_MASTER | PCI_COMMAND_IO);
  174. /* enable ide native mode */
  175. v08_09 |= 0x05;
  176. /* enable primary ide */
  177. v08_41 |= 0x80;
  178. /* enable secondary ide */
  179. v08_43 |= 0x80;
  180. /*
  181. * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
  182. *
  183. * This line of code is intended to provide the user with a work
  184. * around solution to the anomalies cited in SMSC's anomaly sheet
  185. * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
  186. *
  187. * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
  188. */
  189. v08_5c |= 0x01;
  190. early_write_config_byte(hose, busno, busno,
  191. pci_devfn, 0x5c, v08_5c);
  192. early_write_config_byte(hose, busno, busno,
  193. pci_devfn, 0x04, v08_04);
  194. early_write_config_byte(hose, busno, busno,
  195. pci_devfn, 0x09, v08_09);
  196. early_write_config_byte(hose, busno, busno,
  197. pci_devfn, 0x41, v08_41);
  198. early_write_config_byte(hose, busno, busno,
  199. pci_devfn, 0x43, v08_43);
  200. }
  201. }
  202. register_pci_controller(&tx4927_controller);
  203. return 0;
  204. }
  205. arch_initcall(tx4927_pcibios_init);
  206. extern struct resource pci_io_resource;
  207. extern struct resource pci_mem_resource;
  208. void __init tx4927_pci_setup(void)
  209. {
  210. static int called = 0;
  211. extern unsigned int tx4927_get_mem_size(void);
  212. mips_memory_upper = tx4927_get_mem_size() << 20;
  213. mips_memory_upper += KSEG0;
  214. mips_pci_io_base = TX4927_PCIIO;
  215. mips_pci_io_size = TX4927_PCIIO_SIZE;
  216. mips_pci_mem_base = TX4927_PCIMEM;
  217. mips_pci_mem_size = TX4927_PCIMEM_SIZE;
  218. if (!called) {
  219. printk
  220. ("%s PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
  221. toshiba_name,
  222. (unsigned short) (tx4927_pcicptr->pciid >> 16),
  223. (unsigned short) (tx4927_pcicptr->pciid & 0xffff),
  224. (unsigned short) (tx4927_pcicptr->pciccrev & 0xff),
  225. (!(tx4927_ccfgptr->
  226. ccfg & TX4927_CCFG_PCIXARB)) ? "External" :
  227. "Internal");
  228. called = 1;
  229. }
  230. printk("%s PCIC --%s PCICLK:", toshiba_name,
  231. (tx4927_ccfgptr->ccfg & TX4927_CCFG_PCI66) ? " PCI66" : "");
  232. if (tx4927_ccfgptr->pcfg & TX4927_PCFG_PCICLKEN_ALL) {
  233. int pciclk = 0;
  234. if (mips_machtype == MACH_TOSHIBA_RBTX4937)
  235. switch ((unsigned long) tx4927_ccfgptr->
  236. ccfg & TX4937_CCFG_PCIDIVMODE_MASK) {
  237. case TX4937_CCFG_PCIDIVMODE_4:
  238. pciclk = tx4927_cpu_clock / 4;
  239. break;
  240. case TX4937_CCFG_PCIDIVMODE_4_5:
  241. pciclk = tx4927_cpu_clock * 2 / 9;
  242. break;
  243. case TX4937_CCFG_PCIDIVMODE_5:
  244. pciclk = tx4927_cpu_clock / 5;
  245. break;
  246. case TX4937_CCFG_PCIDIVMODE_5_5:
  247. pciclk = tx4927_cpu_clock * 2 / 11;
  248. break;
  249. case TX4937_CCFG_PCIDIVMODE_8:
  250. pciclk = tx4927_cpu_clock / 8;
  251. break;
  252. case TX4937_CCFG_PCIDIVMODE_9:
  253. pciclk = tx4927_cpu_clock / 9;
  254. break;
  255. case TX4937_CCFG_PCIDIVMODE_10:
  256. pciclk = tx4927_cpu_clock / 10;
  257. break;
  258. case TX4937_CCFG_PCIDIVMODE_11:
  259. pciclk = tx4927_cpu_clock / 11;
  260. break;
  261. }
  262. else
  263. switch ((unsigned long) tx4927_ccfgptr->
  264. ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
  265. case TX4927_CCFG_PCIDIVMODE_2_5:
  266. pciclk = tx4927_cpu_clock * 2 / 5;
  267. break;
  268. case TX4927_CCFG_PCIDIVMODE_3:
  269. pciclk = tx4927_cpu_clock / 3;
  270. break;
  271. case TX4927_CCFG_PCIDIVMODE_5:
  272. pciclk = tx4927_cpu_clock / 5;
  273. break;
  274. case TX4927_CCFG_PCIDIVMODE_6:
  275. pciclk = tx4927_cpu_clock / 6;
  276. break;
  277. }
  278. printk("Internal(%dMHz)", pciclk / 1000000);
  279. } else
  280. printk("External");
  281. printk("\n");
  282. /* GB->PCI mappings */
  283. tx4927_pcicptr->g2piomask = (mips_pci_io_size - 1) >> 4;
  284. tx4927_pcicptr->g2piogbase = mips_pci_io_base |
  285. #ifdef __BIG_ENDIAN
  286. TX4927_PCIC_G2PIOGBASE_ECHG
  287. #else
  288. TX4927_PCIC_G2PIOGBASE_BSDIS
  289. #endif
  290. ;
  291. tx4927_pcicptr->g2piopbase = 0;
  292. tx4927_pcicptr->g2pmmask[0] = (mips_pci_mem_size - 1) >> 4;
  293. tx4927_pcicptr->g2pmgbase[0] = mips_pci_mem_base |
  294. #ifdef __BIG_ENDIAN
  295. TX4927_PCIC_G2PMnGBASE_ECHG
  296. #else
  297. TX4927_PCIC_G2PMnGBASE_BSDIS
  298. #endif
  299. ;
  300. tx4927_pcicptr->g2pmpbase[0] = mips_pci_mem_base;
  301. tx4927_pcicptr->g2pmmask[1] = 0;
  302. tx4927_pcicptr->g2pmgbase[1] = 0;
  303. tx4927_pcicptr->g2pmpbase[1] = 0;
  304. tx4927_pcicptr->g2pmmask[2] = 0;
  305. tx4927_pcicptr->g2pmgbase[2] = 0;
  306. tx4927_pcicptr->g2pmpbase[2] = 0;
  307. /* PCI->GB mappings (I/O 256B) */
  308. tx4927_pcicptr->p2giopbase = 0; /* 256B */
  309. /* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
  310. tx4927_pcicptr->p2gm0plbase = 0;
  311. tx4927_pcicptr->p2gm0pubase = 0;
  312. tx4927_pcicptr->p2gmgbase[0] = 0 | TX4927_PCIC_P2GMnGBASE_TMEMEN |
  313. #ifdef __BIG_ENDIAN
  314. TX4927_PCIC_P2GMnGBASE_TECHG
  315. #else
  316. TX4927_PCIC_P2GMnGBASE_TBSDIS
  317. #endif
  318. ;
  319. /* PCI->GB mappings (MEM 16MB) -not used */
  320. tx4927_pcicptr->p2gm1plbase = 0xffffffff;
  321. tx4927_pcicptr->p2gm1pubase = 0xffffffff;
  322. tx4927_pcicptr->p2gmgbase[1] = 0;
  323. /* PCI->GB mappings (MEM 1MB) -not used */
  324. tx4927_pcicptr->p2gm2pbase = 0xffffffff;
  325. tx4927_pcicptr->p2gmgbase[2] = 0;
  326. /* Enable Initiator Memory 0 Space, I/O Space, Config */
  327. tx4927_pcicptr->pciccfg &= TX4927_PCIC_PCICCFG_LBWC_MASK;
  328. tx4927_pcicptr->pciccfg |=
  329. TX4927_PCIC_PCICCFG_IMSE0 | TX4927_PCIC_PCICCFG_IISE |
  330. TX4927_PCIC_PCICCFG_ICAE | TX4927_PCIC_PCICCFG_ATR;
  331. /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
  332. tx4927_pcicptr->pcicfg1 = 0;
  333. if (tx4927_pcic_trdyto >= 0) {
  334. tx4927_pcicptr->g2ptocnt &= ~0xff;
  335. tx4927_pcicptr->g2ptocnt |= (tx4927_pcic_trdyto & 0xff);
  336. }
  337. /* Clear All Local Bus Status */
  338. tx4927_pcicptr->pcicstatus = TX4927_PCIC_PCICSTATUS_ALL;
  339. /* Enable All Local Bus Interrupts */
  340. tx4927_pcicptr->pcicmask = TX4927_PCIC_PCICSTATUS_ALL;
  341. /* Clear All Initiator Status */
  342. tx4927_pcicptr->g2pstatus = TX4927_PCIC_G2PSTATUS_ALL;
  343. /* Enable All Initiator Interrupts */
  344. tx4927_pcicptr->g2pmask = TX4927_PCIC_G2PSTATUS_ALL;
  345. /* Clear All PCI Status Error */
  346. tx4927_pcicptr->pcistatus =
  347. (tx4927_pcicptr->pcistatus & 0x0000ffff) |
  348. (TX4927_PCIC_PCISTATUS_ALL << 16);
  349. /* Enable All PCI Status Error Interrupts */
  350. tx4927_pcicptr->pcimask = TX4927_PCIC_PCISTATUS_ALL;
  351. /* PCIC Int => IRC IRQ16 */
  352. tx4927_pcicptr->pcicfg2 =
  353. (tx4927_pcicptr->pcicfg2 & 0xffffff00) | TX4927_IR_PCIC;
  354. if (!(tx4927_ccfgptr->ccfg & TX4927_CCFG_PCIXARB)) {
  355. /* XXX */
  356. } else {
  357. /* Reset Bus Arbiter */
  358. tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_RPBA;
  359. /* Enable Bus Arbiter */
  360. tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_PBAEN;
  361. }
  362. tx4927_pcicptr->pcistatus = PCI_COMMAND_MASTER |
  363. PCI_COMMAND_MEMORY |
  364. PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
  365. }
  366. #endif /* CONFIG_PCI */
  367. static void __noreturn wait_forever(void)
  368. {
  369. while (1)
  370. if (cpu_wait)
  371. (*cpu_wait)();
  372. }
  373. void toshiba_rbtx4927_restart(char *command)
  374. {
  375. printk(KERN_NOTICE "System Rebooting...\n");
  376. /* enable the s/w reset register */
  377. writeb(RBTX4927_SW_RESET_ENABLE_SET, RBTX4927_SW_RESET_ENABLE);
  378. /* wait for enable to be seen */
  379. while ((readb(RBTX4927_SW_RESET_ENABLE) &
  380. RBTX4927_SW_RESET_ENABLE_SET) == 0x00);
  381. /* do a s/w reset */
  382. writeb(RBTX4927_SW_RESET_DO_SET, RBTX4927_SW_RESET_DO);
  383. /* do something passive while waiting for reset */
  384. local_irq_disable();
  385. wait_forever();
  386. /* no return */
  387. }
  388. void toshiba_rbtx4927_halt(void)
  389. {
  390. printk(KERN_NOTICE "System Halted\n");
  391. local_irq_disable();
  392. wait_forever();
  393. /* no return */
  394. }
  395. void toshiba_rbtx4927_power_off(void)
  396. {
  397. toshiba_rbtx4927_halt();
  398. /* no return */
  399. }
  400. void __init plat_mem_setup(void)
  401. {
  402. int i;
  403. u32 cp0_config;
  404. char *argptr;
  405. printk("CPU is %s\n", toshiba_name);
  406. /* f/w leaves this on at startup */
  407. clear_c0_status(ST0_ERL);
  408. /* enable caches -- HCP5 does this, pmon does not */
  409. cp0_config = read_c0_config();
  410. cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
  411. write_c0_config(cp0_config);
  412. set_io_port_base(KSEG1 + TBTX4927_ISA_IO_OFFSET);
  413. ioport_resource.end = 0xffffffff;
  414. iomem_resource.end = 0xffffffff;
  415. _machine_restart = toshiba_rbtx4927_restart;
  416. _machine_halt = toshiba_rbtx4927_halt;
  417. pm_power_off = toshiba_rbtx4927_power_off;
  418. for (i = 0; i < TX4927_NR_TMR; i++)
  419. txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL);
  420. #ifdef CONFIG_PCI
  421. /* PCIC */
  422. /*
  423. * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
  424. *
  425. * For TX4927:
  426. * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1).
  427. * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
  428. * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
  429. * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
  430. * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
  431. * i.e. S9[3]: ON (83MHz), OFF (100MHz)
  432. *
  433. * For TX4937:
  434. * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1)
  435. * PCIDIVMODE[10] is 0.
  436. * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8)
  437. * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4)
  438. * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9)
  439. * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5)
  440. * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10)
  441. * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5)
  442. *
  443. */
  444. if (mips_machtype == MACH_TOSHIBA_RBTX4937)
  445. switch ((unsigned long)tx4927_ccfgptr->
  446. ccfg & TX4937_CCFG_PCIDIVMODE_MASK) {
  447. case TX4937_CCFG_PCIDIVMODE_8:
  448. case TX4937_CCFG_PCIDIVMODE_4:
  449. tx4927_cpu_clock = 266666666; /* 266MHz */
  450. break;
  451. case TX4937_CCFG_PCIDIVMODE_9:
  452. case TX4937_CCFG_PCIDIVMODE_4_5:
  453. tx4927_cpu_clock = 300000000; /* 300MHz */
  454. break;
  455. default:
  456. tx4927_cpu_clock = 333333333; /* 333MHz */
  457. }
  458. else
  459. switch ((unsigned long)tx4927_ccfgptr->
  460. ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
  461. case TX4927_CCFG_PCIDIVMODE_2_5:
  462. case TX4927_CCFG_PCIDIVMODE_5:
  463. tx4927_cpu_clock = 166666666; /* 166MHz */
  464. break;
  465. default:
  466. tx4927_cpu_clock = 200000000; /* 200MHz */
  467. }
  468. /* CCFG */
  469. /* do reset on watchdog */
  470. tx4927_ccfgptr->ccfg |= TX4927_CCFG_WR;
  471. /* enable Timeout BusError */
  472. if (tx4927_ccfg_toeon)
  473. tx4927_ccfgptr->ccfg |= TX4927_CCFG_TOE;
  474. tx4927_pci_setup();
  475. if (tx4927_using_backplane == 1)
  476. printk("backplane board IS installed\n");
  477. else
  478. printk("No Backplane \n");
  479. /* this is on ISA bus behind PCI bus, so need PCI up first */
  480. #ifdef CONFIG_TOSHIBA_FPCIB0
  481. if (tx4927_using_backplane) {
  482. smsc_fdc37m81x_init(0x3f0);
  483. smsc_fdc37m81x_config_beg();
  484. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM,
  485. SMSC_FDC37M81X_KBD);
  486. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT, 1);
  487. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2, 12);
  488. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE,
  489. 1);
  490. smsc_fdc37m81x_config_end();
  491. }
  492. #endif
  493. #endif /* CONFIG_PCI */
  494. #ifdef CONFIG_SERIAL_TXX9
  495. {
  496. extern int early_serial_txx9_setup(struct uart_port *port);
  497. struct uart_port req;
  498. for(i = 0; i < 2; i++) {
  499. memset(&req, 0, sizeof(req));
  500. req.line = i;
  501. req.iotype = UPIO_MEM;
  502. req.membase = (char *)(0xff1ff300 + i * 0x100);
  503. req.mapbase = 0xff1ff300 + i * 0x100;
  504. req.irq = TX4927_IRQ_PIC_BEG + 8 + i;
  505. req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
  506. req.uartclk = 50000000;
  507. early_serial_txx9_setup(&req);
  508. }
  509. }
  510. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  511. argptr = prom_getcmdline();
  512. if (strstr(argptr, "console=") == NULL) {
  513. strcat(argptr, " console=ttyS0,38400");
  514. }
  515. #endif
  516. #endif
  517. #ifdef CONFIG_ROOT_NFS
  518. argptr = prom_getcmdline();
  519. if (strstr(argptr, "root=") == NULL) {
  520. strcat(argptr, " root=/dev/nfs rw");
  521. }
  522. #endif
  523. #ifdef CONFIG_IP_PNP
  524. argptr = prom_getcmdline();
  525. if (strstr(argptr, "ip=") == NULL) {
  526. strcat(argptr, " ip=any");
  527. }
  528. #endif
  529. }
  530. void __init plat_time_init(void)
  531. {
  532. mips_hpt_frequency = tx4927_cpu_clock / 2;
  533. if (tx4927_ccfgptr->ccfg & TX4927_CCFG_TINTDIS)
  534. txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL,
  535. TXX9_IRQ_BASE + 17,
  536. 50000000);
  537. }
  538. static int __init toshiba_rbtx4927_rtc_init(void)
  539. {
  540. static struct resource __initdata res = {
  541. .start = 0x1c010000,
  542. .end = 0x1c010000 + 0x800 - 1,
  543. .flags = IORESOURCE_MEM,
  544. };
  545. struct platform_device *dev =
  546. platform_device_register_simple("rtc-ds1742", -1, &res, 1);
  547. return IS_ERR(dev) ? PTR_ERR(dev) : 0;
  548. }
  549. device_initcall(toshiba_rbtx4927_rtc_init);
  550. static int __init rbtx4927_ne_init(void)
  551. {
  552. static struct resource __initdata res[] = {
  553. {
  554. .start = RBTX4927_RTL_8019_BASE,
  555. .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
  556. .flags = IORESOURCE_IO,
  557. }, {
  558. .start = RBTX4927_RTL_8019_IRQ,
  559. .flags = IORESOURCE_IRQ,
  560. }
  561. };
  562. struct platform_device *dev =
  563. platform_device_register_simple("ne", -1,
  564. res, ARRAY_SIZE(res));
  565. return IS_ERR(dev) ? PTR_ERR(dev) : 0;
  566. }
  567. device_initcall(rbtx4927_ne_init);
  568. /* Watchdog support */
  569. static int __init txx9_wdt_init(unsigned long base)
  570. {
  571. struct resource res = {
  572. .start = base,
  573. .end = base + 0x100 - 1,
  574. .flags = IORESOURCE_MEM,
  575. };
  576. struct platform_device *dev =
  577. platform_device_register_simple("txx9wdt", -1, &res, 1);
  578. return IS_ERR(dev) ? PTR_ERR(dev) : 0;
  579. }
  580. static int __init rbtx4927_wdt_init(void)
  581. {
  582. return txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL);
  583. }
  584. device_initcall(rbtx4927_wdt_init);
  585. /* Minimum CLK support */
  586. struct clk *clk_get(struct device *dev, const char *id)
  587. {
  588. if (!strcmp(id, "imbus_clk"))
  589. return (struct clk *)50000000;
  590. return ERR_PTR(-ENOENT);
  591. }
  592. EXPORT_SYMBOL(clk_get);
  593. int clk_enable(struct clk *clk)
  594. {
  595. return 0;
  596. }
  597. EXPORT_SYMBOL(clk_enable);
  598. void clk_disable(struct clk *clk)
  599. {
  600. }
  601. EXPORT_SYMBOL(clk_disable);
  602. unsigned long clk_get_rate(struct clk *clk)
  603. {
  604. return (unsigned long)clk;
  605. }
  606. EXPORT_SYMBOL(clk_get_rate);
  607. void clk_put(struct clk *clk)
  608. {
  609. }
  610. EXPORT_SYMBOL(clk_put);