cmd_pcmcia.c 59 KB

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