Skip to content

Commit 82c4be4

Browse files
PCI: j721e: Enable ACSPCIE Refclk if "ti,syscon-acspcie-proxy-ctrl" exists
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>
1 parent cb08c3a commit 82c4be4

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
@@ -44,6 +44,7 @@ enum link_status {
4444
#define J721E_MODE_RC BIT(7)
4545
#define LANE_COUNT(n) ((n) << 8)
4646

47+
#define ACSPCIE_PAD_DISABLE_MASK GENMASK(1, 0)
4748
#define GENERATION_SEL_MASK GENMASK(1, 0)
4849

4950
struct j721e_pcie {
@@ -220,6 +221,36 @@ static int j721e_pcie_set_lane_count(struct j721e_pcie *pcie,
220221
return ret;
221222
}
222223

224+
static int j721e_enable_acspcie_refclk(struct j721e_pcie *pcie,
225+
struct regmap *syscon)
226+
{
227+
struct device *dev = pcie->cdns_pcie->dev;
228+
struct device_node *node = dev->of_node;
229+
u32 mask = ACSPCIE_PAD_DISABLE_MASK;
230+
struct of_phandle_args args;
231+
u32 val;
232+
int ret;
233+
234+
ret = of_parse_phandle_with_fixed_args(node,
235+
"ti,syscon-acspcie-proxy-ctrl",
236+
1, 0, &args);
237+
if (ret) {
238+
dev_err(dev,
239+
"ti,syscon-acspcie-proxy-ctrl has invalid arguments\n");
240+
return ret;
241+
}
242+
243+
/* Clear PAD IO disable bits to enable refclk output */
244+
val = ~(args.args[0]);
245+
ret = regmap_update_bits(syscon, 0, mask, val);
246+
if (ret) {
247+
dev_err(dev, "failed to enable ACSPCIE refclk: %d\n", ret);
248+
return ret;
249+
}
250+
251+
return 0;
252+
}
253+
223254
static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
224255
{
225256
struct device *dev = pcie->cdns_pcie->dev;
@@ -259,7 +290,13 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
259290
return ret;
260291
}
261292

262-
return 0;
293+
/* Enable ACSPCIE refclk output if the optional property exists */
294+
syscon = syscon_regmap_lookup_by_phandle_optional(node,
295+
"ti,syscon-acspcie-proxy-ctrl");
296+
if (!syscon)
297+
return 0;
298+
299+
return j721e_enable_acspcie_refclk(pcie, syscon);
263300
}
264301

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

0 commit comments

Comments
 (0)