aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-04-01 14:38:59 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-01 14:38:59 -0400
commitce2a04c15f4b943015aab0c7476cb1460654e914 (patch)
tree160bc8bb98d4211393230dcfbc6440359c00ecd0
parentc66e98c9532bf7b58fe78cc59fb37d3ff651756d (diff)
parenta7657f128c279ae5796ab2ca7d04a7819f4259f0 (diff)
Merge branch 'stmmac-fixes'
Giuseppe Cavallaro says: ==================== stmmac MDIO and normal descr fixes This patch series is to fix the problems below and recently debugged in this mailing list: o to fix a problem for the HW where the normal descriptor o to fix the mdio registration according to the different platform configurations I am resending all the patches again: built on top of net.git repo. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/norm_desc.c16
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c16
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c10
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c91
-rw-r--r--include/linux/stmmac.h1
5 files changed, 80 insertions, 54 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
index e13228f115f0..011386f6f24d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
@@ -199,11 +199,6 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
199{ 199{
200 unsigned int tdes1 = p->des1; 200 unsigned int tdes1 = p->des1;
201 201
202 if (mode == STMMAC_CHAIN_MODE)
203 norm_set_tx_desc_len_on_chain(p, len);
204 else
205 norm_set_tx_desc_len_on_ring(p, len);
206
207 if (is_fs) 202 if (is_fs)
208 tdes1 |= TDES1_FIRST_SEGMENT; 203 tdes1 |= TDES1_FIRST_SEGMENT;
209 else 204 else
@@ -217,10 +212,15 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
217 if (ls) 212 if (ls)
218 tdes1 |= TDES1_LAST_SEGMENT; 213 tdes1 |= TDES1_LAST_SEGMENT;
219 214
220 if (tx_own)
221 tdes1 |= TDES0_OWN;
222
223 p->des1 = tdes1; 215 p->des1 = tdes1;
216
217 if (mode == STMMAC_CHAIN_MODE)
218 norm_set_tx_desc_len_on_chain(p, len);
219 else
220 norm_set_tx_desc_len_on_ring(p, len);
221
222 if (tx_own)
223 p->des0 |= TDES0_OWN;
224} 224}
225 225
226static void ndesc_set_tx_ic(struct dma_desc *p) 226static void ndesc_set_tx_ic(struct dma_desc *p)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 4c5ce9848ca9..78464fa7fe1f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -278,7 +278,6 @@ static void stmmac_eee_ctrl_timer(unsigned long arg)
278 */ 278 */
279bool stmmac_eee_init(struct stmmac_priv *priv) 279bool stmmac_eee_init(struct stmmac_priv *priv)
280{ 280{
281 char *phy_bus_name = priv->plat->phy_bus_name;
282 unsigned long flags; 281 unsigned long flags;
283 bool ret = false; 282 bool ret = false;
284 283
@@ -290,7 +289,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
290 goto out; 289 goto out;
291 290
292 /* Never init EEE in case of a switch is attached */ 291 /* Never init EEE in case of a switch is attached */
293 if (phy_bus_name && (!strcmp(phy_bus_name, "fixed"))) 292 if (priv->phydev->is_pseudo_fixed_link)
294 goto out; 293 goto out;
295 294
296 /* MAC core supports the EEE feature. */ 295 /* MAC core supports the EEE feature. */
@@ -827,12 +826,8 @@ static int stmmac_init_phy(struct net_device *dev)
827 phydev = of_phy_connect(dev, priv->plat->phy_node, 826 phydev = of_phy_connect(dev, priv->plat->phy_node,
828 &stmmac_adjust_link, 0, interface); 827 &stmmac_adjust_link, 0, interface);
829 } else { 828 } else {
830 if (priv->plat->phy_bus_name) 829 snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x",
831 snprintf(bus_id, MII_BUS_ID_SIZE, "%s-%x", 830 priv->plat->bus_id);
832 priv->plat->phy_bus_name, priv->plat->bus_id);
833 else
834 snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x",
835 priv->plat->bus_id);
836 831
837 snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id, 832 snprintf(phy_id_fmt, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id,
838 priv->plat->phy_addr); 833 priv->plat->phy_addr);
@@ -871,9 +866,8 @@ static int stmmac_init_phy(struct net_device *dev)
871 } 866 }
872 867
873 /* If attached to a switch, there is no reason to poll phy handler */ 868 /* If attached to a switch, there is no reason to poll phy handler */
874 if (priv->plat->phy_bus_name) 869 if (phydev->is_pseudo_fixed_link)
875 if (!strcmp(priv->plat->phy_bus_name, "fixed")) 870 phydev->irq = PHY_IGNORE_INTERRUPT;
876 phydev->irq = PHY_IGNORE_INTERRUPT;
877 871
878 pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" 872 pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)"
879 " Link = %d\n", dev->name, phydev->phy_id, phydev->link); 873 " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index ea76129dafc2..06704ca6f9ca 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -198,20 +198,12 @@ int stmmac_mdio_register(struct net_device *ndev)
198 struct mii_bus *new_bus; 198 struct mii_bus *new_bus;
199 struct stmmac_priv *priv = netdev_priv(ndev); 199 struct stmmac_priv *priv = netdev_priv(ndev);
200 struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; 200 struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
201 int addr, found;
202 struct device_node *mdio_node = priv->plat->mdio_node; 201 struct device_node *mdio_node = priv->plat->mdio_node;
202 int addr, found;
203 203
204 if (!mdio_bus_data) 204 if (!mdio_bus_data)
205 return 0; 205 return 0;
206 206
207 if (IS_ENABLED(CONFIG_OF)) {
208 if (mdio_node) {
209 netdev_dbg(ndev, "FOUND MDIO subnode\n");
210 } else {
211 netdev_warn(ndev, "No MDIO subnode found\n");
212 }
213 }
214
215 new_bus = mdiobus_alloc(); 207 new_bus = mdiobus_alloc();
216 if (new_bus == NULL) 208 if (new_bus == NULL)
217 return -ENOMEM; 209 return -ENOMEM;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index dcbd2a1601e8..cf37ea558ecc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -132,6 +132,69 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
132} 132}
133 133
134/** 134/**
135 * stmmac_dt_phy - parse device-tree driver parameters to allocate PHY resources
136 * @plat: driver data platform structure
137 * @np: device tree node
138 * @dev: device pointer
139 * Description:
140 * The mdio bus will be allocated in case of a phy transceiver is on board;
141 * it will be NULL if the fixed-link is configured.
142 * If there is the "snps,dwmac-mdio" sub-node the mdio will be allocated
143 * in any case (for DSA, mdio must be registered even if fixed-link).
144 * The table below sums the supported configurations:
145 * -------------------------------
146 * snps,phy-addr | Y
147 * -------------------------------
148 * phy-handle | Y
149 * -------------------------------
150 * fixed-link | N
151 * -------------------------------
152 * snps,dwmac-mdio |
153 * even if | Y
154 * fixed-link |
155 * -------------------------------
156 *
157 * It returns 0 in case of success otherwise -ENODEV.
158 */
159static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
160 struct device_node *np, struct device *dev)
161{
162 bool mdio = true;
163
164 /* If phy-handle property is passed from DT, use it as the PHY */
165 plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
166 if (plat->phy_node)
167 dev_dbg(dev, "Found phy-handle subnode\n");
168
169 /* If phy-handle is not specified, check if we have a fixed-phy */
170 if (!plat->phy_node && of_phy_is_fixed_link(np)) {
171 if ((of_phy_register_fixed_link(np) < 0))
172 return -ENODEV;
173
174 dev_dbg(dev, "Found fixed-link subnode\n");
175 plat->phy_node = of_node_get(np);
176 mdio = false;
177 }
178
179 /* If snps,dwmac-mdio is passed from DT, always register the MDIO */
180 for_each_child_of_node(np, plat->mdio_node) {
181 if (of_device_is_compatible(plat->mdio_node, "snps,dwmac-mdio"))
182 break;
183 }
184
185 if (plat->mdio_node) {
186 dev_dbg(dev, "Found MDIO subnode\n");
187 mdio = true;
188 }
189
190 if (mdio)
191 plat->mdio_bus_data =
192 devm_kzalloc(dev, sizeof(struct stmmac_mdio_bus_data),
193 GFP_KERNEL);
194 return 0;
195}
196
197/**
135 * stmmac_probe_config_dt - parse device-tree driver parameters 198 * stmmac_probe_config_dt - parse device-tree driver parameters
136 * @pdev: platform_device structure 199 * @pdev: platform_device structure
137 * @plat: driver data platform structure 200 * @plat: driver data platform structure
@@ -146,7 +209,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
146 struct device_node *np = pdev->dev.of_node; 209 struct device_node *np = pdev->dev.of_node;
147 struct plat_stmmacenet_data *plat; 210 struct plat_stmmacenet_data *plat;
148 struct stmmac_dma_cfg *dma_cfg; 211 struct stmmac_dma_cfg *dma_cfg;
149 struct device_node *child_node = NULL;
150 212
151 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); 213 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
152 if (!plat) 214 if (!plat)
@@ -166,36 +228,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
166 /* Default to phy auto-detection */ 228 /* Default to phy auto-detection */
167 plat->phy_addr = -1; 229 plat->phy_addr = -1;
168 230
169 /* If we find a phy-handle property, use it as the PHY */
170 plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
171
172 /* If phy-handle is not specified, check if we have a fixed-phy */
173 if (!plat->phy_node && of_phy_is_fixed_link(np)) {
174 if ((of_phy_register_fixed_link(np) < 0))
175 return ERR_PTR(-ENODEV);
176
177 plat->phy_node = of_node_get(np);
178 }
179
180 for_each_child_of_node(np, child_node)
181 if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) {
182 plat->mdio_node = child_node;
183 break;
184 }
185
186 /* "snps,phy-addr" is not a standard property. Mark it as deprecated 231 /* "snps,phy-addr" is not a standard property. Mark it as deprecated
187 * and warn of its use. Remove this when phy node support is added. 232 * and warn of its use. Remove this when phy node support is added.
188 */ 233 */
189 if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) 234 if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
190 dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); 235 dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
191 236
192 if ((plat->phy_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node) 237 /* To Configure PHY by using all device-tree supported properties */
193 plat->mdio_bus_data = NULL; 238 if (stmmac_dt_phy(plat, np, &pdev->dev))
194 else 239 return ERR_PTR(-ENODEV);
195 plat->mdio_bus_data =
196 devm_kzalloc(&pdev->dev,
197 sizeof(struct stmmac_mdio_bus_data),
198 GFP_KERNEL);
199 240
200 of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); 241 of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
201 242
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 4bcf5a61aada..e6bc30a42a74 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -108,7 +108,6 @@ struct stmmac_axi {
108}; 108};
109 109
110struct plat_stmmacenet_data { 110struct plat_stmmacenet_data {
111 char *phy_bus_name;
112 int bus_id; 111 int bus_id;
113 int phy_addr; 112 int phy_addr;
114 int interface; 113 int interface;