blob: 5b3b06a0a3bf53e1eac9572ae8d14add0c3835e7 [file] [log] [blame]
Dinh Nguyen801d2332014-03-26 22:45:10 -05001/* Copyright Altera Corporation (C) 2014. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License, version 2,
5 * as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * Adopted from dwmac-sti.c
16 */
17
18#include <linux/mfd/syscon.h>
19#include <linux/of.h>
Ley Foon Tanb4834c82014-08-20 14:33:33 +080020#include <linux/of_address.h>
Dinh Nguyen801d2332014-03-26 22:45:10 -050021#include <linux/of_net.h>
22#include <linux/phy.h>
23#include <linux/regmap.h>
Vince Bridgers2d871aa2014-07-28 14:07:58 -050024#include <linux/reset.h>
Dinh Nguyen801d2332014-03-26 22:45:10 -050025#include <linux/stmmac.h>
Andy Shevchenkof10f9fb2014-11-07 16:46:42 +020026
Vince Bridgers2d871aa2014-07-28 14:07:58 -050027#include "stmmac.h"
Andy Shevchenkof10f9fb2014-11-07 16:46:42 +020028#include "stmmac_platform.h"
Dinh Nguyen801d2332014-03-26 22:45:10 -050029
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070030#include "altr_tse_pcs.h"
31
32#define SGMII_ADAPTER_CTRL_REG 0x00
33#define SGMII_ADAPTER_DISABLE 0x0001
34
Dinh Nguyen801d2332014-03-26 22:45:10 -050035#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII 0x0
36#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII 0x1
37#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII 0x2
38#define SYSMGR_EMACGRP_CTRL_PHYSEL_WIDTH 2
39#define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK 0x00000003
Phil Reid43569812015-12-14 11:32:02 +080040#define SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK 0x00000010
Dinh Nguyen801d2332014-03-26 22:45:10 -050041
Phil Reid734e00fa2016-04-07 15:55:35 +080042#define SYSMGR_FPGAGRP_MODULE_REG 0x00000028
43#define SYSMGR_FPGAGRP_MODULE_EMAC 0x00000004
44
Ley Foon Tanb4834c82014-08-20 14:33:33 +080045#define EMAC_SPLITTER_CTRL_REG 0x0
46#define EMAC_SPLITTER_CTRL_SPEED_MASK 0x3
47#define EMAC_SPLITTER_CTRL_SPEED_10 0x2
48#define EMAC_SPLITTER_CTRL_SPEED_100 0x3
49#define EMAC_SPLITTER_CTRL_SPEED_1000 0x0
50
Dinh Nguyen801d2332014-03-26 22:45:10 -050051struct socfpga_dwmac {
52 int interface;
53 u32 reg_offset;
54 u32 reg_shift;
55 struct device *dev;
56 struct regmap *sys_mgr_base_addr;
Joachim Eastwood70cb1362016-05-01 22:58:21 +020057 struct reset_control *stmmac_rst;
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -050058 struct reset_control *stmmac_ocp_rst;
Ley Foon Tanb4834c82014-08-20 14:33:33 +080059 void __iomem *splitter_base;
Phil Reid43569812015-12-14 11:32:02 +080060 bool f2h_ptp_ref_clk;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070061 struct tse_pcs pcs;
Dinh Nguyen801d2332014-03-26 22:45:10 -050062};
63
Ley Foon Tanb4834c82014-08-20 14:33:33 +080064static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)
65{
66 struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;
67 void __iomem *splitter_base = dwmac->splitter_base;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070068 void __iomem *tse_pcs_base = dwmac->pcs.tse_pcs_base;
69 void __iomem *sgmii_adapter_base = dwmac->pcs.sgmii_adapter_base;
70 struct device *dev = dwmac->dev;
71 struct net_device *ndev = dev_get_drvdata(dev);
72 struct phy_device *phy_dev = ndev->phydev;
Ley Foon Tanb4834c82014-08-20 14:33:33 +080073 u32 val;
74
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070075 if ((tse_pcs_base) && (sgmii_adapter_base))
76 writew(SGMII_ADAPTER_DISABLE,
77 sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
Ley Foon Tanb4834c82014-08-20 14:33:33 +080078
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070079 if (splitter_base) {
80 val = readl(splitter_base + EMAC_SPLITTER_CTRL_REG);
81 val &= ~EMAC_SPLITTER_CTRL_SPEED_MASK;
Ley Foon Tanb4834c82014-08-20 14:33:33 +080082
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070083 switch (speed) {
84 case 1000:
85 val |= EMAC_SPLITTER_CTRL_SPEED_1000;
86 break;
87 case 100:
88 val |= EMAC_SPLITTER_CTRL_SPEED_100;
89 break;
90 case 10:
91 val |= EMAC_SPLITTER_CTRL_SPEED_10;
92 break;
93 default:
94 return;
95 }
96 writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG);
Ley Foon Tanb4834c82014-08-20 14:33:33 +080097 }
98
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -070099 if (tse_pcs_base && sgmii_adapter_base)
100 tse_pcs_fix_mac_speed(&dwmac->pcs, phy_dev, speed);
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800101}
102
Dinh Nguyen801d2332014-03-26 22:45:10 -0500103static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *dev)
104{
105 struct device_node *np = dev->of_node;
106 struct regmap *sys_mgr_base_addr;
107 u32 reg_offset, reg_shift;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700108 int ret, index;
109 struct device_node *np_splitter = NULL;
110 struct device_node *np_sgmii_adapter = NULL;
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800111 struct resource res_splitter;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700112 struct resource res_tse_pcs;
113 struct resource res_sgmii_adapter;
Dinh Nguyen801d2332014-03-26 22:45:10 -0500114
115 dwmac->interface = of_get_phy_mode(np);
116
117 sys_mgr_base_addr = syscon_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon");
118 if (IS_ERR(sys_mgr_base_addr)) {
119 dev_info(dev, "No sysmgr-syscon node found\n");
120 return PTR_ERR(sys_mgr_base_addr);
121 }
122
123 ret = of_property_read_u32_index(np, "altr,sysmgr-syscon", 1, &reg_offset);
124 if (ret) {
125 dev_info(dev, "Could not read reg_offset from sysmgr-syscon!\n");
126 return -EINVAL;
127 }
128
129 ret = of_property_read_u32_index(np, "altr,sysmgr-syscon", 2, &reg_shift);
130 if (ret) {
131 dev_info(dev, "Could not read reg_shift from sysmgr-syscon!\n");
132 return -EINVAL;
133 }
134
Phil Reid43569812015-12-14 11:32:02 +0800135 dwmac->f2h_ptp_ref_clk = of_property_read_bool(np, "altr,f2h_ptp_ref_clk");
136
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800137 np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0);
138 if (np_splitter) {
Peter Chenf7113b32016-08-01 15:02:41 +0800139 ret = of_address_to_resource(np_splitter, 0, &res_splitter);
140 of_node_put(np_splitter);
141 if (ret) {
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800142 dev_info(dev, "Missing emac splitter address\n");
143 return -EINVAL;
144 }
145
Ley Foon Tandace1b52014-08-28 12:59:46 +0800146 dwmac->splitter_base = devm_ioremap_resource(dev, &res_splitter);
Wei Yongjunf19f9162014-09-12 07:12:57 +0800147 if (IS_ERR(dwmac->splitter_base)) {
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800148 dev_info(dev, "Failed to mapping emac splitter\n");
Wei Yongjunf19f9162014-09-12 07:12:57 +0800149 return PTR_ERR(dwmac->splitter_base);
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800150 }
151 }
152
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700153 np_sgmii_adapter = of_parse_phandle(np,
154 "altr,gmii-to-sgmii-converter", 0);
155 if (np_sgmii_adapter) {
156 index = of_property_match_string(np_sgmii_adapter, "reg-names",
157 "hps_emac_interface_splitter_avalon_slave");
158
159 if (index >= 0) {
160 if (of_address_to_resource(np_sgmii_adapter, index,
161 &res_splitter)) {
162 dev_err(dev,
163 "%s: ERROR: missing emac splitter address\n",
164 __func__);
Peter Chenf7113b32016-08-01 15:02:41 +0800165 ret = -EINVAL;
166 goto err_node_put;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700167 }
168
169 dwmac->splitter_base =
170 devm_ioremap_resource(dev, &res_splitter);
171
Peter Chenf7113b32016-08-01 15:02:41 +0800172 if (IS_ERR(dwmac->splitter_base)) {
173 ret = PTR_ERR(dwmac->splitter_base);
174 goto err_node_put;
175 }
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700176 }
177
178 index = of_property_match_string(np_sgmii_adapter, "reg-names",
179 "gmii_to_sgmii_adapter_avalon_slave");
180
181 if (index >= 0) {
182 if (of_address_to_resource(np_sgmii_adapter, index,
183 &res_sgmii_adapter)) {
184 dev_err(dev,
185 "%s: ERROR: failed mapping adapter\n",
186 __func__);
Peter Chenf7113b32016-08-01 15:02:41 +0800187 ret = -EINVAL;
188 goto err_node_put;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700189 }
190
191 dwmac->pcs.sgmii_adapter_base =
192 devm_ioremap_resource(dev, &res_sgmii_adapter);
193
Peter Chenf7113b32016-08-01 15:02:41 +0800194 if (IS_ERR(dwmac->pcs.sgmii_adapter_base)) {
195 ret = PTR_ERR(dwmac->pcs.sgmii_adapter_base);
196 goto err_node_put;
197 }
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700198 }
199
200 index = of_property_match_string(np_sgmii_adapter, "reg-names",
201 "eth_tse_control_port");
202
203 if (index >= 0) {
204 if (of_address_to_resource(np_sgmii_adapter, index,
205 &res_tse_pcs)) {
206 dev_err(dev,
207 "%s: ERROR: failed mapping tse control port\n",
208 __func__);
Peter Chenf7113b32016-08-01 15:02:41 +0800209 ret = -EINVAL;
210 goto err_node_put;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700211 }
212
213 dwmac->pcs.tse_pcs_base =
214 devm_ioremap_resource(dev, &res_tse_pcs);
215
Peter Chenf7113b32016-08-01 15:02:41 +0800216 if (IS_ERR(dwmac->pcs.tse_pcs_base)) {
217 ret = PTR_ERR(dwmac->pcs.tse_pcs_base);
218 goto err_node_put;
219 }
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700220 }
221 }
Dinh Nguyen801d2332014-03-26 22:45:10 -0500222 dwmac->reg_offset = reg_offset;
223 dwmac->reg_shift = reg_shift;
224 dwmac->sys_mgr_base_addr = sys_mgr_base_addr;
225 dwmac->dev = dev;
Peter Chenf7113b32016-08-01 15:02:41 +0800226 of_node_put(np_sgmii_adapter);
Dinh Nguyen801d2332014-03-26 22:45:10 -0500227
228 return 0;
Peter Chenf7113b32016-08-01 15:02:41 +0800229
230err_node_put:
231 of_node_put(np_sgmii_adapter);
232 return ret;
Dinh Nguyen801d2332014-03-26 22:45:10 -0500233}
234
Joachim Eastwood0f400a82016-05-01 22:58:23 +0200235static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
Dinh Nguyen801d2332014-03-26 22:45:10 -0500236{
237 struct regmap *sys_mgr_base_addr = dwmac->sys_mgr_base_addr;
238 int phymode = dwmac->interface;
239 u32 reg_offset = dwmac->reg_offset;
240 u32 reg_shift = dwmac->reg_shift;
Phil Reid734e00fa2016-04-07 15:55:35 +0800241 u32 ctrl, val, module;
Dinh Nguyen801d2332014-03-26 22:45:10 -0500242
243 switch (phymode) {
244 case PHY_INTERFACE_MODE_RGMII:
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800245 case PHY_INTERFACE_MODE_RGMII_ID:
Dinh Nguyen801d2332014-03-26 22:45:10 -0500246 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
247 break;
248 case PHY_INTERFACE_MODE_MII:
249 case PHY_INTERFACE_MODE_GMII:
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700250 case PHY_INTERFACE_MODE_SGMII:
Dinh Nguyen801d2332014-03-26 22:45:10 -0500251 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
252 break;
253 default:
254 dev_err(dwmac->dev, "bad phy mode %d\n", phymode);
255 return -EINVAL;
256 }
257
Ley Foon Tanb4834c82014-08-20 14:33:33 +0800258 /* Overwrite val to GMII if splitter core is enabled. The phymode here
259 * is the actual phy mode on phy hardware, but phy interface from
260 * EMAC core is GMII.
261 */
262 if (dwmac->splitter_base)
263 val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
264
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200265 /* Assert reset to the enet controller before changing the phy mode */
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -0500266 reset_control_assert(dwmac->stmmac_ocp_rst);
267 reset_control_assert(dwmac->stmmac_rst);
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200268
Dinh Nguyen801d2332014-03-26 22:45:10 -0500269 regmap_read(sys_mgr_base_addr, reg_offset, &ctrl);
270 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << reg_shift);
271 ctrl |= val << reg_shift;
272
Stephan Gatzka013dae52017-08-22 14:25:07 +0200273 if (dwmac->f2h_ptp_ref_clk ||
274 phymode == PHY_INTERFACE_MODE_MII ||
275 phymode == PHY_INTERFACE_MODE_GMII ||
276 phymode == PHY_INTERFACE_MODE_SGMII) {
Phil Reid43569812015-12-14 11:32:02 +0800277 ctrl |= SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2);
Phil Reid734e00fa2016-04-07 15:55:35 +0800278 regmap_read(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG,
279 &module);
280 module |= (SYSMGR_FPGAGRP_MODULE_EMAC << (reg_shift / 2));
281 regmap_write(sys_mgr_base_addr, SYSMGR_FPGAGRP_MODULE_REG,
282 module);
283 } else {
Phil Reid43569812015-12-14 11:32:02 +0800284 ctrl &= ~(SYSMGR_EMACGRP_CTRL_PTP_REF_CLK_MASK << (reg_shift / 2));
Phil Reid734e00fa2016-04-07 15:55:35 +0800285 }
Phil Reid43569812015-12-14 11:32:02 +0800286
Dinh Nguyen801d2332014-03-26 22:45:10 -0500287 regmap_write(sys_mgr_base_addr, reg_offset, ctrl);
Phil Reid734e00fa2016-04-07 15:55:35 +0800288
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200289 /* Deassert reset for the phy configuration to be sampled by
290 * the enet controller, and operation to start in requested mode
291 */
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -0500292 reset_control_deassert(dwmac->stmmac_ocp_rst);
293 reset_control_deassert(dwmac->stmmac_rst);
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700294 if (phymode == PHY_INTERFACE_MODE_SGMII) {
295 if (tse_pcs_init(dwmac->pcs.tse_pcs_base, &dwmac->pcs) != 0) {
296 dev_err(dwmac->dev, "Unable to initialize TSE PCS");
297 return -EINVAL;
298 }
299 }
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200300
Dinh Nguyen801d2332014-03-26 22:45:10 -0500301 return 0;
302}
303
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200304static int socfpga_dwmac_probe(struct platform_device *pdev)
Joachim Eastwood82732782015-07-29 00:08:51 +0200305{
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200306 struct plat_stmmacenet_data *plat_dat;
307 struct stmmac_resources stmmac_res;
Joachim Eastwood82732782015-07-29 00:08:51 +0200308 struct device *dev = &pdev->dev;
309 int ret;
310 struct socfpga_dwmac *dwmac;
Johan Hovold50ac64c2016-11-30 15:29:49 +0100311 struct net_device *ndev;
312 struct stmmac_priv *stpriv;
Joachim Eastwood82732782015-07-29 00:08:51 +0200313
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200314 ret = stmmac_get_platform_resources(pdev, &stmmac_res);
315 if (ret)
316 return ret;
317
318 plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
319 if (IS_ERR(plat_dat))
320 return PTR_ERR(plat_dat);
321
Joachim Eastwood82732782015-07-29 00:08:51 +0200322 dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100323 if (!dwmac) {
324 ret = -ENOMEM;
325 goto err_remove_config_dt;
326 }
Joachim Eastwood82732782015-07-29 00:08:51 +0200327
Dinh Nguyenbc8a2d92018-06-19 10:35:38 -0500328 dwmac->stmmac_ocp_rst = devm_reset_control_get_optional(dev, "stmmaceth-ocp");
329 if (IS_ERR(dwmac->stmmac_ocp_rst)) {
330 ret = PTR_ERR(dwmac->stmmac_ocp_rst);
331 dev_err(dev, "error getting reset control of ocp %d\n", ret);
332 goto err_remove_config_dt;
333 }
334
335 reset_control_deassert(dwmac->stmmac_ocp_rst);
336
Joachim Eastwood82732782015-07-29 00:08:51 +0200337 ret = socfpga_dwmac_parse_data(dwmac, dev);
338 if (ret) {
339 dev_err(dev, "Unable to parse OF data\n");
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100340 goto err_remove_config_dt;
Joachim Eastwood82732782015-07-29 00:08:51 +0200341 }
342
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200343 plat_dat->bsp_priv = dwmac;
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200344 plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed;
345
Marek Vasut3c201b52016-04-21 14:11:50 +0200346 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
Johan Hovold50ac64c2016-11-30 15:29:49 +0100347 if (ret)
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100348 goto err_remove_config_dt;
Tien Hock Lohfb3bbdb2016-07-07 20:23:30 -0700349
Johan Hovold50ac64c2016-11-30 15:29:49 +0100350 ndev = platform_get_drvdata(pdev);
351 stpriv = netdev_priv(ndev);
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200352
Johan Hovold50ac64c2016-11-30 15:29:49 +0100353 /* The socfpga driver needs to control the stmmac reset to set the phy
354 * mode. Create a copy of the core reset handle so it can be used by
355 * the driver later.
356 */
jpintof573c0b2017-01-09 12:35:09 +0000357 dwmac->stmmac_rst = stpriv->plat->stmmac_rst;
Joachim Eastwood70cb1362016-05-01 22:58:21 +0200358
Johan Hovold50ac64c2016-11-30 15:29:49 +0100359 ret = socfpga_dwmac_set_phy_mode(dwmac);
360 if (ret)
361 goto err_dvr_remove;
362
363 return 0;
364
365err_dvr_remove:
366 stmmac_dvr_remove(&pdev->dev);
Johan Hovoldd2ed0a72016-11-30 15:29:55 +0100367err_remove_config_dt:
368 stmmac_remove_config_dt(pdev, plat_dat);
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200369
Marek Vasut3c201b52016-04-21 14:11:50 +0200370 return ret;
Joachim Eastwood82732782015-07-29 00:08:51 +0200371}
372
Joachim Eastwood56868de2016-05-01 22:58:20 +0200373#ifdef CONFIG_PM_SLEEP
374static int socfpga_dwmac_resume(struct device *dev)
375{
Joachim Eastwood56868de2016-05-01 22:58:20 +0200376 struct net_device *ndev = dev_get_drvdata(dev);
377 struct stmmac_priv *priv = netdev_priv(ndev);
378
Joachim Eastwood0f400a82016-05-01 22:58:23 +0200379 socfpga_dwmac_set_phy_mode(priv->plat->bsp_priv);
Joachim Eastwood56868de2016-05-01 22:58:20 +0200380
Joachim Eastwood53737242016-05-01 22:58:22 +0200381 /* Before the enet controller is suspended, the phy is suspended.
382 * This causes the phy clock to be gated. The enet controller is
383 * resumed before the phy, so the clock is still gated "off" when
384 * the enet controller is resumed. This code makes sure the phy
385 * is "resumed" before reinitializing the enet controller since
386 * the enet controller depends on an active phy clock to complete
387 * a DMA reset. A DMA reset will "time out" if executed
388 * with no phy clock input on the Synopsys enet controller.
389 * Verified through Synopsys Case #8000711656.
390 *
391 * Note that the phy clock is also gated when the phy is isolated.
392 * Phy "suspend" and "isolate" controls are located in phy basic
393 * control register 0, and can be modified by the phy driver
394 * framework.
395 */
Philippe Reynesd6d50c72016-10-03 08:28:19 +0200396 if (ndev->phydev)
397 phy_resume(ndev->phydev);
Joachim Eastwood53737242016-05-01 22:58:22 +0200398
Joachim Eastwood56868de2016-05-01 22:58:20 +0200399 return stmmac_resume(dev);
400}
401#endif /* CONFIG_PM_SLEEP */
402
Joachim Eastwoodbfca2eb2016-05-08 13:47:23 +0200403static SIMPLE_DEV_PM_OPS(socfpga_dwmac_pm_ops, stmmac_suspend,
404 socfpga_dwmac_resume);
Joachim Eastwood56868de2016-05-01 22:58:20 +0200405
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200406static const struct of_device_id socfpga_dwmac_match[] = {
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200407 { .compatible = "altr,socfpga-stmmac" },
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200408 { }
409};
410MODULE_DEVICE_TABLE(of, socfpga_dwmac_match);
411
412static struct platform_driver socfpga_dwmac_driver = {
Joachim Eastwood8880b6c2015-07-29 00:08:52 +0200413 .probe = socfpga_dwmac_probe,
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200414 .remove = stmmac_pltfr_remove,
415 .driver = {
416 .name = "socfpga-dwmac",
Joachim Eastwood56868de2016-05-01 22:58:20 +0200417 .pm = &socfpga_dwmac_pm_ops,
Joachim Eastwoodc7c52ae2015-05-14 12:11:03 +0200418 .of_match_table = socfpga_dwmac_match,
419 },
420};
421module_platform_driver(socfpga_dwmac_driver);
422
423MODULE_LICENSE("GPL v2");