aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-08-29 19:23:33 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-08-29 19:23:33 -0400
commite89c33168aad32436da842ddda307dcc31c0c4e2 (patch)
tree831668bbda77e4b5ff463b26a75c8f88819436aa
parent2e8b5f621dbe29425906852c6079afb6b28720cb (diff)
parent3dc48af310709b85d07c8b0d3aa8f1ead02829d3 (diff)
Merge branch 'pci/misc' into next
* pci/misc: PCI/ACPI: Fix _OSC ordering to allow PCIe hotplug use when available PCI: exynos: Add I/O access wrappers PCI: designware: Drop "addr" arg from dw_pcie_readl_rc()/dw_pcie_writel_rc()
-rw-r--r--drivers/acpi/pci_root.c62
-rw-r--r--drivers/pci/host/pci-exynos.c160
-rw-r--r--drivers/pci/host/pcie-designware.c135
3 files changed, 184 insertions, 173 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index ce04eb28e029..d3874f425653 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -378,6 +378,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
378 struct acpi_pci_root *root; 378 struct acpi_pci_root *root;
379 u32 flags, base_flags; 379 u32 flags, base_flags;
380 acpi_handle handle = device->handle; 380 acpi_handle handle = device->handle;
381 bool no_aspm = false, clear_aspm = false;
381 382
382 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 383 root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
383 if (!root) 384 if (!root)
@@ -437,27 +438,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
437 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT; 438 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
438 acpi_pci_osc_support(root, flags); 439 acpi_pci_osc_support(root, flags);
439 440
440 /*
441 * TBD: Need PCI interface for enumeration/configuration of roots.
442 */
443
444 /*
445 * Scan the Root Bridge
446 * --------------------
447 * Must do this prior to any attempt to bind the root device, as the
448 * PCI namespace does not get created until this call is made (and
449 * thus the root bridge's pci_dev does not exist).
450 */
451 root->bus = pci_acpi_scan_root(root);
452 if (!root->bus) {
453 dev_err(&device->dev,
454 "Bus %04x:%02x not present in PCI namespace\n",
455 root->segment, (unsigned int)root->secondary.start);
456 result = -ENODEV;
457 goto end;
458 }
459
460 /* Indicate support for various _OSC capabilities. */
461 if (pci_ext_cfg_avail()) 441 if (pci_ext_cfg_avail())
462 flags |= OSC_EXT_PCI_CONFIG_SUPPORT; 442 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
463 if (pcie_aspm_support_enabled()) { 443 if (pcie_aspm_support_enabled()) {
@@ -471,7 +451,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
471 if (ACPI_FAILURE(status)) { 451 if (ACPI_FAILURE(status)) {
472 dev_info(&device->dev, "ACPI _OSC support " 452 dev_info(&device->dev, "ACPI _OSC support "
473 "notification failed, disabling PCIe ASPM\n"); 453 "notification failed, disabling PCIe ASPM\n");
474 pcie_no_aspm(); 454 no_aspm = true;
475 flags = base_flags; 455 flags = base_flags;
476 } 456 }
477 } 457 }
@@ -503,7 +483,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
503 * We have ASPM control, but the FADT indicates 483 * We have ASPM control, but the FADT indicates
504 * that it's unsupported. Clear it. 484 * that it's unsupported. Clear it.
505 */ 485 */
506 pcie_clear_aspm(root->bus); 486 clear_aspm = true;
507 } 487 }
508 } else { 488 } else {
509 dev_info(&device->dev, 489 dev_info(&device->dev,
@@ -512,7 +492,14 @@ static int acpi_pci_root_add(struct acpi_device *device,
512 acpi_format_exception(status), flags); 492 acpi_format_exception(status), flags);
513 dev_info(&device->dev, 493 dev_info(&device->dev,
514 "ACPI _OSC control for PCIe not granted, disabling ASPM\n"); 494 "ACPI _OSC control for PCIe not granted, disabling ASPM\n");
515 pcie_no_aspm(); 495 /*
496 * We want to disable ASPM here, but aspm_disabled
497 * needs to remain in its state from boot so that we
498 * properly handle PCIe 1.1 devices. So we set this
499 * flag here, to defer the action until after the ACPI
500 * root scan.
501 */
502 no_aspm = true;
516 } 503 }
517 } else { 504 } else {
518 dev_info(&device->dev, 505 dev_info(&device->dev,
@@ -520,6 +507,33 @@ static int acpi_pci_root_add(struct acpi_device *device,
520 "(_OSC support mask: 0x%02x)\n", flags); 507 "(_OSC support mask: 0x%02x)\n", flags);
521 } 508 }
522 509
510 /*
511 * TBD: Need PCI interface for enumeration/configuration of roots.
512 */
513
514 /*
515 * Scan the Root Bridge
516 * --------------------
517 * Must do this prior to any attempt to bind the root device, as the
518 * PCI namespace does not get created until this call is made (and
519 * thus the root bridge's pci_dev does not exist).
520 */
521 root->bus = pci_acpi_scan_root(root);
522 if (!root->bus) {
523 dev_err(&device->dev,
524 "Bus %04x:%02x not present in PCI namespace\n",
525 root->segment, (unsigned int)root->secondary.start);
526 result = -ENODEV;
527 goto end;
528 }
529
530 if (clear_aspm) {
531 dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n");
532 pcie_clear_aspm(root->bus);
533 }
534 if (no_aspm)
535 pcie_no_aspm();
536
523 pci_acpi_add_bus_pm_notifier(device, root->bus); 537 pci_acpi_add_bus_pm_notifier(device, root->bus);
524 if (device->wakeup.flags.run_wake) 538 if (device->wakeup.flags.run_wake)
525 device_set_run_wake(root->bus->bridge, true); 539 device_set_run_wake(root->bus->bridge, true);
diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c
index 012ca8aec71a..94e096bb2d0a 100644
--- a/drivers/pci/host/pci-exynos.c
+++ b/drivers/pci/host/pci-exynos.c
@@ -91,19 +91,49 @@ struct exynos_pcie {
91#define PCIE_PHY_TRSV3_RXCDR 0x2ec 91#define PCIE_PHY_TRSV3_RXCDR 0x2ec
92#define PCIE_PHY_TRSV3_LVCC 0x31c 92#define PCIE_PHY_TRSV3_LVCC 0x31c
93 93
94static inline void exynos_elb_writel(struct exynos_pcie *pcie, u32 val, u32 reg)
95{
96 writel(val, pcie->elbi_base + reg);
97}
98
99static inline u32 exynos_elb_readl(struct exynos_pcie *pcie, u32 reg)
100{
101 return readl(pcie->elbi_base + reg);
102}
103
104static inline void exynos_phy_writel(struct exynos_pcie *pcie, u32 val, u32 reg)
105{
106 writel(val, pcie->phy_base + reg);
107}
108
109static inline u32 exynos_phy_readl(struct exynos_pcie *pcie, u32 reg)
110{
111 return readl(pcie->phy_base + reg);
112}
113
114static inline void exynos_blk_writel(struct exynos_pcie *pcie, u32 val, u32 reg)
115{
116 writel(val, pcie->block_base + reg);
117}
118
119static inline u32 exynos_blk_readl(struct exynos_pcie *pcie, u32 reg)
120{
121 return readl(pcie->block_base + reg);
122}
123
94static void exynos_pcie_sideband_dbi_w_mode(struct pcie_port *pp, bool on) 124static void exynos_pcie_sideband_dbi_w_mode(struct pcie_port *pp, bool on)
95{ 125{
96 u32 val; 126 u32 val;
97 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 127 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
98 128
99 if (on) { 129 if (on) {
100 val = readl(exynos_pcie->elbi_base + PCIE_ELBI_SLV_AWMISC); 130 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC);
101 val |= PCIE_ELBI_SLV_DBI_ENABLE; 131 val |= PCIE_ELBI_SLV_DBI_ENABLE;
102 writel(val, exynos_pcie->elbi_base + PCIE_ELBI_SLV_AWMISC); 132 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC);
103 } else { 133 } else {
104 val = readl(exynos_pcie->elbi_base + PCIE_ELBI_SLV_AWMISC); 134 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_AWMISC);
105 val &= ~PCIE_ELBI_SLV_DBI_ENABLE; 135 val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
106 writel(val, exynos_pcie->elbi_base + PCIE_ELBI_SLV_AWMISC); 136 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_AWMISC);
107 } 137 }
108} 138}
109 139
@@ -113,13 +143,13 @@ static void exynos_pcie_sideband_dbi_r_mode(struct pcie_port *pp, bool on)
113 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 143 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
114 144
115 if (on) { 145 if (on) {
116 val = readl(exynos_pcie->elbi_base + PCIE_ELBI_SLV_ARMISC); 146 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC);
117 val |= PCIE_ELBI_SLV_DBI_ENABLE; 147 val |= PCIE_ELBI_SLV_DBI_ENABLE;
118 writel(val, exynos_pcie->elbi_base + PCIE_ELBI_SLV_ARMISC); 148 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC);
119 } else { 149 } else {
120 val = readl(exynos_pcie->elbi_base + PCIE_ELBI_SLV_ARMISC); 150 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_SLV_ARMISC);
121 val &= ~PCIE_ELBI_SLV_DBI_ENABLE; 151 val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
122 writel(val, exynos_pcie->elbi_base + PCIE_ELBI_SLV_ARMISC); 152 exynos_elb_writel(exynos_pcie, val, PCIE_ELBI_SLV_ARMISC);
123 } 153 }
124} 154}
125 155
@@ -127,95 +157,89 @@ static void exynos_pcie_assert_core_reset(struct pcie_port *pp)
127{ 157{
128 u32 val; 158 u32 val;
129 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 159 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
130 void __iomem *elbi_base = exynos_pcie->elbi_base;
131 160
132 val = readl(elbi_base + PCIE_CORE_RESET); 161 val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET);
133 val &= ~PCIE_CORE_RESET_ENABLE; 162 val &= ~PCIE_CORE_RESET_ENABLE;
134 writel(val, elbi_base + PCIE_CORE_RESET); 163 exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET);
135 writel(0, elbi_base + PCIE_PWR_RESET); 164 exynos_elb_writel(exynos_pcie, 0, PCIE_PWR_RESET);
136 writel(0, elbi_base + PCIE_STICKY_RESET); 165 exynos_elb_writel(exynos_pcie, 0, PCIE_STICKY_RESET);
137 writel(0, elbi_base + PCIE_NONSTICKY_RESET); 166 exynos_elb_writel(exynos_pcie, 0, PCIE_NONSTICKY_RESET);
138} 167}
139 168
140static void exynos_pcie_deassert_core_reset(struct pcie_port *pp) 169static void exynos_pcie_deassert_core_reset(struct pcie_port *pp)
141{ 170{
142 u32 val; 171 u32 val;
143 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 172 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
144 void __iomem *elbi_base = exynos_pcie->elbi_base;
145 void __iomem *block_base = exynos_pcie->block_base;
146 173
147 val = readl(elbi_base + PCIE_CORE_RESET); 174 val = exynos_elb_readl(exynos_pcie, PCIE_CORE_RESET);
148 val |= PCIE_CORE_RESET_ENABLE; 175 val |= PCIE_CORE_RESET_ENABLE;
149 writel(val, elbi_base + PCIE_CORE_RESET); 176
150 writel(1, elbi_base + PCIE_STICKY_RESET); 177 exynos_elb_writel(exynos_pcie, val, PCIE_CORE_RESET);
151 writel(1, elbi_base + PCIE_NONSTICKY_RESET); 178 exynos_elb_writel(exynos_pcie, 1, PCIE_STICKY_RESET);
152 writel(1, elbi_base + PCIE_APP_INIT_RESET); 179 exynos_elb_writel(exynos_pcie, 1, PCIE_NONSTICKY_RESET);
153 writel(0, elbi_base + PCIE_APP_INIT_RESET); 180 exynos_elb_writel(exynos_pcie, 1, PCIE_APP_INIT_RESET);
154 writel(1, block_base + PCIE_PHY_MAC_RESET); 181 exynos_elb_writel(exynos_pcie, 0, PCIE_APP_INIT_RESET);
182 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_MAC_RESET);
155} 183}
156 184
157static void exynos_pcie_assert_phy_reset(struct pcie_port *pp) 185static void exynos_pcie_assert_phy_reset(struct pcie_port *pp)
158{ 186{
159 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 187 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
160 void __iomem *block_base = exynos_pcie->block_base;
161 188
162 writel(0, block_base + PCIE_PHY_MAC_RESET); 189 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_MAC_RESET);
163 writel(1, block_base + PCIE_PHY_GLOBAL_RESET); 190 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_GLOBAL_RESET);
164} 191}
165 192
166static void exynos_pcie_deassert_phy_reset(struct pcie_port *pp) 193static void exynos_pcie_deassert_phy_reset(struct pcie_port *pp)
167{ 194{
168 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 195 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
169 void __iomem *elbi_base = exynos_pcie->elbi_base; 196
170 void __iomem *block_base = exynos_pcie->block_base; 197 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_GLOBAL_RESET);
171 198 exynos_elb_writel(exynos_pcie, 1, PCIE_PWR_RESET);
172 writel(0, block_base + PCIE_PHY_GLOBAL_RESET); 199 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET);
173 writel(1, elbi_base + PCIE_PWR_RESET); 200 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_CMN_REG);
174 writel(0, block_base + PCIE_PHY_COMMON_RESET); 201 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSVREG_RESET);
175 writel(0, block_base + PCIE_PHY_CMN_REG); 202 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_TRSV_RESET);
176 writel(0, block_base + PCIE_PHY_TRSVREG_RESET);
177 writel(0, block_base + PCIE_PHY_TRSV_RESET);
178} 203}
179 204
180static void exynos_pcie_init_phy(struct pcie_port *pp) 205static void exynos_pcie_init_phy(struct pcie_port *pp)
181{ 206{
182 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 207 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
183 void __iomem *phy_base = exynos_pcie->phy_base;
184 208
185 /* DCC feedback control off */ 209 /* DCC feedback control off */
186 writel(0x29, phy_base + PCIE_PHY_DCC_FEEDBACK); 210 exynos_phy_writel(exynos_pcie, 0x29, PCIE_PHY_DCC_FEEDBACK);
187 211
188 /* set TX/RX impedance */ 212 /* set TX/RX impedance */
189 writel(0xd5, phy_base + PCIE_PHY_IMPEDANCE); 213 exynos_phy_writel(exynos_pcie, 0xd5, PCIE_PHY_IMPEDANCE);
190 214
191 /* set 50Mhz PHY clock */ 215 /* set 50Mhz PHY clock */
192 writel(0x14, phy_base + PCIE_PHY_PLL_DIV_0); 216 exynos_phy_writel(exynos_pcie, 0x14, PCIE_PHY_PLL_DIV_0);
193 writel(0x12, phy_base + PCIE_PHY_PLL_DIV_1); 217 exynos_phy_writel(exynos_pcie, 0x12, PCIE_PHY_PLL_DIV_1);
194 218
195 /* set TX Differential output for lane 0 */ 219 /* set TX Differential output for lane 0 */
196 writel(0x7f, phy_base + PCIE_PHY_TRSV0_DRV_LVL); 220 exynos_phy_writel(exynos_pcie, 0x7f, PCIE_PHY_TRSV0_DRV_LVL);
197 221
198 /* set TX Pre-emphasis Level Control for lane 0 to minimum */ 222 /* set TX Pre-emphasis Level Control for lane 0 to minimum */
199 writel(0x0, phy_base + PCIE_PHY_TRSV0_EMP_LVL); 223 exynos_phy_writel(exynos_pcie, 0x0, PCIE_PHY_TRSV0_EMP_LVL);
200 224
201 /* set RX clock and data recovery bandwidth */ 225 /* set RX clock and data recovery bandwidth */
202 writel(0xe7, phy_base + PCIE_PHY_PLL_BIAS); 226 exynos_phy_writel(exynos_pcie, 0xe7, PCIE_PHY_PLL_BIAS);
203 writel(0x82, phy_base + PCIE_PHY_TRSV0_RXCDR); 227 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV0_RXCDR);
204 writel(0x82, phy_base + PCIE_PHY_TRSV1_RXCDR); 228 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV1_RXCDR);
205 writel(0x82, phy_base + PCIE_PHY_TRSV2_RXCDR); 229 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV2_RXCDR);
206 writel(0x82, phy_base + PCIE_PHY_TRSV3_RXCDR); 230 exynos_phy_writel(exynos_pcie, 0x82, PCIE_PHY_TRSV3_RXCDR);
207 231
208 /* change TX Pre-emphasis Level Control for lanes */ 232 /* change TX Pre-emphasis Level Control for lanes */
209 writel(0x39, phy_base + PCIE_PHY_TRSV0_EMP_LVL); 233 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV0_EMP_LVL);
210 writel(0x39, phy_base + PCIE_PHY_TRSV1_EMP_LVL); 234 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV1_EMP_LVL);
211 writel(0x39, phy_base + PCIE_PHY_TRSV2_EMP_LVL); 235 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV2_EMP_LVL);
212 writel(0x39, phy_base + PCIE_PHY_TRSV3_EMP_LVL); 236 exynos_phy_writel(exynos_pcie, 0x39, PCIE_PHY_TRSV3_EMP_LVL);
213 237
214 /* set LVCC */ 238 /* set LVCC */
215 writel(0x20, phy_base + PCIE_PHY_TRSV0_LVCC); 239 exynos_phy_writel(exynos_pcie, 0x20, PCIE_PHY_TRSV0_LVCC);
216 writel(0xa0, phy_base + PCIE_PHY_TRSV1_LVCC); 240 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV1_LVCC);
217 writel(0xa0, phy_base + PCIE_PHY_TRSV2_LVCC); 241 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV2_LVCC);
218 writel(0xa0, phy_base + PCIE_PHY_TRSV3_LVCC); 242 exynos_phy_writel(exynos_pcie, 0xa0, PCIE_PHY_TRSV3_LVCC);
219} 243}
220 244
221static void exynos_pcie_assert_reset(struct pcie_port *pp) 245static void exynos_pcie_assert_reset(struct pcie_port *pp)
@@ -233,9 +257,6 @@ static int exynos_pcie_establish_link(struct pcie_port *pp)
233 u32 val; 257 u32 val;
234 int count = 0; 258 int count = 0;
235 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 259 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
236 void __iomem *elbi_base = exynos_pcie->elbi_base;
237 void __iomem *block_base = exynos_pcie->block_base;
238 void __iomem *phy_base = exynos_pcie->phy_base;
239 260
240 if (dw_pcie_link_up(pp)) { 261 if (dw_pcie_link_up(pp)) {
241 dev_err(pp->dev, "Link already up\n"); 262 dev_err(pp->dev, "Link already up\n");
@@ -253,9 +274,9 @@ static int exynos_pcie_establish_link(struct pcie_port *pp)
253 exynos_pcie_init_phy(pp); 274 exynos_pcie_init_phy(pp);
254 275
255 /* pulse for common reset */ 276 /* pulse for common reset */
256 writel(1, block_base + PCIE_PHY_COMMON_RESET); 277 exynos_blk_writel(exynos_pcie, 1, PCIE_PHY_COMMON_RESET);
257 udelay(500); 278 udelay(500);
258 writel(0, block_base + PCIE_PHY_COMMON_RESET); 279 exynos_blk_writel(exynos_pcie, 0, PCIE_PHY_COMMON_RESET);
259 280
260 /* de-assert core reset */ 281 /* de-assert core reset */
261 exynos_pcie_deassert_core_reset(pp); 282 exynos_pcie_deassert_core_reset(pp);
@@ -267,15 +288,18 @@ static int exynos_pcie_establish_link(struct pcie_port *pp)
267 exynos_pcie_assert_reset(pp); 288 exynos_pcie_assert_reset(pp);
268 289
269 /* assert LTSSM enable */ 290 /* assert LTSSM enable */
270 writel(PCIE_ELBI_LTSSM_ENABLE, elbi_base + PCIE_APP_LTSSM_ENABLE); 291 exynos_elb_writel(exynos_pcie, PCIE_ELBI_LTSSM_ENABLE,
292 PCIE_APP_LTSSM_ENABLE);
271 293
272 /* check if the link is up or not */ 294 /* check if the link is up or not */
273 while (!dw_pcie_link_up(pp)) { 295 while (!dw_pcie_link_up(pp)) {
274 mdelay(100); 296 mdelay(100);
275 count++; 297 count++;
276 if (count == 10) { 298 if (count == 10) {
277 while (readl(phy_base + PCIE_PHY_PLL_LOCKED) == 0) { 299 while (exynos_phy_readl(exynos_pcie,
278 val = readl(block_base + PCIE_PHY_PLL_LOCKED); 300 PCIE_PHY_PLL_LOCKED) == 0) {
301 val = exynos_blk_readl(exynos_pcie,
302 PCIE_PHY_PLL_LOCKED);
279 dev_info(pp->dev, "PLL Locked: 0x%x\n", val); 303 dev_info(pp->dev, "PLL Locked: 0x%x\n", val);
280 } 304 }
281 dev_err(pp->dev, "PCIe Link Fail\n"); 305 dev_err(pp->dev, "PCIe Link Fail\n");
@@ -292,10 +316,9 @@ static void exynos_pcie_clear_irq_pulse(struct pcie_port *pp)
292{ 316{
293 u32 val; 317 u32 val;
294 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 318 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
295 void __iomem *elbi_base = exynos_pcie->elbi_base;
296 319
297 val = readl(elbi_base + PCIE_IRQ_PULSE); 320 val = exynos_elb_readl(exynos_pcie, PCIE_IRQ_PULSE);
298 writel(val, elbi_base + PCIE_IRQ_PULSE); 321 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_PULSE);
299 return; 322 return;
300} 323}
301 324
@@ -303,12 +326,11 @@ static void exynos_pcie_enable_irq_pulse(struct pcie_port *pp)
303{ 326{
304 u32 val; 327 u32 val;
305 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 328 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
306 void __iomem *elbi_base = exynos_pcie->elbi_base;
307 329
308 /* enable INTX interrupt */ 330 /* enable INTX interrupt */
309 val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT | 331 val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT |
310 IRQ_INTC_ASSERT | IRQ_INTD_ASSERT, 332 IRQ_INTC_ASSERT | IRQ_INTD_ASSERT,
311 writel(val, elbi_base + PCIE_IRQ_EN_PULSE); 333 exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_PULSE);
312 return; 334 return;
313} 335}
314 336
@@ -369,7 +391,7 @@ static int exynos_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
369static int exynos_pcie_link_up(struct pcie_port *pp) 391static int exynos_pcie_link_up(struct pcie_port *pp)
370{ 392{
371 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp); 393 struct exynos_pcie *exynos_pcie = to_exynos_pcie(pp);
372 u32 val = readl(exynos_pcie->elbi_base + PCIE_ELBI_RDLH_LINKUP); 394 u32 val = exynos_elb_readl(exynos_pcie, PCIE_ELBI_RDLH_LINKUP);
373 395
374 if (val == PCIE_ELBI_LTSSM_ENABLE) 396 if (val == PCIE_ELBI_LTSSM_ENABLE)
375 return 1; 397 return 1;
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 77b0c257f215..c10e9ac9bbbc 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -99,22 +99,20 @@ int cfg_write(void __iomem *addr, int where, int size, u32 val)
99 return PCIBIOS_SUCCESSFUL; 99 return PCIBIOS_SUCCESSFUL;
100} 100}
101 101
102static inline void dw_pcie_readl_rc(struct pcie_port *pp, 102static inline void dw_pcie_readl_rc(struct pcie_port *pp, u32 reg, u32 *val)
103 void __iomem *dbi_addr, u32 *val)
104{ 103{
105 if (pp->ops->readl_rc) 104 if (pp->ops->readl_rc)
106 pp->ops->readl_rc(pp, dbi_addr, val); 105 pp->ops->readl_rc(pp, pp->dbi_base + reg, val);
107 else 106 else
108 *val = readl(dbi_addr); 107 *val = readl(pp->dbi_base + reg);
109} 108}
110 109
111static inline void dw_pcie_writel_rc(struct pcie_port *pp, 110static inline void dw_pcie_writel_rc(struct pcie_port *pp, u32 val, u32 reg)
112 u32 val, void __iomem *dbi_addr)
113{ 111{
114 if (pp->ops->writel_rc) 112 if (pp->ops->writel_rc)
115 pp->ops->writel_rc(pp, val, dbi_addr); 113 pp->ops->writel_rc(pp, val, pp->dbi_base + reg);
116 else 114 else
117 writel(val, dbi_addr); 115 writel(val, pp->dbi_base + reg);
118} 116}
119 117
120int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, 118int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
@@ -251,86 +249,64 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
251 249
252static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev) 250static void dw_pcie_prog_viewport_cfg0(struct pcie_port *pp, u32 busdev)
253{ 251{
254 u32 val;
255 void __iomem *dbi_base = pp->dbi_base;
256
257 /* Program viewport 0 : OUTBOUND : CFG0 */ 252 /* Program viewport 0 : OUTBOUND : CFG0 */
258 val = PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0; 253 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
259 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_VIEWPORT); 254 PCIE_ATU_VIEWPORT);
260 dw_pcie_writel_rc(pp, pp->cfg0_base, dbi_base + PCIE_ATU_LOWER_BASE); 255 dw_pcie_writel_rc(pp, pp->cfg0_base, PCIE_ATU_LOWER_BASE);
261 dw_pcie_writel_rc(pp, (pp->cfg0_base >> 32), 256 dw_pcie_writel_rc(pp, (pp->cfg0_base >> 32), PCIE_ATU_UPPER_BASE);
262 dbi_base + PCIE_ATU_UPPER_BASE);
263 dw_pcie_writel_rc(pp, pp->cfg0_base + pp->config.cfg0_size - 1, 257 dw_pcie_writel_rc(pp, pp->cfg0_base + pp->config.cfg0_size - 1,
264 dbi_base + PCIE_ATU_LIMIT); 258 PCIE_ATU_LIMIT);
265 dw_pcie_writel_rc(pp, busdev, dbi_base + PCIE_ATU_LOWER_TARGET); 259 dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
266 dw_pcie_writel_rc(pp, 0, dbi_base + PCIE_ATU_UPPER_TARGET); 260 dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
267 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG0, dbi_base + PCIE_ATU_CR1); 261 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG0, PCIE_ATU_CR1);
268 val = PCIE_ATU_ENABLE; 262 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
269 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_CR2);
270} 263}
271 264
272static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev) 265static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
273{ 266{
274 u32 val;
275 void __iomem *dbi_base = pp->dbi_base;
276
277 /* Program viewport 1 : OUTBOUND : CFG1 */ 267 /* Program viewport 1 : OUTBOUND : CFG1 */
278 val = PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1; 268 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
279 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_VIEWPORT); 269 PCIE_ATU_VIEWPORT);
280 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, dbi_base + PCIE_ATU_CR1); 270 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
281 val = PCIE_ATU_ENABLE; 271 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
282 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_CR2); 272 dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
283 dw_pcie_writel_rc(pp, pp->cfg1_base, dbi_base + PCIE_ATU_LOWER_BASE); 273 dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
284 dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32),
285 dbi_base + PCIE_ATU_UPPER_BASE);
286 dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1, 274 dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
287 dbi_base + PCIE_ATU_LIMIT); 275 PCIE_ATU_LIMIT);
288 dw_pcie_writel_rc(pp, busdev, dbi_base + PCIE_ATU_LOWER_TARGET); 276 dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
289 dw_pcie_writel_rc(pp, 0, dbi_base + PCIE_ATU_UPPER_TARGET); 277 dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
290} 278}
291 279
292static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp) 280static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
293{ 281{
294 u32 val;
295 void __iomem *dbi_base = pp->dbi_base;
296
297 /* Program viewport 0 : OUTBOUND : MEM */ 282 /* Program viewport 0 : OUTBOUND : MEM */
298 val = PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0; 283 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
299 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_VIEWPORT); 284 PCIE_ATU_VIEWPORT);
300 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, dbi_base + PCIE_ATU_CR1); 285 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
301 val = PCIE_ATU_ENABLE; 286 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
302 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_CR2); 287 dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
303 dw_pcie_writel_rc(pp, pp->mem_base, dbi_base + PCIE_ATU_LOWER_BASE); 288 dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE);
304 dw_pcie_writel_rc(pp, (pp->mem_base >> 32),
305 dbi_base + PCIE_ATU_UPPER_BASE);
306 dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1, 289 dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
307 dbi_base + PCIE_ATU_LIMIT); 290 PCIE_ATU_LIMIT);
308 dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, 291 dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
309 dbi_base + PCIE_ATU_LOWER_TARGET);
310 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr), 292 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
311 dbi_base + PCIE_ATU_UPPER_TARGET); 293 PCIE_ATU_UPPER_TARGET);
312} 294}
313 295
314static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp) 296static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
315{ 297{
316 u32 val;
317 void __iomem *dbi_base = pp->dbi_base;
318
319 /* Program viewport 1 : OUTBOUND : IO */ 298 /* Program viewport 1 : OUTBOUND : IO */
320 val = PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1; 299 dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
321 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_VIEWPORT); 300 PCIE_ATU_VIEWPORT);
322 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, dbi_base + PCIE_ATU_CR1); 301 dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
323 val = PCIE_ATU_ENABLE; 302 dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
324 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_ATU_CR2); 303 dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
325 dw_pcie_writel_rc(pp, pp->io_base, dbi_base + PCIE_ATU_LOWER_BASE); 304 dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE);
326 dw_pcie_writel_rc(pp, (pp->io_base >> 32),
327 dbi_base + PCIE_ATU_UPPER_BASE);
328 dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1, 305 dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
329 dbi_base + PCIE_ATU_LIMIT); 306 PCIE_ATU_LIMIT);
330 dw_pcie_writel_rc(pp, pp->config.io_bus_addr, 307 dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
331 dbi_base + PCIE_ATU_LOWER_TARGET);
332 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr), 308 dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
333 dbi_base + PCIE_ATU_UPPER_TARGET); 309 PCIE_ATU_UPPER_TARGET);
334} 310}
335 311
336static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, 312static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
@@ -518,13 +494,12 @@ static struct hw_pci dw_pci = {
518void dw_pcie_setup_rc(struct pcie_port *pp) 494void dw_pcie_setup_rc(struct pcie_port *pp)
519{ 495{
520 struct pcie_port_info *config = &pp->config; 496 struct pcie_port_info *config = &pp->config;
521 void __iomem *dbi_base = pp->dbi_base;
522 u32 val; 497 u32 val;
523 u32 membase; 498 u32 membase;
524 u32 memlimit; 499 u32 memlimit;
525 500
526 /* set the number of lines as 4 */ 501 /* set the number of lines as 4 */
527 dw_pcie_readl_rc(pp, dbi_base + PCIE_PORT_LINK_CONTROL, &val); 502 dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
528 val &= ~PORT_LINK_MODE_MASK; 503 val &= ~PORT_LINK_MODE_MASK;
529 switch (pp->lanes) { 504 switch (pp->lanes) {
530 case 1: 505 case 1:
@@ -537,10 +512,10 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
537 val |= PORT_LINK_MODE_4_LANES; 512 val |= PORT_LINK_MODE_4_LANES;
538 break; 513 break;
539 } 514 }
540 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_PORT_LINK_CONTROL); 515 dw_pcie_writel_rc(pp, val, PCIE_PORT_LINK_CONTROL);
541 516
542 /* set link width speed control register */ 517 /* set link width speed control register */
543 dw_pcie_readl_rc(pp, dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL, &val); 518 dw_pcie_readl_rc(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, &val);
544 val &= ~PORT_LOGIC_LINK_WIDTH_MASK; 519 val &= ~PORT_LOGIC_LINK_WIDTH_MASK;
545 switch (pp->lanes) { 520 switch (pp->lanes) {
546 case 1: 521 case 1:
@@ -553,36 +528,36 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
553 val |= PORT_LOGIC_LINK_WIDTH_4_LANES; 528 val |= PORT_LOGIC_LINK_WIDTH_4_LANES;
554 break; 529 break;
555 } 530 }
556 dw_pcie_writel_rc(pp, val, dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL); 531 dw_pcie_writel_rc(pp, val, PCIE_LINK_WIDTH_SPEED_CONTROL);
557 532
558 /* setup RC BARs */ 533 /* setup RC BARs */
559 dw_pcie_writel_rc(pp, 0x00000004, dbi_base + PCI_BASE_ADDRESS_0); 534 dw_pcie_writel_rc(pp, 0x00000004, PCI_BASE_ADDRESS_0);
560 dw_pcie_writel_rc(pp, 0x00000004, dbi_base + PCI_BASE_ADDRESS_1); 535 dw_pcie_writel_rc(pp, 0x00000004, PCI_BASE_ADDRESS_1);
561 536
562 /* setup interrupt pins */ 537 /* setup interrupt pins */
563 dw_pcie_readl_rc(pp, dbi_base + PCI_INTERRUPT_LINE, &val); 538 dw_pcie_readl_rc(pp, PCI_INTERRUPT_LINE, &val);
564 val &= 0xffff00ff; 539 val &= 0xffff00ff;
565 val |= 0x00000100; 540 val |= 0x00000100;
566 dw_pcie_writel_rc(pp, val, dbi_base + PCI_INTERRUPT_LINE); 541 dw_pcie_writel_rc(pp, val, PCI_INTERRUPT_LINE);
567 542
568 /* setup bus numbers */ 543 /* setup bus numbers */
569 dw_pcie_readl_rc(pp, dbi_base + PCI_PRIMARY_BUS, &val); 544 dw_pcie_readl_rc(pp, PCI_PRIMARY_BUS, &val);
570 val &= 0xff000000; 545 val &= 0xff000000;
571 val |= 0x00010100; 546 val |= 0x00010100;
572 dw_pcie_writel_rc(pp, val, dbi_base + PCI_PRIMARY_BUS); 547 dw_pcie_writel_rc(pp, val, PCI_PRIMARY_BUS);
573 548
574 /* setup memory base, memory limit */ 549 /* setup memory base, memory limit */
575 membase = ((u32)pp->mem_base & 0xfff00000) >> 16; 550 membase = ((u32)pp->mem_base & 0xfff00000) >> 16;
576 memlimit = (config->mem_size + (u32)pp->mem_base) & 0xfff00000; 551 memlimit = (config->mem_size + (u32)pp->mem_base) & 0xfff00000;
577 val = memlimit | membase; 552 val = memlimit | membase;
578 dw_pcie_writel_rc(pp, val, dbi_base + PCI_MEMORY_BASE); 553 dw_pcie_writel_rc(pp, val, PCI_MEMORY_BASE);
579 554
580 /* setup command register */ 555 /* setup command register */
581 dw_pcie_readl_rc(pp, dbi_base + PCI_COMMAND, &val); 556 dw_pcie_readl_rc(pp, PCI_COMMAND, &val);
582 val &= 0xffff0000; 557 val &= 0xffff0000;
583 val |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY | 558 val |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
584 PCI_COMMAND_MASTER | PCI_COMMAND_SERR; 559 PCI_COMMAND_MASTER | PCI_COMMAND_SERR;
585 dw_pcie_writel_rc(pp, val, dbi_base + PCI_COMMAND); 560 dw_pcie_writel_rc(pp, val, PCI_COMMAND);
586} 561}
587 562
588MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>"); 563MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");