pci-sh7780.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Low-Level PCI Support for the SH7780
  3. *
  4. * Dustin McIntire (dustin@sensoria.com)
  5. * Derived from arch/i386/kernel/pci-*.c which bore the message:
  6. * (c) 1999--2000 Martin Mares <mj@ucw.cz>
  7. *
  8. * Ported to the new API by Paul Mundt <lethal@linux-sh.org>
  9. * With cleanup by Paul van Gool <pvangool@mimotech.com>
  10. *
  11. * May be copied or modified under the terms of the GNU General Public
  12. * License. See linux/COPYING for more information.
  13. *
  14. */
  15. #undef DEBUG
  16. #include <linux/types.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/pci.h>
  20. #include <linux/errno.h>
  21. #include <linux/delay.h>
  22. #include "pci-sh4.h"
  23. int __init sh7780_pci_init(struct pci_channel *chan)
  24. {
  25. unsigned int id;
  26. const char *type = NULL;
  27. int ret;
  28. printk(KERN_NOTICE "PCI: Starting intialization.\n");
  29. chan->reg_base = 0xfe040000;
  30. chan->io_base = 0xfe200000;
  31. /* Enable CPU access to the PCIC registers. */
  32. __raw_writel(PCIECR_ENBL, PCIECR);
  33. id = __raw_readw(chan->reg_base + SH7780_PCIVID);
  34. if (id != SH7780_VENDOR_ID) {
  35. printk(KERN_ERR "PCI: Unknown vendor ID 0x%04x.\n", id);
  36. return -ENODEV;
  37. }
  38. id = __raw_readw(chan->reg_base + SH7780_PCIDID);
  39. type = (id == SH7763_DEVICE_ID) ? "SH7763" :
  40. (id == SH7780_DEVICE_ID) ? "SH7780" :
  41. (id == SH7781_DEVICE_ID) ? "SH7781" :
  42. (id == SH7785_DEVICE_ID) ? "SH7785" :
  43. NULL;
  44. if (unlikely(!type)) {
  45. printk(KERN_ERR "PCI: Found an unsupported Renesas host "
  46. "controller, device id 0x%04x.\n", id);
  47. return -EINVAL;
  48. }
  49. printk(KERN_NOTICE "PCI: Found a Renesas %s host "
  50. "controller, revision %d.\n", type,
  51. __raw_readb(chan->reg_base + SH7780_PCIRID));
  52. if ((ret = sh4_pci_check_direct(chan)) != 0)
  53. return ret;
  54. /*
  55. * Platform specific initialization (BSC registers, and memory space
  56. * mapping) will be called via the platform defined function
  57. * pcibios_init_platform().
  58. */
  59. return pcibios_init_platform();
  60. }
  61. extern u8 pci_cache_line_size;
  62. int __init sh7780_pcic_init(struct pci_channel *chan,
  63. struct sh4_pci_address_map *map)
  64. {
  65. u32 word;
  66. /*
  67. * Set the class and sub-class codes.
  68. */
  69. __raw_writeb(PCI_CLASS_BRIDGE_HOST >> 8,
  70. chan->reg_base + SH7780_PCIBCC);
  71. __raw_writeb(PCI_CLASS_BRIDGE_HOST & 0xff,
  72. chan->reg_base + SH7780_PCISUB);
  73. pci_cache_line_size = pci_read_reg(chan, SH7780_PCICLS) / 4;
  74. /* set the command/status bits to:
  75. * Wait Cycle Control + Parity Enable + Bus Master +
  76. * Mem space enable
  77. */
  78. pci_write_reg(chan, 0x00000046, SH7780_PCICMD);
  79. /* Set IO and Mem windows to local address
  80. * Make PCI and local address the same for easy 1 to 1 mapping
  81. */
  82. pci_write_reg(chan, map->window0.size - 0xfffff, SH4_PCILSR0);
  83. pci_write_reg(chan, map->window1.size - 0xfffff, SH4_PCILSR1);
  84. /* Set the values on window 0 PCI config registers */
  85. pci_write_reg(chan, map->window0.base, SH4_PCILAR0);
  86. pci_write_reg(chan, map->window0.base, SH7780_PCIMBAR0);
  87. /* Set the values on window 1 PCI config registers */
  88. pci_write_reg(chan, map->window1.base, SH4_PCILAR1);
  89. pci_write_reg(chan, map->window1.base, SH7780_PCIMBAR1);
  90. /* Apply any last-minute PCIC fixups */
  91. pci_fixup_pcic(chan);
  92. /* SH7780 init done, set central function init complete */
  93. /* use round robin mode to stop a device starving/overruning */
  94. word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_FTO;
  95. pci_write_reg(chan, word, SH4_PCICR);
  96. return 0;
  97. }