Wolfgang Denk | 9d40799 | 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 | c508a4c | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 7 | #if defined(CONFIG_CMD_PCMCIA) |
Wolfgang Denk | 9d40799 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 8 | #define CONFIG_PCMCIA |
| 9 | #endif |
| 10 | |
Jon Loeliger | c508a4c | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 11 | #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD) |
Wolfgang Denk | 9d40799 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 12 | #define CONFIG_PCMCIA |
| 13 | #endif |
| 14 | |
| 15 | #ifdef CONFIG_PCMCIA |
| 16 | |
| 17 | #ifdef CONFIG_ADS |
| 18 | #define PCMCIA_BOARD_MSG "ADS" |
| 19 | #else |
| 20 | #define PCMCIA_BOARD_MSG "FADS" |
| 21 | #endif |
| 22 | |
| 23 | int pcmcia_voltage_set(int slot, int vcc, int vpp) |
| 24 | { |
| 25 | u_long reg = 0; |
| 26 | |
| 27 | switch(vpp) { |
| 28 | case 0: reg = 0; break; |
| 29 | case 50: reg = 1; break; |
| 30 | case 120: reg = 2; break; |
| 31 | default: return 1; |
| 32 | } |
| 33 | |
| 34 | switch(vcc) { |
| 35 | case 0: reg = 0; break; |
| 36 | #ifdef CONFIG_ADS |
| 37 | case 50: reg = BCSR1_PCCVCCON; break; |
| 38 | #endif |
| 39 | #ifdef CONFIG_FADS |
| 40 | case 33: reg = BCSR1_PCCVCC0 | BCSR1_PCCVCC1; break; |
| 41 | case 50: reg = BCSR1_PCCVCC1; break; |
| 42 | #endif |
| 43 | default: return 1; |
| 44 | } |
| 45 | |
| 46 | /* first, turn off all power */ |
| 47 | |
| 48 | #ifdef CONFIG_ADS |
| 49 | *((uint *)BCSR1) |= BCSR1_PCCVCCON; |
| 50 | #endif |
| 51 | #ifdef CONFIG_FADS |
| 52 | *((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1); |
| 53 | #endif |
| 54 | *((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK; |
| 55 | |
| 56 | /* enable new powersettings */ |
| 57 | |
| 58 | #ifdef CONFIG_ADS |
| 59 | *((uint *)BCSR1) &= ~reg; |
| 60 | #endif |
| 61 | #ifdef CONFIG_FADS |
| 62 | *((uint *)BCSR1) |= reg; |
| 63 | #endif |
| 64 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 65 | *((uint *)BCSR1) |= reg << 20; |
Wolfgang Denk | 9d40799 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | int pcmcia_hardware_enable(int slot) |
| 71 | { |
| 72 | *((uint *)BCSR1) &= ~BCSR1_PCCEN; |
| 73 | return 0; |
| 74 | } |
| 75 | |
Jon Loeliger | c508a4c | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 76 | #if defined(CONFIG_CMD_PCMCIA) |
Wolfgang Denk | 9d40799 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 77 | int pcmcia_hardware_disable(int slot) |
| 78 | { |
| 79 | *((uint *)BCSR1) &= ~BCSR1_PCCEN; |
| 80 | return 0; |
| 81 | } |
Jon Loeliger | c508a4c | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 82 | #endif |
Wolfgang Denk | 9d40799 | 2006-07-10 23:07:28 +0200 | [diff] [blame] | 83 | |
| 84 | #endif /* CONFIG_PCMCIA */ |