setup.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. /*
  2. * linux/arch/mips/tx4938/toshiba_rbtx4938/setup.c
  3. *
  4. * Setup pointers to hardware-dependent routines.
  5. * Copyright (C) 2000-2001 Toshiba Corporation
  6. *
  7. * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
  8. * terms of the GNU General Public License version 2. This program is
  9. * licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. *
  12. * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
  13. */
  14. #include <linux/config.h>
  15. #include <linux/init.h>
  16. #include <linux/types.h>
  17. #include <linux/ioport.h>
  18. #include <linux/proc_fs.h>
  19. #include <linux/delay.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/console.h>
  22. #include <linux/pci.h>
  23. #include <linux/pm.h>
  24. #include <asm/wbflush.h>
  25. #include <asm/reboot.h>
  26. #include <asm/irq.h>
  27. #include <asm/time.h>
  28. #include <asm/uaccess.h>
  29. #include <asm/io.h>
  30. #include <asm/bootinfo.h>
  31. #include <asm/tx4938/rbtx4938.h>
  32. #ifdef CONFIG_SERIAL_TXX9
  33. #include <linux/tty.h>
  34. #include <linux/serial.h>
  35. #include <linux/serial_core.h>
  36. #endif
  37. extern void rbtx4938_time_init(void) __init;
  38. extern char * __init prom_getcmdline(void);
  39. static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr);
  40. /* These functions are used for rebooting or halting the machine*/
  41. extern void rbtx4938_machine_restart(char *command);
  42. extern void rbtx4938_machine_halt(void);
  43. extern void rbtx4938_machine_power_off(void);
  44. /* clocks */
  45. unsigned int txx9_master_clock;
  46. unsigned int txx9_cpu_clock;
  47. unsigned int txx9_gbus_clock;
  48. unsigned long rbtx4938_ce_base[8];
  49. unsigned long rbtx4938_ce_size[8];
  50. int txboard_pci66_mode;
  51. static int tx4938_pcic_trdyto; /* default: disabled */
  52. static int tx4938_pcic_retryto; /* default: disabled */
  53. static int tx4938_ccfg_toeon = 1;
  54. struct tx4938_pcic_reg *pcicptrs[4] = {
  55. tx4938_pcicptr /* default setting for TX4938 */
  56. };
  57. static struct {
  58. unsigned long base;
  59. unsigned long size;
  60. } phys_regions[16] __initdata;
  61. static int num_phys_regions __initdata;
  62. #define PHYS_REGION_MINSIZE 0x10000
  63. void rbtx4938_machine_halt(void)
  64. {
  65. printk(KERN_NOTICE "System Halted\n");
  66. local_irq_disable();
  67. while (1)
  68. __asm__(".set\tmips3\n\t"
  69. "wait\n\t"
  70. ".set\tmips0");
  71. }
  72. void rbtx4938_machine_power_off(void)
  73. {
  74. rbtx4938_machine_halt();
  75. /* no return */
  76. }
  77. void rbtx4938_machine_restart(char *command)
  78. {
  79. local_irq_disable();
  80. printk("Rebooting...");
  81. *rbtx4938_softresetlock_ptr = 1;
  82. *rbtx4938_sfvol_ptr = 1;
  83. *rbtx4938_softreset_ptr = 1;
  84. wbflush();
  85. while(1);
  86. }
  87. void __init
  88. txboard_add_phys_region(unsigned long base, unsigned long size)
  89. {
  90. if (num_phys_regions >= ARRAY_SIZE(phys_regions)) {
  91. printk("phys_region overflow\n");
  92. return;
  93. }
  94. phys_regions[num_phys_regions].base = base;
  95. phys_regions[num_phys_regions].size = size;
  96. num_phys_regions++;
  97. }
  98. unsigned long __init
  99. txboard_find_free_phys_region(unsigned long begin, unsigned long end,
  100. unsigned long size)
  101. {
  102. unsigned long base;
  103. int i;
  104. for (base = begin / size * size; base < end; base += size) {
  105. for (i = 0; i < num_phys_regions; i++) {
  106. if (phys_regions[i].size &&
  107. base <= phys_regions[i].base + (phys_regions[i].size - 1) &&
  108. base + (size - 1) >= phys_regions[i].base)
  109. break;
  110. }
  111. if (i == num_phys_regions)
  112. return base;
  113. }
  114. return 0;
  115. }
  116. unsigned long __init
  117. txboard_find_free_phys_region_shrink(unsigned long begin, unsigned long end,
  118. unsigned long *size)
  119. {
  120. unsigned long sz, base;
  121. for (sz = *size; sz >= PHYS_REGION_MINSIZE; sz /= 2) {
  122. base = txboard_find_free_phys_region(begin, end, sz);
  123. if (base) {
  124. *size = sz;
  125. return base;
  126. }
  127. }
  128. return 0;
  129. }
  130. unsigned long __init
  131. txboard_request_phys_region_range(unsigned long begin, unsigned long end,
  132. unsigned long size)
  133. {
  134. unsigned long base;
  135. base = txboard_find_free_phys_region(begin, end, size);
  136. if (base)
  137. txboard_add_phys_region(base, size);
  138. return base;
  139. }
  140. unsigned long __init
  141. txboard_request_phys_region(unsigned long size)
  142. {
  143. unsigned long base;
  144. unsigned long begin = 0, end = 0x20000000; /* search low 512MB */
  145. base = txboard_find_free_phys_region(begin, end, size);
  146. if (base)
  147. txboard_add_phys_region(base, size);
  148. return base;
  149. }
  150. unsigned long __init
  151. txboard_request_phys_region_shrink(unsigned long *size)
  152. {
  153. unsigned long base;
  154. unsigned long begin = 0, end = 0x20000000; /* search low 512MB */
  155. base = txboard_find_free_phys_region_shrink(begin, end, size);
  156. if (base)
  157. txboard_add_phys_region(base, *size);
  158. return base;
  159. }
  160. #ifdef CONFIG_PCI
  161. void __init
  162. tx4938_pcic_setup(struct tx4938_pcic_reg *pcicptr,
  163. struct pci_controller *channel,
  164. unsigned long pci_io_base,
  165. int extarb)
  166. {
  167. int i;
  168. /* Disable All Initiator Space */
  169. pcicptr->pciccfg &= ~(TX4938_PCIC_PCICCFG_G2PMEN(0)|
  170. TX4938_PCIC_PCICCFG_G2PMEN(1)|
  171. TX4938_PCIC_PCICCFG_G2PMEN(2)|
  172. TX4938_PCIC_PCICCFG_G2PIOEN);
  173. /* GB->PCI mappings */
  174. pcicptr->g2piomask = (channel->io_resource->end - channel->io_resource->start) >> 4;
  175. pcicptr->g2piogbase = pci_io_base |
  176. #ifdef __BIG_ENDIAN
  177. TX4938_PCIC_G2PIOGBASE_ECHG
  178. #else
  179. TX4938_PCIC_G2PIOGBASE_BSDIS
  180. #endif
  181. ;
  182. pcicptr->g2piopbase = 0;
  183. for (i = 0; i < 3; i++) {
  184. pcicptr->g2pmmask[i] = 0;
  185. pcicptr->g2pmgbase[i] = 0;
  186. pcicptr->g2pmpbase[i] = 0;
  187. }
  188. if (channel->mem_resource->end) {
  189. pcicptr->g2pmmask[0] = (channel->mem_resource->end - channel->mem_resource->start) >> 4;
  190. pcicptr->g2pmgbase[0] = channel->mem_resource->start |
  191. #ifdef __BIG_ENDIAN
  192. TX4938_PCIC_G2PMnGBASE_ECHG
  193. #else
  194. TX4938_PCIC_G2PMnGBASE_BSDIS
  195. #endif
  196. ;
  197. pcicptr->g2pmpbase[0] = channel->mem_resource->start;
  198. }
  199. /* PCI->GB mappings (I/O 256B) */
  200. pcicptr->p2giopbase = 0; /* 256B */
  201. pcicptr->p2giogbase = 0;
  202. /* PCI->GB mappings (MEM 512MB (64MB on R1.x)) */
  203. pcicptr->p2gm0plbase = 0;
  204. pcicptr->p2gm0pubase = 0;
  205. pcicptr->p2gmgbase[0] = 0 |
  206. TX4938_PCIC_P2GMnGBASE_TMEMEN |
  207. #ifdef __BIG_ENDIAN
  208. TX4938_PCIC_P2GMnGBASE_TECHG
  209. #else
  210. TX4938_PCIC_P2GMnGBASE_TBSDIS
  211. #endif
  212. ;
  213. /* PCI->GB mappings (MEM 16MB) */
  214. pcicptr->p2gm1plbase = 0xffffffff;
  215. pcicptr->p2gm1pubase = 0xffffffff;
  216. pcicptr->p2gmgbase[1] = 0;
  217. /* PCI->GB mappings (MEM 1MB) */
  218. pcicptr->p2gm2pbase = 0xffffffff; /* 1MB */
  219. pcicptr->p2gmgbase[2] = 0;
  220. pcicptr->pciccfg &= TX4938_PCIC_PCICCFG_GBWC_MASK;
  221. /* Enable Initiator Memory Space */
  222. if (channel->mem_resource->end)
  223. pcicptr->pciccfg |= TX4938_PCIC_PCICCFG_G2PMEN(0);
  224. /* Enable Initiator I/O Space */
  225. if (channel->io_resource->end)
  226. pcicptr->pciccfg |= TX4938_PCIC_PCICCFG_G2PIOEN;
  227. /* Enable Initiator Config */
  228. pcicptr->pciccfg |=
  229. TX4938_PCIC_PCICCFG_ICAEN |
  230. TX4938_PCIC_PCICCFG_TCAR;
  231. /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
  232. pcicptr->pcicfg1 = 0;
  233. pcicptr->g2ptocnt &= ~0xffff;
  234. if (tx4938_pcic_trdyto >= 0) {
  235. pcicptr->g2ptocnt &= ~0xff;
  236. pcicptr->g2ptocnt |= (tx4938_pcic_trdyto & 0xff);
  237. }
  238. if (tx4938_pcic_retryto >= 0) {
  239. pcicptr->g2ptocnt &= ~0xff00;
  240. pcicptr->g2ptocnt |= ((tx4938_pcic_retryto<<8) & 0xff00);
  241. }
  242. /* Clear All Local Bus Status */
  243. pcicptr->pcicstatus = TX4938_PCIC_PCICSTATUS_ALL;
  244. /* Enable All Local Bus Interrupts */
  245. pcicptr->pcicmask = TX4938_PCIC_PCICSTATUS_ALL;
  246. /* Clear All Initiator Status */
  247. pcicptr->g2pstatus = TX4938_PCIC_G2PSTATUS_ALL;
  248. /* Enable All Initiator Interrupts */
  249. pcicptr->g2pmask = TX4938_PCIC_G2PSTATUS_ALL;
  250. /* Clear All PCI Status Error */
  251. pcicptr->pcistatus =
  252. (pcicptr->pcistatus & 0x0000ffff) |
  253. (TX4938_PCIC_PCISTATUS_ALL << 16);
  254. /* Enable All PCI Status Error Interrupts */
  255. pcicptr->pcimask = TX4938_PCIC_PCISTATUS_ALL;
  256. if (!extarb) {
  257. /* Reset Bus Arbiter */
  258. pcicptr->pbacfg = TX4938_PCIC_PBACFG_RPBA;
  259. pcicptr->pbabm = 0;
  260. /* Enable Bus Arbiter */
  261. pcicptr->pbacfg = TX4938_PCIC_PBACFG_PBAEN;
  262. }
  263. /* PCIC Int => IRC IRQ16 */
  264. pcicptr->pcicfg2 =
  265. (pcicptr->pcicfg2 & 0xffffff00) | TX4938_IR_PCIC;
  266. pcicptr->pcistatus = PCI_COMMAND_MASTER |
  267. PCI_COMMAND_MEMORY |
  268. PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
  269. }
  270. int __init
  271. tx4938_report_pciclk(void)
  272. {
  273. unsigned long pcode = TX4938_REV_PCODE();
  274. int pciclk = 0;
  275. printk("TX%lx PCIC --%s PCICLK:",
  276. pcode,
  277. (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI66) ? " PCI66" : "");
  278. if (tx4938_ccfgptr->pcfg & TX4938_PCFG_PCICLKEN_ALL) {
  279. switch ((unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIDIVMODE_MASK) {
  280. case TX4938_CCFG_PCIDIVMODE_4:
  281. pciclk = txx9_cpu_clock / 4; break;
  282. case TX4938_CCFG_PCIDIVMODE_4_5:
  283. pciclk = txx9_cpu_clock * 2 / 9; break;
  284. case TX4938_CCFG_PCIDIVMODE_5:
  285. pciclk = txx9_cpu_clock / 5; break;
  286. case TX4938_CCFG_PCIDIVMODE_5_5:
  287. pciclk = txx9_cpu_clock * 2 / 11; break;
  288. case TX4938_CCFG_PCIDIVMODE_8:
  289. pciclk = txx9_cpu_clock / 8; break;
  290. case TX4938_CCFG_PCIDIVMODE_9:
  291. pciclk = txx9_cpu_clock / 9; break;
  292. case TX4938_CCFG_PCIDIVMODE_10:
  293. pciclk = txx9_cpu_clock / 10; break;
  294. case TX4938_CCFG_PCIDIVMODE_11:
  295. pciclk = txx9_cpu_clock / 11; break;
  296. }
  297. printk("Internal(%dMHz)", pciclk / 1000000);
  298. } else {
  299. printk("External");
  300. pciclk = -1;
  301. }
  302. printk("\n");
  303. return pciclk;
  304. }
  305. void __init set_tx4938_pcicptr(int ch, struct tx4938_pcic_reg *pcicptr)
  306. {
  307. pcicptrs[ch] = pcicptr;
  308. }
  309. struct tx4938_pcic_reg *get_tx4938_pcicptr(int ch)
  310. {
  311. return pcicptrs[ch];
  312. }
  313. static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
  314. int top_bus, int busnr, int devfn)
  315. {
  316. static struct pci_dev dev;
  317. static struct pci_bus bus;
  318. dev.sysdata = (void *)hose;
  319. dev.devfn = devfn;
  320. bus.number = busnr;
  321. bus.ops = hose->pci_ops;
  322. bus.parent = NULL;
  323. dev.bus = &bus;
  324. return &dev;
  325. }
  326. #define EARLY_PCI_OP(rw, size, type) \
  327. static int early_##rw##_config_##size(struct pci_controller *hose, \
  328. int top_bus, int bus, int devfn, int offset, type value) \
  329. { \
  330. return pci_##rw##_config_##size( \
  331. fake_pci_dev(hose, top_bus, bus, devfn), \
  332. offset, value); \
  333. }
  334. EARLY_PCI_OP(read, word, u16 *)
  335. int txboard_pci66_check(struct pci_controller *hose, int top_bus, int current_bus)
  336. {
  337. u32 pci_devfn;
  338. unsigned short vid;
  339. int devfn_start = 0;
  340. int devfn_stop = 0xff;
  341. int cap66 = -1;
  342. u16 stat;
  343. printk("PCI: Checking 66MHz capabilities...\n");
  344. for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
  345. early_read_config_word(hose, top_bus, current_bus, pci_devfn,
  346. PCI_VENDOR_ID, &vid);
  347. if (vid == 0xffff) continue;
  348. /* check 66MHz capability */
  349. if (cap66 < 0)
  350. cap66 = 1;
  351. if (cap66) {
  352. early_read_config_word(hose, top_bus, current_bus, pci_devfn,
  353. PCI_STATUS, &stat);
  354. if (!(stat & PCI_STATUS_66MHZ)) {
  355. printk(KERN_DEBUG "PCI: %02x:%02x not 66MHz capable.\n",
  356. current_bus, pci_devfn);
  357. cap66 = 0;
  358. break;
  359. }
  360. }
  361. }
  362. return cap66 > 0;
  363. }
  364. int __init
  365. tx4938_pciclk66_setup(void)
  366. {
  367. int pciclk;
  368. /* Assert M66EN */
  369. tx4938_ccfgptr->ccfg |= TX4938_CCFG_PCI66;
  370. /* Double PCICLK (if possible) */
  371. if (tx4938_ccfgptr->pcfg & TX4938_PCFG_PCICLKEN_ALL) {
  372. unsigned int pcidivmode =
  373. tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIDIVMODE_MASK;
  374. switch (pcidivmode) {
  375. case TX4938_CCFG_PCIDIVMODE_8:
  376. case TX4938_CCFG_PCIDIVMODE_4:
  377. pcidivmode = TX4938_CCFG_PCIDIVMODE_4;
  378. pciclk = txx9_cpu_clock / 4;
  379. break;
  380. case TX4938_CCFG_PCIDIVMODE_9:
  381. case TX4938_CCFG_PCIDIVMODE_4_5:
  382. pcidivmode = TX4938_CCFG_PCIDIVMODE_4_5;
  383. pciclk = txx9_cpu_clock * 2 / 9;
  384. break;
  385. case TX4938_CCFG_PCIDIVMODE_10:
  386. case TX4938_CCFG_PCIDIVMODE_5:
  387. pcidivmode = TX4938_CCFG_PCIDIVMODE_5;
  388. pciclk = txx9_cpu_clock / 5;
  389. break;
  390. case TX4938_CCFG_PCIDIVMODE_11:
  391. case TX4938_CCFG_PCIDIVMODE_5_5:
  392. default:
  393. pcidivmode = TX4938_CCFG_PCIDIVMODE_5_5;
  394. pciclk = txx9_cpu_clock * 2 / 11;
  395. break;
  396. }
  397. tx4938_ccfgptr->ccfg =
  398. (tx4938_ccfgptr->ccfg & ~TX4938_CCFG_PCIDIVMODE_MASK)
  399. | pcidivmode;
  400. printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
  401. (unsigned long)tx4938_ccfgptr->ccfg);
  402. } else {
  403. pciclk = -1;
  404. }
  405. return pciclk;
  406. }
  407. extern struct pci_controller tx4938_pci_controller[];
  408. static int __init tx4938_pcibios_init(void)
  409. {
  410. unsigned long mem_base[2];
  411. unsigned long mem_size[2] = {TX4938_PCIMEM_SIZE_0,TX4938_PCIMEM_SIZE_1}; /* MAX 128M,64K */
  412. unsigned long io_base[2];
  413. unsigned long io_size[2] = {TX4938_PCIIO_SIZE_0,TX4938_PCIIO_SIZE_1}; /* MAX 16M,64K */
  414. /* TX4938 PCIC1: 64K MEM/IO is enough for ETH0,ETH1 */
  415. int extarb = !(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIXARB);
  416. PCIBIOS_MIN_IO = 0x00001000UL;
  417. PCIBIOS_MIN_MEM = 0x01000000UL;
  418. mem_base[0] = txboard_request_phys_region_shrink(&mem_size[0]);
  419. io_base[0] = txboard_request_phys_region_shrink(&io_size[0]);
  420. printk("TX4938 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
  421. (unsigned short)(tx4938_pcicptr->pciid >> 16),
  422. (unsigned short)(tx4938_pcicptr->pciid & 0xffff),
  423. (unsigned short)(tx4938_pcicptr->pciccrev & 0xff),
  424. extarb ? "External" : "Internal");
  425. /* setup PCI area */
  426. tx4938_pci_controller[0].io_resource->start = io_base[0];
  427. tx4938_pci_controller[0].io_resource->end = (io_base[0] + io_size[0]) - 1;
  428. tx4938_pci_controller[0].mem_resource->start = mem_base[0];
  429. tx4938_pci_controller[0].mem_resource->end = mem_base[0] + mem_size[0] - 1;
  430. set_tx4938_pcicptr(0, tx4938_pcicptr);
  431. register_pci_controller(&tx4938_pci_controller[0]);
  432. if (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI66) {
  433. printk("TX4938_CCFG_PCI66 already configured\n");
  434. txboard_pci66_mode = -1; /* already configured */
  435. }
  436. /* Reset PCI Bus */
  437. *rbtx4938_pcireset_ptr = 0;
  438. /* Reset PCIC */
  439. tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST;
  440. if (txboard_pci66_mode > 0)
  441. tx4938_pciclk66_setup();
  442. mdelay(10);
  443. /* clear PCIC reset */
  444. tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST;
  445. *rbtx4938_pcireset_ptr = 1;
  446. wbflush();
  447. tx4938_report_pcic_status1(tx4938_pcicptr);
  448. tx4938_report_pciclk();
  449. tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb);
  450. if (txboard_pci66_mode == 0 &&
  451. txboard_pci66_check(&tx4938_pci_controller[0], 0, 0)) {
  452. /* Reset PCI Bus */
  453. *rbtx4938_pcireset_ptr = 0;
  454. /* Reset PCIC */
  455. tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST;
  456. tx4938_pciclk66_setup();
  457. mdelay(10);
  458. /* clear PCIC reset */
  459. tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST;
  460. *rbtx4938_pcireset_ptr = 1;
  461. wbflush();
  462. /* Reinitialize PCIC */
  463. tx4938_report_pciclk();
  464. tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb);
  465. }
  466. mem_base[1] = txboard_request_phys_region_shrink(&mem_size[1]);
  467. io_base[1] = txboard_request_phys_region_shrink(&io_size[1]);
  468. /* Reset PCIC1 */
  469. tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIC1RST;
  470. /* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */
  471. if (!(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1DMD))
  472. tx4938_ccfgptr->ccfg |= TX4938_CCFG_PCI1_66;
  473. else
  474. tx4938_ccfgptr->ccfg &= ~TX4938_CCFG_PCI1_66;
  475. mdelay(10);
  476. /* clear PCIC1 reset */
  477. tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIC1RST;
  478. tx4938_report_pcic_status1(tx4938_pcic1ptr);
  479. printk("TX4938 PCIC1 -- DID:%04x VID:%04x RID:%02x",
  480. (unsigned short)(tx4938_pcic1ptr->pciid >> 16),
  481. (unsigned short)(tx4938_pcic1ptr->pciid & 0xffff),
  482. (unsigned short)(tx4938_pcic1ptr->pciccrev & 0xff));
  483. printk("%s PCICLK:%dMHz\n",
  484. (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1_66) ? " PCI66" : "",
  485. txx9_gbus_clock /
  486. ((tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1DMD) ? 4 : 2) /
  487. 1000000);
  488. /* assumption: CPHYSADDR(mips_io_port_base) == io_base[0] */
  489. tx4938_pci_controller[1].io_resource->start =
  490. io_base[1] - io_base[0];
  491. tx4938_pci_controller[1].io_resource->end =
  492. io_base[1] - io_base[0] + io_size[1] - 1;
  493. tx4938_pci_controller[1].mem_resource->start = mem_base[1];
  494. tx4938_pci_controller[1].mem_resource->end =
  495. mem_base[1] + mem_size[1] - 1;
  496. set_tx4938_pcicptr(1, tx4938_pcic1ptr);
  497. register_pci_controller(&tx4938_pci_controller[1]);
  498. tx4938_pcic_setup(tx4938_pcic1ptr, &tx4938_pci_controller[1], io_base[1], extarb);
  499. /* map ioport 0 to PCI I/O space address 0 */
  500. set_io_port_base(KSEG1 + io_base[0]);
  501. return 0;
  502. }
  503. arch_initcall(tx4938_pcibios_init);
  504. #endif /* CONFIG_PCI */
  505. /* SPI support */
  506. /* chip select for SPI devices */
  507. #define SEEPROM1_CS 7 /* PIO7 */
  508. #define SEEPROM2_CS 0 /* IOC */
  509. #define SEEPROM3_CS 1 /* IOC */
  510. #define SRTC_CS 2 /* IOC */
  511. static int rbtx4938_spi_cs_func(int chipid, int on)
  512. {
  513. unsigned char bit;
  514. switch (chipid) {
  515. case RBTX4938_SEEPROM1_CHIPID:
  516. if (on)
  517. tx4938_pioptr->dout &= ~(1 << SEEPROM1_CS);
  518. else
  519. tx4938_pioptr->dout |= (1 << SEEPROM1_CS);
  520. return 0;
  521. break;
  522. case RBTX4938_SEEPROM2_CHIPID:
  523. bit = (1 << SEEPROM2_CS);
  524. break;
  525. case RBTX4938_SEEPROM3_CHIPID:
  526. bit = (1 << SEEPROM3_CS);
  527. break;
  528. case RBTX4938_SRTC_CHIPID:
  529. bit = (1 << SRTC_CS);
  530. break;
  531. default:
  532. return -ENODEV;
  533. }
  534. /* bit1,2,4 are low active, bit3 is high active */
  535. *rbtx4938_spics_ptr =
  536. (*rbtx4938_spics_ptr & ~bit) |
  537. ((on ? (bit ^ 0x0b) : ~(bit ^ 0x0b)) & bit);
  538. return 0;
  539. }
  540. #ifdef CONFIG_PCI
  541. extern int spi_eeprom_read(int chipid, int address, unsigned char *buf, int len);
  542. int rbtx4938_get_tx4938_ethaddr(struct pci_dev *dev, unsigned char *addr)
  543. {
  544. struct pci_controller *channel = (struct pci_controller *)dev->bus->sysdata;
  545. static unsigned char dat[17];
  546. static int read_dat = 0;
  547. int ch = 0;
  548. if (channel != &tx4938_pci_controller[1])
  549. return -ENODEV;
  550. /* TX4938 PCIC1 */
  551. switch (PCI_SLOT(dev->devfn)) {
  552. case TX4938_PCIC_IDSEL_AD_TO_SLOT(31):
  553. ch = 0;
  554. break;
  555. case TX4938_PCIC_IDSEL_AD_TO_SLOT(30):
  556. ch = 1;
  557. break;
  558. default:
  559. return -ENODEV;
  560. }
  561. if (!read_dat) {
  562. unsigned char sum;
  563. int i;
  564. read_dat = 1;
  565. /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */
  566. if (spi_eeprom_read(RBTX4938_SEEPROM1_CHIPID,
  567. 0, dat, sizeof(dat))) {
  568. printk(KERN_ERR "seeprom: read error.\n");
  569. } else {
  570. if (strcmp(dat, "MAC") != 0)
  571. printk(KERN_WARNING "seeprom: bad signature.\n");
  572. for (i = 0, sum = 0; i < sizeof(dat); i++)
  573. sum += dat[i];
  574. if (sum)
  575. printk(KERN_WARNING "seeprom: bad checksum.\n");
  576. }
  577. }
  578. memcpy(addr, &dat[4 + 6 * ch], 6);
  579. return 0;
  580. }
  581. #endif /* CONFIG_PCI */
  582. extern void __init txx9_spi_init(unsigned long base, int (*cs_func)(int chipid, int on));
  583. static void __init rbtx4938_spi_setup(void)
  584. {
  585. /* set SPI_SEL */
  586. tx4938_ccfgptr->pcfg |= TX4938_PCFG_SPI_SEL;
  587. /* chip selects for SPI devices */
  588. tx4938_pioptr->dout |= (1 << SEEPROM1_CS);
  589. tx4938_pioptr->dir |= (1 << SEEPROM1_CS);
  590. txx9_spi_init(TX4938_SPI_REG, rbtx4938_spi_cs_func);
  591. }
  592. static struct resource rbtx4938_fpga_resource;
  593. static char pcode_str[8];
  594. static struct resource tx4938_reg_resource = {
  595. .start = TX4938_REG_BASE,
  596. .end = TX4938_REG_BASE + TX4938_REG_SIZE,
  597. .name = pcode_str,
  598. .flags = IORESOURCE_MEM
  599. };
  600. void __init tx4938_board_setup(void)
  601. {
  602. int i;
  603. unsigned long divmode;
  604. int cpuclk = 0;
  605. unsigned long pcode = TX4938_REV_PCODE();
  606. ioport_resource.start = 0x1000;
  607. ioport_resource.end = 0xffffffff;
  608. iomem_resource.start = 0x1000;
  609. iomem_resource.end = 0xffffffff; /* expand to 4GB */
  610. sprintf(pcode_str, "TX%lx", pcode);
  611. /* SDRAMC,EBUSC are configured by PROM */
  612. for (i = 0; i < 8; i++) {
  613. if (!(tx4938_ebuscptr->cr[i] & 0x8))
  614. continue; /* disabled */
  615. rbtx4938_ce_base[i] = (unsigned long)TX4938_EBUSC_BA(i);
  616. txboard_add_phys_region(rbtx4938_ce_base[i], TX4938_EBUSC_SIZE(i));
  617. }
  618. /* clocks */
  619. if (txx9_master_clock) {
  620. /* calculate gbus_clock and cpu_clock from master_clock */
  621. divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;
  622. switch (divmode) {
  623. case TX4938_CCFG_DIVMODE_8:
  624. case TX4938_CCFG_DIVMODE_10:
  625. case TX4938_CCFG_DIVMODE_12:
  626. case TX4938_CCFG_DIVMODE_16:
  627. case TX4938_CCFG_DIVMODE_18:
  628. txx9_gbus_clock = txx9_master_clock * 4; break;
  629. default:
  630. txx9_gbus_clock = txx9_master_clock;
  631. }
  632. switch (divmode) {
  633. case TX4938_CCFG_DIVMODE_2:
  634. case TX4938_CCFG_DIVMODE_8:
  635. cpuclk = txx9_gbus_clock * 2; break;
  636. case TX4938_CCFG_DIVMODE_2_5:
  637. case TX4938_CCFG_DIVMODE_10:
  638. cpuclk = txx9_gbus_clock * 5 / 2; break;
  639. case TX4938_CCFG_DIVMODE_3:
  640. case TX4938_CCFG_DIVMODE_12:
  641. cpuclk = txx9_gbus_clock * 3; break;
  642. case TX4938_CCFG_DIVMODE_4:
  643. case TX4938_CCFG_DIVMODE_16:
  644. cpuclk = txx9_gbus_clock * 4; break;
  645. case TX4938_CCFG_DIVMODE_4_5:
  646. case TX4938_CCFG_DIVMODE_18:
  647. cpuclk = txx9_gbus_clock * 9 / 2; break;
  648. }
  649. txx9_cpu_clock = cpuclk;
  650. } else {
  651. if (txx9_cpu_clock == 0) {
  652. txx9_cpu_clock = 300000000; /* 300MHz */
  653. }
  654. /* calculate gbus_clock and master_clock from cpu_clock */
  655. cpuclk = txx9_cpu_clock;
  656. divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;
  657. switch (divmode) {
  658. case TX4938_CCFG_DIVMODE_2:
  659. case TX4938_CCFG_DIVMODE_8:
  660. txx9_gbus_clock = cpuclk / 2; break;
  661. case TX4938_CCFG_DIVMODE_2_5:
  662. case TX4938_CCFG_DIVMODE_10:
  663. txx9_gbus_clock = cpuclk * 2 / 5; break;
  664. case TX4938_CCFG_DIVMODE_3:
  665. case TX4938_CCFG_DIVMODE_12:
  666. txx9_gbus_clock = cpuclk / 3; break;
  667. case TX4938_CCFG_DIVMODE_4:
  668. case TX4938_CCFG_DIVMODE_16:
  669. txx9_gbus_clock = cpuclk / 4; break;
  670. case TX4938_CCFG_DIVMODE_4_5:
  671. case TX4938_CCFG_DIVMODE_18:
  672. txx9_gbus_clock = cpuclk * 2 / 9; break;
  673. }
  674. switch (divmode) {
  675. case TX4938_CCFG_DIVMODE_8:
  676. case TX4938_CCFG_DIVMODE_10:
  677. case TX4938_CCFG_DIVMODE_12:
  678. case TX4938_CCFG_DIVMODE_16:
  679. case TX4938_CCFG_DIVMODE_18:
  680. txx9_master_clock = txx9_gbus_clock / 4; break;
  681. default:
  682. txx9_master_clock = txx9_gbus_clock;
  683. }
  684. }
  685. /* change default value to udelay/mdelay take reasonable time */
  686. loops_per_jiffy = txx9_cpu_clock / HZ / 2;
  687. /* CCFG */
  688. /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */
  689. tx4938_ccfgptr->ccfg |= TX4938_CCFG_WDRST | TX4938_CCFG_BEOW;
  690. /* clear PCIC1 reset */
  691. if (tx4938_ccfgptr->clkctr & TX4938_CLKCTR_PCIC1RST)
  692. tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIC1RST;
  693. /* enable Timeout BusError */
  694. if (tx4938_ccfg_toeon)
  695. tx4938_ccfgptr->ccfg |= TX4938_CCFG_TOE;
  696. /* DMA selection */
  697. tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_DMASEL_ALL;
  698. /* Use external clock for external arbiter */
  699. if (!(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIXARB))
  700. tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_PCICLKEN_ALL;
  701. printk("%s -- %dMHz(M%dMHz) CRIR:%08lx CCFG:%Lx PCFG:%Lx\n",
  702. pcode_str,
  703. cpuclk / 1000000, txx9_master_clock / 1000000,
  704. (unsigned long)tx4938_ccfgptr->crir,
  705. tx4938_ccfgptr->ccfg,
  706. tx4938_ccfgptr->pcfg);
  707. printk("%s SDRAMC --", pcode_str);
  708. for (i = 0; i < 4; i++) {
  709. unsigned long long cr = tx4938_sdramcptr->cr[i];
  710. unsigned long ram_base, ram_size;
  711. if (!((unsigned long)cr & 0x00000400))
  712. continue; /* disabled */
  713. ram_base = (unsigned long)(cr >> 49) << 21;
  714. ram_size = ((unsigned long)(cr >> 33) + 1) << 21;
  715. if (ram_base >= 0x20000000)
  716. continue; /* high memory (ignore) */
  717. printk(" CR%d:%016Lx", i, cr);
  718. txboard_add_phys_region(ram_base, ram_size);
  719. }
  720. printk(" TR:%09Lx\n", tx4938_sdramcptr->tr);
  721. /* SRAM */
  722. if (pcode == 0x4938 && tx4938_sramcptr->cr & 1) {
  723. unsigned int size = 0x800;
  724. unsigned long base =
  725. (tx4938_sramcptr->cr >> (39-11)) & ~(size - 1);
  726. txboard_add_phys_region(base, size);
  727. }
  728. /* IRC */
  729. /* disable interrupt control */
  730. tx4938_ircptr->cer = 0;
  731. /* TMR */
  732. /* disable all timers */
  733. for (i = 0; i < TX4938_NR_TMR; i++) {
  734. tx4938_tmrptr(i)->tcr = 0x00000020;
  735. tx4938_tmrptr(i)->tisr = 0;
  736. tx4938_tmrptr(i)->cpra = 0xffffffff;
  737. tx4938_tmrptr(i)->itmr = 0;
  738. tx4938_tmrptr(i)->ccdr = 0;
  739. tx4938_tmrptr(i)->pgmr = 0;
  740. }
  741. /* enable DMA */
  742. TX4938_WR64(0xff1fb150, TX4938_DMA_MCR_MSTEN);
  743. TX4938_WR64(0xff1fb950, TX4938_DMA_MCR_MSTEN);
  744. /* PIO */
  745. tx4938_pioptr->maskcpu = 0;
  746. tx4938_pioptr->maskext = 0;
  747. /* TX4938 internal registers */
  748. if (request_resource(&iomem_resource, &tx4938_reg_resource))
  749. printk("request resource for internal registers failed\n");
  750. }
  751. #ifdef CONFIG_PCI
  752. static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr)
  753. {
  754. unsigned short pcistatus = (unsigned short)(pcicptr->pcistatus >> 16);
  755. unsigned long g2pstatus = pcicptr->g2pstatus;
  756. unsigned long pcicstatus = pcicptr->pcicstatus;
  757. static struct {
  758. unsigned long flag;
  759. const char *str;
  760. } pcistat_tbl[] = {
  761. { PCI_STATUS_DETECTED_PARITY, "DetectedParityError" },
  762. { PCI_STATUS_SIG_SYSTEM_ERROR, "SignaledSystemError" },
  763. { PCI_STATUS_REC_MASTER_ABORT, "ReceivedMasterAbort" },
  764. { PCI_STATUS_REC_TARGET_ABORT, "ReceivedTargetAbort" },
  765. { PCI_STATUS_SIG_TARGET_ABORT, "SignaledTargetAbort" },
  766. { PCI_STATUS_PARITY, "MasterParityError" },
  767. }, g2pstat_tbl[] = {
  768. { TX4938_PCIC_G2PSTATUS_TTOE, "TIOE" },
  769. { TX4938_PCIC_G2PSTATUS_RTOE, "RTOE" },
  770. }, pcicstat_tbl[] = {
  771. { TX4938_PCIC_PCICSTATUS_PME, "PME" },
  772. { TX4938_PCIC_PCICSTATUS_TLB, "TLB" },
  773. { TX4938_PCIC_PCICSTATUS_NIB, "NIB" },
  774. { TX4938_PCIC_PCICSTATUS_ZIB, "ZIB" },
  775. { TX4938_PCIC_PCICSTATUS_PERR, "PERR" },
  776. { TX4938_PCIC_PCICSTATUS_SERR, "SERR" },
  777. { TX4938_PCIC_PCICSTATUS_GBE, "GBE" },
  778. { TX4938_PCIC_PCICSTATUS_IWB, "IWB" },
  779. };
  780. int i;
  781. printk("pcistat:%04x(", pcistatus);
  782. for (i = 0; i < ARRAY_SIZE(pcistat_tbl); i++)
  783. if (pcistatus & pcistat_tbl[i].flag)
  784. printk("%s ", pcistat_tbl[i].str);
  785. printk("), g2pstatus:%08lx(", g2pstatus);
  786. for (i = 0; i < ARRAY_SIZE(g2pstat_tbl); i++)
  787. if (g2pstatus & g2pstat_tbl[i].flag)
  788. printk("%s ", g2pstat_tbl[i].str);
  789. printk("), pcicstatus:%08lx(", pcicstatus);
  790. for (i = 0; i < ARRAY_SIZE(pcicstat_tbl); i++)
  791. if (pcicstatus & pcicstat_tbl[i].flag)
  792. printk("%s ", pcicstat_tbl[i].str);
  793. printk(")\n");
  794. }
  795. void tx4938_report_pcic_status(void)
  796. {
  797. int i;
  798. struct tx4938_pcic_reg *pcicptr;
  799. for (i = 0; (pcicptr = get_tx4938_pcicptr(i)) != NULL; i++)
  800. tx4938_report_pcic_status1(pcicptr);
  801. }
  802. #endif /* CONFIG_PCI */
  803. /* We use onchip r4k counter or TMR timer as our system wide timer
  804. * interrupt running at 100HZ. */
  805. extern void __init rtc_rx5c348_init(int chipid);
  806. void __init rbtx4938_time_init(void)
  807. {
  808. rtc_rx5c348_init(RBTX4938_SRTC_CHIPID);
  809. mips_hpt_frequency = txx9_cpu_clock / 2;
  810. }
  811. void __init toshiba_rbtx4938_setup(void)
  812. {
  813. unsigned long long pcfg;
  814. char *argptr;
  815. iomem_resource.end = 0xffffffff; /* 4GB */
  816. if (txx9_master_clock == 0)
  817. txx9_master_clock = 25000000; /* 25MHz */
  818. tx4938_board_setup();
  819. /* setup irq stuff */
  820. TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM0), 0x00000000); /* irq trigger */
  821. TX4938_WR(TX4938_MKA(TX4938_IRC_IRDM1), 0x00000000); /* irq trigger */
  822. /* setup serial stuff */
  823. TX4938_WR(0xff1ff314, 0x00000000); /* h/w flow control off */
  824. TX4938_WR(0xff1ff414, 0x00000000); /* h/w flow control off */
  825. #ifndef CONFIG_PCI
  826. set_io_port_base(RBTX4938_ETHER_BASE);
  827. #endif
  828. #ifdef CONFIG_SERIAL_TXX9
  829. {
  830. extern int early_serial_txx9_setup(struct uart_port *port);
  831. int i;
  832. struct uart_port req;
  833. for(i = 0; i < 2; i++) {
  834. memset(&req, 0, sizeof(req));
  835. req.line = i;
  836. req.iotype = UPIO_MEM;
  837. req.membase = (char *)(0xff1ff300 + i * 0x100);
  838. req.mapbase = 0xff1ff300 + i * 0x100;
  839. req.irq = 32 + i;
  840. req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
  841. req.uartclk = 50000000;
  842. early_serial_txx9_setup(&req);
  843. }
  844. }
  845. #ifdef CONFIG_SERIAL_TXX9_CONSOLE
  846. argptr = prom_getcmdline();
  847. if (strstr(argptr, "console=") == NULL) {
  848. strcat(argptr, " console=ttyS0,38400");
  849. }
  850. #endif
  851. #endif
  852. #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
  853. printk("PIOSEL: disabling both ata and nand selection\n");
  854. local_irq_disable();
  855. tx4938_ccfgptr->pcfg &= ~(TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL);
  856. #endif
  857. #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND
  858. printk("PIOSEL: enabling nand selection\n");
  859. tx4938_ccfgptr->pcfg |= TX4938_PCFG_NDF_SEL;
  860. tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_ATA_SEL;
  861. #endif
  862. #ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA
  863. printk("PIOSEL: enabling ata selection\n");
  864. tx4938_ccfgptr->pcfg |= TX4938_PCFG_ATA_SEL;
  865. tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_NDF_SEL;
  866. #endif
  867. #ifdef CONFIG_IP_PNP
  868. argptr = prom_getcmdline();
  869. if (strstr(argptr, "ip=") == NULL) {
  870. strcat(argptr, " ip=any");
  871. }
  872. #endif
  873. #ifdef CONFIG_FB
  874. {
  875. conswitchp = &dummy_con;
  876. }
  877. #endif
  878. rbtx4938_spi_setup();
  879. pcfg = tx4938_ccfgptr->pcfg; /* updated */
  880. /* fixup piosel */
  881. if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
  882. TX4938_PCFG_ATA_SEL) {
  883. *rbtx4938_piosel_ptr = (*rbtx4938_piosel_ptr & 0x03) | 0x04;
  884. }
  885. else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
  886. TX4938_PCFG_NDF_SEL) {
  887. *rbtx4938_piosel_ptr = (*rbtx4938_piosel_ptr & 0x03) | 0x08;
  888. }
  889. else {
  890. *rbtx4938_piosel_ptr &= ~(0x08 | 0x04);
  891. }
  892. rbtx4938_fpga_resource.name = "FPGA Registers";
  893. rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR);
  894. rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff;
  895. rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
  896. if (request_resource(&iomem_resource, &rbtx4938_fpga_resource))
  897. printk("request resource for fpga failed\n");
  898. /* disable all OnBoard I/O interrupts */
  899. *rbtx4938_imask_ptr = 0;
  900. _machine_restart = rbtx4938_machine_restart;
  901. _machine_halt = rbtx4938_machine_halt;
  902. pm_power_off = rbtx4938_machine_power_off;
  903. *rbtx4938_led_ptr = 0xff;
  904. printk("RBTX4938 --- FPGA(Rev %02x)", *rbtx4938_fpga_rev_ptr);
  905. printk(" DIPSW:%02x,%02x\n",
  906. *rbtx4938_dipsw_ptr, *rbtx4938_bdipsw_ptr);
  907. }
  908. #ifdef CONFIG_PROC_FS
  909. extern void spi_eeprom_proc_create(struct proc_dir_entry *dir, int chipid);
  910. static int __init tx4938_spi_proc_setup(void)
  911. {
  912. struct proc_dir_entry *tx4938_spi_eeprom_dir;
  913. tx4938_spi_eeprom_dir = proc_mkdir("spi_eeprom", 0);
  914. if (!tx4938_spi_eeprom_dir)
  915. return -ENOMEM;
  916. /* don't allow user access to RBTX4938_SEEPROM1_CHIPID
  917. * as it contains eth0 and eth1 MAC addresses
  918. */
  919. spi_eeprom_proc_create(tx4938_spi_eeprom_dir, RBTX4938_SEEPROM2_CHIPID);
  920. spi_eeprom_proc_create(tx4938_spi_eeprom_dir, RBTX4938_SEEPROM3_CHIPID);
  921. return 0;
  922. }
  923. __initcall(tx4938_spi_proc_setup);
  924. #endif