ibm_ocp.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. };
  66. /* Sysfs support */
  67. #define OCP_SYSFS_EMAC_DATA() \
  68. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_idx) \
  69. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, zmii_mux) \
  70. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_idx) \
  71. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_rx_chan) \
  72. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mal_tx_chan) \
  73. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, wol_irq) \
  74. OCP_SYSFS_ADDTL(struct ocp_func_emac_data, "%d\n", emac, mdio_idx) \
  75. \
  76. void ocp_show_emac_data(struct device *dev) \
  77. { \
  78. device_create_file(dev, &dev_attr_emac_zmii_idx); \
  79. device_create_file(dev, &dev_attr_emac_zmii_mux); \
  80. device_create_file(dev, &dev_attr_emac_mal_idx); \
  81. device_create_file(dev, &dev_attr_emac_mal_rx_chan); \
  82. device_create_file(dev, &dev_attr_emac_mal_tx_chan); \
  83. device_create_file(dev, &dev_attr_emac_wol_irq); \
  84. device_create_file(dev, &dev_attr_emac_mdio_idx); \
  85. }
  86. #ifdef CONFIG_40x
  87. /*
  88. * Helper function to copy MAC addresses from the bd_t to OCP EMAC
  89. * additions.
  90. *
  91. * The range of EMAC indices (inclusive) to be copied are the arguments.
  92. */
  93. static inline void ibm_ocp_set_emac(int start, int end)
  94. {
  95. int i;
  96. struct ocp_def *def;
  97. /* Copy MAC addresses to EMAC additions */
  98. for (i=start; i<=end; i++) {
  99. def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, i);
  100. memcpy(((struct ocp_func_emac_data *)def->additions)->mac_addr,
  101. &__res.bi_enetaddr[i],
  102. 6);
  103. }
  104. }
  105. #endif
  106. /*
  107. * MAL additional data and sysfs support
  108. */
  109. struct ocp_func_mal_data {
  110. int num_tx_chans; /* Number of TX channels */
  111. int num_rx_chans; /* Number of RX channels */
  112. int txeob_irq; /* TX End Of Buffer IRQ */
  113. int rxeob_irq; /* RX End Of Buffer IRQ */
  114. int txde_irq; /* TX Descriptor Error IRQ */
  115. int rxde_irq; /* RX Descriptor Error IRQ */
  116. int serr_irq; /* MAL System Error IRQ */
  117. };
  118. #define OCP_SYSFS_MAL_DATA() \
  119. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, num_tx_chans) \
  120. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, num_rx_chans) \
  121. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txeob_irq) \
  122. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxeob_irq) \
  123. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, txde_irq) \
  124. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, rxde_irq) \
  125. OCP_SYSFS_ADDTL(struct ocp_func_mal_data, "%d\n", mal, serr_irq) \
  126. \
  127. void ocp_show_mal_data(struct device *dev) \
  128. { \
  129. device_create_file(dev, &dev_attr_mal_num_tx_chans); \
  130. device_create_file(dev, &dev_attr_mal_num_rx_chans); \
  131. device_create_file(dev, &dev_attr_mal_txeob_irq); \
  132. device_create_file(dev, &dev_attr_mal_rxeob_irq); \
  133. device_create_file(dev, &dev_attr_mal_txde_irq); \
  134. device_create_file(dev, &dev_attr_mal_rxde_irq); \
  135. device_create_file(dev, &dev_attr_mal_serr_irq); \
  136. }
  137. /*
  138. * IIC additional data and sysfs support
  139. */
  140. struct ocp_func_iic_data {
  141. int fast_mode; /* IIC fast mode enabled */
  142. };
  143. #define OCP_SYSFS_IIC_DATA() \
  144. OCP_SYSFS_ADDTL(struct ocp_func_iic_data, "%d\n", iic, fast_mode) \
  145. \
  146. void ocp_show_iic_data(struct device *dev) \
  147. { \
  148. device_create_file(dev, &dev_attr_iic_fast_mode); \
  149. }
  150. #endif /* __IBM_OCP_H__ */
  151. #endif /* __KERNEL__ */