Wolfgang Denk | 50440e7 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 1 | #include <common.h> |
| 2 | #include <mpc8xx.h> |
| 3 | #include <pcmcia.h> |
| 4 | |
| 5 | #undef CONFIG_PCMCIA |
| 6 | |
Jon Loeliger | 96892a9 | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 7 | #if defined(CONFIG_CMD_PCMCIA) |
Wolfgang Denk | 50440e7 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 8 | #define CONFIG_PCMCIA |
| 9 | #endif |
| 10 | |
Jon Loeliger | 96892a9 | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 11 | #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD) |
Wolfgang Denk | 50440e7 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 12 | #define CONFIG_PCMCIA |
| 13 | #endif |
| 14 | |
| 15 | #ifdef CONFIG_PCMCIA |
| 16 | |
| 17 | #define PCMCIA_BOARD_MSG "GTH COMPACT FLASH" |
| 18 | |
| 19 | int pcmcia_voltage_set (int slot, int vcc, int vpp) |
| 20 | { /* Do nothing */ |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | int pcmcia_hardware_enable (int slot) |
| 25 | { |
| 26 | volatile immap_t *immap; |
| 27 | volatile cpm8xx_t *cp; |
| 28 | volatile pcmconf8xx_t *pcmp; |
| 29 | volatile sysconf8xx_t *sysp; |
| 30 | uint reg, mask; |
| 31 | |
| 32 | debug ("hardware_enable: GTH Slot %c\n", 'A' + slot); |
| 33 | |
| 34 | immap = (immap_t *) CFG_IMMR; |
| 35 | sysp = (sysconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_siu_conf)); |
| 36 | pcmp = (pcmconf8xx_t *) (&(((immap_t *) CFG_IMMR)->im_pcmcia)); |
| 37 | cp = (cpm8xx_t *) (&(((immap_t *) CFG_IMMR)->im_cpm)); |
| 38 | |
| 39 | /* clear interrupt state, and disable interrupts */ |
| 40 | pcmp->pcmc_pscr = PCMCIA_MASK (_slot_); |
| 41 | pcmp->pcmc_per &= ~PCMCIA_MASK (_slot_); |
| 42 | |
| 43 | /* |
| 44 | * Disable interrupts, DMA, and PCMCIA buffers |
| 45 | * (isolate the interface) and assert RESET signal |
| 46 | */ |
| 47 | debug ("Disable PCMCIA buffers and assert RESET\n"); |
| 48 | reg = 0; |
| 49 | reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */ |
| 50 | reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */ |
| 51 | PCMCIA_PGCRX (_slot_) = reg; |
| 52 | udelay (500); |
| 53 | |
| 54 | /* |
| 55 | * Make sure there is a card in the slot, |
| 56 | * then configure the interface. |
| 57 | */ |
| 58 | udelay (10000); |
| 59 | debug ("[%d] %s: PIPR(%p)=0x%x\n", |
| 60 | __LINE__, __FUNCTION__, |
| 61 | &(pcmp->pcmc_pipr), pcmp->pcmc_pipr); |
| 62 | if (pcmp->pcmc_pipr & 0x98000000) { |
| 63 | printf (" No Card found\n"); |
| 64 | return (1); |
| 65 | } |
| 66 | |
| 67 | mask = PCMCIA_VS1 (slot) | PCMCIA_VS2 (slot); |
| 68 | reg = pcmp->pcmc_pipr; |
| 69 | debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", |
| 70 | reg, |
| 71 | (reg & PCMCIA_VS1 (slot)) ? "n" : "ff", |
| 72 | (reg & PCMCIA_VS2 (slot)) ? "n" : "ff"); |
| 73 | |
| 74 | debug ("Enable PCMCIA buffers and stop RESET\n"); |
| 75 | reg = PCMCIA_PGCRX (_slot_); |
| 76 | reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */ |
| 77 | reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */ |
| 78 | PCMCIA_PGCRX (_slot_) = reg; |
| 79 | |
| 80 | udelay (250000); /* some cards need >150 ms to come up :-( */ |
| 81 | |
| 82 | debug ("# hardware_enable done\n"); |
| 83 | |
| 84 | return 0; |
| 85 | } |
Jon Loeliger | 96892a9 | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 86 | #if defined(CONFIG_CMD_PCMCIA) |
Wolfgang Denk | 50440e7 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 87 | int pcmcia_hardware_disable(int slot) |
| 88 | { |
| 89 | return 0; /* No hardware to disable */ |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | #endif /* CONFIG_PCMCIA */ |