Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
93aa731e
Commit
93aa731e
authored
Oct 25, 2023
by
David S. Miller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dsa-microchip-WoL-support'
parents
e43e6d95
d264f244
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
0 deletions
+139
-0
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
+2
-0
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/microchip/ksz9477.c
+100
-0
drivers/net/dsa/microchip/ksz9477.h
drivers/net/dsa/microchip/ksz9477.h
+4
-0
drivers/net/dsa/microchip/ksz_common.c
drivers/net/dsa/microchip/ksz_common.c
+28
-0
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/ksz_common.h
+5
-0
No files found.
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml
View file @
93aa731e
...
...
@@ -38,6 +38,8 @@ properties:
Should be a gpio specifier for a reset line.
maxItems
:
1
wakeup-source
:
true
microchip,synclko-125
:
$ref
:
/schemas/types.yaml#/definitions/flag
description
:
...
...
drivers/net/dsa/microchip/ksz9477.c
View file @
93aa731e
...
...
@@ -56,6 +56,103 @@ int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu)
REG_SW_MTU_MASK
,
frame_size
);
}
/**
* ksz9477_handle_wake_reason - Handle wake reason on a specified port.
* @dev: The device structure.
* @port: The port number.
*
* This function reads the PME (Power Management Event) status register of a
* specified port to determine the wake reason. If there is no wake event, it
* returns early. Otherwise, it logs the wake reason which could be due to a
* "Magic Packet", "Link Up", or "Energy Detect" event. The PME status register
* is then cleared to acknowledge the handling of the wake event.
*
* Return: 0 on success, or an error code on failure.
*/
static
int
ksz9477_handle_wake_reason
(
struct
ksz_device
*
dev
,
int
port
)
{
u8
pme_status
;
int
ret
;
ret
=
ksz_pread8
(
dev
,
port
,
REG_PORT_PME_STATUS
,
&
pme_status
);
if
(
ret
)
return
ret
;
if
(
!
pme_status
)
return
0
;
dev_dbg
(
dev
->
dev
,
"Wake event on port %d due to:%s%s
\n
"
,
port
,
pme_status
&
PME_WOL_LINKUP
?
"
\"
Link Up
\"
"
:
""
,
pme_status
&
PME_WOL_ENERGY
?
"
\"
Enery detect
\"
"
:
""
);
return
ksz_pwrite8
(
dev
,
port
,
REG_PORT_PME_STATUS
,
pme_status
);
}
/**
* ksz9477_get_wol - Get Wake-on-LAN settings for a specified port.
* @dev: The device structure.
* @port: The port number.
* @wol: Pointer to ethtool Wake-on-LAN settings structure.
*
* This function checks the PME Pin Control Register to see if PME Pin Output
* Enable is set, indicating PME is enabled. If enabled, it sets the supported
* and active WoL flags.
*/
void
ksz9477_get_wol
(
struct
ksz_device
*
dev
,
int
port
,
struct
ethtool_wolinfo
*
wol
)
{
u8
pme_ctrl
;
int
ret
;
if
(
!
dev
->
wakeup_source
)
return
;
wol
->
supported
=
WAKE_PHY
;
ret
=
ksz_pread8
(
dev
,
port
,
REG_PORT_PME_CTRL
,
&
pme_ctrl
);
if
(
ret
)
return
;
if
(
pme_ctrl
&
(
PME_WOL_LINKUP
|
PME_WOL_ENERGY
))
wol
->
wolopts
|=
WAKE_PHY
;
}
/**
* ksz9477_set_wol - Set Wake-on-LAN settings for a specified port.
* @dev: The device structure.
* @port: The port number.
* @wol: Pointer to ethtool Wake-on-LAN settings structure.
*
* This function configures Wake-on-LAN (WoL) settings for a specified port.
* It validates the provided WoL options, checks if PME is enabled via the
* switch's PME Pin Control Register, clears any previous wake reasons,
* and sets the Magic Packet flag in the port's PME control register if
* specified.
*
* Return: 0 on success, or other error codes on failure.
*/
int
ksz9477_set_wol
(
struct
ksz_device
*
dev
,
int
port
,
struct
ethtool_wolinfo
*
wol
)
{
u8
pme_ctrl
=
0
;
int
ret
;
if
(
wol
->
wolopts
&
~
WAKE_PHY
)
return
-
EINVAL
;
if
(
!
dev
->
wakeup_source
)
return
-
EOPNOTSUPP
;
ret
=
ksz9477_handle_wake_reason
(
dev
,
port
);
if
(
ret
)
return
ret
;
if
(
wol
->
wolopts
&
WAKE_PHY
)
pme_ctrl
|=
PME_WOL_LINKUP
|
PME_WOL_ENERGY
;
return
ksz_pwrite8
(
dev
,
port
,
REG_PORT_PME_CTRL
,
pme_ctrl
);
}
static
int
ksz9477_wait_vlan_ctrl_ready
(
struct
ksz_device
*
dev
)
{
unsigned
int
val
;
...
...
@@ -1006,6 +1103,9 @@ void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
ksz_pread16
(
dev
,
port
,
REG_PORT_PHY_INT_ENABLE
,
&
data16
);
ksz9477_port_acl_init
(
dev
,
port
);
/* clear pending wake flags */
ksz9477_handle_wake_reason
(
dev
,
port
);
}
void
ksz9477_config_cpu_port
(
struct
dsa_switch
*
ds
)
...
...
drivers/net/dsa/microchip/ksz9477.h
View file @
93aa731e
...
...
@@ -58,6 +58,10 @@ void ksz9477_switch_exit(struct ksz_device *dev);
void
ksz9477_port_queue_split
(
struct
ksz_device
*
dev
,
int
port
);
void
ksz9477_hsr_join
(
struct
dsa_switch
*
ds
,
int
port
,
struct
net_device
*
hsr
);
void
ksz9477_hsr_leave
(
struct
dsa_switch
*
ds
,
int
port
,
struct
net_device
*
hsr
);
void
ksz9477_get_wol
(
struct
ksz_device
*
dev
,
int
port
,
struct
ethtool_wolinfo
*
wol
);
int
ksz9477_set_wol
(
struct
ksz_device
*
dev
,
int
port
,
struct
ethtool_wolinfo
*
wol
);
int
ksz9477_port_acl_init
(
struct
ksz_device
*
dev
,
int
port
);
void
ksz9477_port_acl_free
(
struct
ksz_device
*
dev
,
int
port
);
...
...
drivers/net/dsa/microchip/ksz_common.c
View file @
93aa731e
...
...
@@ -319,6 +319,8 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
.
mdb_del
=
ksz9477_mdb_del
,
.
change_mtu
=
ksz9477_change_mtu
,
.
phylink_mac_link_up
=
ksz9477_phylink_mac_link_up
,
.
get_wol
=
ksz9477_get_wol
,
.
set_wol
=
ksz9477_set_wol
,
.
config_cpu_port
=
ksz9477_config_cpu_port
,
.
tc_cbs_set_cinc
=
ksz9477_tc_cbs_set_cinc
,
.
enable_stp_addr
=
ksz9477_enable_stp_addr
,
...
...
@@ -441,6 +443,7 @@ static const u8 ksz8795_shifts[] = {
};
static
const
u16
ksz8863_regs
[]
=
{
[
REG_SW_MAC_ADDR
]
=
0x70
,
[
REG_IND_CTRL_0
]
=
0x79
,
[
REG_IND_DATA_8
]
=
0x7B
,
[
REG_IND_DATA_CHECK
]
=
0x7B
,
...
...
@@ -3542,6 +3545,26 @@ static int ksz_setup_tc(struct dsa_switch *ds, int port,
}
}
static
void
ksz_get_wol
(
struct
dsa_switch
*
ds
,
int
port
,
struct
ethtool_wolinfo
*
wol
)
{
struct
ksz_device
*
dev
=
ds
->
priv
;
if
(
dev
->
dev_ops
->
get_wol
)
dev
->
dev_ops
->
get_wol
(
dev
,
port
,
wol
);
}
static
int
ksz_set_wol
(
struct
dsa_switch
*
ds
,
int
port
,
struct
ethtool_wolinfo
*
wol
)
{
struct
ksz_device
*
dev
=
ds
->
priv
;
if
(
dev
->
dev_ops
->
set_wol
)
return
dev
->
dev_ops
->
set_wol
(
dev
,
port
,
wol
);
return
-
EOPNOTSUPP
;
}
static
int
ksz_port_set_mac_address
(
struct
dsa_switch
*
ds
,
int
port
,
const
unsigned
char
*
addr
)
{
...
...
@@ -3726,6 +3749,8 @@ static const struct dsa_switch_ops ksz_switch_ops = {
.
get_pause_stats
=
ksz_get_pause_stats
,
.
port_change_mtu
=
ksz_change_mtu
,
.
port_max_mtu
=
ksz_max_mtu
,
.
get_wol
=
ksz_get_wol
,
.
set_wol
=
ksz_set_wol
,
.
get_ts_info
=
ksz_get_ts_info
,
.
port_hwtstamp_get
=
ksz_hwtstamp_get
,
.
port_hwtstamp_set
=
ksz_hwtstamp_set
,
...
...
@@ -4158,6 +4183,9 @@ int ksz_switch_register(struct ksz_device *dev)
dev_err
(
dev
->
dev
,
"inconsistent synclko settings
\n
"
);
return
-
EINVAL
;
}
dev
->
wakeup_source
=
of_property_read_bool
(
dev
->
dev
->
of_node
,
"wakeup-source"
);
}
ret
=
dsa_register_switch
(
dev
->
ds
);
...
...
drivers/net/dsa/microchip/ksz_common.h
View file @
93aa731e
...
...
@@ -163,6 +163,7 @@ struct ksz_device {
phy_interface_t
compat_interface
;
bool
synclko_125
;
bool
synclko_disable
;
bool
wakeup_source
;
struct
vlan_table
*
vlan_cache
;
...
...
@@ -373,6 +374,10 @@ struct ksz_dev_ops {
int
duplex
,
bool
tx_pause
,
bool
rx_pause
);
void
(
*
setup_rgmii_delay
)(
struct
ksz_device
*
dev
,
int
port
);
int
(
*
tc_cbs_set_cinc
)(
struct
ksz_device
*
dev
,
int
port
,
u32
val
);
void
(
*
get_wol
)(
struct
ksz_device
*
dev
,
int
port
,
struct
ethtool_wolinfo
*
wol
);
int
(
*
set_wol
)(
struct
ksz_device
*
dev
,
int
port
,
struct
ethtool_wolinfo
*
wol
);
void
(
*
config_cpu_port
)(
struct
dsa_switch
*
ds
);
int
(
*
enable_stp_addr
)(
struct
ksz_device
*
dev
);
int
(
*
reset
)(
struct
ksz_device
*
dev
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment