cmd_pcmcia.c 63 KB

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