ibm_ocp.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * ibm_ocp.h
  3. *
  4. * (c) Benjamin Herrenschmidt (benh@kernel.crashing.org)
  5. * Mipsys - France
  6. *
  7. * Derived from work (c) Armin Kuster akuster@pacbell.net
  8. *
  9. * Additional support and port to 2.6 LDM/sysfs by
  10. * Matt Porter <mporter@kernel.crashing.org>
  11. * Copyright 2003-2004 MontaVista Software, Inc.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. */
  19. #ifdef __KERNEL__
  20. #ifndef __IBM_OCP_H__
  21. #define __IBM_OCP_H__
  22. #include <asm/types.h>
  23. /*
  24. * IBM 4xx OCP system information
  25. */
  26. struct ocp_sys_info_data {
  27. int opb_bus_freq; /* OPB Bus Frequency (Hz) */
  28. int ebc_bus_freq; /* EBC Bus Frequency (Hz) */
  29. };
  30. extern struct ocp_sys_info_data ocp_sys_info;
  31. /*
  32. * EMAC additional data and sysfs support
  33. *
  34. * Note about mdio_idx: When you have a zmii, it's usually
  35. * not necessary, it covers the case of the 405EP which has
  36. * the MDIO lines on EMAC0 only
  37. *
  38. * Note about phy_map: Per EMAC map of PHY ids which should
  39. * be probed by emac_probe. Different EMACs can have
  40. * overlapping maps.
  41. *
  42. * Note, this map uses inverse logic for bits:
  43. * 0 - id should be probed
  44. * 1 - id should be ignored
  45. *
  46. * Default value of 0x00000000 - will result in usual
  47. * auto-detection logic.
  48. *
  49. */
  50. struct ocp_func_emac_data {
  51. int rgmii_idx; /* RGMII device index or -1 */
  52. int rgmii_mux; /* RGMII input of this EMAC */
  53. int zmii_idx; /* ZMII device index or -1 */
  54. int zmii_mux; /* ZMII input of this EMAC */
  55. int mal_idx; /* MAL device index */
  56. int mal_rx_chan; /* MAL rx channel number */
  57. int mal_tx_chan; /* MAL tx channel number */
  58. int wol_irq; /* WOL interrupt */
  59. int mdio_idx; /* EMAC idx of MDIO master or -1 */
  60. int tah_idx; /* TAH device index or -1 */
  61. int jumbo; /* Jumbo frames capable flag */
  62. int phy_mode; /* PHY type or configurable mode */
  63. u8 mac_addr[6]; /* EMAC mac address */
  64. u32 phy_map; /* EMAC phy map */
  65. u32 phy_feat_exc; /* Excluded PHY features */
  66. };
  67. /* Sysfs support */
  68. #define OCP_SYSFS_EMAC_DATA() \
  69. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, rgmii_idx) \
  70. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, rgmii_mux) \
  71. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_idx) \
  72. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_mux) \
  73. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_idx) \
  74. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_rx_chan) \
  75. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_tx_chan) \
  76. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, wol_irq) \
  77. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mdio_idx) \
  78. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, tah_idx) \
  79. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, phy_mode) \
  80. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "0x%08x\n", emac, phy_map) \
  81. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "0x%08x\n", emac, phy_feat_exc)\
  82. \
  83. void ocp_show_emac_data(struct device *dev) \
  84. { \
  85. device_create_file(dev, &dev_attr_emac_rgmii_idx); \
  86. device_create_file(dev, &dev_attr_emac_rgmii_mux); \
  87. device_create_file(dev, &dev_attr_emac_zmii_idx); \
  88. device_create_file(dev, &dev_attr_emac_zmii_mux); \
  89. device_create_file(dev, &dev_attr_emac_mal_idx); \
  90. device_create_file(dev, &dev_attr_emac_mal_rx_chan); \
  91. device_create_file(dev, &dev_attr_emac_mal_tx_chan); \
  92. device_create_file(dev, &dev_attr_emac_wol_irq); \
  93. device_create_file(dev, &dev_attr_emac_mdio_idx); \
  94. device_create_file(dev, &dev_attr_emac_tah_idx); \
  95. device_create_file(dev, &dev_attr_emac_phy_mode); \
  96. device_create_file(dev, &dev_attr_emac_phy_map); \
  97. device_create_file(dev, &dev_attr_emac_phy_feat_exc); \
  98. }
  99. /*
  100. * PHY mode settings (EMAC <-> ZMII/RGMII bridge <-> PHY)
  101. */
  102. #define PHY_MODE_NA 0
  103. #define PHY_MODE_MII 1
  104. #define PHY_MODE_RMII 2
  105. #define PHY_MODE_SMII 3
  106. #define PHY_MODE_RGMII 4
  107. #define PHY_MODE_TBI 5
  108. #define PHY_MODE_GMII 6
  109. #define PHY_MODE_RTBI 7
  110. #define PHY_MODE_SGMII 8
  111. #ifdef CONFIG_40x
  112. /*
  113. * Helper function to copy MAC addresses from the bd_t to OCP EMAC
  114. * additions.
  115. *
  116. * The range of EMAC indices (inclusive) to be copied are the arguments.
  117. */
  118. static inline void ibm_ocp_set_emac(int start, int end)
  119. {
  120. int i;
  121. struct ocp_def *def;
  122. /* Copy MAC addresses to EMAC additions */
  123. for (i=start; i<=end; i++) {
  124. def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, i);
  125. memcpy(((struct ocp_func_emac_data *)def->additions)->mac_addr,
  126. &__res.bi_enetaddr[i],
  127. 6);
  128. }
  129. }
  130. #endif
  131. /*
  132. * MAL additional data and sysfs support
  133. */
  134. struct ocp_func_mal_data {
  135. int num_tx_chans; /* Number of TX channels */
  136. int num_rx_chans; /* Number of RX channels */
  137. int txeob_irq; /* TX End Of Buffer IRQ */
  138. int rxeob_irq; /* RX End Of Buffer IRQ */
  139. int txde_irq; /* TX Descriptor Error IRQ */
  140. int rxde_irq; /* RX Descriptor Error IRQ */
  141. int serr_irq; /* MAL System Error IRQ */
  142. int dcr_base; /* MALx_CFG DCR number */
  143. };
  144. #define OCP_SYSFS_MAL_DATA() \
  145. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, num_tx_chans) \
  146. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, num_rx_chans) \
  147. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txeob_irq) \
  148. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxeob_irq) \
  149. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txde_irq) \
  150. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxde_irq) \
  151. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, serr_irq) \
  152. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, dcr_base) \
  153. \
  154. void ocp_show_mal_data(struct device *dev) \
  155. { \
  156. device_create_file(dev, &dev_attr_mal_num_tx_chans); \
  157. device_create_file(dev, &dev_attr_mal_num_rx_chans); \
  158. device_create_file(dev, &dev_attr_mal_txeob_irq); \
  159. device_create_file(dev, &dev_attr_mal_rxeob_irq); \
  160. device_create_file(dev, &dev_attr_mal_txde_irq); \
  161. device_create_file(dev, &dev_attr_mal_rxde_irq); \
  162. device_create_file(dev, &dev_attr_mal_serr_irq); \
  163. device_create_file(dev, &dev_attr_mal_dcr_base); \
  164. }
  165. /*
  166. * IIC additional data and sysfs support
  167. */
  168. struct ocp_func_iic_data {
  169. int fast_mode; /* IIC fast mode enabled */
  170. };
  171. #define OCP_SYSFS_IIC_DATA() \
  172. OCP_SYSFS_ADDTL(struct ocp_func_iic_data, "%d\n", iic, fast_mode) \
  173. \
  174. void ocp_show_iic_data(struct device *dev) \
  175. { \
  176. device_create_file(dev, &dev_attr_iic_fast_mode); \
  177. }
  178. #endif /* __IBM_OCP_H__ */
  179. #endif /* __KERNEL__ */