pci-emma2rh.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) NEC Electronics Corporation 2004-2006
  3. *
  4. * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
  5. *
  6. * Copyright 2001 MontaVista Software Inc.
  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 as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/types.h>
  25. #include <linux/pci.h>
  26. #include <asm/bootinfo.h>
  27. #include <asm/emma/emma2rh.h>
  28. static struct resource pci_io_resource = {
  29. .name = "pci IO space",
  30. .start = EMMA2RH_PCI_IO_BASE,
  31. .end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1,
  32. .flags = IORESOURCE_IO,
  33. };
  34. static struct resource pci_mem_resource = {
  35. .name = "pci memory space",
  36. .start = EMMA2RH_PCI_MEM_BASE,
  37. .end = EMMA2RH_PCI_MEM_BASE + EMMA2RH_PCI_MEM_SIZE - 1,
  38. .flags = IORESOURCE_MEM,
  39. };
  40. extern struct pci_ops emma2rh_pci_ops;
  41. static struct pci_controller emma2rh_pci_controller = {
  42. .pci_ops = &emma2rh_pci_ops,
  43. .mem_resource = &pci_mem_resource,
  44. .io_resource = &pci_io_resource,
  45. .mem_offset = -0x04000000,
  46. .io_offset = 0,
  47. };
  48. static void __init emma2rh_pci_init(void)
  49. {
  50. /* setup PCI interface */
  51. emma2rh_out32(EMMA2RH_PCI_ARBIT_CTR, 0x70f);
  52. emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, 0x80000a18);
  53. emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE + PCI_COMMAND,
  54. PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_CAP_LIST |
  55. PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  56. emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE + PCI_BASE_ADDRESS_0, 0x10000000);
  57. emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE + PCI_BASE_ADDRESS_1, 0x00000000);
  58. emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR, 0x12000000 | 0x218);
  59. emma2rh_out32(EMMA2RH_PCI_IWIN1_CTR, 0x18000000 | 0x600);
  60. emma2rh_out32(EMMA2RH_PCI_INIT_ESWP, 0x00000200);
  61. emma2rh_out32(EMMA2RH_PCI_TWIN_CTR, 0x00009200);
  62. emma2rh_out32(EMMA2RH_PCI_TWIN_BADR, 0x00000000);
  63. emma2rh_out32(EMMA2RH_PCI_TWIN0_DADR, 0x00000000);
  64. emma2rh_out32(EMMA2RH_PCI_TWIN1_DADR, 0x00000000);
  65. }
  66. static int __init emma2rh_pci_setup(void)
  67. {
  68. emma2rh_pci_init();
  69. register_pci_controller(&emma2rh_pci_controller);
  70. return 0;
  71. }
  72. arch_initcall(emma2rh_pci_setup);