Lines Matching +full:channel +full:-

1 // SPDX-License-Identifier: GPL-2.0
37 struct r8a779f0_eth_serdes_channel channel[R8A779F0_ETH_SERDES_NUM]; member
53 r8a779f0_eth_serdes_reg_wait(struct r8a779f0_eth_serdes_channel *channel, in r8a779f0_eth_serdes_reg_wait() argument
59 iowrite32(bank, channel->addr + R8A779F0_ETH_SERDES_BANK_SELECT); in r8a779f0_eth_serdes_reg_wait()
61 ret = readl_poll_timeout_atomic(channel->addr + offs, val, in r8a779f0_eth_serdes_reg_wait()
65 dev_dbg(&channel->phy->dev, in r8a779f0_eth_serdes_reg_wait()
67 __func__, channel->index, offs, bank, mask, expected); in r8a779f0_eth_serdes_reg_wait()
75 struct r8a779f0_eth_serdes_channel *channel; in r8a779f0_eth_serdes_common_init_ram() local
79 channel = &dd->channel[i]; in r8a779f0_eth_serdes_common_init_ram()
80 ret = r8a779f0_eth_serdes_reg_wait(channel, 0x026c, 0x180, BIT(0), 0x01); in r8a779f0_eth_serdes_common_init_ram()
85 r8a779f0_eth_serdes_write32(dd->addr, 0x026c, 0x180, 0x03); in r8a779f0_eth_serdes_common_init_ram()
91 r8a779f0_eth_serdes_common_setting(struct r8a779f0_eth_serdes_channel *channel) in r8a779f0_eth_serdes_common_setting() argument
93 struct r8a779f0_eth_serdes_drv_data *dd = channel->dd; in r8a779f0_eth_serdes_common_setting()
95 switch (channel->phy_interface) { in r8a779f0_eth_serdes_common_setting()
97 r8a779f0_eth_serdes_write32(dd->addr, 0x0244, 0x180, 0x0097); in r8a779f0_eth_serdes_common_setting()
98 r8a779f0_eth_serdes_write32(dd->addr, 0x01d0, 0x180, 0x0060); in r8a779f0_eth_serdes_common_setting()
99 r8a779f0_eth_serdes_write32(dd->addr, 0x01d8, 0x180, 0x2200); in r8a779f0_eth_serdes_common_setting()
100 r8a779f0_eth_serdes_write32(dd->addr, 0x01d4, 0x180, 0x0000); in r8a779f0_eth_serdes_common_setting()
101 r8a779f0_eth_serdes_write32(dd->addr, 0x01e0, 0x180, 0x003d); in r8a779f0_eth_serdes_common_setting()
104 return -EOPNOTSUPP; in r8a779f0_eth_serdes_common_setting()
109 r8a779f0_eth_serdes_chan_setting(struct r8a779f0_eth_serdes_channel *channel) in r8a779f0_eth_serdes_chan_setting() argument
113 switch (channel->phy_interface) { in r8a779f0_eth_serdes_chan_setting()
115 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x380, 0x2000); in r8a779f0_eth_serdes_chan_setting()
116 r8a779f0_eth_serdes_write32(channel->addr, 0x01c0, 0x180, 0x0011); in r8a779f0_eth_serdes_chan_setting()
117 r8a779f0_eth_serdes_write32(channel->addr, 0x0248, 0x180, 0x0540); in r8a779f0_eth_serdes_chan_setting()
118 r8a779f0_eth_serdes_write32(channel->addr, 0x0258, 0x180, 0x0015); in r8a779f0_eth_serdes_chan_setting()
119 r8a779f0_eth_serdes_write32(channel->addr, 0x0144, 0x180, 0x0100); in r8a779f0_eth_serdes_chan_setting()
120 r8a779f0_eth_serdes_write32(channel->addr, 0x01a0, 0x180, 0x0000); in r8a779f0_eth_serdes_chan_setting()
121 r8a779f0_eth_serdes_write32(channel->addr, 0x00d0, 0x180, 0x0002); in r8a779f0_eth_serdes_chan_setting()
122 r8a779f0_eth_serdes_write32(channel->addr, 0x0150, 0x180, 0x0003); in r8a779f0_eth_serdes_chan_setting()
123 r8a779f0_eth_serdes_write32(channel->addr, 0x00c8, 0x180, 0x0100); in r8a779f0_eth_serdes_chan_setting()
124 r8a779f0_eth_serdes_write32(channel->addr, 0x0148, 0x180, 0x0100); in r8a779f0_eth_serdes_chan_setting()
125 r8a779f0_eth_serdes_write32(channel->addr, 0x0174, 0x180, 0x0000); in r8a779f0_eth_serdes_chan_setting()
126 r8a779f0_eth_serdes_write32(channel->addr, 0x0160, 0x180, 0x0007); in r8a779f0_eth_serdes_chan_setting()
127 r8a779f0_eth_serdes_write32(channel->addr, 0x01ac, 0x180, 0x0000); in r8a779f0_eth_serdes_chan_setting()
128 r8a779f0_eth_serdes_write32(channel->addr, 0x00c4, 0x180, 0x0310); in r8a779f0_eth_serdes_chan_setting()
129 r8a779f0_eth_serdes_write32(channel->addr, 0x00c8, 0x180, 0x0101); in r8a779f0_eth_serdes_chan_setting()
130 ret = r8a779f0_eth_serdes_reg_wait(channel, 0x00c8, 0x0180, BIT(0), 0); in r8a779f0_eth_serdes_chan_setting()
134 r8a779f0_eth_serdes_write32(channel->addr, 0x0148, 0x180, 0x0101); in r8a779f0_eth_serdes_chan_setting()
135 ret = r8a779f0_eth_serdes_reg_wait(channel, 0x0148, 0x0180, BIT(0), 0); in r8a779f0_eth_serdes_chan_setting()
139 r8a779f0_eth_serdes_write32(channel->addr, 0x00c4, 0x180, 0x1310); in r8a779f0_eth_serdes_chan_setting()
140 r8a779f0_eth_serdes_write32(channel->addr, 0x00d8, 0x180, 0x1800); in r8a779f0_eth_serdes_chan_setting()
141 r8a779f0_eth_serdes_write32(channel->addr, 0x00dc, 0x180, 0x0000); in r8a779f0_eth_serdes_chan_setting()
142 r8a779f0_eth_serdes_write32(channel->addr, 0x001c, 0x300, 0x0001); in r8a779f0_eth_serdes_chan_setting()
143 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x380, 0x2100); in r8a779f0_eth_serdes_chan_setting()
144 ret = r8a779f0_eth_serdes_reg_wait(channel, 0x0000, 0x0380, BIT(8), 0); in r8a779f0_eth_serdes_chan_setting()
148 if (channel->speed == 1000) in r8a779f0_eth_serdes_chan_setting()
149 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x1f00, 0x0140); in r8a779f0_eth_serdes_chan_setting()
150 else if (channel->speed == 100) in r8a779f0_eth_serdes_chan_setting()
151 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x1f00, 0x2100); in r8a779f0_eth_serdes_chan_setting()
154 r8a779f0_eth_serdes_write32(channel->addr, 0x0004, 0x1f80, 0x0005); in r8a779f0_eth_serdes_chan_setting()
155 r8a779f0_eth_serdes_write32(channel->addr, 0x0028, 0x1f80, 0x07a1); in r8a779f0_eth_serdes_chan_setting()
156 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x1f80, 0x0208); in r8a779f0_eth_serdes_chan_setting()
159 return -EOPNOTSUPP; in r8a779f0_eth_serdes_chan_setting()
166 r8a779f0_eth_serdes_chan_speed(struct r8a779f0_eth_serdes_channel *channel) in r8a779f0_eth_serdes_chan_speed() argument
170 switch (channel->phy_interface) { in r8a779f0_eth_serdes_chan_speed()
173 if (channel->speed == 1000) in r8a779f0_eth_serdes_chan_speed()
174 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x1f00, 0x1140); in r8a779f0_eth_serdes_chan_speed()
175 else if (channel->speed == 100) in r8a779f0_eth_serdes_chan_speed()
176 r8a779f0_eth_serdes_write32(channel->addr, 0x0000, 0x1f00, 0x3100); in r8a779f0_eth_serdes_chan_speed()
177 ret = r8a779f0_eth_serdes_reg_wait(channel, 0x0008, 0x1f80, BIT(0), 1); in r8a779f0_eth_serdes_chan_speed()
180 r8a779f0_eth_serdes_write32(channel->addr, 0x0008, 0x1f80, 0x0000); in r8a779f0_eth_serdes_chan_speed()
183 return -EOPNOTSUPP; in r8a779f0_eth_serdes_chan_speed()
190 static int r8a779f0_eth_serdes_monitor_linkup(struct r8a779f0_eth_serdes_channel *channel) in r8a779f0_eth_serdes_monitor_linkup() argument
195 ret = r8a779f0_eth_serdes_reg_wait(channel, 0x0004, 0x300, in r8a779f0_eth_serdes_monitor_linkup()
201 r8a779f0_eth_serdes_write32(channel->addr, 0x0144, 0x180, 0x0100); in r8a779f0_eth_serdes_monitor_linkup()
203 r8a779f0_eth_serdes_write32(channel->addr, 0x0144, 0x180, 0x0000); in r8a779f0_eth_serdes_monitor_linkup()
209 static int r8a779f0_eth_serdes_hw_init(struct r8a779f0_eth_serdes_channel *channel) in r8a779f0_eth_serdes_hw_init() argument
211 struct r8a779f0_eth_serdes_drv_data *dd = channel->dd; in r8a779f0_eth_serdes_hw_init()
214 if (dd->initialized) in r8a779f0_eth_serdes_hw_init()
217 reset_control_reset(dd->reset); in r8a779f0_eth_serdes_hw_init()
226 ret = r8a779f0_eth_serdes_reg_wait(&dd->channel[i], 0x0000, in r8a779f0_eth_serdes_hw_init()
233 r8a779f0_eth_serdes_write32(dd->channel[i].addr, 0x03d4, 0x380, 0x0443); in r8a779f0_eth_serdes_hw_init()
235 ret = r8a779f0_eth_serdes_common_setting(channel); in r8a779f0_eth_serdes_hw_init()
240 r8a779f0_eth_serdes_write32(dd->channel[i].addr, 0x03d0, 0x380, 0x0001); in r8a779f0_eth_serdes_hw_init()
243 r8a779f0_eth_serdes_write32(dd->addr, 0x0000, 0x380, 0x8000); in r8a779f0_eth_serdes_hw_init()
249 return r8a779f0_eth_serdes_reg_wait(&dd->channel[0], 0x0000, 0x380, BIT(15), 0); in r8a779f0_eth_serdes_hw_init()
254 struct r8a779f0_eth_serdes_channel *channel = phy_get_drvdata(p); in r8a779f0_eth_serdes_init() local
257 ret = r8a779f0_eth_serdes_hw_init(channel); in r8a779f0_eth_serdes_init()
259 channel->dd->initialized = true; in r8a779f0_eth_serdes_init()
266 struct r8a779f0_eth_serdes_channel *channel = phy_get_drvdata(p); in r8a779f0_eth_serdes_exit() local
268 channel->dd->initialized = false; in r8a779f0_eth_serdes_exit()
274 *channel) in r8a779f0_eth_serdes_hw_init_late()
278 ret = r8a779f0_eth_serdes_chan_setting(channel); in r8a779f0_eth_serdes_hw_init_late()
282 ret = r8a779f0_eth_serdes_chan_speed(channel); in r8a779f0_eth_serdes_hw_init_late()
286 r8a779f0_eth_serdes_write32(channel->addr, 0x03c0, 0x380, 0x0000); in r8a779f0_eth_serdes_hw_init_late()
288 r8a779f0_eth_serdes_write32(channel->addr, 0x03d0, 0x380, 0x0000); in r8a779f0_eth_serdes_hw_init_late()
290 return r8a779f0_eth_serdes_monitor_linkup(channel); in r8a779f0_eth_serdes_hw_init_late()
295 struct r8a779f0_eth_serdes_channel *channel = phy_get_drvdata(p); in r8a779f0_eth_serdes_power_on() local
297 return r8a779f0_eth_serdes_hw_init_late(channel); in r8a779f0_eth_serdes_power_on()
303 struct r8a779f0_eth_serdes_channel *channel = phy_get_drvdata(p); in r8a779f0_eth_serdes_set_mode() local
306 return -EOPNOTSUPP; in r8a779f0_eth_serdes_set_mode()
312 channel->phy_interface = submode; in r8a779f0_eth_serdes_set_mode()
315 return -EOPNOTSUPP; in r8a779f0_eth_serdes_set_mode()
321 struct r8a779f0_eth_serdes_channel *channel = phy_get_drvdata(p); in r8a779f0_eth_serdes_set_speed() local
323 channel->speed = speed; in r8a779f0_eth_serdes_set_speed()
341 if (args->args[0] >= R8A779F0_ETH_SERDES_NUM) in r8a779f0_eth_serdes_xlate()
342 return ERR_PTR(-ENODEV); in r8a779f0_eth_serdes_xlate()
344 return dd->channel[args->args[0]].phy; in r8a779f0_eth_serdes_xlate()
348 { .compatible = "renesas,r8a779f0-ether-serdes", },
359 dd = devm_kzalloc(&pdev->dev, sizeof(*dd), GFP_KERNEL); in r8a779f0_eth_serdes_probe()
361 return -ENOMEM; in r8a779f0_eth_serdes_probe()
364 dd->pdev = pdev; in r8a779f0_eth_serdes_probe()
365 dd->addr = devm_platform_ioremap_resource(pdev, 0); in r8a779f0_eth_serdes_probe()
366 if (IS_ERR(dd->addr)) in r8a779f0_eth_serdes_probe()
367 return PTR_ERR(dd->addr); in r8a779f0_eth_serdes_probe()
369 dd->reset = devm_reset_control_get(&pdev->dev, NULL); in r8a779f0_eth_serdes_probe()
370 if (IS_ERR(dd->reset)) in r8a779f0_eth_serdes_probe()
371 return PTR_ERR(dd->reset); in r8a779f0_eth_serdes_probe()
374 struct r8a779f0_eth_serdes_channel *channel = &dd->channel[i]; in r8a779f0_eth_serdes_probe() local
376 channel->phy = devm_phy_create(&pdev->dev, NULL, in r8a779f0_eth_serdes_probe()
378 if (IS_ERR(channel->phy)) in r8a779f0_eth_serdes_probe()
379 return PTR_ERR(channel->phy); in r8a779f0_eth_serdes_probe()
380 channel->addr = dd->addr + R8A779F0_ETH_SERDES_OFFSET * i; in r8a779f0_eth_serdes_probe()
381 channel->dd = dd; in r8a779f0_eth_serdes_probe()
382 channel->index = i; in r8a779f0_eth_serdes_probe()
383 phy_set_drvdata(channel->phy, channel); in r8a779f0_eth_serdes_probe()
386 provider = devm_of_phy_provider_register(&pdev->dev, in r8a779f0_eth_serdes_probe()
391 pm_runtime_enable(&pdev->dev); in r8a779f0_eth_serdes_probe()
392 pm_runtime_get_sync(&pdev->dev); in r8a779f0_eth_serdes_probe()
399 pm_runtime_put(&pdev->dev); in r8a779f0_eth_serdes_remove()
400 pm_runtime_disable(&pdev->dev); in r8a779f0_eth_serdes_remove()