cmd_pcmcia.c 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488
  1. /*
  2. * (C) Copyright 2000-2006
  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. #if defined(CONFIG_8xx)
  59. #include <mpc8xx.h>
  60. #endif
  61. #if defined(CONFIG_LWMON)
  62. #include <i2c.h>
  63. #endif
  64. #ifdef CONFIG_PXA_PCMCIA
  65. #include <asm/arch/pxa-regs.h>
  66. #endif
  67. #include <asm/io.h>
  68. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
  69. ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
  70. int pcmcia_on (void);
  71. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  72. static int pcmcia_off (void);
  73. #endif
  74. #ifdef CONFIG_I82365
  75. extern int i82365_init (void);
  76. extern void i82365_exit (void);
  77. #else /* ! CONFIG_I82365 */
  78. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  79. static int hardware_disable(int slot);
  80. #endif
  81. static int hardware_enable (int slot);
  82. static int voltage_set(int slot, int vcc, int vpp);
  83. #if (! defined(CONFIG_I82365)) && (! defined(CONFIG_PXA_PCMCIA))
  84. static u_int m8xx_get_graycode(u_int size);
  85. #endif /* !CONFIG_I82365, !CONFIG_PXA_PCMCIA */
  86. #if 0
  87. static u_int m8xx_get_speed(u_int ns, u_int is_io);
  88. #endif
  89. /* -------------------------------------------------------------------- */
  90. #ifndef CONFIG_PXA_PCMCIA
  91. /* look up table for pgcrx registers */
  92. static u_int *pcmcia_pgcrx[2] = {
  93. &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
  94. &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
  95. };
  96. #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
  97. #endif /* CONFIG_PXA_PCMCIA */
  98. #endif /* CONFIG_I82365 */
  99. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  100. static void print_funcid (int func);
  101. static void print_fixed (volatile uchar *p);
  102. static int identify (volatile uchar *p);
  103. static int check_ide_device (int slot);
  104. #endif /* CONFIG_IDE_8xx_PCCARD, CONFIG_PXA_PCMCIA */
  105. const char *indent = "\t ";
  106. /* -------------------------------------------------------------------- */
  107. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  108. int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  109. {
  110. int rcode = 0;
  111. if (argc != 2) {
  112. printf ("Usage: pinit {on | off}\n");
  113. return 1;
  114. }
  115. if (strcmp(argv[1],"on") == 0) {
  116. rcode = pcmcia_on ();
  117. } else if (strcmp(argv[1],"off") == 0) {
  118. rcode = pcmcia_off ();
  119. } else {
  120. printf ("Usage: pinit {on | off}\n");
  121. return 1;
  122. }
  123. return rcode;
  124. }
  125. #endif /* CFG_CMD_PCMCIA */
  126. /* -------------------------------------------------------------------- */
  127. #ifdef CONFIG_I82365
  128. int pcmcia_on (void)
  129. {
  130. u_int rc;
  131. debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  132. rc = i82365_init();
  133. if (rc == 0) {
  134. rc = check_ide_device(0);
  135. }
  136. return (rc);
  137. }
  138. #else
  139. #ifndef CONFIG_PXA_PCMCIA
  140. #ifdef CONFIG_HMI10
  141. # define HMI10_FRAM_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(2) | PCMCIA_SL(4))
  142. #endif
  143. #if defined(CONFIG_LWMON) || defined(CONFIG_NSCU)
  144. # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
  145. #else
  146. # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
  147. #endif
  148. int pcmcia_on (void)
  149. {
  150. int i;
  151. u_long reg, base;
  152. pcmcia_win_t *win;
  153. u_int slotbit;
  154. u_int rc, slot;
  155. debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  156. /* intialize the fixed memory windows */
  157. win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
  158. base = CFG_PCMCIA_MEM_ADDR;
  159. if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
  160. printf ("Cannot set window size to 0x%08x\n",
  161. CFG_PCMCIA_MEM_SIZE);
  162. return (1);
  163. }
  164. slotbit = PCMCIA_SLOT_x;
  165. for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
  166. win->br = base;
  167. #if (PCMCIA_SOCKETS_NO == 2)
  168. if (i == 4) /* Another slot starting from win 4 */
  169. slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
  170. #endif
  171. switch (i) {
  172. #ifdef CONFIG_IDE_8xx_PCCARD
  173. case 4:
  174. #ifdef CONFIG_HMI10
  175. { /* map FRAM area */
  176. win->or = ( PCMCIA_BSIZE_256K
  177. | PCMCIA_PPS_8
  178. | PCMCIA_PRS_ATTR
  179. | slotbit
  180. | PCMCIA_PV
  181. | HMI10_FRAM_TIMING );
  182. break;
  183. }
  184. #endif
  185. case 0: { /* map attribute memory */
  186. win->or = ( PCMCIA_BSIZE_64M
  187. | PCMCIA_PPS_8
  188. | PCMCIA_PRS_ATTR
  189. | slotbit
  190. | PCMCIA_PV
  191. | CFG_PCMCIA_TIMING );
  192. break;
  193. }
  194. case 5:
  195. case 1: { /* map I/O window for data reg */
  196. win->or = ( PCMCIA_BSIZE_1K
  197. | PCMCIA_PPS_16
  198. | PCMCIA_PRS_IO
  199. | slotbit
  200. | PCMCIA_PV
  201. | CFG_PCMCIA_TIMING );
  202. break;
  203. }
  204. case 6:
  205. case 2: { /* map I/O window for cmd/ctrl reg block */
  206. win->or = ( PCMCIA_BSIZE_1K
  207. | PCMCIA_PPS_8
  208. | PCMCIA_PRS_IO
  209. | slotbit
  210. | PCMCIA_PV
  211. | CFG_PCMCIA_TIMING );
  212. break;
  213. }
  214. #endif /* CONFIG_IDE_8xx_PCCARD */
  215. #ifdef CONFIG_HMI10
  216. case 3: { /* map I/O window for 4xUART data/ctrl */
  217. win->br += 0x40000;
  218. win->or = ( PCMCIA_BSIZE_256K
  219. | PCMCIA_PPS_8
  220. | PCMCIA_PRS_IO
  221. | slotbit
  222. | PCMCIA_PV
  223. | CFG_PCMCIA_TIMING );
  224. break;
  225. }
  226. #endif /* CONFIG_HMI10 */
  227. default: /* set to not valid */
  228. win->or = 0;
  229. break;
  230. }
  231. debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
  232. i, win->br, win->or);
  233. base += CFG_PCMCIA_MEM_SIZE;
  234. ++win;
  235. }
  236. for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
  237. /* turn off voltage */
  238. if ((rc = voltage_set(slot, 0, 0)))
  239. continue;
  240. /* Enable external hardware */
  241. if ((rc = hardware_enable(slot)))
  242. continue;
  243. #ifdef CONFIG_IDE_8xx_PCCARD
  244. if ((rc = check_ide_device(i)))
  245. continue;
  246. #endif
  247. }
  248. return (rc);
  249. }
  250. #endif /* CONFIG_PXA_PCMCIA */
  251. #endif /* CONFIG_I82365 */
  252. #ifdef CONFIG_PXA_PCMCIA
  253. static int hardware_enable (int slot)
  254. {
  255. return 0; /* No hardware to enable */
  256. }
  257. static int hardware_disable(int slot)
  258. {
  259. return 0; /* No hardware to disable */
  260. }
  261. static int voltage_set(int slot, int vcc, int vpp)
  262. {
  263. return 0;
  264. }
  265. void msWait(unsigned msVal)
  266. {
  267. udelay(msVal*1000);
  268. }
  269. int pcmcia_on (void)
  270. {
  271. unsigned int reg_arr[] = {
  272. 0x48000028, CFG_MCMEM0_VAL,
  273. 0x4800002c, CFG_MCMEM1_VAL,
  274. 0x48000030, CFG_MCATT0_VAL,
  275. 0x48000034, CFG_MCATT1_VAL,
  276. 0x48000038, CFG_MCIO0_VAL,
  277. 0x4800003c, CFG_MCIO1_VAL,
  278. 0, 0
  279. };
  280. int i, rc;
  281. #ifdef CONFIG_EXADRON1
  282. int cardDetect;
  283. volatile unsigned int *v_pBCRReg =
  284. (volatile unsigned int *) 0x08000000;
  285. #endif
  286. debug ("%s\n", __FUNCTION__);
  287. i = 0;
  288. while (reg_arr[i])
  289. *((volatile unsigned int *) reg_arr[i++]) |= reg_arr[i++];
  290. udelay (1000);
  291. debug ("%s: programmed mem controller \n", __FUNCTION__);
  292. #ifdef CONFIG_EXADRON1
  293. /*define useful BCR masks */
  294. #define BCR_CF_INIT_VAL 0x00007230
  295. #define BCR_CF_PWRON_BUSOFF_RESETOFF_VAL 0x00007231
  296. #define BCR_CF_PWRON_BUSOFF_RESETON_VAL 0x00007233
  297. #define BCR_CF_PWRON_BUSON_RESETON_VAL 0x00007213
  298. #define BCR_CF_PWRON_BUSON_RESETOFF_VAL 0x00007211
  299. /* we see from the GPIO bit if the card is present */
  300. cardDetect = !(GPLR0 & GPIO_bit (14));
  301. if (cardDetect) {
  302. printf ("No PCMCIA card found!\n");
  303. }
  304. /* reset the card via the BCR line */
  305. *v_pBCRReg = (unsigned) BCR_CF_INIT_VAL;
  306. msWait (500);
  307. *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSOFF_RESETOFF_VAL;
  308. msWait (500);
  309. *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSOFF_RESETON_VAL;
  310. msWait (500);
  311. *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSON_RESETON_VAL;
  312. msWait (500);
  313. *v_pBCRReg = (unsigned) BCR_CF_PWRON_BUSON_RESETOFF_VAL;
  314. msWait (1500);
  315. /* enable address bus */
  316. GPCR1 = 0x01;
  317. /* and the first CF slot */
  318. MECR = 0x00000002;
  319. #endif /* EXADRON 1 */
  320. rc = check_ide_device (0); /* use just slot 0 */
  321. return rc;
  322. }
  323. #endif /* CONFIG_PXA_PCMCIA */
  324. /* -------------------------------------------------------------------- */
  325. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  326. #ifdef CONFIG_I82365
  327. static int pcmcia_off (void)
  328. {
  329. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  330. i82365_exit();
  331. return 0;
  332. }
  333. #else
  334. #ifndef CONFIG_PXA_PCMCIA
  335. static int pcmcia_off (void)
  336. {
  337. int i;
  338. pcmcia_win_t *win;
  339. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  340. /* clear interrupt state, and disable interrupts */
  341. ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
  342. ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
  343. /* turn off interrupt and disable CxOE */
  344. PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
  345. /* turn off memory windows */
  346. win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
  347. for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
  348. /* disable memory window */
  349. win->or = 0;
  350. ++win;
  351. }
  352. /* turn off voltage */
  353. voltage_set(_slot_, 0, 0);
  354. /* disable external hardware */
  355. printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
  356. hardware_disable(_slot_);
  357. return 0;
  358. }
  359. #endif /* CONFIG_PXA_PCMCIA */
  360. #endif /* CONFIG_I82365 */
  361. #ifdef CONFIG_PXA_PCMCIA
  362. static int pcmcia_off (void)
  363. {
  364. return 0;
  365. }
  366. #endif
  367. #endif /* CFG_CMD_PCMCIA */
  368. /* -------------------------------------------------------------------- */
  369. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  370. #define MAX_TUPEL_SZ 512
  371. #define MAX_FEATURES 4
  372. int ide_devices_found;
  373. static int check_ide_device (int slot)
  374. {
  375. volatile uchar *ident = NULL;
  376. volatile uchar *feature_p[MAX_FEATURES];
  377. volatile uchar *p, *start, *addr;
  378. int n_features = 0;
  379. uchar func_id = ~0;
  380. uchar code, len;
  381. ushort config_base = 0;
  382. int found = 0;
  383. int i;
  384. addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
  385. CFG_PCMCIA_MEM_SIZE * (slot * 4));
  386. debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
  387. start = p = (volatile uchar *) addr;
  388. while ((p - start) < MAX_TUPEL_SZ) {
  389. code = *p; p += 2;
  390. if (code == 0xFF) { /* End of chain */
  391. break;
  392. }
  393. len = *p; p += 2;
  394. #if defined(DEBUG) && (DEBUG > 1)
  395. { volatile uchar *q = p;
  396. printf ("\nTuple code %02x length %d\n\tData:",
  397. code, len);
  398. for (i = 0; i < len; ++i) {
  399. printf (" %02x", *q);
  400. q+= 2;
  401. }
  402. }
  403. #endif /* DEBUG */
  404. switch (code) {
  405. case CISTPL_VERS_1:
  406. ident = p + 4;
  407. break;
  408. case CISTPL_FUNCID:
  409. /* Fix for broken SanDisk which may have 0x80 bit set */
  410. func_id = *p & 0x7F;
  411. break;
  412. case CISTPL_FUNCE:
  413. if (n_features < MAX_FEATURES)
  414. feature_p[n_features++] = p;
  415. break;
  416. case CISTPL_CONFIG:
  417. config_base = (*(p+6) << 8) + (*(p+4));
  418. debug ("\n## Config_base = %04x ###\n", config_base);
  419. default:
  420. break;
  421. }
  422. p += 2 * len;
  423. }
  424. found = identify (ident);
  425. if (func_id != ((uchar)~0)) {
  426. print_funcid (func_id);
  427. if (func_id == CISTPL_FUNCID_FIXED)
  428. found = 1;
  429. else
  430. return (1); /* no disk drive */
  431. }
  432. for (i=0; i<n_features; ++i) {
  433. print_fixed (feature_p[i]);
  434. }
  435. if (!found) {
  436. printf ("unknown card type\n");
  437. return (1);
  438. }
  439. ide_devices_found |= (1 << slot);
  440. #if CONFIG_CPC45
  441. #else
  442. /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
  443. *((uchar *)(addr + config_base)) = 1;
  444. #endif
  445. #if 0
  446. printf("\n## Config_base = %04x ###\n", config_base);
  447. printf("Configuration Option Register: %02x @ %x\n", readb(addr + config_base), addr + config_base);
  448. printf("Card Configuration and Status Register: %02x\n", readb(addr + config_base + 2));
  449. printf("Pin Replacement Register Register: %02x\n", readb(addr + config_base + 4));
  450. printf("Socket and Copy Register: %02x\n", readb(addr + config_base + 6));
  451. #endif
  452. return (0);
  453. }
  454. #endif /* CONFIG_IDE_8xx_PCCARD */
  455. /* -------------------------------------------------------------------- */
  456. /* -------------------------------------------------------------------- */
  457. /* board specific stuff: */
  458. /* voltage_set(), hardware_enable() and hardware_disable() */
  459. /* -------------------------------------------------------------------- */
  460. /* -------------------------------------------------------------------- */
  461. /* RPX Boards from Embedded Planet */
  462. /* -------------------------------------------------------------------- */
  463. #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
  464. /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
  465. * SYPCR is write once only, therefore must the slowest memory be faster
  466. * than the bus monitor or we will get a machine check due to the bus timeout.
  467. */
  468. #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
  469. #undef PCMCIA_BMT_LIMIT
  470. #define PCMCIA_BMT_LIMIT (6*8)
  471. static int voltage_set(int slot, int vcc, int vpp)
  472. {
  473. u_long reg = 0;
  474. switch(vcc) {
  475. case 0: break;
  476. case 33: reg |= BCSR1_PCVCTL4; break;
  477. case 50: reg |= BCSR1_PCVCTL5; break;
  478. default: return 1;
  479. }
  480. switch(vpp) {
  481. case 0: break;
  482. case 33:
  483. case 50:
  484. if(vcc == vpp)
  485. reg |= BCSR1_PCVCTL6;
  486. else
  487. return 1;
  488. break;
  489. case 120:
  490. reg |= BCSR1_PCVCTL7;
  491. default: return 1;
  492. }
  493. if(vcc == 120)
  494. return 1;
  495. /* first, turn off all power */
  496. *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
  497. | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
  498. /* enable new powersettings */
  499. *((uint *)RPX_CSR_ADDR) |= reg;
  500. return 0;
  501. }
  502. #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
  503. static int hardware_enable (int slot)
  504. {
  505. return 0; /* No hardware to enable */
  506. }
  507. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  508. static int hardware_disable(int slot)
  509. {
  510. return 0; /* No hardware to disable */
  511. }
  512. #endif /* CFG_CMD_PCMCIA */
  513. #endif /* CONFIG_RPXCLASSIC */
  514. /* -------------------------------------------------------------------- */
  515. /* (F)ADS Boards from Motorola */
  516. /* -------------------------------------------------------------------- */
  517. #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
  518. #ifdef CONFIG_ADS
  519. #define PCMCIA_BOARD_MSG "ADS"
  520. #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
  521. #else
  522. #define PCMCIA_BOARD_MSG "FADS"
  523. #endif
  524. static int voltage_set(int slot, int vcc, int vpp)
  525. {
  526. u_long reg = 0;
  527. switch(vpp) {
  528. case 0: reg = 0; break;
  529. case 50: reg = 1; break;
  530. case 120: reg = 2; break;
  531. default: return 1;
  532. }
  533. switch(vcc) {
  534. case 0: reg = 0; break;
  535. #ifdef CONFIG_ADS
  536. case 50: reg = BCSR1_PCCVCCON; break;
  537. #endif
  538. #ifdef CONFIG_FADS
  539. case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
  540. case 50: reg = BCSR1_PCCVCC1; break;
  541. #endif
  542. default: return 1;
  543. }
  544. /* first, turn off all power */
  545. #ifdef CONFIG_ADS
  546. *((uint *)BCSR1) |= BCSR1_PCCVCCON;
  547. #endif
  548. #ifdef CONFIG_FADS
  549. *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
  550. #endif
  551. *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
  552. /* enable new powersettings */
  553. #ifdef CONFIG_ADS
  554. *((uint *)BCSR1) &= ~reg;
  555. #endif
  556. #ifdef CONFIG_FADS
  557. *((uint *)BCSR1) |= reg;
  558. #endif
  559. *((uint *)BCSR1) |= reg << 20;
  560. return 0;
  561. }
  562. #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
  563. static int hardware_enable(int slot)
  564. {
  565. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  566. return 0;
  567. }
  568. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  569. static int hardware_disable(int slot)
  570. {
  571. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  572. return 0;
  573. }
  574. #endif /* CFG_CMD_PCMCIA */
  575. #endif /* (F)ADS */
  576. /* -------------------------------------------------------------------- */
  577. /* TQM8xxL Boards by TQ Components */
  578. /* SC8xx Boards by SinoVee Microsystems */
  579. /* -------------------------------------------------------------------- */
  580. #if (defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)) \
  581. && !defined(CONFIG_VIRTLAB2)
  582. #if defined(CONFIG_TQM8xxL)
  583. #define PCMCIA_BOARD_MSG "TQM8xxL"
  584. #endif
  585. #if defined(CONFIG_SVM_SC8xx)
  586. #define PCMCIA_BOARD_MSG "SC8xx"
  587. #endif
  588. static int hardware_enable(int slot)
  589. {
  590. volatile immap_t *immap;
  591. volatile cpm8xx_t *cp;
  592. volatile pcmconf8xx_t *pcmp;
  593. volatile sysconf8xx_t *sysp;
  594. uint reg, mask;
  595. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  596. udelay(10000);
  597. immap = (immap_t *)CFG_IMMR;
  598. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  599. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  600. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  601. /*
  602. * Configure SIUMCR to enable PCMCIA port B
  603. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  604. */
  605. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  606. /* clear interrupt state, and disable interrupts */
  607. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  608. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  609. /*
  610. * Disable interrupts, DMA, and PCMCIA buffers
  611. * (isolate the interface) and assert RESET signal
  612. */
  613. debug ("Disable PCMCIA buffers and assert RESET\n");
  614. reg = 0;
  615. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  616. #ifndef NSCU_OE_INV
  617. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  618. #endif
  619. PCMCIA_PGCRX(slot) = reg;
  620. udelay(500);
  621. #ifndef CONFIG_HMI10
  622. #ifndef CONFIG_NSCU
  623. /*
  624. * Configure Port C pins for
  625. * 5 Volts Enable and 3 Volts enable
  626. */
  627. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  628. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  629. /* remove all power */
  630. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  631. #endif
  632. #else /* CONFIG_HMI10 */
  633. /*
  634. * Configure Port B pins for
  635. * 5 Volts Enable and 3 Volts enable
  636. */
  637. immap->im_cpm.cp_pbpar &= ~(0x00000300);
  638. /* remove all power */
  639. immap->im_cpm.cp_pbdat |= 0x00000300;
  640. #endif /* CONFIG_HMI10 */
  641. /*
  642. * Make sure there is a card in the slot, then configure the interface.
  643. */
  644. udelay(10000);
  645. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  646. __LINE__,__FUNCTION__,
  647. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  648. #ifndef CONFIG_HMI10
  649. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  650. #else
  651. if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
  652. #endif /* CONFIG_HMI10 */
  653. printf (" No Card found\n");
  654. return (1);
  655. }
  656. /*
  657. * Power On.
  658. */
  659. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  660. reg = pcmp->pcmc_pipr;
  661. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  662. reg,
  663. (reg&PCMCIA_VS1(slot))?"n":"ff",
  664. (reg&PCMCIA_VS2(slot))?"n":"ff");
  665. #ifndef CONFIG_NSCU
  666. if ((reg & mask) == mask) {
  667. #ifndef CONFIG_HMI10
  668. immap->im_ioport.iop_pcdat |= 0x0004;
  669. #else
  670. immap->im_cpm.cp_pbdat &= ~(0x0000100);
  671. #endif /* CONFIG_HMI10 */
  672. puts (" 5.0V card found: ");
  673. } else {
  674. #ifndef CONFIG_HMI10
  675. immap->im_ioport.iop_pcdat |= 0x0002;
  676. #else
  677. immap->im_cpm.cp_pbdat &= ~(0x0000200);
  678. #endif /* CONFIG_HMI10 */
  679. puts (" 3.3V card found: ");
  680. }
  681. #ifndef CONFIG_HMI10
  682. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  683. #else
  684. immap->im_cpm.cp_pbdir |= 0x00000300;
  685. #endif /* CONFIG_HMI10 */
  686. #else
  687. if ((reg & mask) == mask) {
  688. puts (" 5.0V card found: ");
  689. } else {
  690. puts (" 3.3V card found: ");
  691. }
  692. #endif
  693. #if 0
  694. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  695. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  696. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  697. udelay(500000);
  698. #endif
  699. udelay(1000);
  700. debug ("Enable PCMCIA buffers and stop RESET\n");
  701. reg = PCMCIA_PGCRX(slot);
  702. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  703. #ifndef NSCU_OE_INV
  704. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  705. #else
  706. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  707. #endif
  708. PCMCIA_PGCRX(slot) = reg;
  709. udelay(250000); /* some cards need >150 ms to come up :-( */
  710. debug ("# hardware_enable done\n");
  711. return (0);
  712. }
  713. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  714. static int hardware_disable(int slot)
  715. {
  716. volatile immap_t *immap;
  717. volatile pcmconf8xx_t *pcmp;
  718. u_long reg;
  719. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  720. immap = (immap_t *)CFG_IMMR;
  721. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  722. #ifndef CONFIG_HMI10
  723. #ifndef CONFIG_NSCU
  724. /* remove all power */
  725. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  726. #endif
  727. #else /* CONFIG_HMI10 */
  728. immap->im_cpm.cp_pbdat |= 0x00000300;
  729. #endif /* CONFIG_HMI10 */
  730. debug ("Disable PCMCIA buffers and assert RESET\n");
  731. reg = 0;
  732. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  733. #ifndef NSCU_OE_INV
  734. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  735. #endif
  736. PCMCIA_PGCRX(slot) = reg;
  737. udelay(10000);
  738. return (0);
  739. }
  740. #endif /* CFG_CMD_PCMCIA */
  741. #ifdef CONFIG_NSCU
  742. static int voltage_set(int slot, int vcc, int vpp)
  743. {
  744. return 0;
  745. }
  746. #else
  747. static int voltage_set(int slot, int vcc, int vpp)
  748. {
  749. volatile immap_t *immap;
  750. volatile pcmconf8xx_t *pcmp;
  751. u_long reg;
  752. debug ("voltage_set: "
  753. PCMCIA_BOARD_MSG
  754. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  755. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  756. immap = (immap_t *)CFG_IMMR;
  757. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  758. /*
  759. * Disable PCMCIA buffers (isolate the interface)
  760. * and assert RESET signal
  761. */
  762. debug ("Disable PCMCIA buffers and assert RESET\n");
  763. reg = PCMCIA_PGCRX(slot);
  764. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  765. #ifndef NSCU_OE_INV
  766. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  767. #else
  768. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  769. #endif
  770. PCMCIA_PGCRX(slot) = reg;
  771. udelay(500);
  772. #ifndef CONFIG_HMI10
  773. /*
  774. * Configure Port C pins for
  775. * 5 Volts Enable and 3 Volts enable,
  776. * Turn off all power
  777. */
  778. debug ("PCMCIA power OFF\n");
  779. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  780. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  781. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  782. reg = 0;
  783. switch(vcc) {
  784. case 0: break;
  785. case 33: reg |= 0x0002; break;
  786. case 50: reg |= 0x0004; break;
  787. default: goto done;
  788. }
  789. #else /* CONFIG_HMI10 */
  790. /*
  791. * Configure Port B pins for
  792. * 5 Volts Enable and 3 Volts enable,
  793. * Turn off all power
  794. */
  795. debug ("PCMCIA power OFF\n");
  796. immap->im_cpm.cp_pbpar &= ~(0x00000300);
  797. /* remove all power */
  798. immap->im_cpm.cp_pbdat |= 0x00000300;
  799. reg = 0;
  800. switch(vcc) {
  801. case 0: break;
  802. case 33: reg |= 0x00000200; break;
  803. case 50: reg |= 0x00000100; break;
  804. default: goto done;
  805. }
  806. #endif /* CONFIG_HMI10 */
  807. /* Checking supported voltages */
  808. debug ("PIPR: 0x%x --> %s\n",
  809. pcmp->pcmc_pipr,
  810. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  811. #ifndef CONFIG_HMI10
  812. immap->im_ioport.iop_pcdat |= reg;
  813. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  814. #else
  815. immap->im_cpm.cp_pbdat &= !reg;
  816. immap->im_cpm.cp_pbdir |= 0x00000300;
  817. #endif /* CONFIG_HMI10 */
  818. if (reg) {
  819. #ifndef CONFIG_HMI10
  820. debug ("PCMCIA powered at %sV\n",
  821. (reg&0x0004) ? "5.0" : "3.3");
  822. #else
  823. debug ("PCMCIA powered at %sV\n",
  824. (reg&0x00000200) ? "5.0" : "3.3");
  825. #endif /* CONFIG_HMI10 */
  826. } else {
  827. debug ("PCMCIA powered down\n");
  828. }
  829. done:
  830. debug ("Enable PCMCIA buffers and stop RESET\n");
  831. reg = PCMCIA_PGCRX(slot);
  832. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  833. #ifndef NSCU_OE_INV
  834. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  835. #else
  836. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  837. #endif
  838. PCMCIA_PGCRX(slot) = reg;
  839. udelay(500);
  840. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  841. slot+'A');
  842. return (0);
  843. }
  844. #endif
  845. #endif /* TQM8xxL */
  846. /* -------------------------------------------------------------------- */
  847. /* Virtlab2 Board by TQ Components */
  848. /* -------------------------------------------------------------------- */
  849. #if defined(CONFIG_VIRTLAB2)
  850. #define PCMCIA_BOARD_MSG "Virtlab2"
  851. static int hardware_enable(int slot)
  852. {
  853. volatile pcmconf8xx_t *pcmp =
  854. (pcmconf8xx_t *)&(((immap_t *)CFG_IMMR)->im_pcmcia);
  855. volatile unsigned char *powerctl =
  856. (volatile unsigned char *)PCMCIA_CTRL;
  857. volatile sysconf8xx_t *sysp =
  858. (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  859. unsigned int reg, mask;
  860. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  861. udelay(10000);
  862. /*
  863. * Configure SIUMCR to enable PCMCIA port B
  864. */
  865. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  866. /* clear interrupt state, and disable interrupts */
  867. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  868. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  869. /*
  870. * Disable interrupts, DMA, and PCMCIA buffers
  871. * (isolate the interface) and assert RESET signal
  872. */
  873. debug ("Disable PCMCIA buffers and assert RESET\n");
  874. reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
  875. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  876. PCMCIA_PGCRX(slot) = reg;
  877. udelay(500);
  878. /* remove all power */
  879. *powerctl = 0;
  880. /*
  881. * Make sure there is a card in the slot, then configure the interface.
  882. */
  883. udelay(10000);
  884. debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__,
  885. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  886. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  887. printf (" No Card found\n");
  888. return (1);
  889. }
  890. /*
  891. * Power On.
  892. */
  893. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  894. reg = pcmp->pcmc_pipr;
  895. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  896. (reg&PCMCIA_VS1(slot))?"n":"ff",
  897. (reg&PCMCIA_VS2(slot))?"n":"ff");
  898. if ((reg & mask) == mask) {
  899. *powerctl = 2; /* Enable 5V Vccout */
  900. puts (" 5.0V card found: ");
  901. } else {
  902. *powerctl = 1; /* Enable 3.3 V Vccout */
  903. puts (" 3.3V card found: ");
  904. }
  905. udelay(1000);
  906. debug ("Enable PCMCIA buffers and stop RESET\n");
  907. reg = PCMCIA_PGCRX(slot);
  908. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  909. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  910. PCMCIA_PGCRX(slot) = reg;
  911. udelay(250000); /* some cards need >150 ms to come up :-( */
  912. debug ("# hardware_enable done\n");
  913. return (0);
  914. }
  915. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  916. static int hardware_disable(int slot)
  917. {
  918. volatile unsigned char *powerctl =
  919. (volatile unsigned char *)PCMCIA_CTRL;
  920. unsigned long reg;
  921. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  922. /* remove all power */
  923. *powerctl = 0;
  924. debug ("Disable PCMCIA buffers and assert RESET\n");
  925. reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
  926. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  927. PCMCIA_PGCRX(slot) = reg;
  928. udelay(10000);
  929. return (0);
  930. }
  931. #endif
  932. static int voltage_set(int slot, int vcc, int vpp)
  933. {
  934. #ifdef DEBUG
  935. volatile pcmconf8xx_t *pcmp =
  936. (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  937. #endif
  938. volatile unsigned char *powerctl =
  939. (volatile unsigned char *)PCMCIA_CTRL;
  940. unsigned long reg;
  941. debug ("voltage_set: " PCMCIA_BOARD_MSG
  942. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  943. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  944. /*
  945. * Disable PCMCIA buffers (isolate the interface)
  946. * and assert RESET signal
  947. */
  948. debug ("Disable PCMCIA buffers and assert RESET\n");
  949. reg = PCMCIA_PGCRX(slot);
  950. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  951. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  952. PCMCIA_PGCRX(slot) = reg;
  953. udelay(500);
  954. /*
  955. * Configure pins for 5 Volts Enable and 3 Volts enable,
  956. * Turn off all power.
  957. */
  958. debug ("PCMCIA power OFF\n");
  959. reg = 0;
  960. switch(vcc) {
  961. case 0: break;
  962. case 33: reg = 0x0001; break;
  963. case 50: reg = 0x0002; break;
  964. default: goto done;
  965. }
  966. /* Checking supported voltages */
  967. debug ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
  968. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  969. *powerctl = reg;
  970. if (reg) {
  971. debug ("PCMCIA powered at %sV\n", (reg&0x0004) ? "5.0" : "3.3");
  972. } else {
  973. debug ("PCMCIA powered down\n");
  974. }
  975. done:
  976. debug ("Enable PCMCIA buffers and stop RESET\n");
  977. reg = PCMCIA_PGCRX(slot);
  978. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  979. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  980. PCMCIA_PGCRX(slot) = reg;
  981. udelay(500);
  982. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
  983. return (0);
  984. }
  985. #endif /* CONFIG_VIRTLAB2 */
  986. /* -------------------------------------------------------------------- */
  987. /* LWMON Board */
  988. /* -------------------------------------------------------------------- */
  989. #if defined(CONFIG_LWMON)
  990. #define PCMCIA_BOARD_MSG "LWMON"
  991. /* #define's for MAX1604 Power Switch */
  992. #define MAX1604_OP_SUS 0x80
  993. #define MAX1604_VCCBON 0x40
  994. #define MAX1604_VCC_35 0x20
  995. #define MAX1604_VCCBHIZ 0x10
  996. #define MAX1604_VPPBON 0x08
  997. #define MAX1604_VPPBPBPGM 0x04
  998. #define MAX1604_VPPBHIZ 0x02
  999. /* reserved 0x01 */
  1000. static int hardware_enable(int slot)
  1001. {
  1002. volatile immap_t *immap;
  1003. volatile cpm8xx_t *cp;
  1004. volatile pcmconf8xx_t *pcmp;
  1005. volatile sysconf8xx_t *sysp;
  1006. uint reg, mask;
  1007. uchar val;
  1008. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1009. /* Switch on PCMCIA port in PIC register 0x60 */
  1010. reg = pic_read (0x60);
  1011. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1012. reg &= ~0x10;
  1013. /* reg |= 0x08; Vpp not needed */
  1014. pic_write (0x60, reg);
  1015. #ifdef DEBUG
  1016. reg = pic_read (0x60);
  1017. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1018. #endif
  1019. udelay(10000);
  1020. immap = (immap_t *)CFG_IMMR;
  1021. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1022. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1023. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1024. /*
  1025. * Configure SIUMCR to enable PCMCIA port B
  1026. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1027. */
  1028. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1029. /* clear interrupt state, and disable interrupts */
  1030. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1031. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1032. /*
  1033. * Disable interrupts, DMA, and PCMCIA buffers
  1034. * (isolate the interface) and assert RESET signal
  1035. */
  1036. debug ("Disable PCMCIA buffers and assert RESET\n");
  1037. reg = 0;
  1038. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1039. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1040. PCMCIA_PGCRX(_slot_) = reg;
  1041. udelay(500);
  1042. /*
  1043. * Make sure there is a card in the slot, then configure the interface.
  1044. */
  1045. udelay(10000);
  1046. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1047. __LINE__,__FUNCTION__,
  1048. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1049. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1050. printf (" No Card found\n");
  1051. return (1);
  1052. }
  1053. /*
  1054. * Power On.
  1055. */
  1056. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1057. reg = pcmp->pcmc_pipr;
  1058. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1059. reg,
  1060. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1061. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1062. if ((reg & mask) == mask) {
  1063. val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
  1064. puts (" 5.0V card found: ");
  1065. } else {
  1066. val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
  1067. puts (" 3.3V card found: ");
  1068. }
  1069. /* switch VCC on */
  1070. val |= MAX1604_OP_SUS | MAX1604_VCCBON;
  1071. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  1072. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1073. udelay(500000);
  1074. debug ("Enable PCMCIA buffers and stop RESET\n");
  1075. reg = PCMCIA_PGCRX(_slot_);
  1076. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1077. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1078. PCMCIA_PGCRX(_slot_) = reg;
  1079. udelay(250000); /* some cards need >150 ms to come up :-( */
  1080. debug ("# hardware_enable done\n");
  1081. return (0);
  1082. }
  1083. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1084. static int hardware_disable(int slot)
  1085. {
  1086. volatile immap_t *immap;
  1087. volatile pcmconf8xx_t *pcmp;
  1088. u_long reg;
  1089. uchar val;
  1090. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1091. immap = (immap_t *)CFG_IMMR;
  1092. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1093. /* remove all power, put output in high impedance state */
  1094. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  1095. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  1096. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1097. /* Configure PCMCIA General Control Register */
  1098. debug ("Disable PCMCIA buffers and assert RESET\n");
  1099. reg = 0;
  1100. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1101. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1102. PCMCIA_PGCRX(_slot_) = reg;
  1103. /* Switch off PCMCIA port in PIC register 0x60 */
  1104. reg = pic_read (0x60);
  1105. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1106. reg |= 0x10;
  1107. reg &= ~0x08;
  1108. pic_write (0x60, reg);
  1109. #ifdef DEBUG
  1110. reg = pic_read (0x60);
  1111. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1112. #endif
  1113. udelay(10000);
  1114. return (0);
  1115. }
  1116. #endif /* CFG_CMD_PCMCIA */
  1117. static int voltage_set(int slot, int vcc, int vpp)
  1118. {
  1119. volatile immap_t *immap;
  1120. volatile pcmconf8xx_t *pcmp;
  1121. u_long reg;
  1122. uchar val;
  1123. debug ("voltage_set: "
  1124. PCMCIA_BOARD_MSG
  1125. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1126. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1127. immap = (immap_t *)CFG_IMMR;
  1128. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1129. /*
  1130. * Disable PCMCIA buffers (isolate the interface)
  1131. * and assert RESET signal
  1132. */
  1133. debug ("Disable PCMCIA buffers and assert RESET\n");
  1134. reg = PCMCIA_PGCRX(_slot_);
  1135. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1136. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1137. PCMCIA_PGCRX(_slot_) = reg;
  1138. udelay(500);
  1139. /*
  1140. * Turn off all power (switch to high impedance)
  1141. */
  1142. debug ("PCMCIA power OFF\n");
  1143. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  1144. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  1145. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1146. val = 0;
  1147. switch(vcc) {
  1148. case 0: break;
  1149. case 33: val = MAX1604_VCC_35; break;
  1150. case 50: break;
  1151. default: goto done;
  1152. }
  1153. /* Checking supported voltages */
  1154. debug ("PIPR: 0x%x --> %s\n",
  1155. pcmp->pcmc_pipr,
  1156. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1157. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1158. if (val) {
  1159. debug ("PCMCIA powered at %sV\n",
  1160. (val & MAX1604_VCC_35) ? "3.3" : "5.0");
  1161. } else {
  1162. debug ("PCMCIA powered down\n");
  1163. }
  1164. done:
  1165. debug ("Enable PCMCIA buffers and stop RESET\n");
  1166. reg = PCMCIA_PGCRX(_slot_);
  1167. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1168. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1169. PCMCIA_PGCRX(_slot_) = reg;
  1170. udelay(500);
  1171. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1172. slot+'A');
  1173. return (0);
  1174. }
  1175. #endif /* LWMON */
  1176. /* -------------------------------------------------------------------- */
  1177. /* GTH board by Corelatus AB */
  1178. /* -------------------------------------------------------------------- */
  1179. #if defined(CONFIG_GTH)
  1180. #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
  1181. static int voltage_set (int slot, int vcc, int vpp)
  1182. { /* Do nothing */
  1183. return 0;
  1184. }
  1185. static int hardware_enable (int slot)
  1186. {
  1187. volatile immap_t *immap;
  1188. volatile cpm8xx_t *cp;
  1189. volatile pcmconf8xx_t *pcmp;
  1190. volatile sysconf8xx_t *sysp;
  1191. uint reg, mask;
  1192. debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
  1193. immap = (immap_t *) CFG_IMMR;
  1194. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1195. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1196. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1197. /* clear interrupt state, and disable interrupts */
  1198. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1199. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1200. /*
  1201. * Disable interrupts, DMA, and PCMCIA buffers
  1202. * (isolate the interface) and assert RESET signal
  1203. */
  1204. debug ("Disable PCMCIA buffers and assert RESET\n");
  1205. reg = 0;
  1206. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1207. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1208. PCMCIA_PGCRX (_slot_) = reg;
  1209. udelay (500);
  1210. /*
  1211. * Make sure there is a card in the slot,
  1212. * then configure the interface.
  1213. */
  1214. udelay (10000);
  1215. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1216. __LINE__, __FUNCTION__,
  1217. &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
  1218. if (pcmp->pcmc_pipr & 0x98000000) {
  1219. printf (" No Card found\n");
  1220. return (1);
  1221. }
  1222. mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
  1223. reg = pcmp->pcmc_pipr;
  1224. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1225. reg,
  1226. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1227. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1228. debug ("Enable PCMCIA buffers and stop RESET\n");
  1229. reg = PCMCIA_PGCRX (_slot_);
  1230. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1231. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1232. PCMCIA_PGCRX (_slot_) = reg;
  1233. udelay (250000); /* some cards need >150 ms to come up :-( */
  1234. debug ("# hardware_enable done\n");
  1235. return 0;
  1236. }
  1237. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1238. static int hardware_disable(int slot)
  1239. {
  1240. return 0; /* No hardware to disable */
  1241. }
  1242. #endif /* CFG_CMD_PCMCIA */
  1243. #endif /* CONFIG_GTH */
  1244. /* -------------------------------------------------------------------- */
  1245. /* ICU862 Boards by Cambridge Broadband Ltd. */
  1246. /* -------------------------------------------------------------------- */
  1247. #if defined(CONFIG_ICU862)
  1248. #define PCMCIA_BOARD_MSG "ICU862"
  1249. static void cfg_port_B (void);
  1250. static int hardware_enable(int slot)
  1251. {
  1252. volatile immap_t *immap;
  1253. volatile cpm8xx_t *cp;
  1254. volatile pcmconf8xx_t *pcmp;
  1255. volatile sysconf8xx_t *sysp;
  1256. uint reg, pipr, mask;
  1257. int i;
  1258. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1259. udelay(10000);
  1260. immap = (immap_t *)CFG_IMMR;
  1261. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1262. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1263. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1264. /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
  1265. cfg_port_B ();
  1266. /*
  1267. * Configure SIUMCR to enable PCMCIA port B
  1268. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1269. */
  1270. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1271. /* clear interrupt state, and disable interrupts */
  1272. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1273. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1274. /*
  1275. * Disable interrupts, DMA, and PCMCIA buffers
  1276. * (isolate the interface) and assert RESET signal
  1277. */
  1278. debug ("Disable PCMCIA buffers and assert RESET\n");
  1279. reg = 0;
  1280. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1281. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1282. PCMCIA_PGCRX(_slot_) = reg;
  1283. udelay(500);
  1284. /*
  1285. * Make sure there is a card in the slot, then configure the interface.
  1286. */
  1287. udelay(10000);
  1288. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1289. __LINE__,__FUNCTION__,
  1290. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1291. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1292. printf (" No Card found\n");
  1293. return (1);
  1294. }
  1295. /*
  1296. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1297. */
  1298. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1299. pipr = pcmp->pcmc_pipr;
  1300. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1301. pipr,
  1302. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1303. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1304. reg = cp->cp_pbdat;
  1305. if ((pipr & mask) == mask) {
  1306. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1307. TPS2205_VCC3); /* 3V off */
  1308. reg &= ~(TPS2205_VCC5); /* 5V on */
  1309. puts (" 5.0V card found: ");
  1310. } else {
  1311. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1312. TPS2205_VCC5); /* 5V off */
  1313. reg &= ~(TPS2205_VCC3); /* 3V on */
  1314. puts (" 3.3V card found: ");
  1315. }
  1316. debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
  1317. reg,
  1318. (reg & TPS2205_VCC3) ? "off" : "on",
  1319. (reg & TPS2205_VCC5) ? "off" : "on",
  1320. (reg & TPS2205_VPP_PGM) ? "off" : "on",
  1321. (reg & TPS2205_VPP_VCC) ? "off" : "on" );
  1322. cp->cp_pbdat = reg;
  1323. /* Wait 500 ms; use this to check for over-current */
  1324. for (i=0; i<5000; ++i) {
  1325. if ((cp->cp_pbdat & TPS2205_OC) == 0) {
  1326. printf (" *** Overcurrent - Safety shutdown ***\n");
  1327. cp->cp_pbdat &= ~(TPS2205_SHDN);
  1328. return (1);
  1329. }
  1330. udelay (100);
  1331. }
  1332. debug ("Enable PCMCIA buffers and stop RESET\n");
  1333. reg = PCMCIA_PGCRX(_slot_);
  1334. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1335. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1336. PCMCIA_PGCRX(_slot_) = reg;
  1337. udelay(250000); /* some cards need >150 ms to come up :-( */
  1338. debug ("# hardware_enable done\n");
  1339. return (0);
  1340. }
  1341. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1342. static int hardware_disable(int slot)
  1343. {
  1344. volatile immap_t *immap;
  1345. volatile cpm8xx_t *cp;
  1346. volatile pcmconf8xx_t *pcmp;
  1347. u_long reg;
  1348. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1349. immap = (immap_t *)CFG_IMMR;
  1350. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1351. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1352. /* Shut down */
  1353. cp->cp_pbdat &= ~(TPS2205_SHDN);
  1354. /* Configure PCMCIA General Control Register */
  1355. debug ("Disable PCMCIA buffers and assert RESET\n");
  1356. reg = 0;
  1357. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1358. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1359. PCMCIA_PGCRX(_slot_) = reg;
  1360. udelay(10000);
  1361. return (0);
  1362. }
  1363. #endif /* CFG_CMD_PCMCIA */
  1364. static int voltage_set(int slot, int vcc, int vpp)
  1365. {
  1366. volatile immap_t *immap;
  1367. volatile cpm8xx_t *cp;
  1368. volatile pcmconf8xx_t *pcmp;
  1369. u_long reg;
  1370. debug ("voltage_set: "
  1371. PCMCIA_BOARD_MSG
  1372. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1373. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1374. immap = (immap_t *)CFG_IMMR;
  1375. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1376. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1377. /*
  1378. * Disable PCMCIA buffers (isolate the interface)
  1379. * and assert RESET signal
  1380. */
  1381. debug ("Disable PCMCIA buffers and assert RESET\n");
  1382. reg = PCMCIA_PGCRX(_slot_);
  1383. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1384. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1385. PCMCIA_PGCRX(_slot_) = reg;
  1386. udelay(500);
  1387. /*
  1388. * Configure Port C pins for
  1389. * 5 Volts Enable and 3 Volts enable,
  1390. * Turn all power pins to Hi-Z
  1391. */
  1392. debug ("PCMCIA power OFF\n");
  1393. cfg_port_B (); /* Enables switch, but all in Hi-Z */
  1394. reg = cp->cp_pbdat;
  1395. switch(vcc) {
  1396. case 0: break; /* Switch off */
  1397. case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
  1398. case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
  1399. default: goto done;
  1400. }
  1401. /* Checking supported voltages */
  1402. debug ("PIPR: 0x%x --> %s\n",
  1403. pcmp->pcmc_pipr,
  1404. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1405. cp->cp_pbdat = reg;
  1406. #ifdef DEBUG
  1407. {
  1408. char *s;
  1409. if ((reg & TPS2205_VCC3) == 0) {
  1410. s = "at 3.3V";
  1411. } else if ((reg & TPS2205_VCC5) == 0) {
  1412. s = "at 5.0V";
  1413. } else {
  1414. s = "down";
  1415. }
  1416. printf ("PCMCIA powered %s\n", s);
  1417. }
  1418. #endif
  1419. done:
  1420. debug ("Enable PCMCIA buffers and stop RESET\n");
  1421. reg = PCMCIA_PGCRX(_slot_);
  1422. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1423. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1424. PCMCIA_PGCRX(_slot_) = reg;
  1425. udelay(500);
  1426. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1427. slot+'A');
  1428. return (0);
  1429. }
  1430. static void cfg_port_B (void)
  1431. {
  1432. volatile immap_t *immap;
  1433. volatile cpm8xx_t *cp;
  1434. uint reg;
  1435. immap = (immap_t *)CFG_IMMR;
  1436. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1437. /*
  1438. * Configure Port B for TPS2205 PC-Card Power-Interface Switch
  1439. *
  1440. * Switch off all voltages, assert shutdown
  1441. */
  1442. reg = cp->cp_pbdat;
  1443. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1444. TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
  1445. TPS2205_SHDN); /* enable switch */
  1446. cp->cp_pbdat = reg;
  1447. cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
  1448. reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
  1449. cp->cp_pbdir = reg | TPS2205_OUTPUTS;
  1450. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1451. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1452. }
  1453. #endif /* ICU862 */
  1454. /* -------------------------------------------------------------------- */
  1455. /* C2MON Boards by TTTech Computertechnik AG */
  1456. /* -------------------------------------------------------------------- */
  1457. #if defined(CONFIG_C2MON)
  1458. #define PCMCIA_BOARD_MSG "C2MON"
  1459. static void cfg_ports (void);
  1460. static int hardware_enable(int slot)
  1461. {
  1462. volatile immap_t *immap;
  1463. volatile cpm8xx_t *cp;
  1464. volatile pcmconf8xx_t *pcmp;
  1465. volatile sysconf8xx_t *sysp;
  1466. uint reg, pipr, mask;
  1467. ushort sreg;
  1468. int i;
  1469. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1470. udelay(10000);
  1471. immap = (immap_t *)CFG_IMMR;
  1472. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1473. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1474. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1475. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  1476. cfg_ports ();
  1477. /*
  1478. * Configure SIUMCR to enable PCMCIA port B
  1479. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1480. */
  1481. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1482. /* clear interrupt state, and disable interrupts */
  1483. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1484. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1485. /*
  1486. * Disable interrupts, DMA, and PCMCIA buffers
  1487. * (isolate the interface) and assert RESET signal
  1488. */
  1489. debug ("Disable PCMCIA buffers and assert RESET\n");
  1490. reg = 0;
  1491. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1492. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1493. PCMCIA_PGCRX(_slot_) = reg;
  1494. udelay(500);
  1495. /*
  1496. * Make sure there is a card in the slot, then configure the interface.
  1497. */
  1498. udelay(10000);
  1499. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1500. __LINE__,__FUNCTION__,
  1501. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1502. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1503. printf (" No Card found\n");
  1504. return (1);
  1505. }
  1506. /*
  1507. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1508. */
  1509. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1510. pipr = pcmp->pcmc_pipr;
  1511. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1512. pipr,
  1513. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1514. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1515. sreg = immap->im_ioport.iop_pcdat;
  1516. if ((pipr & mask) == mask) {
  1517. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1518. TPS2211_VCCD1); /* 5V on */
  1519. sreg &= ~(TPS2211_VCCD0); /* 3V off */
  1520. puts (" 5.0V card found: ");
  1521. } else {
  1522. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1523. TPS2211_VCCD0); /* 3V on */
  1524. sreg &= ~(TPS2211_VCCD1); /* 5V off */
  1525. puts (" 3.3V card found: ");
  1526. }
  1527. debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
  1528. sreg,
  1529. ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
  1530. (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
  1531. );
  1532. immap->im_ioport.iop_pcdat = sreg;
  1533. /* Wait 500 ms; use this to check for over-current */
  1534. for (i=0; i<5000; ++i) {
  1535. if ((cp->cp_pbdat & TPS2211_OC) == 0) {
  1536. printf (" *** Overcurrent - Safety shutdown ***\n");
  1537. immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
  1538. return (1);
  1539. }
  1540. udelay (100);
  1541. }
  1542. debug ("Enable PCMCIA buffers and stop 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(250000); /* some cards need >150 ms to come up :-( */
  1548. debug ("# hardware_enable done\n");
  1549. return (0);
  1550. }
  1551. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1552. static int hardware_disable(int slot)
  1553. {
  1554. volatile immap_t *immap;
  1555. volatile cpm8xx_t *cp;
  1556. volatile pcmconf8xx_t *pcmp;
  1557. u_long reg;
  1558. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1559. immap = (immap_t *)CFG_IMMR;
  1560. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1561. /* Configure PCMCIA General Control Register */
  1562. debug ("Disable PCMCIA buffers and assert RESET\n");
  1563. reg = 0;
  1564. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1565. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1566. PCMCIA_PGCRX(_slot_) = reg;
  1567. /* ALl voltages off / Hi-Z */
  1568. immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
  1569. TPS2211_VCCD0 | TPS2211_VCCD1 );
  1570. udelay(10000);
  1571. return (0);
  1572. }
  1573. #endif /* CFG_CMD_PCMCIA */
  1574. static int voltage_set(int slot, int vcc, int vpp)
  1575. {
  1576. volatile immap_t *immap;
  1577. volatile cpm8xx_t *cp;
  1578. volatile pcmconf8xx_t *pcmp;
  1579. u_long reg;
  1580. ushort sreg;
  1581. debug ("voltage_set: "
  1582. PCMCIA_BOARD_MSG
  1583. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1584. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1585. immap = (immap_t *)CFG_IMMR;
  1586. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1587. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1588. /*
  1589. * Disable PCMCIA buffers (isolate the interface)
  1590. * and assert RESET signal
  1591. */
  1592. debug ("Disable PCMCIA buffers and assert RESET\n");
  1593. reg = PCMCIA_PGCRX(_slot_);
  1594. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1595. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1596. PCMCIA_PGCRX(_slot_) = reg;
  1597. udelay(500);
  1598. /*
  1599. * Configure Port C pins for
  1600. * 5 Volts Enable and 3 Volts enable,
  1601. * Turn all power pins to Hi-Z
  1602. */
  1603. debug ("PCMCIA power OFF\n");
  1604. cfg_ports (); /* Enables switch, but all in Hi-Z */
  1605. sreg = immap->im_ioport.iop_pcdat;
  1606. sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
  1607. switch(vcc) {
  1608. case 0: break; /* Switch off */
  1609. case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
  1610. sreg &= ~TPS2211_VCCD1;
  1611. break;
  1612. case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
  1613. sreg |= TPS2211_VCCD1;
  1614. break;
  1615. default: goto done;
  1616. }
  1617. /* Checking supported voltages */
  1618. debug ("PIPR: 0x%x --> %s\n",
  1619. pcmp->pcmc_pipr,
  1620. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1621. immap->im_ioport.iop_pcdat = sreg;
  1622. #ifdef DEBUG
  1623. {
  1624. char *s;
  1625. if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
  1626. s = "at 3.3V";
  1627. } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
  1628. s = "at 5.0V";
  1629. } else {
  1630. s = "down";
  1631. }
  1632. printf ("PCMCIA powered %s\n", s);
  1633. }
  1634. #endif
  1635. done:
  1636. debug ("Enable PCMCIA buffers and stop RESET\n");
  1637. reg = PCMCIA_PGCRX(_slot_);
  1638. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1639. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1640. PCMCIA_PGCRX(_slot_) = reg;
  1641. udelay(500);
  1642. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1643. slot+'A');
  1644. return (0);
  1645. }
  1646. static void cfg_ports (void)
  1647. {
  1648. volatile immap_t *immap;
  1649. volatile cpm8xx_t *cp;
  1650. ushort sreg;
  1651. immap = (immap_t *)CFG_IMMR;
  1652. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1653. /*
  1654. * Configure Port C for TPS2211 PC-Card Power-Interface Switch
  1655. *
  1656. * Switch off all voltages, assert shutdown
  1657. */
  1658. sreg = immap->im_ioport.iop_pcdat;
  1659. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
  1660. sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
  1661. immap->im_ioport.iop_pcdat = sreg;
  1662. immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
  1663. immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
  1664. debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
  1665. immap->im_ioport.iop_pcpar,
  1666. immap->im_ioport.iop_pcdir,
  1667. immap->im_ioport.iop_pcdat);
  1668. /*
  1669. * Configure Port B for TPS2211 PC-Card Power-Interface Switch
  1670. *
  1671. * Over-Current Input only
  1672. */
  1673. cp->cp_pbpar &= ~(TPS2211_INPUTS);
  1674. cp->cp_pbdir &= ~(TPS2211_INPUTS);
  1675. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1676. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1677. }
  1678. #endif /* C2MON */
  1679. /* -------------------------------------------------------------------- */
  1680. /* MBX board from Morotola */
  1681. /* -------------------------------------------------------------------- */
  1682. #if defined( CONFIG_MBX )
  1683. #include <../board/mbx8xx/csr.h>
  1684. /* A lot of this has been taken from the RPX code in this file it works from me.
  1685. I have added the voltage selection for the MBX board. */
  1686. /* MBX voltage bit in control register #2 */
  1687. #define CR2_VPP12 ((uchar)0x10)
  1688. #define CR2_VPPVDD ((uchar)0x20)
  1689. #define CR2_VDD5 ((uchar)0x40)
  1690. #define CR2_VDD3 ((uchar)0x80)
  1691. #define PCMCIA_BOARD_MSG "MBX860"
  1692. static int voltage_set (int slot, int vcc, int vpp)
  1693. {
  1694. uchar reg = 0;
  1695. debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1696. 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
  1697. switch (vcc) {
  1698. case 0:
  1699. break;
  1700. case 33:
  1701. reg |= CR2_VDD3;
  1702. break;
  1703. case 50:
  1704. reg |= CR2_VDD5;
  1705. break;
  1706. default:
  1707. return 1;
  1708. }
  1709. switch (vpp) {
  1710. case 0:
  1711. break;
  1712. case 33:
  1713. case 50:
  1714. if (vcc == vpp) {
  1715. reg |= CR2_VPPVDD;
  1716. } else {
  1717. return 1;
  1718. }
  1719. break;
  1720. case 120:
  1721. reg |= CR2_VPP12;
  1722. break;
  1723. default:
  1724. return 1;
  1725. }
  1726. /* first, turn off all power */
  1727. MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
  1728. /* enable new powersettings */
  1729. MBX_CSR2 |= reg;
  1730. debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
  1731. return (0);
  1732. }
  1733. static int hardware_enable (int slot)
  1734. {
  1735. volatile immap_t *immap;
  1736. volatile cpm8xx_t *cp;
  1737. volatile pcmconf8xx_t *pcmp;
  1738. volatile sysconf8xx_t *sysp;
  1739. uint reg, mask;
  1740. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
  1741. 'A' + slot);
  1742. udelay (10000);
  1743. immap = (immap_t *) CFG_IMMR;
  1744. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1745. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1746. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1747. /* clear interrupt state, and disable interrupts */
  1748. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1749. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1750. /*
  1751. * Disable interrupts, DMA, and PCMCIA buffers
  1752. * (isolate the interface) and assert RESET signal
  1753. */
  1754. debug ("Disable PCMCIA buffers and assert RESET\n");
  1755. reg = 0;
  1756. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1757. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1758. PCMCIA_PGCRX (_slot_) = reg;
  1759. udelay (500);
  1760. /* remove all power */
  1761. voltage_set (slot, 0, 0);
  1762. /*
  1763. * Make sure there is a card in the slot, then configure the interface.
  1764. */
  1765. udelay(10000);
  1766. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1767. __LINE__,__FUNCTION__,
  1768. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1769. #ifndef CONFIG_HMI10
  1770. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1771. #else
  1772. if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
  1773. #endif /* CONFIG_HMI10 */
  1774. printf (" No Card found\n");
  1775. return (1);
  1776. }
  1777. /*
  1778. * Power On.
  1779. */
  1780. mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
  1781. reg = pcmp->pcmc_pipr;
  1782. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  1783. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1784. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1785. if ((reg & mask) == mask) {
  1786. voltage_set (_slot_, 50, 0);
  1787. printf (" 5.0V card found: ");
  1788. } else {
  1789. voltage_set (_slot_, 33, 0);
  1790. printf (" 3.3V card found: ");
  1791. }
  1792. debug ("Enable PCMCIA buffers and stop RESET\n");
  1793. reg = PCMCIA_PGCRX (_slot_);
  1794. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1795. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1796. PCMCIA_PGCRX (_slot_) = reg;
  1797. udelay (250000); /* some cards need >150 ms to come up :-( */
  1798. debug ("# hardware_enable done\n");
  1799. return (0);
  1800. }
  1801. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1802. static int hardware_disable (int slot)
  1803. {
  1804. return 0; /* No hardware to disable */
  1805. }
  1806. #endif /* CFG_CMD_PCMCIA */
  1807. #endif /* CONFIG_MBX */
  1808. /* -------------------------------------------------------------------- */
  1809. /* R360MPI Board */
  1810. /* -------------------------------------------------------------------- */
  1811. #if defined(CONFIG_R360MPI)
  1812. #define PCMCIA_BOARD_MSG "R360MPI"
  1813. static int hardware_enable(int slot)
  1814. {
  1815. volatile immap_t *immap;
  1816. volatile cpm8xx_t *cp;
  1817. volatile pcmconf8xx_t *pcmp;
  1818. volatile sysconf8xx_t *sysp;
  1819. uint reg, mask;
  1820. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1821. udelay(10000);
  1822. immap = (immap_t *)CFG_IMMR;
  1823. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1824. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1825. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1826. /*
  1827. * Configure SIUMCR to enable PCMCIA port B
  1828. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1829. */
  1830. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1831. /* clear interrupt state, and disable interrupts */
  1832. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1833. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1834. /*
  1835. * Disable interrupts, DMA, and PCMCIA buffers
  1836. * (isolate the interface) and assert RESET signal
  1837. */
  1838. debug ("Disable PCMCIA buffers and assert RESET\n");
  1839. reg = 0;
  1840. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1841. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1842. PCMCIA_PGCRX(_slot_) = reg;
  1843. udelay(500);
  1844. /*
  1845. * Configure Ports A, B & C pins for
  1846. * 5 Volts Enable and 3 Volts enable
  1847. */
  1848. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1849. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1850. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1851. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1852. immap->im_ioport.iop_padir |= 0x0200;*/
  1853. #if 0
  1854. immap->im_ioport.iop_pbpar &= ~(0xC000);
  1855. immap->im_ioport.iop_pbdir &= ~(0xC000);
  1856. #endif
  1857. /* remove all power */
  1858. immap->im_ioport.iop_pcdat |= 0x0400;
  1859. immap->im_ioport.iop_padat |= 0x0200;
  1860. /*
  1861. * Make sure there is a card in the slot, then configure the interface.
  1862. */
  1863. udelay(10000);
  1864. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1865. __LINE__,__FUNCTION__,
  1866. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1867. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1868. printf (" No Card found\n");
  1869. return (1);
  1870. }
  1871. /*
  1872. * Power On.
  1873. */
  1874. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1875. reg = pcmp->pcmc_pipr;
  1876. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1877. reg,
  1878. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1879. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1880. if ((reg & mask) == mask) {
  1881. immap->im_ioport.iop_pcdat &= ~(0x4000);
  1882. puts (" 5.0V card found: ");
  1883. } else {
  1884. immap->im_ioport.iop_padat &= ~(0x0002);
  1885. puts (" 3.3V card found: ");
  1886. }
  1887. immap->im_ioport.iop_pcdir |= 0x0400;
  1888. immap->im_ioport.iop_padir |= 0x0200;
  1889. #if 0
  1890. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1891. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1892. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1893. udelay(500000);
  1894. #endif
  1895. debug ("Enable PCMCIA buffers and stop RESET\n");
  1896. reg = PCMCIA_PGCRX(_slot_);
  1897. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1898. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1899. PCMCIA_PGCRX(_slot_) = reg;
  1900. udelay(250000); /* some cards need >150 ms to come up :-( */
  1901. debug ("# hardware_enable done\n");
  1902. return (0);
  1903. }
  1904. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1905. static int hardware_disable(int slot)
  1906. {
  1907. volatile immap_t *immap;
  1908. volatile pcmconf8xx_t *pcmp;
  1909. u_long reg;
  1910. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1911. immap = (immap_t *)CFG_IMMR;
  1912. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1913. /* remove all power */
  1914. immap->im_ioport.iop_pcdat |= 0x0400;
  1915. immap->im_ioport.iop_padat |= 0x0200;
  1916. /* Configure PCMCIA General Control Register */
  1917. debug ("Disable PCMCIA buffers and assert RESET\n");
  1918. reg = 0;
  1919. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1920. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1921. PCMCIA_PGCRX(_slot_) = reg;
  1922. udelay(10000);
  1923. return (0);
  1924. }
  1925. #endif /* CFG_CMD_PCMCIA */
  1926. static int voltage_set(int slot, int vcc, int vpp)
  1927. {
  1928. volatile immap_t *immap;
  1929. volatile pcmconf8xx_t *pcmp;
  1930. u_long reg;
  1931. debug ("voltage_set: "
  1932. PCMCIA_BOARD_MSG
  1933. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1934. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1935. immap = (immap_t *)CFG_IMMR;
  1936. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1937. /*
  1938. * Disable PCMCIA buffers (isolate the interface)
  1939. * and assert RESET signal
  1940. */
  1941. debug ("Disable PCMCIA buffers and assert RESET\n");
  1942. reg = PCMCIA_PGCRX(_slot_);
  1943. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1944. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1945. PCMCIA_PGCRX(_slot_) = reg;
  1946. udelay(500);
  1947. /*
  1948. * Configure Ports A & C pins for
  1949. * 5 Volts Enable and 3 Volts enable,
  1950. * Turn off all power
  1951. */
  1952. debug ("PCMCIA power OFF\n");
  1953. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1954. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1955. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1956. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1957. immap->im_ioport.iop_padir |= 0x0200;*/
  1958. immap->im_ioport.iop_pcdat |= 0x0400;
  1959. immap->im_ioport.iop_padat |= 0x0200;
  1960. reg = 0;
  1961. switch(vcc) {
  1962. case 0: break;
  1963. case 33: reg |= 0x0200; break;
  1964. case 50: reg |= 0x0400; break;
  1965. default: goto done;
  1966. }
  1967. /* Checking supported voltages */
  1968. debug ("PIPR: 0x%x --> %s\n",
  1969. pcmp->pcmc_pipr,
  1970. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1971. if (reg & 0x0200)
  1972. immap->im_ioport.iop_pcdat &= !reg;
  1973. if (reg & 0x0400)
  1974. immap->im_ioport.iop_padat &= !reg;
  1975. immap->im_ioport.iop_pcdir |= 0x0200;
  1976. immap->im_ioport.iop_padir |= 0x0400;
  1977. if (reg) {
  1978. debug ("PCMCIA powered at %sV\n",
  1979. (reg&0x0400) ? "5.0" : "3.3");
  1980. } else {
  1981. debug ("PCMCIA powered down\n");
  1982. }
  1983. done:
  1984. debug ("Enable PCMCIA buffers and stop RESET\n");
  1985. reg = PCMCIA_PGCRX(_slot_);
  1986. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1987. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1988. PCMCIA_PGCRX(_slot_) = reg;
  1989. udelay(500);
  1990. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1991. slot+'A');
  1992. return (0);
  1993. }
  1994. #endif /* R360MPI */
  1995. /* -------------------------------------------------------------------- */
  1996. /* KUP4K and KUP4X Boards */
  1997. /* -------------------------------------------------------------------- */
  1998. #if defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
  1999. #define PCMCIA_BOARD_MSG "KUP"
  2000. #define KUP4K_PCMCIA_B_3V3 (0x00020000)
  2001. static int hardware_enable(int slot)
  2002. {
  2003. volatile immap_t *immap;
  2004. volatile cpm8xx_t *cp;
  2005. volatile pcmconf8xx_t *pcmp;
  2006. volatile sysconf8xx_t *sysp;
  2007. uint reg, mask;
  2008. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2009. udelay(10000);
  2010. immap = (immap_t *)CFG_IMMR;
  2011. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  2012. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2013. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2014. /*
  2015. * Configure SIUMCR to enable PCMCIA port B
  2016. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  2017. */
  2018. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  2019. /* clear interrupt state, and disable interrupts */
  2020. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  2021. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  2022. /*
  2023. * Disable interrupts, DMA, and PCMCIA buffers
  2024. * (isolate the interface) and assert RESET signal
  2025. */
  2026. debug ("Disable PCMCIA buffers and assert RESET\n");
  2027. reg = 0;
  2028. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2029. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2030. PCMCIA_PGCRX(slot) = reg;
  2031. udelay(2500);
  2032. /*
  2033. * Configure Port B pins for
  2034. * 3 Volts enable
  2035. */
  2036. if (slot) { /* Slot A is built-in */
  2037. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  2038. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  2039. /* remove all power */
  2040. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  2041. }
  2042. /*
  2043. * Make sure there is a card in the slot, then configure the interface.
  2044. */
  2045. udelay(10000);
  2046. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  2047. __LINE__,__FUNCTION__,
  2048. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  2049. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  2050. printf (" No Card found\n");
  2051. return (1);
  2052. }
  2053. /*
  2054. * Power On.
  2055. */
  2056. printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
  2057. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  2058. reg = pcmp->pcmc_pipr;
  2059. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  2060. reg,
  2061. (reg&PCMCIA_VS1(slot))?"n":"ff",
  2062. (reg&PCMCIA_VS2(slot))?"n":"ff");
  2063. if ((reg & mask) == mask) {
  2064. puts (" 5.0V card found: NOT SUPPORTED !!!\n");
  2065. } else {
  2066. if(slot)
  2067. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  2068. puts (" 3.3V card found: ");
  2069. }
  2070. #if 0
  2071. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  2072. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  2073. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  2074. udelay(500000);
  2075. #endif
  2076. debug ("Enable PCMCIA buffers and stop RESET\n");
  2077. reg = PCMCIA_PGCRX(slot);
  2078. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2079. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2080. PCMCIA_PGCRX(slot) = reg;
  2081. udelay(250000); /* some cards need >150 ms to come up :-( */
  2082. debug ("# hardware_enable done\n");
  2083. return (0);
  2084. }
  2085. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2086. static int hardware_disable(int slot)
  2087. {
  2088. volatile immap_t *immap;
  2089. volatile cpm8xx_t *cp;
  2090. volatile pcmconf8xx_t *pcmp;
  2091. u_long reg;
  2092. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2093. immap = (immap_t *)CFG_IMMR;
  2094. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2095. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2096. /* remove all power */
  2097. if (slot)
  2098. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
  2099. /* Configure PCMCIA General Control Register */
  2100. debug ("Disable PCMCIA buffers and assert RESET\n");
  2101. reg = 0;
  2102. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2103. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2104. PCMCIA_PGCRX(slot) = reg;
  2105. udelay(10000);
  2106. return (0);
  2107. }
  2108. #endif /* CFG_CMD_PCMCIA */
  2109. static int voltage_set(int slot, int vcc, int vpp)
  2110. {
  2111. volatile immap_t *immap;
  2112. volatile cpm8xx_t *cp;
  2113. volatile pcmconf8xx_t *pcmp;
  2114. u_long reg;
  2115. debug ("voltage_set: " \
  2116. PCMCIA_BOARD_MSG \
  2117. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  2118. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  2119. if (!slot) /* Slot A is not configurable */
  2120. return 0;
  2121. immap = (immap_t *)CFG_IMMR;
  2122. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2123. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2124. /*
  2125. * Disable PCMCIA buffers (isolate the interface)
  2126. * and assert RESET signal
  2127. */
  2128. debug ("Disable PCMCIA buffers and assert RESET\n");
  2129. reg = PCMCIA_PGCRX(slot);
  2130. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2131. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2132. PCMCIA_PGCRX(slot) = reg;
  2133. udelay(500);
  2134. debug ("PCMCIA power OFF\n");
  2135. /*
  2136. * Configure Port B pins for
  2137. * 3 Volts enable
  2138. */
  2139. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  2140. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  2141. /* remove all power */
  2142. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  2143. switch(vcc) {
  2144. case 0: break;
  2145. case 33:
  2146. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  2147. debug ("PCMCIA powered at 3.3V\n");
  2148. break;
  2149. case 50:
  2150. debug ("PCMCIA: 5Volt vcc not supported\n");
  2151. break;
  2152. default:
  2153. puts("PCMCIA: vcc not supported");
  2154. break;
  2155. }
  2156. udelay(10000);
  2157. /* Checking supported voltages */
  2158. debug ("PIPR: 0x%x --> %s\n",
  2159. pcmp->pcmc_pipr,
  2160. (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
  2161. ? "only 5 V --> NOT SUPPORTED"
  2162. : "can do 3.3V");
  2163. debug ("Enable PCMCIA buffers and stop RESET\n");
  2164. reg = PCMCIA_PGCRX(slot);
  2165. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2166. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2167. PCMCIA_PGCRX(slot) = reg;
  2168. udelay(500);
  2169. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  2170. slot+'A');
  2171. return (0);
  2172. }
  2173. #endif /* KUP4K || KUP4X */
  2174. /* -------------------------------------------------------------------- */
  2175. /* End of Board Specific Stuff */
  2176. /* -------------------------------------------------------------------- */
  2177. /* -------------------------------------------------------------------- */
  2178. /* MPC8xx Specific Stuff - should go to MPC8xx directory */
  2179. /* -------------------------------------------------------------------- */
  2180. /*
  2181. * Search this table to see if the windowsize is
  2182. * supported...
  2183. */
  2184. #define M8XX_SIZES_NO 32
  2185. static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
  2186. { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
  2187. 0x00000080, 0x00000040, 0x00000010, 0x00000020,
  2188. 0x00008000, 0x00004000, 0x00001000, 0x00002000,
  2189. 0x00000100, 0x00000200, 0x00000800, 0x00000400,
  2190. 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  2191. 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
  2192. 0x00010000, 0x00020000, 0x00080000, 0x00040000,
  2193. 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
  2194. /* -------------------------------------------------------------------- */
  2195. #if ( ! defined(CONFIG_I82365) && ! defined(CONFIG_PXA_PCMCIA) )
  2196. static u_int m8xx_get_graycode(u_int size)
  2197. {
  2198. u_int k;
  2199. for (k = 0; k < M8XX_SIZES_NO; k++) {
  2200. if(m8xx_size_to_gray[k] == size)
  2201. break;
  2202. }
  2203. if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
  2204. k = -1;
  2205. return k;
  2206. }
  2207. #endif /* CONFIG_I82365 */
  2208. /* -------------------------------------------------------------------- */
  2209. #if 0
  2210. static u_int m8xx_get_speed(u_int ns, u_int is_io)
  2211. {
  2212. u_int reg, clocks, psst, psl, psht;
  2213. if(!ns) {
  2214. /*
  2215. * We get called with IO maps setup to 0ns
  2216. * if not specified by the user.
  2217. * They should be 255ns.
  2218. */
  2219. if(is_io)
  2220. ns = 255;
  2221. else
  2222. ns = 100; /* fast memory if 0 */
  2223. }
  2224. /*
  2225. * In PSST, PSL, PSHT fields we tell the controller
  2226. * timing parameters in CLKOUT clock cycles.
  2227. * CLKOUT is the same as GCLK2_50.
  2228. */
  2229. /* how we want to adjust the timing - in percent */
  2230. #define ADJ 180 /* 80 % longer accesstime - to be sure */
  2231. clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
  2232. clocks = (clocks * ADJ) / (100*1000);
  2233. if(clocks >= PCMCIA_BMT_LIMIT) {
  2234. DEBUG(0, "Max access time limit reached\n");
  2235. clocks = PCMCIA_BMT_LIMIT-1;
  2236. }
  2237. psst = clocks / 7; /* setup time */
  2238. psht = clocks / 7; /* hold time */
  2239. psl = (clocks * 5) / 7; /* strobe length */
  2240. psst += clocks - (psst + psht + psl);
  2241. reg = psst << 12;
  2242. reg |= psl << 7;
  2243. reg |= psht << 16;
  2244. return reg;
  2245. }
  2246. #endif
  2247. /* -------------------------------------------------------------------- */
  2248. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  2249. static void print_funcid (int func)
  2250. {
  2251. puts (indent);
  2252. switch (func) {
  2253. case CISTPL_FUNCID_MULTI:
  2254. puts (" Multi-Function");
  2255. break;
  2256. case CISTPL_FUNCID_MEMORY:
  2257. puts (" Memory");
  2258. break;
  2259. case CISTPL_FUNCID_SERIAL:
  2260. puts (" Serial Port");
  2261. break;
  2262. case CISTPL_FUNCID_PARALLEL:
  2263. puts (" Parallel Port");
  2264. break;
  2265. case CISTPL_FUNCID_FIXED:
  2266. puts (" Fixed Disk");
  2267. break;
  2268. case CISTPL_FUNCID_VIDEO:
  2269. puts (" Video Adapter");
  2270. break;
  2271. case CISTPL_FUNCID_NETWORK:
  2272. puts (" Network Adapter");
  2273. break;
  2274. case CISTPL_FUNCID_AIMS:
  2275. puts (" AIMS Card");
  2276. break;
  2277. case CISTPL_FUNCID_SCSI:
  2278. puts (" SCSI Adapter");
  2279. break;
  2280. default:
  2281. puts (" Unknown");
  2282. break;
  2283. }
  2284. puts (" Card\n");
  2285. }
  2286. #endif /* CONFIG_IDE_8xx_PCCARD */
  2287. /* -------------------------------------------------------------------- */
  2288. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  2289. static void print_fixed (volatile uchar *p)
  2290. {
  2291. if (p == NULL)
  2292. return;
  2293. puts(indent);
  2294. switch (*p) {
  2295. case CISTPL_FUNCE_IDE_IFACE:
  2296. { uchar iface = *(p+2);
  2297. puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
  2298. puts (" interface ");
  2299. break;
  2300. }
  2301. case CISTPL_FUNCE_IDE_MASTER:
  2302. case CISTPL_FUNCE_IDE_SLAVE:
  2303. { uchar f1 = *(p+2);
  2304. uchar f2 = *(p+4);
  2305. puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
  2306. if (f1 & CISTPL_IDE_UNIQUE)
  2307. puts (" [unique]");
  2308. puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
  2309. if (f2 & CISTPL_IDE_HAS_SLEEP)
  2310. puts (" [sleep]");
  2311. if (f2 & CISTPL_IDE_HAS_STANDBY)
  2312. puts (" [standby]");
  2313. if (f2 & CISTPL_IDE_HAS_IDLE)
  2314. puts (" [idle]");
  2315. if (f2 & CISTPL_IDE_LOW_POWER)
  2316. puts (" [low power]");
  2317. if (f2 & CISTPL_IDE_REG_INHIBIT)
  2318. puts (" [reg inhibit]");
  2319. if (f2 & CISTPL_IDE_HAS_INDEX)
  2320. puts (" [index]");
  2321. if (f2 & CISTPL_IDE_IOIS16)
  2322. puts (" [IOis16]");
  2323. break;
  2324. }
  2325. }
  2326. putc ('\n');
  2327. }
  2328. #endif /* CONFIG_IDE_8xx_PCCARD */
  2329. /* -------------------------------------------------------------------- */
  2330. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  2331. #define MAX_IDENT_CHARS 64
  2332. #define MAX_IDENT_FIELDS 4
  2333. static uchar *known_cards[] = {
  2334. (uchar *)"ARGOSY PnPIDE D5",
  2335. NULL
  2336. };
  2337. static int identify (volatile uchar *p)
  2338. {
  2339. uchar id_str[MAX_IDENT_CHARS];
  2340. uchar data;
  2341. uchar *t;
  2342. uchar **card;
  2343. int i, done;
  2344. if (p == NULL)
  2345. return (0); /* Don't know */
  2346. t = id_str;
  2347. done =0;
  2348. for (i=0; i<=4 && !done; ++i, p+=2) {
  2349. while ((data = *p) != '\0') {
  2350. if (data == 0xFF) {
  2351. done = 1;
  2352. break;
  2353. }
  2354. *t++ = data;
  2355. if (t == &id_str[MAX_IDENT_CHARS-1]) {
  2356. done = 1;
  2357. break;
  2358. }
  2359. p += 2;
  2360. }
  2361. if (!done)
  2362. *t++ = ' ';
  2363. }
  2364. *t = '\0';
  2365. while (--t > id_str) {
  2366. if (*t == ' ')
  2367. *t = '\0';
  2368. else
  2369. break;
  2370. }
  2371. puts ((char *)id_str);
  2372. putc ('\n');
  2373. for (card=known_cards; *card; ++card) {
  2374. debug ("## Compare against \"%s\"\n", *card);
  2375. if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
  2376. debug ("## CARD FOUND ##\n");
  2377. return (1);
  2378. }
  2379. }
  2380. return (0); /* don't know */
  2381. }
  2382. #endif /* CONFIG_IDE_8xx_PCCARD */
  2383. /* -------------------------------------------------------------------- */
  2384. /* NETTA board by Intracom S.A. */
  2385. /* -------------------------------------------------------------------- */
  2386. #if defined(CONFIG_NETTA)
  2387. /* some sane bit macros */
  2388. #define _BD(_b) (1U << (31-(_b)))
  2389. #define _BDR(_l, _h) (((((1U << (31-(_l))) - 1) << 1) | 1) & ~((1U << (31-(_h))) - 1))
  2390. #define _BW(_b) (1U << (15-(_b)))
  2391. #define _BWR(_l, _h) (((((1U << (15-(_l))) - 1) << 1) | 1) & ~((1U << (15-(_h))) - 1))
  2392. #define _BB(_b) (1U << (7-(_b)))
  2393. #define _BBR(_l, _h) (((((1U << (7-(_l))) - 1) << 1) | 1) & ~((1U << (7-(_h))) - 1))
  2394. #define _B(_b) _BD(_b)
  2395. #define _BR(_l, _h) _BDR(_l, _h)
  2396. #define PCMCIA_BOARD_MSG "NETTA"
  2397. static const unsigned short vppd_masks[2] = { _BW(14), _BW(15) };
  2398. static void cfg_vppd(int no)
  2399. {
  2400. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2401. unsigned short mask;
  2402. if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
  2403. return;
  2404. mask = vppd_masks[no];
  2405. immap->im_ioport.iop_papar &= ~mask;
  2406. immap->im_ioport.iop_paodr &= ~mask;
  2407. immap->im_ioport.iop_padir |= mask;
  2408. }
  2409. static void set_vppd(int no, int what)
  2410. {
  2411. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2412. unsigned short mask;
  2413. if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
  2414. return;
  2415. mask = vppd_masks[no];
  2416. if (what)
  2417. immap->im_ioport.iop_padat |= mask;
  2418. else
  2419. immap->im_ioport.iop_padat &= ~mask;
  2420. }
  2421. static const unsigned short vccd_masks[2] = { _BW(10), _BW(6) };
  2422. static void cfg_vccd(int no)
  2423. {
  2424. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2425. unsigned short mask;
  2426. if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
  2427. return;
  2428. mask = vccd_masks[no];
  2429. immap->im_ioport.iop_papar &= ~mask;
  2430. immap->im_ioport.iop_paodr &= ~mask;
  2431. immap->im_ioport.iop_padir |= mask;
  2432. }
  2433. static void set_vccd(int no, int what)
  2434. {
  2435. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2436. unsigned short mask;
  2437. if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
  2438. return;
  2439. mask = vccd_masks[no];
  2440. if (what)
  2441. immap->im_ioport.iop_padat |= mask;
  2442. else
  2443. immap->im_ioport.iop_padat &= ~mask;
  2444. }
  2445. static const unsigned short oc_mask = _BW(8);
  2446. static void cfg_oc(void)
  2447. {
  2448. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2449. unsigned short mask = oc_mask;
  2450. immap->im_ioport.iop_pcdir &= ~mask;
  2451. immap->im_ioport.iop_pcso &= ~mask;
  2452. immap->im_ioport.iop_pcint &= ~mask;
  2453. immap->im_ioport.iop_pcpar &= ~mask;
  2454. }
  2455. static int get_oc(void)
  2456. {
  2457. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2458. unsigned short mask = oc_mask;
  2459. int what;
  2460. what = !!(immap->im_ioport.iop_pcdat & mask);;
  2461. return what;
  2462. }
  2463. static const unsigned short shdn_mask = _BW(12);
  2464. static void cfg_shdn(void)
  2465. {
  2466. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2467. unsigned short mask;
  2468. mask = shdn_mask;
  2469. immap->im_ioport.iop_papar &= ~mask;
  2470. immap->im_ioport.iop_paodr &= ~mask;
  2471. immap->im_ioport.iop_padir |= mask;
  2472. }
  2473. static void set_shdn(int what)
  2474. {
  2475. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2476. unsigned short mask;
  2477. mask = shdn_mask;
  2478. if (what)
  2479. immap->im_ioport.iop_padat |= mask;
  2480. else
  2481. immap->im_ioport.iop_padat &= ~mask;
  2482. }
  2483. static void cfg_ports (void);
  2484. static int hardware_enable(int slot)
  2485. {
  2486. volatile immap_t *immap;
  2487. volatile cpm8xx_t *cp;
  2488. volatile pcmconf8xx_t *pcmp;
  2489. volatile sysconf8xx_t *sysp;
  2490. uint reg, pipr, mask;
  2491. int i;
  2492. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2493. udelay(10000);
  2494. immap = (immap_t *)CFG_IMMR;
  2495. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  2496. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2497. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2498. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  2499. cfg_ports ();
  2500. /* clear interrupt state, and disable interrupts */
  2501. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  2502. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  2503. /*
  2504. * Disable interrupts, DMA, and PCMCIA buffers
  2505. * (isolate the interface) and assert RESET signal
  2506. */
  2507. debug ("Disable PCMCIA buffers and assert RESET\n");
  2508. reg = 0;
  2509. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2510. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2511. PCMCIA_PGCRX(_slot_) = reg;
  2512. udelay(500);
  2513. /*
  2514. * Make sure there is a card in the slot, then configure the interface.
  2515. */
  2516. udelay(10000);
  2517. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  2518. __LINE__,__FUNCTION__,
  2519. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  2520. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  2521. printf (" No Card found\n");
  2522. return (1);
  2523. }
  2524. /*
  2525. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  2526. */
  2527. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  2528. pipr = pcmp->pcmc_pipr;
  2529. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  2530. pipr,
  2531. (reg&PCMCIA_VS1(slot))?"n":"ff",
  2532. (reg&PCMCIA_VS2(slot))?"n":"ff");
  2533. if ((pipr & mask) == mask) {
  2534. set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
  2535. set_vccd(0, 0); set_vccd(1, 1); /* 5V on, 3V off */
  2536. puts (" 5.0V card found: ");
  2537. } else {
  2538. set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
  2539. set_vccd(0, 1); set_vccd(1, 0); /* 5V off, 3V on */
  2540. puts (" 3.3V card found: ");
  2541. }
  2542. /* Wait 500 ms; use this to check for over-current */
  2543. for (i=0; i<5000; ++i) {
  2544. if (!get_oc()) {
  2545. printf (" *** Overcurrent - Safety shutdown ***\n");
  2546. set_vccd(0, 0); set_vccd(1, 0); /* VAVPP => Hi-Z */
  2547. return (1);
  2548. }
  2549. udelay (100);
  2550. }
  2551. debug ("Enable PCMCIA buffers and stop RESET\n");
  2552. reg = PCMCIA_PGCRX(_slot_);
  2553. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2554. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2555. PCMCIA_PGCRX(_slot_) = reg;
  2556. udelay(250000); /* some cards need >150 ms to come up :-( */
  2557. debug ("# hardware_enable done\n");
  2558. return (0);
  2559. }
  2560. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2561. static int hardware_disable(int slot)
  2562. {
  2563. volatile immap_t *immap;
  2564. volatile pcmconf8xx_t *pcmp;
  2565. u_long reg;
  2566. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2567. immap = (immap_t *)CFG_IMMR;
  2568. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2569. /* Configure PCMCIA General Control Register */
  2570. debug ("Disable PCMCIA buffers and assert RESET\n");
  2571. reg = 0;
  2572. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2573. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2574. PCMCIA_PGCRX(_slot_) = reg;
  2575. /* All voltages off / Hi-Z */
  2576. set_vppd(0, 1); set_vppd(1, 1);
  2577. set_vccd(0, 1); set_vccd(1, 1);
  2578. udelay(10000);
  2579. return (0);
  2580. }
  2581. #endif /* CFG_CMD_PCMCIA */
  2582. static int voltage_set(int slot, int vcc, int vpp)
  2583. {
  2584. volatile immap_t *immap;
  2585. volatile cpm8xx_t *cp;
  2586. volatile pcmconf8xx_t *pcmp;
  2587. u_long reg;
  2588. ushort sreg;
  2589. debug ("voltage_set: "
  2590. PCMCIA_BOARD_MSG
  2591. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  2592. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  2593. immap = (immap_t *)CFG_IMMR;
  2594. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2595. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2596. /*
  2597. * Disable PCMCIA buffers (isolate the interface)
  2598. * and assert RESET signal
  2599. */
  2600. debug ("Disable PCMCIA buffers and assert RESET\n");
  2601. reg = PCMCIA_PGCRX(_slot_);
  2602. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2603. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2604. PCMCIA_PGCRX(_slot_) = reg;
  2605. udelay(500);
  2606. /*
  2607. * Configure Port C pins for
  2608. * 5 Volts Enable and 3 Volts enable,
  2609. * Turn all power pins to Hi-Z
  2610. */
  2611. debug ("PCMCIA power OFF\n");
  2612. cfg_ports (); /* Enables switch, but all in Hi-Z */
  2613. sreg = immap->im_ioport.iop_pcdat;
  2614. set_vppd(0, 1); set_vppd(1, 1);
  2615. switch(vcc) {
  2616. case 0:
  2617. break; /* Switch off */
  2618. case 33:
  2619. set_vccd(0, 1); set_vccd(1, 0);
  2620. break;
  2621. case 50:
  2622. set_vccd(0, 0); set_vccd(1, 1);
  2623. break;
  2624. default:
  2625. goto done;
  2626. }
  2627. /* Checking supported voltages */
  2628. debug ("PIPR: 0x%x --> %s\n",
  2629. pcmp->pcmc_pipr,
  2630. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  2631. done:
  2632. debug ("Enable PCMCIA buffers and stop RESET\n");
  2633. reg = PCMCIA_PGCRX(_slot_);
  2634. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2635. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2636. PCMCIA_PGCRX(_slot_) = reg;
  2637. udelay(500);
  2638. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  2639. slot+'A');
  2640. return (0);
  2641. }
  2642. static void cfg_ports (void)
  2643. {
  2644. volatile immap_t *immap;
  2645. volatile cpm8xx_t *cp;
  2646. immap = (immap_t *)CFG_IMMR;
  2647. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2648. cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
  2649. cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
  2650. cfg_shdn();
  2651. cfg_oc();
  2652. /*
  2653. * Configure Port A for TPS2211 PC-Card Power-Interface Switch
  2654. *
  2655. * Switch off all voltages, assert shutdown
  2656. */
  2657. set_vppd(0, 1); set_vppd(1, 1);
  2658. set_vccd(0, 0); set_vccd(1, 0);
  2659. set_shdn(1);
  2660. udelay(100000);
  2661. }
  2662. #endif /* NETTA */
  2663. /* -------------------------------------------------------------------- */
  2664. /* UC100 Boards */
  2665. /* -------------------------------------------------------------------- */
  2666. #if defined(CONFIG_UC100)
  2667. #define PCMCIA_BOARD_MSG "UC100"
  2668. /*
  2669. * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
  2670. * This leads to board-hangup! (sr, 8 Dez. 2004)
  2671. */
  2672. static void cfg_ports (void);
  2673. static int hardware_enable(int slot)
  2674. {
  2675. volatile immap_t *immap;
  2676. volatile cpm8xx_t *cp;
  2677. volatile pcmconf8xx_t *pcmp;
  2678. volatile sysconf8xx_t *sysp;
  2679. uint reg, mask;
  2680. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2681. udelay(10000);
  2682. immap = (immap_t *)CFG_IMMR;
  2683. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  2684. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2685. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2686. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  2687. cfg_ports ();
  2688. /*
  2689. * Configure SIUMCR to enable PCMCIA port B
  2690. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  2691. */
  2692. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  2693. /* clear interrupt state, and disable interrupts */
  2694. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  2695. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  2696. /*
  2697. * Disable interrupts, DMA, and PCMCIA buffers
  2698. * (isolate the interface) and assert RESET signal
  2699. */
  2700. debug ("Disable PCMCIA buffers and assert RESET\n");
  2701. reg = 0;
  2702. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2703. PCMCIA_PGCRX(_slot_) = reg;
  2704. udelay(500);
  2705. /*
  2706. * Make sure there is a card in the slot, then configure the interface.
  2707. */
  2708. udelay(10000);
  2709. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  2710. __LINE__,__FUNCTION__,
  2711. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  2712. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  2713. printf (" No Card found\n");
  2714. return (1);
  2715. }
  2716. /*
  2717. * Power On.
  2718. */
  2719. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  2720. reg = pcmp->pcmc_pipr;
  2721. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  2722. reg,
  2723. (reg&PCMCIA_VS1(slot))?"n":"ff",
  2724. (reg&PCMCIA_VS2(slot))?"n":"ff");
  2725. if ((reg & mask) == mask) {
  2726. puts (" 5.0V card found: ");
  2727. } else {
  2728. puts (" 3.3V card found: ");
  2729. }
  2730. /* switch VCC on */
  2731. immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
  2732. udelay(10000);
  2733. debug ("Enable PCMCIA buffers and stop RESET\n");
  2734. reg = PCMCIA_PGCRX(_slot_);
  2735. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2736. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2737. PCMCIA_PGCRX(_slot_) = reg;
  2738. udelay(250000); /* some cards need >150 ms to come up :-( */
  2739. debug ("# hardware_enable done\n");
  2740. return (0);
  2741. }
  2742. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2743. static int hardware_disable(int slot)
  2744. {
  2745. volatile immap_t *immap;
  2746. volatile cpm8xx_t *cp;
  2747. volatile pcmconf8xx_t *pcmp;
  2748. u_long reg;
  2749. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2750. immap = (immap_t *)CFG_IMMR;
  2751. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2752. /* switch VCC off */
  2753. immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
  2754. /* Configure PCMCIA General Control Register */
  2755. debug ("Disable PCMCIA buffers and assert RESET\n");
  2756. reg = 0;
  2757. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2758. PCMCIA_PGCRX(_slot_) = reg;
  2759. udelay(10000);
  2760. return (0);
  2761. }
  2762. #endif /* CFG_CMD_PCMCIA */
  2763. static int voltage_set(int slot, int vcc, int vpp)
  2764. {
  2765. volatile immap_t *immap;
  2766. volatile pcmconf8xx_t *pcmp;
  2767. u_long reg;
  2768. debug ("voltage_set: "
  2769. PCMCIA_BOARD_MSG
  2770. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  2771. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  2772. immap = (immap_t *)CFG_IMMR;
  2773. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2774. /*
  2775. * Disable PCMCIA buffers (isolate the interface)
  2776. * and assert RESET signal
  2777. */
  2778. debug ("Disable PCMCIA buffers and assert RESET\n");
  2779. reg = PCMCIA_PGCRX(_slot_);
  2780. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2781. PCMCIA_PGCRX(_slot_) = reg;
  2782. udelay(500);
  2783. /*
  2784. * Configure Port C pins for
  2785. * 5 Volts Enable and 3 Volts enable,
  2786. * Turn all power pins to Hi-Z
  2787. */
  2788. debug ("PCMCIA power OFF\n");
  2789. cfg_ports (); /* Enables switch, but all in Hi-Z */
  2790. debug ("Enable PCMCIA buffers and stop RESET\n");
  2791. reg = PCMCIA_PGCRX(_slot_);
  2792. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2793. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2794. PCMCIA_PGCRX(_slot_) = reg;
  2795. udelay(500);
  2796. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  2797. slot+'A');
  2798. return (0);
  2799. }
  2800. static void cfg_ports (void)
  2801. {
  2802. volatile immap_t *immap;
  2803. immap = (immap_t *)CFG_IMMR;
  2804. /*
  2805. * Configure Port A for MAX1602 PC-Card Power-Interface Switch
  2806. */
  2807. immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
  2808. immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
  2809. debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
  2810. immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
  2811. immap->im_ioport.iop_padat);
  2812. }
  2813. #endif /* UC100 */
  2814. /* -------------------------------------------------------------------- */
  2815. #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
  2816. /**************************************************/
  2817. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2818. U_BOOT_CMD(
  2819. pinit, 2, 1, do_pinit,
  2820. "pinit - PCMCIA sub-system\n",
  2821. "on - power on PCMCIA socket\n"
  2822. "pinit off - power off PCMCIA socket\n"
  2823. );
  2824. #endif