cmd_pcmcia.c 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495
  1. /*
  2. * (C) Copyright 2000-2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. ********************************************************************
  24. *
  25. * Lots of code copied from:
  26. *
  27. * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
  28. * (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
  29. *
  30. * "The ExCA standard specifies that socket controllers should provide
  31. * two IO and five memory windows per socket, which can be independently
  32. * configured and positioned in the host address space and mapped to
  33. * arbitrary segments of card address space. " - David A Hinds. 1999
  34. *
  35. * This controller does _not_ meet the ExCA standard.
  36. *
  37. * m8xx pcmcia controller brief info:
  38. * + 8 windows (attrib, mem, i/o)
  39. * + up to two slots (SLOT_A and SLOT_B)
  40. * + inputpins, outputpins, event and mask registers.
  41. * - no offset register. sigh.
  42. *
  43. * Because of the lacking offset register we must map the whole card.
  44. * We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
  45. * Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
  46. * * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
  47. * The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
  48. * They are maximum 64KByte each...
  49. */
  50. /* #define DEBUG 1 */
  51. /*
  52. * PCMCIA support
  53. */
  54. #include <common.h>
  55. #include <command.h>
  56. #include <config.h>
  57. #include <pcmcia.h>
  58. #include <cmd_pcmcia.h>
  59. #if defined(CONFIG_IDE_8xx_PCCARD) && defined(CONFIG_8xx)
  60. #include <mpc8xx.h>
  61. #endif
  62. #if defined(CONFIG_LWMON)
  63. #include <i2c.h>
  64. #endif
  65. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
  66. ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
  67. int pcmcia_on (void);
  68. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  69. static int pcmcia_off (void);
  70. #endif
  71. #ifdef CONFIG_I82365
  72. extern int i82365_init (void);
  73. extern void i82365_exit (void);
  74. #else /* ! CONFIG_I82365 */
  75. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  76. static int hardware_disable(int slot);
  77. #endif
  78. static int hardware_enable (int slot);
  79. static int voltage_set(int slot, int vcc, int vpp);
  80. static u_int m8xx_get_graycode(u_int size);
  81. #if 0
  82. static u_int m8xx_get_speed(u_int ns, u_int is_io);
  83. #endif
  84. /* -------------------------------------------------------------------- */
  85. /* look up table for pgcrx registers */
  86. static u_int *pcmcia_pgcrx[2] = {
  87. &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
  88. &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
  89. };
  90. #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
  91. #endif /* CONFIG_I82365 */
  92. #ifdef CONFIG_IDE_8xx_PCCARD
  93. static void print_funcid (int func);
  94. static void print_fixed (volatile uchar *p);
  95. static int identify (volatile uchar *p);
  96. static int check_ide_device (int slot);
  97. #endif /* CONFIG_IDE_8xx_PCCARD */
  98. const char *indent = "\t ";
  99. /* -------------------------------------------------------------------- */
  100. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  101. int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  102. {
  103. int rcode = 0;
  104. if (argc != 2) {
  105. printf ("Usage: pinit {on | off}\n");
  106. return 1;
  107. }
  108. if (strcmp(argv[1],"on") == 0) {
  109. rcode = pcmcia_on ();
  110. } else if (strcmp(argv[1],"off") == 0) {
  111. rcode = pcmcia_off ();
  112. } else {
  113. printf ("Usage: pinit {on | off}\n");
  114. return 1;
  115. }
  116. return rcode;
  117. }
  118. #endif /* CFG_CMD_PCMCIA */
  119. /* -------------------------------------------------------------------- */
  120. #ifdef CONFIG_I82365
  121. int pcmcia_on (void)
  122. {
  123. u_int rc;
  124. debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  125. rc = i82365_init();
  126. if (rc == 0)
  127. {
  128. rc = check_ide_device(0);
  129. }
  130. return (rc);
  131. }
  132. #else
  133. #if defined(CONFIG_LWMON)
  134. # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
  135. #else
  136. # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
  137. #endif
  138. int pcmcia_on (void)
  139. {
  140. int i;
  141. u_long reg, base;
  142. pcmcia_win_t *win;
  143. u_int slotbit;
  144. u_int rc, slot;
  145. debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  146. /* intialize the fixed memory windows */
  147. win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
  148. base = CFG_PCMCIA_MEM_ADDR;
  149. if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
  150. printf ("Cannot set window size to 0x%08x\n",
  151. CFG_PCMCIA_MEM_SIZE);
  152. return (1);
  153. }
  154. slotbit = PCMCIA_SLOT_x;
  155. for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
  156. win->br = base;
  157. #if (PCMCIA_SOCKETS_NO == 2)
  158. if (i == 4) /* Another slot starting from win 4 */
  159. slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
  160. #endif
  161. switch (i) {
  162. #ifdef CONFIG_IDE_8xx_PCCARD
  163. case 4:
  164. case 0: { /* map attribute memory */
  165. win->or = ( PCMCIA_BSIZE_64M
  166. | PCMCIA_PPS_8
  167. | PCMCIA_PRS_ATTR
  168. | slotbit
  169. | PCMCIA_PV
  170. | CFG_PCMCIA_TIMING );
  171. break;
  172. }
  173. case 5:
  174. case 1: { /* map I/O window for data reg */
  175. win->or = ( PCMCIA_BSIZE_1K
  176. | PCMCIA_PPS_16
  177. | PCMCIA_PRS_IO
  178. | slotbit
  179. | PCMCIA_PV
  180. | CFG_PCMCIA_TIMING );
  181. break;
  182. }
  183. case 6:
  184. case 2: { /* map I/O window for cmd/ctrl reg block */
  185. win->or = ( PCMCIA_BSIZE_1K
  186. | PCMCIA_PPS_8
  187. | PCMCIA_PRS_IO
  188. | slotbit
  189. | PCMCIA_PV
  190. | CFG_PCMCIA_TIMING );
  191. break;
  192. }
  193. #endif /* CONFIG_IDE_8xx_PCCARD */
  194. default: /* set to not valid */
  195. win->or = 0;
  196. break;
  197. }
  198. debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
  199. i, win->br, win->or);
  200. base += CFG_PCMCIA_MEM_SIZE;
  201. ++win;
  202. }
  203. for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
  204. /* turn off voltage */
  205. if ((rc = voltage_set(slot, 0, 0)))
  206. continue;
  207. /* Enable external hardware */
  208. if ((rc = hardware_enable(slot)))
  209. continue;
  210. #ifdef CONFIG_IDE_8xx_PCCARD
  211. if ((rc = check_ide_device(i)))
  212. continue;
  213. #endif
  214. }
  215. return (rc);
  216. }
  217. #endif /* CONFIG_I82365 */
  218. /* -------------------------------------------------------------------- */
  219. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  220. #ifdef CONFIG_I82365
  221. static int pcmcia_off (void)
  222. {
  223. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  224. i82365_exit();
  225. return 0;
  226. }
  227. #else
  228. static int pcmcia_off (void)
  229. {
  230. int i;
  231. pcmcia_win_t *win;
  232. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  233. /* clear interrupt state, and disable interrupts */
  234. ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
  235. ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
  236. /* turn off interrupt and disable CxOE */
  237. PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
  238. /* turn off memory windows */
  239. win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
  240. for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
  241. /* disable memory window */
  242. win->or = 0;
  243. ++win;
  244. }
  245. /* turn off voltage */
  246. voltage_set(_slot_, 0, 0);
  247. /* disable external hardware */
  248. printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
  249. hardware_disable(_slot_);
  250. return 0;
  251. }
  252. #endif /* CONFIG_I82365 */
  253. #endif /* CFG_CMD_PCMCIA */
  254. /* -------------------------------------------------------------------- */
  255. #ifdef CONFIG_IDE_8xx_PCCARD
  256. #define MAX_TUPEL_SZ 512
  257. #define MAX_FEATURES 4
  258. int ide_devices_found;
  259. static int check_ide_device (int slot)
  260. {
  261. volatile uchar *ident = NULL;
  262. volatile uchar *feature_p[MAX_FEATURES];
  263. volatile uchar *p, *start, *addr;
  264. int n_features = 0;
  265. uchar func_id = ~0;
  266. uchar code, len;
  267. ushort config_base = 0;
  268. int found = 0;
  269. int i;
  270. addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
  271. CFG_PCMCIA_MEM_SIZE * (slot * 4));
  272. debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
  273. start = p = (volatile uchar *) addr;
  274. while ((p - start) < MAX_TUPEL_SZ) {
  275. code = *p; p += 2;
  276. if (code == 0xFF) { /* End of chain */
  277. break;
  278. }
  279. len = *p; p += 2;
  280. #if defined(DEBUG) && (DEBUG > 1)
  281. { volatile uchar *q = p;
  282. printf ("\nTuple code %02x length %d\n\tData:",
  283. code, len);
  284. for (i = 0; i < len; ++i) {
  285. printf (" %02x", *q);
  286. q+= 2;
  287. }
  288. }
  289. #endif /* DEBUG */
  290. switch (code) {
  291. case CISTPL_VERS_1:
  292. ident = p + 4;
  293. break;
  294. case CISTPL_FUNCID:
  295. /* Fix for broken SanDisk which may have 0x80 bit set */
  296. func_id = *p & 0x7F;
  297. break;
  298. case CISTPL_FUNCE:
  299. if (n_features < MAX_FEATURES)
  300. feature_p[n_features++] = p;
  301. break;
  302. case CISTPL_CONFIG:
  303. config_base = (*(p+6) << 8) + (*(p+4));
  304. debug ("\n## Config_base = %04x ###\n", config_base);
  305. default:
  306. break;
  307. }
  308. p += 2 * len;
  309. }
  310. found = identify (ident);
  311. if (func_id != ((uchar)~0)) {
  312. print_funcid (func_id);
  313. if (func_id == CISTPL_FUNCID_FIXED)
  314. found = 1;
  315. else
  316. return (1); /* no disk drive */
  317. }
  318. for (i=0; i<n_features; ++i) {
  319. print_fixed (feature_p[i]);
  320. }
  321. if (!found) {
  322. printf ("unknown card type\n");
  323. return (1);
  324. }
  325. ide_devices_found |= (1 << slot);
  326. /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
  327. *((uchar *)(addr + config_base)) = 1;
  328. return (0);
  329. }
  330. #endif /* CONFIG_IDE_8xx_PCCARD */
  331. /* -------------------------------------------------------------------- */
  332. /* -------------------------------------------------------------------- */
  333. /* board specific stuff: */
  334. /* voltage_set(), hardware_enable() and hardware_disable() */
  335. /* -------------------------------------------------------------------- */
  336. /* -------------------------------------------------------------------- */
  337. /* RPX Boards from Embedded Planet */
  338. /* -------------------------------------------------------------------- */
  339. #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
  340. /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
  341. * SYPCR is write once only, therefore must the slowest memory be faster
  342. * than the bus monitor or we will get a machine check due to the bus timeout.
  343. */
  344. #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
  345. #undef PCMCIA_BMT_LIMIT
  346. #define PCMCIA_BMT_LIMIT (6*8)
  347. static int voltage_set(int slot, int vcc, int vpp)
  348. {
  349. u_long reg = 0;
  350. switch(vcc) {
  351. case 0: break;
  352. case 33: reg |= BCSR1_PCVCTL4; break;
  353. case 50: reg |= BCSR1_PCVCTL5; break;
  354. default: return 1;
  355. }
  356. switch(vpp) {
  357. case 0: break;
  358. case 33:
  359. case 50:
  360. if(vcc == vpp)
  361. reg |= BCSR1_PCVCTL6;
  362. else
  363. return 1;
  364. break;
  365. case 120:
  366. reg |= BCSR1_PCVCTL7;
  367. default: return 1;
  368. }
  369. if(vcc == 120)
  370. return 1;
  371. /* first, turn off all power */
  372. *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
  373. | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
  374. /* enable new powersettings */
  375. *((uint *)RPX_CSR_ADDR) |= reg;
  376. return 0;
  377. }
  378. #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
  379. static int hardware_enable (int slot)
  380. {
  381. return 0; /* No hardware to enable */
  382. }
  383. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  384. static int hardware_disable(int slot)
  385. {
  386. return 0; /* No hardware to disable */
  387. }
  388. #endif /* CFG_CMD_PCMCIA */
  389. #endif /* CONFIG_RPXCLASSIC */
  390. /* -------------------------------------------------------------------- */
  391. /* (F)ADS Boards from Motorola */
  392. /* -------------------------------------------------------------------- */
  393. #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
  394. #ifdef CONFIG_ADS
  395. #define PCMCIA_BOARD_MSG "ADS"
  396. #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
  397. #else
  398. #define PCMCIA_BOARD_MSG "FADS"
  399. #endif
  400. static int voltage_set(int slot, int vcc, int vpp)
  401. {
  402. u_long reg = 0;
  403. switch(vpp) {
  404. case 0: reg = 0; break;
  405. case 50: reg = 1; break;
  406. case 120: reg = 2; break;
  407. default: return 1;
  408. }
  409. switch(vcc) {
  410. case 0: reg = 0; break;
  411. #ifdef CONFIG_ADS
  412. case 50: reg = BCSR1_PCCVCCON; break;
  413. #endif
  414. #ifdef CONFIG_FADS
  415. case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
  416. case 50: reg = BCSR1_PCCVCC1; break;
  417. #endif
  418. default: return 1;
  419. }
  420. /* first, turn off all power */
  421. #ifdef CONFIG_ADS
  422. *((uint *)BCSR1) |= BCSR1_PCCVCCON;
  423. #endif
  424. #ifdef CONFIG_FADS
  425. *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
  426. #endif
  427. *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
  428. /* enable new powersettings */
  429. #ifdef CONFIG_ADS
  430. *((uint *)BCSR1) &= ~reg;
  431. #endif
  432. #ifdef CONFIG_FADS
  433. *((uint *)BCSR1) |= reg;
  434. #endif
  435. *((uint *)BCSR1) |= reg << 20;
  436. return 0;
  437. }
  438. #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
  439. static int hardware_enable(int slot)
  440. {
  441. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  442. return 0;
  443. }
  444. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  445. static int hardware_disable(int slot)
  446. {
  447. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  448. return 0;
  449. }
  450. #endif /* CFG_CMD_PCMCIA */
  451. #endif /* (F)ADS */
  452. /* -------------------------------------------------------------------- */
  453. /* TQM8xxL Boards by TQ Components */
  454. /* SC8xx Boards by SinoVee Microsystems */
  455. /* -------------------------------------------------------------------- */
  456. #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
  457. #if defined(CONFIG_TQM8xxL)
  458. #define PCMCIA_BOARD_MSG "TQM8xxL"
  459. #endif
  460. #if defined(CONFIG_SVM_SC8xx)
  461. #define PCMCIA_BOARD_MSG "SC8xx"
  462. #endif
  463. static int hardware_enable(int slot)
  464. {
  465. volatile immap_t *immap;
  466. volatile cpm8xx_t *cp;
  467. volatile pcmconf8xx_t *pcmp;
  468. volatile sysconf8xx_t *sysp;
  469. uint reg, mask;
  470. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  471. udelay(10000);
  472. immap = (immap_t *)CFG_IMMR;
  473. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  474. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  475. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  476. /*
  477. * Configure SIUMCR to enable PCMCIA port B
  478. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  479. */
  480. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  481. /* clear interrupt state, and disable interrupts */
  482. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  483. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  484. /*
  485. * Disable interrupts, DMA, and PCMCIA buffers
  486. * (isolate the interface) and assert RESET signal
  487. */
  488. debug ("Disable PCMCIA buffers and assert RESET\n");
  489. reg = 0;
  490. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  491. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  492. PCMCIA_PGCRX(_slot_) = reg;
  493. udelay(500);
  494. /*
  495. * Configure Port C pins for
  496. * 5 Volts Enable and 3 Volts enable
  497. */
  498. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  499. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  500. /* remove all power */
  501. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  502. /*
  503. * Make sure there is a card in the slot, then configure the interface.
  504. */
  505. udelay(10000);
  506. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  507. __LINE__,__FUNCTION__,
  508. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  509. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  510. printf (" No Card found\n");
  511. return (1);
  512. }
  513. /*
  514. * Power On.
  515. */
  516. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  517. reg = pcmp->pcmc_pipr;
  518. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  519. reg,
  520. (reg&PCMCIA_VS1(slot))?"n":"ff",
  521. (reg&PCMCIA_VS2(slot))?"n":"ff");
  522. if ((reg & mask) == mask) {
  523. immap->im_ioport.iop_pcdat |= 0x0004;
  524. puts (" 5.0V card found: ");
  525. } else {
  526. immap->im_ioport.iop_pcdat |= 0x0002;
  527. puts (" 3.3V card found: ");
  528. }
  529. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  530. #if 0
  531. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  532. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  533. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  534. udelay(500000);
  535. #endif
  536. udelay(1000);
  537. debug ("Enable PCMCIA buffers and stop RESET\n");
  538. reg = PCMCIA_PGCRX(_slot_);
  539. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  540. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  541. PCMCIA_PGCRX(_slot_) = reg;
  542. udelay(250000); /* some cards need >150 ms to come up :-( */
  543. debug ("# hardware_enable done\n");
  544. return (0);
  545. }
  546. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  547. static int hardware_disable(int slot)
  548. {
  549. volatile immap_t *immap;
  550. volatile pcmconf8xx_t *pcmp;
  551. u_long reg;
  552. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  553. immap = (immap_t *)CFG_IMMR;
  554. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  555. /* remove all power */
  556. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  557. debug ("Disable PCMCIA buffers and assert RESET\n");
  558. reg = 0;
  559. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  560. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  561. PCMCIA_PGCRX(_slot_) = reg;
  562. udelay(10000);
  563. return (0);
  564. }
  565. #endif /* CFG_CMD_PCMCIA */
  566. static int voltage_set(int slot, int vcc, int vpp)
  567. {
  568. volatile immap_t *immap;
  569. volatile pcmconf8xx_t *pcmp;
  570. u_long reg;
  571. debug ("voltage_set: "
  572. PCMCIA_BOARD_MSG
  573. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  574. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  575. immap = (immap_t *)CFG_IMMR;
  576. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  577. /*
  578. * Disable PCMCIA buffers (isolate the interface)
  579. * and assert RESET signal
  580. */
  581. debug ("Disable PCMCIA buffers and assert RESET\n");
  582. reg = PCMCIA_PGCRX(_slot_);
  583. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  584. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  585. PCMCIA_PGCRX(_slot_) = reg;
  586. udelay(500);
  587. /*
  588. * Configure Port C pins for
  589. * 5 Volts Enable and 3 Volts enable,
  590. * Turn off all power
  591. */
  592. debug ("PCMCIA power OFF\n");
  593. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  594. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  595. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  596. reg = 0;
  597. switch(vcc) {
  598. case 0: break;
  599. case 33: reg |= 0x0002; break;
  600. case 50: reg |= 0x0004; break;
  601. default: goto done;
  602. }
  603. /* Checking supported voltages */
  604. debug ("PIPR: 0x%x --> %s\n",
  605. pcmp->pcmc_pipr,
  606. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  607. immap->im_ioport.iop_pcdat |= reg;
  608. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  609. if (reg) {
  610. debug ("PCMCIA powered at %sV\n",
  611. (reg&0x0004) ? "5.0" : "3.3");
  612. } else {
  613. debug ("PCMCIA powered down\n");
  614. }
  615. done:
  616. debug ("Enable PCMCIA buffers and stop RESET\n");
  617. reg = PCMCIA_PGCRX(_slot_);
  618. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  619. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  620. PCMCIA_PGCRX(_slot_) = reg;
  621. udelay(500);
  622. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  623. slot+'A');
  624. return (0);
  625. }
  626. #endif /* TQM8xxL */
  627. /* -------------------------------------------------------------------- */
  628. /* LWMON Board */
  629. /* -------------------------------------------------------------------- */
  630. #if defined(CONFIG_LWMON)
  631. #define PCMCIA_BOARD_MSG "LWMON"
  632. /* #define's for MAX1604 Power Switch */
  633. #define MAX1604_OP_SUS 0x80
  634. #define MAX1604_VCCBON 0x40
  635. #define MAX1604_VCC_35 0x20
  636. #define MAX1604_VCCBHIZ 0x10
  637. #define MAX1604_VPPBON 0x08
  638. #define MAX1604_VPPBPBPGM 0x04
  639. #define MAX1604_VPPBHIZ 0x02
  640. /* reserved 0x01 */
  641. static int hardware_enable(int slot)
  642. {
  643. volatile immap_t *immap;
  644. volatile cpm8xx_t *cp;
  645. volatile pcmconf8xx_t *pcmp;
  646. volatile sysconf8xx_t *sysp;
  647. uint reg, mask;
  648. uchar val;
  649. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  650. /* Switch on PCMCIA port in PIC register 0x60 */
  651. reg = pic_read (0x60);
  652. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  653. reg &= ~0x10;
  654. /* reg |= 0x08; Vpp not needed */
  655. pic_write (0x60, reg);
  656. #ifdef DEBUG
  657. reg = pic_read (0x60);
  658. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  659. #endif
  660. udelay(10000);
  661. immap = (immap_t *)CFG_IMMR;
  662. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  663. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  664. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  665. /*
  666. * Configure SIUMCR to enable PCMCIA port B
  667. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  668. */
  669. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  670. /* clear interrupt state, and disable interrupts */
  671. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  672. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  673. /*
  674. * Disable interrupts, DMA, and PCMCIA buffers
  675. * (isolate the interface) and assert RESET signal
  676. */
  677. debug ("Disable PCMCIA buffers and assert RESET\n");
  678. reg = 0;
  679. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  680. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  681. PCMCIA_PGCRX(_slot_) = reg;
  682. udelay(500);
  683. /*
  684. * Make sure there is a card in the slot, then configure the interface.
  685. */
  686. udelay(10000);
  687. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  688. __LINE__,__FUNCTION__,
  689. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  690. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  691. printf (" No Card found\n");
  692. return (1);
  693. }
  694. /*
  695. * Power On.
  696. */
  697. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  698. reg = pcmp->pcmc_pipr;
  699. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  700. reg,
  701. (reg&PCMCIA_VS1(slot))?"n":"ff",
  702. (reg&PCMCIA_VS2(slot))?"n":"ff");
  703. if ((reg & mask) == mask) {
  704. val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
  705. puts (" 5.0V card found: ");
  706. } else {
  707. val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
  708. puts (" 3.3V card found: ");
  709. }
  710. /* switch VCC on */
  711. val |= MAX1604_OP_SUS | MAX1604_VCCBON;
  712. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  713. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  714. udelay(500000);
  715. debug ("Enable PCMCIA buffers and stop RESET\n");
  716. reg = PCMCIA_PGCRX(_slot_);
  717. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  718. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  719. PCMCIA_PGCRX(_slot_) = reg;
  720. udelay(250000); /* some cards need >150 ms to come up :-( */
  721. debug ("# hardware_enable done\n");
  722. return (0);
  723. }
  724. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  725. static int hardware_disable(int slot)
  726. {
  727. volatile immap_t *immap;
  728. volatile pcmconf8xx_t *pcmp;
  729. u_long reg;
  730. uchar val;
  731. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  732. immap = (immap_t *)CFG_IMMR;
  733. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  734. /* remove all power, put output in high impedance state */
  735. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  736. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  737. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  738. /* Configure PCMCIA General Control Register */
  739. debug ("Disable PCMCIA buffers and assert RESET\n");
  740. reg = 0;
  741. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  742. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  743. PCMCIA_PGCRX(_slot_) = reg;
  744. /* Switch off PCMCIA port in PIC register 0x60 */
  745. reg = pic_read (0x60);
  746. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  747. reg |= 0x10;
  748. reg &= ~0x08;
  749. pic_write (0x60, reg);
  750. #ifdef DEBUG
  751. reg = pic_read (0x60);
  752. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  753. #endif
  754. udelay(10000);
  755. return (0);
  756. }
  757. #endif /* CFG_CMD_PCMCIA */
  758. static int voltage_set(int slot, int vcc, int vpp)
  759. {
  760. volatile immap_t *immap;
  761. volatile pcmconf8xx_t *pcmp;
  762. u_long reg;
  763. uchar val;
  764. debug ("voltage_set: "
  765. PCMCIA_BOARD_MSG
  766. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  767. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  768. immap = (immap_t *)CFG_IMMR;
  769. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  770. /*
  771. * Disable PCMCIA buffers (isolate the interface)
  772. * and assert RESET signal
  773. */
  774. debug ("Disable PCMCIA buffers and assert RESET\n");
  775. reg = PCMCIA_PGCRX(_slot_);
  776. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  777. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  778. PCMCIA_PGCRX(_slot_) = reg;
  779. udelay(500);
  780. /*
  781. * Turn off all power (switch to high impedance)
  782. */
  783. debug ("PCMCIA power OFF\n");
  784. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  785. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  786. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  787. val = 0;
  788. switch(vcc) {
  789. case 0: break;
  790. case 33: val = MAX1604_VCC_35; break;
  791. case 50: break;
  792. default: goto done;
  793. }
  794. /* Checking supported voltages */
  795. debug ("PIPR: 0x%x --> %s\n",
  796. pcmp->pcmc_pipr,
  797. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  798. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  799. if (val) {
  800. debug ("PCMCIA powered at %sV\n",
  801. (val & MAX1604_VCC_35) ? "3.3" : "5.0");
  802. } else {
  803. debug ("PCMCIA powered down\n");
  804. }
  805. done:
  806. debug ("Enable PCMCIA buffers and stop RESET\n");
  807. reg = PCMCIA_PGCRX(_slot_);
  808. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  809. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  810. PCMCIA_PGCRX(_slot_) = reg;
  811. udelay(500);
  812. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  813. slot+'A');
  814. return (0);
  815. }
  816. #endif /* LWMON */
  817. /* -------------------------------------------------------------------- */
  818. /* GTH board by Corelatus AB */
  819. /* -------------------------------------------------------------------- */
  820. #if defined(CONFIG_GTH)
  821. #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
  822. static int voltage_set (int slot, int vcc, int vpp)
  823. { /* Do nothing */
  824. return 0;
  825. }
  826. static int hardware_enable (int slot)
  827. {
  828. volatile immap_t *immap;
  829. volatile cpm8xx_t *cp;
  830. volatile pcmconf8xx_t *pcmp;
  831. volatile sysconf8xx_t *sysp;
  832. uint reg, mask;
  833. debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
  834. immap = (immap_t *) CFG_IMMR;
  835. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  836. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  837. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  838. /* clear interrupt state, and disable interrupts */
  839. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  840. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  841. /*
  842. * Disable interrupts, DMA, and PCMCIA buffers
  843. * (isolate the interface) and assert RESET signal
  844. */
  845. debug ("Disable PCMCIA buffers and assert RESET\n");
  846. reg = 0;
  847. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  848. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  849. PCMCIA_PGCRX (_slot_) = reg;
  850. udelay (500);
  851. /*
  852. * Make sure there is a card in the slot,
  853. * then configure the interface.
  854. */
  855. udelay (10000);
  856. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  857. __LINE__, __FUNCTION__,
  858. &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
  859. if (pcmp->pcmc_pipr & 0x98000000) {
  860. printf (" No Card found\n");
  861. return (1);
  862. }
  863. mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
  864. reg = pcmp->pcmc_pipr;
  865. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  866. reg,
  867. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  868. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  869. debug ("Enable PCMCIA buffers and stop RESET\n");
  870. reg = PCMCIA_PGCRX (_slot_);
  871. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  872. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  873. PCMCIA_PGCRX (_slot_) = reg;
  874. udelay (250000); /* some cards need >150 ms to come up :-( */
  875. debug ("# hardware_enable done\n");
  876. return 0;
  877. }
  878. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  879. static int hardware_disable(int slot)
  880. {
  881. return 0; /* No hardware to disable */
  882. }
  883. #endif /* CFG_CMD_PCMCIA */
  884. #endif /* CONFIG_GTH */
  885. /* -------------------------------------------------------------------- */
  886. /* ICU862 Boards by Cambridge Broadband Ltd. */
  887. /* -------------------------------------------------------------------- */
  888. #if defined(CONFIG_ICU862)
  889. #define PCMCIA_BOARD_MSG "ICU862"
  890. static void cfg_port_B (void);
  891. static int hardware_enable(int slot)
  892. {
  893. volatile immap_t *immap;
  894. volatile cpm8xx_t *cp;
  895. volatile pcmconf8xx_t *pcmp;
  896. volatile sysconf8xx_t *sysp;
  897. uint reg, pipr, mask;
  898. int i;
  899. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  900. udelay(10000);
  901. immap = (immap_t *)CFG_IMMR;
  902. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  903. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  904. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  905. /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
  906. cfg_port_B ();
  907. /*
  908. * Configure SIUMCR to enable PCMCIA port B
  909. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  910. */
  911. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  912. /* clear interrupt state, and disable interrupts */
  913. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  914. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  915. /*
  916. * Disable interrupts, DMA, and PCMCIA buffers
  917. * (isolate the interface) and assert RESET signal
  918. */
  919. debug ("Disable PCMCIA buffers and assert RESET\n");
  920. reg = 0;
  921. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  922. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  923. PCMCIA_PGCRX(_slot_) = reg;
  924. udelay(500);
  925. /*
  926. * Make sure there is a card in the slot, then configure the interface.
  927. */
  928. udelay(10000);
  929. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  930. __LINE__,__FUNCTION__,
  931. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  932. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  933. printf (" No Card found\n");
  934. return (1);
  935. }
  936. /*
  937. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  938. */
  939. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  940. pipr = pcmp->pcmc_pipr;
  941. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  942. pipr,
  943. (reg&PCMCIA_VS1(slot))?"n":"ff",
  944. (reg&PCMCIA_VS2(slot))?"n":"ff");
  945. reg = cp->cp_pbdat;
  946. if ((pipr & mask) == mask) {
  947. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  948. TPS2205_VCC3); /* 3V off */
  949. reg &= ~(TPS2205_VCC5); /* 5V on */
  950. puts (" 5.0V card found: ");
  951. } else {
  952. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  953. TPS2205_VCC5); /* 5V off */
  954. reg &= ~(TPS2205_VCC3); /* 3V on */
  955. puts (" 3.3V card found: ");
  956. }
  957. debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
  958. reg,
  959. (reg & TPS2205_VCC3) ? "off" : "on",
  960. (reg & TPS2205_VCC5) ? "off" : "on",
  961. (reg & TPS2205_VPP_PGM) ? "off" : "on",
  962. (reg & TPS2205_VPP_VCC) ? "off" : "on" );
  963. cp->cp_pbdat = reg;
  964. /* Wait 500 ms; use this to check for over-current */
  965. for (i=0; i<5000; ++i) {
  966. if ((cp->cp_pbdat & TPS2205_OC) == 0) {
  967. printf (" *** Overcurrent - Safety shutdown ***\n");
  968. cp->cp_pbdat &= ~(TPS2205_SHDN);
  969. return (1);
  970. }
  971. udelay (100);
  972. }
  973. debug ("Enable PCMCIA buffers and stop RESET\n");
  974. reg = PCMCIA_PGCRX(_slot_);
  975. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  976. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  977. PCMCIA_PGCRX(_slot_) = reg;
  978. udelay(250000); /* some cards need >150 ms to come up :-( */
  979. debug ("# hardware_enable done\n");
  980. return (0);
  981. }
  982. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  983. static int hardware_disable(int slot)
  984. {
  985. volatile immap_t *immap;
  986. volatile cpm8xx_t *cp;
  987. volatile pcmconf8xx_t *pcmp;
  988. u_long reg;
  989. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  990. immap = (immap_t *)CFG_IMMR;
  991. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  992. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  993. /* Shut down */
  994. cp->cp_pbdat &= ~(TPS2205_SHDN);
  995. /* Configure PCMCIA General Control Register */
  996. debug ("Disable PCMCIA buffers and assert RESET\n");
  997. reg = 0;
  998. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  999. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1000. PCMCIA_PGCRX(_slot_) = reg;
  1001. udelay(10000);
  1002. return (0);
  1003. }
  1004. #endif /* CFG_CMD_PCMCIA */
  1005. static int voltage_set(int slot, int vcc, int vpp)
  1006. {
  1007. volatile immap_t *immap;
  1008. volatile cpm8xx_t *cp;
  1009. volatile pcmconf8xx_t *pcmp;
  1010. u_long reg;
  1011. debug ("voltage_set: "
  1012. PCMCIA_BOARD_MSG
  1013. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1014. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1015. immap = (immap_t *)CFG_IMMR;
  1016. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1017. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1018. /*
  1019. * Disable PCMCIA buffers (isolate the interface)
  1020. * and assert RESET signal
  1021. */
  1022. debug ("Disable PCMCIA buffers and assert RESET\n");
  1023. reg = PCMCIA_PGCRX(_slot_);
  1024. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1025. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1026. PCMCIA_PGCRX(_slot_) = reg;
  1027. udelay(500);
  1028. /*
  1029. * Configure Port C pins for
  1030. * 5 Volts Enable and 3 Volts enable,
  1031. * Turn all power pins to Hi-Z
  1032. */
  1033. debug ("PCMCIA power OFF\n");
  1034. cfg_port_B (); /* Enables switch, but all in Hi-Z */
  1035. reg = cp->cp_pbdat;
  1036. switch(vcc) {
  1037. case 0: break; /* Switch off */
  1038. case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
  1039. case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
  1040. default: goto done;
  1041. }
  1042. /* Checking supported voltages */
  1043. debug ("PIPR: 0x%x --> %s\n",
  1044. pcmp->pcmc_pipr,
  1045. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1046. cp->cp_pbdat = reg;
  1047. #ifdef DEBUG
  1048. {
  1049. char *s;
  1050. if ((reg & TPS2205_VCC3) == 0) {
  1051. s = "at 3.3V";
  1052. } else if ((reg & TPS2205_VCC5) == 0) {
  1053. s = "at 5.0V";
  1054. } else {
  1055. s = "down";
  1056. }
  1057. printf ("PCMCIA powered %s\n", s);
  1058. }
  1059. #endif
  1060. done:
  1061. debug ("Enable PCMCIA buffers and stop RESET\n");
  1062. reg = PCMCIA_PGCRX(_slot_);
  1063. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1064. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1065. PCMCIA_PGCRX(_slot_) = reg;
  1066. udelay(500);
  1067. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1068. slot+'A');
  1069. return (0);
  1070. }
  1071. static void cfg_port_B (void)
  1072. {
  1073. volatile immap_t *immap;
  1074. volatile cpm8xx_t *cp;
  1075. uint reg;
  1076. immap = (immap_t *)CFG_IMMR;
  1077. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1078. /*
  1079. * Configure Port B for TPS2205 PC-Card Power-Interface Switch
  1080. *
  1081. * Switch off all voltages, assert shutdown
  1082. */
  1083. reg = cp->cp_pbdat;
  1084. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1085. TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
  1086. TPS2205_SHDN); /* enable switch */
  1087. cp->cp_pbdat = reg;
  1088. cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
  1089. reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
  1090. cp->cp_pbdir = reg | TPS2205_OUTPUTS;
  1091. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1092. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1093. }
  1094. #endif /* ICU862 */
  1095. /* -------------------------------------------------------------------- */
  1096. /* C2MON Boards by TTTech Computertechnik AG */
  1097. /* -------------------------------------------------------------------- */
  1098. #if defined(CONFIG_C2MON)
  1099. #define PCMCIA_BOARD_MSG "C2MON"
  1100. static void cfg_ports (void);
  1101. static int hardware_enable(int slot)
  1102. {
  1103. volatile immap_t *immap;
  1104. volatile cpm8xx_t *cp;
  1105. volatile pcmconf8xx_t *pcmp;
  1106. volatile sysconf8xx_t *sysp;
  1107. uint reg, pipr, mask;
  1108. ushort sreg;
  1109. int i;
  1110. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1111. udelay(10000);
  1112. immap = (immap_t *)CFG_IMMR;
  1113. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1114. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1115. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1116. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  1117. cfg_ports ();
  1118. /*
  1119. * Configure SIUMCR to enable PCMCIA port B
  1120. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1121. */
  1122. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1123. /* clear interrupt state, and disable interrupts */
  1124. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1125. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1126. /*
  1127. * Disable interrupts, DMA, and PCMCIA buffers
  1128. * (isolate the interface) and assert RESET signal
  1129. */
  1130. debug ("Disable PCMCIA buffers and assert RESET\n");
  1131. reg = 0;
  1132. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1133. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1134. PCMCIA_PGCRX(_slot_) = reg;
  1135. udelay(500);
  1136. /*
  1137. * Make sure there is a card in the slot, then configure the interface.
  1138. */
  1139. udelay(10000);
  1140. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1141. __LINE__,__FUNCTION__,
  1142. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1143. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1144. printf (" No Card found\n");
  1145. return (1);
  1146. }
  1147. /*
  1148. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1149. */
  1150. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1151. pipr = pcmp->pcmc_pipr;
  1152. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1153. pipr,
  1154. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1155. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1156. sreg = immap->im_ioport.iop_pcdat;
  1157. if ((pipr & mask) == mask) {
  1158. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1159. TPS2211_VCCD1); /* 5V on */
  1160. sreg &= ~(TPS2211_VCCD0); /* 3V off */
  1161. puts (" 5.0V card found: ");
  1162. } else {
  1163. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1164. TPS2211_VCCD0); /* 3V on */
  1165. sreg &= ~(TPS2211_VCCD1); /* 5V off */
  1166. puts (" 3.3V card found: ");
  1167. }
  1168. debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
  1169. sreg,
  1170. ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
  1171. (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
  1172. );
  1173. immap->im_ioport.iop_pcdat = sreg;
  1174. /* Wait 500 ms; use this to check for over-current */
  1175. for (i=0; i<5000; ++i) {
  1176. if ((cp->cp_pbdat & TPS2211_OC) == 0) {
  1177. printf (" *** Overcurrent - Safety shutdown ***\n");
  1178. immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
  1179. return (1);
  1180. }
  1181. udelay (100);
  1182. }
  1183. debug ("Enable PCMCIA buffers and stop RESET\n");
  1184. reg = PCMCIA_PGCRX(_slot_);
  1185. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1186. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1187. PCMCIA_PGCRX(_slot_) = reg;
  1188. udelay(250000); /* some cards need >150 ms to come up :-( */
  1189. debug ("# hardware_enable done\n");
  1190. return (0);
  1191. }
  1192. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1193. static int hardware_disable(int slot)
  1194. {
  1195. volatile immap_t *immap;
  1196. volatile cpm8xx_t *cp;
  1197. volatile pcmconf8xx_t *pcmp;
  1198. u_long reg;
  1199. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1200. immap = (immap_t *)CFG_IMMR;
  1201. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1202. /* Configure PCMCIA General Control Register */
  1203. debug ("Disable PCMCIA buffers and assert RESET\n");
  1204. reg = 0;
  1205. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1206. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1207. PCMCIA_PGCRX(_slot_) = reg;
  1208. /* ALl voltages off / Hi-Z */
  1209. immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
  1210. TPS2211_VCCD0 | TPS2211_VCCD1 );
  1211. udelay(10000);
  1212. return (0);
  1213. }
  1214. #endif /* CFG_CMD_PCMCIA */
  1215. static int voltage_set(int slot, int vcc, int vpp)
  1216. {
  1217. volatile immap_t *immap;
  1218. volatile cpm8xx_t *cp;
  1219. volatile pcmconf8xx_t *pcmp;
  1220. u_long reg;
  1221. ushort sreg;
  1222. debug ("voltage_set: "
  1223. PCMCIA_BOARD_MSG
  1224. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1225. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1226. immap = (immap_t *)CFG_IMMR;
  1227. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1228. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1229. /*
  1230. * Disable PCMCIA buffers (isolate the interface)
  1231. * and assert RESET signal
  1232. */
  1233. debug ("Disable PCMCIA buffers and assert RESET\n");
  1234. reg = PCMCIA_PGCRX(_slot_);
  1235. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1236. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1237. PCMCIA_PGCRX(_slot_) = reg;
  1238. udelay(500);
  1239. /*
  1240. * Configure Port C pins for
  1241. * 5 Volts Enable and 3 Volts enable,
  1242. * Turn all power pins to Hi-Z
  1243. */
  1244. debug ("PCMCIA power OFF\n");
  1245. cfg_ports (); /* Enables switch, but all in Hi-Z */
  1246. sreg = immap->im_ioport.iop_pcdat;
  1247. sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
  1248. switch(vcc) {
  1249. case 0: break; /* Switch off */
  1250. case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
  1251. sreg &= ~TPS2211_VCCD1;
  1252. break;
  1253. case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
  1254. sreg |= TPS2211_VCCD1;
  1255. break;
  1256. default: goto done;
  1257. }
  1258. /* Checking supported voltages */
  1259. debug ("PIPR: 0x%x --> %s\n",
  1260. pcmp->pcmc_pipr,
  1261. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1262. immap->im_ioport.iop_pcdat = sreg;
  1263. #ifdef DEBUG
  1264. {
  1265. char *s;
  1266. if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
  1267. s = "at 3.3V";
  1268. } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
  1269. s = "at 5.0V";
  1270. } else {
  1271. s = "down";
  1272. }
  1273. printf ("PCMCIA powered %s\n", s);
  1274. }
  1275. #endif
  1276. done:
  1277. debug ("Enable PCMCIA buffers and stop RESET\n");
  1278. reg = PCMCIA_PGCRX(_slot_);
  1279. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1280. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1281. PCMCIA_PGCRX(_slot_) = reg;
  1282. udelay(500);
  1283. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1284. slot+'A');
  1285. return (0);
  1286. }
  1287. static void cfg_ports (void)
  1288. {
  1289. volatile immap_t *immap;
  1290. volatile cpm8xx_t *cp;
  1291. ushort sreg;
  1292. immap = (immap_t *)CFG_IMMR;
  1293. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1294. /*
  1295. * Configure Port C for TPS2211 PC-Card Power-Interface Switch
  1296. *
  1297. * Switch off all voltages, assert shutdown
  1298. */
  1299. sreg = immap->im_ioport.iop_pcdat;
  1300. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
  1301. sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
  1302. immap->im_ioport.iop_pcdat = sreg;
  1303. immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
  1304. immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
  1305. debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
  1306. immap->im_ioport.iop_pcpar,
  1307. immap->im_ioport.iop_pcdir,
  1308. immap->im_ioport.iop_pcdat);
  1309. /*
  1310. * Configure Port B for TPS2211 PC-Card Power-Interface Switch
  1311. *
  1312. * Over-Current Input only
  1313. */
  1314. cp->cp_pbpar &= ~(TPS2211_INPUTS);
  1315. cp->cp_pbdir &= ~(TPS2211_INPUTS);
  1316. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1317. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1318. }
  1319. #endif /* C2MON */
  1320. /* -------------------------------------------------------------------- */
  1321. /* MBX board from Morotola */
  1322. /* -------------------------------------------------------------------- */
  1323. #if defined( CONFIG_MBX )
  1324. #include <../board/mbx8xx/csr.h>
  1325. /* A lot of this has been taken from the RPX code in this file it works from me.
  1326. I have added the voltage selection for the MBX board. */
  1327. /* MBX voltage bit in control register #2 */
  1328. #define CR2_VPP12 ((uchar)0x10)
  1329. #define CR2_VPPVDD ((uchar)0x20)
  1330. #define CR2_VDD5 ((uchar)0x40)
  1331. #define CR2_VDD3 ((uchar)0x80)
  1332. #define PCMCIA_BOARD_MSG "MBX860"
  1333. static int voltage_set (int slot, int vcc, int vpp)
  1334. {
  1335. uchar reg = 0;
  1336. debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1337. 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
  1338. switch (vcc) {
  1339. case 0:
  1340. break;
  1341. case 33:
  1342. reg |= CR2_VDD3;
  1343. break;
  1344. case 50:
  1345. reg |= CR2_VDD5;
  1346. break;
  1347. default:
  1348. return 1;
  1349. }
  1350. switch (vpp) {
  1351. case 0:
  1352. break;
  1353. case 33:
  1354. case 50:
  1355. if (vcc == vpp) {
  1356. reg |= CR2_VPPVDD;
  1357. } else {
  1358. return 1;
  1359. }
  1360. break;
  1361. case 120:
  1362. reg |= CR2_VPP12;
  1363. break;
  1364. default:
  1365. return 1;
  1366. }
  1367. /* first, turn off all power */
  1368. MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
  1369. /* enable new powersettings */
  1370. MBX_CSR2 |= reg;
  1371. debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
  1372. return (0);
  1373. }
  1374. static int hardware_enable (int slot)
  1375. {
  1376. volatile immap_t *immap;
  1377. volatile cpm8xx_t *cp;
  1378. volatile pcmconf8xx_t *pcmp;
  1379. volatile sysconf8xx_t *sysp;
  1380. uint reg, mask;
  1381. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
  1382. 'A' + slot);
  1383. udelay (10000);
  1384. immap = (immap_t *) CFG_IMMR;
  1385. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1386. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1387. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1388. /* clear interrupt state, and disable interrupts */
  1389. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1390. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1391. /*
  1392. * Disable interrupts, DMA, and PCMCIA buffers
  1393. * (isolate the interface) and assert RESET signal
  1394. */
  1395. debug ("Disable PCMCIA buffers and assert RESET\n");
  1396. reg = 0;
  1397. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1398. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1399. PCMCIA_PGCRX (_slot_) = reg;
  1400. udelay (500);
  1401. /* remove all power */
  1402. voltage_set (slot, 0, 0);
  1403. /*
  1404. * Make sure there is a card in the slot, then configure the interface.
  1405. */
  1406. udelay(10000);
  1407. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1408. __LINE__,__FUNCTION__,
  1409. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1410. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1411. printf (" No Card found\n");
  1412. return (1);
  1413. }
  1414. /*
  1415. * Power On.
  1416. */
  1417. mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
  1418. reg = pcmp->pcmc_pipr;
  1419. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  1420. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1421. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1422. if ((reg & mask) == mask) {
  1423. voltage_set (_slot_, 50, 0);
  1424. printf (" 5.0V card found: ");
  1425. } else {
  1426. voltage_set (_slot_, 33, 0);
  1427. printf (" 3.3V card found: ");
  1428. }
  1429. debug ("Enable PCMCIA buffers and stop RESET\n");
  1430. reg = PCMCIA_PGCRX (_slot_);
  1431. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1432. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1433. PCMCIA_PGCRX (_slot_) = reg;
  1434. udelay (250000); /* some cards need >150 ms to come up :-( */
  1435. debug ("# hardware_enable done\n");
  1436. return (0);
  1437. }
  1438. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1439. static int hardware_disable (int slot)
  1440. {
  1441. return 0; /* No hardware to disable */
  1442. }
  1443. #endif /* CFG_CMD_PCMCIA */
  1444. #endif /* CONFIG_MBX */
  1445. /* -------------------------------------------------------------------- */
  1446. /* R360MPI Board */
  1447. /* -------------------------------------------------------------------- */
  1448. #if defined(CONFIG_R360MPI)
  1449. #define PCMCIA_BOARD_MSG "R360MPI"
  1450. static int hardware_enable(int slot)
  1451. {
  1452. volatile immap_t *immap;
  1453. volatile cpm8xx_t *cp;
  1454. volatile pcmconf8xx_t *pcmp;
  1455. volatile sysconf8xx_t *sysp;
  1456. uint reg, mask;
  1457. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1458. udelay(10000);
  1459. immap = (immap_t *)CFG_IMMR;
  1460. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1461. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1462. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1463. /*
  1464. * Configure SIUMCR to enable PCMCIA port B
  1465. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1466. */
  1467. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1468. /* clear interrupt state, and disable interrupts */
  1469. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1470. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1471. /*
  1472. * Disable interrupts, DMA, and PCMCIA buffers
  1473. * (isolate the interface) and assert RESET signal
  1474. */
  1475. debug ("Disable PCMCIA buffers and assert RESET\n");
  1476. reg = 0;
  1477. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1478. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1479. PCMCIA_PGCRX(_slot_) = reg;
  1480. udelay(500);
  1481. /*
  1482. * Configure Ports A, B & C pins for
  1483. * 5 Volts Enable and 3 Volts enable
  1484. */
  1485. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1486. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1487. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1488. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1489. immap->im_ioport.iop_padir |= 0x0200;*/
  1490. #if 0
  1491. immap->im_ioport.iop_pbpar &= ~(0xC000);
  1492. immap->im_ioport.iop_pbdir &= ~(0xC000);
  1493. #endif
  1494. /* remove all power */
  1495. immap->im_ioport.iop_pcdat |= 0x0400;
  1496. immap->im_ioport.iop_padat |= 0x0200;
  1497. /*
  1498. * Make sure there is a card in the slot, then configure the interface.
  1499. */
  1500. udelay(10000);
  1501. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1502. __LINE__,__FUNCTION__,
  1503. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1504. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1505. printf (" No Card found\n");
  1506. return (1);
  1507. }
  1508. /*
  1509. * Power On.
  1510. */
  1511. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1512. reg = pcmp->pcmc_pipr;
  1513. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1514. reg,
  1515. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1516. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1517. if ((reg & mask) == mask) {
  1518. immap->im_ioport.iop_pcdat &= ~(0x4000);
  1519. puts (" 5.0V card found: ");
  1520. } else {
  1521. immap->im_ioport.iop_padat &= ~(0x0002);
  1522. puts (" 3.3V card found: ");
  1523. }
  1524. immap->im_ioport.iop_pcdir |= 0x0400;
  1525. immap->im_ioport.iop_padir |= 0x0200;
  1526. #if 0
  1527. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1528. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1529. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1530. udelay(500000);
  1531. #endif
  1532. debug ("Enable PCMCIA buffers and stop RESET\n");
  1533. reg = PCMCIA_PGCRX(_slot_);
  1534. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1535. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1536. PCMCIA_PGCRX(_slot_) = reg;
  1537. udelay(250000); /* some cards need >150 ms to come up :-( */
  1538. debug ("# hardware_enable done\n");
  1539. return (0);
  1540. }
  1541. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1542. static int hardware_disable(int slot)
  1543. {
  1544. volatile immap_t *immap;
  1545. volatile pcmconf8xx_t *pcmp;
  1546. u_long reg;
  1547. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1548. immap = (immap_t *)CFG_IMMR;
  1549. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1550. /* remove all power */
  1551. immap->im_ioport.iop_pcdat |= 0x0400;
  1552. immap->im_ioport.iop_padat |= 0x0200;
  1553. /* Configure PCMCIA General Control Register */
  1554. debug ("Disable PCMCIA buffers and assert RESET\n");
  1555. reg = 0;
  1556. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1557. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1558. PCMCIA_PGCRX(_slot_) = reg;
  1559. udelay(10000);
  1560. return (0);
  1561. }
  1562. #endif /* CFG_CMD_PCMCIA */
  1563. static int voltage_set(int slot, int vcc, int vpp)
  1564. {
  1565. volatile immap_t *immap;
  1566. volatile pcmconf8xx_t *pcmp;
  1567. u_long reg;
  1568. debug ("voltage_set: "
  1569. PCMCIA_BOARD_MSG
  1570. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1571. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1572. immap = (immap_t *)CFG_IMMR;
  1573. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1574. /*
  1575. * Disable PCMCIA buffers (isolate the interface)
  1576. * and assert RESET signal
  1577. */
  1578. debug ("Disable PCMCIA buffers and assert RESET\n");
  1579. reg = PCMCIA_PGCRX(_slot_);
  1580. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1581. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1582. PCMCIA_PGCRX(_slot_) = reg;
  1583. udelay(500);
  1584. /*
  1585. * Configure Ports A & C pins for
  1586. * 5 Volts Enable and 3 Volts enable,
  1587. * Turn off all power
  1588. */
  1589. debug ("PCMCIA power OFF\n");
  1590. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1591. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1592. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1593. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1594. immap->im_ioport.iop_padir |= 0x0200;*/
  1595. immap->im_ioport.iop_pcdat |= 0x0400;
  1596. immap->im_ioport.iop_padat |= 0x0200;
  1597. reg = 0;
  1598. switch(vcc) {
  1599. case 0: break;
  1600. case 33: reg |= 0x0200; break;
  1601. case 50: reg |= 0x0400; break;
  1602. default: goto done;
  1603. }
  1604. /* Checking supported voltages */
  1605. debug ("PIPR: 0x%x --> %s\n",
  1606. pcmp->pcmc_pipr,
  1607. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1608. if (reg & 0x0200)
  1609. immap->im_ioport.iop_pcdat &= !reg;
  1610. if (reg & 0x0400)
  1611. immap->im_ioport.iop_padat &= !reg;
  1612. immap->im_ioport.iop_pcdir |= 0x0200;
  1613. immap->im_ioport.iop_padir |= 0x0400;
  1614. if (reg) {
  1615. debug ("PCMCIA powered at %sV\n",
  1616. (reg&0x0400) ? "5.0" : "3.3");
  1617. } else {
  1618. debug ("PCMCIA powered down\n");
  1619. }
  1620. done:
  1621. debug ("Enable PCMCIA buffers and stop RESET\n");
  1622. reg = PCMCIA_PGCRX(_slot_);
  1623. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1624. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1625. PCMCIA_PGCRX(_slot_) = reg;
  1626. udelay(500);
  1627. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1628. slot+'A');
  1629. return (0);
  1630. }
  1631. #endif /* R360MPI */
  1632. /* -------------------------------------------------------------------- */
  1633. /* KUP4K Board */
  1634. /* -------------------------------------------------------------------- */
  1635. #if defined(CONFIG_KUP4K)
  1636. #define PCMCIA_BOARD_MSG "KUP4K"
  1637. #define KUP4K_PCMCIA_B_3V3 (0x00020000)
  1638. static int hardware_enable(int slot)
  1639. {
  1640. volatile immap_t *immap;
  1641. volatile cpm8xx_t *cp;
  1642. volatile pcmconf8xx_t *pcmp;
  1643. volatile sysconf8xx_t *sysp;
  1644. uint reg, mask;
  1645. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1646. udelay(10000);
  1647. immap = (immap_t *)CFG_IMMR;
  1648. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1649. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1650. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1651. /*
  1652. * Configure SIUMCR to enable PCMCIA port B
  1653. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1654. */
  1655. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1656. /* clear interrupt state, and disable interrupts */
  1657. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  1658. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  1659. /*
  1660. * Disable interrupts, DMA, and PCMCIA buffers
  1661. * (isolate the interface) and assert RESET signal
  1662. */
  1663. debug ("Disable PCMCIA buffers and assert RESET\n");
  1664. reg = 0;
  1665. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1666. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1667. PCMCIA_PGCRX(slot) = reg;
  1668. udelay(2500);
  1669. /*
  1670. * Configure Port B pins for
  1671. * 3 Volts enable
  1672. */
  1673. if (slot) { /* Slot A is built-in */
  1674. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  1675. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  1676. /* remove all power */
  1677. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  1678. }
  1679. /*
  1680. * Make sure there is a card in the slot, then configure the interface.
  1681. */
  1682. udelay(10000);
  1683. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1684. __LINE__,__FUNCTION__,
  1685. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1686. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1687. printf (" No Card found\n");
  1688. return (1);
  1689. }
  1690. /*
  1691. * Power On.
  1692. */
  1693. printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
  1694. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1695. reg = pcmp->pcmc_pipr;
  1696. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1697. reg,
  1698. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1699. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1700. if ((reg & mask) == mask) {
  1701. puts (" 5.0V card found: NOT SUPPORTED !!!\n");
  1702. } else {
  1703. if(slot)
  1704. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  1705. puts (" 3.3V card found: ");
  1706. }
  1707. #if 0
  1708. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1709. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1710. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1711. udelay(500000);
  1712. #endif
  1713. debug ("Enable PCMCIA buffers and stop RESET\n");
  1714. reg = PCMCIA_PGCRX(slot);
  1715. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1716. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1717. PCMCIA_PGCRX(slot) = reg;
  1718. udelay(250000); /* some cards need >150 ms to come up :-( */
  1719. debug ("# hardware_enable done\n");
  1720. return (0);
  1721. }
  1722. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1723. static int hardware_disable(int slot)
  1724. {
  1725. volatile immap_t *immap;
  1726. volatile cpm8xx_t *cp;
  1727. volatile pcmconf8xx_t *pcmp;
  1728. u_long reg;
  1729. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1730. immap = (immap_t *)CFG_IMMR;
  1731. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1732. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1733. /* remove all power */
  1734. if (slot)
  1735. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
  1736. /* Configure PCMCIA General Control Register */
  1737. debug ("Disable PCMCIA buffers and assert RESET\n");
  1738. reg = 0;
  1739. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1740. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1741. PCMCIA_PGCRX(slot) = reg;
  1742. udelay(10000);
  1743. return (0);
  1744. }
  1745. #endif /* CFG_CMD_PCMCIA */
  1746. static int voltage_set(int slot, int vcc, int vpp)
  1747. {
  1748. volatile immap_t *immap;
  1749. volatile cpm8xx_t *cp;
  1750. volatile pcmconf8xx_t *pcmp;
  1751. u_long reg;
  1752. debug ("voltage_set: " \
  1753. PCMCIA_BOARD_MSG \
  1754. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1755. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1756. if (!slot) /* Slot A is not configurable */
  1757. return 0;
  1758. immap = (immap_t *)CFG_IMMR;
  1759. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1760. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1761. /*
  1762. * Disable PCMCIA buffers (isolate the interface)
  1763. * and assert RESET signal
  1764. */
  1765. debug ("Disable PCMCIA buffers and assert RESET\n");
  1766. reg = PCMCIA_PGCRX(slot);
  1767. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1768. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1769. PCMCIA_PGCRX(slot) = reg;
  1770. udelay(500);
  1771. debug ("PCMCIA power OFF\n");
  1772. /*
  1773. * Configure Port B pins for
  1774. * 3 Volts enable
  1775. */
  1776. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  1777. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  1778. /* remove all power */
  1779. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  1780. switch(vcc) {
  1781. case 0: break;
  1782. case 33:
  1783. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  1784. debug ("PCMCIA powered at 3.3V\n");
  1785. break;
  1786. case 50:
  1787. debug ("PCMCIA: 5Volt vcc not supported\n");
  1788. break;
  1789. default:
  1790. puts("PCMCIA: vcc not supported");
  1791. break;
  1792. }
  1793. udelay(10000);
  1794. /* Checking supported voltages */
  1795. debug ("PIPR: 0x%x --> %s\n",
  1796. pcmp->pcmc_pipr,
  1797. (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
  1798. ? "only 5 V --> NOT SUPPORTED"
  1799. : "can do 3.3V");
  1800. debug ("Enable PCMCIA buffers and stop RESET\n");
  1801. reg = PCMCIA_PGCRX(slot);
  1802. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1803. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1804. PCMCIA_PGCRX(slot) = reg;
  1805. udelay(500);
  1806. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1807. slot+'A');
  1808. return (0);
  1809. }
  1810. #endif /* KUP4K */
  1811. /* -------------------------------------------------------------------- */
  1812. /* End of Board Specific Stuff */
  1813. /* -------------------------------------------------------------------- */
  1814. /* -------------------------------------------------------------------- */
  1815. /* MPC8xx Specific Stuff - should go to MPC8xx directory */
  1816. /* -------------------------------------------------------------------- */
  1817. /*
  1818. * Search this table to see if the windowsize is
  1819. * supported...
  1820. */
  1821. #define M8XX_SIZES_NO 32
  1822. static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
  1823. { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
  1824. 0x00000080, 0x00000040, 0x00000010, 0x00000020,
  1825. 0x00008000, 0x00004000, 0x00001000, 0x00002000,
  1826. 0x00000100, 0x00000200, 0x00000800, 0x00000400,
  1827. 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  1828. 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
  1829. 0x00010000, 0x00020000, 0x00080000, 0x00040000,
  1830. 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
  1831. /* -------------------------------------------------------------------- */
  1832. static u_int m8xx_get_graycode(u_int size)
  1833. {
  1834. u_int k;
  1835. for (k = 0; k < M8XX_SIZES_NO; k++) {
  1836. if(m8xx_size_to_gray[k] == size)
  1837. break;
  1838. }
  1839. if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
  1840. k = -1;
  1841. return k;
  1842. }
  1843. /* -------------------------------------------------------------------- */
  1844. #if 0
  1845. static u_int m8xx_get_speed(u_int ns, u_int is_io)
  1846. {
  1847. u_int reg, clocks, psst, psl, psht;
  1848. if(!ns) {
  1849. /*
  1850. * We get called with IO maps setup to 0ns
  1851. * if not specified by the user.
  1852. * They should be 255ns.
  1853. */
  1854. if(is_io)
  1855. ns = 255;
  1856. else
  1857. ns = 100; /* fast memory if 0 */
  1858. }
  1859. /*
  1860. * In PSST, PSL, PSHT fields we tell the controller
  1861. * timing parameters in CLKOUT clock cycles.
  1862. * CLKOUT is the same as GCLK2_50.
  1863. */
  1864. /* how we want to adjust the timing - in percent */
  1865. #define ADJ 180 /* 80 % longer accesstime - to be sure */
  1866. clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
  1867. clocks = (clocks * ADJ) / (100*1000);
  1868. if(clocks >= PCMCIA_BMT_LIMIT) {
  1869. DEBUG(0, "Max access time limit reached\n");
  1870. clocks = PCMCIA_BMT_LIMIT-1;
  1871. }
  1872. psst = clocks / 7; /* setup time */
  1873. psht = clocks / 7; /* hold time */
  1874. psl = (clocks * 5) / 7; /* strobe length */
  1875. psst += clocks - (psst + psht + psl);
  1876. reg = psst << 12;
  1877. reg |= psl << 7;
  1878. reg |= psht << 16;
  1879. return reg;
  1880. }
  1881. #endif
  1882. /* -------------------------------------------------------------------- */
  1883. #ifdef CONFIG_IDE_8xx_PCCARD
  1884. static void print_funcid (int func)
  1885. {
  1886. puts (indent);
  1887. switch (func) {
  1888. case CISTPL_FUNCID_MULTI:
  1889. puts (" Multi-Function");
  1890. break;
  1891. case CISTPL_FUNCID_MEMORY:
  1892. puts (" Memory");
  1893. break;
  1894. case CISTPL_FUNCID_SERIAL:
  1895. puts (" Serial Port");
  1896. break;
  1897. case CISTPL_FUNCID_PARALLEL:
  1898. puts (" Parallel Port");
  1899. break;
  1900. case CISTPL_FUNCID_FIXED:
  1901. puts (" Fixed Disk");
  1902. break;
  1903. case CISTPL_FUNCID_VIDEO:
  1904. puts (" Video Adapter");
  1905. break;
  1906. case CISTPL_FUNCID_NETWORK:
  1907. puts (" Network Adapter");
  1908. break;
  1909. case CISTPL_FUNCID_AIMS:
  1910. puts (" AIMS Card");
  1911. break;
  1912. case CISTPL_FUNCID_SCSI:
  1913. puts (" SCSI Adapter");
  1914. break;
  1915. default:
  1916. puts (" Unknown");
  1917. break;
  1918. }
  1919. puts (" Card\n");
  1920. }
  1921. #endif /* CONFIG_IDE_8xx_PCCARD */
  1922. /* -------------------------------------------------------------------- */
  1923. #ifdef CONFIG_IDE_8xx_PCCARD
  1924. static void print_fixed (volatile uchar *p)
  1925. {
  1926. if (p == NULL)
  1927. return;
  1928. puts(indent);
  1929. switch (*p) {
  1930. case CISTPL_FUNCE_IDE_IFACE:
  1931. { uchar iface = *(p+2);
  1932. puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
  1933. puts (" interface ");
  1934. break;
  1935. }
  1936. case CISTPL_FUNCE_IDE_MASTER:
  1937. case CISTPL_FUNCE_IDE_SLAVE:
  1938. { uchar f1 = *(p+2);
  1939. uchar f2 = *(p+4);
  1940. puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
  1941. if (f1 & CISTPL_IDE_UNIQUE)
  1942. puts (" [unique]");
  1943. puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
  1944. if (f2 & CISTPL_IDE_HAS_SLEEP)
  1945. puts (" [sleep]");
  1946. if (f2 & CISTPL_IDE_HAS_STANDBY)
  1947. puts (" [standby]");
  1948. if (f2 & CISTPL_IDE_HAS_IDLE)
  1949. puts (" [idle]");
  1950. if (f2 & CISTPL_IDE_LOW_POWER)
  1951. puts (" [low power]");
  1952. if (f2 & CISTPL_IDE_REG_INHIBIT)
  1953. puts (" [reg inhibit]");
  1954. if (f2 & CISTPL_IDE_HAS_INDEX)
  1955. puts (" [index]");
  1956. if (f2 & CISTPL_IDE_IOIS16)
  1957. puts (" [IOis16]");
  1958. break;
  1959. }
  1960. }
  1961. putc ('\n');
  1962. }
  1963. #endif /* CONFIG_IDE_8xx_PCCARD */
  1964. /* -------------------------------------------------------------------- */
  1965. #ifdef CONFIG_IDE_8xx_PCCARD
  1966. #define MAX_IDENT_CHARS 64
  1967. #define MAX_IDENT_FIELDS 4
  1968. static uchar *known_cards[] = {
  1969. "ARGOSY PnPIDE D5",
  1970. NULL
  1971. };
  1972. static int identify (volatile uchar *p)
  1973. {
  1974. uchar id_str[MAX_IDENT_CHARS];
  1975. uchar data;
  1976. uchar *t;
  1977. uchar **card;
  1978. int i, done;
  1979. if (p == NULL)
  1980. return (0); /* Don't know */
  1981. t = id_str;
  1982. done =0;
  1983. for (i=0; i<=4 && !done; ++i, p+=2) {
  1984. while ((data = *p) != '\0') {
  1985. if (data == 0xFF) {
  1986. done = 1;
  1987. break;
  1988. }
  1989. *t++ = data;
  1990. if (t == &id_str[MAX_IDENT_CHARS-1]) {
  1991. done = 1;
  1992. break;
  1993. }
  1994. p += 2;
  1995. }
  1996. if (!done)
  1997. *t++ = ' ';
  1998. }
  1999. *t = '\0';
  2000. while (--t > id_str) {
  2001. if (*t == ' ')
  2002. *t = '\0';
  2003. else
  2004. break;
  2005. }
  2006. puts (id_str);
  2007. putc ('\n');
  2008. for (card=known_cards; *card; ++card) {
  2009. debug ("## Compare against \"%s\"\n", *card);
  2010. if (strcmp(*card, id_str) == 0) { /* found! */
  2011. debug ("## CARD FOUND ##\n");
  2012. return (1);
  2013. }
  2014. }
  2015. return (0); /* don't know */
  2016. }
  2017. #endif /* CONFIG_IDE_8xx_PCCARD */
  2018. /* -------------------------------------------------------------------- */
  2019. #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */