OSDN Git Service

70f227fb69a1f0c0e6050527a85e887e9633a713
[immortalwrt/immortalwrt.git] / target / linux / generic / backport-5.15 / 747-v5.16-12-net-dsa-qca8k-add-support-for-QCA8328.patch
1 From f477d1c8bdbef4f400718238e350f16f521d2a3e Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Thu, 14 Oct 2021 00:39:17 +0200
4 Subject: net: dsa: qca8k: add support for QCA8328
5
6 QCA8328 switch is the bigger brother of the qca8327. Same regs different
7 chip. Change the function to set the correct pin layout and introduce a
8 new match_data to differentiate the 2 switch as they have the same ID
9 and their internal PHY have the same ID.
10
11 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
12 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15  drivers/net/dsa/qca8k.c | 19 ++++++++++++++++---
16  drivers/net/dsa/qca8k.h |  1 +
17  2 files changed, 17 insertions(+), 3 deletions(-)
18
19 --- a/drivers/net/dsa/qca8k.c
20 +++ b/drivers/net/dsa/qca8k.c
21 @@ -935,6 +935,7 @@ static int
22  qca8k_setup_of_pws_reg(struct qca8k_priv *priv)
23  {
24         struct device_node *node = priv->dev->of_node;
25 +       const struct qca8k_match_data *data;
26         u32 val = 0;
27         int ret;
28  
29 @@ -943,8 +944,14 @@ qca8k_setup_of_pws_reg(struct qca8k_priv
30          * Should be applied by default but we set this just to make sure.
31          */
32         if (priv->switch_id == QCA8K_ID_QCA8327) {
33 +               data = of_device_get_match_data(priv->dev);
34 +
35 +               /* Set the correct package of 148 pin for QCA8327 */
36 +               if (data->reduced_package)
37 +                       val |= QCA8327_PWS_PACKAGE148_EN;
38 +
39                 ret = qca8k_rmw(priv, QCA8K_REG_PWS, QCA8327_PWS_PACKAGE148_EN,
40 -                               QCA8327_PWS_PACKAGE148_EN);
41 +                               val);
42                 if (ret)
43                         return ret;
44         }
45 @@ -2105,7 +2112,12 @@ static int qca8k_resume(struct device *d
46  static SIMPLE_DEV_PM_OPS(qca8k_pm_ops,
47                          qca8k_suspend, qca8k_resume);
48  
49 -static const struct qca8k_match_data qca832x = {
50 +static const struct qca8k_match_data qca8327 = {
51 +       .id = QCA8K_ID_QCA8327,
52 +       .reduced_package = true,
53 +};
54 +
55 +static const struct qca8k_match_data qca8328 = {
56         .id = QCA8K_ID_QCA8327,
57  };
58  
59 @@ -2114,7 +2126,8 @@ static const struct qca8k_match_data qca
60  };
61  
62  static const struct of_device_id qca8k_of_match[] = {
63 -       { .compatible = "qca,qca8327", .data = &qca832x },
64 +       { .compatible = "qca,qca8327", .data = &qca8327 },
65 +       { .compatible = "qca,qca8328", .data = &qca8328 },
66         { .compatible = "qca,qca8334", .data = &qca833x },
67         { .compatible = "qca,qca8337", .data = &qca833x },
68         { /* sentinel */ },
69 --- a/drivers/net/dsa/qca8k.h
70 +++ b/drivers/net/dsa/qca8k.h
71 @@ -260,6 +260,7 @@ struct ar8xxx_port_status {
72  
73  struct qca8k_match_data {
74         u8 id;
75 +       bool reduced_package;
76  };
77  
78  enum {