203-net-igb-add-phy-read-write-functions-that-accept-phy.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. From 16df7dc5901c1cb2a40f6adbd0d9423768ed8210 Mon Sep 17 00:00:00 2001
  2. From: Tim Harvey <tharvey@gateworks.com>
  3. Date: Thu, 15 May 2014 00:29:18 -0700
  4. Subject: [PATCH] net: igb: add phy read/write functions that accept phy addr
  5. Add igb_write_reg_gs40g/igb_read_reg_gs40g that can be passed a phy address.
  6. The existing igb_write_phy_reg_gs40g/igb_read_phy_reg_gs40g become wrappers
  7. to this function.
  8. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
  9. ---
  10. drivers/net/ethernet/intel/igb/e1000_82575.c | 4 +-
  11. drivers/net/ethernet/intel/igb/e1000_phy.c | 74 +++++++++++++++++++---------
  12. drivers/net/ethernet/intel/igb/e1000_phy.h | 6 ++-
  13. 3 files changed, 58 insertions(+), 26 deletions(-)
  14. --- a/drivers/net/ethernet/intel/igb/e1000_82575.c
  15. +++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
  16. @@ -2154,7 +2154,7 @@ static s32 igb_read_phy_reg_82580(struct
  17. if (ret_val)
  18. goto out;
  19. - ret_val = igb_read_phy_reg_mdic(hw, offset, data);
  20. + ret_val = igb_read_phy_reg_mdic(hw, hw->phy.addr, offset, data);
  21. hw->phy.ops.release(hw);
  22. @@ -2179,7 +2179,7 @@ static s32 igb_write_phy_reg_82580(struc
  23. if (ret_val)
  24. goto out;
  25. - ret_val = igb_write_phy_reg_mdic(hw, offset, data);
  26. + ret_val = igb_write_phy_reg_mdic(hw, hw->phy.addr, offset, data);
  27. hw->phy.ops.release(hw);
  28. --- a/drivers/net/ethernet/intel/igb/e1000_phy.c
  29. +++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
  30. @@ -130,9 +130,8 @@ out:
  31. * Reads the MDI control regsiter in the PHY at offset and stores the
  32. * information read to data.
  33. **/
  34. -s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
  35. +s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u8 addr, u32 offset, u16 *data)
  36. {
  37. - struct e1000_phy_info *phy = &hw->phy;
  38. u32 i, mdicnfg, mdic = 0;
  39. s32 ret_val = 0;
  40. @@ -151,14 +150,14 @@ s32 igb_read_phy_reg_mdic(struct e1000_h
  41. case e1000_i211:
  42. mdicnfg = rd32(E1000_MDICNFG);
  43. mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
  44. - mdicnfg |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
  45. + mdicnfg |= (addr << E1000_MDICNFG_PHY_SHIFT);
  46. wr32(E1000_MDICNFG, mdicnfg);
  47. mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  48. (E1000_MDIC_OP_READ));
  49. break;
  50. default:
  51. mdic = ((offset << E1000_MDIC_REG_SHIFT) |
  52. - (phy->addr << E1000_MDIC_PHY_SHIFT) |
  53. + (addr << E1000_MDIC_PHY_SHIFT) |
  54. (E1000_MDIC_OP_READ));
  55. break;
  56. }
  57. @@ -212,9 +211,8 @@ out:
  58. *
  59. * Writes data to MDI control register in the PHY at offset.
  60. **/
  61. -s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
  62. +s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u8 addr, u32 offset, u16 data)
  63. {
  64. - struct e1000_phy_info *phy = &hw->phy;
  65. u32 i, mdicnfg, mdic = 0;
  66. s32 ret_val = 0;
  67. @@ -233,7 +231,7 @@ s32 igb_write_phy_reg_mdic(struct e1000_
  68. case e1000_i211:
  69. mdicnfg = rd32(E1000_MDICNFG);
  70. mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
  71. - mdicnfg |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
  72. + mdicnfg |= (addr << E1000_MDICNFG_PHY_SHIFT);
  73. wr32(E1000_MDICNFG, mdicnfg);
  74. mdic = (((u32)data) |
  75. (offset << E1000_MDIC_REG_SHIFT) |
  76. @@ -242,7 +240,7 @@ s32 igb_write_phy_reg_mdic(struct e1000_
  77. default:
  78. mdic = (((u32)data) |
  79. (offset << E1000_MDIC_REG_SHIFT) |
  80. - (phy->addr << E1000_MDIC_PHY_SHIFT) |
  81. + (addr << E1000_MDIC_PHY_SHIFT) |
  82. (E1000_MDIC_OP_WRITE));
  83. break;
  84. }
  85. @@ -462,7 +460,7 @@ s32 igb_read_phy_reg_igp(struct e1000_hw
  86. goto out;
  87. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  88. - ret_val = igb_write_phy_reg_mdic(hw,
  89. + ret_val = igb_write_phy_reg_mdic(hw, hw->phy.addr,
  90. IGP01E1000_PHY_PAGE_SELECT,
  91. (u16)offset);
  92. if (ret_val) {
  93. @@ -471,8 +469,8 @@ s32 igb_read_phy_reg_igp(struct e1000_hw
  94. }
  95. }
  96. - ret_val = igb_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  97. - data);
  98. + ret_val = igb_read_phy_reg_mdic(hw, hw->phy.addr,
  99. + MAX_PHY_REG_ADDRESS & offset, data);
  100. hw->phy.ops.release(hw);
  101. @@ -501,7 +499,7 @@ s32 igb_write_phy_reg_igp(struct e1000_h
  102. goto out;
  103. if (offset > MAX_PHY_MULTI_PAGE_REG) {
  104. - ret_val = igb_write_phy_reg_mdic(hw,
  105. + ret_val = igb_write_phy_reg_mdic(hw, hw->phy.addr,
  106. IGP01E1000_PHY_PAGE_SELECT,
  107. (u16)offset);
  108. if (ret_val) {
  109. @@ -510,8 +508,8 @@ s32 igb_write_phy_reg_igp(struct e1000_h
  110. }
  111. }
  112. - ret_val = igb_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
  113. - data);
  114. + ret_val = igb_write_phy_reg_mdic(hw, hw->phy.addr,
  115. + MAX_PHY_REG_ADDRESS & offset, data);
  116. hw->phy.ops.release(hw);
  117. @@ -2551,8 +2549,9 @@ out:
  118. }
  119. /**
  120. - * igb_write_phy_reg_gs40g - Write GS40G PHY register
  121. + * igb_write_reg_gs40g - Write GS40G PHY register
  122. * @hw: pointer to the HW structure
  123. + * @addr: phy address to write to
  124. * @offset: lower half is register offset to write to
  125. * upper half is page to use.
  126. * @data: data to write at register offset
  127. @@ -2560,7 +2559,7 @@ out:
  128. * Acquires semaphore, if necessary, then writes the data to PHY register
  129. * at the offset. Release any acquired semaphores before exiting.
  130. **/
  131. -s32 igb_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data)
  132. +s32 igb_write_reg_gs40g(struct e1000_hw *hw, u8 addr, u32 offset, u16 data)
  133. {
  134. s32 ret_val;
  135. u16 page = offset >> GS40G_PAGE_SHIFT;
  136. @@ -2570,10 +2569,10 @@ s32 igb_write_phy_reg_gs40g(struct e1000
  137. if (ret_val)
  138. return ret_val;
  139. - ret_val = igb_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, page);
  140. + ret_val = igb_write_phy_reg_mdic(hw, addr, GS40G_PAGE_SELECT, page);
  141. if (ret_val)
  142. goto release;
  143. - ret_val = igb_write_phy_reg_mdic(hw, offset, data);
  144. + ret_val = igb_write_phy_reg_mdic(hw, addr, offset, data);
  145. release:
  146. hw->phy.ops.release(hw);
  147. @@ -2581,8 +2580,24 @@ release:
  148. }
  149. /**
  150. - * igb_read_phy_reg_gs40g - Read GS40G PHY register
  151. + * igb_write_phy_reg_gs40g - Write GS40G PHY register
  152. + * @hw: pointer to the HW structure
  153. + * @offset: lower half is register offset to write to
  154. + * upper half is page to use.
  155. + * @data: data to write at register offset
  156. + *
  157. + * Acquires semaphore, if necessary, then writes the data to PHY register
  158. + * at the offset. Release any acquired semaphores before exiting.
  159. + **/
  160. +s32 igb_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data)
  161. +{
  162. + return igb_write_reg_gs40g(hw, hw->phy.addr, offset, data);
  163. +}
  164. +
  165. +/**
  166. + * igb_read_reg_gs40g - Read GS40G PHY register
  167. * @hw: pointer to the HW structure
  168. + * @addr: phy address to read from
  169. * @offset: lower half is register offset to read to
  170. * upper half is page to use.
  171. * @data: data to read at register offset
  172. @@ -2590,7 +2605,7 @@ release:
  173. * Acquires semaphore, if necessary, then reads the data in the PHY register
  174. * at the offset. Release any acquired semaphores before exiting.
  175. **/
  176. -s32 igb_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data)
  177. +s32 igb_read_reg_gs40g(struct e1000_hw *hw, u8 addr, u32 offset, u16 *data)
  178. {
  179. s32 ret_val;
  180. u16 page = offset >> GS40G_PAGE_SHIFT;
  181. @@ -2600,10 +2615,10 @@ s32 igb_read_phy_reg_gs40g(struct e1000_
  182. if (ret_val)
  183. return ret_val;
  184. - ret_val = igb_write_phy_reg_mdic(hw, GS40G_PAGE_SELECT, page);
  185. + ret_val = igb_write_phy_reg_mdic(hw, addr, GS40G_PAGE_SELECT, page);
  186. if (ret_val)
  187. goto release;
  188. - ret_val = igb_read_phy_reg_mdic(hw, offset, data);
  189. + ret_val = igb_read_phy_reg_mdic(hw, addr, offset, data);
  190. release:
  191. hw->phy.ops.release(hw);
  192. @@ -2611,6 +2626,21 @@ release:
  193. }
  194. /**
  195. + * igb_read_phy_reg_gs40g - Read GS40G PHY register
  196. + * @hw: pointer to the HW structure
  197. + * @offset: lower half is register offset to read to
  198. + * upper half is page to use.
  199. + * @data: data to read at register offset
  200. + *
  201. + * Acquires semaphore, if necessary, then reads the data in the PHY register
  202. + * at the offset. Release any acquired semaphores before exiting.
  203. + **/
  204. +s32 igb_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data)
  205. +{
  206. + return igb_read_reg_gs40g(hw, hw->phy.addr, offset, data);
  207. +}
  208. +
  209. +/**
  210. * igb_set_master_slave_mode - Setup PHY for Master/slave mode
  211. * @hw: pointer to the HW structure
  212. *
  213. --- a/drivers/net/ethernet/intel/igb/e1000_phy.h
  214. +++ b/drivers/net/ethernet/intel/igb/e1000_phy.h
  215. @@ -62,8 +62,8 @@ void igb_power_up_phy_copper(struct e100
  216. void igb_power_down_phy_copper(struct e1000_hw *hw);
  217. s32 igb_phy_init_script_igp3(struct e1000_hw *hw);
  218. s32 igb_initialize_M88E1512_phy(struct e1000_hw *hw);
  219. -s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data);
  220. -s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data);
  221. +s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u8 addr, u32 offset, u16 *data);
  222. +s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u8 addr, u32 offset, u16 data);
  223. s32 igb_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data);
  224. s32 igb_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data);
  225. s32 igb_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data);
  226. @@ -73,6 +73,8 @@ s32 igb_phy_force_speed_duplex_82580(st
  227. s32 igb_get_cable_length_82580(struct e1000_hw *hw);
  228. s32 igb_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data);
  229. s32 igb_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data);
  230. +s32 igb_read_reg_gs40g(struct e1000_hw *hw, u8 addr, u32 offset, u16 *data);
  231. +s32 igb_write_reg_gs40g(struct e1000_hw *hw, u8 addr, u32 offset, u16 data);
  232. s32 igb_check_polarity_m88(struct e1000_hw *hw);
  233. /* IGP01E1000 Specific Registers */