cmd_pcmcia.c 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496
  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_IDE_8xx_PCCARD) && 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)
  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. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  493. PCMCIA_PGCRX(_slot_) = reg;
  494. udelay(500);
  495. /*
  496. * Configure Port C pins for
  497. * 5 Volts Enable and 3 Volts enable
  498. */
  499. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  500. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  501. /* remove all power */
  502. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  503. /*
  504. * Make sure there is a card in the slot, then configure the interface.
  505. */
  506. udelay(10000);
  507. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  508. __LINE__,__FUNCTION__,
  509. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  510. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  511. printf (" No Card found\n");
  512. return (1);
  513. }
  514. /*
  515. * Power On.
  516. */
  517. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  518. reg = pcmp->pcmc_pipr;
  519. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  520. reg,
  521. (reg&PCMCIA_VS1(slot))?"n":"ff",
  522. (reg&PCMCIA_VS2(slot))?"n":"ff");
  523. if ((reg & mask) == mask) {
  524. immap->im_ioport.iop_pcdat |= 0x0004;
  525. puts (" 5.0V card found: ");
  526. } else {
  527. immap->im_ioport.iop_pcdat |= 0x0002;
  528. puts (" 3.3V card found: ");
  529. }
  530. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  531. #if 0
  532. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  533. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  534. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  535. udelay(500000);
  536. #endif
  537. udelay(1000);
  538. debug ("Enable PCMCIA buffers and stop RESET\n");
  539. reg = PCMCIA_PGCRX(_slot_);
  540. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  541. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  542. PCMCIA_PGCRX(_slot_) = reg;
  543. udelay(250000); /* some cards need >150 ms to come up :-( */
  544. debug ("# hardware_enable done\n");
  545. return (0);
  546. }
  547. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  548. static int hardware_disable(int slot)
  549. {
  550. volatile immap_t *immap;
  551. volatile pcmconf8xx_t *pcmp;
  552. u_long reg;
  553. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  554. immap = (immap_t *)CFG_IMMR;
  555. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  556. /* remove all power */
  557. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  558. debug ("Disable PCMCIA buffers and assert RESET\n");
  559. reg = 0;
  560. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  561. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  562. PCMCIA_PGCRX(_slot_) = reg;
  563. udelay(10000);
  564. return (0);
  565. }
  566. #endif /* CFG_CMD_PCMCIA */
  567. static int voltage_set(int slot, int vcc, int vpp)
  568. {
  569. volatile immap_t *immap;
  570. volatile pcmconf8xx_t *pcmp;
  571. u_long reg;
  572. debug ("voltage_set: "
  573. PCMCIA_BOARD_MSG
  574. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  575. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  576. immap = (immap_t *)CFG_IMMR;
  577. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  578. /*
  579. * Disable PCMCIA buffers (isolate the interface)
  580. * and assert RESET signal
  581. */
  582. debug ("Disable PCMCIA buffers and assert RESET\n");
  583. reg = PCMCIA_PGCRX(_slot_);
  584. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  585. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  586. PCMCIA_PGCRX(_slot_) = reg;
  587. udelay(500);
  588. /*
  589. * Configure Port C pins for
  590. * 5 Volts Enable and 3 Volts enable,
  591. * Turn off all power
  592. */
  593. debug ("PCMCIA power OFF\n");
  594. immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
  595. immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
  596. immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
  597. reg = 0;
  598. switch(vcc) {
  599. case 0: break;
  600. case 33: reg |= 0x0002; break;
  601. case 50: reg |= 0x0004; break;
  602. default: goto done;
  603. }
  604. /* Checking supported voltages */
  605. debug ("PIPR: 0x%x --> %s\n",
  606. pcmp->pcmc_pipr,
  607. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  608. immap->im_ioport.iop_pcdat |= reg;
  609. immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
  610. if (reg) {
  611. debug ("PCMCIA powered at %sV\n",
  612. (reg&0x0004) ? "5.0" : "3.3");
  613. } else {
  614. debug ("PCMCIA powered down\n");
  615. }
  616. done:
  617. debug ("Enable PCMCIA buffers and stop RESET\n");
  618. reg = PCMCIA_PGCRX(_slot_);
  619. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  620. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  621. PCMCIA_PGCRX(_slot_) = reg;
  622. udelay(500);
  623. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  624. slot+'A');
  625. return (0);
  626. }
  627. #endif /* TQM8xxL */
  628. /* -------------------------------------------------------------------- */
  629. /* LWMON Board */
  630. /* -------------------------------------------------------------------- */
  631. #if defined(CONFIG_LWMON)
  632. #define PCMCIA_BOARD_MSG "LWMON"
  633. /* #define's for MAX1604 Power Switch */
  634. #define MAX1604_OP_SUS 0x80
  635. #define MAX1604_VCCBON 0x40
  636. #define MAX1604_VCC_35 0x20
  637. #define MAX1604_VCCBHIZ 0x10
  638. #define MAX1604_VPPBON 0x08
  639. #define MAX1604_VPPBPBPGM 0x04
  640. #define MAX1604_VPPBHIZ 0x02
  641. /* reserved 0x01 */
  642. static int hardware_enable(int slot)
  643. {
  644. volatile immap_t *immap;
  645. volatile cpm8xx_t *cp;
  646. volatile pcmconf8xx_t *pcmp;
  647. volatile sysconf8xx_t *sysp;
  648. uint reg, mask;
  649. uchar val;
  650. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  651. /* Switch on PCMCIA port in PIC register 0x60 */
  652. reg = pic_read (0x60);
  653. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  654. reg &= ~0x10;
  655. /* reg |= 0x08; Vpp not needed */
  656. pic_write (0x60, reg);
  657. #ifdef DEBUG
  658. reg = pic_read (0x60);
  659. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  660. #endif
  661. udelay(10000);
  662. immap = (immap_t *)CFG_IMMR;
  663. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  664. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  665. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  666. /*
  667. * Configure SIUMCR to enable PCMCIA port B
  668. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  669. */
  670. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  671. /* clear interrupt state, and disable interrupts */
  672. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  673. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  674. /*
  675. * Disable interrupts, DMA, and PCMCIA buffers
  676. * (isolate the interface) and assert RESET signal
  677. */
  678. debug ("Disable PCMCIA buffers and assert RESET\n");
  679. reg = 0;
  680. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  681. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  682. PCMCIA_PGCRX(_slot_) = reg;
  683. udelay(500);
  684. /*
  685. * Make sure there is a card in the slot, then configure the interface.
  686. */
  687. udelay(10000);
  688. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  689. __LINE__,__FUNCTION__,
  690. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  691. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  692. printf (" No Card found\n");
  693. return (1);
  694. }
  695. /*
  696. * Power On.
  697. */
  698. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  699. reg = pcmp->pcmc_pipr;
  700. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  701. reg,
  702. (reg&PCMCIA_VS1(slot))?"n":"ff",
  703. (reg&PCMCIA_VS2(slot))?"n":"ff");
  704. if ((reg & mask) == mask) {
  705. val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
  706. puts (" 5.0V card found: ");
  707. } else {
  708. val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
  709. puts (" 3.3V card found: ");
  710. }
  711. /* switch VCC on */
  712. val |= MAX1604_OP_SUS | MAX1604_VCCBON;
  713. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  714. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  715. udelay(500000);
  716. debug ("Enable PCMCIA buffers and stop RESET\n");
  717. reg = PCMCIA_PGCRX(_slot_);
  718. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  719. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  720. PCMCIA_PGCRX(_slot_) = reg;
  721. udelay(250000); /* some cards need >150 ms to come up :-( */
  722. debug ("# hardware_enable done\n");
  723. return (0);
  724. }
  725. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  726. static int hardware_disable(int slot)
  727. {
  728. volatile immap_t *immap;
  729. volatile pcmconf8xx_t *pcmp;
  730. u_long reg;
  731. uchar val;
  732. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  733. immap = (immap_t *)CFG_IMMR;
  734. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  735. /* remove all power, put output in high impedance state */
  736. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  737. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  738. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  739. /* Configure PCMCIA General Control Register */
  740. debug ("Disable PCMCIA buffers and assert RESET\n");
  741. reg = 0;
  742. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  743. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  744. PCMCIA_PGCRX(_slot_) = reg;
  745. /* Switch off PCMCIA port in PIC register 0x60 */
  746. reg = pic_read (0x60);
  747. debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  748. reg |= 0x10;
  749. reg &= ~0x08;
  750. pic_write (0x60, reg);
  751. #ifdef DEBUG
  752. reg = pic_read (0x60);
  753. printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
  754. #endif
  755. udelay(10000);
  756. return (0);
  757. }
  758. #endif /* CFG_CMD_PCMCIA */
  759. static int voltage_set(int slot, int vcc, int vpp)
  760. {
  761. volatile immap_t *immap;
  762. volatile pcmconf8xx_t *pcmp;
  763. u_long reg;
  764. uchar val;
  765. debug ("voltage_set: "
  766. PCMCIA_BOARD_MSG
  767. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  768. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  769. immap = (immap_t *)CFG_IMMR;
  770. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  771. /*
  772. * Disable PCMCIA buffers (isolate the interface)
  773. * and assert RESET signal
  774. */
  775. debug ("Disable PCMCIA buffers and assert RESET\n");
  776. reg = PCMCIA_PGCRX(_slot_);
  777. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  778. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  779. PCMCIA_PGCRX(_slot_) = reg;
  780. udelay(500);
  781. /*
  782. * Turn off all power (switch to high impedance)
  783. */
  784. debug ("PCMCIA power OFF\n");
  785. val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
  786. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  787. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  788. val = 0;
  789. switch(vcc) {
  790. case 0: break;
  791. case 33: val = MAX1604_VCC_35; break;
  792. case 50: break;
  793. default: goto done;
  794. }
  795. /* Checking supported voltages */
  796. debug ("PIPR: 0x%x --> %s\n",
  797. pcmp->pcmc_pipr,
  798. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  799. i2c_write (CFG_I2C_POWER_A_ADDR, 0, 0, &val, 1);
  800. if (val) {
  801. debug ("PCMCIA powered at %sV\n",
  802. (val & MAX1604_VCC_35) ? "3.3" : "5.0");
  803. } else {
  804. debug ("PCMCIA powered down\n");
  805. }
  806. done:
  807. debug ("Enable PCMCIA buffers and stop RESET\n");
  808. reg = PCMCIA_PGCRX(_slot_);
  809. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  810. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  811. PCMCIA_PGCRX(_slot_) = reg;
  812. udelay(500);
  813. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  814. slot+'A');
  815. return (0);
  816. }
  817. #endif /* LWMON */
  818. /* -------------------------------------------------------------------- */
  819. /* GTH board by Corelatus AB */
  820. /* -------------------------------------------------------------------- */
  821. #if defined(CONFIG_GTH)
  822. #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH"
  823. static int voltage_set (int slot, int vcc, int vpp)
  824. { /* Do nothing */
  825. return 0;
  826. }
  827. static int hardware_enable (int slot)
  828. {
  829. volatile immap_t *immap;
  830. volatile cpm8xx_t *cp;
  831. volatile pcmconf8xx_t *pcmp;
  832. volatile sysconf8xx_t *sysp;
  833. uint reg, mask;
  834. debug ("hardware_enable: GTH Slot %c\n", 'A' + slot);
  835. immap = (immap_t *) CFG_IMMR;
  836. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  837. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  838. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  839. /* clear interrupt state, and disable interrupts */
  840. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  841. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  842. /*
  843. * Disable interrupts, DMA, and PCMCIA buffers
  844. * (isolate the interface) and assert RESET signal
  845. */
  846. debug ("Disable PCMCIA buffers and assert RESET\n");
  847. reg = 0;
  848. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  849. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  850. PCMCIA_PGCRX (_slot_) = reg;
  851. udelay (500);
  852. /*
  853. * Make sure there is a card in the slot,
  854. * then configure the interface.
  855. */
  856. udelay (10000);
  857. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  858. __LINE__, __FUNCTION__,
  859. &(pcmp->pcmc_pipr), pcmp->pcmc_pipr);
  860. if (pcmp->pcmc_pipr & 0x98000000) {
  861. printf (" No Card found\n");
  862. return (1);
  863. }
  864. mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot);
  865. reg = pcmp->pcmc_pipr;
  866. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  867. reg,
  868. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  869. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  870. debug ("Enable PCMCIA buffers and stop RESET\n");
  871. reg = PCMCIA_PGCRX (_slot_);
  872. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  873. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  874. PCMCIA_PGCRX (_slot_) = reg;
  875. udelay (250000); /* some cards need >150 ms to come up :-( */
  876. debug ("# hardware_enable done\n");
  877. return 0;
  878. }
  879. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  880. static int hardware_disable(int slot)
  881. {
  882. return 0; /* No hardware to disable */
  883. }
  884. #endif /* CFG_CMD_PCMCIA */
  885. #endif /* CONFIG_GTH */
  886. /* -------------------------------------------------------------------- */
  887. /* ICU862 Boards by Cambridge Broadband Ltd. */
  888. /* -------------------------------------------------------------------- */
  889. #if defined(CONFIG_ICU862)
  890. #define PCMCIA_BOARD_MSG "ICU862"
  891. static void cfg_port_B (void);
  892. static int hardware_enable(int slot)
  893. {
  894. volatile immap_t *immap;
  895. volatile cpm8xx_t *cp;
  896. volatile pcmconf8xx_t *pcmp;
  897. volatile sysconf8xx_t *sysp;
  898. uint reg, pipr, mask;
  899. int i;
  900. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  901. udelay(10000);
  902. immap = (immap_t *)CFG_IMMR;
  903. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  904. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  905. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  906. /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
  907. cfg_port_B ();
  908. /*
  909. * Configure SIUMCR to enable PCMCIA port B
  910. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  911. */
  912. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  913. /* clear interrupt state, and disable interrupts */
  914. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  915. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  916. /*
  917. * Disable interrupts, DMA, and PCMCIA buffers
  918. * (isolate the interface) and assert RESET signal
  919. */
  920. debug ("Disable PCMCIA buffers and assert RESET\n");
  921. reg = 0;
  922. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  923. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  924. PCMCIA_PGCRX(_slot_) = reg;
  925. udelay(500);
  926. /*
  927. * Make sure there is a card in the slot, then configure the interface.
  928. */
  929. udelay(10000);
  930. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  931. __LINE__,__FUNCTION__,
  932. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  933. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  934. printf (" No Card found\n");
  935. return (1);
  936. }
  937. /*
  938. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  939. */
  940. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  941. pipr = pcmp->pcmc_pipr;
  942. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  943. pipr,
  944. (reg&PCMCIA_VS1(slot))?"n":"ff",
  945. (reg&PCMCIA_VS2(slot))?"n":"ff");
  946. reg = cp->cp_pbdat;
  947. if ((pipr & mask) == mask) {
  948. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  949. TPS2205_VCC3); /* 3V off */
  950. reg &= ~(TPS2205_VCC5); /* 5V on */
  951. puts (" 5.0V card found: ");
  952. } else {
  953. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  954. TPS2205_VCC5); /* 5V off */
  955. reg &= ~(TPS2205_VCC3); /* 3V on */
  956. puts (" 3.3V card found: ");
  957. }
  958. debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
  959. reg,
  960. (reg & TPS2205_VCC3) ? "off" : "on",
  961. (reg & TPS2205_VCC5) ? "off" : "on",
  962. (reg & TPS2205_VPP_PGM) ? "off" : "on",
  963. (reg & TPS2205_VPP_VCC) ? "off" : "on" );
  964. cp->cp_pbdat = reg;
  965. /* Wait 500 ms; use this to check for over-current */
  966. for (i=0; i<5000; ++i) {
  967. if ((cp->cp_pbdat & TPS2205_OC) == 0) {
  968. printf (" *** Overcurrent - Safety shutdown ***\n");
  969. cp->cp_pbdat &= ~(TPS2205_SHDN);
  970. return (1);
  971. }
  972. udelay (100);
  973. }
  974. debug ("Enable PCMCIA buffers and stop RESET\n");
  975. reg = PCMCIA_PGCRX(_slot_);
  976. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  977. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  978. PCMCIA_PGCRX(_slot_) = reg;
  979. udelay(250000); /* some cards need >150 ms to come up :-( */
  980. debug ("# hardware_enable done\n");
  981. return (0);
  982. }
  983. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  984. static int hardware_disable(int slot)
  985. {
  986. volatile immap_t *immap;
  987. volatile cpm8xx_t *cp;
  988. volatile pcmconf8xx_t *pcmp;
  989. u_long reg;
  990. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  991. immap = (immap_t *)CFG_IMMR;
  992. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  993. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  994. /* Shut down */
  995. cp->cp_pbdat &= ~(TPS2205_SHDN);
  996. /* Configure PCMCIA General Control Register */
  997. debug ("Disable PCMCIA buffers and assert RESET\n");
  998. reg = 0;
  999. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1000. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1001. PCMCIA_PGCRX(_slot_) = reg;
  1002. udelay(10000);
  1003. return (0);
  1004. }
  1005. #endif /* CFG_CMD_PCMCIA */
  1006. static int voltage_set(int slot, int vcc, int vpp)
  1007. {
  1008. volatile immap_t *immap;
  1009. volatile cpm8xx_t *cp;
  1010. volatile pcmconf8xx_t *pcmp;
  1011. u_long reg;
  1012. debug ("voltage_set: "
  1013. PCMCIA_BOARD_MSG
  1014. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1015. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1016. immap = (immap_t *)CFG_IMMR;
  1017. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1018. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1019. /*
  1020. * Disable PCMCIA buffers (isolate the interface)
  1021. * and assert RESET signal
  1022. */
  1023. debug ("Disable PCMCIA buffers and assert RESET\n");
  1024. reg = PCMCIA_PGCRX(_slot_);
  1025. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1026. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1027. PCMCIA_PGCRX(_slot_) = reg;
  1028. udelay(500);
  1029. /*
  1030. * Configure Port C pins for
  1031. * 5 Volts Enable and 3 Volts enable,
  1032. * Turn all power pins to Hi-Z
  1033. */
  1034. debug ("PCMCIA power OFF\n");
  1035. cfg_port_B (); /* Enables switch, but all in Hi-Z */
  1036. reg = cp->cp_pbdat;
  1037. switch(vcc) {
  1038. case 0: break; /* Switch off */
  1039. case 33: reg &= ~TPS2205_VCC3; break; /* Switch on 3.3V */
  1040. case 50: reg &= ~TPS2205_VCC5; break; /* Switch on 5.0V */
  1041. default: goto done;
  1042. }
  1043. /* Checking supported voltages */
  1044. debug ("PIPR: 0x%x --> %s\n",
  1045. pcmp->pcmc_pipr,
  1046. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1047. cp->cp_pbdat = reg;
  1048. #ifdef DEBUG
  1049. {
  1050. char *s;
  1051. if ((reg & TPS2205_VCC3) == 0) {
  1052. s = "at 3.3V";
  1053. } else if ((reg & TPS2205_VCC5) == 0) {
  1054. s = "at 5.0V";
  1055. } else {
  1056. s = "down";
  1057. }
  1058. printf ("PCMCIA powered %s\n", s);
  1059. }
  1060. #endif
  1061. done:
  1062. debug ("Enable PCMCIA buffers and stop RESET\n");
  1063. reg = PCMCIA_PGCRX(_slot_);
  1064. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1065. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1066. PCMCIA_PGCRX(_slot_) = reg;
  1067. udelay(500);
  1068. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1069. slot+'A');
  1070. return (0);
  1071. }
  1072. static void cfg_port_B (void)
  1073. {
  1074. volatile immap_t *immap;
  1075. volatile cpm8xx_t *cp;
  1076. uint reg;
  1077. immap = (immap_t *)CFG_IMMR;
  1078. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1079. /*
  1080. * Configure Port B for TPS2205 PC-Card Power-Interface Switch
  1081. *
  1082. * Switch off all voltages, assert shutdown
  1083. */
  1084. reg = cp->cp_pbdat;
  1085. reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
  1086. TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
  1087. TPS2205_SHDN); /* enable switch */
  1088. cp->cp_pbdat = reg;
  1089. cp->cp_pbpar &= ~(TPS2205_INPUTS | TPS2205_OUTPUTS);
  1090. reg = cp->cp_pbdir & ~(TPS2205_INPUTS);
  1091. cp->cp_pbdir = reg | TPS2205_OUTPUTS;
  1092. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1093. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1094. }
  1095. #endif /* ICU862 */
  1096. /* -------------------------------------------------------------------- */
  1097. /* C2MON Boards by TTTech Computertechnik AG */
  1098. /* -------------------------------------------------------------------- */
  1099. #if defined(CONFIG_C2MON)
  1100. #define PCMCIA_BOARD_MSG "C2MON"
  1101. static void cfg_ports (void);
  1102. static int hardware_enable(int slot)
  1103. {
  1104. volatile immap_t *immap;
  1105. volatile cpm8xx_t *cp;
  1106. volatile pcmconf8xx_t *pcmp;
  1107. volatile sysconf8xx_t *sysp;
  1108. uint reg, pipr, mask;
  1109. ushort sreg;
  1110. int i;
  1111. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1112. udelay(10000);
  1113. immap = (immap_t *)CFG_IMMR;
  1114. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1115. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1116. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1117. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  1118. cfg_ports ();
  1119. /*
  1120. * Configure SIUMCR to enable PCMCIA port B
  1121. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1122. */
  1123. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1124. /* clear interrupt state, and disable interrupts */
  1125. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1126. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1127. /*
  1128. * Disable interrupts, DMA, and PCMCIA buffers
  1129. * (isolate the interface) and assert RESET signal
  1130. */
  1131. debug ("Disable PCMCIA buffers and assert RESET\n");
  1132. reg = 0;
  1133. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1134. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1135. PCMCIA_PGCRX(_slot_) = reg;
  1136. udelay(500);
  1137. /*
  1138. * Make sure there is a card in the slot, then configure the interface.
  1139. */
  1140. udelay(10000);
  1141. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1142. __LINE__,__FUNCTION__,
  1143. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1144. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1145. printf (" No Card found\n");
  1146. return (1);
  1147. }
  1148. /*
  1149. * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
  1150. */
  1151. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1152. pipr = pcmp->pcmc_pipr;
  1153. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1154. pipr,
  1155. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1156. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1157. sreg = immap->im_ioport.iop_pcdat;
  1158. if ((pipr & mask) == mask) {
  1159. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1160. TPS2211_VCCD1); /* 5V on */
  1161. sreg &= ~(TPS2211_VCCD0); /* 3V off */
  1162. puts (" 5.0V card found: ");
  1163. } else {
  1164. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
  1165. TPS2211_VCCD0); /* 3V on */
  1166. sreg &= ~(TPS2211_VCCD1); /* 5V off */
  1167. puts (" 3.3V card found: ");
  1168. }
  1169. debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
  1170. sreg,
  1171. ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
  1172. (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
  1173. );
  1174. immap->im_ioport.iop_pcdat = sreg;
  1175. /* Wait 500 ms; use this to check for over-current */
  1176. for (i=0; i<5000; ++i) {
  1177. if ((cp->cp_pbdat & TPS2211_OC) == 0) {
  1178. printf (" *** Overcurrent - Safety shutdown ***\n");
  1179. immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
  1180. return (1);
  1181. }
  1182. udelay (100);
  1183. }
  1184. debug ("Enable PCMCIA buffers and stop RESET\n");
  1185. reg = PCMCIA_PGCRX(_slot_);
  1186. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1187. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1188. PCMCIA_PGCRX(_slot_) = reg;
  1189. udelay(250000); /* some cards need >150 ms to come up :-( */
  1190. debug ("# hardware_enable done\n");
  1191. return (0);
  1192. }
  1193. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1194. static int hardware_disable(int slot)
  1195. {
  1196. volatile immap_t *immap;
  1197. volatile cpm8xx_t *cp;
  1198. volatile pcmconf8xx_t *pcmp;
  1199. u_long reg;
  1200. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1201. immap = (immap_t *)CFG_IMMR;
  1202. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1203. /* Configure PCMCIA General Control Register */
  1204. debug ("Disable PCMCIA buffers and assert RESET\n");
  1205. reg = 0;
  1206. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1207. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1208. PCMCIA_PGCRX(_slot_) = reg;
  1209. /* ALl voltages off / Hi-Z */
  1210. immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
  1211. TPS2211_VCCD0 | TPS2211_VCCD1 );
  1212. udelay(10000);
  1213. return (0);
  1214. }
  1215. #endif /* CFG_CMD_PCMCIA */
  1216. static int voltage_set(int slot, int vcc, int vpp)
  1217. {
  1218. volatile immap_t *immap;
  1219. volatile cpm8xx_t *cp;
  1220. volatile pcmconf8xx_t *pcmp;
  1221. u_long reg;
  1222. ushort sreg;
  1223. debug ("voltage_set: "
  1224. PCMCIA_BOARD_MSG
  1225. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1226. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1227. immap = (immap_t *)CFG_IMMR;
  1228. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1229. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1230. /*
  1231. * Disable PCMCIA buffers (isolate the interface)
  1232. * and assert RESET signal
  1233. */
  1234. debug ("Disable PCMCIA buffers and assert RESET\n");
  1235. reg = PCMCIA_PGCRX(_slot_);
  1236. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1237. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1238. PCMCIA_PGCRX(_slot_) = reg;
  1239. udelay(500);
  1240. /*
  1241. * Configure Port C pins for
  1242. * 5 Volts Enable and 3 Volts enable,
  1243. * Turn all power pins to Hi-Z
  1244. */
  1245. debug ("PCMCIA power OFF\n");
  1246. cfg_ports (); /* Enables switch, but all in Hi-Z */
  1247. sreg = immap->im_ioport.iop_pcdat;
  1248. sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
  1249. switch(vcc) {
  1250. case 0: break; /* Switch off */
  1251. case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
  1252. sreg &= ~TPS2211_VCCD1;
  1253. break;
  1254. case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
  1255. sreg |= TPS2211_VCCD1;
  1256. break;
  1257. default: goto done;
  1258. }
  1259. /* Checking supported voltages */
  1260. debug ("PIPR: 0x%x --> %s\n",
  1261. pcmp->pcmc_pipr,
  1262. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1263. immap->im_ioport.iop_pcdat = sreg;
  1264. #ifdef DEBUG
  1265. {
  1266. char *s;
  1267. if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
  1268. s = "at 3.3V";
  1269. } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
  1270. s = "at 5.0V";
  1271. } else {
  1272. s = "down";
  1273. }
  1274. printf ("PCMCIA powered %s\n", s);
  1275. }
  1276. #endif
  1277. done:
  1278. debug ("Enable PCMCIA buffers and stop RESET\n");
  1279. reg = PCMCIA_PGCRX(_slot_);
  1280. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1281. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1282. PCMCIA_PGCRX(_slot_) = reg;
  1283. udelay(500);
  1284. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1285. slot+'A');
  1286. return (0);
  1287. }
  1288. static void cfg_ports (void)
  1289. {
  1290. volatile immap_t *immap;
  1291. volatile cpm8xx_t *cp;
  1292. ushort sreg;
  1293. immap = (immap_t *)CFG_IMMR;
  1294. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1295. /*
  1296. * Configure Port C for TPS2211 PC-Card Power-Interface Switch
  1297. *
  1298. * Switch off all voltages, assert shutdown
  1299. */
  1300. sreg = immap->im_ioport.iop_pcdat;
  1301. sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
  1302. sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
  1303. immap->im_ioport.iop_pcdat = sreg;
  1304. immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
  1305. immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
  1306. debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
  1307. immap->im_ioport.iop_pcpar,
  1308. immap->im_ioport.iop_pcdir,
  1309. immap->im_ioport.iop_pcdat);
  1310. /*
  1311. * Configure Port B for TPS2211 PC-Card Power-Interface Switch
  1312. *
  1313. * Over-Current Input only
  1314. */
  1315. cp->cp_pbpar &= ~(TPS2211_INPUTS);
  1316. cp->cp_pbdir &= ~(TPS2211_INPUTS);
  1317. debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
  1318. cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
  1319. }
  1320. #endif /* C2MON */
  1321. /* -------------------------------------------------------------------- */
  1322. /* MBX board from Morotola */
  1323. /* -------------------------------------------------------------------- */
  1324. #if defined( CONFIG_MBX )
  1325. #include <../board/mbx8xx/csr.h>
  1326. /* A lot of this has been taken from the RPX code in this file it works from me.
  1327. I have added the voltage selection for the MBX board. */
  1328. /* MBX voltage bit in control register #2 */
  1329. #define CR2_VPP12 ((uchar)0x10)
  1330. #define CR2_VPPVDD ((uchar)0x20)
  1331. #define CR2_VDD5 ((uchar)0x40)
  1332. #define CR2_VDD3 ((uchar)0x80)
  1333. #define PCMCIA_BOARD_MSG "MBX860"
  1334. static int voltage_set (int slot, int vcc, int vpp)
  1335. {
  1336. uchar reg = 0;
  1337. debug ("voltage_set: PCMCIA_BOARD_MSG Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1338. 'A' + slot, vcc / 10, vcc % 10, vpp / 10, vcc % 10);
  1339. switch (vcc) {
  1340. case 0:
  1341. break;
  1342. case 33:
  1343. reg |= CR2_VDD3;
  1344. break;
  1345. case 50:
  1346. reg |= CR2_VDD5;
  1347. break;
  1348. default:
  1349. return 1;
  1350. }
  1351. switch (vpp) {
  1352. case 0:
  1353. break;
  1354. case 33:
  1355. case 50:
  1356. if (vcc == vpp) {
  1357. reg |= CR2_VPPVDD;
  1358. } else {
  1359. return 1;
  1360. }
  1361. break;
  1362. case 120:
  1363. reg |= CR2_VPP12;
  1364. break;
  1365. default:
  1366. return 1;
  1367. }
  1368. /* first, turn off all power */
  1369. MBX_CSR2 &= ~(CR2_VDDSEL | CR2_VPPSEL);
  1370. /* enable new powersettings */
  1371. MBX_CSR2 |= reg;
  1372. debug ("MBX_CSR2 read = 0x%02x\n", MBX_CSR2);
  1373. return (0);
  1374. }
  1375. static int hardware_enable (int slot)
  1376. {
  1377. volatile immap_t *immap;
  1378. volatile cpm8xx_t *cp;
  1379. volatile pcmconf8xx_t *pcmp;
  1380. volatile sysconf8xx_t *sysp;
  1381. uint reg, mask;
  1382. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
  1383. 'A' + slot);
  1384. udelay (10000);
  1385. immap = (immap_t *) CFG_IMMR;
  1386. sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf));
  1387. pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia));
  1388. cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm));
  1389. /* clear interrupt state, and disable interrupts */
  1390. pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
  1391. pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_);
  1392. /*
  1393. * Disable interrupts, DMA, and PCMCIA buffers
  1394. * (isolate the interface) and assert RESET signal
  1395. */
  1396. debug ("Disable PCMCIA buffers and assert RESET\n");
  1397. reg = 0;
  1398. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1399. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1400. PCMCIA_PGCRX (_slot_) = reg;
  1401. udelay (500);
  1402. /* remove all power */
  1403. voltage_set (slot, 0, 0);
  1404. /*
  1405. * Make sure there is a card in the slot, then configure the interface.
  1406. */
  1407. udelay(10000);
  1408. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1409. __LINE__,__FUNCTION__,
  1410. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1411. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1412. printf (" No Card found\n");
  1413. return (1);
  1414. }
  1415. /*
  1416. * Power On.
  1417. */
  1418. mask = PCMCIA_VS1 (_slot_) | PCMCIA_VS2 (_slot_);
  1419. reg = pcmp->pcmc_pipr;
  1420. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg,
  1421. (reg & PCMCIA_VS1 (slot)) ? "n" : "ff",
  1422. (reg & PCMCIA_VS2 (slot)) ? "n" : "ff");
  1423. if ((reg & mask) == mask) {
  1424. voltage_set (_slot_, 50, 0);
  1425. printf (" 5.0V card found: ");
  1426. } else {
  1427. voltage_set (_slot_, 33, 0);
  1428. printf (" 3.3V card found: ");
  1429. }
  1430. debug ("Enable PCMCIA buffers and stop RESET\n");
  1431. reg = PCMCIA_PGCRX (_slot_);
  1432. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1433. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1434. PCMCIA_PGCRX (_slot_) = reg;
  1435. udelay (250000); /* some cards need >150 ms to come up :-( */
  1436. debug ("# hardware_enable done\n");
  1437. return (0);
  1438. }
  1439. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1440. static int hardware_disable (int slot)
  1441. {
  1442. return 0; /* No hardware to disable */
  1443. }
  1444. #endif /* CFG_CMD_PCMCIA */
  1445. #endif /* CONFIG_MBX */
  1446. /* -------------------------------------------------------------------- */
  1447. /* R360MPI Board */
  1448. /* -------------------------------------------------------------------- */
  1449. #if defined(CONFIG_R360MPI)
  1450. #define PCMCIA_BOARD_MSG "R360MPI"
  1451. static int hardware_enable(int slot)
  1452. {
  1453. volatile immap_t *immap;
  1454. volatile cpm8xx_t *cp;
  1455. volatile pcmconf8xx_t *pcmp;
  1456. volatile sysconf8xx_t *sysp;
  1457. uint reg, mask;
  1458. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1459. udelay(10000);
  1460. immap = (immap_t *)CFG_IMMR;
  1461. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1462. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1463. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1464. /*
  1465. * Configure SIUMCR to enable PCMCIA port B
  1466. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1467. */
  1468. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1469. /* clear interrupt state, and disable interrupts */
  1470. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  1471. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  1472. /*
  1473. * Disable interrupts, DMA, and PCMCIA buffers
  1474. * (isolate the interface) and assert RESET signal
  1475. */
  1476. debug ("Disable PCMCIA buffers and assert RESET\n");
  1477. reg = 0;
  1478. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1479. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1480. PCMCIA_PGCRX(_slot_) = reg;
  1481. udelay(500);
  1482. /*
  1483. * Configure Ports A, B & C pins for
  1484. * 5 Volts Enable and 3 Volts enable
  1485. */
  1486. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1487. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1488. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1489. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1490. immap->im_ioport.iop_padir |= 0x0200;*/
  1491. #if 0
  1492. immap->im_ioport.iop_pbpar &= ~(0xC000);
  1493. immap->im_ioport.iop_pbdir &= ~(0xC000);
  1494. #endif
  1495. /* remove all power */
  1496. immap->im_ioport.iop_pcdat |= 0x0400;
  1497. immap->im_ioport.iop_padat |= 0x0200;
  1498. /*
  1499. * Make sure there is a card in the slot, then configure the interface.
  1500. */
  1501. udelay(10000);
  1502. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1503. __LINE__,__FUNCTION__,
  1504. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1505. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1506. printf (" No Card found\n");
  1507. return (1);
  1508. }
  1509. /*
  1510. * Power On.
  1511. */
  1512. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1513. reg = pcmp->pcmc_pipr;
  1514. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1515. reg,
  1516. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1517. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1518. if ((reg & mask) == mask) {
  1519. immap->im_ioport.iop_pcdat &= ~(0x4000);
  1520. puts (" 5.0V card found: ");
  1521. } else {
  1522. immap->im_ioport.iop_padat &= ~(0x0002);
  1523. puts (" 3.3V card found: ");
  1524. }
  1525. immap->im_ioport.iop_pcdir |= 0x0400;
  1526. immap->im_ioport.iop_padir |= 0x0200;
  1527. #if 0
  1528. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1529. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1530. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1531. udelay(500000);
  1532. #endif
  1533. debug ("Enable PCMCIA buffers and stop RESET\n");
  1534. reg = PCMCIA_PGCRX(_slot_);
  1535. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1536. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1537. PCMCIA_PGCRX(_slot_) = reg;
  1538. udelay(250000); /* some cards need >150 ms to come up :-( */
  1539. debug ("# hardware_enable done\n");
  1540. return (0);
  1541. }
  1542. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1543. static int hardware_disable(int slot)
  1544. {
  1545. volatile immap_t *immap;
  1546. volatile pcmconf8xx_t *pcmp;
  1547. u_long reg;
  1548. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1549. immap = (immap_t *)CFG_IMMR;
  1550. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1551. /* remove all power */
  1552. immap->im_ioport.iop_pcdat |= 0x0400;
  1553. immap->im_ioport.iop_padat |= 0x0200;
  1554. /* Configure PCMCIA General Control Register */
  1555. debug ("Disable PCMCIA buffers and assert RESET\n");
  1556. reg = 0;
  1557. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1558. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1559. PCMCIA_PGCRX(_slot_) = reg;
  1560. udelay(10000);
  1561. return (0);
  1562. }
  1563. #endif /* CFG_CMD_PCMCIA */
  1564. static int voltage_set(int slot, int vcc, int vpp)
  1565. {
  1566. volatile immap_t *immap;
  1567. volatile pcmconf8xx_t *pcmp;
  1568. u_long reg;
  1569. debug ("voltage_set: "
  1570. PCMCIA_BOARD_MSG
  1571. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1572. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1573. immap = (immap_t *)CFG_IMMR;
  1574. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1575. /*
  1576. * Disable PCMCIA buffers (isolate the interface)
  1577. * and assert RESET signal
  1578. */
  1579. debug ("Disable PCMCIA buffers and assert RESET\n");
  1580. reg = PCMCIA_PGCRX(_slot_);
  1581. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1582. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1583. PCMCIA_PGCRX(_slot_) = reg;
  1584. udelay(500);
  1585. /*
  1586. * Configure Ports A & C pins for
  1587. * 5 Volts Enable and 3 Volts enable,
  1588. * Turn off all power
  1589. */
  1590. debug ("PCMCIA power OFF\n");
  1591. immap->im_ioport.iop_pcpar &= ~(0x0400);
  1592. immap->im_ioport.iop_pcso &= ~(0x0400);/*
  1593. immap->im_ioport.iop_pcdir |= 0x0400;*/
  1594. immap->im_ioport.iop_papar &= ~(0x0200);/*
  1595. immap->im_ioport.iop_padir |= 0x0200;*/
  1596. immap->im_ioport.iop_pcdat |= 0x0400;
  1597. immap->im_ioport.iop_padat |= 0x0200;
  1598. reg = 0;
  1599. switch(vcc) {
  1600. case 0: break;
  1601. case 33: reg |= 0x0200; break;
  1602. case 50: reg |= 0x0400; break;
  1603. default: goto done;
  1604. }
  1605. /* Checking supported voltages */
  1606. debug ("PIPR: 0x%x --> %s\n",
  1607. pcmp->pcmc_pipr,
  1608. (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
  1609. if (reg & 0x0200)
  1610. immap->im_ioport.iop_pcdat &= !reg;
  1611. if (reg & 0x0400)
  1612. immap->im_ioport.iop_padat &= !reg;
  1613. immap->im_ioport.iop_pcdir |= 0x0200;
  1614. immap->im_ioport.iop_padir |= 0x0400;
  1615. if (reg) {
  1616. debug ("PCMCIA powered at %sV\n",
  1617. (reg&0x0400) ? "5.0" : "3.3");
  1618. } else {
  1619. debug ("PCMCIA powered down\n");
  1620. }
  1621. done:
  1622. debug ("Enable PCMCIA buffers and stop RESET\n");
  1623. reg = PCMCIA_PGCRX(_slot_);
  1624. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1625. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1626. PCMCIA_PGCRX(_slot_) = reg;
  1627. udelay(500);
  1628. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1629. slot+'A');
  1630. return (0);
  1631. }
  1632. #endif /* R360MPI */
  1633. /* -------------------------------------------------------------------- */
  1634. /* KUP4K Board */
  1635. /* -------------------------------------------------------------------- */
  1636. #if defined(CONFIG_KUP4K)
  1637. #define PCMCIA_BOARD_MSG "KUP4K"
  1638. #define KUP4K_PCMCIA_B_3V3 (0x00020000)
  1639. static int hardware_enable(int slot)
  1640. {
  1641. volatile immap_t *immap;
  1642. volatile cpm8xx_t *cp;
  1643. volatile pcmconf8xx_t *pcmp;
  1644. volatile sysconf8xx_t *sysp;
  1645. uint reg, mask;
  1646. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1647. udelay(10000);
  1648. immap = (immap_t *)CFG_IMMR;
  1649. sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
  1650. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1651. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1652. /*
  1653. * Configure SIUMCR to enable PCMCIA port B
  1654. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  1655. */
  1656. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  1657. /* clear interrupt state, and disable interrupts */
  1658. pcmp->pcmc_pscr = PCMCIA_MASK(slot);
  1659. pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
  1660. /*
  1661. * Disable interrupts, DMA, and PCMCIA buffers
  1662. * (isolate the interface) and assert RESET signal
  1663. */
  1664. debug ("Disable PCMCIA buffers and assert RESET\n");
  1665. reg = 0;
  1666. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1667. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1668. PCMCIA_PGCRX(slot) = reg;
  1669. udelay(2500);
  1670. /*
  1671. * Configure Port B pins for
  1672. * 3 Volts enable
  1673. */
  1674. if (slot) { /* Slot A is built-in */
  1675. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  1676. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  1677. /* remove all power */
  1678. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  1679. }
  1680. /*
  1681. * Make sure there is a card in the slot, then configure the interface.
  1682. */
  1683. udelay(10000);
  1684. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  1685. __LINE__,__FUNCTION__,
  1686. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  1687. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  1688. printf (" No Card found\n");
  1689. return (1);
  1690. }
  1691. /*
  1692. * Power On.
  1693. */
  1694. printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
  1695. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  1696. reg = pcmp->pcmc_pipr;
  1697. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  1698. reg,
  1699. (reg&PCMCIA_VS1(slot))?"n":"ff",
  1700. (reg&PCMCIA_VS2(slot))?"n":"ff");
  1701. if ((reg & mask) == mask) {
  1702. puts (" 5.0V card found: NOT SUPPORTED !!!\n");
  1703. } else {
  1704. if(slot)
  1705. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  1706. puts (" 3.3V card found: ");
  1707. }
  1708. #if 0
  1709. /* VCC switch error flag, PCMCIA slot INPACK_ pin */
  1710. cp->cp_pbdir &= ~(0x0020 | 0x0010);
  1711. cp->cp_pbpar &= ~(0x0020 | 0x0010);
  1712. udelay(500000);
  1713. #endif
  1714. debug ("Enable PCMCIA buffers and stop RESET\n");
  1715. reg = PCMCIA_PGCRX(slot);
  1716. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  1717. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  1718. PCMCIA_PGCRX(slot) = reg;
  1719. udelay(250000); /* some cards need >150 ms to come up :-( */
  1720. debug ("# hardware_enable done\n");
  1721. return (0);
  1722. }
  1723. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  1724. static int hardware_disable(int slot)
  1725. {
  1726. volatile immap_t *immap;
  1727. volatile cpm8xx_t *cp;
  1728. volatile pcmconf8xx_t *pcmp;
  1729. u_long reg;
  1730. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  1731. immap = (immap_t *)CFG_IMMR;
  1732. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1733. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1734. /* remove all power */
  1735. if (slot)
  1736. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
  1737. /* Configure PCMCIA General Control Register */
  1738. debug ("Disable PCMCIA buffers and assert RESET\n");
  1739. reg = 0;
  1740. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1741. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1742. PCMCIA_PGCRX(slot) = reg;
  1743. udelay(10000);
  1744. return (0);
  1745. }
  1746. #endif /* CFG_CMD_PCMCIA */
  1747. static int voltage_set(int slot, int vcc, int vpp)
  1748. {
  1749. volatile immap_t *immap;
  1750. volatile cpm8xx_t *cp;
  1751. volatile pcmconf8xx_t *pcmp;
  1752. u_long reg;
  1753. debug ("voltage_set: " \
  1754. PCMCIA_BOARD_MSG \
  1755. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  1756. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  1757. if (!slot) /* Slot A is not configurable */
  1758. return 0;
  1759. immap = (immap_t *)CFG_IMMR;
  1760. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  1761. cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
  1762. /*
  1763. * Disable PCMCIA buffers (isolate the interface)
  1764. * and assert RESET signal
  1765. */
  1766. debug ("Disable PCMCIA buffers and assert RESET\n");
  1767. reg = PCMCIA_PGCRX(slot);
  1768. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  1769. reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
  1770. PCMCIA_PGCRX(slot) = reg;
  1771. udelay(500);
  1772. debug ("PCMCIA power OFF\n");
  1773. /*
  1774. * Configure Port B pins for
  1775. * 3 Volts enable
  1776. */
  1777. cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
  1778. cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
  1779. /* remove all power */
  1780. cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
  1781. switch(vcc) {
  1782. case 0: break;
  1783. case 33:
  1784. cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
  1785. debug ("PCMCIA powered at 3.3V\n");
  1786. break;
  1787. case 50:
  1788. debug ("PCMCIA: 5Volt vcc not supported\n");
  1789. break;
  1790. default:
  1791. puts("PCMCIA: vcc not supported");
  1792. break;
  1793. }
  1794. udelay(10000);
  1795. /* Checking supported voltages */
  1796. debug ("PIPR: 0x%x --> %s\n",
  1797. pcmp->pcmc_pipr,
  1798. (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
  1799. ? "only 5 V --> NOT SUPPORTED"
  1800. : "can do 3.3V");
  1801. debug ("Enable PCMCIA buffers and stop 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 ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  1808. slot+'A');
  1809. return (0);
  1810. }
  1811. #endif /* KUP4K */
  1812. /* -------------------------------------------------------------------- */
  1813. /* End of Board Specific Stuff */
  1814. /* -------------------------------------------------------------------- */
  1815. /* -------------------------------------------------------------------- */
  1816. /* MPC8xx Specific Stuff - should go to MPC8xx directory */
  1817. /* -------------------------------------------------------------------- */
  1818. /*
  1819. * Search this table to see if the windowsize is
  1820. * supported...
  1821. */
  1822. #define M8XX_SIZES_NO 32
  1823. static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
  1824. { 0x00000001, 0x00000002, 0x00000008, 0x00000004,
  1825. 0x00000080, 0x00000040, 0x00000010, 0x00000020,
  1826. 0x00008000, 0x00004000, 0x00001000, 0x00002000,
  1827. 0x00000100, 0x00000200, 0x00000800, 0x00000400,
  1828. 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  1829. 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
  1830. 0x00010000, 0x00020000, 0x00080000, 0x00040000,
  1831. 0x00800000, 0x00400000, 0x00100000, 0x00200000 };
  1832. /* -------------------------------------------------------------------- */
  1833. #ifndef CONFIG_I82365
  1834. static u_int m8xx_get_graycode(u_int size)
  1835. {
  1836. u_int k;
  1837. for (k = 0; k < M8XX_SIZES_NO; k++) {
  1838. if(m8xx_size_to_gray[k] == size)
  1839. break;
  1840. }
  1841. if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
  1842. k = -1;
  1843. return k;
  1844. }
  1845. #endif /* CONFIG_I82365 */
  1846. /* -------------------------------------------------------------------- */
  1847. #if 0
  1848. static u_int m8xx_get_speed(u_int ns, u_int is_io)
  1849. {
  1850. u_int reg, clocks, psst, psl, psht;
  1851. if(!ns) {
  1852. /*
  1853. * We get called with IO maps setup to 0ns
  1854. * if not specified by the user.
  1855. * They should be 255ns.
  1856. */
  1857. if(is_io)
  1858. ns = 255;
  1859. else
  1860. ns = 100; /* fast memory if 0 */
  1861. }
  1862. /*
  1863. * In PSST, PSL, PSHT fields we tell the controller
  1864. * timing parameters in CLKOUT clock cycles.
  1865. * CLKOUT is the same as GCLK2_50.
  1866. */
  1867. /* how we want to adjust the timing - in percent */
  1868. #define ADJ 180 /* 80 % longer accesstime - to be sure */
  1869. clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
  1870. clocks = (clocks * ADJ) / (100*1000);
  1871. if(clocks >= PCMCIA_BMT_LIMIT) {
  1872. DEBUG(0, "Max access time limit reached\n");
  1873. clocks = PCMCIA_BMT_LIMIT-1;
  1874. }
  1875. psst = clocks / 7; /* setup time */
  1876. psht = clocks / 7; /* hold time */
  1877. psl = (clocks * 5) / 7; /* strobe length */
  1878. psst += clocks - (psst + psht + psl);
  1879. reg = psst << 12;
  1880. reg |= psl << 7;
  1881. reg |= psht << 16;
  1882. return reg;
  1883. }
  1884. #endif
  1885. /* -------------------------------------------------------------------- */
  1886. #ifdef CONFIG_IDE_8xx_PCCARD
  1887. static void print_funcid (int func)
  1888. {
  1889. puts (indent);
  1890. switch (func) {
  1891. case CISTPL_FUNCID_MULTI:
  1892. puts (" Multi-Function");
  1893. break;
  1894. case CISTPL_FUNCID_MEMORY:
  1895. puts (" Memory");
  1896. break;
  1897. case CISTPL_FUNCID_SERIAL:
  1898. puts (" Serial Port");
  1899. break;
  1900. case CISTPL_FUNCID_PARALLEL:
  1901. puts (" Parallel Port");
  1902. break;
  1903. case CISTPL_FUNCID_FIXED:
  1904. puts (" Fixed Disk");
  1905. break;
  1906. case CISTPL_FUNCID_VIDEO:
  1907. puts (" Video Adapter");
  1908. break;
  1909. case CISTPL_FUNCID_NETWORK:
  1910. puts (" Network Adapter");
  1911. break;
  1912. case CISTPL_FUNCID_AIMS:
  1913. puts (" AIMS Card");
  1914. break;
  1915. case CISTPL_FUNCID_SCSI:
  1916. puts (" SCSI Adapter");
  1917. break;
  1918. default:
  1919. puts (" Unknown");
  1920. break;
  1921. }
  1922. puts (" Card\n");
  1923. }
  1924. #endif /* CONFIG_IDE_8xx_PCCARD */
  1925. /* -------------------------------------------------------------------- */
  1926. #ifdef CONFIG_IDE_8xx_PCCARD
  1927. static void print_fixed (volatile uchar *p)
  1928. {
  1929. if (p == NULL)
  1930. return;
  1931. puts(indent);
  1932. switch (*p) {
  1933. case CISTPL_FUNCE_IDE_IFACE:
  1934. { uchar iface = *(p+2);
  1935. puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
  1936. puts (" interface ");
  1937. break;
  1938. }
  1939. case CISTPL_FUNCE_IDE_MASTER:
  1940. case CISTPL_FUNCE_IDE_SLAVE:
  1941. { uchar f1 = *(p+2);
  1942. uchar f2 = *(p+4);
  1943. puts ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
  1944. if (f1 & CISTPL_IDE_UNIQUE)
  1945. puts (" [unique]");
  1946. puts ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
  1947. if (f2 & CISTPL_IDE_HAS_SLEEP)
  1948. puts (" [sleep]");
  1949. if (f2 & CISTPL_IDE_HAS_STANDBY)
  1950. puts (" [standby]");
  1951. if (f2 & CISTPL_IDE_HAS_IDLE)
  1952. puts (" [idle]");
  1953. if (f2 & CISTPL_IDE_LOW_POWER)
  1954. puts (" [low power]");
  1955. if (f2 & CISTPL_IDE_REG_INHIBIT)
  1956. puts (" [reg inhibit]");
  1957. if (f2 & CISTPL_IDE_HAS_INDEX)
  1958. puts (" [index]");
  1959. if (f2 & CISTPL_IDE_IOIS16)
  1960. puts (" [IOis16]");
  1961. break;
  1962. }
  1963. }
  1964. putc ('\n');
  1965. }
  1966. #endif /* CONFIG_IDE_8xx_PCCARD */
  1967. /* -------------------------------------------------------------------- */
  1968. #ifdef CONFIG_IDE_8xx_PCCARD
  1969. #define MAX_IDENT_CHARS 64
  1970. #define MAX_IDENT_FIELDS 4
  1971. static uchar *known_cards[] = {
  1972. "ARGOSY PnPIDE D5",
  1973. NULL
  1974. };
  1975. static int identify (volatile uchar *p)
  1976. {
  1977. uchar id_str[MAX_IDENT_CHARS];
  1978. uchar data;
  1979. uchar *t;
  1980. uchar **card;
  1981. int i, done;
  1982. if (p == NULL)
  1983. return (0); /* Don't know */
  1984. t = id_str;
  1985. done =0;
  1986. for (i=0; i<=4 && !done; ++i, p+=2) {
  1987. while ((data = *p) != '\0') {
  1988. if (data == 0xFF) {
  1989. done = 1;
  1990. break;
  1991. }
  1992. *t++ = data;
  1993. if (t == &id_str[MAX_IDENT_CHARS-1]) {
  1994. done = 1;
  1995. break;
  1996. }
  1997. p += 2;
  1998. }
  1999. if (!done)
  2000. *t++ = ' ';
  2001. }
  2002. *t = '\0';
  2003. while (--t > id_str) {
  2004. if (*t == ' ')
  2005. *t = '\0';
  2006. else
  2007. break;
  2008. }
  2009. puts (id_str);
  2010. putc ('\n');
  2011. for (card=known_cards; *card; ++card) {
  2012. debug ("## Compare against \"%s\"\n", *card);
  2013. if (strcmp(*card, id_str) == 0) { /* found! */
  2014. debug ("## CARD FOUND ##\n");
  2015. return (1);
  2016. }
  2017. }
  2018. return (0); /* don't know */
  2019. }
  2020. #endif /* CONFIG_IDE_8xx_PCCARD */
  2021. /* -------------------------------------------------------------------- */
  2022. #endif /* CFG_CMD_PCMCIA || (CFG_CMD_IDE && CONFIG_IDE_8xx_PCCARD) */
  2023. /**************************************************/
  2024. #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
  2025. U_BOOT_CMD(
  2026. pinit, 2, 1, do_pinit,
  2027. "pinit - PCMCIA sub-system\n",
  2028. "on - power on PCMCIA socket\n"
  2029. "pinit off - power off PCMCIA socket\n"
  2030. );
  2031. #endif