Skip to content

Commit 7dcf07a

Browse files
kishonLorenzo Pieralisi
authored andcommitted
PCI: keystone: Use phandle argument from "ti,syscon-pcie-id"/"ti,syscon-pcie-mode"
Get "syscon" pcie_mode and pcie_id offset from the argument of "ti,syscon-pcie-id" and "ti,syscon-pcie-mode" phandle respectively. Previously a subnode to "syscon" node was added which has the exact memory mapped address of pcie_mode and pcie_id but now the offset of pcie_mode and pcie_id within "syscon" is now being passed as argument to "ti,syscon-pcie-id" and "ti,syscon-pcie-mode" phandle. If the offset is not provided in "ti,syscon-pcie-id"/"ti,syscon-pcie-mode", the full memory mapped address of pcie_ctrl is used in order to maintain old DT compatibility. Similar change for J721E is as discussed in [1] [1] -> http://lore.kernel.org/r/CAL_JsqKiUcO76bo1GoepWM1TusJWoty_BRy2hFSgtEVMqtrvvQ@mail.gmail.com Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]>
1 parent d91e775 commit 7dcf07a

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,19 @@ static int __init ks_pcie_init_id(struct keystone_pcie *ks_pcie)
775775
struct dw_pcie *pci = ks_pcie->pci;
776776
struct device *dev = pci->dev;
777777
struct device_node *np = dev->of_node;
778+
struct of_phandle_args args;
779+
unsigned int offset = 0;
778780

779781
devctrl_regs = syscon_regmap_lookup_by_phandle(np, "ti,syscon-pcie-id");
780782
if (IS_ERR(devctrl_regs))
781783
return PTR_ERR(devctrl_regs);
782784

783-
ret = regmap_read(devctrl_regs, 0, &id);
785+
/* Do not error out to maintain old DT compatibility */
786+
ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-pcie-id", 1, 0, &args);
787+
if (!ret)
788+
offset = args.args[0];
789+
790+
ret = regmap_read(devctrl_regs, offset, &id);
784791
if (ret)
785792
return ret;
786793

@@ -989,6 +996,8 @@ static int ks_pcie_enable_phy(struct keystone_pcie *ks_pcie)
989996
static int ks_pcie_set_mode(struct device *dev)
990997
{
991998
struct device_node *np = dev->of_node;
999+
struct of_phandle_args args;
1000+
unsigned int offset = 0;
9921001
struct regmap *syscon;
9931002
u32 val;
9941003
u32 mask;
@@ -998,10 +1007,15 @@ static int ks_pcie_set_mode(struct device *dev)
9981007
if (IS_ERR(syscon))
9991008
return 0;
10001009

1010+
/* Do not error out to maintain old DT compatibility */
1011+
ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-pcie-mode", 1, 0, &args);
1012+
if (!ret)
1013+
offset = args.args[0];
1014+
10011015
mask = KS_PCIE_DEV_TYPE_MASK | KS_PCIE_SYSCLOCKOUTEN;
10021016
val = KS_PCIE_DEV_TYPE(RC) | KS_PCIE_SYSCLOCKOUTEN;
10031017

1004-
ret = regmap_update_bits(syscon, 0, mask, val);
1018+
ret = regmap_update_bits(syscon, offset, mask, val);
10051019
if (ret) {
10061020
dev_err(dev, "failed to set pcie mode\n");
10071021
return ret;
@@ -1014,6 +1028,8 @@ static int ks_pcie_am654_set_mode(struct device *dev,
10141028
enum dw_pcie_device_mode mode)
10151029
{
10161030
struct device_node *np = dev->of_node;
1031+
struct of_phandle_args args;
1032+
unsigned int offset = 0;
10171033
struct regmap *syscon;
10181034
u32 val;
10191035
u32 mask;
@@ -1023,6 +1039,11 @@ static int ks_pcie_am654_set_mode(struct device *dev,
10231039
if (IS_ERR(syscon))
10241040
return 0;
10251041

1042+
/* Do not error out to maintain old DT compatibility */
1043+
ret = of_parse_phandle_with_fixed_args(np, "ti,syscon-pcie-mode", 1, 0, &args);
1044+
if (!ret)
1045+
offset = args.args[0];
1046+
10261047
mask = AM654_PCIE_DEV_TYPE_MASK;
10271048

10281049
switch (mode) {
@@ -1037,7 +1058,7 @@ static int ks_pcie_am654_set_mode(struct device *dev,
10371058
return -EINVAL;
10381059
}
10391060

1040-
ret = regmap_update_bits(syscon, 0, mask, val);
1061+
ret = regmap_update_bits(syscon, offset, mask, val);
10411062
if (ret) {
10421063
dev_err(dev, "failed to set pcie mode\n");
10431064
return ret;

0 commit comments

Comments
 (0)