bast-ide.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /* list of registered interfaces */
  21. static ide_hwif_t *ifs[2];
  22. static int __init
  23. bastide_register(unsigned int base, unsigned int aux, int irq,
  24. ide_hwif_t **hwif)
  25. {
  26. ide_hwif_t *hwif;
  27. hw_regs_t hw;
  28. int i;
  29. u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
  30. memset(&hw, 0, sizeof(hw));
  31. base += BAST_IDE_CS;
  32. aux += BAST_IDE_CS;
  33. for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
  34. hw.io_ports[i] = (unsigned long)base;
  35. base += 0x20;
  36. }
  37. hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
  38. hw.irq = irq;
  39. hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]);
  40. if (hwif == NULL)
  41. goto out;
  42. i = hwif->index;
  43. if (hwif->present)
  44. ide_unregister(i, 0, 0);
  45. else if (!hwif->hold)
  46. ide_init_port_data(hwif, i);
  47. ide_init_port_hw(hwif, &hw);
  48. hwif->quirkproc = NULL;
  49. idx[0] = i;
  50. ide_device_add(idx, NULL);
  51. out:
  52. return 0;
  53. }
  54. static int __init bastide_init(void)
  55. {
  56. /* we can treat the VR1000 and the BAST the same */
  57. if (!(machine_is_bast() || machine_is_vr1000()))
  58. return 0;
  59. printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n");
  60. bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0, &ifs[0]);
  61. bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1, &ifs[1]);
  62. return 0;
  63. }
  64. module_init(bastide_init);
  65. MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
  66. MODULE_LICENSE("GPL");
  67. MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");