cmd_pcmcia.c 60 KB

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