cmd_pcmcia.c 61 KB

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