platform.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * include/asm-arm/arch-ixp2000/platform.h
  3. *
  4. * Various bits of code used by platform-level code.
  5. *
  6. * Author: Deepak Saxena <dsaxena@plexity.net>
  7. *
  8. * Copyright 2004 (c) MontaVista Software, Inc.
  9. *
  10. * This file is licensed under the terms of the GNU General Public
  11. * License version 2. This program is licensed "as is" without any
  12. * warranty of any kind, whether express or implied.
  13. */
  14. #ifndef __ASSEMBLY__
  15. static inline unsigned long ixp2000_reg_read(volatile void *reg)
  16. {
  17. return *((volatile unsigned long *)reg);
  18. }
  19. static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)
  20. {
  21. *((volatile unsigned long *)reg) = val;
  22. }
  23. /*
  24. * On the IXP2400, we can't use XCB=000 due to chip bugs. We use
  25. * XCB=101 instead, but that makes all I/O accesses bufferable. This
  26. * is not a problem in general, but we do have to be slightly more
  27. * careful because I/O writes are no longer automatically flushed out
  28. * of the write buffer.
  29. *
  30. * In cases where we want to make sure that a write has been flushed
  31. * out of the write buffer before we proceed, for example when masking
  32. * a device interrupt before re-enabling IRQs in CPSR, we can use this
  33. * function, ixp2000_reg_wrb, which performs a write, a readback, and
  34. * issues a dummy instruction dependent on the value of the readback
  35. * (mov rX, rX) to make sure that the readback has completed before we
  36. * continue.
  37. */
  38. static inline void ixp2000_reg_wrb(volatile void *reg, unsigned long val)
  39. {
  40. unsigned long dummy;
  41. *((volatile unsigned long *)reg) = val;
  42. dummy = *((volatile unsigned long *)reg);
  43. __asm__ __volatile__("mov %0, %0" : "+r" (dummy));
  44. }
  45. /*
  46. * Boards may multiplex different devices on the 2nd channel of
  47. * the slowport interface that each need different configuration
  48. * settings. For example, the IXDP2400 uses channel 2 on the interface
  49. * to access the CPLD, the switch fabric card, and the media card. Each
  50. * one needs a different mode so drivers must save/restore the mode
  51. * before and after each operation.
  52. *
  53. * acquire_slowport(&your_config);
  54. * ...
  55. * do slowport operations
  56. * ...
  57. * release_slowport();
  58. *
  59. * Note that while you have the slowport, you are holding a spinlock,
  60. * so your code should be written as if you explicitly acquired a lock.
  61. *
  62. * The configuration only affects device 2 on the slowport, so the
  63. * MTD map driver does not acquire/release the slowport.
  64. */
  65. struct slowport_cfg {
  66. unsigned long CCR; /* Clock divide */
  67. unsigned long WTC; /* Write Timing Control */
  68. unsigned long RTC; /* Read Timing Control */
  69. unsigned long PCR; /* Protocol Control Register */
  70. unsigned long ADC; /* Address/Data Width Control */
  71. };
  72. void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
  73. void ixp2000_release_slowport(struct slowport_cfg *);
  74. /*
  75. * IXP2400 A0/A1 and IXP2800 A0/A1/A2 have broken slowport that requires
  76. * tweaking of addresses in the MTD driver.
  77. */
  78. static inline unsigned ixp2000_has_broken_slowport(void)
  79. {
  80. unsigned long id = *IXP2000_PRODUCT_ID;
  81. unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK |
  82. IXP2000_MIN_PROD_TYPE_MASK);
  83. return (((id_prod ==
  84. /* fixed in IXP2400-B0 */
  85. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  86. IXP2000_MIN_PROD_TYPE_IXP2400)) &&
  87. ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
  88. ((id_prod ==
  89. /* fixed in IXP2800-B0 */
  90. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  91. IXP2000_MIN_PROD_TYPE_IXP2800)) &&
  92. ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
  93. ((id_prod ==
  94. /* fixed in IXP2850-B0 */
  95. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  96. IXP2000_MIN_PROD_TYPE_IXP2850)) &&
  97. ((id & IXP2000_MAJ_REV_MASK) == 0)));
  98. }
  99. static inline unsigned int ixp2000_has_flash(void)
  100. {
  101. return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
  102. }
  103. static inline unsigned int ixp2000_is_pcimaster(void)
  104. {
  105. return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
  106. }
  107. void ixp2000_map_io(void);
  108. void ixp2000_uart_init(void);
  109. void ixp2000_init_irq(void);
  110. void ixp2000_init_time(unsigned long);
  111. unsigned long ixp2000_gettimeoffset(void);
  112. struct pci_sys_data;
  113. u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);
  114. void ixp2000_pci_preinit(void);
  115. int ixp2000_pci_setup(int, struct pci_sys_data*);
  116. struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
  117. int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
  118. int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
  119. /*
  120. * Several of the IXP2000 systems have banked flash so we need to extend the
  121. * flash_platform_data structure with some private pointers
  122. */
  123. struct ixp2000_flash_data {
  124. struct flash_platform_data *platform_data;
  125. int nr_banks;
  126. unsigned long (*bank_setup)(unsigned long);
  127. };
  128. struct ixp2000_i2c_pins {
  129. unsigned long sda_pin;
  130. unsigned long scl_pin;
  131. };
  132. #endif /* !__ASSEMBLY__ */