net: dsa: lan9303: Multiply by 4 to get MDIO register
authorEgil Hjelmeland <privat@egil-hjelmeland.no>
Sun, 30 Jul 2017 17:58:54 +0000 (19:58 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 31 Jul 2017 02:23:29 +0000 (19:23 -0700)
lan9303_mdio_write()/_read() must multiply register number by 4 to get
offset.

Added some commments to the register definitions.

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/lan9303-core.c
drivers/net/dsa/lan9303_mdio.c

index 9d0ab77edb4ae2630830026b642d2003e8020a15..96ebeb9bd59abbcc063f7effc6887f0f58ffa42a 100644 (file)
@@ -20,6 +20,9 @@
 
 #include "lan9303.h"
 
+/* 13.2 System Control and Status Registers
+ * Multiply register number by 4 to get address offset.
+ */
 #define LAN9303_CHIP_REV 0x14
 # define LAN9303_CHIP_ID 0x9303
 #define LAN9303_IRQ_CFG 0x15
@@ -53,6 +56,9 @@
 #define LAN9303_VIRT_PHY_BASE 0x70
 #define LAN9303_VIRT_SPECIAL_CTRL 0x77
 
+/*13.4 Switch Fabric Control and Status Registers
+ * Accessed indirectly via SWITCH_CSR_CMD, SWITCH_CSR_DATA.
+ */
 #define LAN9303_SW_DEV_ID 0x0000
 #define LAN9303_SW_RESET 0x0001
 #define LAN9303_SW_RESET_RESET BIT(0)
index 93c36c0541cf95fc9f6a73c6442a2e5cc3136736..2db7970fc88ce57b729b6fe004ab65c2f66f872a 100644 (file)
@@ -40,6 +40,7 @@ static int lan9303_mdio_write(void *ctx, uint32_t reg, uint32_t val)
 {
        struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx;
 
+       reg <<= 2; /* reg num to offset */
        mutex_lock(&sw_dev->device->bus->mdio_lock);
        lan9303_mdio_real_write(sw_dev->device, reg, val & 0xffff);
        lan9303_mdio_real_write(sw_dev->device, reg + 2, (val >> 16) & 0xffff);
@@ -57,6 +58,7 @@ static int lan9303_mdio_read(void *ctx, uint32_t reg, uint32_t *val)
 {
        struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx;
 
+       reg <<= 2; /* reg num to offset */
        mutex_lock(&sw_dev->device->bus->mdio_lock);
        *val = lan9303_mdio_real_read(sw_dev->device, reg);
        *val |= (lan9303_mdio_real_read(sw_dev->device, reg + 2) << 16);