blob: 8bdbddeec1174fa9b2c56640cd6a32a368113f6c [file] [log] [blame]
Thomas Gleixnercaab2772019-06-03 07:44:50 +02001// SPDX-License-Identifier: GPL-2.0-only
Dinh Nguyen801d2332014-03-26 22:45:10 -05002/* Copyright Altera Corporation (C) 2014. All rights reserved.
3 *
Dinh Nguyen801d2332014-03-26 22:45:10 -05004 * Adopted from dwmac-sti.c
5 */
6
Thor Thayer54a5afb2019-03-11 17:18:07 -05007#include <linux/mfd/altera-sysmgr.h>
Dinh Nguyen801d2332014-03-26 22:45:10 -05008#include <linux/of.h>
Ley Foon Tanb4834c82014-08-20 14:33:33 +08009#include <linux/of_address.h>
Dinh Nguyen801d2332014-03-26 22:45:10 -050010#include <linux/of_net.h>
11#include <linux/phy.h>
12#include <linux/regmap.h>
Vince Bridgers2d871aa2014-07-28 14:07:58 -050013#include <linux/reset.h>
Dinh Nguyen801d2332014-03-26 22:45:10 -050014#include <linux/stmmac.h>
Andy Shevchenkof10f9fb2014-11-07 16:46:42 +020015
Vince Bridgers2d871aa2014-07-28 14:07:58 -050016#include "stmmac.h"
Andy Shevchenkof10f9fb2014-11-07 16:46:42 +020017#include "stmmac_platform.h"
Dinh Nguyen801d2332014-03-26 22:45:10 -050018
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070019#include "altr_tse_pcs.h"
20
21#define SGMII_ADAPTER_CTRL_REG 0x00
22#define SGMII_ADAPTER_DISABLE 0x0001
23
Dinh Nguyen801d2332014-03-26 22:45:10 -050024#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII 0x0
25#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII 0x1
26#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII 0x2
27#define SYSMGR_EMACGRP_CTRL_PHYSEL_WIDTH 2
28#define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK 0x00000003
Phil Reid43569812015-12-14 11:32:02 +080029#define SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK 0x00000010
Dinh Nguyen801d2332014-03-26 22:45:10 -050030
Phil Reid734e00fa2016-04-07 15:55:35 +080031#define SYSMGR_FPGAGRP_MODULE_REG 0x00000028
32#define SYSMGR_FPGAGRP_MODULE_EMAC 0x00000004
33
Ley Foon Tanb4834c82014-08-20 14:33:33 +080034#define EMAC_SPLITTER_CTRL_REG 0x0
35#define EMAC_SPLITTER_CTRL_SPEED_MASK 0x3
36#define EMAC_SPLITTER_CTRL_SPEED_10 0x2
37#define EMAC_SPLITTER_CTRL_SPEED_100 0x3
38#define EMAC_SPLITTER_CTRL_SPEED_1000 0x0
39
Dinh Nguyen801d2332014-03-26 22:45:10 -050040struct socfpga_dwmac {
41 int interface;
42 u32 reg_offset;
43 u32 reg_shift;
44 struct device *dev;
45 struct regmap *sys_mgr_base_addr;
Joachim Eastwood70cb1362016-05-01 22:58:21 +020046 struct reset_control *stmmac_rst;
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -050047 struct reset_control *stmmac_ocp_rst;
Ley Foon Tanb4834c82014-08-20 14:33:33 +080048 void __iomem *splitter_base;
Phil Reid43569812015-12-14 11:32:02 +080049 bool f2h_ptp_ref_clk;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070050 struct tse_pcs pcs;
Dinh Nguyen801d2332014-03-26 22:45:10 -050051};
52
Ley Foon Tanb4834c82014-08-20 14:33:33 +080053static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)
54{
55 struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;
56 void __iomem *splitter_base = dwmac->splitter_base;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070057 void __iomem *tse_pcs_base = dwmac->pcs.tse_pcs_base;
58 void __iomem *sgmii_adapter_base = dwmac->pcs.sgmii_adapter_base;
59 struct device *dev = dwmac->dev;
60 struct net_device *ndev = dev_get_drvdata(dev);
61 struct phy_device *phy_dev = ndev->phydev;
Ley Foon Tanb4834c82014-08-20 14:33:33 +080062 u32 val;
63
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070064 if ((tse_pcs_base) && (sgmii_adapter_base))
65 writew(SGMII_ADAPTER_DISABLE,
66 sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
Ley Foon Tanb4834c82014-08-20 14:33:33 +080067
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070068 if (splitter_base) {
69 val = readl(splitter_base + EMAC_SPLITTER_CTRL_REG);
70 val &= ~EMAC_SPLITTER_CTRL_SPEED_MASK;
Ley Foon Tanb4834c82014-08-20 14:33:33 +080071
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070072 switch (speed) {
73 case 1000:
74 val |= EMAC_SPLITTER_CTRL_SPEED_1000;
75 break;
76 case 100:
77 val |= EMAC_SPLITTER_CTRL_SPEED_100;
78 break;
79 case 10:
80 val |= EMAC_SPLITTER_CTRL_SPEED_10;
81 break;
82 default:
83 return;
84 }
85 writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG);
Ley Foon Tanb4834c82014-08-20 14:33:33 +080086 }
87
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070088 if (tse_pcs_base && sgmii_adapter_base)
89 tse_pcs_fix_mac_speed(&dwmac->pcs, phy_dev, speed);
Ley Foon Tanb4834c82014-08-20 14:33:33 +080090}
91
Dinh Nguyen801d2332014-03-26 22:45:10 -050092static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *dev)
93{
94 struct device_node *np = dev->of_node;
95 struct regmap *sys_mgr_base_addr;
96 u32 reg_offset, reg_shift;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070097 int ret, index;
98 struct device_node *np_splitter = NULL;
99 struct device_node *np_sgmii_adapter = NULL;
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800100 struct resource res_splitter;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700101 struct resource res_tse_pcs;
102 struct resource res_sgmii_adapter;
Dinh Nguyen801d2332014-03-26 22:45:10 -0500103
104 dwmac->interface = of_get_phy_mode(np);
105
Thor Thayer54a5afb2019-03-11 17:18:07 -0500106 sys_mgr_base_addr =
107 altr_sysmgr_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon");
Dinh Nguyen801d2332014-03-26 22:45:10 -0500108 if (IS_ERR(sys_mgr_base_addr)) {
109 dev_info(dev, "No sysmgr-syscon node found\n");
110 return PTR_ERR(sys_mgr_base_addr);
111 }
112
113 ret = of_property_read_u32_index(np, "altr,sysmgr-syscon", 1, &reg_offset);
114 if (ret) {
115 dev_info(dev, "Could not read reg_offset from sysmgr-syscon!\n");
116 return -EINVAL;
117 }
118
119 ret = of_property_read_u32_index(np, "altr,sysmgr-syscon", 2, &reg_shift);
120 if (ret) {
121 dev_info(dev, "Could not read reg_shift from sysmgr-syscon!\n");
122 return -EINVAL;
123 }
124
Phil Reid43569812015-12-14 11:32:02 +0800125 dwmac->f2h_ptp_ref_clk = of_property_read_bool(np, "altr,f2h_ptp_ref_clk");
126
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800127 np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0);
128 if (np_splitter) {
Peter Chenf7113b32016-08-01 15:02:41 +0800129 ret = of_address_to_resource(np_splitter, 0, &res_splitter);
130 of_node_put(np_splitter);
131 if (ret) {
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800132 dev_info(dev, "Missing emac splitter address\n");
133 return -EINVAL;
134 }
135
Ley Foon Tandace1b52014-08-28 12:59:46 +0800136 dwmac->splitter_base = devm_ioremap_resource(dev, &res_splitter);
Wei Yongjunf19f9162014-09-12 07:12:57 +0800137 if (IS_ERR(dwmac->splitter_base)) {
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800138 dev_info(dev, "Failed to mapping emac splitter\n");
Wei Yongjunf19f9162014-09-12 07:12:57 +0800139 return PTR_ERR(dwmac->splitter_base);
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800140 }
141 }
142
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700143 np_sgmii_adapter = of_parse_phandle(np,
144 "altr,gmii-to-sgmii-converter", 0);
145 if (np_sgmii_adapter) {
146 index = of_property_match_string(np_sgmii_adapter, "reg-names",
147 "hps_emac_interface_splitter_avalon_slave");
148
149 if (index >= 0) {
150 if (of_address_to_resource(np_sgmii_adapter, index,
151 &res_splitter)) {
152 dev_err(dev,
153 "%s: ERROR: missing emac splitter address\n",
154 __func__);
Peter Chenf7113b32016-08-01 15:02:41 +0800155 ret = -EINVAL;
156 goto err_node_put;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700157 }
158
159 dwmac->splitter_base =
160 devm_ioremap_resource(dev, &res_splitter);
161
Peter Chenf7113b32016-08-01 15:02:41 +0800162 if (IS_ERR(dwmac->splitter_base)) {
163 ret = PTR_ERR(dwmac->splitter_base);
164 goto err_node_put;
165 }
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700166 }
167
168 index = of_property_match_string(np_sgmii_adapter, "reg-names",
169 "gmii_to_sgmii_adapter_avalon_slave");
170
171 if (index >= 0) {
172 if (of_address_to_resource(np_sgmii_adapter, index,
173 &res_sgmii_adapter)) {
174 dev_err(dev,
175 "%s: ERROR: failed mapping adapter\n",
176 __func__);
Peter Chenf7113b32016-08-01 15:02:41 +0800177 ret = -EINVAL;
178 goto err_node_put;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700179 }
180
181 dwmac->pcs.sgmii_adapter_base =
182 devm_ioremap_resource(dev, &res_sgmii_adapter);
183
Peter Chenf7113b32016-08-01 15:02:41 +0800184 if (IS_ERR(dwmac->pcs.sgmii_adapter_base)) {
185 ret = PTR_ERR(dwmac->pcs.sgmii_adapter_base);
186 goto err_node_put;
187 }
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700188 }
189
190 index = of_property_match_string(np_sgmii_adapter, "reg-names",
191 "eth_tse_control_port");
192
193 if (index >= 0) {
194 if (of_address_to_resource(np_sgmii_adapter, index,
195 &res_tse_pcs)) {
196 dev_err(dev,
197 "%s: ERROR: failed mapping tse control port\n",
198 __func__);
Peter Chenf7113b32016-08-01 15:02:41 +0800199 ret = -EINVAL;
200 goto err_node_put;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700201 }
202
203 dwmac->pcs.tse_pcs_base =
204 devm_ioremap_resource(dev, &res_tse_pcs);
205
Peter Chenf7113b32016-08-01 15:02:41 +0800206 if (IS_ERR(dwmac->pcs.tse_pcs_base)) {
207 ret = PTR_ERR(dwmac->pcs.tse_pcs_base);
208 goto err_node_put;
209 }
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700210 }
211 }
Dinh Nguyen801d2332014-03-26 22:45:10 -0500212 dwmac->reg_offset = reg_offset;
213 dwmac->reg_shift = reg_shift;
214 dwmac->sys_mgr_base_addr = sys_mgr_base_addr;
215 dwmac->dev = dev;
Peter Chenf7113b32016-08-01 15:02:41 +0800216 of_node_put(np_sgmii_adapter);
Dinh Nguyen801d2332014-03-26 22:45:10 -0500217
218 return 0;
Peter Chenf7113b32016-08-01 15:02:41 +0800219
220err_node_put:
221 of_node_put(np_sgmii_adapter);
222 return ret;
Dinh Nguyen801d2332014-03-26 22:45:10 -0500223}
224
Joachim Eastwood0f400a82016-05-01 22:58:23 +0200225static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
Dinh Nguyen801d2332014-03-26 22:45:10 -0500226{
227 struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr;
228 int phymode = dwmac->interface;
229 u32 reg_offset = dwmac->reg_offset;
230 u32 reg_shift = dwmac->reg_shift;
Phil Reid734e00fa2016-04-07 15:55:35 +0800231 u32 ctrl, val, module;
Dinh Nguyen801d2332014-03-26 22:45:10 -0500232
233 switch (phymode) {
234 case PHY_INTERFACE_MODE_RGMII:
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800235 case PHY_INTERFACE_MODE_RGMII_ID:
Dinh Nguyen801d2332014-03-26 22:45:10 -0500236 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
237 break;
238 case PHY_INTERFACE_MODE_MII:
239 case PHY_INTERFACE_MODE_GMII:
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700240 case PHY_INTERFACE_MODE_SGMII:
Dinh Nguyen801d2332014-03-26 22:45:10 -0500241 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
242 break;
243 default:
244 dev_err(dwmac->dev, "bad phy mode %d\n", phymode);
245 return -EINVAL;
246 }
247
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800248 /* Overwrite val to GMII if splitter core is enabled. The phymode here
249 * is the actual phy mode on phy hardware, but phy interface from
250 * EMAC core is GMII.
251 */
252 if (dwmac->splitter_base)
253 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
254
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200255 /* Assert reset to the enet controller before changing the phy mode */
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -0500256 reset_control_assert(dwmac->stmmac_ocp_rst);
257 reset_control_assert(dwmac->stmmac_rst);
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200258
Dinh Nguyen801d2332014-03-26 22:45:10 -0500259 regmap_read(sys_mgr_base_addr, reg_offset, &ctrl);
260 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
261 ctrl |= val << reg_shift;
262
Stephan Gatzka013dae52017-08-22 14:25:07 +0200263 if (dwmac->f2h_ptp_ref_clk ||
264 phymode == PHY_INTERFACE_MODE_MII ||
265 phymode == PHY_INTERFACE_MODE_GMII ||
266 phymode == PHY_INTERFACE_MODE_SGMII) {
Phil Reid43569812015-12-14 11:32:02 +0800267 ctrl |= SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2);
Phil Reid734e00fa2016-04-07 15:55:35 +0800268 regmap_read(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG,
269 &module);
270 module |= (SYSMGR_FPGAGRP_MODULE_EMAC << (reg_shift / 2));
271 regmap_write(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG,
272 module);
273 } else {
Phil Reid43569812015-12-14 11:32:02 +0800274 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2));
Phil Reid734e00fa2016-04-07 15:55:35 +0800275 }
Phil Reid43569812015-12-14 11:32:02 +0800276
Dinh Nguyen801d2332014-03-26 22:45:10 -0500277 regmap_write(sys_mgr_base_addr, reg_offset, ctrl);
Phil Reid734e00fa2016-04-07 15:55:35 +0800278
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200279 /* Deassert reset for the phy configuration to be sampled by
280 * the enet controller, and operation to start in requested mode
281 */
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -0500282 reset_control_deassert(dwmac->stmmac_ocp_rst);
283 reset_control_deassert(dwmac->stmmac_rst);
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700284 if (phymode == PHY_INTERFACE_MODE_SGMII) {
285 if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) {
286 dev_err(dwmac->dev, "Unable to initialize TSE PCS");
287 return -EINVAL;
288 }
289 }
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200290
Dinh Nguyen801d2332014-03-26 22:45:10 -0500291 return 0;
292}
293
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200294static int socfpga_dwmac_probe(struct platform_device *pdev)
Joachim Eastwood82732782015-07-29 00:08:51 +0200295{
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200296 struct plat_stmmacenet_data *plat_dat;
297 struct stmmac_resources stmmac_res;
Joachim Eastwood82732782015-07-29 00:08:51 +0200298 struct device *dev = &pdev->dev;
299 int ret;
300 struct socfpga_dwmac *dwmac;
Johan Hovold50ac64c2016-11-30 15:29:49 +0100301 struct net_device *ndev;
302 struct stmmac_priv *stpriv;
Joachim Eastwood82732782015-07-29 00:08:51 +0200303
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200304 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
305 if (ret)
306 return ret;
307
308 plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
309 if (IS_ERR(plat_dat))
310 return PTR_ERR(plat_dat);
311
Joachim Eastwood82732782015-07-29 00:08:51 +0200312 dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100313 if (!dwmac) {
314 ret = -ENOMEM;
315 goto err_remove_config_dt;
316 }
Joachim Eastwood82732782015-07-29 00:08:51 +0200317
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -0500318 dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
319 if (IS_ERR(dwmac->stmmac_ocp_rst)) {
320 ret = PTR_ERR(dwmac->stmmac_ocp_rst);
321 dev_err(dev, "error getting reset control of ocp %d\n", ret);
322 goto err_remove_config_dt;
323 }
324
325 reset_control_deassert(dwmac->stmmac_ocp_rst);
326
Joachim Eastwood82732782015-07-29 00:08:51 +0200327 ret = socfpga_dwmac_parse_data(dwmac, dev);
328 if (ret) {
329 dev_err(dev, "Unable to parse OF data\n");
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100330 goto err_remove_config_dt;
Joachim Eastwood82732782015-07-29 00:08:51 +0200331 }
332
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200333 plat_dat->bsp_priv = dwmac;
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200334 plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed;
335
Marek Vasut3c201b52016-04-21 14:11:50 +0200336 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
Johan Hovold50ac64c2016-11-30 15:29:49 +0100337 if (ret)
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100338 goto err_remove_config_dt;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700339
Johan Hovold50ac64c2016-11-30 15:29:49 +0100340 ndev = platform_get_drvdata(pdev);
341 stpriv = netdev_priv(ndev);
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200342
Johan Hovold50ac64c2016-11-30 15:29:49 +0100343 /* The socfpga driver needs to control the stmmac reset to set the phy
344 * mode. Create a copy of the core reset handle so it can be used by
345 * the driver later.
346 */
jpintof573c0b2017-01-09 12:35:09 +0000347 dwmac->stmmac_rst = stpriv->plat->stmmac_rst;
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200348
Johan Hovold50ac64c2016-11-30 15:29:49 +0100349 ret = socfpga_dwmac_set_phy_mode(dwmac);
350 if (ret)
351 goto err_dvr_remove;
352
353 return 0;
354
355err_dvr_remove:
356 stmmac_dvr_remove(&pdev->dev);
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100357err_remove_config_dt:
358 stmmac_remove_config_dt(pdev, plat_dat);
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200359
Marek Vasut3c201b52016-04-21 14:11:50 +0200360 return ret;
Joachim Eastwood82732782015-07-29 00:08:51 +0200361}
362
Joachim Eastwood56868de2016-05-01 22:58:20 +0200363#ifdef CONFIG_PM_SLEEP
364static int socfpga_dwmac_resume(struct device *dev)
365{
Joachim Eastwood56868de2016-05-01 22:58:20 +0200366 struct net_device *ndev = dev_get_drvdata(dev);
367 struct stmmac_priv *priv = netdev_priv(ndev);
368
Joachim Eastwood0f400a82016-05-01 22:58:23 +0200369 socfpga_dwmac_set_phy_mode(priv->plat->bsp_priv);
Joachim Eastwood56868de2016-05-01 22:58:20 +0200370
Joachim Eastwood53737242016-05-01 22:58:22 +0200371 /* Before the enet controller is suspended, the phy is suspended.
372 * This causes the phy clock to be gated. The enet controller is
373 * resumed before the phy, so the clock is still gated "off" when
374 * the enet controller is resumed. This code makes sure the phy
375 * is "resumed" before reinitializing the enet controller since
376 * the enet controller depends on an active phy clock to complete
377 * a DMA reset. A DMA reset will "time out" if executed
378 * with no phy clock input on the Synopsys enet controller.
379 * Verified through Synopsys Case #8000711656.
380 *
381 * Note that the phy clock is also gated when the phy is isolated.
382 * Phy "suspend" and "isolate" controls are located in phy basic
383 * control register 0, and can be modified by the phy driver
384 * framework.
385 */
Philippe Reynesd6d50c72016-10-03 08:28:19 +0200386 if (ndev->phydev)
387 phy_resume(ndev->phydev);
Joachim Eastwood53737242016-05-01 22:58:22 +0200388
Joachim Eastwood56868de2016-05-01 22:58:20 +0200389 return stmmac_resume(dev);
390}
391#endif /* CONFIG_PM_SLEEP */
392
Joachim Eastwoodbfca2eb2016-05-08 13:47:23 +0200393static SIMPLE_DEV_PM_OPS(socfpga_dwmac_pm_ops, stmmac_suspend,
394 socfpga_dwmac_resume);
Joachim Eastwood56868de2016-05-01 22:58:20 +0200395
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200396static const struct of_device_id socfpga_dwmac_match[] = {
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200397 { .compatible = "altr,socfpga-stmmac" },
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200398 { }
399};
400MODULE_DEVICE_TABLE(of, socfpga_dwmac_match);
401
402static struct platform_driver socfpga_dwmac_driver = {
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200403 .probe = socfpga_dwmac_probe,
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200404 .remove = stmmac_pltfr_remove,
405 .driver = {
406 .name = "socfpga-dwmac",
Joachim Eastwood56868de2016-05-01 22:58:20 +0200407 .pm = &socfpga_dwmac_pm_ops,
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200408 .of_match_table = socfpga_dwmac_match,
409 },
410};
411module_platform_driver(socfpga_dwmac_driver);
412
413MODULE_LICENSE("GPL v2");