net: ravb: Add runtime PM support
authorClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Wed, 14 Feb 2024 13:58:00 +0000 (15:58 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Feb 2024 08:32:04 +0000 (08:32 +0000)
commit48f894ab07c444b9b26a0913d2032de663f4aecb
tree8fc91c582d28731178c1f2fd2af568b3cfc815d6
parenta71a50e391bf00fdc88bb13a867620c59ad744da
net: ravb: Add runtime PM support

Add runtime PM support for the ravb driver. As the driver is used by
different IP variants, with different behaviors, to be able to have the
runtime PM support available for all devices, the preparatory commits
moved all the resources parsing and allocations in the driver's probe
function and kept the settings for ravb_open(). This is due to the fact
that on some IP variants-platforms tuples disabling/enabling the clocks
will switch the IP to the reset operation mode where register contents is
lost and reconfiguration needs to be done. For this the rabv_open()
function enables the clocks, switches the IP to configuration mode, applies
all the register settings and switches the IP to the operational mode. At
the end of ravb_open() IP is ready to send/receive data.

In ravb_close() necessary reverts are done (compared with ravb_open()), the
IP is switched to reset mode and clocks are disabled.

The ethtool APIs or IOCTLs that might execute while the interface is down
are either cached (and applied in ravb_open()) or rejected (as at that time
the IP is in reset mode). Keeping the IP in the reset mode also increases
the power saved (according to the hardware manual).

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/ravb_main.c