Commit bf0a6dae authored by David S. Miller's avatar David S. Miller

Merge branch 'mediatek-reset-flow'

Sean Wang says:

====================
mediatek: add enhancement into the existing reset flow

Current driver only resets DMA used by descriptor rings which
can't guarantee it can recover all various kinds of fatal
errors, so the patch
1) tries to reset the underlying hardware resource from scratch on
Mediatek SoC required for ethernet running.
2) refactors code in order to the reusability of existing code.
3) considers handling for race condition between the reset flow and
callbacks registered into core driver called about hardware accessing.
4) introduces power domain usage to hardware setup which leads to have
cleanly and completely restore to the state as the initial.

Changes since v1:
- fix the build error with module built causing undefined symbol for
  pinctrl_bind_pins, so using pinctrl_select_state instead accomplishes
  the pin mux setup during the reset process.
====================
Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 364eac0c dce6fa42
This diff is collapsed.
...@@ -266,6 +266,11 @@ ...@@ -266,6 +266,11 @@
#define SYSCFG0_GE_MASK 0x3 #define SYSCFG0_GE_MASK 0x3
#define SYSCFG0_GE_MODE(x, y) (x << (12 + (y * 2))) #define SYSCFG0_GE_MODE(x, y) (x << (12 + (y * 2)))
/*ethernet reset control register*/
#define ETHSYS_RSTCTRL 0x34
#define RSTCTRL_FE BIT(6)
#define RSTCTRL_PPE BIT(31)
struct mtk_rx_dma { struct mtk_rx_dma {
unsigned int rxd1; unsigned int rxd1;
unsigned int rxd2; unsigned int rxd2;
...@@ -330,6 +335,11 @@ enum mtk_clks_map { ...@@ -330,6 +335,11 @@ enum mtk_clks_map {
MTK_CLK_MAX MTK_CLK_MAX
}; };
enum mtk_dev_state {
MTK_HW_INIT,
MTK_RESETTING
};
/* struct mtk_tx_buf - This struct holds the pointers to the memory pointed at /* struct mtk_tx_buf - This struct holds the pointers to the memory pointed at
* by the TX descriptor s * by the TX descriptor s
* @skb: The SKB pointer of the packet being sent * @skb: The SKB pointer of the packet being sent
...@@ -413,12 +423,12 @@ struct mtk_rx_ring { ...@@ -413,12 +423,12 @@ struct mtk_rx_ring {
* @clks: clock array for all clocks required * @clks: clock array for all clocks required
* @mii_bus: If there is a bus we need to create an instance for it * @mii_bus: If there is a bus we need to create an instance for it
* @pending_work: The workqueue used to reset the dma ring * @pending_work: The workqueue used to reset the dma ring
* @state Initialization and runtime state of the device.
*/ */
struct mtk_eth { struct mtk_eth {
struct device *dev; struct device *dev;
void __iomem *base; void __iomem *base;
struct reset_control *rstc;
spinlock_t page_lock; spinlock_t page_lock;
spinlock_t irq_lock; spinlock_t irq_lock;
struct net_device dummy_dev; struct net_device dummy_dev;
...@@ -441,11 +451,13 @@ struct mtk_eth { ...@@ -441,11 +451,13 @@ struct mtk_eth {
struct mii_bus *mii_bus; struct mii_bus *mii_bus;
struct work_struct pending_work; struct work_struct pending_work;
unsigned long state;
}; };
/* struct mtk_mac - the structure that holds the info about the MACs of the /* struct mtk_mac - the structure that holds the info about the MACs of the
* SoC * SoC
* @id: The number of the MAC * @id: The number of the MAC
* @ge_mode: Interface mode kept for setup restoring
* @of_node: Our devicetree node * @of_node: Our devicetree node
* @hw: Backpointer to our main datastruture * @hw: Backpointer to our main datastruture
* @hw_stats: Packet statistics counter * @hw_stats: Packet statistics counter
...@@ -453,6 +465,7 @@ struct mtk_eth { ...@@ -453,6 +465,7 @@ struct mtk_eth {
*/ */
struct mtk_mac { struct mtk_mac {
int id; int id;
int ge_mode;
struct device_node *of_node; struct device_node *of_node;
struct mtk_eth *hw; struct mtk_eth *hw;
struct mtk_hw_stats *hw_stats; struct mtk_hw_stats *hw_stats;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment