cmd_pcmcia.c 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479
  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. unsigned int reg, mask;
  858. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  859. udelay(10000);
  860. /* clear interrupt state, and disable interrupts */
  861. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  862. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  863. /*
  864. * Disable interrupts, DMA, and PCMCIA buffers
  865. * (isolate the interface) and assert RESET signal
  866. */
  867. debug ("Disable PCMCIA buffers and assert RESET\n");
  868. reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
  869. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  870. PCMCIA_PGCRX(slot) = reg;
  871. udelay(500);
  872. /* remove all power */
  873. *powerctl = 0;
  874. /*
  875. * Make sure there is a card in the slot, then configure the interface.
  876. */
  877. udelay(10000);
  878. debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__,
  879. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  880. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  881. printf (" No Card found\n");
  882. return (1);
  883. }
  884. /*
  885. * Power On.
  886. */
  887. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  888. reg = pcmp->pcmc_pipr;
  889. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  890. (reg&PCMCIA_VS1(slot))?"n":"ff",
  891. (reg&PCMCIA_VS2(slot))?"n":"ff");
  892. if ((reg & mask) == mask) {
  893. *powerctl = 2; /* Enable 5V Vccout */
  894. puts (" 5.0V card found: ");
  895. } else {
  896. *powerctl = 1; /* Enable 3.3 V Vccout */
  897. puts (" 3.3V card found: ");
  898. }
  899. udelay(1000);
  900. debug ("Enable PCMCIA buffers and stop RESET\n");
  901. reg = PCMCIA_PGCRX(slot);
  902. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  903. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  904. PCMCIA_PGCRX(slot) = reg;
  905. udelay(250000); /* some cards need >150 ms to come up :-( */
  906. debug ("# hardware_enable done\n");
  907. return (0);
  908. }
  909. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  910. static int hardware_disable(int slot)
  911. {
  912. volatile unsigned char *powerctl =
  913. (volatile unsigned char *)PCMCIA_CTRL;
  914. unsigned long reg;
  915. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  916. /* remove all power */
  917. *powerctl = 0;
  918. debug ("Disable PCMCIA buffers and assert RESET\n");
  919. reg = __MY_PCMCIA_GCRX_CXRESET; /* active high */
  920. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  921. PCMCIA_PGCRX(slot) = reg;
  922. udelay(10000);
  923. return (0);
  924. }
  925. #endif
  926. static int voltage_set(int slot, int vcc, int vpp)
  927. {
  928. volatile pcmconf8xx_t *pcmp =
  929. (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  930. volatile unsigned char *powerctl =
  931. (volatile unsigned char *)PCMCIA_CTRL;
  932. unsigned long reg;
  933. debug ("voltage_set: " PCMCIA_BOARD_MSG
  934. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  935. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  936. /*
  937. * Disable PCMCIA buffers (isolate the interface)
  938. * and assert RESET signal
  939. */
  940. debug ("Disable PCMCIA buffers and assert RESET\n");
  941. reg = PCMCIA_PGCRX(slot);
  942. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  943. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  944. PCMCIA_PGCRX(slot) = reg;
  945. udelay(500);
  946. /*
  947. * Configure pins for 5 Volts Enable and 3 Volts enable,
  948. * Turn off all power.
  949. */
  950. debug ("PCMCIA power OFF\n");
  951. reg = 0;
  952. switch(vcc) {
  953. case 0: break;
  954. case 33: reg = 0x0001; break;
  955. case 50: reg = 0x0002; break;
  956. default: goto done;
  957. }
  958. /* Checking supported voltages */
  959. debug ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
  960. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  961. *powerctl = reg;
  962. if (reg) {
  963. debug ("PCMCIA powered at %sV\n", (reg&0x0004) ? "5.0" : "3.3");
  964. } else {
  965. debug ("PCMCIA powered down\n");
  966. }
  967. done:
  968. debug ("Enable PCMCIA buffers and stop RESET\n");
  969. reg = PCMCIA_PGCRX(slot);
  970. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  971. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  972. PCMCIA_PGCRX(slot) = reg;
  973. udelay(500);
  974. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
  975. return (0);
  976. }
  977. #endif /* CONFIG_VIRTLAB2 */
  978. /* -------------------------------------------------------------------- */
  979. /* LWMON Board */
  980. /* -------------------------------------------------------------------- */
  981. #if defined(CONFIG_LWMON)
  982. #define PCMCIA_BOARD_MSG "LWMON"
  983. /* #define's for MAX1604 Power Switch */
  984. #define MAX1604_OP_SUS 0x80
  985. #define MAX1604_VCCBON 0x40
  986. #define MAX1604_VCC_35 0x20
  987. #define MAX1604_VCCBHIZ 0x10
  988. #define MAX1604_VPPBON 0x08
  989. #define MAX1604_VPPBPBPGM 0x04
  990. #define MAX1604_VPPBHIZ 0x02
  991. /* reserved 0x01 */
  992. static int hardware_enable(int slot)
  993. {
  994. volatile immap_t *immap;
  995. volatile cpm8xx_t *cp;
  996. volatile pcmconf8xx_t *pcmp;
  997. volatile sysconf8xx_t *sysp;
  998. uint reg, mask;
  999. uchar val;
  1000. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1001. /* Switch on PCMCIA port in PIC register 0x60 */
  1002. reg = pic_read (0x60);
  1003. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1004. reg &= ~0x10;
  1005. /* reg |= 0x08; Vpp not needed */
  1006. pic_write (0x60, reg);
  1007. #ifdef DEBUG
  1008. reg = pic_read (0x60);
  1009. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1010. #endif
  1011. udelay(10000);
  1012. immap = (immap_t *)CFG_IMMR;
  1013. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1014. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1015. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1016. /*
  1017. * Configure SIUMCR to enable PCMCIA port B
  1018. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1019. */
  1020. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1021. /* clear interrupt state, and disable interrupts */
  1022. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1023. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1024. /*
  1025. * Disable interrupts, DMA, and PCMCIA buffers
  1026. * (isolate the interface) and assert RESET signal
  1027. */
  1028. debug ("Disable PCMCIA buffers and assert RESET\n");
  1029. reg = 0;
  1030. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1031. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1032. PCMCIA_PGCRX(_slot_) = reg;
  1033. udelay(500);
  1034. /*
  1035. * Make sure there is a card in the slot, then configure the interface.
  1036. */
  1037. udelay(10000);
  1038. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1039. __LINE__,__FUNCTION__,
  1040. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1041. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1042. printf (" No Card found\n");
  1043. return (1);
  1044. }
  1045. /*
  1046. * Power On.
  1047. */
  1048. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1049. reg = pcmp->pcmc_pipr;
  1050. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1051. reg,
  1052. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1053. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1054. if ((reg & mask) == mask) {
  1055. val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
  1056. puts (" 5.0V card found: ");
  1057. } else {
  1058. val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
  1059. puts (" 3.3V card found: ");
  1060. }
  1061. /* switch VCC on */
  1062. val |= MAX1604_OP_SUS | MAX1604_VCCBON;
  1063. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  1064. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1065. udelay(500000);
  1066. debug ("Enable PCMCIA buffers and stop RESET\n");
  1067. reg = PCMCIA_PGCRX(_slot_);
  1068. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1069. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1070. PCMCIA_PGCRX(_slot_) = reg;
  1071. udelay(250000); /* some cards need >150 ms to come up :-( */
  1072. debug ("# hardware_enable done\n");
  1073. return (0);
  1074. }
  1075. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1076. static int hardware_disable(int slot)
  1077. {
  1078. volatile immap_t *immap;
  1079. volatile pcmconf8xx_t *pcmp;
  1080. u_long reg;
  1081. uchar val;
  1082. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1083. immap = (immap_t *)CFG_IMMR;
  1084. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1085. /* remove all power, put output in high impedance state */
  1086. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  1087. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  1088. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1089. /* Configure PCMCIA General Control Register */
  1090. debug ("Disable PCMCIA buffers and assert RESET\n");
  1091. reg = 0;
  1092. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1093. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1094. PCMCIA_PGCRX(_slot_) = reg;
  1095. /* Switch off PCMCIA port in PIC register 0x60 */
  1096. reg = pic_read (0x60);
  1097. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1098. reg |= 0x10;
  1099. reg &= ~0x08;
  1100. pic_write (0x60, reg);
  1101. #ifdef DEBUG
  1102. reg = pic_read (0x60);
  1103. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  1104. #endif
  1105. udelay(10000);
  1106. return (0);
  1107. }
  1108. #endif /* CFG_CMD_PCMCIA */
  1109. static int voltage_set(int slot, int vcc, int vpp)
  1110. {
  1111. volatile immap_t *immap;
  1112. volatile pcmconf8xx_t *pcmp;
  1113. u_long reg;
  1114. uchar val;
  1115. debug ("voltage_set: "
  1116. PCMCIA_BOARD_MSG
  1117. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1118. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1119. immap = (immap_t *)CFG_IMMR;
  1120. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1121. /*
  1122. * Disable PCMCIA buffers (isolate the interface)
  1123. * and assert RESET signal
  1124. */
  1125. debug ("Disable PCMCIA buffers and assert RESET\n");
  1126. reg = PCMCIA_PGCRX(_slot_);
  1127. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1128. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1129. PCMCIA_PGCRX(_slot_) = reg;
  1130. udelay(500);
  1131. /*
  1132. * Turn off all power (switch to high impedance)
  1133. */
  1134. debug ("PCMCIA power OFF\n");
  1135. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  1136. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  1137. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1138. val = 0;
  1139. switch(vcc) {
  1140. case 0: break;
  1141. case 33: val = MAX1604_VCC_35; break;
  1142. case 50: break;
  1143. default: goto done;
  1144. }
  1145. /* Checking supported voltages */
  1146. debug ("PIPR: 0x%x --> %s\n",
  1147. pcmp->pcmc_pipr,
  1148. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1149. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  1150. if (val) {
  1151. debug ("PCMCIA powered at %sV\n",
  1152. (val & MAX1604_VCC_35) ? "3.3" : "5.0");
  1153. } else {
  1154. debug ("PCMCIA powered down\n");
  1155. }
  1156. done:
  1157. debug ("Enable PCMCIA buffers and stop RESET\n");
  1158. reg = PCMCIA_PGCRX(_slot_);
  1159. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1160. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1161. PCMCIA_PGCRX(_slot_) = reg;
  1162. udelay(500);
  1163. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1164. slot+'A');
  1165. return (0);
  1166. }
  1167. #endif /* LWMON */
  1168. /* -------------------------------------------------------------------- */
  1169. /* GTH board by Corelatus AB */
  1170. /* -------------------------------------------------------------------- */
  1171. #if defined(CONFIG_GTH)
  1172. #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
  1173. static int voltage_set (int slot, int vcc, int vpp)
  1174. { /* Do nothing */
  1175. return 0;
  1176. }
  1177. static int hardware_enable (int slot)
  1178. {
  1179. volatile immap_t *immap;
  1180. volatile cpm8xx_t *cp;
  1181. volatile pcmconf8xx_t *pcmp;
  1182. volatile sysconf8xx_t *sysp;
  1183. uint reg, mask;
  1184. debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
  1185. immap = (immap_t *) CFG_IMMR;
  1186. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1187. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1188. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1189. /* clear interrupt state, and disable interrupts */
  1190. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1191. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1192. /*
  1193. * Disable interrupts, DMA, and PCMCIA buffers
  1194. * (isolate the interface) and assert RESET signal
  1195. */
  1196. debug ("Disable PCMCIA buffers and assert RESET\n");
  1197. reg = 0;
  1198. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1199. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1200. PCMCIA_PGCRX (_slot_) = reg;
  1201. udelay (500);
  1202. /*
  1203. * Make sure there is a card in the slot,
  1204. * then configure the interface.
  1205. */
  1206. udelay (10000);
  1207. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1208. __LINE__, __FUNCTION__,
  1209. &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
  1210. if (pcmp->pcmc_pipr & 0x98000000) {
  1211. printf (" No Card found\n");
  1212. return (1);
  1213. }
  1214. mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
  1215. reg = pcmp->pcmc_pipr;
  1216. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1217. reg,
  1218. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1219. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1220. debug ("Enable PCMCIA buffers and stop RESET\n");
  1221. reg = PCMCIA_PGCRX (_slot_);
  1222. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1223. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1224. PCMCIA_PGCRX (_slot_) = reg;
  1225. udelay (250000); /* some cards need >150 ms to come up :-( */
  1226. debug ("# hardware_enable done\n");
  1227. return 0;
  1228. }
  1229. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1230. static int hardware_disable(int slot)
  1231. {
  1232. return 0; /* No hardware to disable */
  1233. }
  1234. #endif /* CFG_CMD_PCMCIA */
  1235. #endif /* CONFIG_GTH */
  1236. /* -------------------------------------------------------------------- */
  1237. /* ICU862 Boards by Cambridge Broadband Ltd. */
  1238. /* -------------------------------------------------------------------- */
  1239. #if defined(CONFIG_ICU862)
  1240. #define PCMCIA_BOARD_MSG "ICU862"
  1241. static void cfg_port_B (void);
  1242. static int hardware_enable(int slot)
  1243. {
  1244. volatile immap_t *immap;
  1245. volatile cpm8xx_t *cp;
  1246. volatile pcmconf8xx_t *pcmp;
  1247. volatile sysconf8xx_t *sysp;
  1248. uint reg, pipr, mask;
  1249. int i;
  1250. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1251. udelay(10000);
  1252. immap = (immap_t *)CFG_IMMR;
  1253. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1254. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1255. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1256. /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
  1257. cfg_port_B ();
  1258. /*
  1259. * Configure SIUMCR to enable PCMCIA port B
  1260. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1261. */
  1262. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1263. /* clear interrupt state, and disable interrupts */
  1264. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1265. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1266. /*
  1267. * Disable interrupts, DMA, and PCMCIA buffers
  1268. * (isolate the interface) and assert RESET signal
  1269. */
  1270. debug ("Disable PCMCIA buffers and assert RESET\n");
  1271. reg = 0;
  1272. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1273. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1274. PCMCIA_PGCRX(_slot_) = reg;
  1275. udelay(500);
  1276. /*
  1277. * Make sure there is a card in the slot, then configure the interface.
  1278. */
  1279. udelay(10000);
  1280. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1281. __LINE__,__FUNCTION__,
  1282. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1283. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1284. printf (" No Card found\n");
  1285. return (1);
  1286. }
  1287. /*
  1288. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1289. */
  1290. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1291. pipr = pcmp->pcmc_pipr;
  1292. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1293. pipr,
  1294. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1295. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1296. reg = cp->cp_pbdat;
  1297. if ((pipr & mask) == mask) {
  1298. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1299. TPS2205_VCC3); /* 3V off */
  1300. reg &= ~(TPS2205_VCC5); /* 5V on */
  1301. puts (" 5.0V card found: ");
  1302. } else {
  1303. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1304. TPS2205_VCC5); /* 5V off */
  1305. reg &= ~(TPS2205_VCC3); /* 3V on */
  1306. puts (" 3.3V card found: ");
  1307. }
  1308. debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
  1309. reg,
  1310. (reg & TPS2205_VCC3) ? "off" : "on",
  1311. (reg & TPS2205_VCC5) ? "off" : "on",
  1312. (reg & TPS2205_VPP_PGM) ? "off" : "on",
  1313. (reg & TPS2205_VPP_VCC) ? "off" : "on" );
  1314. cp->cp_pbdat = reg;
  1315. /* Wait 500 ms; use this to check for over-current */
  1316. for (i=0; i<5000; ++i) {
  1317. if ((cp->cp_pbdat & TPS2205_OC) == 0) {
  1318. printf (" *** Overcurrent - Safety shutdown ***\n");
  1319. cp->cp_pbdat &= ~(TPS2205_SHDN);
  1320. return (1);
  1321. }
  1322. udelay (100);
  1323. }
  1324. debug ("Enable PCMCIA buffers and stop RESET\n");
  1325. reg = PCMCIA_PGCRX(_slot_);
  1326. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1327. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1328. PCMCIA_PGCRX(_slot_) = reg;
  1329. udelay(250000); /* some cards need >150 ms to come up :-( */
  1330. debug ("# hardware_enable done\n");
  1331. return (0);
  1332. }
  1333. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1334. static int hardware_disable(int slot)
  1335. {
  1336. volatile immap_t *immap;
  1337. volatile cpm8xx_t *cp;
  1338. volatile pcmconf8xx_t *pcmp;
  1339. u_long reg;
  1340. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1341. immap = (immap_t *)CFG_IMMR;
  1342. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1343. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1344. /* Shut down */
  1345. cp->cp_pbdat &= ~(TPS2205_SHDN);
  1346. /* Configure PCMCIA General Control Register */
  1347. debug ("Disable PCMCIA buffers and assert RESET\n");
  1348. reg = 0;
  1349. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1350. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1351. PCMCIA_PGCRX(_slot_) = reg;
  1352. udelay(10000);
  1353. return (0);
  1354. }
  1355. #endif /* CFG_CMD_PCMCIA */
  1356. static int voltage_set(int slot, int vcc, int vpp)
  1357. {
  1358. volatile immap_t *immap;
  1359. volatile cpm8xx_t *cp;
  1360. volatile pcmconf8xx_t *pcmp;
  1361. u_long reg;
  1362. debug ("voltage_set: "
  1363. PCMCIA_BOARD_MSG
  1364. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1365. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1366. immap = (immap_t *)CFG_IMMR;
  1367. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1368. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1369. /*
  1370. * Disable PCMCIA buffers (isolate the interface)
  1371. * and assert RESET signal
  1372. */
  1373. debug ("Disable PCMCIA buffers and assert RESET\n");
  1374. reg = PCMCIA_PGCRX(_slot_);
  1375. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1376. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1377. PCMCIA_PGCRX(_slot_) = reg;
  1378. udelay(500);
  1379. /*
  1380. * Configure Port C pins for
  1381. * 5 Volts Enable and 3 Volts enable,
  1382. * Turn all power pins to Hi-Z
  1383. */
  1384. debug ("PCMCIA power OFF\n");
  1385. cfg_port_B (); /* Enables switch, but all in Hi-Z */
  1386. reg = cp->cp_pbdat;
  1387. switch(vcc) {
  1388. case 0: break; /* Switch off */
  1389. case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
  1390. case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
  1391. default: goto done;
  1392. }
  1393. /* Checking supported voltages */
  1394. debug ("PIPR: 0x%x --> %s\n",
  1395. pcmp->pcmc_pipr,
  1396. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1397. cp->cp_pbdat = reg;
  1398. #ifdef DEBUG
  1399. {
  1400. char *s;
  1401. if ((reg & TPS2205_VCC3) == 0) {
  1402. s = "at 3.3V";
  1403. } else if ((reg & TPS2205_VCC5) == 0) {
  1404. s = "at 5.0V";
  1405. } else {
  1406. s = "down";
  1407. }
  1408. printf ("PCMCIA powered %s\n", s);
  1409. }
  1410. #endif
  1411. done:
  1412. debug ("Enable PCMCIA buffers and stop RESET\n");
  1413. reg = PCMCIA_PGCRX(_slot_);
  1414. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1415. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1416. PCMCIA_PGCRX(_slot_) = reg;
  1417. udelay(500);
  1418. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1419. slot+'A');
  1420. return (0);
  1421. }
  1422. static void cfg_port_B (void)
  1423. {
  1424. volatile immap_t *immap;
  1425. volatile cpm8xx_t *cp;
  1426. uint reg;
  1427. immap = (immap_t *)CFG_IMMR;
  1428. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1429. /*
  1430. * Configure Port B for TPS2205 PC-Card Power-Interface Switch
  1431. *
  1432. * Switch off all voltages, assert shutdown
  1433. */
  1434. reg = cp->cp_pbdat;
  1435. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1436. TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
  1437. TPS2205_SHDN); /* enable switch */
  1438. cp->cp_pbdat = reg;
  1439. cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
  1440. reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
  1441. cp->cp_pbdir = reg | TPS2205_OUTPUTS;
  1442. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1443. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1444. }
  1445. #endif /* ICU862 */
  1446. /* -------------------------------------------------------------------- */
  1447. /* C2MON Boards by TTTech Computertechnik AG */
  1448. /* -------------------------------------------------------------------- */
  1449. #if defined(CONFIG_C2MON)
  1450. #define PCMCIA_BOARD_MSG "C2MON"
  1451. static void cfg_ports (void);
  1452. static int hardware_enable(int slot)
  1453. {
  1454. volatile immap_t *immap;
  1455. volatile cpm8xx_t *cp;
  1456. volatile pcmconf8xx_t *pcmp;
  1457. volatile sysconf8xx_t *sysp;
  1458. uint reg, pipr, mask;
  1459. ushort sreg;
  1460. int i;
  1461. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1462. udelay(10000);
  1463. immap = (immap_t *)CFG_IMMR;
  1464. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1465. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1466. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1467. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  1468. cfg_ports ();
  1469. /*
  1470. * Configure SIUMCR to enable PCMCIA port B
  1471. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1472. */
  1473. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1474. /* clear interrupt state, and disable interrupts */
  1475. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1476. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1477. /*
  1478. * Disable interrupts, DMA, and PCMCIA buffers
  1479. * (isolate the interface) and assert RESET signal
  1480. */
  1481. debug ("Disable PCMCIA buffers and assert RESET\n");
  1482. reg = 0;
  1483. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1484. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1485. PCMCIA_PGCRX(_slot_) = reg;
  1486. udelay(500);
  1487. /*
  1488. * Make sure there is a card in the slot, then configure the interface.
  1489. */
  1490. udelay(10000);
  1491. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1492. __LINE__,__FUNCTION__,
  1493. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1494. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1495. printf (" No Card found\n");
  1496. return (1);
  1497. }
  1498. /*
  1499. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1500. */
  1501. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1502. pipr = pcmp->pcmc_pipr;
  1503. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1504. pipr,
  1505. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1506. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1507. sreg = immap->im_ioport.iop_pcdat;
  1508. if ((pipr & mask) == mask) {
  1509. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1510. TPS2211_VCCD1); /* 5V on */
  1511. sreg &= ~(TPS2211_VCCD0); /* 3V off */
  1512. puts (" 5.0V card found: ");
  1513. } else {
  1514. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1515. TPS2211_VCCD0); /* 3V on */
  1516. sreg &= ~(TPS2211_VCCD1); /* 5V off */
  1517. puts (" 3.3V card found: ");
  1518. }
  1519. debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
  1520. sreg,
  1521. ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
  1522. (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
  1523. );
  1524. immap->im_ioport.iop_pcdat = sreg;
  1525. /* Wait 500 ms; use this to check for over-current */
  1526. for (i=0; i<5000; ++i) {
  1527. if ((cp->cp_pbdat & TPS2211_OC) == 0) {
  1528. printf (" *** Overcurrent - Safety shutdown ***\n");
  1529. immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
  1530. return (1);
  1531. }
  1532. udelay (100);
  1533. }
  1534. debug ("Enable PCMCIA buffers and stop RESET\n");
  1535. reg = PCMCIA_PGCRX(_slot_);
  1536. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1537. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1538. PCMCIA_PGCRX(_slot_) = reg;
  1539. udelay(250000); /* some cards need >150 ms to come up :-( */
  1540. debug ("# hardware_enable done\n");
  1541. return (0);
  1542. }
  1543. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1544. static int hardware_disable(int slot)
  1545. {
  1546. volatile immap_t *immap;
  1547. volatile cpm8xx_t *cp;
  1548. volatile pcmconf8xx_t *pcmp;
  1549. u_long reg;
  1550. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1551. immap = (immap_t *)CFG_IMMR;
  1552. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1553. /* Configure PCMCIA General Control Register */
  1554. debug ("Disable PCMCIA buffers and assert RESET\n");
  1555. reg = 0;
  1556. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1557. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1558. PCMCIA_PGCRX(_slot_) = reg;
  1559. /* ALl voltages off / Hi-Z */
  1560. immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
  1561. TPS2211_VCCD0 | TPS2211_VCCD1 );
  1562. udelay(10000);
  1563. return (0);
  1564. }
  1565. #endif /* CFG_CMD_PCMCIA */
  1566. static int voltage_set(int slot, int vcc, int vpp)
  1567. {
  1568. volatile immap_t *immap;
  1569. volatile cpm8xx_t *cp;
  1570. volatile pcmconf8xx_t *pcmp;
  1571. u_long reg;
  1572. ushort sreg;
  1573. debug ("voltage_set: "
  1574. PCMCIA_BOARD_MSG
  1575. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1576. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1577. immap = (immap_t *)CFG_IMMR;
  1578. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1579. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1580. /*
  1581. * Disable PCMCIA buffers (isolate the interface)
  1582. * and assert RESET signal
  1583. */
  1584. debug ("Disable PCMCIA buffers and assert RESET\n");
  1585. reg = PCMCIA_PGCRX(_slot_);
  1586. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1587. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1588. PCMCIA_PGCRX(_slot_) = reg;
  1589. udelay(500);
  1590. /*
  1591. * Configure Port C pins for
  1592. * 5 Volts Enable and 3 Volts enable,
  1593. * Turn all power pins to Hi-Z
  1594. */
  1595. debug ("PCMCIA power OFF\n");
  1596. cfg_ports (); /* Enables switch, but all in Hi-Z */
  1597. sreg = immap->im_ioport.iop_pcdat;
  1598. sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
  1599. switch(vcc) {
  1600. case 0: break; /* Switch off */
  1601. case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
  1602. sreg &= ~TPS2211_VCCD1;
  1603. break;
  1604. case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
  1605. sreg |= TPS2211_VCCD1;
  1606. break;
  1607. default: goto done;
  1608. }
  1609. /* Checking supported voltages */
  1610. debug ("PIPR: 0x%x --> %s\n",
  1611. pcmp->pcmc_pipr,
  1612. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1613. immap->im_ioport.iop_pcdat = sreg;
  1614. #ifdef DEBUG
  1615. {
  1616. char *s;
  1617. if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
  1618. s = "at 3.3V";
  1619. } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
  1620. s = "at 5.0V";
  1621. } else {
  1622. s = "down";
  1623. }
  1624. printf ("PCMCIA powered %s\n", s);
  1625. }
  1626. #endif
  1627. done:
  1628. debug ("Enable PCMCIA buffers and stop RESET\n");
  1629. reg = PCMCIA_PGCRX(_slot_);
  1630. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1631. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1632. PCMCIA_PGCRX(_slot_) = reg;
  1633. udelay(500);
  1634. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1635. slot+'A');
  1636. return (0);
  1637. }
  1638. static void cfg_ports (void)
  1639. {
  1640. volatile immap_t *immap;
  1641. volatile cpm8xx_t *cp;
  1642. ushort sreg;
  1643. immap = (immap_t *)CFG_IMMR;
  1644. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1645. /*
  1646. * Configure Port C for TPS2211 PC-Card Power-Interface Switch
  1647. *
  1648. * Switch off all voltages, assert shutdown
  1649. */
  1650. sreg = immap->im_ioport.iop_pcdat;
  1651. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
  1652. sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
  1653. immap->im_ioport.iop_pcdat = sreg;
  1654. immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
  1655. immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
  1656. debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
  1657. immap->im_ioport.iop_pcpar,
  1658. immap->im_ioport.iop_pcdir,
  1659. immap->im_ioport.iop_pcdat);
  1660. /*
  1661. * Configure Port B for TPS2211 PC-Card Power-Interface Switch
  1662. *
  1663. * Over-Current Input only
  1664. */
  1665. cp->cp_pbpar &= ~(TPS2211_INPUTS);
  1666. cp->cp_pbdir &= ~(TPS2211_INPUTS);
  1667. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1668. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1669. }
  1670. #endif /* C2MON */
  1671. /* -------------------------------------------------------------------- */
  1672. /* MBX board from Morotola */
  1673. /* -------------------------------------------------------------------- */
  1674. #if defined( CONFIG_MBX )
  1675. #include <../board/mbx8xx/csr.h>
  1676. /* A lot of this has been taken from the RPX code in this file it works from me.
  1677. I have added the voltage selection for the MBX board. */
  1678. /* MBX voltage bit in control register #2 */
  1679. #define CR2_VPP12 ((uchar)0x10)
  1680. #define CR2_VPPVDD ((uchar)0x20)
  1681. #define CR2_VDD5 ((uchar)0x40)
  1682. #define CR2_VDD3 ((uchar)0x80)
  1683. #define PCMCIA_BOARD_MSG "MBX860"
  1684. static int voltage_set (int slot, int vcc, int vpp)
  1685. {
  1686. uchar reg = 0;
  1687. debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1688. 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
  1689. switch (vcc) {
  1690. case 0:
  1691. break;
  1692. case 33:
  1693. reg |= CR2_VDD3;
  1694. break;
  1695. case 50:
  1696. reg |= CR2_VDD5;
  1697. break;
  1698. default:
  1699. return 1;
  1700. }
  1701. switch (vpp) {
  1702. case 0:
  1703. break;
  1704. case 33:
  1705. case 50:
  1706. if (vcc == vpp) {
  1707. reg |= CR2_VPPVDD;
  1708. } else {
  1709. return 1;
  1710. }
  1711. break;
  1712. case 120:
  1713. reg |= CR2_VPP12;
  1714. break;
  1715. default:
  1716. return 1;
  1717. }
  1718. /* first, turn off all power */
  1719. MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
  1720. /* enable new powersettings */
  1721. MBX_CSR2 |= reg;
  1722. debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
  1723. return (0);
  1724. }
  1725. static int hardware_enable (int slot)
  1726. {
  1727. volatile immap_t *immap;
  1728. volatile cpm8xx_t *cp;
  1729. volatile pcmconf8xx_t *pcmp;
  1730. volatile sysconf8xx_t *sysp;
  1731. uint reg, mask;
  1732. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
  1733. 'A' + slot);
  1734. udelay (10000);
  1735. immap = (immap_t *) CFG_IMMR;
  1736. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1737. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1738. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1739. /* clear interrupt state, and disable interrupts */
  1740. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1741. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1742. /*
  1743. * Disable interrupts, DMA, and PCMCIA buffers
  1744. * (isolate the interface) and assert RESET signal
  1745. */
  1746. debug ("Disable PCMCIA buffers and assert RESET\n");
  1747. reg = 0;
  1748. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1749. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1750. PCMCIA_PGCRX (_slot_) = reg;
  1751. udelay (500);
  1752. /* remove all power */
  1753. voltage_set (slot, 0, 0);
  1754. /*
  1755. * Make sure there is a card in the slot, then configure the interface.
  1756. */
  1757. udelay(10000);
  1758. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1759. __LINE__,__FUNCTION__,
  1760. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1761. #ifndef CONFIG_HMI10
  1762. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1763. #else
  1764. if (pcmp->pcmc_pipr & (0x10000000 >> (slot << 4))) {
  1765. #endif /* CONFIG_HMI10 */
  1766. printf (" No Card found\n");
  1767. return (1);
  1768. }
  1769. /*
  1770. * Power On.
  1771. */
  1772. mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
  1773. reg = pcmp->pcmc_pipr;
  1774. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  1775. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1776. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1777. if ((reg & mask) == mask) {
  1778. voltage_set (_slot_, 50, 0);
  1779. printf (" 5.0V card found: ");
  1780. } else {
  1781. voltage_set (_slot_, 33, 0);
  1782. printf (" 3.3V card found: ");
  1783. }
  1784. debug ("Enable PCMCIA buffers and stop RESET\n");
  1785. reg = PCMCIA_PGCRX (_slot_);
  1786. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1787. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1788. PCMCIA_PGCRX (_slot_) = reg;
  1789. udelay (250000); /* some cards need >150 ms to come up :-( */
  1790. debug ("# hardware_enable done\n");
  1791. return (0);
  1792. }
  1793. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1794. static int hardware_disable (int slot)
  1795. {
  1796. return 0; /* No hardware to disable */
  1797. }
  1798. #endif /* CFG_CMD_PCMCIA */
  1799. #endif /* CONFIG_MBX */
  1800. /* -------------------------------------------------------------------- */
  1801. /* R360MPI Board */
  1802. /* -------------------------------------------------------------------- */
  1803. #if defined(CONFIG_R360MPI)
  1804. #define PCMCIA_BOARD_MSG "R360MPI"
  1805. static int hardware_enable(int slot)
  1806. {
  1807. volatile immap_t *immap;
  1808. volatile cpm8xx_t *cp;
  1809. volatile pcmconf8xx_t *pcmp;
  1810. volatile sysconf8xx_t *sysp;
  1811. uint reg, mask;
  1812. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1813. udelay(10000);
  1814. immap = (immap_t *)CFG_IMMR;
  1815. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1816. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1817. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1818. /*
  1819. * Configure SIUMCR to enable PCMCIA port B
  1820. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1821. */
  1822. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1823. /* clear interrupt state, and disable interrupts */
  1824. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1825. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1826. /*
  1827. * Disable interrupts, DMA, and PCMCIA buffers
  1828. * (isolate the interface) and assert RESET signal
  1829. */
  1830. debug ("Disable PCMCIA buffers and assert RESET\n");
  1831. reg = 0;
  1832. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1833. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1834. PCMCIA_PGCRX(_slot_) = reg;
  1835. udelay(500);
  1836. /*
  1837. * Configure Ports A, B & C pins for
  1838. * 5 Volts Enable and 3 Volts enable
  1839. */
  1840. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1841. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1842. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1843. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1844. immap->im_ioport.iop_padir |= 0x0200;*/
  1845. #if 0
  1846. immap->im_ioport.iop_pbpar &= ~(0xC000);
  1847. immap->im_ioport.iop_pbdir &= ~(0xC000);
  1848. #endif
  1849. /* remove all power */
  1850. immap->im_ioport.iop_pcdat |= 0x0400;
  1851. immap->im_ioport.iop_padat |= 0x0200;
  1852. /*
  1853. * Make sure there is a card in the slot, then configure the interface.
  1854. */
  1855. udelay(10000);
  1856. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1857. __LINE__,__FUNCTION__,
  1858. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1859. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1860. printf (" No Card found\n");
  1861. return (1);
  1862. }
  1863. /*
  1864. * Power On.
  1865. */
  1866. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1867. reg = pcmp->pcmc_pipr;
  1868. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1869. reg,
  1870. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1871. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1872. if ((reg & mask) == mask) {
  1873. immap->im_ioport.iop_pcdat &= ~(0x4000);
  1874. puts (" 5.0V card found: ");
  1875. } else {
  1876. immap->im_ioport.iop_padat &= ~(0x0002);
  1877. puts (" 3.3V card found: ");
  1878. }
  1879. immap->im_ioport.iop_pcdir |= 0x0400;
  1880. immap->im_ioport.iop_padir |= 0x0200;
  1881. #if 0
  1882. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1883. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1884. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1885. udelay(500000);
  1886. #endif
  1887. debug ("Enable PCMCIA buffers and stop RESET\n");
  1888. reg = PCMCIA_PGCRX(_slot_);
  1889. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1890. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1891. PCMCIA_PGCRX(_slot_) = reg;
  1892. udelay(250000); /* some cards need >150 ms to come up :-( */
  1893. debug ("# hardware_enable done\n");
  1894. return (0);
  1895. }
  1896. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1897. static int hardware_disable(int slot)
  1898. {
  1899. volatile immap_t *immap;
  1900. volatile pcmconf8xx_t *pcmp;
  1901. u_long reg;
  1902. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1903. immap = (immap_t *)CFG_IMMR;
  1904. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1905. /* remove all power */
  1906. immap->im_ioport.iop_pcdat |= 0x0400;
  1907. immap->im_ioport.iop_padat |= 0x0200;
  1908. /* Configure PCMCIA General Control Register */
  1909. debug ("Disable PCMCIA buffers and assert RESET\n");
  1910. reg = 0;
  1911. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1912. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1913. PCMCIA_PGCRX(_slot_) = reg;
  1914. udelay(10000);
  1915. return (0);
  1916. }
  1917. #endif /* CFG_CMD_PCMCIA */
  1918. static int voltage_set(int slot, int vcc, int vpp)
  1919. {
  1920. volatile immap_t *immap;
  1921. volatile pcmconf8xx_t *pcmp;
  1922. u_long reg;
  1923. debug ("voltage_set: "
  1924. PCMCIA_BOARD_MSG
  1925. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1926. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1927. immap = (immap_t *)CFG_IMMR;
  1928. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1929. /*
  1930. * Disable PCMCIA buffers (isolate the interface)
  1931. * and assert RESET signal
  1932. */
  1933. debug ("Disable PCMCIA buffers and assert RESET\n");
  1934. reg = PCMCIA_PGCRX(_slot_);
  1935. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1936. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1937. PCMCIA_PGCRX(_slot_) = reg;
  1938. udelay(500);
  1939. /*
  1940. * Configure Ports A & C pins for
  1941. * 5 Volts Enable and 3 Volts enable,
  1942. * Turn off all power
  1943. */
  1944. debug ("PCMCIA power OFF\n");
  1945. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1946. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1947. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1948. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1949. immap->im_ioport.iop_padir |= 0x0200;*/
  1950. immap->im_ioport.iop_pcdat |= 0x0400;
  1951. immap->im_ioport.iop_padat |= 0x0200;
  1952. reg = 0;
  1953. switch(vcc) {
  1954. case 0: break;
  1955. case 33: reg |= 0x0200; break;
  1956. case 50: reg |= 0x0400; break;
  1957. default: goto done;
  1958. }
  1959. /* Checking supported voltages */
  1960. debug ("PIPR: 0x%x --> %s\n",
  1961. pcmp->pcmc_pipr,
  1962. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1963. if (reg & 0x0200)
  1964. immap->im_ioport.iop_pcdat &= !reg;
  1965. if (reg & 0x0400)
  1966. immap->im_ioport.iop_padat &= !reg;
  1967. immap->im_ioport.iop_pcdir |= 0x0200;
  1968. immap->im_ioport.iop_padir |= 0x0400;
  1969. if (reg) {
  1970. debug ("PCMCIA powered at %sV\n",
  1971. (reg&0x0400) ? "5.0" : "3.3");
  1972. } else {
  1973. debug ("PCMCIA powered down\n");
  1974. }
  1975. done:
  1976. debug ("Enable PCMCIA buffers and stop RESET\n");
  1977. reg = PCMCIA_PGCRX(_slot_);
  1978. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1979. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1980. PCMCIA_PGCRX(_slot_) = reg;
  1981. udelay(500);
  1982. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1983. slot+'A');
  1984. return (0);
  1985. }
  1986. #endif /* R360MPI */
  1987. /* -------------------------------------------------------------------- */
  1988. /* KUP4K and KUP4X Boards */
  1989. /* -------------------------------------------------------------------- */
  1990. #if defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
  1991. #define PCMCIA_BOARD_MSG "KUP"
  1992. #define KUP4K_PCMCIA_B_3V3 (0x00020000)
  1993. static int hardware_enable(int slot)
  1994. {
  1995. volatile immap_t *immap;
  1996. volatile cpm8xx_t *cp;
  1997. volatile pcmconf8xx_t *pcmp;
  1998. volatile sysconf8xx_t *sysp;
  1999. uint reg, mask;
  2000. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2001. udelay(10000);
  2002. immap = (immap_t *)CFG_IMMR;
  2003. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  2004. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2005. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2006. /*
  2007. * Configure SIUMCR to enable PCMCIA port B
  2008. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  2009. */
  2010. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  2011. /* clear interrupt state, and disable interrupts */
  2012. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  2013. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  2014. /*
  2015. * Disable interrupts, DMA, and PCMCIA buffers
  2016. * (isolate the interface) and assert RESET signal
  2017. */
  2018. debug ("Disable PCMCIA buffers and assert RESET\n");
  2019. reg = 0;
  2020. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2021. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2022. PCMCIA_PGCRX(slot) = reg;
  2023. udelay(2500);
  2024. /*
  2025. * Configure Port B pins for
  2026. * 3 Volts enable
  2027. */
  2028. if (slot) { /* Slot A is built-in */
  2029. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  2030. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  2031. /* remove all power */
  2032. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  2033. }
  2034. /*
  2035. * Make sure there is a card in the slot, then configure the interface.
  2036. */
  2037. udelay(10000);
  2038. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  2039. __LINE__,__FUNCTION__,
  2040. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  2041. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  2042. printf (" No Card found\n");
  2043. return (1);
  2044. }
  2045. /*
  2046. * Power On.
  2047. */
  2048. printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
  2049. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  2050. reg = pcmp->pcmc_pipr;
  2051. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  2052. reg,
  2053. (reg&PCMCIA_VS1(slot))?"n":"ff",
  2054. (reg&PCMCIA_VS2(slot))?"n":"ff");
  2055. if ((reg & mask) == mask) {
  2056. puts (" 5.0V card found: NOT SUPPORTED !!!\n");
  2057. } else {
  2058. if(slot)
  2059. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  2060. puts (" 3.3V card found: ");
  2061. }
  2062. #if 0
  2063. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  2064. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  2065. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  2066. udelay(500000);
  2067. #endif
  2068. debug ("Enable PCMCIA buffers and stop RESET\n");
  2069. reg = PCMCIA_PGCRX(slot);
  2070. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2071. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2072. PCMCIA_PGCRX(slot) = reg;
  2073. udelay(250000); /* some cards need >150 ms to come up :-( */
  2074. debug ("# hardware_enable done\n");
  2075. return (0);
  2076. }
  2077. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2078. static int hardware_disable(int slot)
  2079. {
  2080. volatile immap_t *immap;
  2081. volatile cpm8xx_t *cp;
  2082. volatile pcmconf8xx_t *pcmp;
  2083. u_long reg;
  2084. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2085. immap = (immap_t *)CFG_IMMR;
  2086. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2087. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2088. /* remove all power */
  2089. if (slot)
  2090. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
  2091. /* Configure PCMCIA General Control Register */
  2092. debug ("Disable PCMCIA buffers and assert RESET\n");
  2093. reg = 0;
  2094. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2095. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2096. PCMCIA_PGCRX(slot) = reg;
  2097. udelay(10000);
  2098. return (0);
  2099. }
  2100. #endif /* CFG_CMD_PCMCIA */
  2101. static int voltage_set(int slot, int vcc, int vpp)
  2102. {
  2103. volatile immap_t *immap;
  2104. volatile cpm8xx_t *cp;
  2105. volatile pcmconf8xx_t *pcmp;
  2106. u_long reg;
  2107. debug ("voltage_set: " \
  2108. PCMCIA_BOARD_MSG \
  2109. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  2110. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  2111. if (!slot) /* Slot A is not configurable */
  2112. return 0;
  2113. immap = (immap_t *)CFG_IMMR;
  2114. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2115. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2116. /*
  2117. * Disable PCMCIA buffers (isolate the interface)
  2118. * and assert RESET signal
  2119. */
  2120. debug ("Disable PCMCIA buffers and assert RESET\n");
  2121. reg = PCMCIA_PGCRX(slot);
  2122. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2123. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2124. PCMCIA_PGCRX(slot) = reg;
  2125. udelay(500);
  2126. debug ("PCMCIA power OFF\n");
  2127. /*
  2128. * Configure Port B pins for
  2129. * 3 Volts enable
  2130. */
  2131. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  2132. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  2133. /* remove all power */
  2134. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  2135. switch(vcc) {
  2136. case 0: break;
  2137. case 33:
  2138. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  2139. debug ("PCMCIA powered at 3.3V\n");
  2140. break;
  2141. case 50:
  2142. debug ("PCMCIA: 5Volt vcc not supported\n");
  2143. break;
  2144. default:
  2145. puts("PCMCIA: vcc not supported");
  2146. break;
  2147. }
  2148. udelay(10000);
  2149. /* Checking supported voltages */
  2150. debug ("PIPR: 0x%x --> %s\n",
  2151. pcmp->pcmc_pipr,
  2152. (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
  2153. ? "only 5 V --> NOT SUPPORTED"
  2154. : "can do 3.3V");
  2155. debug ("Enable PCMCIA buffers and stop RESET\n");
  2156. reg = PCMCIA_PGCRX(slot);
  2157. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2158. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2159. PCMCIA_PGCRX(slot) = reg;
  2160. udelay(500);
  2161. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  2162. slot+'A');
  2163. return (0);
  2164. }
  2165. #endif /* KUP4K || KUP4X */
  2166. /* -------------------------------------------------------------------- */
  2167. /* End of Board Specific Stuff */
  2168. /* -------------------------------------------------------------------- */
  2169. /* -------------------------------------------------------------------- */
  2170. /* MPC8xx Specific Stuff - should go to MPC8xx directory */
  2171. /* -------------------------------------------------------------------- */
  2172. /*
  2173. * Search this table to see if the windowsize is
  2174. * supported...
  2175. */
  2176. #define M8XX_SIZES_NO 32
  2177. static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
  2178. { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
  2179. 0x00000080, 0x00000040, 0x00000010, 0x00000020,
  2180. 0x00008000, 0x00004000, 0x00001000, 0x00002000,
  2181. 0x00000100, 0x00000200, 0x00000800, 0x00000400,
  2182. 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  2183. 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
  2184. 0x00010000, 0x00020000, 0x00080000, 0x00040000,
  2185. 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
  2186. /* -------------------------------------------------------------------- */
  2187. #if ( ! defined(CONFIG_I82365) && ! defined(CONFIG_PXA_PCMCIA) )
  2188. static u_int m8xx_get_graycode(u_int size)
  2189. {
  2190. u_int k;
  2191. for (k = 0; k < M8XX_SIZES_NO; k++) {
  2192. if(m8xx_size_to_gray[k] == size)
  2193. break;
  2194. }
  2195. if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
  2196. k = -1;
  2197. return k;
  2198. }
  2199. #endif /* CONFIG_I82365 */
  2200. /* -------------------------------------------------------------------- */
  2201. #if 0
  2202. static u_int m8xx_get_speed(u_int ns, u_int is_io)
  2203. {
  2204. u_int reg, clocks, psst, psl, psht;
  2205. if(!ns) {
  2206. /*
  2207. * We get called with IO maps setup to 0ns
  2208. * if not specified by the user.
  2209. * They should be 255ns.
  2210. */
  2211. if(is_io)
  2212. ns = 255;
  2213. else
  2214. ns = 100; /* fast memory if 0 */
  2215. }
  2216. /*
  2217. * In PSST, PSL, PSHT fields we tell the controller
  2218. * timing parameters in CLKOUT clock cycles.
  2219. * CLKOUT is the same as GCLK2_50.
  2220. */
  2221. /* how we want to adjust the timing - in percent */
  2222. #define ADJ 180 /* 80 % longer accesstime - to be sure */
  2223. clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
  2224. clocks = (clocks * ADJ) / (100*1000);
  2225. if(clocks >= PCMCIA_BMT_LIMIT) {
  2226. DEBUG(0, "Max access time limit reached\n");
  2227. clocks = PCMCIA_BMT_LIMIT-1;
  2228. }
  2229. psst = clocks / 7; /* setup time */
  2230. psht = clocks / 7; /* hold time */
  2231. psl = (clocks * 5) / 7; /* strobe length */
  2232. psst += clocks - (psst + psht + psl);
  2233. reg = psst << 12;
  2234. reg |= psl << 7;
  2235. reg |= psht << 16;
  2236. return reg;
  2237. }
  2238. #endif
  2239. /* -------------------------------------------------------------------- */
  2240. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  2241. static void print_funcid (int func)
  2242. {
  2243. puts (indent);
  2244. switch (func) {
  2245. case CISTPL_FUNCID_MULTI:
  2246. puts (" Multi-Function");
  2247. break;
  2248. case CISTPL_FUNCID_MEMORY:
  2249. puts (" Memory");
  2250. break;
  2251. case CISTPL_FUNCID_SERIAL:
  2252. puts (" Serial Port");
  2253. break;
  2254. case CISTPL_FUNCID_PARALLEL:
  2255. puts (" Parallel Port");
  2256. break;
  2257. case CISTPL_FUNCID_FIXED:
  2258. puts (" Fixed Disk");
  2259. break;
  2260. case CISTPL_FUNCID_VIDEO:
  2261. puts (" Video Adapter");
  2262. break;
  2263. case CISTPL_FUNCID_NETWORK:
  2264. puts (" Network Adapter");
  2265. break;
  2266. case CISTPL_FUNCID_AIMS:
  2267. puts (" AIMS Card");
  2268. break;
  2269. case CISTPL_FUNCID_SCSI:
  2270. puts (" SCSI Adapter");
  2271. break;
  2272. default:
  2273. puts (" Unknown");
  2274. break;
  2275. }
  2276. puts (" Card\n");
  2277. }
  2278. #endif /* CONFIG_IDE_8xx_PCCARD */
  2279. /* -------------------------------------------------------------------- */
  2280. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  2281. static void print_fixed (volatile uchar *p)
  2282. {
  2283. if (p == NULL)
  2284. return;
  2285. puts(indent);
  2286. switch (*p) {
  2287. case CISTPL_FUNCE_IDE_IFACE:
  2288. { uchar iface = *(p+2);
  2289. puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
  2290. puts (" interface ");
  2291. break;
  2292. }
  2293. case CISTPL_FUNCE_IDE_MASTER:
  2294. case CISTPL_FUNCE_IDE_SLAVE:
  2295. { uchar f1 = *(p+2);
  2296. uchar f2 = *(p+4);
  2297. puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
  2298. if (f1 & CISTPL_IDE_UNIQUE)
  2299. puts (" [unique]");
  2300. puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
  2301. if (f2 & CISTPL_IDE_HAS_SLEEP)
  2302. puts (" [sleep]");
  2303. if (f2 & CISTPL_IDE_HAS_STANDBY)
  2304. puts (" [standby]");
  2305. if (f2 & CISTPL_IDE_HAS_IDLE)
  2306. puts (" [idle]");
  2307. if (f2 & CISTPL_IDE_LOW_POWER)
  2308. puts (" [low power]");
  2309. if (f2 & CISTPL_IDE_REG_INHIBIT)
  2310. puts (" [reg inhibit]");
  2311. if (f2 & CISTPL_IDE_HAS_INDEX)
  2312. puts (" [index]");
  2313. if (f2 & CISTPL_IDE_IOIS16)
  2314. puts (" [IOis16]");
  2315. break;
  2316. }
  2317. }
  2318. putc ('\n');
  2319. }
  2320. #endif /* CONFIG_IDE_8xx_PCCARD */
  2321. /* -------------------------------------------------------------------- */
  2322. #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_PXA_PCMCIA)
  2323. #define MAX_IDENT_CHARS 64
  2324. #define MAX_IDENT_FIELDS 4
  2325. static uchar *known_cards[] = {
  2326. (uchar *)"ARGOSY PnPIDE D5",
  2327. NULL
  2328. };
  2329. static int identify (volatile uchar *p)
  2330. {
  2331. uchar id_str[MAX_IDENT_CHARS];
  2332. uchar data;
  2333. uchar *t;
  2334. uchar **card;
  2335. int i, done;
  2336. if (p == NULL)
  2337. return (0); /* Don't know */
  2338. t = id_str;
  2339. done =0;
  2340. for (i=0; i<=4 && !done; ++i, p+=2) {
  2341. while ((data = *p) != '\0') {
  2342. if (data == 0xFF) {
  2343. done = 1;
  2344. break;
  2345. }
  2346. *t++ = data;
  2347. if (t == &id_str[MAX_IDENT_CHARS-1]) {
  2348. done = 1;
  2349. break;
  2350. }
  2351. p += 2;
  2352. }
  2353. if (!done)
  2354. *t++ = ' ';
  2355. }
  2356. *t = '\0';
  2357. while (--t > id_str) {
  2358. if (*t == ' ')
  2359. *t = '\0';
  2360. else
  2361. break;
  2362. }
  2363. puts ((char *)id_str);
  2364. putc ('\n');
  2365. for (card=known_cards; *card; ++card) {
  2366. debug ("## Compare against \"%s\"\n", *card);
  2367. if (strcmp((char *)*card, (char *)id_str) == 0) { /* found! */
  2368. debug ("## CARD FOUND ##\n");
  2369. return (1);
  2370. }
  2371. }
  2372. return (0); /* don't know */
  2373. }
  2374. #endif /* CONFIG_IDE_8xx_PCCARD */
  2375. /* -------------------------------------------------------------------- */
  2376. /* NETTA board by Intracom S.A. */
  2377. /* -------------------------------------------------------------------- */
  2378. #if defined(CONFIG_NETTA)
  2379. /* some sane bit macros */
  2380. #define _BD(_b) (1U << (31-(_b)))
  2381. #define _BDR(_l, _h) (((((1U << (31-(_l))) - 1) << 1) | 1) & ~((1U << (31-(_h))) - 1))
  2382. #define _BW(_b) (1U << (15-(_b)))
  2383. #define _BWR(_l, _h) (((((1U << (15-(_l))) - 1) << 1) | 1) & ~((1U << (15-(_h))) - 1))
  2384. #define _BB(_b) (1U << (7-(_b)))
  2385. #define _BBR(_l, _h) (((((1U << (7-(_l))) - 1) << 1) | 1) & ~((1U << (7-(_h))) - 1))
  2386. #define _B(_b) _BD(_b)
  2387. #define _BR(_l, _h) _BDR(_l, _h)
  2388. #define PCMCIA_BOARD_MSG "NETTA"
  2389. static const unsigned short vppd_masks[2] = { _BW(14), _BW(15) };
  2390. static void cfg_vppd(int no)
  2391. {
  2392. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2393. unsigned short mask;
  2394. if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
  2395. return;
  2396. mask = vppd_masks[no];
  2397. immap->im_ioport.iop_papar &= ~mask;
  2398. immap->im_ioport.iop_paodr &= ~mask;
  2399. immap->im_ioport.iop_padir |= mask;
  2400. }
  2401. static void set_vppd(int no, int what)
  2402. {
  2403. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2404. unsigned short mask;
  2405. if ((unsigned int)no >= sizeof(vppd_masks)/sizeof(vppd_masks[0]))
  2406. return;
  2407. mask = vppd_masks[no];
  2408. if (what)
  2409. immap->im_ioport.iop_padat |= mask;
  2410. else
  2411. immap->im_ioport.iop_padat &= ~mask;
  2412. }
  2413. static const unsigned short vccd_masks[2] = { _BW(10), _BW(6) };
  2414. static void cfg_vccd(int no)
  2415. {
  2416. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2417. unsigned short mask;
  2418. if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
  2419. return;
  2420. mask = vccd_masks[no];
  2421. immap->im_ioport.iop_papar &= ~mask;
  2422. immap->im_ioport.iop_paodr &= ~mask;
  2423. immap->im_ioport.iop_padir |= mask;
  2424. }
  2425. static void set_vccd(int no, int what)
  2426. {
  2427. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2428. unsigned short mask;
  2429. if ((unsigned int)no >= sizeof(vccd_masks)/sizeof(vccd_masks[0]))
  2430. return;
  2431. mask = vccd_masks[no];
  2432. if (what)
  2433. immap->im_ioport.iop_padat |= mask;
  2434. else
  2435. immap->im_ioport.iop_padat &= ~mask;
  2436. }
  2437. static const unsigned short oc_mask = _BW(8);
  2438. static void cfg_oc(void)
  2439. {
  2440. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2441. unsigned short mask = oc_mask;
  2442. immap->im_ioport.iop_pcdir &= ~mask;
  2443. immap->im_ioport.iop_pcso &= ~mask;
  2444. immap->im_ioport.iop_pcint &= ~mask;
  2445. immap->im_ioport.iop_pcpar &= ~mask;
  2446. }
  2447. static int get_oc(void)
  2448. {
  2449. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2450. unsigned short mask = oc_mask;
  2451. int what;
  2452. what = !!(immap->im_ioport.iop_pcdat & mask);;
  2453. return what;
  2454. }
  2455. static const unsigned short shdn_mask = _BW(12);
  2456. static void cfg_shdn(void)
  2457. {
  2458. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2459. unsigned short mask;
  2460. mask = shdn_mask;
  2461. immap->im_ioport.iop_papar &= ~mask;
  2462. immap->im_ioport.iop_paodr &= ~mask;
  2463. immap->im_ioport.iop_padir |= mask;
  2464. }
  2465. static void set_shdn(int what)
  2466. {
  2467. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  2468. unsigned short mask;
  2469. mask = shdn_mask;
  2470. if (what)
  2471. immap->im_ioport.iop_padat |= mask;
  2472. else
  2473. immap->im_ioport.iop_padat &= ~mask;
  2474. }
  2475. static void cfg_ports (void);
  2476. static int hardware_enable(int slot)
  2477. {
  2478. volatile immap_t *immap;
  2479. volatile cpm8xx_t *cp;
  2480. volatile pcmconf8xx_t *pcmp;
  2481. volatile sysconf8xx_t *sysp;
  2482. uint reg, pipr, mask;
  2483. int i;
  2484. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2485. udelay(10000);
  2486. immap = (immap_t *)CFG_IMMR;
  2487. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  2488. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2489. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2490. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  2491. cfg_ports ();
  2492. /* clear interrupt state, and disable interrupts */
  2493. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  2494. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  2495. /*
  2496. * Disable interrupts, DMA, and PCMCIA buffers
  2497. * (isolate the interface) and assert RESET signal
  2498. */
  2499. debug ("Disable PCMCIA buffers and assert RESET\n");
  2500. reg = 0;
  2501. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2502. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2503. PCMCIA_PGCRX(_slot_) = reg;
  2504. udelay(500);
  2505. /*
  2506. * Make sure there is a card in the slot, then configure the interface.
  2507. */
  2508. udelay(10000);
  2509. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  2510. __LINE__,__FUNCTION__,
  2511. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  2512. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  2513. printf (" No Card found\n");
  2514. return (1);
  2515. }
  2516. /*
  2517. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  2518. */
  2519. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  2520. pipr = pcmp->pcmc_pipr;
  2521. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  2522. pipr,
  2523. (reg&PCMCIA_VS1(slot))?"n":"ff",
  2524. (reg&PCMCIA_VS2(slot))?"n":"ff");
  2525. if ((pipr & mask) == mask) {
  2526. set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
  2527. set_vccd(0, 0); set_vccd(1, 1); /* 5V on, 3V off */
  2528. puts (" 5.0V card found: ");
  2529. } else {
  2530. set_vppd(0, 1); set_vppd(1, 1); /* VAVPP => Hi-Z */
  2531. set_vccd(0, 1); set_vccd(1, 0); /* 5V off, 3V on */
  2532. puts (" 3.3V card found: ");
  2533. }
  2534. /* Wait 500 ms; use this to check for over-current */
  2535. for (i=0; i<5000; ++i) {
  2536. if (!get_oc()) {
  2537. printf (" *** Overcurrent - Safety shutdown ***\n");
  2538. set_vccd(0, 0); set_vccd(1, 0); /* VAVPP => Hi-Z */
  2539. return (1);
  2540. }
  2541. udelay (100);
  2542. }
  2543. debug ("Enable PCMCIA buffers and stop RESET\n");
  2544. reg = PCMCIA_PGCRX(_slot_);
  2545. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2546. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2547. PCMCIA_PGCRX(_slot_) = reg;
  2548. udelay(250000); /* some cards need >150 ms to come up :-( */
  2549. debug ("# hardware_enable done\n");
  2550. return (0);
  2551. }
  2552. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2553. static int hardware_disable(int slot)
  2554. {
  2555. volatile immap_t *immap;
  2556. volatile pcmconf8xx_t *pcmp;
  2557. u_long reg;
  2558. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2559. immap = (immap_t *)CFG_IMMR;
  2560. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2561. /* Configure PCMCIA General Control Register */
  2562. debug ("Disable PCMCIA buffers and assert RESET\n");
  2563. reg = 0;
  2564. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2565. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2566. PCMCIA_PGCRX(_slot_) = reg;
  2567. /* All voltages off / Hi-Z */
  2568. set_vppd(0, 1); set_vppd(1, 1);
  2569. set_vccd(0, 1); set_vccd(1, 1);
  2570. udelay(10000);
  2571. return (0);
  2572. }
  2573. #endif /* CFG_CMD_PCMCIA */
  2574. static int voltage_set(int slot, int vcc, int vpp)
  2575. {
  2576. volatile immap_t *immap;
  2577. volatile cpm8xx_t *cp;
  2578. volatile pcmconf8xx_t *pcmp;
  2579. u_long reg;
  2580. ushort sreg;
  2581. debug ("voltage_set: "
  2582. PCMCIA_BOARD_MSG
  2583. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  2584. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  2585. immap = (immap_t *)CFG_IMMR;
  2586. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2587. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2588. /*
  2589. * Disable PCMCIA buffers (isolate the interface)
  2590. * and assert RESET signal
  2591. */
  2592. debug ("Disable PCMCIA buffers and assert RESET\n");
  2593. reg = PCMCIA_PGCRX(_slot_);
  2594. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2595. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  2596. PCMCIA_PGCRX(_slot_) = reg;
  2597. udelay(500);
  2598. /*
  2599. * Configure Port C pins for
  2600. * 5 Volts Enable and 3 Volts enable,
  2601. * Turn all power pins to Hi-Z
  2602. */
  2603. debug ("PCMCIA power OFF\n");
  2604. cfg_ports (); /* Enables switch, but all in Hi-Z */
  2605. sreg = immap->im_ioport.iop_pcdat;
  2606. set_vppd(0, 1); set_vppd(1, 1);
  2607. switch(vcc) {
  2608. case 0:
  2609. break; /* Switch off */
  2610. case 33:
  2611. set_vccd(0, 1); set_vccd(1, 0);
  2612. break;
  2613. case 50:
  2614. set_vccd(0, 0); set_vccd(1, 1);
  2615. break;
  2616. default:
  2617. goto done;
  2618. }
  2619. /* Checking supported voltages */
  2620. debug ("PIPR: 0x%x --> %s\n",
  2621. pcmp->pcmc_pipr,
  2622. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  2623. done:
  2624. debug ("Enable PCMCIA buffers and stop RESET\n");
  2625. reg = PCMCIA_PGCRX(_slot_);
  2626. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2627. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2628. PCMCIA_PGCRX(_slot_) = reg;
  2629. udelay(500);
  2630. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  2631. slot+'A');
  2632. return (0);
  2633. }
  2634. static void cfg_ports (void)
  2635. {
  2636. volatile immap_t *immap;
  2637. volatile cpm8xx_t *cp;
  2638. immap = (immap_t *)CFG_IMMR;
  2639. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2640. cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
  2641. cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
  2642. cfg_shdn();
  2643. cfg_oc();
  2644. /*
  2645. * Configure Port A for TPS2211 PC-Card Power-Interface Switch
  2646. *
  2647. * Switch off all voltages, assert shutdown
  2648. */
  2649. set_vppd(0, 1); set_vppd(1, 1);
  2650. set_vccd(0, 0); set_vccd(1, 0);
  2651. set_shdn(1);
  2652. udelay(100000);
  2653. }
  2654. #endif /* NETTA */
  2655. /* -------------------------------------------------------------------- */
  2656. /* UC100 Boards */
  2657. /* -------------------------------------------------------------------- */
  2658. #if defined(CONFIG_UC100)
  2659. #define PCMCIA_BOARD_MSG "UC100"
  2660. /*
  2661. * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
  2662. * This leads to board-hangup! (sr, 8 Dez. 2004)
  2663. */
  2664. static void cfg_ports (void);
  2665. static int hardware_enable(int slot)
  2666. {
  2667. volatile immap_t *immap;
  2668. volatile cpm8xx_t *cp;
  2669. volatile pcmconf8xx_t *pcmp;
  2670. volatile sysconf8xx_t *sysp;
  2671. uint reg, mask;
  2672. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2673. udelay(10000);
  2674. immap = (immap_t *)CFG_IMMR;
  2675. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  2676. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2677. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  2678. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  2679. cfg_ports ();
  2680. /*
  2681. * Configure SIUMCR to enable PCMCIA port B
  2682. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  2683. */
  2684. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  2685. /* clear interrupt state, and disable interrupts */
  2686. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  2687. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  2688. /*
  2689. * Disable interrupts, DMA, and PCMCIA buffers
  2690. * (isolate the interface) and assert RESET signal
  2691. */
  2692. debug ("Disable PCMCIA buffers and assert RESET\n");
  2693. reg = 0;
  2694. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2695. PCMCIA_PGCRX(_slot_) = reg;
  2696. udelay(500);
  2697. /*
  2698. * Make sure there is a card in the slot, then configure the interface.
  2699. */
  2700. udelay(10000);
  2701. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  2702. __LINE__,__FUNCTION__,
  2703. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  2704. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  2705. printf (" No Card found\n");
  2706. return (1);
  2707. }
  2708. /*
  2709. * Power On.
  2710. */
  2711. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  2712. reg = pcmp->pcmc_pipr;
  2713. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  2714. reg,
  2715. (reg&PCMCIA_VS1(slot))?"n":"ff",
  2716. (reg&PCMCIA_VS2(slot))?"n":"ff");
  2717. if ((reg & mask) == mask) {
  2718. puts (" 5.0V card found: ");
  2719. } else {
  2720. puts (" 3.3V card found: ");
  2721. }
  2722. /* switch VCC on */
  2723. immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
  2724. udelay(10000);
  2725. debug ("Enable PCMCIA buffers and stop RESET\n");
  2726. reg = PCMCIA_PGCRX(_slot_);
  2727. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2728. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2729. PCMCIA_PGCRX(_slot_) = reg;
  2730. udelay(250000); /* some cards need >150 ms to come up :-( */
  2731. debug ("# hardware_enable done\n");
  2732. return (0);
  2733. }
  2734. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2735. static int hardware_disable(int slot)
  2736. {
  2737. volatile immap_t *immap;
  2738. volatile cpm8xx_t *cp;
  2739. volatile pcmconf8xx_t *pcmp;
  2740. u_long reg;
  2741. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  2742. immap = (immap_t *)CFG_IMMR;
  2743. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2744. /* switch VCC off */
  2745. immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
  2746. /* Configure PCMCIA General Control Register */
  2747. debug ("Disable PCMCIA buffers and assert RESET\n");
  2748. reg = 0;
  2749. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2750. PCMCIA_PGCRX(_slot_) = reg;
  2751. udelay(10000);
  2752. return (0);
  2753. }
  2754. #endif /* CFG_CMD_PCMCIA */
  2755. static int voltage_set(int slot, int vcc, int vpp)
  2756. {
  2757. volatile immap_t *immap;
  2758. volatile pcmconf8xx_t *pcmp;
  2759. u_long reg;
  2760. debug ("voltage_set: "
  2761. PCMCIA_BOARD_MSG
  2762. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  2763. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  2764. immap = (immap_t *)CFG_IMMR;
  2765. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  2766. /*
  2767. * Disable PCMCIA buffers (isolate the interface)
  2768. * and assert RESET signal
  2769. */
  2770. debug ("Disable PCMCIA buffers and assert RESET\n");
  2771. reg = PCMCIA_PGCRX(_slot_);
  2772. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  2773. PCMCIA_PGCRX(_slot_) = reg;
  2774. udelay(500);
  2775. /*
  2776. * Configure Port C pins for
  2777. * 5 Volts Enable and 3 Volts enable,
  2778. * Turn all power pins to Hi-Z
  2779. */
  2780. debug ("PCMCIA power OFF\n");
  2781. cfg_ports (); /* Enables switch, but all in Hi-Z */
  2782. debug ("Enable PCMCIA buffers and stop RESET\n");
  2783. reg = PCMCIA_PGCRX(_slot_);
  2784. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  2785. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  2786. PCMCIA_PGCRX(_slot_) = reg;
  2787. udelay(500);
  2788. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  2789. slot+'A');
  2790. return (0);
  2791. }
  2792. static void cfg_ports (void)
  2793. {
  2794. volatile immap_t *immap;
  2795. immap = (immap_t *)CFG_IMMR;
  2796. /*
  2797. * Configure Port A for MAX1602 PC-Card Power-Interface Switch
  2798. */
  2799. immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
  2800. immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
  2801. debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
  2802. immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
  2803. immap->im_ioport.iop_padat);
  2804. }
  2805. #endif /* UC100 */
  2806. /* -------------------------------------------------------------------- */
  2807. #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
  2808. /**************************************************/
  2809. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2810. U_BOOT_CMD(
  2811. pinit, 2, 1, do_pinit,
  2812. "pinit - PCMCIA sub-system\n",
  2813. "on - power on PCMCIA socket\n"
  2814. "pinit off - power off PCMCIA socket\n"
  2815. );
  2816. #endif