bast-ide.c 1.8 KB

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