Skip to content

Commit 04de8fa

Browse files
khayash1kishon
authored andcommitted
phy: uniphier-pcie: Add legacy SoC support for Pro5
Add legacy SoC support that needs to manage gio clock and reset and to skip setting unimplemented phy parameters. This supports Pro5. This specifies only 1 port use because Pro5 doesn't set it in the power-on sequence. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
1 parent 25858c5 commit 04de8fa

1 file changed

Lines changed: 72 additions & 11 deletions

File tree

‎drivers/phy/socionext/phy-uniphier-pcie.c‎

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include <linux/resource.h>
2020

2121
/* PHY */
22+
#define PCL_PHY_CLKCTRL 0x0000
23+
#define PORT_SEL_MASK GENMASK(11, 9)
24+
#define PORT_SEL_1 FIELD_PREP(PORT_SEL_MASK, 1)
25+
2226
#define PCL_PHY_TEST_I 0x2000
2327
#define PCL_PHY_TEST_O 0x2004
2428
#define TESTI_DAT_MASK GENMASK(13, 6)
@@ -45,13 +49,14 @@
4549
struct uniphier_pciephy_priv {
4650
void __iomem *base;
4751
struct device *dev;
48-
struct clk *clk;
49-
struct reset_control *rst;
52+
struct clk *clk, *clk_gio;
53+
struct reset_control *rst, *rst_gio;
5054
const struct uniphier_pciephy_soc_data *data;
5155
};
5256

5357
struct uniphier_pciephy_soc_data {
5458
bool has_syscon;
59+
bool is_legacy;
5560
};
5661

5762
static void uniphier_pciephy_testio_write(struct uniphier_pciephy_priv *priv,
@@ -111,16 +116,35 @@ static void uniphier_pciephy_deassert(struct uniphier_pciephy_priv *priv)
111116
static int uniphier_pciephy_init(struct phy *phy)
112117
{
113118
struct uniphier_pciephy_priv *priv = phy_get_drvdata(phy);
119+
u32 val;
114120
int ret;
115121

116122
ret = clk_prepare_enable(priv->clk);
117123
if (ret)
118124
return ret;
119125

120-
ret = reset_control_deassert(priv->rst);
126+
ret = clk_prepare_enable(priv->clk_gio);
121127
if (ret)
122128
goto out_clk_disable;
123129

130+
ret = reset_control_deassert(priv->rst);
131+
if (ret)
132+
goto out_clk_gio_disable;
133+
134+
ret = reset_control_deassert(priv->rst_gio);
135+
if (ret)
136+
goto out_rst_assert;
137+
138+
/* support only 1 port */
139+
val = readl(priv->base + PCL_PHY_CLKCTRL);
140+
val &= ~PORT_SEL_MASK;
141+
val |= PORT_SEL_1;
142+
writel(val, priv->base + PCL_PHY_CLKCTRL);
143+
144+
/* legacy controller doesn't have phy_reset and parameters */
145+
if (priv->data->is_legacy)
146+
return 0;
147+
124148
uniphier_pciephy_set_param(priv, PCL_PHY_R00,
125149
RX_EQ_ADJ_EN, RX_EQ_ADJ_EN);
126150
uniphier_pciephy_set_param(priv, PCL_PHY_R06, RX_EQ_ADJ,
@@ -134,6 +158,10 @@ static int uniphier_pciephy_init(struct phy *phy)
134158

135159
return 0;
136160

161+
out_rst_assert:
162+
reset_control_assert(priv->rst);
163+
out_clk_gio_disable:
164+
clk_disable_unprepare(priv->clk_gio);
137165
out_clk_disable:
138166
clk_disable_unprepare(priv->clk);
139167

@@ -144,8 +172,11 @@ static int uniphier_pciephy_exit(struct phy *phy)
144172
{
145173
struct uniphier_pciephy_priv *priv = phy_get_drvdata(phy);
146174

147-
uniphier_pciephy_assert(priv);
175+
if (!priv->data->is_legacy)
176+
uniphier_pciephy_assert(priv);
177+
reset_control_assert(priv->rst_gio);
148178
reset_control_assert(priv->rst);
179+
clk_disable_unprepare(priv->clk_gio);
149180
clk_disable_unprepare(priv->clk);
150181

151182
return 0;
@@ -179,13 +210,32 @@ static int uniphier_pciephy_probe(struct platform_device *pdev)
179210
if (IS_ERR(priv->base))
180211
return PTR_ERR(priv->base);
181212

182-
priv->clk = devm_clk_get(dev, NULL);
183-
if (IS_ERR(priv->clk))
184-
return PTR_ERR(priv->clk);
185-
186-
priv->rst = devm_reset_control_get_shared(dev, NULL);
187-
if (IS_ERR(priv->rst))
188-
return PTR_ERR(priv->rst);
213+
if (priv->data->is_legacy) {
214+
priv->clk_gio = devm_clk_get(dev, "gio");
215+
if (IS_ERR(priv->clk_gio))
216+
return PTR_ERR(priv->clk_gio);
217+
218+
priv->rst_gio =
219+
devm_reset_control_get_shared(dev, "gio");
220+
if (IS_ERR(priv->rst_gio))
221+
return PTR_ERR(priv->rst_gio);
222+
223+
priv->clk = devm_clk_get(dev, "link");
224+
if (IS_ERR(priv->clk))
225+
return PTR_ERR(priv->clk);
226+
227+
priv->rst = devm_reset_control_get_shared(dev, "link");
228+
if (IS_ERR(priv->rst))
229+
return PTR_ERR(priv->rst);
230+
} else {
231+
priv->clk = devm_clk_get(dev, NULL);
232+
if (IS_ERR(priv->clk))
233+
return PTR_ERR(priv->clk);
234+
235+
priv->rst = devm_reset_control_get_shared(dev, NULL);
236+
if (IS_ERR(priv->rst))
237+
return PTR_ERR(priv->rst);
238+
}
189239

190240
phy = devm_phy_create(dev, dev->of_node, &uniphier_pciephy_ops);
191241
if (IS_ERR(phy))
@@ -203,15 +253,26 @@ static int uniphier_pciephy_probe(struct platform_device *pdev)
203253
return PTR_ERR_OR_ZERO(phy_provider);
204254
}
205255

256+
static const struct uniphier_pciephy_soc_data uniphier_pro5_data = {
257+
.has_syscon = false,
258+
.is_legacy = true,
259+
};
260+
206261
static const struct uniphier_pciephy_soc_data uniphier_ld20_data = {
207262
.has_syscon = true,
263+
.is_legacy = false,
208264
};
209265

210266
static const struct uniphier_pciephy_soc_data uniphier_pxs3_data = {
211267
.has_syscon = false,
268+
.is_legacy = false,
212269
};
213270

214271
static const struct of_device_id uniphier_pciephy_match[] = {
272+
{
273+
.compatible = "socionext,uniphier-pro5-pcie-phy",
274+
.data = &uniphier_pro5_data,
275+
},
215276
{
216277
.compatible = "socionext,uniphier-ld20-pcie-phy",
217278
.data = &uniphier_ld20_data,

0 commit comments

Comments
 (0)