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. /*
  16. * The IXP2400 B0 silicon contains an erratum (#66) that causes writes
  17. * to on-chip I/O register to not complete fully. What this means is
  18. * that if you have a write to on-chip I/O followed by a back-to-back
  19. * read or write, the first write will happen twice. OR...if it's
  20. * not a back-to-back transaction, the read or write will generate
  21. * incorrect data.
  22. *
  23. * The official work around for this is to set the on-chip I/O regions
  24. * as XCB=101 and then force a read-back from the register.
  25. *
  26. */
  27. #if defined(CONFIG_ARCH_ENP2611) || defined(CONFIG_ARCH_IXDP2400) || defined(CONFIG_ARCH_IXDP2401)
  28. #include <asm/system.h> /* Pickup local_irq_ functions */
  29. static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)
  30. {
  31. unsigned long dummy;
  32. unsigned long flags;
  33. local_irq_save(flags);
  34. *((volatile unsigned long *)reg) = val;
  35. barrier();
  36. dummy = *((volatile unsigned long *)reg);
  37. local_irq_restore(flags);
  38. }
  39. #else
  40. static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)
  41. {
  42. *((volatile unsigned long *)reg) = val;
  43. }
  44. #endif /* IXDP2400 || IXDP2401 */
  45. #define ixp2000_reg_read(reg) (*((volatile unsigned long *)reg))
  46. /*
  47. * Boards may multiplex different devices on the 2nd channel of
  48. * the slowport interface that each need different configuration
  49. * settings. For example, the IXDP2400 uses channel 2 on the interface
  50. * to access the CPLD, the switch fabric card, and the media card. Each
  51. * one needs a different mode so drivers must save/restore the mode
  52. * before and after each operation.
  53. *
  54. * acquire_slowport(&your_config);
  55. * ...
  56. * do slowport operations
  57. * ...
  58. * release_slowport();
  59. *
  60. * Note that while you have the slowport, you are holding a spinlock,
  61. * so your code should be written as if you explicitly acquired a lock.
  62. *
  63. * The configuration only affects device 2 on the slowport, so the
  64. * MTD map driver does not acquire/release the slowport.
  65. */
  66. struct slowport_cfg {
  67. unsigned long CCR; /* Clock divide */
  68. unsigned long WTC; /* Write Timing Control */
  69. unsigned long RTC; /* Read Timing Control */
  70. unsigned long PCR; /* Protocol Control Register */
  71. unsigned long ADC; /* Address/Data Width Control */
  72. };
  73. void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
  74. void ixp2000_release_slowport(struct slowport_cfg *);
  75. /*
  76. * IXP2400 A0/A1 and IXP2800 A0/A1/A2 have broken slowport that requires
  77. * tweaking of addresses in the MTD driver.
  78. */
  79. static inline unsigned ixp2000_has_broken_slowport(void)
  80. {
  81. unsigned long id = *IXP2000_PRODUCT_ID;
  82. unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK |
  83. IXP2000_MIN_PROD_TYPE_MASK);
  84. return (((id_prod ==
  85. /* fixed in IXP2400-B0 */
  86. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  87. IXP2000_MIN_PROD_TYPE_IXP2400)) &&
  88. ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
  89. ((id_prod ==
  90. /* fixed in IXP2800-B0 */
  91. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  92. IXP2000_MIN_PROD_TYPE_IXP2800)) &&
  93. ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
  94. ((id_prod ==
  95. /* fixed in IXP2850-B0 */
  96. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  97. IXP2000_MIN_PROD_TYPE_IXP2850)) &&
  98. ((id & IXP2000_MAJ_REV_MASK) == 0)));
  99. }
  100. static inline unsigned int ixp2000_has_flash(void)
  101. {
  102. return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
  103. }
  104. static inline unsigned int ixp2000_is_pcimaster(void)
  105. {
  106. return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
  107. }
  108. void ixp2000_map_io(void);
  109. void ixp2000_uart_init(void);
  110. void ixp2000_init_irq(void);
  111. void ixp2000_init_time(unsigned long);
  112. unsigned long ixp2000_gettimeoffset(void);
  113. struct pci_sys_data;
  114. u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);
  115. void ixp2000_pci_preinit(void);
  116. int ixp2000_pci_setup(int, struct pci_sys_data*);
  117. struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
  118. int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
  119. int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
  120. /*
  121. * Several of the IXP2000 systems have banked flash so we need to extend the
  122. * flash_platform_data structure with some private pointers
  123. */
  124. struct ixp2000_flash_data {
  125. struct flash_platform_data *platform_data;
  126. int nr_banks;
  127. unsigned long (*bank_setup)(unsigned long);
  128. };
  129. struct ixp2000_i2c_pins {
  130. unsigned long sda_pin;
  131. unsigned long scl_pin;
  132. };
  133. #endif /* !__ASSEMBLY__ */