X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=drivers%2Fpcmcia%2Ftqm8xx_pcmcia.c;h=dda7d374450a14899d27c072d811fb98a72db175;hb=d4125ebc8dae28e8ade858ba519bca7fbeb6ccae;hp=132c7a5169b649e59a255b5265a34e4f0eff345d;hpb=f743931f9b4d4e15c9bdfe726bef033ea1f1402c;p=karo-tx-uboot.git diff --git a/drivers/pcmcia/tqm8xx_pcmcia.c b/drivers/pcmcia/tqm8xx_pcmcia.c index 132c7a5169..dda7d37445 100644 --- a/drivers/pcmcia/tqm8xx_pcmcia.c +++ b/drivers/pcmcia/tqm8xx_pcmcia.c @@ -3,6 +3,7 @@ /* SC8xx Boards by SinoVee Microsystems */ /* -------------------------------------------------------------------- */ #include +#include #ifdef CONFIG_8xx #include #endif @@ -31,118 +32,96 @@ #if defined(CONFIG_NSCU) -#define power_config(slot) do {} while (0) -#define power_off(slot) do {} while (0) -#define power_on_5_0(slot) do {} while (0) -#define power_on_3_3(slot) do {} while (0) +static inline void power_config(int slot) {} +static inline void power_off(int slot) {} +static inline void power_on_5_0(int slot) {} +static inline void power_on_3_3(int slot) {} -#elif defined(CONFIG_HMI10) +#elif defined(CONFIG_VIRTLAB2) -static inline void power_config(int slot) -{ - volatile immap_t *immap = (immap_t *)CFG_IMMR; - /* - * Configure Port B pins for - * 5 Volts Enable and 3 Volts enable - */ - immap->im_cpm.cp_pbpar &= ~(0x00000300); -} +static inline void power_config(int slot) {} static inline void power_off(int slot) { - volatile immap_t *immap = (immap_t *)CFG_IMMR; - /* remove all power */ - immap->im_cpm.cp_pbdat |= 0x00000300; -} - -static inline void power_on_5_0(int slot) -{ - volatile immap_t *immap = (immap_t *)CFG_IMMR; - immap->im_cpm.cp_pbdat &= ~(0x0000100); - immap->im_cpm.cp_pbdir |= 0x00000300; -} - -static inline void power_on_3_3(int slot) -{ - volatile immap_t *immap = (immap_t *)CFG_IMMR; - immap->im_cpm.cp_pbdat &= ~(0x0000200); - immap->im_cpm.cp_pbdir |= 0x00000300; -} + volatile unsigned __iomem *addr; + addr = (volatile unsigned __iomem *)PCMCIA_CTRL; -#elif defined(CONFIG_VIRTLAB2) - -#define power_config(slot) do {} while (0) -static inline void power_off(int slot) -{ - volatile unsigned char *powerctl = - (volatile unsigned char *)PCMCIA_CTRL; - *powerctl = 0; + out_be32(addr, 0); } static inline void power_on_5_0(int slot) { - volatile unsigned char *powerctl = - (volatile unsigned char *)PCMCIA_CTRL; - *powerctl = 2; /* Enable 5V Vccout */ + volatile unsigned __iomem *addr; + addr = (volatile unsigned __iomem *)PCMCIA_CTRL; + + /* Enable 5V Vccout */ + out_be32(addr, 2); } static inline void power_on_3_3(int slot) { - volatile unsigned char *powerctl = - (volatile unsigned char *)PCMCIA_CTRL; - *powerctl = 1; /* Enable 3.3V Vccout */ + volatile unsigned __iomem *addr; + addr = (volatile unsigned __iomem *)PCMCIA_CTRL; + + /* Enable 3.3V Vccout */ + out_be32(addr, 1); } #else static inline void power_config(int slot) { - volatile immap_t *immap = (immap_t *)CFG_IMMR; + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; /* - * Configure Port C pins for - * 5 Volts Enable and 3 Volts enable - */ - immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004); - immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004); + * Configure Port C pins for + * 5 Volts Enable and 3 Volts enable + */ + clrbits_be16(&immap->im_ioport.iop_pcpar, 0x0002 | 0x0004); + clrbits_be16(&immap->im_ioport.iop_pcso, 0x0002 | 0x0004); } static inline void power_off(int slot) { - volatile immap_t *immap = (immap_t *)CFG_IMMR; - immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004); + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; + clrbits_be16(&immap->im_ioport.iop_pcdat, 0x0002 | 0x0004); } static inline void power_on_5_0(int slot) { - volatile immap_t *immap = (immap_t *)CFG_IMMR; - immap->im_ioport.iop_pcdat |= 0x0004; - immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004); + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; + setbits_be16(&immap->im_ioport.iop_pcdat, 0x0004); + setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004); } static inline void power_on_3_3(int slot) { - volatile immap_t *immap = (immap_t *)CFG_IMMR; - immap->im_ioport.iop_pcdat |= 0x0002; - immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004); + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; + setbits_be16(&immap->im_ioport.iop_pcdat, 0x0002); + setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004); } #endif -#ifdef CONFIG_HMI10 -static inline int check_card_is_absent(int slot) +/* + * Function to retrieve the PIPR register, used for debuging purposes. + */ +static inline uint32_t debug_get_pipr(void) { - volatile pcmconf8xx_t *pcmp = - (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia)); - return pcmp->pcmc_pipr & (0x10000000 >> (slot << 4)); + uint32_t pipr = 0; +#ifdef DEBUG + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; + pipr = in_be32(&immap->im_pcmcia.pcmc_pipr); +#endif + return pipr; } -#else + + static inline int check_card_is_absent(int slot) { - volatile pcmconf8xx_t *pcmp = - (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia)); - return pcmp->pcmc_pipr & (0x18000000 >> (slot << 4)); + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; + uint32_t pipr = in_be32(&immap->im_pcmcia.pcmc_pipr); + return pipr & (0x18000000 >> (slot << 4)); } -#endif #ifdef NSCU_OE_INV #define NSCU_GCRX_CXOE 0 @@ -152,31 +131,30 @@ static inline int check_card_is_absent(int slot) int pcmcia_hardware_enable(int slot) { - volatile pcmconf8xx_t *pcmp = - (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia)); - volatile sysconf8xx_t *sysp = - (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf)); + immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; uint reg, mask; - debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot); + debug("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot); udelay(10000); /* - * Configure SIUMCR to enable PCMCIA port B - * (VFLS[0:1] are not used for debugging, we connect FRZ# instead) - */ - sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */ + * Configure SIUMCR to enable PCMCIA port B + * (VFLS[0:1] are not used for debugging, we connect FRZ# instead) + */ + + /* Set DBGC to 00 */ + clrbits_be32(&immap->im_siu_conf.sc_siumcr, SIUMCR_DBGC11); - /* clear interrupt state, and disable interrupts */ - pcmp->pcmc_pscr = PCMCIA_MASK(slot); - pcmp->pcmc_per &= ~PCMCIA_MASK(slot); + /* Clear interrupt state, and disable interrupts */ + out_be32(&immap->im_pcmcia.pcmc_pscr, PCMCIA_MASK(slot)); + clrbits_be32(&immap->im_pcmcia.pcmc_per, PCMCIA_MASK(slot)); /* - * Disable interrupts, DMA, and PCMCIA buffers - * (isolate the interface) and assert RESET signal - */ - debug ("Disable PCMCIA buffers and assert RESET\n"); + * Disable interrupts, DMA, and PCMCIA buffers + * (isolate the interface) and assert RESET signal + */ + debug("Disable PCMCIA buffers and assert RESET\n"); reg = 0; reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */ reg |= NSCU_GCRX_CXOE; @@ -191,8 +169,9 @@ int pcmcia_hardware_enable(int slot) * Make sure there is a card in the slot, then configure the interface. */ udelay(10000); - debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__, - &(pcmp->pcmc_pipr),pcmp->pcmc_pipr); + reg = debug_get_pipr(); + debug("[%d] %s: PIPR(%p)=0x%x\n", __LINE__, __FUNCTION__, + &immap->im_pcmcia.pcmc_pipr, reg); if (check_card_is_absent(slot)) { printf (" No Card found\n"); @@ -200,14 +179,14 @@ int pcmcia_hardware_enable(int slot) } /* - * Power On. - */ + * Power On. + */ mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot); - reg = pcmp->pcmc_pipr; + reg = in_be32(&immap->im_pcmcia.pcmc_pipr); debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n", reg, - (reg&PCMCIA_VS1(slot))?"n":"ff", - (reg&PCMCIA_VS2(slot))?"n":"ff"); + (reg & PCMCIA_VS1(slot)) ? "n" : "ff", + (reg & PCMCIA_VS2(slot)) ? "n" : "ff"); if ((reg & mask) == mask) { power_on_5_0(slot); @@ -225,7 +204,7 @@ int pcmcia_hardware_enable(int slot) #endif udelay(1000); - debug ("Enable PCMCIA buffers and stop RESET\n"); + debug("Enable PCMCIA buffers and stop RESET\n"); reg = PCMCIA_PGCRX(slot); reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */ reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */ @@ -235,7 +214,7 @@ int pcmcia_hardware_enable(int slot) udelay(250000); /* some cards need >150 ms to come up :-( */ - debug ("# hardware_enable done\n"); + debug("# hardware_enable done\n"); return (0); } @@ -246,13 +225,12 @@ int pcmcia_hardware_disable(int slot) { u_long reg; - debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot); - + debug("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot); /* remove all power */ power_off(slot); - debug ("Disable PCMCIA buffers and assert RESET\n"); + debug("Disable PCMCIA buffers and assert RESET\n"); reg = 0; reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */ reg |= NSCU_GCRX_CXOE; /* active low */ @@ -269,20 +247,17 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp) { #ifndef CONFIG_NSCU u_long reg; -# ifdef DEBUG - volatile pcmconf8xx_t *pcmp = - (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia)); -# endif + uint32_t pipr = 0; - debug ("voltage_set: " PCMCIA_BOARD_MSG + debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n", 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10); /* - * Disable PCMCIA buffers (isolate the interface) - * and assert RESET signal - */ - debug ("Disable PCMCIA buffers and assert RESET\n"); + * Disable PCMCIA buffers (isolate the interface) + * and assert RESET signal + */ + debug("Disable PCMCIA buffers and assert RESET\n"); reg = PCMCIA_PGCRX(slot); reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */ reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */ @@ -291,21 +266,21 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp) PCMCIA_PGCRX(slot) = reg; udelay(500); - debug ("PCMCIA power OFF\n"); + debug("PCMCIA power OFF\n"); power_config(slot); power_off(slot); switch(vcc) { - case 0: break; + case 0: break; case 33: power_on_3_3(slot); break; case 50: power_on_5_0(slot); break; - default: goto done; + default: goto done; } /* Checking supported voltages */ - - debug("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr, - (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V"); + pipr = debug_get_pipr(); + debug("PIPR: 0x%x --> %s\n", pipr, + (pipr & 0x00008000) ? "only 5 V" : "can do 3.3V"); if (vcc) debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3"); @@ -324,7 +299,7 @@ done: debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A'); #endif /* CONFIG_NSCU */ - return (0); + return 0; } #endif /* CONFIG_PCMCIA && (CONFIG_TQM8xxL || CONFIG_SVM_SC8xx) */