dataMonitoring.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * arch/arm/mach-ks8695/pci.c
  3. *
  4. * Copyright (C) 2003, Micrel Semiconductors
  5. * Copyright (C) 2006, Greg Ungerer <gerg@snapgear.com>
  6. * Copyright (C) 2006, Ben Dooks
  7. * Copyright (C) 2007, Andrew Victor
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/pci.h>
  25. #include <linux/mm.h>
  26. #include <linux/init.h>
  27. #include <linux/irq.h>
  28. #include <linux/delay.h>
  29. #include <linux/io.h>
  30. #include <asm/signal.h>
  31. #include <asm/mach/pci.h>
  32. #include <mach/hardware.h>
  33. #include <mach/devices.h>
  34. #include <mach/regs-pci.h>
  35. static int pci_dbg;
  36. static int pci_cfg_dbg;
  37. static void ks8695_pci_setupconfig(unsigned int bus_nr, unsigned int devfn, unsigned int where)
  38. {
  39. unsigned long pbca;
  40. pbca = PBCA_ENABLE | (where & ~3);
  41. pbca |= PCI_SLOT(devfn) << 11 ;
  42. pbca |= PCI_FUNC(devfn) << 8;
  43. pbca |= bus_nr << 16;
  44. if (bus_nr == 0) {
  45. /* use Type-0 transaction */
  46. __raw_writel(pbca, KS8695_PCI_VA + KS8695_PBCA);
  47. } else {
  48. /* use Type-1 transaction */
  49. __raw_writel(pbca | PBCA_TYPE1, KS8695_PCI_VA + KS8695_PBCA);
  50. }
  51. }
  52. /*
  53. * The KS8695 datasheet prohibits anything other than 32bit accesses
  54. * to the IO registers, so all our configuration must be done with
  55. * 32bit operations, and the correct bit masking and shifting.
  56. */
  57. static int ks8695_pci_readconfig(struct pci_bus *bus,
  58. unsigned int devfn, int where, int size, u32 *value)
  59. {
  60. ks8695_pci_setupconfig(bus->number, devfn, where);
  61. *value = __raw_readl(KS8695_PCI_VA + KS8695_PBCD);
  62. switch (size) {
  63. case 4:
  64. break;
  65. case 2:
  66. *value = *value >> ((where & 2) * 8);
  67. *value &= 0xffff;
  68. break;
  69. case 1:
  70. *value = *value >> ((where & 3) * 8);
  71. *value &= 0xff;
  72. break;
  73. }
  74. if (pci_cfg_dbg) {
  75. printk("read: %d,%08x,%02x,%d: %08x (%08x)\n",
  76. bus->number, devfn, where, size, *value,
  77. __raw_readl(KS8695_PCI_VA + KS8695_PBCD));
  78. }
  79. return PCIBIOS_SUCCESSFUL;
  80. }
  81. static int ks8695_pci_writeconfig(struct pci_bus *bus,
  82. unsigned int devfn, int where, int size, u32 value)
  83. {
  84. unsigned long tmp;
  85. if (pci_cfg_dbg) {
  86. printk("write: %d,%08x,%02x,%d: %08x\n",
  87. bus->number, devfn, where, size, value);
  88. }
  89. ks8695_pci_setupconfig(bus->number, devfn, where);
  90. switch (size) {
  91. case 4:
  92. __raw_writel(value, KS8695_PCI_VA + KS8695_PBCD);
  93. break;