cmd_pcmcia.c 79 KB

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