platform.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * include/asm-arm/arch-ixp4xx/platform.h
  3. *
  4. * Constants and functions that are useful to IXP4xx platform-specific code
  5. * and device drivers.
  6. *
  7. * Copyright (C) 2004 MontaVista Software, Inc.
  8. */
  9. #ifndef __ASM_ARCH_HARDWARE_H__
  10. #error "Do not include this directly, instead #include <asm/hardware.h>"
  11. #endif
  12. #ifndef __ASSEMBLY__
  13. #include <asm/types.h>
  14. #ifndef __ARMEB__
  15. #define REG_OFFSET 0
  16. #else
  17. #define REG_OFFSET 3
  18. #endif
  19. /*
  20. * Expansion bus memory regions
  21. */
  22. #define IXP4XX_EXP_BUS_BASE_PHYS (0x50000000)
  23. /*
  24. * The expansion bus on the IXP4xx can be configured for either 16 or
  25. * 32MB windows and the CS offset for each region changes based on the
  26. * current configuration. This means that we cannot simply hardcode
  27. * each offset. ixp4xx_sys_init() looks at the expansion bus configuration
  28. * as setup by the bootloader to determine our window size.
  29. */
  30. extern unsigned long ixp4xx_exp_bus_size;
  31. #define IXP4XX_EXP_BUS_BASE(region)\
  32. (IXP4XX_EXP_BUS_BASE_PHYS + ((region) * ixp4xx_exp_bus_size))
  33. #define IXP4XX_EXP_BUS_END(region)\
  34. (IXP4XX_EXP_BUS_BASE(region) + ixp4xx_exp_bus_size - 1)
  35. /* Those macros can be used to adjust timing and configure
  36. * other features for each region.
  37. */
  38. #define IXP4XX_EXP_BUS_RECOVERY_T(x) (((x) & 0x0f) << 16)
  39. #define IXP4XX_EXP_BUS_HOLD_T(x) (((x) & 0x03) << 20)
  40. #define IXP4XX_EXP_BUS_STROBE_T(x) (((x) & 0x0f) << 22)
  41. #define IXP4XX_EXP_BUS_SETUP_T(x) (((x) & 0x03) << 26)
  42. #define IXP4XX_EXP_BUS_ADDR_T(x) (((x) & 0x03) << 28)
  43. #define IXP4XX_EXP_BUS_SIZE(x) (((x) & 0x0f) << 10)
  44. #define IXP4XX_EXP_BUS_CYCLES(x) (((x) & 0x03) << 14)
  45. #define IXP4XX_EXP_BUS_CS_EN (1L << 31)
  46. #define IXP4XX_EXP_BUS_BYTE_RD16 (1L << 6)
  47. #define IXP4XX_EXP_BUS_HRDY_POL (1L << 5)
  48. #define IXP4XX_EXP_BUS_MUX_EN (1L << 4)
  49. #define IXP4XX_EXP_BUS_SPLT_EN (1L << 3)
  50. #define IXP4XX_EXP_BUS_WR_EN (1L << 1)
  51. #define IXP4XX_EXP_BUS_BYTE_EN (1L << 0)
  52. #define IXP4XX_EXP_BUS_CYCLES_INTEL 0x00
  53. #define IXP4XX_EXP_BUS_CYCLES_MOTOROLA 0x01
  54. #define IXP4XX_EXP_BUS_CYCLES_HPI 0x02
  55. #define IXP4XX_FLASH_WRITABLE (0x2)
  56. #define IXP4XX_FLASH_DEFAULT (0xbcd23c40)
  57. #define IXP4XX_FLASH_WRITE (0xbcd23c42)
  58. /*
  59. * Clock Speed Definitions.
  60. */
  61. #define IXP4XX_PERIPHERAL_BUS_CLOCK (66) /* 66Mhzi APB BUS */
  62. #define IXP4XX_UART_XTAL 14745600
  63. /*
  64. * The IXP4xx chips do not have an I2C unit, so GPIO lines are just
  65. * used to
  66. * Used as platform_data to provide GPIO pin information to the ixp42x
  67. * I2C driver.
  68. */
  69. struct ixp4xx_i2c_pins {
  70. unsigned long sda_pin;
  71. unsigned long scl_pin;
  72. };
  73. struct sys_timer;
  74. /*
  75. * Frequency of clock used for primary clocksource
  76. */
  77. extern unsigned long ixp4xx_timer_freq;
  78. /*
  79. * Functions used by platform-level setup code
  80. */
  81. extern void ixp4xx_map_io(void);
  82. extern void ixp4xx_init_irq(void);
  83. extern void ixp4xx_sys_init(void);
  84. extern struct sys_timer ixp4xx_timer;
  85. extern void ixp4xx_pci_preinit(void);
  86. struct pci_sys_data;
  87. extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
  88. extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
  89. /*
  90. * GPIO-functions
  91. */
  92. /*
  93. * The following converted to the real HW bits the gpio_line_config
  94. */
  95. /* GPIO pin types */
  96. #define IXP4XX_GPIO_OUT 0x1
  97. #define IXP4XX_GPIO_IN 0x2
  98. /* GPIO signal types */
  99. #define IXP4XX_GPIO_LOW 0
  100. #define IXP4XX_GPIO_HIGH 1
  101. /* GPIO Clocks */
  102. #define IXP4XX_GPIO_CLK_0 14
  103. #define IXP4XX_GPIO_CLK_1 15
  104. static inline void gpio_line_config(u8 line, u32 direction)
  105. {
  106. if (direction == IXP4XX_GPIO_IN)
  107. *IXP4XX_GPIO_GPOER |= (1 << line);
  108. else
  109. *IXP4XX_GPIO_GPOER &= ~(1 << line);
  110. }
  111. static inline void gpio_line_get(u8 line, int *value)
  112. {
  113. *value = (*IXP4XX_GPIO_GPINR >> line) & 0x1;
  114. }
  115. static inline void gpio_line_set(u8 line, int value)
  116. {
  117. if (value == IXP4XX_GPIO_HIGH)
  118. *IXP4XX_GPIO_GPOUTR |= (1 << line);
  119. else if (value == IXP4XX_GPIO_LOW)
  120. *IXP4XX_GPIO_GPOUTR &= ~(1 << line);
  121. }
  122. #endif // __ASSEMBLY__