0033-mpc85xx-gianfar-add-add-mtd-mac-address-support.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 30 Apr 2015 02:10:54 +0200
  3. Subject: mpc85xx: gianfar: add add mtd-mac-address support
  4. diff --git a/target/linux/mpc85xx/patches-3.10/101-NET-add-of_get_mac_address_mtd.patch b/target/linux/mpc85xx/patches-3.10/101-NET-add-of_get_mac_address_mtd.patch
  5. new file mode 100644
  6. index 0000000..cd88d2b
  7. --- /dev/null
  8. +++ b/target/linux/mpc85xx/patches-3.10/101-NET-add-of_get_mac_address_mtd.patch
  9. @@ -0,0 +1,76 @@
  10. +From 92f38460229a8816404408f036f0a374f1013d0e Mon Sep 17 00:00:00 2001
  11. +From: John Crispin <blogic@openwrt.org>
  12. +Date: Sun, 27 Jul 2014 09:40:01 +0100
  13. +Subject: NET: add of_get_mac_address_mtd()
  14. +
  15. +Many embedded devices have information such as mac addresses stored inside mtd
  16. +devices. This patch allows us to add a property inside a node describing a
  17. +network interface. The new property points at a mtd partition with an offset
  18. +where the mac address can be found.
  19. +
  20. +Signed-off-by: John Crispin <blogic@openwrt.org>
  21. +---
  22. + drivers/of/of_net.c | 37 +++++++++++++++++++++++++++++++++++++
  23. + include/linux/of_net.h | 1 +
  24. + 2 files changed, 38 insertions(+)
  25. +
  26. +--- a/drivers/of/of_net.c
  27. ++++ b/drivers/of/of_net.c
  28. +@@ -10,6 +10,7 @@
  29. + #include <linux/of_net.h>
  30. + #include <linux/phy.h>
  31. + #include <linux/export.h>
  32. ++#include <linux/mtd/mtd.h>
  33. +
  34. + /**
  35. + * It maps 'enum phy_interface_t' found in include/linux/phy.h
  36. +@@ -92,3 +93,39 @@ const void *of_get_mac_address(struct de
  37. + return NULL;
  38. + }
  39. + EXPORT_SYMBOL(of_get_mac_address);
  40. ++
  41. ++int of_get_mac_address_mtd(struct device_node *np, void *mac)
  42. ++{
  43. ++ struct device_node *mtd_np = NULL;
  44. ++ size_t retlen;
  45. ++ int size, ret;
  46. ++ struct mtd_info *mtd;
  47. ++ const char *part;
  48. ++ const __be32 *list;
  49. ++ phandle phandle;
  50. ++
  51. ++ list = of_get_property(np, "mtd-mac-address", &size);
  52. ++ if (!list || (size != (2 * sizeof(*list))))
  53. ++ return -ENOENT;
  54. ++
  55. ++ phandle = be32_to_cpup(list++);
  56. ++ if (phandle)
  57. ++ mtd_np = of_find_node_by_phandle(phandle);
  58. ++
  59. ++ if (!mtd_np)
  60. ++ return -ENOENT;
  61. ++
  62. ++ part = of_get_property(mtd_np, "label", NULL);
  63. ++ if (!part)
  64. ++ part = mtd_np->name;
  65. ++
  66. ++ mtd = get_mtd_device_nm(part);
  67. ++ if (IS_ERR(mtd))
  68. ++ return PTR_ERR(mtd);
  69. ++
  70. ++ ret = mtd_read(mtd, be32_to_cpup(list), 6, &retlen, (u_char *) mac);
  71. ++ put_mtd_device(mtd);
  72. ++
  73. ++ return ret;
  74. ++}
  75. ++EXPORT_SYMBOL_GPL(of_get_mac_address_mtd);
  76. +--- a/include/linux/of_net.h
  77. ++++ b/include/linux/of_net.h
  78. +@@ -11,6 +11,7 @@
  79. + #include <linux/of.h>
  80. + extern const int of_get_phy_mode(struct device_node *np);
  81. + extern const void *of_get_mac_address(struct device_node *np);
  82. ++extern int of_get_mac_address_mtd(struct device_node *np, void *mac);
  83. + #else
  84. + static inline const int of_get_phy_mode(struct device_node *np)
  85. + {
  86. diff --git a/target/linux/mpc85xx/patches-3.10/201-net-gianfar-use-mtd-mac-address.patch b/target/linux/mpc85xx/patches-3.10/201-net-gianfar-use-mtd-mac-address.patch
  87. new file mode 100644
  88. index 0000000..1de4418
  89. --- /dev/null
  90. +++ b/target/linux/mpc85xx/patches-3.10/201-net-gianfar-use-mtd-mac-address.patch
  91. @@ -0,0 +1,19 @@
  92. +--- a/drivers/net/ethernet/freescale/gianfar.c
  93. ++++ b/drivers/net/ethernet/freescale/gianfar.c
  94. +@@ -741,10 +741,13 @@ static int gfar_of_init(struct platform_
  95. + if (stash_len || stash_idx)
  96. + priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
  97. +
  98. +- mac_addr = of_get_mac_address(np);
  99. ++ err = of_get_mac_address_mtd(np, dev->dev_addr);
  100. ++ if (err) {
  101. ++ mac_addr = of_get_mac_address(np);
  102. +
  103. +- if (mac_addr)
  104. +- memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
  105. ++ if (mac_addr)
  106. ++ memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
  107. ++ }
  108. +
  109. + if (model && !strcasecmp(model, "TSEC"))
  110. + priv->device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
  111. diff --git a/target/linux/mpc85xx/patches-3.10/220-fix_gianfar_reported_number_of_sent_bytes_to_BQL.patch b/target/linux/mpc85xx/patches-3.10/220-fix_gianfar_reported_number_of_sent_bytes_to_BQL.patch
  112. index d0380ff..0d510bc 100644
  113. --- a/target/linux/mpc85xx/patches-3.10/220-fix_gianfar_reported_number_of_sent_bytes_to_BQL.patch
  114. +++ b/target/linux/mpc85xx/patches-3.10/220-fix_gianfar_reported_number_of_sent_bytes_to_BQL.patch
  115. @@ -1,6 +1,6 @@
  116. --- a/drivers/net/ethernet/freescale/gianfar.c
  117. +++ b/drivers/net/ethernet/freescale/gianfar.c
  118. -@@ -2064,7 +2064,7 @@ static int gfar_start_xmit(struct sk_buf
  119. +@@ -2067,7 +2067,7 @@ static int gfar_start_xmit(struct sk_buf
  120. int i, rq = 0, do_tstamp = 0;
  121. u32 bufaddr;
  122. unsigned long flags;
  123. @@ -9,7 +9,7 @@
  124. /* TOE=1 frames larger than 2500 bytes may see excess delays
  125. * before start of transmission.
  126. -@@ -2130,7 +2130,10 @@ static int gfar_start_xmit(struct sk_buf
  127. +@@ -2133,7 +2133,10 @@ static int gfar_start_xmit(struct sk_buf
  128. }
  129. /* Update transmit stats */
  130. @@ -21,7 +21,7 @@
  131. tx_queue->stats.tx_packets++;
  132. txbdp = txbdp_start = tx_queue->cur_tx;
  133. -@@ -2150,12 +2153,13 @@ static int gfar_start_xmit(struct sk_buf
  134. +@@ -2153,12 +2156,13 @@ static int gfar_start_xmit(struct sk_buf
  135. } else {
  136. /* Place the fragment addresses and lengths into the TxBDs */
  137. for (i = 0; i < nr_frags; i++) {
  138. @@ -37,7 +37,7 @@
  139. BD_LFLAG(TXBD_READY);
  140. /* Handle the last BD specially */
  141. -@@ -2165,7 +2169,7 @@ static int gfar_start_xmit(struct sk_buf
  142. +@@ -2168,7 +2172,7 @@ static int gfar_start_xmit(struct sk_buf
  143. bufaddr = skb_frag_dma_map(priv->dev,
  144. &skb_shinfo(skb)->frags[i],
  145. 0,
  146. @@ -46,7 +46,7 @@
  147. DMA_TO_DEVICE);
  148. /* set the TxBD length and buffer pointer */
  149. -@@ -2231,7 +2235,7 @@ static int gfar_start_xmit(struct sk_buf
  150. +@@ -2234,7 +2238,7 @@ static int gfar_start_xmit(struct sk_buf
  151. lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);
  152. }
  153. @@ -55,7 +55,7 @@
  154. /* We can work in parallel with gfar_clean_tx_ring(), except
  155. * when modifying num_txbdfree. Note that we didn't grab the lock
  156. -@@ -2551,7 +2555,7 @@ static void gfar_clean_tx_ring(struct gf
  157. +@@ -2554,7 +2558,7 @@ static void gfar_clean_tx_ring(struct gf
  158. bdp = next_txbd(bdp, base, tx_ring_size);
  159. }