iomap.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * linux/arch/unicore32/mm/iomap.c
  3. *
  4. * Code specific to PKUnity SoC and UniCore ISA
  5. *
  6. * Copyright (C) 2001-2010 GUAN Xue-tao
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Map IO port and PCI memory spaces so that {read,write}[bwl] can
  13. * be used to access this memory.
  14. */
  15. #include <linux/module.h>
  16. #include <linux/pci.h>
  17. #include <linux/ioport.h>
  18. #include <linux/io.h>
  19. #ifdef __io
  20. void __iomem *ioport_map(unsigned long port, unsigned int nr)
  21. {
  22. /* we map PC lagcy 64K IO port to PCI IO space 0x80030000 */
  23. return (void __iomem *) (unsigned long)
  24. io_p2v((port & 0xffff) + PKUNITY_PCILIO_BASE);
  25. }
  26. EXPORT_SYMBOL(ioport_map);
  27. void ioport_unmap(void __iomem *addr)
  28. {
  29. }
  30. EXPORT_SYMBOL(ioport_unmap);
  31. #endif
  32. #ifdef CONFIG_PCI
  33. void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
  34. {
  35. resource_size_t start = pci_resource_start(dev, bar);
  36. resource_size_t len = pci_resource_len(dev, bar);
  37. unsigned long flags = pci_resource_flags(dev, bar);
  38. if (!len || !start)
  39. return NULL;
  40. if (maxlen && len > maxlen)
  41. len = maxlen;
  42. if (flags & IORESOURCE_IO)
  43. return ioport_map(start, len);
  44. if (flags & IORESOURCE_MEM) {
  45. if (flags & IORESOURCE_CACHEABLE)
  46. return ioremap(start, len);
  47. return ioremap_nocache(start, len);
  48. }
  49. return NULL;
  50. }
  51. EXPORT_SYMBOL(pci_iomap);
  52. #endif