Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
ffc60b5
Documentation
LICENSES
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
connector
counter
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
ide
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip
isdn
leds
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
mux
net
appletalk
arcnet
bonding
caif
can
dsa
b53
microchip
Kconfig
Makefile
ksz8795.c
ksz8795_reg.h
ksz8795_spi.c
ksz9477.c
ksz9477_reg.h
ksz9477_spi.c
ksz_common.c
ksz_common.h
ksz_priv.h
mv88e6xxx
sja1105
Kconfig
Makefile
bcm_sf2.c
bcm_sf2.h
bcm_sf2_cfp.c
bcm_sf2_regs.h
dsa_loop.c
dsa_loop.h
dsa_loop_bdinfo.c
lan9303-core.c
lan9303.h
lan9303_i2c.c
lan9303_mdio.c
lantiq_gswip.c
lantiq_pce.h
mt7530.c
mt7530.h
mv88e6060.c
mv88e6060.h
qca8k.c
qca8k.h
realtek-smi-core.c
realtek-smi-core.h
rtl8366.c
rtl8366rb.c
vitesse-vsc73xx-core.c
vitesse-vsc73xx-platform.c
vitesse-vsc73xx-spi.c
vitesse-vsc73xx.h
ethernet
fddi
fjes
hamradio
hippi
hyperv
ieee802154
ipvlan
netdevsim
phy
plip
ppp
slip
team
usb
vmxnet3
wan
wimax
wireless
xen-netback
Kconfig
LICENSE.SRC
Makefile
Space.c
dummy.c
eql.c
geneve.c
gtp.c
ifb.c
loopback.c
macsec.c
macvlan.c
macvtap.c
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
sungem_phy.c
tap.c
thunderbolt.c
tun.c
veth.c
virtio_net.c
vrf.c
vsockmon.c
vxlan.c
xen-netfront.c
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
siox
slimbus
sn
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
uwb
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
net
/
dsa
/
microchip
/
ksz_common.h
Copy path
Blame
Blame
Latest commit
History
History
181 lines (149 loc) · 5.22 KB
Breadcrumbs
linux
/
drivers
/
net
/
dsa
/
microchip
/
ksz_common.h
Top
File metadata and controls
Code
Blame
181 lines (149 loc) · 5.22 KB
Raw
/* SPDX-License-Identifier: GPL-2.0 * Microchip switch driver common header * * Copyright (C) 2017-2019 Microchip Technology Inc. */ #ifndef __KSZ_COMMON_H #define __KSZ_COMMON_H #include <linux/regmap.h> void ksz_update_port_member(struct ksz_device *dev, int port); void ksz_init_mib_timer(struct ksz_device *dev); /* Common DSA access functions */ int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg); int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val); void ksz_adjust_link(struct dsa_switch *ds, int port, struct phy_device *phydev); int ksz_sset_count(struct dsa_switch *ds, int port, int sset); void ksz_get_ethtool_stats(struct dsa_switch *ds, int port, uint64_t *buf); int ksz_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br); void ksz_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br); void ksz_port_fast_age(struct dsa_switch *ds, int port); int ksz_port_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan); int ksz_port_fdb_dump(struct dsa_switch *ds, int port, dsa_fdb_dump_cb_t *cb, void *data); int ksz_port_mdb_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb); void ksz_port_mdb_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb); int ksz_port_mdb_del(struct dsa_switch *ds, int port, const struct switchdev_obj_port_mdb *mdb); int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy); void ksz_disable_port(struct dsa_switch *ds, int port); /* Common register access functions */ static inline int ksz_read8(struct ksz_device *dev, u32 reg, u8 *val) { unsigned int value; int ret = regmap_read(dev->regmap[0], reg, &value); *val = value; return ret; } static inline int ksz_read16(struct ksz_device *dev, u32 reg, u16 *val) { unsigned int value; int ret = regmap_read(dev->regmap[1], reg, &value); *val = value; return ret; } static inline int ksz_read32(struct ksz_device *dev, u32 reg, u32 *val) { unsigned int value; int ret = regmap_read(dev->regmap[2], reg, &value); *val = value; return ret; } static inline int ksz_read64(struct ksz_device *dev, u32 reg, u64 *val) { u32 value[2]; int ret; ret = regmap_bulk_read(dev->regmap[2], reg, value, 2); if (!ret) { /* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */ value[0] = swab32(value[0]); value[1] = swab32(value[1]); *val = swab64((u64)*value); } return ret; } static inline int ksz_write8(struct ksz_device *dev, u32 reg, u8 value) { return regmap_write(dev->regmap[0], reg, value); } static inline int ksz_write16(struct ksz_device *dev, u32 reg, u16 value) { return regmap_write(dev->regmap[1], reg, value); } static inline int ksz_write32(struct ksz_device *dev, u32 reg, u32 value) { return regmap_write(dev->regmap[2], reg, value); } static inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value) { u32 val[2]; /* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */ value = swab64(value); val[0] = swab32(value & 0xffffffffULL); val[1] = swab32(value >> 32ULL); return regmap_bulk_write(dev->regmap[2], reg, val, 2); } static inline void ksz_pread8(struct ksz_device *dev, int port, int offset, u8 *data) { ksz_read8(dev, dev->dev_ops->get_port_addr(port, offset), data); } static inline void ksz_pread16(struct ksz_device *dev, int port, int offset, u16 *data) { ksz_read16(dev, dev->dev_ops->get_port_addr(port, offset), data); } static inline void ksz_pread32(struct ksz_device *dev, int port, int offset, u32 *data) { ksz_read32(dev, dev->dev_ops->get_port_addr(port, offset), data); } static inline void ksz_pwrite8(struct ksz_device *dev, int port, int offset, u8 data) { ksz_write8(dev, dev->dev_ops->get_port_addr(port, offset), data); } static inline void ksz_pwrite16(struct ksz_device *dev, int port, int offset, u16 data) { ksz_write16(dev, dev->dev_ops->get_port_addr(port, offset), data); } static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, u32 data) { ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data); } /* Regmap tables generation */ #define KSZ_SPI_OP_RD 3 #define KSZ_SPI_OP_WR 2 #define KSZ_SPI_OP_FLAG_MASK(opcode, swp, regbits, regpad) \ swab##swp((opcode) << ((regbits) + (regpad))) #define KSZ_REGMAP_ENTRY(width, swp, regbits, regpad, regalign) \ { \ .val_bits = (width), \ .reg_stride = (width) / 8, \ .reg_bits = (regbits) + (regalign), \ .pad_bits = (regpad), \ .max_register = BIT(regbits) - 1, \ .cache_type = REGCACHE_NONE, \ .read_flag_mask = \ KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_RD, swp, \ regbits, regpad), \ .write_flag_mask = \ KSZ_SPI_OP_FLAG_MASK(KSZ_SPI_OP_WR, swp, \ regbits, regpad), \ .reg_format_endian = REGMAP_ENDIAN_BIG, \ .val_format_endian = REGMAP_ENDIAN_BIG \ } #define KSZ_REGMAP_TABLE(ksz, swp, regbits, regpad, regalign) \ static const struct regmap_config ksz##_regmap_config[] = { \ KSZ_REGMAP_ENTRY(8, swp, (regbits), (regpad), (regalign)), \ KSZ_REGMAP_ENTRY(16, swp, (regbits), (regpad), (regalign)), \ KSZ_REGMAP_ENTRY(32, swp, (regbits), (regpad), (regalign)), \ } #endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
You can’t perform that action at this time.