cmd_pcmcia.c 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530
  1. /*
  2. * (C) Copyright 2000-2002
  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. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) || \
  65. ((CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD))
  66. int pcmcia_on (void);
  67. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  68. static int pcmcia_off (void);
  69. #endif
  70. #ifdef CONFIG_I82365
  71. extern int i82365_init (void);
  72. extern void i82365_exit (void);
  73. #else /* ! CONFIG_I82365 */
  74. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  75. static int hardware_disable(int slot);
  76. #endif
  77. static int hardware_enable (int slot);
  78. static int voltage_set(int slot, int vcc, int vpp);
  79. #ifndef CONFIG_I82365
  80. static u_int m8xx_get_graycode(u_int size);
  81. #endif /* CONFIG_I82365 */
  82. #if 0
  83. static u_int m8xx_get_speed(u_int ns, u_int is_io);
  84. #endif
  85. /* -------------------------------------------------------------------- */
  86. /* look up table for pgcrx registers */
  87. static u_int *pcmcia_pgcrx[2] = {
  88. &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcra,
  89. &((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pgcrb,
  90. };
  91. #define PCMCIA_PGCRX(slot) (*pcmcia_pgcrx[slot])
  92. #endif /* CONFIG_I82365 */
  93. #ifdef CONFIG_IDE_8xx_PCCARD
  94. static void print_funcid (int func);
  95. static void print_fixed (volatile uchar *p);
  96. static int identify (volatile uchar *p);
  97. static int check_ide_device (int slot);
  98. #endif /* CONFIG_IDE_8xx_PCCARD */
  99. const char *indent = "\t ";
  100. /* -------------------------------------------------------------------- */
  101. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  102. int do_pinit (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  103. {
  104. int rcode = 0;
  105. if (argc != 2) {
  106. printf ("Usage: pinit {on | off}\n");
  107. return 1;
  108. }
  109. if (strcmp(argv[1],"on") == 0) {
  110. rcode = pcmcia_on ();
  111. } else if (strcmp(argv[1],"off") == 0) {
  112. rcode = pcmcia_off ();
  113. } else {
  114. printf ("Usage: pinit {on | off}\n");
  115. return 1;
  116. }
  117. return rcode;
  118. }
  119. #endif /* CFG_CMD_PCMCIA */
  120. /* -------------------------------------------------------------------- */
  121. #ifdef CONFIG_I82365
  122. int pcmcia_on (void)
  123. {
  124. u_int rc;
  125. debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  126. rc = i82365_init();
  127. if (rc == 0)
  128. {
  129. rc = check_ide_device(0);
  130. }
  131. return (rc);
  132. }
  133. #else
  134. #if defined(CONFIG_LWMON) || defined(CONFIG_NSCU)
  135. # define CFG_PCMCIA_TIMING (PCMCIA_SHT(9) | PCMCIA_SST(3) | PCMCIA_SL(12))
  136. #else
  137. # define CFG_PCMCIA_TIMING (PCMCIA_SHT(2) | PCMCIA_SST(4) | PCMCIA_SL(9))
  138. #endif
  139. int pcmcia_on (void)
  140. {
  141. int i;
  142. u_long reg, base;
  143. pcmcia_win_t *win;
  144. u_int slotbit;
  145. u_int rc, slot;
  146. debug ("Enable PCMCIA " PCMCIA_SLOT_MSG "\n");
  147. /* intialize the fixed memory windows */
  148. win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
  149. base = CFG_PCMCIA_MEM_ADDR;
  150. if((reg = m8xx_get_graycode(CFG_PCMCIA_MEM_SIZE)) == -1) {
  151. printf ("Cannot set window size to 0x%08x\n",
  152. CFG_PCMCIA_MEM_SIZE);
  153. return (1);
  154. }
  155. slotbit = PCMCIA_SLOT_x;
  156. for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
  157. win->br = base;
  158. #if (PCMCIA_SOCKETS_NO == 2)
  159. if (i == 4) /* Another slot starting from win 4 */
  160. slotbit = (slotbit ? PCMCIA_PSLOT_A : PCMCIA_PSLOT_B);
  161. #endif
  162. switch (i) {
  163. #ifdef CONFIG_IDE_8xx_PCCARD
  164. case 4:
  165. case 0: { /* map attribute memory */
  166. win->or = ( PCMCIA_BSIZE_64M
  167. | PCMCIA_PPS_8
  168. | PCMCIA_PRS_ATTR
  169. | slotbit
  170. | PCMCIA_PV
  171. | CFG_PCMCIA_TIMING );
  172. break;
  173. }
  174. case 5:
  175. case 1: { /* map I/O window for data reg */
  176. win->or = ( PCMCIA_BSIZE_1K
  177. | PCMCIA_PPS_16
  178. | PCMCIA_PRS_IO
  179. | slotbit
  180. | PCMCIA_PV
  181. | CFG_PCMCIA_TIMING );
  182. break;
  183. }
  184. case 6:
  185. case 2: { /* map I/O window for cmd/ctrl reg block */
  186. win->or = ( PCMCIA_BSIZE_1K
  187. | PCMCIA_PPS_8
  188. | PCMCIA_PRS_IO
  189. | slotbit
  190. | PCMCIA_PV
  191. | CFG_PCMCIA_TIMING );
  192. break;
  193. }
  194. #endif /* CONFIG_IDE_8xx_PCCARD */
  195. default: /* set to not valid */
  196. win->or = 0;
  197. break;
  198. }
  199. debug ("MemWin %d: PBR 0x%08lX POR %08lX\n",
  200. i, win->br, win->or);
  201. base += CFG_PCMCIA_MEM_SIZE;
  202. ++win;
  203. }
  204. for (i=0, rc=0, slot=_slot_; i<PCMCIA_SOCKETS_NO; i++, slot = !slot) {
  205. /* turn off voltage */
  206. if ((rc = voltage_set(slot, 0, 0)))
  207. continue;
  208. /* Enable external hardware */
  209. if ((rc = hardware_enable(slot)))
  210. continue;
  211. #ifdef CONFIG_IDE_8xx_PCCARD
  212. if ((rc = check_ide_device(i)))
  213. continue;
  214. #endif
  215. }
  216. return (rc);
  217. }
  218. #endif /* CONFIG_I82365 */
  219. /* -------------------------------------------------------------------- */
  220. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  221. #ifdef CONFIG_I82365
  222. static int pcmcia_off (void)
  223. {
  224. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  225. i82365_exit();
  226. return 0;
  227. }
  228. #else
  229. static int pcmcia_off (void)
  230. {
  231. int i;
  232. pcmcia_win_t *win;
  233. printf ("Disable PCMCIA " PCMCIA_SLOT_MSG "\n");
  234. /* clear interrupt state, and disable interrupts */
  235. ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pscr = PCMCIA_MASK(_slot_);
  236. ((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_per &= ~PCMCIA_MASK(_slot_);
  237. /* turn off interrupt and disable CxOE */
  238. PCMCIA_PGCRX(_slot_) = __MY_PCMCIA_GCRX_CXOE;
  239. /* turn off memory windows */
  240. win = (pcmcia_win_t *)(&((immap_t *)CFG_IMMR)->im_pcmcia.pcmc_pbr0);
  241. for (i=0; i<PCMCIA_MEM_WIN_NO; ++i) {
  242. /* disable memory window */
  243. win->or = 0;
  244. ++win;
  245. }
  246. /* turn off voltage */
  247. voltage_set(_slot_, 0, 0);
  248. /* disable external hardware */
  249. printf ("Shutdown and Poweroff " PCMCIA_SLOT_MSG "\n");
  250. hardware_disable(_slot_);
  251. return 0;
  252. }
  253. #endif /* CONFIG_I82365 */
  254. #endif /* CFG_CMD_PCMCIA */
  255. /* -------------------------------------------------------------------- */
  256. #ifdef CONFIG_IDE_8xx_PCCARD
  257. #define MAX_TUPEL_SZ 512
  258. #define MAX_FEATURES 4
  259. int ide_devices_found;
  260. static int check_ide_device (int slot)
  261. {
  262. volatile uchar *ident = NULL;
  263. volatile uchar *feature_p[MAX_FEATURES];
  264. volatile uchar *p, *start, *addr;
  265. int n_features = 0;
  266. uchar func_id = ~0;
  267. uchar code, len;
  268. ushort config_base = 0;
  269. int found = 0;
  270. int i;
  271. addr = (volatile uchar *)(CFG_PCMCIA_MEM_ADDR +
  272. CFG_PCMCIA_MEM_SIZE * (slot * 4));
  273. debug ("PCMCIA MEM: %08lX\n", (ulong)addr);
  274. start = p = (volatile uchar *) addr;
  275. while ((p - start) < MAX_TUPEL_SZ) {
  276. code = *p; p += 2;
  277. if (code == 0xFF) { /* End of chain */
  278. break;
  279. }
  280. len = *p; p += 2;
  281. #if defined(DEBUG) && (DEBUG > 1)
  282. { volatile uchar *q = p;
  283. printf ("\nTuple code %02x length %d\n\tData:",
  284. code, len);
  285. for (i = 0; i < len; ++i) {
  286. printf (" %02x", *q);
  287. q+= 2;
  288. }
  289. }
  290. #endif /* DEBUG */
  291. switch (code) {
  292. case CISTPL_VERS_1:
  293. ident = p + 4;
  294. break;
  295. case CISTPL_FUNCID:
  296. /* Fix for broken SanDisk which may have 0x80 bit set */
  297. func_id = *p & 0x7F;
  298. break;
  299. case CISTPL_FUNCE:
  300. if (n_features < MAX_FEATURES)
  301. feature_p[n_features++] = p;
  302. break;
  303. case CISTPL_CONFIG:
  304. config_base = (*(p+6) << 8) + (*(p+4));
  305. debug ("\n## Config_base = %04x ###\n", config_base);
  306. default:
  307. break;
  308. }
  309. p += 2 * len;
  310. }
  311. found = identify (ident);
  312. if (func_id != ((uchar)~0)) {
  313. print_funcid (func_id);
  314. if (func_id == CISTPL_FUNCID_FIXED)
  315. found = 1;
  316. else
  317. return (1); /* no disk drive */
  318. }
  319. for (i=0; i<n_features; ++i) {
  320. print_fixed (feature_p[i]);
  321. }
  322. if (!found) {
  323. printf ("unknown card type\n");
  324. return (1);
  325. }
  326. ide_devices_found |= (1 << slot);
  327. /* set I/O area in config reg -> only valid for ARGOSY D5!!! */
  328. *((uchar *)(addr + config_base)) = 1;
  329. return (0);
  330. }
  331. #endif /* CONFIG_IDE_8xx_PCCARD */
  332. /* -------------------------------------------------------------------- */
  333. /* -------------------------------------------------------------------- */
  334. /* board specific stuff: */
  335. /* voltage_set(), hardware_enable() and hardware_disable() */
  336. /* -------------------------------------------------------------------- */
  337. /* -------------------------------------------------------------------- */
  338. /* RPX Boards from Embedded Planet */
  339. /* -------------------------------------------------------------------- */
  340. #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
  341. /* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
  342. * SYPCR is write once only, therefore must the slowest memory be faster
  343. * than the bus monitor or we will get a machine check due to the bus timeout.
  344. */
  345. #define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
  346. #undef PCMCIA_BMT_LIMIT
  347. #define PCMCIA_BMT_LIMIT (6*8)
  348. static int voltage_set(int slot, int vcc, int vpp)
  349. {
  350. u_long reg = 0;
  351. switch(vcc) {
  352. case 0: break;
  353. case 33: reg |= BCSR1_PCVCTL4; break;
  354. case 50: reg |= BCSR1_PCVCTL5; break;
  355. default: return 1;
  356. }
  357. switch(vpp) {
  358. case 0: break;
  359. case 33:
  360. case 50:
  361. if(vcc == vpp)
  362. reg |= BCSR1_PCVCTL6;
  363. else
  364. return 1;
  365. break;
  366. case 120:
  367. reg |= BCSR1_PCVCTL7;
  368. default: return 1;
  369. }
  370. if(vcc == 120)
  371. return 1;
  372. /* first, turn off all power */
  373. *((uint *)RPX_CSR_ADDR) &= ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5
  374. | BCSR1_PCVCTL6 | BCSR1_PCVCTL7);
  375. /* enable new powersettings */
  376. *((uint *)RPX_CSR_ADDR) |= reg;
  377. return 0;
  378. }
  379. #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
  380. static int hardware_enable (int slot)
  381. {
  382. return 0; /* No hardware to enable */
  383. }
  384. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  385. static int hardware_disable(int slot)
  386. {
  387. return 0; /* No hardware to disable */
  388. }
  389. #endif /* CFG_CMD_PCMCIA */
  390. #endif /* CONFIG_RPXCLASSIC */
  391. /* -------------------------------------------------------------------- */
  392. /* (F)ADS Boards from Motorola */
  393. /* -------------------------------------------------------------------- */
  394. #if defined(CONFIG_ADS) || defined(CONFIG_FADS)
  395. #ifdef CONFIG_ADS
  396. #define PCMCIA_BOARD_MSG "ADS"
  397. #define PCMCIA_GLITCHY_CD /* My ADS board needs this */
  398. #else
  399. #define PCMCIA_BOARD_MSG "FADS"
  400. #endif
  401. static int voltage_set(int slot, int vcc, int vpp)
  402. {
  403. u_long reg = 0;
  404. switch(vpp) {
  405. case 0: reg = 0; break;
  406. case 50: reg = 1; break;
  407. case 120: reg = 2; break;
  408. default: return 1;
  409. }
  410. switch(vcc) {
  411. case 0: reg = 0; break;
  412. #ifdef CONFIG_ADS
  413. case 50: reg = BCSR1_PCCVCCON; break;
  414. #endif
  415. #ifdef CONFIG_FADS
  416. case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break;
  417. case 50: reg = BCSR1_PCCVCC1; break;
  418. #endif
  419. default: return 1;
  420. }
  421. /* first, turn off all power */
  422. #ifdef CONFIG_ADS
  423. *((uint *)BCSR1) |= BCSR1_PCCVCCON;
  424. #endif
  425. #ifdef CONFIG_FADS
  426. *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
  427. #endif
  428. *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
  429. /* enable new powersettings */
  430. #ifdef CONFIG_ADS
  431. *((uint *)BCSR1) &= ~reg;
  432. #endif
  433. #ifdef CONFIG_FADS
  434. *((uint *)BCSR1) |= reg;
  435. #endif
  436. *((uint *)BCSR1) |= reg << 20;
  437. return 0;
  438. }
  439. #define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
  440. static int hardware_enable(int slot)
  441. {
  442. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  443. return 0;
  444. }
  445. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  446. static int hardware_disable(int slot)
  447. {
  448. *((uint *)BCSR1) &= ~BCSR1_PCCEN;
  449. return 0;
  450. }
  451. #endif /* CFG_CMD_PCMCIA */
  452. #endif /* (F)ADS */
  453. /* -------------------------------------------------------------------- */
  454. /* TQM8xxL Boards by TQ Components */
  455. /* SC8xx Boards by SinoVee Microsystems */
  456. /* -------------------------------------------------------------------- */
  457. #if defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx)
  458. #if defined(CONFIG_TQM8xxL)
  459. #define PCMCIA_BOARD_MSG "TQM8xxL"
  460. #endif
  461. #if defined(CONFIG_SVM_SC8xx)
  462. #define PCMCIA_BOARD_MSG "SC8xx"
  463. #endif
  464. static int hardware_enable(int slot)
  465. {
  466. volatile immap_t *immap;
  467. volatile cpm8xx_t *cp;
  468. volatile pcmconf8xx_t *pcmp;
  469. volatile sysconf8xx_t *sysp;
  470. uint reg, mask;
  471. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  472. udelay(10000);
  473. immap = (immap_t *)CFG_IMMR;
  474. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  475. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  476. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  477. /*
  478. * Configure SIUMCR to enable PCMCIA port B
  479. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  480. */
  481. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  482. /* clear interrupt state, and disable interrupts */
  483. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  484. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  485. /*
  486. * Disable interrupts, DMA, and PCMCIA buffers
  487. * (isolate the interface) and assert RESET signal
  488. */
  489. debug ("Disable PCMCIA buffers and assert RESET\n");
  490. reg = 0;
  491. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  492. #ifndef NSCU_OE_INV
  493. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  494. #endif
  495. PCMCIA_PGCRX(slot) = reg;
  496. udelay(500);
  497. #ifndef CONFIG_NSCU
  498. /*
  499. * Configure Port C pins for
  500. * 5 Volts Enable and 3 Volts enable
  501. */
  502. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  503. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  504. /* remove all power */
  505. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  506. #endif
  507. /*
  508. * Make sure there is a card in the slot, then configure the interface.
  509. */
  510. udelay(10000);
  511. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  512. __LINE__,__FUNCTION__,
  513. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  514. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  515. printf (" No Card found\n");
  516. return (1);
  517. }
  518. /*
  519. * Power On.
  520. */
  521. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  522. reg = pcmp->pcmc_pipr;
  523. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  524. reg,
  525. (reg&PCMCIA_VS1(slot))?"n":"ff",
  526. (reg&PCMCIA_VS2(slot))?"n":"ff");
  527. #ifndef CONFIG_NSCU
  528. if ((reg & mask) == mask) {
  529. immap->im_ioport.iop_pcdat |= 0x0004;
  530. puts (" 5.0V card found: ");
  531. } else {
  532. immap->im_ioport.iop_pcdat |= 0x0002;
  533. puts (" 3.3V card found: ");
  534. }
  535. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  536. #else
  537. if ((reg & mask) == mask) {
  538. puts (" 5.0V card found: ");
  539. } else {
  540. puts (" 3.3V card found: ");
  541. }
  542. #endif
  543. #if 0
  544. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  545. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  546. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  547. udelay(500000);
  548. #endif
  549. udelay(1000);
  550. debug ("Enable PCMCIA buffers and stop RESET\n");
  551. reg = PCMCIA_PGCRX(slot);
  552. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  553. #ifndef NSCU_OE_INV
  554. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  555. #else
  556. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  557. #endif
  558. PCMCIA_PGCRX(slot) = reg;
  559. udelay(250000); /* some cards need >150 ms to come up :-( */
  560. debug ("# hardware_enable done\n");
  561. return (0);
  562. }
  563. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  564. static int hardware_disable(int slot)
  565. {
  566. volatile immap_t *immap;
  567. volatile pcmconf8xx_t *pcmp;
  568. u_long reg;
  569. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  570. immap = (immap_t *)CFG_IMMR;
  571. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  572. #ifndef CONFIG_NSCU
  573. /* remove all power */
  574. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  575. #endif
  576. debug ("Disable PCMCIA buffers and assert RESET\n");
  577. reg = 0;
  578. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  579. #ifndef NSCU_OE_INV
  580. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  581. #endif
  582. PCMCIA_PGCRX(slot) = reg;
  583. udelay(10000);
  584. return (0);
  585. }
  586. #endif /* CFG_CMD_PCMCIA */
  587. #ifdef CONFIG_NSCU
  588. static int voltage_set(int slot, int vcc, int vpp)
  589. {
  590. return 0;
  591. }
  592. #else
  593. static int voltage_set(int slot, int vcc, int vpp)
  594. {
  595. volatile immap_t *immap;
  596. volatile pcmconf8xx_t *pcmp;
  597. u_long reg;
  598. debug ("voltage_set: "
  599. PCMCIA_BOARD_MSG
  600. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  601. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  602. immap = (immap_t *)CFG_IMMR;
  603. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  604. /*
  605. * Disable PCMCIA buffers (isolate the interface)
  606. * and assert RESET signal
  607. */
  608. debug ("Disable PCMCIA buffers and assert RESET\n");
  609. reg = PCMCIA_PGCRX(slot);
  610. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  611. #ifndef NSCU_OE_INV
  612. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  613. #else
  614. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  615. #endif
  616. PCMCIA_PGCRX(slot) = reg;
  617. udelay(500);
  618. /*
  619. * Configure Port C pins for
  620. * 5 Volts Enable and 3 Volts enable,
  621. * Turn off all power
  622. */
  623. debug ("PCMCIA power OFF\n");
  624. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  625. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  626. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  627. reg = 0;
  628. switch(vcc) {
  629. case 0: break;
  630. case 33: reg |= 0x0002; break;
  631. case 50: reg |= 0x0004; break;
  632. default: goto done;
  633. }
  634. /* Checking supported voltages */
  635. debug ("PIPR: 0x%x --> %s\n",
  636. pcmp->pcmc_pipr,
  637. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  638. immap->im_ioport.iop_pcdat |= reg;
  639. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  640. if (reg) {
  641. debug ("PCMCIA powered at %sV\n",
  642. (reg&0x0004) ? "5.0" : "3.3");
  643. } else {
  644. debug ("PCMCIA powered down\n");
  645. }
  646. done:
  647. debug ("Enable PCMCIA buffers and stop RESET\n");
  648. reg = PCMCIA_PGCRX(slot);
  649. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  650. #ifndef NSCU_OE_INV
  651. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  652. #else
  653. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  654. #endif
  655. PCMCIA_PGCRX(slot) = reg;
  656. udelay(500);
  657. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  658. slot+'A');
  659. return (0);
  660. }
  661. #endif
  662. #endif /* TQM8xxL */
  663. /* -------------------------------------------------------------------- */
  664. /* LWMON Board */
  665. /* -------------------------------------------------------------------- */
  666. #if defined(CONFIG_LWMON)
  667. #define PCMCIA_BOARD_MSG "LWMON"
  668. /* #define's for MAX1604 Power Switch */
  669. #define MAX1604_OP_SUS 0x80
  670. #define MAX1604_VCCBON 0x40
  671. #define MAX1604_VCC_35 0x20
  672. #define MAX1604_VCCBHIZ 0x10
  673. #define MAX1604_VPPBON 0x08
  674. #define MAX1604_VPPBPBPGM 0x04
  675. #define MAX1604_VPPBHIZ 0x02
  676. /* reserved 0x01 */
  677. static int hardware_enable(int slot)
  678. {
  679. volatile immap_t *immap;
  680. volatile cpm8xx_t *cp;
  681. volatile pcmconf8xx_t *pcmp;
  682. volatile sysconf8xx_t *sysp;
  683. uint reg, mask;
  684. uchar val;
  685. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  686. /* Switch on PCMCIA port in PIC register 0x60 */
  687. reg = pic_read (0x60);
  688. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  689. reg &= ~0x10;
  690. /* reg |= 0x08; Vpp not needed */
  691. pic_write (0x60, reg);
  692. #ifdef DEBUG
  693. reg = pic_read (0x60);
  694. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  695. #endif
  696. udelay(10000);
  697. immap = (immap_t *)CFG_IMMR;
  698. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  699. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  700. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  701. /*
  702. * Configure SIUMCR to enable PCMCIA port B
  703. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  704. */
  705. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  706. /* clear interrupt state, and disable interrupts */
  707. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  708. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  709. /*
  710. * Disable interrupts, DMA, and PCMCIA buffers
  711. * (isolate the interface) and assert RESET signal
  712. */
  713. debug ("Disable PCMCIA buffers and assert RESET\n");
  714. reg = 0;
  715. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  716. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  717. PCMCIA_PGCRX(_slot_) = reg;
  718. udelay(500);
  719. /*
  720. * Make sure there is a card in the slot, then configure the interface.
  721. */
  722. udelay(10000);
  723. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  724. __LINE__,__FUNCTION__,
  725. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  726. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  727. printf (" No Card found\n");
  728. return (1);
  729. }
  730. /*
  731. * Power On.
  732. */
  733. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  734. reg = pcmp->pcmc_pipr;
  735. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  736. reg,
  737. (reg&PCMCIA_VS1(slot))?"n":"ff",
  738. (reg&PCMCIA_VS2(slot))?"n":"ff");
  739. if ((reg & mask) == mask) {
  740. val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
  741. puts (" 5.0V card found: ");
  742. } else {
  743. val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
  744. puts (" 3.3V card found: ");
  745. }
  746. /* switch VCC on */
  747. val |= MAX1604_OP_SUS | MAX1604_VCCBON;
  748. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  749. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  750. udelay(500000);
  751. debug ("Enable PCMCIA buffers and stop RESET\n");
  752. reg = PCMCIA_PGCRX(_slot_);
  753. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  754. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  755. PCMCIA_PGCRX(_slot_) = reg;
  756. udelay(250000); /* some cards need >150 ms to come up :-( */
  757. debug ("# hardware_enable done\n");
  758. return (0);
  759. }
  760. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  761. static int hardware_disable(int slot)
  762. {
  763. volatile immap_t *immap;
  764. volatile pcmconf8xx_t *pcmp;
  765. u_long reg;
  766. uchar val;
  767. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  768. immap = (immap_t *)CFG_IMMR;
  769. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  770. /* remove all power, put output in high impedance state */
  771. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  772. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  773. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  774. /* Configure PCMCIA General Control Register */
  775. debug ("Disable PCMCIA buffers and assert RESET\n");
  776. reg = 0;
  777. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  778. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  779. PCMCIA_PGCRX(_slot_) = reg;
  780. /* Switch off PCMCIA port in PIC register 0x60 */
  781. reg = pic_read (0x60);
  782. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  783. reg |= 0x10;
  784. reg &= ~0x08;
  785. pic_write (0x60, reg);
  786. #ifdef DEBUG
  787. reg = pic_read (0x60);
  788. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  789. #endif
  790. udelay(10000);
  791. return (0);
  792. }
  793. #endif /* CFG_CMD_PCMCIA */
  794. static int voltage_set(int slot, int vcc, int vpp)
  795. {
  796. volatile immap_t *immap;
  797. volatile pcmconf8xx_t *pcmp;
  798. u_long reg;
  799. uchar val;
  800. debug ("voltage_set: "
  801. PCMCIA_BOARD_MSG
  802. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  803. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  804. immap = (immap_t *)CFG_IMMR;
  805. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  806. /*
  807. * Disable PCMCIA buffers (isolate the interface)
  808. * and assert RESET signal
  809. */
  810. debug ("Disable PCMCIA buffers and assert RESET\n");
  811. reg = PCMCIA_PGCRX(_slot_);
  812. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  813. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  814. PCMCIA_PGCRX(_slot_) = reg;
  815. udelay(500);
  816. /*
  817. * Turn off all power (switch to high impedance)
  818. */
  819. debug ("PCMCIA power OFF\n");
  820. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  821. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  822. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  823. val = 0;
  824. switch(vcc) {
  825. case 0: break;
  826. case 33: val = MAX1604_VCC_35; break;
  827. case 50: break;
  828. default: goto done;
  829. }
  830. /* Checking supported voltages */
  831. debug ("PIPR: 0x%x --> %s\n",
  832. pcmp->pcmc_pipr,
  833. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  834. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  835. if (val) {
  836. debug ("PCMCIA powered at %sV\n",
  837. (val & MAX1604_VCC_35) ? "3.3" : "5.0");
  838. } else {
  839. debug ("PCMCIA powered down\n");
  840. }
  841. done:
  842. debug ("Enable PCMCIA buffers and stop RESET\n");
  843. reg = PCMCIA_PGCRX(_slot_);
  844. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  845. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  846. PCMCIA_PGCRX(_slot_) = reg;
  847. udelay(500);
  848. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  849. slot+'A');
  850. return (0);
  851. }
  852. #endif /* LWMON */
  853. /* -------------------------------------------------------------------- */
  854. /* GTH board by Corelatus AB */
  855. /* -------------------------------------------------------------------- */
  856. #if defined(CONFIG_GTH)
  857. #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
  858. static int voltage_set (int slot, int vcc, int vpp)
  859. { /* Do nothing */
  860. return 0;
  861. }
  862. static int hardware_enable (int slot)
  863. {
  864. volatile immap_t *immap;
  865. volatile cpm8xx_t *cp;
  866. volatile pcmconf8xx_t *pcmp;
  867. volatile sysconf8xx_t *sysp;
  868. uint reg, mask;
  869. debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
  870. immap = (immap_t *) CFG_IMMR;
  871. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  872. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  873. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  874. /* clear interrupt state, and disable interrupts */
  875. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  876. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  877. /*
  878. * Disable interrupts, DMA, and PCMCIA buffers
  879. * (isolate the interface) and assert RESET signal
  880. */
  881. debug ("Disable PCMCIA buffers and assert RESET\n");
  882. reg = 0;
  883. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  884. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  885. PCMCIA_PGCRX (_slot_) = reg;
  886. udelay (500);
  887. /*
  888. * Make sure there is a card in the slot,
  889. * then configure the interface.
  890. */
  891. udelay (10000);
  892. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  893. __LINE__, __FUNCTION__,
  894. &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
  895. if (pcmp->pcmc_pipr & 0x98000000) {
  896. printf (" No Card found\n");
  897. return (1);
  898. }
  899. mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
  900. reg = pcmp->pcmc_pipr;
  901. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  902. reg,
  903. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  904. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  905. debug ("Enable PCMCIA buffers and stop RESET\n");
  906. reg = PCMCIA_PGCRX (_slot_);
  907. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  908. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  909. PCMCIA_PGCRX (_slot_) = reg;
  910. udelay (250000); /* some cards need >150 ms to come up :-( */
  911. debug ("# hardware_enable done\n");
  912. return 0;
  913. }
  914. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  915. static int hardware_disable(int slot)
  916. {
  917. return 0; /* No hardware to disable */
  918. }
  919. #endif /* CFG_CMD_PCMCIA */
  920. #endif /* CONFIG_GTH */
  921. /* -------------------------------------------------------------------- */
  922. /* ICU862 Boards by Cambridge Broadband Ltd. */
  923. /* -------------------------------------------------------------------- */
  924. #if defined(CONFIG_ICU862)
  925. #define PCMCIA_BOARD_MSG "ICU862"
  926. static void cfg_port_B (void);
  927. static int hardware_enable(int slot)
  928. {
  929. volatile immap_t *immap;
  930. volatile cpm8xx_t *cp;
  931. volatile pcmconf8xx_t *pcmp;
  932. volatile sysconf8xx_t *sysp;
  933. uint reg, pipr, mask;
  934. int i;
  935. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  936. udelay(10000);
  937. immap = (immap_t *)CFG_IMMR;
  938. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  939. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  940. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  941. /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
  942. cfg_port_B ();
  943. /*
  944. * Configure SIUMCR to enable PCMCIA port B
  945. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  946. */
  947. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  948. /* clear interrupt state, and disable interrupts */
  949. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  950. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  951. /*
  952. * Disable interrupts, DMA, and PCMCIA buffers
  953. * (isolate the interface) and assert RESET signal
  954. */
  955. debug ("Disable PCMCIA buffers and assert RESET\n");
  956. reg = 0;
  957. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  958. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  959. PCMCIA_PGCRX(_slot_) = reg;
  960. udelay(500);
  961. /*
  962. * Make sure there is a card in the slot, then configure the interface.
  963. */
  964. udelay(10000);
  965. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  966. __LINE__,__FUNCTION__,
  967. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  968. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  969. printf (" No Card found\n");
  970. return (1);
  971. }
  972. /*
  973. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  974. */
  975. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  976. pipr = pcmp->pcmc_pipr;
  977. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  978. pipr,
  979. (reg&PCMCIA_VS1(slot))?"n":"ff",
  980. (reg&PCMCIA_VS2(slot))?"n":"ff");
  981. reg = cp->cp_pbdat;
  982. if ((pipr & mask) == mask) {
  983. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  984. TPS2205_VCC3); /* 3V off */
  985. reg &= ~(TPS2205_VCC5); /* 5V on */
  986. puts (" 5.0V card found: ");
  987. } else {
  988. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  989. TPS2205_VCC5); /* 5V off */
  990. reg &= ~(TPS2205_VCC3); /* 3V on */
  991. puts (" 3.3V card found: ");
  992. }
  993. debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
  994. reg,
  995. (reg & TPS2205_VCC3) ? "off" : "on",
  996. (reg & TPS2205_VCC5) ? "off" : "on",
  997. (reg & TPS2205_VPP_PGM) ? "off" : "on",
  998. (reg & TPS2205_VPP_VCC) ? "off" : "on" );
  999. cp->cp_pbdat = reg;
  1000. /* Wait 500 ms; use this to check for over-current */
  1001. for (i=0; i<5000; ++i) {
  1002. if ((cp->cp_pbdat & TPS2205_OC) == 0) {
  1003. printf (" *** Overcurrent - Safety shutdown ***\n");
  1004. cp->cp_pbdat &= ~(TPS2205_SHDN);
  1005. return (1);
  1006. }
  1007. udelay (100);
  1008. }
  1009. debug ("Enable PCMCIA buffers and stop RESET\n");
  1010. reg = PCMCIA_PGCRX(_slot_);
  1011. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1012. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1013. PCMCIA_PGCRX(_slot_) = reg;
  1014. udelay(250000); /* some cards need >150 ms to come up :-( */
  1015. debug ("# hardware_enable done\n");
  1016. return (0);
  1017. }
  1018. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1019. static int hardware_disable(int slot)
  1020. {
  1021. volatile immap_t *immap;
  1022. volatile cpm8xx_t *cp;
  1023. volatile pcmconf8xx_t *pcmp;
  1024. u_long reg;
  1025. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1026. immap = (immap_t *)CFG_IMMR;
  1027. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1028. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1029. /* Shut down */
  1030. cp->cp_pbdat &= ~(TPS2205_SHDN);
  1031. /* Configure PCMCIA General Control Register */
  1032. debug ("Disable PCMCIA buffers and assert RESET\n");
  1033. reg = 0;
  1034. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1035. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1036. PCMCIA_PGCRX(_slot_) = reg;
  1037. udelay(10000);
  1038. return (0);
  1039. }
  1040. #endif /* CFG_CMD_PCMCIA */
  1041. static int voltage_set(int slot, int vcc, int vpp)
  1042. {
  1043. volatile immap_t *immap;
  1044. volatile cpm8xx_t *cp;
  1045. volatile pcmconf8xx_t *pcmp;
  1046. u_long reg;
  1047. debug ("voltage_set: "
  1048. PCMCIA_BOARD_MSG
  1049. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1050. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1051. immap = (immap_t *)CFG_IMMR;
  1052. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1053. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1054. /*
  1055. * Disable PCMCIA buffers (isolate the interface)
  1056. * and assert RESET signal
  1057. */
  1058. debug ("Disable PCMCIA buffers and assert RESET\n");
  1059. reg = PCMCIA_PGCRX(_slot_);
  1060. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1061. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1062. PCMCIA_PGCRX(_slot_) = reg;
  1063. udelay(500);
  1064. /*
  1065. * Configure Port C pins for
  1066. * 5 Volts Enable and 3 Volts enable,
  1067. * Turn all power pins to Hi-Z
  1068. */
  1069. debug ("PCMCIA power OFF\n");
  1070. cfg_port_B (); /* Enables switch, but all in Hi-Z */
  1071. reg = cp->cp_pbdat;
  1072. switch(vcc) {
  1073. case 0: break; /* Switch off */
  1074. case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
  1075. case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
  1076. default: goto done;
  1077. }
  1078. /* Checking supported voltages */
  1079. debug ("PIPR: 0x%x --> %s\n",
  1080. pcmp->pcmc_pipr,
  1081. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1082. cp->cp_pbdat = reg;
  1083. #ifdef DEBUG
  1084. {
  1085. char *s;
  1086. if ((reg & TPS2205_VCC3) == 0) {
  1087. s = "at 3.3V";
  1088. } else if ((reg & TPS2205_VCC5) == 0) {
  1089. s = "at 5.0V";
  1090. } else {
  1091. s = "down";
  1092. }
  1093. printf ("PCMCIA powered %s\n", s);
  1094. }
  1095. #endif
  1096. done:
  1097. debug ("Enable PCMCIA buffers and stop RESET\n");
  1098. reg = PCMCIA_PGCRX(_slot_);
  1099. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1100. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1101. PCMCIA_PGCRX(_slot_) = reg;
  1102. udelay(500);
  1103. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1104. slot+'A');
  1105. return (0);
  1106. }
  1107. static void cfg_port_B (void)
  1108. {
  1109. volatile immap_t *immap;
  1110. volatile cpm8xx_t *cp;
  1111. uint reg;
  1112. immap = (immap_t *)CFG_IMMR;
  1113. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1114. /*
  1115. * Configure Port B for TPS2205 PC-Card Power-Interface Switch
  1116. *
  1117. * Switch off all voltages, assert shutdown
  1118. */
  1119. reg = cp->cp_pbdat;
  1120. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1121. TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
  1122. TPS2205_SHDN); /* enable switch */
  1123. cp->cp_pbdat = reg;
  1124. cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
  1125. reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
  1126. cp->cp_pbdir = reg | TPS2205_OUTPUTS;
  1127. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1128. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1129. }
  1130. #endif /* ICU862 */
  1131. /* -------------------------------------------------------------------- */
  1132. /* C2MON Boards by TTTech Computertechnik AG */
  1133. /* -------------------------------------------------------------------- */
  1134. #if defined(CONFIG_C2MON)
  1135. #define PCMCIA_BOARD_MSG "C2MON"
  1136. static void cfg_ports (void);
  1137. static int hardware_enable(int slot)
  1138. {
  1139. volatile immap_t *immap;
  1140. volatile cpm8xx_t *cp;
  1141. volatile pcmconf8xx_t *pcmp;
  1142. volatile sysconf8xx_t *sysp;
  1143. uint reg, pipr, mask;
  1144. ushort sreg;
  1145. int i;
  1146. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1147. udelay(10000);
  1148. immap = (immap_t *)CFG_IMMR;
  1149. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1150. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1151. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1152. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  1153. cfg_ports ();
  1154. /*
  1155. * Configure SIUMCR to enable PCMCIA port B
  1156. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1157. */
  1158. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1159. /* clear interrupt state, and disable interrupts */
  1160. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1161. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1162. /*
  1163. * Disable interrupts, DMA, and PCMCIA buffers
  1164. * (isolate the interface) and assert RESET signal
  1165. */
  1166. debug ("Disable PCMCIA buffers and assert RESET\n");
  1167. reg = 0;
  1168. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1169. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1170. PCMCIA_PGCRX(_slot_) = reg;
  1171. udelay(500);
  1172. /*
  1173. * Make sure there is a card in the slot, then configure the interface.
  1174. */
  1175. udelay(10000);
  1176. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1177. __LINE__,__FUNCTION__,
  1178. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1179. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1180. printf (" No Card found\n");
  1181. return (1);
  1182. }
  1183. /*
  1184. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1185. */
  1186. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1187. pipr = pcmp->pcmc_pipr;
  1188. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1189. pipr,
  1190. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1191. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1192. sreg = immap->im_ioport.iop_pcdat;
  1193. if ((pipr & mask) == mask) {
  1194. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1195. TPS2211_VCCD1); /* 5V on */
  1196. sreg &= ~(TPS2211_VCCD0); /* 3V off */
  1197. puts (" 5.0V card found: ");
  1198. } else {
  1199. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1200. TPS2211_VCCD0); /* 3V on */
  1201. sreg &= ~(TPS2211_VCCD1); /* 5V off */
  1202. puts (" 3.3V card found: ");
  1203. }
  1204. debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
  1205. sreg,
  1206. ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
  1207. (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
  1208. );
  1209. immap->im_ioport.iop_pcdat = sreg;
  1210. /* Wait 500 ms; use this to check for over-current */
  1211. for (i=0; i<5000; ++i) {
  1212. if ((cp->cp_pbdat & TPS2211_OC) == 0) {
  1213. printf (" *** Overcurrent - Safety shutdown ***\n");
  1214. immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
  1215. return (1);
  1216. }
  1217. udelay (100);
  1218. }
  1219. debug ("Enable PCMCIA buffers and stop RESET\n");
  1220. reg = PCMCIA_PGCRX(_slot_);
  1221. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1222. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1223. PCMCIA_PGCRX(_slot_) = reg;
  1224. udelay(250000); /* some cards need >150 ms to come up :-( */
  1225. debug ("# hardware_enable done\n");
  1226. return (0);
  1227. }
  1228. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1229. static int hardware_disable(int slot)
  1230. {
  1231. volatile immap_t *immap;
  1232. volatile cpm8xx_t *cp;
  1233. volatile pcmconf8xx_t *pcmp;
  1234. u_long reg;
  1235. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1236. immap = (immap_t *)CFG_IMMR;
  1237. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1238. /* Configure PCMCIA General Control Register */
  1239. debug ("Disable PCMCIA buffers and assert RESET\n");
  1240. reg = 0;
  1241. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1242. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1243. PCMCIA_PGCRX(_slot_) = reg;
  1244. /* ALl voltages off / Hi-Z */
  1245. immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
  1246. TPS2211_VCCD0 | TPS2211_VCCD1 );
  1247. udelay(10000);
  1248. return (0);
  1249. }
  1250. #endif /* CFG_CMD_PCMCIA */
  1251. static int voltage_set(int slot, int vcc, int vpp)
  1252. {
  1253. volatile immap_t *immap;
  1254. volatile cpm8xx_t *cp;
  1255. volatile pcmconf8xx_t *pcmp;
  1256. u_long reg;
  1257. ushort sreg;
  1258. debug ("voltage_set: "
  1259. PCMCIA_BOARD_MSG
  1260. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1261. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1262. immap = (immap_t *)CFG_IMMR;
  1263. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1264. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1265. /*
  1266. * Disable PCMCIA buffers (isolate the interface)
  1267. * and assert RESET signal
  1268. */
  1269. debug ("Disable PCMCIA buffers and assert RESET\n");
  1270. reg = PCMCIA_PGCRX(_slot_);
  1271. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1272. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1273. PCMCIA_PGCRX(_slot_) = reg;
  1274. udelay(500);
  1275. /*
  1276. * Configure Port C pins for
  1277. * 5 Volts Enable and 3 Volts enable,
  1278. * Turn all power pins to Hi-Z
  1279. */
  1280. debug ("PCMCIA power OFF\n");
  1281. cfg_ports (); /* Enables switch, but all in Hi-Z */
  1282. sreg = immap->im_ioport.iop_pcdat;
  1283. sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
  1284. switch(vcc) {
  1285. case 0: break; /* Switch off */
  1286. case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
  1287. sreg &= ~TPS2211_VCCD1;
  1288. break;
  1289. case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
  1290. sreg |= TPS2211_VCCD1;
  1291. break;
  1292. default: goto done;
  1293. }
  1294. /* Checking supported voltages */
  1295. debug ("PIPR: 0x%x --> %s\n",
  1296. pcmp->pcmc_pipr,
  1297. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1298. immap->im_ioport.iop_pcdat = sreg;
  1299. #ifdef DEBUG
  1300. {
  1301. char *s;
  1302. if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
  1303. s = "at 3.3V";
  1304. } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
  1305. s = "at 5.0V";
  1306. } else {
  1307. s = "down";
  1308. }
  1309. printf ("PCMCIA powered %s\n", s);
  1310. }
  1311. #endif
  1312. done:
  1313. debug ("Enable PCMCIA buffers and stop RESET\n");
  1314. reg = PCMCIA_PGCRX(_slot_);
  1315. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1316. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1317. PCMCIA_PGCRX(_slot_) = reg;
  1318. udelay(500);
  1319. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1320. slot+'A');
  1321. return (0);
  1322. }
  1323. static void cfg_ports (void)
  1324. {
  1325. volatile immap_t *immap;
  1326. volatile cpm8xx_t *cp;
  1327. ushort sreg;
  1328. immap = (immap_t *)CFG_IMMR;
  1329. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1330. /*
  1331. * Configure Port C for TPS2211 PC-Card Power-Interface Switch
  1332. *
  1333. * Switch off all voltages, assert shutdown
  1334. */
  1335. sreg = immap->im_ioport.iop_pcdat;
  1336. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
  1337. sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
  1338. immap->im_ioport.iop_pcdat = sreg;
  1339. immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
  1340. immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
  1341. debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
  1342. immap->im_ioport.iop_pcpar,
  1343. immap->im_ioport.iop_pcdir,
  1344. immap->im_ioport.iop_pcdat);
  1345. /*
  1346. * Configure Port B for TPS2211 PC-Card Power-Interface Switch
  1347. *
  1348. * Over-Current Input only
  1349. */
  1350. cp->cp_pbpar &= ~(TPS2211_INPUTS);
  1351. cp->cp_pbdir &= ~(TPS2211_INPUTS);
  1352. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1353. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1354. }
  1355. #endif /* C2MON */
  1356. /* -------------------------------------------------------------------- */
  1357. /* MBX board from Morotola */
  1358. /* -------------------------------------------------------------------- */
  1359. #if defined( CONFIG_MBX )
  1360. #include <../board/mbx8xx/csr.h>
  1361. /* A lot of this has been taken from the RPX code in this file it works from me.
  1362. I have added the voltage selection for the MBX board. */
  1363. /* MBX voltage bit in control register #2 */
  1364. #define CR2_VPP12 ((uchar)0x10)
  1365. #define CR2_VPPVDD ((uchar)0x20)
  1366. #define CR2_VDD5 ((uchar)0x40)
  1367. #define CR2_VDD3 ((uchar)0x80)
  1368. #define PCMCIA_BOARD_MSG "MBX860"
  1369. static int voltage_set (int slot, int vcc, int vpp)
  1370. {
  1371. uchar reg = 0;
  1372. debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1373. 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
  1374. switch (vcc) {
  1375. case 0:
  1376. break;
  1377. case 33:
  1378. reg |= CR2_VDD3;
  1379. break;
  1380. case 50:
  1381. reg |= CR2_VDD5;
  1382. break;
  1383. default:
  1384. return 1;
  1385. }
  1386. switch (vpp) {
  1387. case 0:
  1388. break;
  1389. case 33:
  1390. case 50:
  1391. if (vcc == vpp) {
  1392. reg |= CR2_VPPVDD;
  1393. } else {
  1394. return 1;
  1395. }
  1396. break;
  1397. case 120:
  1398. reg |= CR2_VPP12;
  1399. break;
  1400. default:
  1401. return 1;
  1402. }
  1403. /* first, turn off all power */
  1404. MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
  1405. /* enable new powersettings */
  1406. MBX_CSR2 |= reg;
  1407. debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
  1408. return (0);
  1409. }
  1410. static int hardware_enable (int slot)
  1411. {
  1412. volatile immap_t *immap;
  1413. volatile cpm8xx_t *cp;
  1414. volatile pcmconf8xx_t *pcmp;
  1415. volatile sysconf8xx_t *sysp;
  1416. uint reg, mask;
  1417. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
  1418. 'A' + slot);
  1419. udelay (10000);
  1420. immap = (immap_t *) CFG_IMMR;
  1421. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1422. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1423. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1424. /* clear interrupt state, and disable interrupts */
  1425. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1426. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1427. /*
  1428. * Disable interrupts, DMA, and PCMCIA buffers
  1429. * (isolate the interface) and assert RESET signal
  1430. */
  1431. debug ("Disable PCMCIA buffers and assert RESET\n");
  1432. reg = 0;
  1433. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1434. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1435. PCMCIA_PGCRX (_slot_) = reg;
  1436. udelay (500);
  1437. /* remove all power */
  1438. voltage_set (slot, 0, 0);
  1439. /*
  1440. * Make sure there is a card in the slot, then configure the interface.
  1441. */
  1442. udelay(10000);
  1443. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1444. __LINE__,__FUNCTION__,
  1445. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1446. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1447. printf (" No Card found\n");
  1448. return (1);
  1449. }
  1450. /*
  1451. * Power On.
  1452. */
  1453. mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
  1454. reg = pcmp->pcmc_pipr;
  1455. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  1456. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1457. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1458. if ((reg & mask) == mask) {
  1459. voltage_set (_slot_, 50, 0);
  1460. printf (" 5.0V card found: ");
  1461. } else {
  1462. voltage_set (_slot_, 33, 0);
  1463. printf (" 3.3V card found: ");
  1464. }
  1465. debug ("Enable PCMCIA buffers and stop RESET\n");
  1466. reg = PCMCIA_PGCRX (_slot_);
  1467. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1468. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1469. PCMCIA_PGCRX (_slot_) = reg;
  1470. udelay (250000); /* some cards need >150 ms to come up :-( */
  1471. debug ("# hardware_enable done\n");
  1472. return (0);
  1473. }
  1474. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1475. static int hardware_disable (int slot)
  1476. {
  1477. return 0; /* No hardware to disable */
  1478. }
  1479. #endif /* CFG_CMD_PCMCIA */
  1480. #endif /* CONFIG_MBX */
  1481. /* -------------------------------------------------------------------- */
  1482. /* R360MPI Board */
  1483. /* -------------------------------------------------------------------- */
  1484. #if defined(CONFIG_R360MPI)
  1485. #define PCMCIA_BOARD_MSG "R360MPI"
  1486. static int hardware_enable(int slot)
  1487. {
  1488. volatile immap_t *immap;
  1489. volatile cpm8xx_t *cp;
  1490. volatile pcmconf8xx_t *pcmp;
  1491. volatile sysconf8xx_t *sysp;
  1492. uint reg, mask;
  1493. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1494. udelay(10000);
  1495. immap = (immap_t *)CFG_IMMR;
  1496. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1497. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1498. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1499. /*
  1500. * Configure SIUMCR to enable PCMCIA port B
  1501. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1502. */
  1503. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1504. /* clear interrupt state, and disable interrupts */
  1505. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1506. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1507. /*
  1508. * Disable interrupts, DMA, and PCMCIA buffers
  1509. * (isolate the interface) and assert RESET signal
  1510. */
  1511. debug ("Disable PCMCIA buffers and assert RESET\n");
  1512. reg = 0;
  1513. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1514. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1515. PCMCIA_PGCRX(_slot_) = reg;
  1516. udelay(500);
  1517. /*
  1518. * Configure Ports A, B & C pins for
  1519. * 5 Volts Enable and 3 Volts enable
  1520. */
  1521. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1522. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1523. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1524. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1525. immap->im_ioport.iop_padir |= 0x0200;*/
  1526. #if 0
  1527. immap->im_ioport.iop_pbpar &= ~(0xC000);
  1528. immap->im_ioport.iop_pbdir &= ~(0xC000);
  1529. #endif
  1530. /* remove all power */
  1531. immap->im_ioport.iop_pcdat |= 0x0400;
  1532. immap->im_ioport.iop_padat |= 0x0200;
  1533. /*
  1534. * Make sure there is a card in the slot, then configure the interface.
  1535. */
  1536. udelay(10000);
  1537. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1538. __LINE__,__FUNCTION__,
  1539. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1540. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1541. printf (" No Card found\n");
  1542. return (1);
  1543. }
  1544. /*
  1545. * Power On.
  1546. */
  1547. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1548. reg = pcmp->pcmc_pipr;
  1549. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1550. reg,
  1551. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1552. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1553. if ((reg & mask) == mask) {
  1554. immap->im_ioport.iop_pcdat &= ~(0x4000);
  1555. puts (" 5.0V card found: ");
  1556. } else {
  1557. immap->im_ioport.iop_padat &= ~(0x0002);
  1558. puts (" 3.3V card found: ");
  1559. }
  1560. immap->im_ioport.iop_pcdir |= 0x0400;
  1561. immap->im_ioport.iop_padir |= 0x0200;
  1562. #if 0
  1563. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1564. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1565. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1566. udelay(500000);
  1567. #endif
  1568. debug ("Enable PCMCIA buffers and stop RESET\n");
  1569. reg = PCMCIA_PGCRX(_slot_);
  1570. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1571. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1572. PCMCIA_PGCRX(_slot_) = reg;
  1573. udelay(250000); /* some cards need >150 ms to come up :-( */
  1574. debug ("# hardware_enable done\n");
  1575. return (0);
  1576. }
  1577. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1578. static int hardware_disable(int slot)
  1579. {
  1580. volatile immap_t *immap;
  1581. volatile pcmconf8xx_t *pcmp;
  1582. u_long reg;
  1583. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1584. immap = (immap_t *)CFG_IMMR;
  1585. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1586. /* remove all power */
  1587. immap->im_ioport.iop_pcdat |= 0x0400;
  1588. immap->im_ioport.iop_padat |= 0x0200;
  1589. /* Configure PCMCIA General Control Register */
  1590. debug ("Disable PCMCIA buffers and assert RESET\n");
  1591. reg = 0;
  1592. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1593. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1594. PCMCIA_PGCRX(_slot_) = reg;
  1595. udelay(10000);
  1596. return (0);
  1597. }
  1598. #endif /* CFG_CMD_PCMCIA */
  1599. static int voltage_set(int slot, int vcc, int vpp)
  1600. {
  1601. volatile immap_t *immap;
  1602. volatile pcmconf8xx_t *pcmp;
  1603. u_long reg;
  1604. debug ("voltage_set: "
  1605. PCMCIA_BOARD_MSG
  1606. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1607. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1608. immap = (immap_t *)CFG_IMMR;
  1609. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1610. /*
  1611. * Disable PCMCIA buffers (isolate the interface)
  1612. * and assert RESET signal
  1613. */
  1614. debug ("Disable PCMCIA buffers and assert RESET\n");
  1615. reg = PCMCIA_PGCRX(_slot_);
  1616. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1617. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1618. PCMCIA_PGCRX(_slot_) = reg;
  1619. udelay(500);
  1620. /*
  1621. * Configure Ports A & C pins for
  1622. * 5 Volts Enable and 3 Volts enable,
  1623. * Turn off all power
  1624. */
  1625. debug ("PCMCIA power OFF\n");
  1626. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1627. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1628. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1629. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1630. immap->im_ioport.iop_padir |= 0x0200;*/
  1631. immap->im_ioport.iop_pcdat |= 0x0400;
  1632. immap->im_ioport.iop_padat |= 0x0200;
  1633. reg = 0;
  1634. switch(vcc) {
  1635. case 0: break;
  1636. case 33: reg |= 0x0200; break;
  1637. case 50: reg |= 0x0400; break;
  1638. default: goto done;
  1639. }
  1640. /* Checking supported voltages */
  1641. debug ("PIPR: 0x%x --> %s\n",
  1642. pcmp->pcmc_pipr,
  1643. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1644. if (reg & 0x0200)
  1645. immap->im_ioport.iop_pcdat &= !reg;
  1646. if (reg & 0x0400)
  1647. immap->im_ioport.iop_padat &= !reg;
  1648. immap->im_ioport.iop_pcdir |= 0x0200;
  1649. immap->im_ioport.iop_padir |= 0x0400;
  1650. if (reg) {
  1651. debug ("PCMCIA powered at %sV\n",
  1652. (reg&0x0400) ? "5.0" : "3.3");
  1653. } else {
  1654. debug ("PCMCIA powered down\n");
  1655. }
  1656. done:
  1657. debug ("Enable PCMCIA buffers and stop RESET\n");
  1658. reg = PCMCIA_PGCRX(_slot_);
  1659. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1660. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1661. PCMCIA_PGCRX(_slot_) = reg;
  1662. udelay(500);
  1663. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1664. slot+'A');
  1665. return (0);
  1666. }
  1667. #endif /* R360MPI */
  1668. /* -------------------------------------------------------------------- */
  1669. /* KUP4K Board */
  1670. /* -------------------------------------------------------------------- */
  1671. #if defined(CONFIG_KUP4K)
  1672. #define PCMCIA_BOARD_MSG "KUP4K"
  1673. #define KUP4K_PCMCIA_B_3V3 (0x00020000)
  1674. static int hardware_enable(int slot)
  1675. {
  1676. volatile immap_t *immap;
  1677. volatile cpm8xx_t *cp;
  1678. volatile pcmconf8xx_t *pcmp;
  1679. volatile sysconf8xx_t *sysp;
  1680. uint reg, mask;
  1681. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1682. udelay(10000);
  1683. immap = (immap_t *)CFG_IMMR;
  1684. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1685. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1686. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1687. /*
  1688. * Configure SIUMCR to enable PCMCIA port B
  1689. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1690. */
  1691. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1692. /* clear interrupt state, and disable interrupts */
  1693. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  1694. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  1695. /*
  1696. * Disable interrupts, DMA, and PCMCIA buffers
  1697. * (isolate the interface) and assert RESET signal
  1698. */
  1699. debug ("Disable PCMCIA buffers and assert RESET\n");
  1700. reg = 0;
  1701. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1702. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1703. PCMCIA_PGCRX(slot) = reg;
  1704. udelay(2500);
  1705. /*
  1706. * Configure Port B pins for
  1707. * 3 Volts enable
  1708. */
  1709. if (slot) { /* Slot A is built-in */
  1710. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  1711. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  1712. /* remove all power */
  1713. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  1714. }
  1715. /*
  1716. * Make sure there is a card in the slot, then configure the interface.
  1717. */
  1718. udelay(10000);
  1719. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1720. __LINE__,__FUNCTION__,
  1721. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1722. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1723. printf (" No Card found\n");
  1724. return (1);
  1725. }
  1726. /*
  1727. * Power On.
  1728. */
  1729. printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
  1730. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1731. reg = pcmp->pcmc_pipr;
  1732. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1733. reg,
  1734. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1735. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1736. if ((reg & mask) == mask) {
  1737. puts (" 5.0V card found: NOT SUPPORTED !!!\n");
  1738. } else {
  1739. if(slot)
  1740. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  1741. puts (" 3.3V card found: ");
  1742. }
  1743. #if 0
  1744. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1745. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1746. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1747. udelay(500000);
  1748. #endif
  1749. debug ("Enable PCMCIA buffers and stop RESET\n");
  1750. reg = PCMCIA_PGCRX(slot);
  1751. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1752. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1753. PCMCIA_PGCRX(slot) = reg;
  1754. udelay(250000); /* some cards need >150 ms to come up :-( */
  1755. debug ("# hardware_enable done\n");
  1756. return (0);
  1757. }
  1758. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1759. static int hardware_disable(int slot)
  1760. {
  1761. volatile immap_t *immap;
  1762. volatile cpm8xx_t *cp;
  1763. volatile pcmconf8xx_t *pcmp;
  1764. u_long reg;
  1765. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1766. immap = (immap_t *)CFG_IMMR;
  1767. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1768. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1769. /* remove all power */
  1770. if (slot)
  1771. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
  1772. /* Configure PCMCIA General Control Register */
  1773. debug ("Disable PCMCIA buffers and assert RESET\n");
  1774. reg = 0;
  1775. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1776. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1777. PCMCIA_PGCRX(slot) = reg;
  1778. udelay(10000);
  1779. return (0);
  1780. }
  1781. #endif /* CFG_CMD_PCMCIA */
  1782. static int voltage_set(int slot, int vcc, int vpp)
  1783. {
  1784. volatile immap_t *immap;
  1785. volatile cpm8xx_t *cp;
  1786. volatile pcmconf8xx_t *pcmp;
  1787. u_long reg;
  1788. debug ("voltage_set: " \
  1789. PCMCIA_BOARD_MSG \
  1790. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1791. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1792. if (!slot) /* Slot A is not configurable */
  1793. return 0;
  1794. immap = (immap_t *)CFG_IMMR;
  1795. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1796. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1797. /*
  1798. * Disable PCMCIA buffers (isolate the interface)
  1799. * and assert RESET signal
  1800. */
  1801. debug ("Disable PCMCIA buffers and assert RESET\n");
  1802. reg = PCMCIA_PGCRX(slot);
  1803. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1804. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1805. PCMCIA_PGCRX(slot) = reg;
  1806. udelay(500);
  1807. debug ("PCMCIA power OFF\n");
  1808. /*
  1809. * Configure Port B pins for
  1810. * 3 Volts enable
  1811. */
  1812. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  1813. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  1814. /* remove all power */
  1815. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  1816. switch(vcc) {
  1817. case 0: break;
  1818. case 33:
  1819. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  1820. debug ("PCMCIA powered at 3.3V\n");
  1821. break;
  1822. case 50:
  1823. debug ("PCMCIA: 5Volt vcc not supported\n");
  1824. break;
  1825. default:
  1826. puts("PCMCIA: vcc not supported");
  1827. break;
  1828. }
  1829. udelay(10000);
  1830. /* Checking supported voltages */
  1831. debug ("PIPR: 0x%x --> %s\n",
  1832. pcmp->pcmc_pipr,
  1833. (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
  1834. ? "only 5 V --> NOT SUPPORTED"
  1835. : "can do 3.3V");
  1836. debug ("Enable PCMCIA buffers and stop RESET\n");
  1837. reg = PCMCIA_PGCRX(slot);
  1838. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1839. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1840. PCMCIA_PGCRX(slot) = reg;
  1841. udelay(500);
  1842. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1843. slot+'A');
  1844. return (0);
  1845. }
  1846. #endif /* KUP4K */
  1847. /* -------------------------------------------------------------------- */
  1848. /* End of Board Specific Stuff */
  1849. /* -------------------------------------------------------------------- */
  1850. /* -------------------------------------------------------------------- */
  1851. /* MPC8xx Specific Stuff - should go to MPC8xx directory */
  1852. /* -------------------------------------------------------------------- */
  1853. /*
  1854. * Search this table to see if the windowsize is
  1855. * supported...
  1856. */
  1857. #define M8XX_SIZES_NO 32
  1858. static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
  1859. { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
  1860. 0x00000080, 0x00000040, 0x00000010, 0x00000020,
  1861. 0x00008000, 0x00004000, 0x00001000, 0x00002000,
  1862. 0x00000100, 0x00000200, 0x00000800, 0x00000400,
  1863. 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  1864. 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
  1865. 0x00010000, 0x00020000, 0x00080000, 0x00040000,
  1866. 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
  1867. /* -------------------------------------------------------------------- */
  1868. #ifndef CONFIG_I82365
  1869. static u_int m8xx_get_graycode(u_int size)
  1870. {
  1871. u_int k;
  1872. for (k = 0; k < M8XX_SIZES_NO; k++) {
  1873. if(m8xx_size_to_gray[k] == size)
  1874. break;
  1875. }
  1876. if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
  1877. k = -1;
  1878. return k;
  1879. }
  1880. #endif /* CONFIG_I82365 */
  1881. /* -------------------------------------------------------------------- */
  1882. #if 0
  1883. static u_int m8xx_get_speed(u_int ns, u_int is_io)
  1884. {
  1885. u_int reg, clocks, psst, psl, psht;
  1886. if(!ns) {
  1887. /*
  1888. * We get called with IO maps setup to 0ns
  1889. * if not specified by the user.
  1890. * They should be 255ns.
  1891. */
  1892. if(is_io)
  1893. ns = 255;
  1894. else
  1895. ns = 100; /* fast memory if 0 */
  1896. }
  1897. /*
  1898. * In PSST, PSL, PSHT fields we tell the controller
  1899. * timing parameters in CLKOUT clock cycles.
  1900. * CLKOUT is the same as GCLK2_50.
  1901. */
  1902. /* how we want to adjust the timing - in percent */
  1903. #define ADJ 180 /* 80 % longer accesstime - to be sure */
  1904. clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
  1905. clocks = (clocks * ADJ) / (100*1000);
  1906. if(clocks >= PCMCIA_BMT_LIMIT) {
  1907. DEBUG(0, "Max access time limit reached\n");
  1908. clocks = PCMCIA_BMT_LIMIT-1;
  1909. }
  1910. psst = clocks / 7; /* setup time */
  1911. psht = clocks / 7; /* hold time */
  1912. psl = (clocks * 5) / 7; /* strobe length */
  1913. psst += clocks - (psst + psht + psl);
  1914. reg = psst << 12;
  1915. reg |= psl << 7;
  1916. reg |= psht << 16;
  1917. return reg;
  1918. }
  1919. #endif
  1920. /* -------------------------------------------------------------------- */
  1921. #ifdef CONFIG_IDE_8xx_PCCARD
  1922. static void print_funcid (int func)
  1923. {
  1924. puts (indent);
  1925. switch (func) {
  1926. case CISTPL_FUNCID_MULTI:
  1927. puts (" Multi-Function");
  1928. break;
  1929. case CISTPL_FUNCID_MEMORY:
  1930. puts (" Memory");
  1931. break;
  1932. case CISTPL_FUNCID_SERIAL:
  1933. puts (" Serial Port");
  1934. break;
  1935. case CISTPL_FUNCID_PARALLEL:
  1936. puts (" Parallel Port");
  1937. break;
  1938. case CISTPL_FUNCID_FIXED:
  1939. puts (" Fixed Disk");
  1940. break;
  1941. case CISTPL_FUNCID_VIDEO:
  1942. puts (" Video Adapter");
  1943. break;
  1944. case CISTPL_FUNCID_NETWORK:
  1945. puts (" Network Adapter");
  1946. break;
  1947. case CISTPL_FUNCID_AIMS:
  1948. puts (" AIMS Card");
  1949. break;
  1950. case CISTPL_FUNCID_SCSI:
  1951. puts (" SCSI Adapter");
  1952. break;
  1953. default:
  1954. puts (" Unknown");
  1955. break;
  1956. }
  1957. puts (" Card\n");
  1958. }
  1959. #endif /* CONFIG_IDE_8xx_PCCARD */
  1960. /* -------------------------------------------------------------------- */
  1961. #ifdef CONFIG_IDE_8xx_PCCARD
  1962. static void print_fixed (volatile uchar *p)
  1963. {
  1964. if (p == NULL)
  1965. return;
  1966. puts(indent);
  1967. switch (*p) {
  1968. case CISTPL_FUNCE_IDE_IFACE:
  1969. { uchar iface = *(p+2);
  1970. puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
  1971. puts (" interface ");
  1972. break;
  1973. }
  1974. case CISTPL_FUNCE_IDE_MASTER:
  1975. case CISTPL_FUNCE_IDE_SLAVE:
  1976. { uchar f1 = *(p+2);
  1977. uchar f2 = *(p+4);
  1978. puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
  1979. if (f1 & CISTPL_IDE_UNIQUE)
  1980. puts (" [unique]");
  1981. puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
  1982. if (f2 & CISTPL_IDE_HAS_SLEEP)
  1983. puts (" [sleep]");
  1984. if (f2 & CISTPL_IDE_HAS_STANDBY)
  1985. puts (" [standby]");
  1986. if (f2 & CISTPL_IDE_HAS_IDLE)
  1987. puts (" [idle]");
  1988. if (f2 & CISTPL_IDE_LOW_POWER)
  1989. puts (" [low power]");
  1990. if (f2 & CISTPL_IDE_REG_INHIBIT)
  1991. puts (" [reg inhibit]");
  1992. if (f2 & CISTPL_IDE_HAS_INDEX)
  1993. puts (" [index]");
  1994. if (f2 & CISTPL_IDE_IOIS16)
  1995. puts (" [IOis16]");
  1996. break;
  1997. }
  1998. }
  1999. putc ('\n');
  2000. }
  2001. #endif /* CONFIG_IDE_8xx_PCCARD */
  2002. /* -------------------------------------------------------------------- */
  2003. #ifdef CONFIG_IDE_8xx_PCCARD
  2004. #define MAX_IDENT_CHARS 64
  2005. #define MAX_IDENT_FIELDS 4
  2006. static uchar *known_cards[] = {
  2007. "ARGOSY PnPIDE D5",
  2008. NULL
  2009. };
  2010. static int identify (volatile uchar *p)
  2011. {
  2012. uchar id_str[MAX_IDENT_CHARS];
  2013. uchar data;
  2014. uchar *t;
  2015. uchar **card;
  2016. int i, done;
  2017. if (p == NULL)
  2018. return (0); /* Don't know */
  2019. t = id_str;
  2020. done =0;
  2021. for (i=0; i<=4 && !done; ++i, p+=2) {
  2022. while ((data = *p) != '\0') {
  2023. if (data == 0xFF) {
  2024. done = 1;
  2025. break;
  2026. }
  2027. *t++ = data;
  2028. if (t == &id_str[MAX_IDENT_CHARS-1]) {
  2029. done = 1;
  2030. break;
  2031. }
  2032. p += 2;
  2033. }
  2034. if (!done)
  2035. *t++ = ' ';
  2036. }
  2037. *t = '\0';
  2038. while (--t > id_str) {
  2039. if (*t == ' ')
  2040. *t = '\0';
  2041. else
  2042. break;
  2043. }
  2044. puts (id_str);
  2045. putc ('\n');
  2046. for (card=known_cards; *card; ++card) {
  2047. debug ("## Compare against \"%s\"\n", *card);
  2048. if (strcmp(*card, id_str) == 0) { /* found! */
  2049. debug ("## CARD FOUND ##\n");
  2050. return (1);
  2051. }
  2052. }
  2053. return (0); /* don't know */
  2054. }
  2055. #endif /* CONFIG_IDE_8xx_PCCARD */
  2056. /* -------------------------------------------------------------------- */
  2057. #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
  2058. /**************************************************/
  2059. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2060. U_BOOT_CMD(
  2061. pinit, 2, 1, do_pinit,
  2062. "pinit - PCMCIA sub-system\n",
  2063. "on - power on PCMCIA socket\n"
  2064. "pinit off - power off PCMCIA socket\n"
  2065. );
  2066. #endif