cmd_pcmcia.c 59 KB

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