]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/mips/txx9/generic/setup_tx4938.c
Merge branch 'omap-clock-fixes' of git://git.pwsan.com/linux-2.6
[linux-2.6-omap-h63xx.git] / arch / mips / txx9 / generic / setup_tx4938.c
index af724e53ef9134b905b64e98fcd723ec43365dee..f0844f891f0bf11ca2ea9869f96ba590417eff71 100644 (file)
 #include <linux/param.h>
 #include <linux/ptrace.h>
 #include <linux/mtd/physmap.h>
+#include <linux/platform_device.h>
 #include <asm/reboot.h>
 #include <asm/traps.h>
 #include <asm/txx9irq.h>
 #include <asm/txx9tmr.h>
 #include <asm/txx9pio.h>
 #include <asm/txx9/generic.h>
+#include <asm/txx9/ndfmc.h>
 #include <asm/txx9/tx4938.h>
 
 static void __init tx4938_wdr_init(void)
@@ -335,6 +337,72 @@ void __init tx4938_mtd_init(int ch)
        txx9_physmap_flash_init(ch, start, size, &pdata);
 }
 
+void __init tx4938_ata_init(unsigned int irq, unsigned int shift, int tune)
+{
+       struct platform_device *pdev;
+       struct resource res[] = {
+               {
+                       /* .start and .end are filled in later */
+                       .flags = IORESOURCE_MEM,
+               }, {
+                       .start = irq,
+                       .flags = IORESOURCE_IRQ,
+               },
+       };
+       struct tx4938ide_platform_info pdata = {
+               .ioport_shift = shift,
+               /*
+                * The IDE driver should not change bus timings if other ISA
+                * devices existed.
+                */
+               .gbus_clock = tune ? txx9_gbus_clock : 0,
+       };
+       u64 ebccr;
+       int i;
+
+       if ((__raw_readq(&tx4938_ccfgptr->pcfg) &
+            (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL))
+           != TX4938_PCFG_ATA_SEL)
+               return;
+       for (i = 0; i < 8; i++) {
+               /* check EBCCRn.ISA, EBCCRn.BSZ, EBCCRn.ME */
+               ebccr = __raw_readq(&tx4938_ebuscptr->cr[i]);
+               if ((ebccr & 0x00f00008) == 0x00e00008)
+                       break;
+       }
+       if (i == 8)
+               return;
+       pdata.ebus_ch = i;
+       res[0].start = ((ebccr >> 48) << 20) + 0x10000;
+       res[0].end = res[0].start + 0x20000 - 1;
+       pdev = platform_device_alloc("tx4938ide", -1);
+       if (!pdev ||
+           platform_device_add_resources(pdev, res, ARRAY_SIZE(res)) ||
+           platform_device_add_data(pdev, &pdata, sizeof(pdata)) ||
+           platform_device_add(pdev))
+               platform_device_put(pdev);
+}
+
+void __init tx4938_ndfmc_init(unsigned int hold, unsigned int spw)
+{
+       struct txx9ndfmc_platform_data plat_data = {
+               .shift = 1,
+               .gbus_clock = txx9_gbus_clock,
+               .hold = hold,
+               .spw = spw,
+               .ch_mask = 1,
+       };
+       unsigned long baseaddr = TX4938_NDFMC_REG & 0xfffffffffULL;
+
+#ifdef __BIG_ENDIAN
+       baseaddr += 4;
+#endif
+       if ((__raw_readq(&tx4938_ccfgptr->pcfg) &
+            (TX4938_PCFG_ATA_SEL|TX4938_PCFG_ISA_SEL|TX4938_PCFG_NDF_SEL)) ==
+           TX4938_PCFG_NDF_SEL)
+               txx9_ndfmc_init(baseaddr, &plat_data);
+}
+
 static void __init tx4938_stop_unused_modules(void)
 {
        __u64 pcfg, rst = 0, ckd = 0;