cmd_pcmcia.c 83 KB

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