fs_enet_pd.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Platform information definitions for the
  3. * universal Freescale Ethernet driver.
  4. *
  5. * Copyright (c) 2003 Intracom S.A.
  6. * by Pantelis Antoniou <panto@intracom.gr>
  7. *
  8. * 2005 (c) MontaVista Software, Inc.
  9. * Vitaly Bordug <vbordug@ru.mvista.com>
  10. *
  11. * This file is licensed under the terms of the GNU General Public License
  12. * version 2. This program is licensed "as is" without any warranty of any
  13. * kind, whether express or implied.
  14. */
  15. #ifndef FS_ENET_PD_H
  16. #define FS_ENET_PD_H
  17. #include <linux/string.h>
  18. #include <linux/of_mdio.h>
  19. #include <asm/types.h>
  20. #define FS_ENET_NAME "fs_enet"
  21. enum fs_id {
  22. fsid_fec1,
  23. fsid_fec2,
  24. fsid_fcc1,
  25. fsid_fcc2,
  26. fsid_fcc3,
  27. fsid_scc1,
  28. fsid_scc2,
  29. fsid_scc3,
  30. fsid_scc4,
  31. };
  32. #define FS_MAX_INDEX 9
  33. static inline int fs_get_fec_index(enum fs_id id)
  34. {
  35. if (id >= fsid_fec1 && id <= fsid_fec2)
  36. return id - fsid_fec1;
  37. return -1;
  38. }
  39. static inline int fs_get_fcc_index(enum fs_id id)
  40. {
  41. if (id >= fsid_fcc1 && id <= fsid_fcc3)
  42. return id - fsid_fcc1;
  43. return -1;
  44. }
  45. static inline int fs_get_scc_index(enum fs_id id)
  46. {
  47. if (id >= fsid_scc1 && id <= fsid_scc4)
  48. return id - fsid_scc1;
  49. return -1;
  50. }
  51. static inline int fs_fec_index2id(int index)
  52. {
  53. int id = fsid_fec1 + index - 1;
  54. if (id >= fsid_fec1 && id <= fsid_fec2)
  55. return id;
  56. return FS_MAX_INDEX;
  57. }
  58. static inline int fs_fcc_index2id(int index)
  59. {
  60. int id = fsid_fcc1 + index - 1;
  61. if (id >= fsid_fcc1 && id <= fsid_fcc3)
  62. return id;
  63. return FS_MAX_INDEX;
  64. }
  65. static inline int fs_scc_index2id(int index)
  66. {
  67. int id = fsid_scc1 + index - 1;
  68. if (id >= fsid_scc1 && id <= fsid_scc4)
  69. return id;
  70. return FS_MAX_INDEX;
  71. }
  72. enum fs_mii_method {
  73. fsmii_fixed,
  74. fsmii_fec,
  75. fsmii_bitbang,
  76. };
  77. enum fs_ioport {
  78. fsiop_porta,
  79. fsiop_portb,
  80. fsiop_portc,
  81. fsiop_portd,
  82. fsiop_porte,
  83. };
  84. struct fs_mii_bit {
  85. u32 offset;
  86. u8 bit;
  87. u8 polarity;
  88. };
  89. struct fs_mii_bb_platform_info {
  90. struct fs_mii_bit mdio_dir;
  91. struct fs_mii_bit mdio_dat;
  92. struct fs_mii_bit mdc_dat;
  93. int delay; /* delay in us */
  94. int irq[32]; /* irqs per phy's */
  95. };
  96. struct fs_platform_info {
  97. void(*init_ioports)(struct fs_platform_info *);
  98. /* device specific information */
  99. int fs_no; /* controller index */
  100. char fs_type[4]; /* controller type */
  101. u32 cp_page; /* CPM page */
  102. u32 cp_block; /* CPM sblock */
  103. u32 cp_command; /* CPM page/sblock/mcn */
  104. u32 clk_trx; /* some stuff for pins & mux configuration*/
  105. u32 clk_rx;
  106. u32 clk_tx;
  107. u32 clk_route;
  108. u32 clk_mask;
  109. u32 mem_offset;
  110. u32 dpram_offset;
  111. u32 fcc_regs_c;
  112. u32 device_flags;
  113. struct device_node *phy_node;
  114. const struct fs_mii_bus_info *bus_info;
  115. int rx_ring, tx_ring; /* number of buffers on rx */
  116. __u8 macaddr[6]; /* mac address */
  117. int rx_copybreak; /* limit we copy small frames */
  118. int use_napi; /* use NAPI */
  119. int napi_weight; /* NAPI weight */
  120. int use_rmii; /* use RMII mode */
  121. int has_phy; /* if the network is phy container as well...*/
  122. };
  123. struct fs_mii_fec_platform_info {
  124. u32 irq[32];
  125. u32 mii_speed;
  126. };
  127. static inline int fs_get_id(struct fs_platform_info *fpi)
  128. {
  129. if(strstr(fpi->fs_type, "SCC"))
  130. return fs_scc_index2id(fpi->fs_no);
  131. if(strstr(fpi->fs_type, "FCC"))
  132. return fs_fcc_index2id(fpi->fs_no);
  133. if(strstr(fpi->fs_type, "FEC"))
  134. return fs_fec_index2id(fpi->fs_no);
  135. return fpi->fs_no;
  136. }
  137. #endif