toshiba_rbtx4927_setup.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  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/config.h>
  46. #include <linux/init.h>
  47. #include <linux/kernel.h>
  48. #include <linux/types.h>
  49. #include <linux/mm.h>
  50. #include <linux/swap.h>
  51. #include <linux/ioport.h>
  52. #include <linux/sched.h>
  53. #include <linux/interrupt.h>
  54. #include <linux/pci.h>
  55. #include <linux/timex.h>
  56. #include <asm/bootinfo.h>
  57. #include <asm/page.h>
  58. #include <asm/io.h>
  59. #include <asm/irq.h>
  60. #include <asm/processor.h>
  61. #include <asm/ptrace.h>
  62. #include <asm/reboot.h>
  63. #include <asm/time.h>
  64. #include <linux/bootmem.h>
  65. #include <linux/blkdev.h>
  66. #ifdef CONFIG_RTC_DS1742
  67. #include <linux/ds1742rtc.h>
  68. #endif
  69. #ifdef CONFIG_TOSHIBA_FPCIB0
  70. #include <asm/tx4927/smsc_fdc37m81x.h>
  71. #endif
  72. #include <asm/tx4927/toshiba_rbtx4927.h>
  73. #ifdef CONFIG_PCI
  74. #include <asm/tx4927/tx4927_pci.h>
  75. #endif
  76. #ifdef CONFIG_BLK_DEV_IDEPCI
  77. #include <linux/hdreg.h>
  78. #include <linux/ide.h>
  79. #endif
  80. #undef TOSHIBA_RBTX4927_SETUP_DEBUG
  81. #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
  82. #define TOSHIBA_RBTX4927_SETUP_NONE 0x00000000
  83. #define TOSHIBA_RBTX4927_SETUP_INFO ( 1 << 0 )
  84. #define TOSHIBA_RBTX4927_SETUP_WARN ( 1 << 1 )
  85. #define TOSHIBA_RBTX4927_SETUP_EROR ( 1 << 2 )
  86. #define TOSHIBA_RBTX4927_SETUP_EFWFU ( 1 << 3 )
  87. #define TOSHIBA_RBTX4927_SETUP_SETUP ( 1 << 4 )
  88. #define TOSHIBA_RBTX4927_SETUP_TIME_INIT ( 1 << 5 )
  89. #define TOSHIBA_RBTX4927_SETUP_TIMER_SETUP ( 1 << 6 )
  90. #define TOSHIBA_RBTX4927_SETUP_PCIBIOS ( 1 << 7 )
  91. #define TOSHIBA_RBTX4927_SETUP_PCI1 ( 1 << 8 )
  92. #define TOSHIBA_RBTX4927_SETUP_PCI2 ( 1 << 9 )
  93. #define TOSHIBA_RBTX4927_SETUP_PCI66 ( 1 << 10 )
  94. #define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
  95. #endif
  96. #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
  97. static const u32 toshiba_rbtx4927_setup_debug_flag =
  98. (TOSHIBA_RBTX4927_SETUP_NONE | TOSHIBA_RBTX4927_SETUP_INFO |
  99. TOSHIBA_RBTX4927_SETUP_WARN | TOSHIBA_RBTX4927_SETUP_EROR |
  100. TOSHIBA_RBTX4927_SETUP_EFWFU | TOSHIBA_RBTX4927_SETUP_SETUP |
  101. TOSHIBA_RBTX4927_SETUP_TIME_INIT | TOSHIBA_RBTX4927_SETUP_TIMER_SETUP
  102. | TOSHIBA_RBTX4927_SETUP_PCIBIOS | TOSHIBA_RBTX4927_SETUP_PCI1 |
  103. TOSHIBA_RBTX4927_SETUP_PCI2 | TOSHIBA_RBTX4927_SETUP_PCI66);
  104. #endif
  105. #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
  106. #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...) \
  107. if ( (toshiba_rbtx4927_setup_debug_flag) & (flag) ) \
  108. { \
  109. char tmp[100]; \
  110. sprintf( tmp, str ); \
  111. printk( "%s(%s:%u)::%s", __FUNCTION__, __FILE__, __LINE__, tmp ); \
  112. }
  113. #else
  114. #define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...)
  115. #endif
  116. /* These functions are used for rebooting or halting the machine*/
  117. extern void toshiba_rbtx4927_restart(char *command);
  118. extern void toshiba_rbtx4927_halt(void);
  119. extern void toshiba_rbtx4927_power_off(void);
  120. int tx4927_using_backplane = 0;
  121. extern void gt64120_time_init(void);
  122. extern void toshiba_rbtx4927_irq_setup(void);
  123. #ifdef CONFIG_PCI
  124. #define CONFIG_TX4927BUG_WORKAROUND
  125. #undef TX4927_SUPPORT_COMMAND_IO
  126. #undef TX4927_SUPPORT_PCI_66
  127. int tx4927_cpu_clock = 100000000; /* 100MHz */
  128. unsigned long mips_pci_io_base;
  129. unsigned long mips_pci_io_size;
  130. unsigned long mips_pci_mem_base;
  131. unsigned long mips_pci_mem_size;
  132. /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
  133. unsigned long mips_pci_io_pciaddr = 0;
  134. unsigned long mips_memory_upper;
  135. static int tx4927_ccfg_toeon = 1;
  136. static int tx4927_pcic_trdyto = 0; /* default: disabled */
  137. unsigned long tx4927_ce_base[8];
  138. void tx4927_pci_setup(void);
  139. void tx4927_reset_pci_pcic(void);
  140. int tx4927_pci66 = 0; /* 0:auto */
  141. #endif
  142. char *toshiba_name = "";
  143. #ifdef CONFIG_PCI
  144. static void tx4927_pcierr_interrupt(int irq, void *dev_id,
  145. struct pt_regs *regs)
  146. {
  147. #ifdef CONFIG_BLK_DEV_IDEPCI
  148. /* ignore MasterAbort for ide probing... */
  149. if (irq == TX4927_IRQ_IRC_PCIERR &&
  150. ((tx4927_pcicptr->pcistatus >> 16) & 0xf900) ==
  151. PCI_STATUS_REC_MASTER_ABORT) {
  152. tx4927_pcicptr->pcistatus =
  153. (tx4927_pcicptr->
  154. pcistatus & 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT
  155. << 16);
  156. return;
  157. }
  158. #endif
  159. printk("PCI error interrupt (irq 0x%x).\n", irq);
  160. printk("pcistat:%04x, g2pstatus:%08lx, pcicstatus:%08lx\n",
  161. (unsigned short) (tx4927_pcicptr->pcistatus >> 16),
  162. tx4927_pcicptr->g2pstatus, tx4927_pcicptr->pcicstatus);
  163. printk("ccfg:%08lx, tear:%02lx_%08lx\n",
  164. (unsigned long) tx4927_ccfgptr->ccfg,
  165. (unsigned long) (tx4927_ccfgptr->tear >> 32),
  166. (unsigned long) tx4927_ccfgptr->tear);
  167. show_regs(regs);
  168. }
  169. void __init toshiba_rbtx4927_pci_irq_init(void)
  170. {
  171. return;
  172. }
  173. void tx4927_reset_pci_pcic(void)
  174. {
  175. /* Reset PCI Bus */
  176. *tx4927_pcireset_ptr = 1;
  177. /* Reset PCIC */
  178. tx4927_ccfgptr->clkctr |= TX4927_CLKCTR_PCIRST;
  179. udelay(10000);
  180. /* clear PCIC reset */
  181. tx4927_ccfgptr->clkctr &= ~TX4927_CLKCTR_PCIRST;
  182. *tx4927_pcireset_ptr = 0;
  183. }
  184. #endif /* CONFIG_PCI */
  185. #ifdef CONFIG_PCI
  186. void print_pci_status(void)
  187. {
  188. printk("PCI STATUS %lx\n", tx4927_pcicptr->pcistatus);
  189. printk("PCIC STATUS %lx\n", tx4927_pcicptr->pcicstatus);
  190. }
  191. extern struct pci_controller tx4927_controller;
  192. static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
  193. int top_bus, int busnr, int devfn)
  194. {
  195. static struct pci_dev dev;
  196. static struct pci_bus bus;
  197. dev.sysdata = (void *)hose;
  198. dev.devfn = devfn;
  199. bus.number = busnr;
  200. bus.ops = hose->pci_ops;
  201. bus.parent = NULL;
  202. dev.bus = &bus;
  203. return &dev;
  204. }
  205. #define EARLY_PCI_OP(rw, size, type) \
  206. static int early_##rw##_config_##size(struct pci_controller *hose, \
  207. int top_bus, int bus, int devfn, int offset, type value) \
  208. { \
  209. return pci_##rw##_config_##size( \
  210. fake_pci_dev(hose, top_bus, bus, devfn), \
  211. offset, value); \
  212. }
  213. EARLY_PCI_OP(read, byte, u8 *)
  214. EARLY_PCI_OP(read, word, u16 *)
  215. EARLY_PCI_OP(read, dword, u32 *)
  216. EARLY_PCI_OP(write, byte, u8)
  217. EARLY_PCI_OP(write, word, u16)
  218. EARLY_PCI_OP(write, dword, u32)
  219. static int __init tx4927_pcibios_init(void)
  220. {
  221. unsigned int id;
  222. u32 pci_devfn;
  223. int devfn_start = 0;
  224. int devfn_stop = 0xff;
  225. int busno = 0; /* One bus on the Toshiba */
  226. struct pci_controller *hose = &tx4927_controller;
  227. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  228. "-\n");
  229. for (pci_devfn = devfn_start; pci_devfn < devfn_stop; pci_devfn++) {
  230. early_read_config_dword(hose, busno, busno, pci_devfn,
  231. PCI_VENDOR_ID, &id);
  232. if (id == 0xffffffff) {
  233. continue;
  234. }
  235. if (id == 0x94601055) {
  236. u8 v08_64;
  237. u32 v32_b0;
  238. u8 v08_e1;
  239. char *s = " sb/isa --";
  240. TOSHIBA_RBTX4927_SETUP_DPRINTK
  241. (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
  242. s);
  243. early_read_config_byte(hose, busno, busno,
  244. pci_devfn, 0x64, &v08_64);
  245. early_read_config_dword(hose, busno, busno,
  246. pci_devfn, 0xb0, &v32_b0);
  247. early_read_config_byte(hose, busno, busno,
  248. pci_devfn, 0xe1, &v08_e1);
  249. TOSHIBA_RBTX4927_SETUP_DPRINTK
  250. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  251. ":%s beg 0x64 = 0x%02x\n", s, v08_64);
  252. TOSHIBA_RBTX4927_SETUP_DPRINTK
  253. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  254. ":%s beg 0xb0 = 0x%02x\n", s, v32_b0);
  255. TOSHIBA_RBTX4927_SETUP_DPRINTK
  256. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  257. ":%s beg 0xe1 = 0x%02x\n", s, v08_e1);
  258. /* serial irq control */
  259. v08_64 = 0xd0;
  260. /* serial irq pin */
  261. v32_b0 |= 0x00010000;
  262. /* ide irq on isa14 */
  263. v08_e1 &= 0xf0;
  264. v08_e1 |= 0x0d;
  265. TOSHIBA_RBTX4927_SETUP_DPRINTK
  266. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  267. ":%s mid 0x64 = 0x%02x\n", s, v08_64);
  268. TOSHIBA_RBTX4927_SETUP_DPRINTK
  269. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  270. ":%s mid 0xb0 = 0x%02x\n", s, v32_b0);
  271. TOSHIBA_RBTX4927_SETUP_DPRINTK
  272. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  273. ":%s mid 0xe1 = 0x%02x\n", s, v08_e1);
  274. early_write_config_byte(hose, busno, busno,
  275. pci_devfn, 0x64, v08_64);
  276. early_write_config_dword(hose, busno, busno,
  277. pci_devfn, 0xb0, v32_b0);
  278. early_write_config_byte(hose, busno, busno,
  279. pci_devfn, 0xe1, v08_e1);
  280. #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
  281. {
  282. early_read_config_byte(hose, busno, busno,
  283. pci_devfn, 0x64,
  284. &v08_64);
  285. early_read_config_dword(hose, busno, busno,
  286. pci_devfn, 0xb0,
  287. &v32_b0);
  288. early_read_config_byte(hose, busno, busno,
  289. pci_devfn, 0xe1,
  290. &v08_e1);
  291. TOSHIBA_RBTX4927_SETUP_DPRINTK
  292. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  293. ":%s end 0x64 = 0x%02x\n", s, v08_64);
  294. TOSHIBA_RBTX4927_SETUP_DPRINTK
  295. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  296. ":%s end 0xb0 = 0x%02x\n", s, v32_b0);
  297. TOSHIBA_RBTX4927_SETUP_DPRINTK
  298. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  299. ":%s end 0xe1 = 0x%02x\n", s, v08_e1);
  300. }
  301. #endif
  302. TOSHIBA_RBTX4927_SETUP_DPRINTK
  303. (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s end\n",
  304. s);
  305. }
  306. if (id == 0x91301055) {
  307. u8 v08_04;
  308. u8 v08_09;
  309. u8 v08_41;
  310. u8 v08_43;
  311. u8 v08_5c;
  312. char *s = " sb/ide --";
  313. TOSHIBA_RBTX4927_SETUP_DPRINTK
  314. (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
  315. s);
  316. early_read_config_byte(hose, busno, busno,
  317. pci_devfn, 0x04, &v08_04);
  318. early_read_config_byte(hose, busno, busno,
  319. pci_devfn, 0x09, &v08_09);
  320. early_read_config_byte(hose, busno, busno,
  321. pci_devfn, 0x41, &v08_41);
  322. early_read_config_byte(hose, busno, busno,
  323. pci_devfn, 0x43, &v08_43);
  324. early_read_config_byte(hose, busno, busno,
  325. pci_devfn, 0x5c, &v08_5c);
  326. TOSHIBA_RBTX4927_SETUP_DPRINTK
  327. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  328. ":%s beg 0x04 = 0x%02x\n", s, v08_04);
  329. TOSHIBA_RBTX4927_SETUP_DPRINTK
  330. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  331. ":%s beg 0x09 = 0x%02x\n", s, v08_09);
  332. TOSHIBA_RBTX4927_SETUP_DPRINTK
  333. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  334. ":%s beg 0x41 = 0x%02x\n", s, v08_41);
  335. TOSHIBA_RBTX4927_SETUP_DPRINTK
  336. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  337. ":%s beg 0x43 = 0x%02x\n", s, v08_43);
  338. TOSHIBA_RBTX4927_SETUP_DPRINTK
  339. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  340. ":%s beg 0x5c = 0x%02x\n", s, v08_5c);
  341. /* enable ide master/io */
  342. v08_04 |= (PCI_COMMAND_MASTER | PCI_COMMAND_IO);
  343. /* enable ide native mode */
  344. v08_09 |= 0x05;
  345. /* enable primary ide */
  346. v08_41 |= 0x80;
  347. /* enable secondary ide */
  348. v08_43 |= 0x80;
  349. /*
  350. * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
  351. *
  352. * This line of code is intended to provide the user with a work
  353. * around solution to the anomalies cited in SMSC's anomaly sheet
  354. * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
  355. *
  356. * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
  357. */
  358. v08_5c |= 0x01;
  359. TOSHIBA_RBTX4927_SETUP_DPRINTK
  360. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  361. ":%s mid 0x04 = 0x%02x\n", s, v08_04);
  362. TOSHIBA_RBTX4927_SETUP_DPRINTK
  363. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  364. ":%s mid 0x09 = 0x%02x\n", s, v08_09);
  365. TOSHIBA_RBTX4927_SETUP_DPRINTK
  366. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  367. ":%s mid 0x41 = 0x%02x\n", s, v08_41);
  368. TOSHIBA_RBTX4927_SETUP_DPRINTK
  369. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  370. ":%s mid 0x43 = 0x%02x\n", s, v08_43);
  371. TOSHIBA_RBTX4927_SETUP_DPRINTK
  372. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  373. ":%s mid 0x5c = 0x%02x\n", s, v08_5c);
  374. early_write_config_byte(hose, busno, busno,
  375. pci_devfn, 0x5c, v08_5c);
  376. early_write_config_byte(hose, busno, busno,
  377. pci_devfn, 0x04, v08_04);
  378. early_write_config_byte(hose, busno, busno,
  379. pci_devfn, 0x09, v08_09);
  380. early_write_config_byte(hose, busno, busno,
  381. pci_devfn, 0x41, v08_41);
  382. early_write_config_byte(hose, busno, busno,
  383. pci_devfn, 0x43, v08_43);
  384. #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
  385. {
  386. early_read_config_byte(hose, busno, busno,
  387. pci_devfn, 0x04,
  388. &v08_04);
  389. early_read_config_byte(hose, busno, busno,
  390. pci_devfn, 0x09,
  391. &v08_09);
  392. early_read_config_byte(hose, busno, busno,
  393. pci_devfn, 0x41,
  394. &v08_41);
  395. early_read_config_byte(hose, busno, busno,
  396. pci_devfn, 0x43,
  397. &v08_43);
  398. early_read_config_byte(hose, busno, busno,
  399. pci_devfn, 0x5c,
  400. &v08_5c);
  401. TOSHIBA_RBTX4927_SETUP_DPRINTK
  402. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  403. ":%s end 0x04 = 0x%02x\n", s, v08_04);
  404. TOSHIBA_RBTX4927_SETUP_DPRINTK
  405. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  406. ":%s end 0x09 = 0x%02x\n", s, v08_09);
  407. TOSHIBA_RBTX4927_SETUP_DPRINTK
  408. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  409. ":%s end 0x41 = 0x%02x\n", s, v08_41);
  410. TOSHIBA_RBTX4927_SETUP_DPRINTK
  411. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  412. ":%s end 0x43 = 0x%02x\n", s, v08_43);
  413. TOSHIBA_RBTX4927_SETUP_DPRINTK
  414. (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  415. ":%s end 0x5c = 0x%02x\n", s, v08_5c);
  416. }
  417. #endif
  418. TOSHIBA_RBTX4927_SETUP_DPRINTK
  419. (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s end\n",
  420. s);
  421. }
  422. }
  423. register_pci_controller(&tx4927_controller);
  424. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
  425. "+\n");
  426. return 0;
  427. }
  428. arch_initcall(tx4927_pcibios_init);
  429. extern struct resource pci_io_resource;
  430. extern struct resource pci_mem_resource;
  431. void tx4927_pci_setup(void)
  432. {
  433. static int called = 0;
  434. extern unsigned int tx4927_get_mem_size(void);
  435. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "-\n");
  436. mips_memory_upper = tx4927_get_mem_size() << 20;
  437. mips_memory_upper += KSEG0;
  438. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  439. "0x%08lx=mips_memory_upper\n",
  440. mips_memory_upper);
  441. mips_pci_io_base = TX4927_PCIIO;
  442. mips_pci_io_size = TX4927_PCIIO_SIZE;
  443. mips_pci_mem_base = TX4927_PCIMEM;
  444. mips_pci_mem_size = TX4927_PCIMEM_SIZE;
  445. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  446. "0x%08lx=mips_pci_io_base\n",
  447. mips_pci_io_base);
  448. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  449. "0x%08lx=mips_pci_io_size\n",
  450. mips_pci_io_size);
  451. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  452. "0x%08lx=mips_pci_mem_base\n",
  453. mips_pci_mem_base);
  454. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  455. "0x%08lx=mips_pci_mem_size\n",
  456. mips_pci_mem_size);
  457. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  458. "0x%08lx=pci_io_resource.start\n",
  459. pci_io_resource.start);
  460. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  461. "0x%08lx=pci_io_resource.end\n",
  462. pci_io_resource.end);
  463. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  464. "0x%08lx=pci_mem_resource.start\n",
  465. pci_mem_resource.start);
  466. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  467. "0x%08lx=pci_mem_resource.end\n",
  468. pci_mem_resource.end);
  469. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  470. "0x%08lx=mips_io_port_base",
  471. mips_io_port_base);
  472. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  473. "setup pci_io_resource to 0x%08lx 0x%08lx\n",
  474. pci_io_resource.start,
  475. pci_io_resource.end);
  476. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  477. "setup pci_mem_resource to 0x%08lx 0x%08lx\n",
  478. pci_mem_resource.start,
  479. pci_mem_resource.end);
  480. if (!called) {
  481. printk
  482. ("TX4927 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
  483. (unsigned short) (tx4927_pcicptr->pciid >> 16),
  484. (unsigned short) (tx4927_pcicptr->pciid & 0xffff),
  485. (unsigned short) (tx4927_pcicptr->pciccrev & 0xff),
  486. (!(tx4927_ccfgptr->
  487. ccfg & TX4927_CCFG_PCIXARB)) ? "External" :
  488. "Internal");
  489. called = 1;
  490. }
  491. printk("%s PCIC --%s PCICLK:",toshiba_name,
  492. (tx4927_ccfgptr->ccfg & TX4927_CCFG_PCI66) ? " PCI66" : "");
  493. if (tx4927_ccfgptr->pcfg & TX4927_PCFG_PCICLKEN_ALL) {
  494. int pciclk = 0;
  495. switch ((unsigned long) tx4927_ccfgptr->
  496. ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
  497. case TX4927_CCFG_PCIDIVMODE_2_5:
  498. pciclk = tx4927_cpu_clock * 2 / 5;
  499. break;
  500. case TX4927_CCFG_PCIDIVMODE_3:
  501. pciclk = tx4927_cpu_clock / 3;
  502. break;
  503. case TX4927_CCFG_PCIDIVMODE_5:
  504. pciclk = tx4927_cpu_clock / 5;
  505. break;
  506. case TX4927_CCFG_PCIDIVMODE_6:
  507. pciclk = tx4927_cpu_clock / 6;
  508. break;
  509. }
  510. printk("Internal(%dMHz)", pciclk / 1000000);
  511. } else {
  512. int pciclk = 0;
  513. int pciclk_setting = *tx4927_pci_clk_ptr;
  514. switch (pciclk_setting & TX4927_PCI_CLK_MASK) {
  515. case TX4927_PCI_CLK_33:
  516. pciclk = 33333333;
  517. break;
  518. case TX4927_PCI_CLK_25:
  519. pciclk = 25000000;
  520. break;
  521. case TX4927_PCI_CLK_66:
  522. pciclk = 66666666;
  523. break;
  524. case TX4927_PCI_CLK_50:
  525. pciclk = 50000000;
  526. break;
  527. }
  528. printk("External(%dMHz)", pciclk / 1000000);
  529. }
  530. printk("\n");
  531. /* GB->PCI mappings */
  532. tx4927_pcicptr->g2piomask = (mips_pci_io_size - 1) >> 4;
  533. tx4927_pcicptr->g2piogbase = mips_pci_io_base |
  534. #ifdef __BIG_ENDIAN
  535. TX4927_PCIC_G2PIOGBASE_ECHG
  536. #else
  537. TX4927_PCIC_G2PIOGBASE_BSDIS
  538. #endif
  539. ;
  540. tx4927_pcicptr->g2piopbase = 0;
  541. tx4927_pcicptr->g2pmmask[0] = (mips_pci_mem_size - 1) >> 4;
  542. tx4927_pcicptr->g2pmgbase[0] = mips_pci_mem_base |
  543. #ifdef __BIG_ENDIAN
  544. TX4927_PCIC_G2PMnGBASE_ECHG
  545. #else
  546. TX4927_PCIC_G2PMnGBASE_BSDIS
  547. #endif
  548. ;
  549. tx4927_pcicptr->g2pmpbase[0] = mips_pci_mem_base;
  550. tx4927_pcicptr->g2pmmask[1] = 0;
  551. tx4927_pcicptr->g2pmgbase[1] = 0;
  552. tx4927_pcicptr->g2pmpbase[1] = 0;
  553. tx4927_pcicptr->g2pmmask[2] = 0;
  554. tx4927_pcicptr->g2pmgbase[2] = 0;
  555. tx4927_pcicptr->g2pmpbase[2] = 0;
  556. /* PCI->GB mappings (I/O 256B) */
  557. tx4927_pcicptr->p2giopbase = 0; /* 256B */
  558. /* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
  559. tx4927_pcicptr->p2gm0plbase = 0;
  560. tx4927_pcicptr->p2gm0pubase = 0;
  561. tx4927_pcicptr->p2gmgbase[0] = 0 | TX4927_PCIC_P2GMnGBASE_TMEMEN |
  562. #ifdef __BIG_ENDIAN
  563. TX4927_PCIC_P2GMnGBASE_TECHG
  564. #else
  565. TX4927_PCIC_P2GMnGBASE_TBSDIS
  566. #endif
  567. ;
  568. /* PCI->GB mappings (MEM 16MB) -not used */
  569. tx4927_pcicptr->p2gm1plbase = 0xffffffff;
  570. #ifdef CONFIG_TX4927BUG_WORKAROUND
  571. /*
  572. * TX4927-PCIC-BUG: P2GM1PUBASE must be 0
  573. * if P2GM0PUBASE was 0.
  574. */
  575. tx4927_pcicptr->p2gm1pubase = 0;
  576. #else
  577. tx4927_pcicptr->p2gm1pubase = 0xffffffff;
  578. #endif
  579. tx4927_pcicptr->p2gmgbase[1] = 0;
  580. /* PCI->GB mappings (MEM 1MB) -not used */
  581. tx4927_pcicptr->p2gm2pbase = 0xffffffff;
  582. tx4927_pcicptr->p2gmgbase[2] = 0;
  583. /* Enable Initiator Memory 0 Space, I/O Space, Config */
  584. tx4927_pcicptr->pciccfg &= TX4927_PCIC_PCICCFG_LBWC_MASK;
  585. tx4927_pcicptr->pciccfg |=
  586. TX4927_PCIC_PCICCFG_IMSE0 | TX4927_PCIC_PCICCFG_IISE |
  587. TX4927_PCIC_PCICCFG_ICAE | TX4927_PCIC_PCICCFG_ATR;
  588. /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
  589. tx4927_pcicptr->pcicfg1 = 0;
  590. if (tx4927_pcic_trdyto >= 0) {
  591. tx4927_pcicptr->g2ptocnt &= ~0xff;
  592. tx4927_pcicptr->g2ptocnt |= (tx4927_pcic_trdyto & 0xff);
  593. }
  594. /* Clear All Local Bus Status */
  595. tx4927_pcicptr->pcicstatus = TX4927_PCIC_PCICSTATUS_ALL;
  596. /* Enable All Local Bus Interrupts */
  597. tx4927_pcicptr->pcicmask = TX4927_PCIC_PCICSTATUS_ALL;
  598. /* Clear All Initiator Status */
  599. tx4927_pcicptr->g2pstatus = TX4927_PCIC_G2PSTATUS_ALL;
  600. /* Enable All Initiator Interrupts */
  601. tx4927_pcicptr->g2pmask = TX4927_PCIC_G2PSTATUS_ALL;
  602. /* Clear All PCI Status Error */
  603. tx4927_pcicptr->pcistatus =
  604. (tx4927_pcicptr->pcistatus & 0x0000ffff) |
  605. (TX4927_PCIC_PCISTATUS_ALL << 16);
  606. /* Enable All PCI Status Error Interrupts */
  607. tx4927_pcicptr->pcimask = TX4927_PCIC_PCISTATUS_ALL;
  608. /* PCIC Int => IRC IRQ16 */
  609. tx4927_pcicptr->pcicfg2 =
  610. (tx4927_pcicptr->pcicfg2 & 0xffffff00) | TX4927_IR_PCIC;
  611. if (!(tx4927_ccfgptr->ccfg & TX4927_CCFG_PCIXARB)) {
  612. /* XXX */
  613. } else {
  614. /* Reset Bus Arbiter */
  615. tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_RPBA;
  616. /* Enable Bus Arbiter */
  617. tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_PBAEN;
  618. }
  619. tx4927_pcicptr->pcistatus = PCI_COMMAND_MASTER |
  620. PCI_COMMAND_MEMORY |
  621. PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
  622. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
  623. ":pci setup complete:\n");
  624. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "+\n");
  625. }
  626. #endif /* CONFIG_PCI */
  627. void toshiba_rbtx4927_restart(char *command)
  628. {
  629. printk(KERN_NOTICE "System Rebooting...\n");
  630. /* enable the s/w reset register */
  631. reg_wr08(RBTX4927_SW_RESET_ENABLE, RBTX4927_SW_RESET_ENABLE_SET);
  632. /* wait for enable to be seen */
  633. while ((reg_rd08(RBTX4927_SW_RESET_ENABLE) &
  634. RBTX4927_SW_RESET_ENABLE_SET) == 0x00);
  635. /* do a s/w reset */
  636. reg_wr08(RBTX4927_SW_RESET_DO, RBTX4927_SW_RESET_DO_SET);
  637. /* do something passive while waiting for reset */
  638. local_irq_disable();
  639. while (1)
  640. asm_wait();
  641. /* no return */
  642. }
  643. void toshiba_rbtx4927_halt(void)
  644. {
  645. printk(KERN_NOTICE "System Halted\n");
  646. local_irq_disable();
  647. while (1) {
  648. asm_wait();
  649. }
  650. /* no return */
  651. }
  652. void toshiba_rbtx4927_power_off(void)
  653. {
  654. toshiba_rbtx4927_halt();
  655. /* no return */
  656. }
  657. void __init toshiba_rbtx4927_setup(void)
  658. {
  659. vu32 cp0_config;
  660. char *argptr;
  661. printk("CPU is %s\n", toshiba_name);
  662. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  663. "-\n");
  664. /* f/w leaves this on at startup */
  665. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  666. ":Clearing STO_ERL.\n");
  667. clear_c0_status(ST0_ERL);
  668. /* enable caches -- HCP5 does this, pmon does not */
  669. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  670. ":Enabling TX49_CONF_IC,TX49_CONF_DC.\n");
  671. cp0_config = read_c0_config();
  672. cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
  673. write_c0_config(cp0_config);
  674. #ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
  675. {
  676. extern void dump_cp0(char *);
  677. dump_cp0("toshiba_rbtx4927_early_fw_fixup");
  678. }
  679. #endif
  680. /* setup irq stuff */
  681. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  682. ":Setting up tx4927 pic.\n");
  683. TX4927_WR(0xff1ff604, 0x00000400); /* irq trigger */
  684. TX4927_WR(0xff1ff608, 0x00000000); /* irq trigger */
  685. /* setup serial stuff */
  686. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  687. ":Setting up tx4927 sio.\n");
  688. TX4927_WR(0xff1ff314, 0x00000000); /* h/w flow control off */
  689. TX4927_WR(0xff1ff414, 0x00000000); /* h/w flow control off */
  690. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  691. "+\n");
  692. set_io_port_base(KSEG1 + TBTX4927_ISA_IO_OFFSET);
  693. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  694. ":mips_io_port_base=0x%08lx\n",
  695. mips_io_port_base);
  696. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  697. ":Resource\n");
  698. ioport_resource.end = 0xffffffff;
  699. iomem_resource.end = 0xffffffff;
  700. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  701. ":ResetRoutines\n");
  702. _machine_restart = toshiba_rbtx4927_restart;
  703. _machine_halt = toshiba_rbtx4927_halt;
  704. _machine_power_off = toshiba_rbtx4927_power_off;
  705. #ifdef CONFIG_PCI
  706. /* PCIC */
  707. /*
  708. * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
  709. * PCIDIVMODE[12:11]'s initial value are given by S9[4:3] (ON:0, OFF:1).
  710. * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
  711. * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
  712. * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
  713. * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
  714. * i.e. S9[3]: ON (83MHz), OFF (100MHz)
  715. */
  716. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
  717. "ccfg is %lx, DIV is %x\n",
  718. (unsigned long) tx4927_ccfgptr->
  719. ccfg, TX4927_CCFG_PCIDIVMODE_MASK);
  720. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
  721. "PCI66 mode is %lx, PCI mode is %lx, pci arb is %lx\n",
  722. (unsigned long) tx4927_ccfgptr->
  723. ccfg & TX4927_CCFG_PCI66,
  724. (unsigned long) tx4927_ccfgptr->
  725. ccfg & TX4927_CCFG_PCIMIDE,
  726. (unsigned long) tx4927_ccfgptr->
  727. ccfg & TX4927_CCFG_PCIXARB);
  728. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
  729. "PCIDIVMODE is %lx\n",
  730. (unsigned long) tx4927_ccfgptr->
  731. ccfg & TX4927_CCFG_PCIDIVMODE_MASK);
  732. switch ((unsigned long) tx4927_ccfgptr->
  733. ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
  734. case TX4927_CCFG_PCIDIVMODE_2_5:
  735. case TX4927_CCFG_PCIDIVMODE_5:
  736. tx4927_cpu_clock = 166000000; /* 166MHz */
  737. break;
  738. default:
  739. tx4927_cpu_clock = 200000000; /* 200MHz */
  740. }
  741. /* CCFG */
  742. /* enable Timeout BusError */
  743. if (tx4927_ccfg_toeon)
  744. tx4927_ccfgptr->ccfg |= TX4927_CCFG_TOE;
  745. /* SDRAMC fixup */
  746. #ifdef CONFIG_TX4927BUG_WORKAROUND
  747. /*
  748. * TX4927-BUG: INF 01-01-18/ BUG 01-01-22
  749. * G-bus timeout error detection is incorrect
  750. */
  751. if (tx4927_ccfg_toeon)
  752. tx4927_sdramcptr->tr |= 0x02000000; /* RCD:3tck */
  753. #endif
  754. tx4927_pci_setup();
  755. if (tx4927_using_backplane == 1)
  756. printk("backplane board IS installed\n");
  757. else
  758. printk("No Backplane \n");
  759. /* this is on ISA bus behind PCI bus, so need PCI up first */
  760. #ifdef CONFIG_TOSHIBA_FPCIB0
  761. {
  762. if (tx4927_using_backplane) {
  763. TOSHIBA_RBTX4927_SETUP_DPRINTK
  764. (TOSHIBA_RBTX4927_SETUP_SETUP,
  765. ":fpcibo=yes\n");
  766. TOSHIBA_RBTX4927_SETUP_DPRINTK
  767. (TOSHIBA_RBTX4927_SETUP_SETUP,
  768. ":smsc_fdc37m81x_init()\n");
  769. smsc_fdc37m81x_init(0x3f0);
  770. TOSHIBA_RBTX4927_SETUP_DPRINTK
  771. (TOSHIBA_RBTX4927_SETUP_SETUP,
  772. ":smsc_fdc37m81x_config_beg()\n");
  773. smsc_fdc37m81x_config_beg();
  774. TOSHIBA_RBTX4927_SETUP_DPRINTK
  775. (TOSHIBA_RBTX4927_SETUP_SETUP,
  776. ":smsc_fdc37m81x_config_set(KBD)\n");
  777. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM,
  778. SMSC_FDC37M81X_KBD);
  779. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT, 1);
  780. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2, 12);
  781. smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE,
  782. 1);
  783. smsc_fdc37m81x_config_end();
  784. TOSHIBA_RBTX4927_SETUP_DPRINTK
  785. (TOSHIBA_RBTX4927_SETUP_SETUP,
  786. ":smsc_fdc37m81x_config_end()\n");
  787. } else {
  788. TOSHIBA_RBTX4927_SETUP_DPRINTK
  789. (TOSHIBA_RBTX4927_SETUP_SETUP,
  790. ":fpcibo=not_found\n");
  791. }
  792. }
  793. #else
  794. {
  795. TOSHIBA_RBTX4927_SETUP_DPRINTK
  796. (TOSHIBA_RBTX4927_SETUP_SETUP, ":fpcibo=no\n");
  797. }
  798. #endif
  799. #endif /* CONFIG_PCI */
  800. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  801. argptr = prom_getcmdline();
  802. if (strstr(argptr, "console=") == NULL) {
  803. strcat(argptr, " console=ttyS0,38400");
  804. }
  805. #endif
  806. #ifdef CONFIG_ROOT_NFS
  807. argptr = prom_getcmdline();
  808. if (strstr(argptr, "root=") == NULL) {
  809. strcat(argptr, " root=/dev/nfs rw");
  810. }
  811. #endif
  812. #ifdef CONFIG_IP_PNP
  813. argptr = prom_getcmdline();
  814. if (strstr(argptr, "ip=") == NULL) {
  815. strcat(argptr, " ip=any");
  816. }
  817. #endif
  818. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
  819. "+\n");
  820. }
  821. #ifdef CONFIG_RTC_DS1742
  822. extern unsigned long rtc_ds1742_get_time(void);
  823. extern int rtc_ds1742_set_time(unsigned long);
  824. extern void rtc_ds1742_wait(void);
  825. #endif
  826. void __init
  827. toshiba_rbtx4927_time_init(void)
  828. {
  829. u32 c1;
  830. u32 c2;
  831. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, "-\n");
  832. #ifdef CONFIG_RTC_DS1742
  833. rtc_get_time = rtc_ds1742_get_time;
  834. rtc_set_time = rtc_ds1742_set_time;
  835. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  836. ":rtc_ds1742_init()-\n");
  837. rtc_ds1742_init(0xbc010000);
  838. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  839. ":rtc_ds1742_init()+\n");
  840. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  841. ":Calibrate mips_hpt_frequency-\n");
  842. rtc_ds1742_wait();
  843. /* get the count */
  844. c1 = read_c0_count();
  845. /* wait for the seconds to change again */
  846. rtc_ds1742_wait();
  847. /* get the count again */
  848. c2 = read_c0_count();
  849. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  850. ":Calibrate mips_hpt_frequency+\n");
  851. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  852. ":c1=%12u\n", c1);
  853. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  854. ":c2=%12u\n", c2);
  855. /* this diff is as close as we are going to get to counter ticks per sec */
  856. mips_hpt_frequency = abs(c2 - c1);
  857. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  858. ":f1=%12u\n", mips_hpt_frequency);
  859. /* round to 1/10th of a MHz */
  860. mips_hpt_frequency /= (100 * 1000);
  861. mips_hpt_frequency *= (100 * 1000);
  862. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT,
  863. ":f2=%12u\n", mips_hpt_frequency);
  864. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_INFO,
  865. ":mips_hpt_frequency=%uHz (%uMHz)\n",
  866. mips_hpt_frequency,
  867. mips_hpt_frequency / 1000000);
  868. #else
  869. mips_hpt_frequency = 100000000;
  870. #endif
  871. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIME_INIT, "+\n");
  872. }
  873. void __init toshiba_rbtx4927_timer_setup(struct irqaction *irq)
  874. {
  875. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIMER_SETUP,
  876. "-\n");
  877. TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_TIMER_SETUP,
  878. "+\n");
  879. }