Skip to content

Commit d763fff

Browse files
Siddharth-Vadapalli-at-TIgregkh
authored andcommitted
PCI: j721e: Enable ACSPCIE Refclk if "ti,syscon-acspcie-proxy-ctrl" exists
[ Upstream commit 82c4be4 ] The ACSPCIE module is capable of driving the reference clock required by the PCIe Endpoint device. It is an alternative to on-board and external reference clock generators. Enabling the output from the ACSPCIE module's PAD IO Buffers requires clearing the "PAD IO disable" bits of the ACSPCIE_PROXY_CTRL register in the CTRL_MMR register space. Add support to enable the ACSPCIE reference clock output using the optional device-tree property "ti,syscon-acspcie-proxy-ctrl". Link: https://lore.kernel.org/linux-pci/20240829105316.1483684-3-s-vadapalli@ti.com Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Stable-dep-of: f842d33 ("PCI: j721e: Fix programming sequence of "strap" settings") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 92b82e2 commit d763fff

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum link_status {
4848
#define J721E_MODE_RC BIT(7)
4949
#define LANE_COUNT(n) ((n) << 8)
5050

51+
#define ACSPCIE_PAD_DISABLE_MASK GENMASK(1, 0)
5152
#define GENERATION_SEL_MASK GENMASK(1, 0)
5253

5354
struct j721e_pcie {
@@ -225,6 +226,36 @@ static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie,
225226
return ret;
226227
}
227228

229+
static int j721e_enable_acspcie_refclk(struct j721e_pcie *pcie,
230+
struct regmap *syscon)
231+
{
232+
struct device *dev = pcie->cdns_pcie->dev;
233+
struct device_node *node = dev->of_node;
234+
u32 mask = ACSPCIE_PAD_DISABLE_MASK;
235+
struct of_phandle_args args;
236+
u32 val;
237+
int ret;
238+
239+
ret = of_parse_phandle_with_fixed_args(node,
240+
"ti,syscon-acspcie-proxy-ctrl",
241+
1, 0, &args);
242+
if (ret) {
243+
dev_err(dev,
244+
"ti,syscon-acspcie-proxy-ctrl has invalid arguments\n");
245+
return ret;
246+
}
247+
248+
/* Clear PAD IO disable bits to enable refclk output */
249+
val = ~(args.args[0]);
250+
ret = regmap_update_bits(syscon, 0, mask, val);
251+
if (ret) {
252+
dev_err(dev, "failed to enable ACSPCIE refclk: %d\n", ret);
253+
return ret;
254+
}
255+
256+
return 0;
257+
}
258+
228259
static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
229260
{
230261
struct device *dev = pcie->cdns_pcie->dev;
@@ -264,7 +295,13 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
264295
return ret;
265296
}
266297

267-
return 0;
298+
/* Enable ACSPCIE refclk output if the optional property exists */
299+
syscon = syscon_regmap_lookup_by_phandle_optional(node,
300+
"ti,syscon-acspcie-proxy-ctrl");
301+
if (!syscon)
302+
return 0;
303+
304+
return j721e_enable_acspcie_refclk(pcie, syscon);
268305
}
269306

270307
static int cdns_ti_pcie_config_read(struct pci_bus *bus, unsigned int devfn,

0 commit comments

Comments
 (0)