1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Marvell 88E6xxx Switch Hidden Registers support
5 * Copyright (c) 2008 Marvell Semiconductor
7 * Copyright (c) 2019 Andrew Lunn <andrew@lunn.ch>
10 #include <linux/bitfield.h>
15 /* The mv88e6390 and mv88e6341 have some hidden registers used for debug and
16 * development. The errata also makes use of them.
18 int mv88e6xxx_port_hidden_write(struct mv88e6xxx_chip
*chip
, int block
,
19 int port
, int reg
, u16 val
)
24 err
= mv88e6xxx_port_write(chip
, MV88E6XXX_PORT_RESERVED_1A_DATA_PORT
,
25 MV88E6XXX_PORT_RESERVED_1A
, val
);
29 ctrl
= MV88E6XXX_PORT_RESERVED_1A_BUSY
|
30 MV88E6XXX_PORT_RESERVED_1A_WRITE
|
31 block
<< MV88E6XXX_PORT_RESERVED_1A_BLOCK_SHIFT
|
32 port
<< MV88E6XXX_PORT_RESERVED_1A_PORT_SHIFT
|
35 return mv88e6xxx_port_write(chip
, MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT
,
36 MV88E6XXX_PORT_RESERVED_1A
, ctrl
);
39 int mv88e6xxx_port_hidden_wait(struct mv88e6xxx_chip
*chip
)
41 int bit
= __bf_shf(MV88E6XXX_PORT_RESERVED_1A_BUSY
);
43 return mv88e6xxx_wait_bit(chip
, MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT
,
44 MV88E6XXX_PORT_RESERVED_1A
, bit
, 0);
47 int mv88e6xxx_port_hidden_read(struct mv88e6xxx_chip
*chip
, int block
, int port
,
53 ctrl
= MV88E6XXX_PORT_RESERVED_1A_BUSY
|
54 MV88E6XXX_PORT_RESERVED_1A_READ
|
55 block
<< MV88E6XXX_PORT_RESERVED_1A_BLOCK_SHIFT
|
56 port
<< MV88E6XXX_PORT_RESERVED_1A_PORT_SHIFT
|
59 err
= mv88e6xxx_port_write(chip
, MV88E6XXX_PORT_RESERVED_1A_CTRL_PORT
,
60 MV88E6XXX_PORT_RESERVED_1A
, ctrl
);
64 err
= mv88e6xxx_port_hidden_wait(chip
);
68 return mv88e6xxx_port_read(chip
, MV88E6XXX_PORT_RESERVED_1A_DATA_PORT
,
69 MV88E6XXX_PORT_RESERVED_1A
, val
);