cmd_pcmcia.c 74 KB

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