vsprintf: split out '%p' handling logic
[pandora-kernel.git] / drivers / ide / ppc / mpc8xx.c
index a784a97..236f9c3 100644 (file)
@@ -36,6 +36,8 @@
 #include <asm/machdep.h>
 #include <asm/irq.h>
 
+#define DRV_NAME "ide-mpc8xx"
+
 static int identify  (volatile u8 *p);
 static void print_fixed (volatile u8 *p);
 static void print_funcid (int func);
@@ -127,9 +129,9 @@ static int pcmcia_schlvl = PCMCIA_SCHLVL;
  * MPC8xx's internal PCMCIA interface
  */
 #if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
-static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
+static int __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
 {
-       unsigned long *p = hw->io_ports;
+       unsigned long *p = hw->io_ports_array;
        int i;
 
        typedef struct {
@@ -182,6 +184,13 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
                        pcmcia_phy_base, pcmcia_phy_end,
                        pcmcia_phy_end - pcmcia_phy_base);
 
+               if (!request_mem_region(pcmcia_phy_base,
+                                       pcmcia_phy_end - pcmcia_phy_base,
+                                       DRV_NAME)) {
+                       printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
+                       return -EBUSY;
+               }
+
                pcmcia_base=(unsigned long)ioremap(pcmcia_phy_base,
                                                   pcmcia_phy_end-pcmcia_phy_base);
 
@@ -236,7 +245,7 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
        if (pcmp->pcmc_pipr & (M8XX_PCMCIA_CD1(_slot_)|M8XX_PCMCIA_CD2(_slot_))) {
                printk ("No card in slot %c: PIPR=%08x\n",
                        'A' + _slot_, (u32) pcmp->pcmc_pipr);
-               return;         /* No card in slot */
+               return -ENODEV;         /* No card in slot */
        }
 
        check_ide_device (pcmcia_base);
@@ -279,9 +288,6 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
        }
 #endif /* CONFIG_IDE_8xx_PCCARD */
 
-       ide_hwifs[data_port].pio_mask = ATA_PIO4;
-       ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode;
-
        /* Enable Harddisk Interrupt,
         * and make it edge sensitive
         */
@@ -296,6 +302,10 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
        /* Enable falling edge irq */
        pcmp->pcmc_per = 0x100000 >> (16 * _slot_);
 #endif /* CONFIG_IDE_8xx_PCCARD */
+
+       hw->chipset = ide_generic;
+
+       return 0;
 }
 #endif /* CONFIG_IDE_8xx_PCCARD || CONFIG_IDE_8xx_DIRECT */
 
@@ -304,9 +314,9 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
  * MPC8xx's internal PCMCIA interface
  */
 #if defined(CONFIG_IDE_EXT_DIRECT)
-static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
+static int __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
 {
-       unsigned long *p = hw->io_ports;
+       unsigned long *p = hw->io_ports_array;
        int i;
 
        u32 ide_phy_base;
@@ -327,7 +337,12 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
                printk ("IDE phys mem : %08x...%08x (size %08x)\n",
                        ide_phy_base, ide_phy_end,
                        ide_phy_end - ide_phy_base);
-               
+
+               if (!request_mem_region(ide_phy_base, 0x200, DRV_NAME)) {
+                       printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
+                       return -EBUSY;
+               }
+
                ide_base=(unsigned long)ioremap(ide_phy_base,
                                                ide_phy_end-ide_phy_base);
 
@@ -357,15 +372,16 @@ static void __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
        hw->irq = ioport_dsc[data_port].irq;
        hw->ack_intr = (ide_ack_intr_t *)ide_interrupt_ack;
 
-       ide_hwifs[data_port].pio_mask = ATA_PIO4;
-       ide_hwifs[data_port].set_pio_mode = m8xx_ide_set_pio_mode;
-
        /* Enable Harddisk Interrupt,
         * and make it edge sensitive
         */
        /* (11-18) Set edge detect for irq, no wakeup from low power mode */
        ((immap_t *) IMAP_ADDR)->im_siu_conf.sc_siel |=
                        (0x80000000 >> ioport_dsc[data_port].irq);
+
+       hw->chipset = ide_generic;
+
+       return 0;
 }
 #endif /* CONFIG_IDE_8xx_DIRECT */
 
@@ -426,10 +442,14 @@ static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
 #elif defined(CONFIG_IDE_EXT_DIRECT)
 
        printk("%s[%d] %s: not implemented yet!\n",
-               __FILE__,__LINE__,__FUNCTION__);
+               __FILE__, __LINE__, __func__);
 #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */
 }
 
+static const struct ide_port_ops m8xx_port_ops = {
+       .set_pio_mode           = m8xx_ide_set_pio_mode,
+};
+
 static void
 ide_interrupt_ack (void *dev)
 {
@@ -794,14 +814,30 @@ static int __init mpc8xx_ide_probe(void)
 
 #ifdef IDE0_BASE_OFFSET
        memset(&hw, 0, sizeof(hw));
-       m8xx_ide_init_ports(&hw, 0);
-       ide_init_port_hw(&ide_hwifs[0], &hw);
-       idx[0] = 0;
+       if (!m8xx_ide_init_ports(&hw, 0)) {
+               ide_hwif_t *hwif = ide_find_port();
+
+               if (hwif) {
+                       ide_init_port_hw(hwif, &hw);
+                       hwif->pio_mask = ATA_PIO4;
+                       hwif->port_ops = &m8xx_port_ops;
+
+                       idx[0] = hwif->index;
+               }
+       }
 #ifdef IDE1_BASE_OFFSET
        memset(&hw, 0, sizeof(hw));
-       m8xx_ide_init_ports(&hw, 1);
-       ide_init_port_hw(&ide_hwifs[1], &hw);
-       idx[1] = 1;
+       if (!m8xx_ide_init_ports(&hw, 1)) {
+               ide_hwif_t *mate = ide_find_port();
+
+               if (mate) {
+                       ide_init_port_hw(mate, &hw);
+                       mate->pio_mask = ATA_PIO4;
+                       mate->port_ops = &m8xx_port_ops;
+
+                       idx[1] = mate->index;
+               }
+       }
 #endif
 #endif