cmd_pcmcia.c 59 KB

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