OSDN Git Service

net: atlantic: add hw_soft_reset, hw_prepare to hw_ops
authorMark Starovoytov <mstarovoitov@marvell.com>
Thu, 30 Apr 2020 08:04:32 +0000 (11:04 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 May 2020 22:37:57 +0000 (15:37 -0700)
A2 will have a different implementation of these 2 APIs, so
this patch moves them to hw_ops in preparation for A2.

Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com>
Co-developed-by: Dmitry Bezrukov <dbezrukov@marvell.com>
Signed-off-by: Dmitry Bezrukov <dbezrukov@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/aquantia/atlantic/aq_hw.h
drivers/net/ethernet/aquantia/atlantic/aq_nic.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c

index 7d71bc7..84abce2 100644 (file)
@@ -182,6 +182,11 @@ struct aq_hw_ops {
 
        int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
 
+       int (*hw_soft_reset)(struct aq_hw_s *self);
+
+       int (*hw_prepare)(struct aq_hw_s *self,
+                         const struct aq_fw_ops **fw_ops);
+
        int (*hw_reset)(struct aq_hw_s *self);
 
        int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
index 80dd744..7f4d8ab 100644 (file)
@@ -257,6 +257,20 @@ static void aq_nic_polling_timer_cb(struct timer_list *t)
                  AQ_CFG_POLLING_TIMER_INTERVAL);
 }
 
+static int aq_nic_hw_prepare(struct aq_nic_s *self)
+{
+       int err = 0;
+
+       err = self->aq_hw_ops->hw_soft_reset(self->aq_hw);
+       if (err)
+               goto exit;
+
+       err = self->aq_hw_ops->hw_prepare(self->aq_hw, &self->aq_fw_ops);
+
+exit:
+       return err;
+}
+
 int aq_nic_ndev_register(struct aq_nic_s *self)
 {
        int err = 0;
@@ -266,7 +280,7 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
                goto err_exit;
        }
 
-       err = hw_atl_utils_initfw(self->aq_hw, &self->aq_fw_ops);
+       err = aq_nic_hw_prepare(self);
        if (err)
                goto err_exit;
 
index 9b1062b..2dba8c2 100644 (file)
@@ -886,6 +886,8 @@ static int hw_atl_a0_hw_ring_rx_stop(struct aq_hw_s *self,
 }
 
 const struct aq_hw_ops hw_atl_ops_a0 = {
+       .hw_soft_reset        = hw_atl_utils_soft_reset,
+       .hw_prepare           = hw_atl_utils_initfw,
        .hw_set_mac_address   = hw_atl_a0_hw_mac_addr_set,
        .hw_init              = hw_atl_a0_hw_init,
        .hw_reset             = hw_atl_a0_hw_reset,
index d20d91c..4e2e4ee 100644 (file)
@@ -1478,6 +1478,8 @@ static int hw_atl_b0_set_loopback(struct aq_hw_s *self, u32 mode, bool enable)
 }
 
 const struct aq_hw_ops hw_atl_ops_b0 = {
+       .hw_soft_reset        = hw_atl_utils_soft_reset,
+       .hw_prepare           = hw_atl_utils_initfw,
        .hw_set_mac_address   = hw_atl_b0_hw_mac_addr_set,
        .hw_init              = hw_atl_b0_hw_init,
        .hw_reset             = hw_atl_b0_hw_reset,
index 354705f..7259bcb 100644 (file)
@@ -67,10 +67,6 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops)
 {
        int err = 0;
 
-       err = hw_atl_utils_soft_reset(self);
-       if (err)
-               return err;
-
        hw_atl_utils_hw_chip_features_init(self,
                                           &self->chip_features);