platform.h 3.7 KB

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