platform.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. * Boards may multiplex different devices on the 2nd channel of
  25. * the slowport interface that each need different configuration
  26. * settings. For example, the IXDP2400 uses channel 2 on the interface
  27. * to access the CPLD, the switch fabric card, and the media card. Each
  28. * one needs a different mode so drivers must save/restore the mode
  29. * before and after each operation.
  30. *
  31. * acquire_slowport(&your_config);
  32. * ...
  33. * do slowport operations
  34. * ...
  35. * release_slowport();
  36. *
  37. * Note that while you have the slowport, you are holding a spinlock,
  38. * so your code should be written as if you explicitly acquired a lock.
  39. *
  40. * The configuration only affects device 2 on the slowport, so the
  41. * MTD map driver does not acquire/release the slowport.
  42. */
  43. struct slowport_cfg {
  44. unsigned long CCR; /* Clock divide */
  45. unsigned long WTC; /* Write Timing Control */
  46. unsigned long RTC; /* Read Timing Control */
  47. unsigned long PCR; /* Protocol Control Register */
  48. unsigned long ADC; /* Address/Data Width Control */
  49. };
  50. void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
  51. void ixp2000_release_slowport(struct slowport_cfg *);
  52. /*
  53. * IXP2400 A0/A1 and IXP2800 A0/A1/A2 have broken slowport that requires
  54. * tweaking of addresses in the MTD driver.
  55. */
  56. static inline unsigned ixp2000_has_broken_slowport(void)
  57. {
  58. unsigned long id = *IXP2000_PRODUCT_ID;
  59. unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK |
  60. IXP2000_MIN_PROD_TYPE_MASK);
  61. return (((id_prod ==
  62. /* fixed in IXP2400-B0 */
  63. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  64. IXP2000_MIN_PROD_TYPE_IXP2400)) &&
  65. ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
  66. ((id_prod ==
  67. /* fixed in IXP2800-B0 */
  68. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  69. IXP2000_MIN_PROD_TYPE_IXP2800)) &&
  70. ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
  71. ((id_prod ==
  72. /* fixed in IXP2850-B0 */
  73. (IXP2000_MAJ_PROD_TYPE_IXP2000 |
  74. IXP2000_MIN_PROD_TYPE_IXP2850)) &&
  75. ((id & IXP2000_MAJ_REV_MASK) == 0)));
  76. }
  77. static inline unsigned int ixp2000_has_flash(void)
  78. {
  79. return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
  80. }
  81. static inline unsigned int ixp2000_is_pcimaster(void)
  82. {
  83. return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
  84. }
  85. void ixp2000_map_io(void);
  86. void ixp2000_uart_init(void);
  87. void ixp2000_init_irq(void);
  88. void ixp2000_init_time(unsigned long);
  89. unsigned long ixp2000_gettimeoffset(void);
  90. struct pci_sys_data;
  91. u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);
  92. void ixp2000_pci_preinit(void);
  93. int ixp2000_pci_setup(int, struct pci_sys_data*);
  94. struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
  95. int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
  96. int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
  97. /*
  98. * Several of the IXP2000 systems have banked flash so we need to extend the
  99. * flash_platform_data structure with some private pointers
  100. */
  101. struct ixp2000_flash_data {
  102. struct flash_platform_data *platform_data;
  103. int nr_banks;
  104. unsigned long (*bank_setup)(unsigned long);
  105. };
  106. struct ixp2000_i2c_pins {
  107. unsigned long sda_pin;
  108. unsigned long scl_pin;
  109. };
  110. #endif /* !__ASSEMBLY__ */