platform.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <linux/err.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4. #include <linux/io.h>
  5. #include <linux/platform_device.h>
  6. #include <linux/ata_platform.h>
  7. #include <asm/sibyte/board.h>
  8. #include <asm/sibyte/sb1250_genbus.h>
  9. #include <asm/sibyte/sb1250_regs.h>
  10. #if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR)
  11. #define DRV_NAME "pata-swarm"
  12. #define SWARM_IDE_SHIFT 5
  13. #define SWARM_IDE_BASE 0x1f0
  14. #define SWARM_IDE_CTRL 0x3f6
  15. static struct resource swarm_pata_resource[] = {
  16. {
  17. .name = "Swarm GenBus IDE",
  18. .flags = IORESOURCE_MEM,
  19. }, {
  20. .name = "Swarm GenBus IDE",
  21. .flags = IORESOURCE_MEM,
  22. }, {
  23. .name = "Swarm GenBus IDE",
  24. .flags = IORESOURCE_IRQ,
  25. .start = K_INT_GB_IDE,
  26. .end = K_INT_GB_IDE,
  27. },
  28. };
  29. static struct pata_platform_info pata_platform_data = {
  30. .ioport_shift = SWARM_IDE_SHIFT,
  31. };
  32. static struct platform_device swarm_pata_device = {
  33. .name = "pata_platform",
  34. .id = -1,
  35. .resource = swarm_pata_resource,
  36. .num_resources = ARRAY_SIZE(swarm_pata_resource),
  37. .dev = {
  38. .platform_data = &pata_platform_data,
  39. .coherent_dma_mask = ~0, /* grumble */
  40. },
  41. };
  42. static int __init swarm_pata_init(void)
  43. {
  44. u8 __iomem *base;
  45. phys_t offset, size;
  46. struct resource *r;
  47. if (!SIBYTE_HAVE_IDE)
  48. return -ENODEV;
  49. base = ioremap(A_IO_EXT_BASE, 0x800);
  50. offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
  51. size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
  52. iounmap(base);
  53. offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
  54. size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
  55. if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
  56. pr_info(DRV_NAME ": PATA interface at GenBus disabled\n");
  57. return -EBUSY;
  58. }
  59. pr_info(DRV_NAME ": PATA interface at GenBus slot %i\n", IDE_CS);
  60. r = swarm_pata_resource;
  61. r[0].start = offset + (SWARM_IDE_BASE << SWARM_IDE_SHIFT);
  62. r[0].end = offset + ((SWARM_IDE_BASE + 8) << SWARM_IDE_SHIFT) - 1;
  63. r[1].start = offset + (SWARM_IDE_CTRL << SWARM_IDE_SHIFT);
  64. r[1].end = offset + ((SWARM_IDE_CTRL + 1) << SWARM_IDE_SHIFT) - 1;
  65. return platform_device_register(&swarm_pata_device);
  66. }
  67. device_initcall(swarm_pata_init);
  68. #endif /* defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR) */