cmd_pcmcia.c 60 KB

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