cmd_pcmcia.c 79 KB

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