Skip to content

Commit 0dfa6f6

Browse files
committed
Merge branch 'remotes/lorenzo/pci/keystone'
- Add register offset for ti,syscon-pcie-id and ti,syscon-pcie-mode DT properties (Kishon Vijay Abraham I) * remotes/lorenzo/pci/keystone: PCI: keystone: Use phandle argument from "ti,syscon-pcie-id"/"ti,syscon-pcie-mode" dt-bindings: PCI: ti,am65: Fix "ti,syscon-pcie-id"/"ti,syscon-pcie-mode" to take argument
2 parents 6553ff3 + 7dcf07a commit 0dfa6f6

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

Documentation/devicetree/bindings/pci/ti,am65-pci-ep.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ properties:
3232
maxItems: 1
3333

3434
ti,syscon-pcie-mode:
35+
$ref: /schemas/types.yaml#/definitions/phandle-array
36+
items:
37+
- items:
38+
- description: Phandle to the SYSCON entry
39+
- description: pcie_ctrl register offset within SYSCON
3540
description: Phandle to the SYSCON entry required for configuring PCIe in RC or EP mode.
36-
$ref: /schemas/types.yaml#/definitions/phandle
3741

3842
interrupts:
3943
minItems: 1
@@ -65,7 +69,7 @@ examples:
6569
<0x5506000 0x1000>;
6670
reg-names = "app", "dbics", "addr_space", "atu";
6771
power-domains = <&k3_pds 120 TI_SCI_PD_EXCLUSIVE>;
68-
ti,syscon-pcie-mode = <&pcie0_mode>;
72+
ti,syscon-pcie-mode = <&scm_conf 0x4060>;
6973
num-ib-windows = <16>;
7074
num-ob-windows = <16>;
7175
max-link-speed = <2>;

Documentation/devicetree/bindings/pci/ti,am65-pci-host.yaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,20 @@ properties:
3333
maxItems: 1
3434

3535
ti,syscon-pcie-id:
36+
$ref: /schemas/types.yaml#/definitions/phandle-array
37+
items:
38+
- items:
39+
- description: Phandle to the SYSCON entry
40+
- description: pcie_device_id register offset within SYSCON
3641
description: Phandle to the SYSCON entry required for getting PCIe device/vendor ID
37-
$ref: /schemas/types.yaml#/definitions/phandle
3842

3943
ti,syscon-pcie-mode:
44+
$ref: /schemas/types.yaml#/definitions/phandle-array
45+
items:
46+
- items:
47+
- description: Phandle to the SYSCON entry
48+
- description: pcie_ctrl register offset within SYSCON
4049
description: Phandle to the SYSCON entry required for configuring PCIe in RC or EP mode.
41-
$ref: /schemas/types.yaml#/definitions/phandle
4250

4351
msi-map: true
4452

@@ -84,8 +92,8 @@ examples:
8492
#size-cells = <2>;
8593
ranges = <0x81000000 0 0 0x10020000 0 0x00010000>,
8694
<0x82000000 0 0x10030000 0x10030000 0 0x07FD0000>;
87-
ti,syscon-pcie-id = <&pcie_devid>;
88-
ti,syscon-pcie-mode = <&pcie0_mode>;
95+
ti,syscon-pcie-id = <&scm_conf 0x0210>;
96+
ti,syscon-pcie-mode = <&scm_conf 0x4060>;
8997
bus-range = <0x0 0xff>;
9098
num-viewport = <16>;
9199
max-link-speed = <2>;

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)