bast-ide.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2003-2004 Simtec Electronics
  3. * Ben Dooks <ben@simtec.co.uk>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. */
  10. #include <linux/module.h>
  11. #include <linux/errno.h>
  12. #include <linux/ide.h>
  13. #include <linux/init.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/io.h>
  16. #include <asm/irq.h>
  17. #include <asm/arch/map.h>
  18. #include <asm/arch/bast-map.h>
  19. #include <asm/arch/bast-irq.h>
  20. static int __init bastide_register(unsigned int base, unsigned int aux, int irq)
  21. {
  22. ide_hwif_t *hwif;
  23. hw_regs_t hw;
  24. int i;
  25. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  26. memset(&hw, 0, sizeof(hw));
  27. base += BAST_IDE_CS;
  28. aux += BAST_IDE_CS;
  29. for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
  30. hw.io_ports[i] = (unsigned long)base;
  31. base += 0x20;
  32. }
  33. hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
  34. hw.irq = irq;
  35. hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]);
  36. if (hwif == NULL)
  37. goto out;
  38. i = hwif->index;
  39. if (hwif->present)
  40. ide_unregister(i);
  41. else
  42. ide_init_port_data(hwif, i);
  43. ide_init_port_hw(hwif, &hw);
  44. hwif->quirkproc = NULL;
  45. idx[0] = i;
  46. ide_device_add(idx, NULL);
  47. out:
  48. return 0;
  49. }
  50. static int __init bastide_init(void)
  51. {
  52. /* we can treat the VR1000 and the BAST the same */
  53. if (!(machine_is_bast() || machine_is_vr1000()))
  54. return 0;
  55. printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n");
  56. bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0);
  57. bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1);
  58. return 0;
  59. }
  60. module_init(bastide_init);
  61. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  62. MODULE_LICENSE("GPL");
  63. MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");