aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/pciehp_hpc.c
diff options
context:
space:
mode:
authorKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>2008-12-19 01:19:02 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 14:13:22 -0500
commit322162a71bd9fc4edb1b11236e7bc8aa27ccac22 (patch)
treef5a5ea837934c8af3285157ee53f0d1d6e05cfcf /drivers/pci/hotplug/pciehp_hpc.c
parent67f6533802fd2cc6f5b3c6355ef72bcf636d7fda (diff)
PCI: pciehp: cleanup register and field definitions
Clean up register definitions related to PCI Express Hot plug. - Add register definitions into include/linux/pci_regs.h, and use them instead of pciehp's locally definied register definitions. - Remove pciehp's locally defined register definitions - Remove unused register definitions in pciehp. - Some minor cleanups. Signed-off-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug/pciehp_hpc.c')
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c328
1 files changed, 99 insertions, 229 deletions
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 22b88cb17a07..71a8012886b0 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -42,42 +42,6 @@
42 42
43static atomic_t pciehp_num_controllers = ATOMIC_INIT(0); 43static atomic_t pciehp_num_controllers = ATOMIC_INIT(0);
44 44
45struct ctrl_reg {
46 u8 cap_id;
47 u8 nxt_ptr;
48 u16 cap_reg;
49 u32 dev_cap;
50 u16 dev_ctrl;
51 u16 dev_status;
52 u32 lnk_cap;
53 u16 lnk_ctrl;
54 u16 lnk_status;
55 u32 slot_cap;
56 u16 slot_ctrl;
57 u16 slot_status;
58 u16 root_ctrl;
59 u16 rsvp;
60 u32 root_status;
61} __attribute__ ((packed));
62
63/* offsets to the controller registers based on the above structure layout */
64enum ctrl_offsets {
65 PCIECAPID = offsetof(struct ctrl_reg, cap_id),
66 NXTCAPPTR = offsetof(struct ctrl_reg, nxt_ptr),
67 CAPREG = offsetof(struct ctrl_reg, cap_reg),
68 DEVCAP = offsetof(struct ctrl_reg, dev_cap),
69 DEVCTRL = offsetof(struct ctrl_reg, dev_ctrl),
70 DEVSTATUS = offsetof(struct ctrl_reg, dev_status),
71 LNKCAP = offsetof(struct ctrl_reg, lnk_cap),
72 LNKCTRL = offsetof(struct ctrl_reg, lnk_ctrl),
73 LNKSTATUS = offsetof(struct ctrl_reg, lnk_status),
74 SLOTCAP = offsetof(struct ctrl_reg, slot_cap),
75 SLOTCTRL = offsetof(struct ctrl_reg, slot_ctrl),
76 SLOTSTATUS = offsetof(struct ctrl_reg, slot_status),
77 ROOTCTRL = offsetof(struct ctrl_reg, root_ctrl),
78 ROOTSTATUS = offsetof(struct ctrl_reg, root_status),
79};
80
81static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value) 45static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value)
82{ 46{
83 struct pci_dev *dev = ctrl->pci_dev; 47 struct pci_dev *dev = ctrl->pci_dev;
@@ -102,95 +66,9 @@ static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
102 return pci_write_config_dword(dev, ctrl->cap_base + reg, value); 66 return pci_write_config_dword(dev, ctrl->cap_base + reg, value);
103} 67}
104 68
105/* Field definitions in PCI Express Capabilities Register */
106#define CAP_VER 0x000F
107#define DEV_PORT_TYPE 0x00F0
108#define SLOT_IMPL 0x0100
109#define MSG_NUM 0x3E00
110
111/* Device or Port Type */
112#define NAT_ENDPT 0x00
113#define LEG_ENDPT 0x01
114#define ROOT_PORT 0x04
115#define UP_STREAM 0x05
116#define DN_STREAM 0x06
117#define PCIE_PCI_BRDG 0x07
118#define PCI_PCIE_BRDG 0x10
119
120/* Field definitions in Device Capabilities Register */
121#define DATTN_BUTTN_PRSN 0x1000
122#define DATTN_LED_PRSN 0x2000
123#define DPWR_LED_PRSN 0x4000
124
125/* Field definitions in Link Capabilities Register */
126#define MAX_LNK_SPEED 0x000F
127#define MAX_LNK_WIDTH 0x03F0
128#define LINK_ACTIVE_REPORTING 0x00100000
129
130/* Link Width Encoding */
131#define LNK_X1 0x01
132#define LNK_X2 0x02
133#define LNK_X4 0x04
134#define LNK_X8 0x08
135#define LNK_X12 0x0C
136#define LNK_X16 0x10
137#define LNK_X32 0x20
138
139/*Field definitions of Link Status Register */
140#define LNK_SPEED 0x000F
141#define NEG_LINK_WD 0x03F0
142#define LNK_TRN_ERR 0x0400
143#define LNK_TRN 0x0800
144#define SLOT_CLK_CONF 0x1000
145#define LINK_ACTIVE 0x2000
146
147/* Field definitions in Slot Capabilities Register */
148#define ATTN_BUTTN_PRSN 0x00000001
149#define PWR_CTRL_PRSN 0x00000002
150#define MRL_SENS_PRSN 0x00000004
151#define ATTN_LED_PRSN 0x00000008
152#define PWR_LED_PRSN 0x00000010
153#define HP_SUPR_RM_SUP 0x00000020
154#define HP_CAP 0x00000040
155#define SLOT_PWR_VALUE 0x000003F8
156#define SLOT_PWR_LIMIT 0x00000C00
157#define PSN 0xFFF80000 /* PSN: Physical Slot Number */
158
159/* Field definitions in Slot Control Register */
160#define ATTN_BUTTN_ENABLE 0x0001
161#define PWR_FAULT_DETECT_ENABLE 0x0002
162#define MRL_DETECT_ENABLE 0x0004
163#define PRSN_DETECT_ENABLE 0x0008
164#define CMD_CMPL_INTR_ENABLE 0x0010
165#define HP_INTR_ENABLE 0x0020
166#define ATTN_LED_CTRL 0x00C0
167#define PWR_LED_CTRL 0x0300
168#define PWR_CTRL 0x0400
169#define EMI_CTRL 0x0800
170
171/* Attention indicator and Power indicator states */
172#define LED_ON 0x01
173#define LED_BLINK 0x10
174#define LED_OFF 0x11
175
176/* Power Control Command */ 69/* Power Control Command */
177#define POWER_ON 0 70#define POWER_ON 0
178#define POWER_OFF 0x0400 71#define POWER_OFF PCI_EXP_SLTCTL_PCC
179
180/* EMI Status defines */
181#define EMI_DISENGAGED 0
182#define EMI_ENGAGED 1
183
184/* Field definitions in Slot Status Register */
185#define ATTN_BUTTN_PRESSED 0x0001
186#define PWR_FAULT_DETECTED 0x0002
187#define MRL_SENS_CHANGED 0x0004
188#define PRSN_DETECT_CHANGED 0x0008
189#define CMD_COMPLETED 0x0010
190#define MRL_STATE 0x0020
191#define PRSN_STATE 0x0040
192#define EMI_STATE 0x0080
193#define EMI_STATUS_BIT 7
194 72
195static irqreturn_t pcie_isr(int irq, void *dev_id); 73static irqreturn_t pcie_isr(int irq, void *dev_id);
196static void start_int_poll_timer(struct controller *ctrl, int sec); 74static void start_int_poll_timer(struct controller *ctrl, int sec);
@@ -253,22 +131,20 @@ static inline void pciehp_free_irq(struct controller *ctrl)
253static int pcie_poll_cmd(struct controller *ctrl) 131static int pcie_poll_cmd(struct controller *ctrl)
254{ 132{
255 u16 slot_status; 133 u16 slot_status;
256 int timeout = 1000; 134 int err, timeout = 1000;
257 135
258 if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status)) { 136 err = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
259 if (slot_status & CMD_COMPLETED) { 137 if (!err && (slot_status & PCI_EXP_SLTSTA_CC)) {
260 pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED); 138 pciehp_writew(ctrl, PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_CC);
261 return 1; 139 return 1;
262 }
263 } 140 }
264 while (timeout > 0) { 141 while (timeout > 0) {
265 msleep(10); 142 msleep(10);
266 timeout -= 10; 143 timeout -= 10;
267 if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status)) { 144 err = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
268 if (slot_status & CMD_COMPLETED) { 145 if (!err && (slot_status & PCI_EXP_SLTSTA_CC)) {
269 pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED); 146 pciehp_writew(ctrl, PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_CC);
270 return 1; 147 return 1;
271 }
272 } 148 }
273 } 149 }
274 return 0; /* timeout */ 150 return 0; /* timeout */
@@ -302,14 +178,14 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
302 178
303 mutex_lock(&ctrl->ctrl_lock); 179 mutex_lock(&ctrl->ctrl_lock);
304 180
305 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 181 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
306 if (retval) { 182 if (retval) {
307 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 183 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
308 __func__); 184 __func__);
309 goto out; 185 goto out;
310 } 186 }
311 187
312 if (slot_status & CMD_COMPLETED) { 188 if (slot_status & PCI_EXP_SLTSTA_CC) {
313 if (!ctrl->no_cmd_complete) { 189 if (!ctrl->no_cmd_complete) {
314 /* 190 /*
315 * After 1 sec and CMD_COMPLETED still not set, just 191 * After 1 sec and CMD_COMPLETED still not set, just
@@ -332,7 +208,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
332 } 208 }
333 } 209 }
334 210
335 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); 211 retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
336 if (retval) { 212 if (retval) {
337 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); 213 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
338 goto out; 214 goto out;
@@ -342,7 +218,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
342 slot_ctrl |= (cmd & mask); 218 slot_ctrl |= (cmd & mask);
343 ctrl->cmd_busy = 1; 219 ctrl->cmd_busy = 1;
344 smp_mb(); 220 smp_mb();
345 retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); 221 retval = pciehp_writew(ctrl, PCI_EXP_SLTCTL, slot_ctrl);
346 if (retval) 222 if (retval)
347 ctrl_err(ctrl, "Cannot write to SLOTCTRL register\n"); 223 ctrl_err(ctrl, "Cannot write to SLOTCTRL register\n");
348 224
@@ -356,8 +232,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
356 * completed interrupt is not enabled, we need to poll 232 * completed interrupt is not enabled, we need to poll
357 * command completed event. 233 * command completed event.
358 */ 234 */
359 if (!(slot_ctrl & HP_INTR_ENABLE) || 235 if (!(slot_ctrl & PCI_EXP_SLTCTL_HPIE) ||
360 !(slot_ctrl & CMD_CMPL_INTR_ENABLE)) 236 !(slot_ctrl & PCI_EXP_SLTCTL_CCIE))
361 poll = 1; 237 poll = 1;
362 pcie_wait_cmd(ctrl, poll); 238 pcie_wait_cmd(ctrl, poll);
363 } 239 }
@@ -370,9 +246,9 @@ static inline int check_link_active(struct controller *ctrl)
370{ 246{
371 u16 link_status; 247 u16 link_status;
372 248
373 if (pciehp_readw(ctrl, LNKSTATUS, &link_status)) 249 if (pciehp_readw(ctrl, PCI_EXP_LNKSTA, &link_status))
374 return 0; 250 return 0;
375 return !!(link_status & LINK_ACTIVE); 251 return !!(link_status & PCI_EXP_LNKSTA_DLLLA);
376} 252}
377 253
378static void pcie_wait_link_active(struct controller *ctrl) 254static void pcie_wait_link_active(struct controller *ctrl)
@@ -412,14 +288,15 @@ static int hpc_check_lnk_status(struct controller *ctrl)
412 } else 288 } else
413 msleep(1000); 289 msleep(1000);
414 290
415 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); 291 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
416 if (retval) { 292 if (retval) {
417 ctrl_err(ctrl, "Cannot read LNKSTATUS register\n"); 293 ctrl_err(ctrl, "Cannot read LNKSTATUS register\n");
418 return retval; 294 return retval;
419 } 295 }
420 296
421 ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); 297 ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
422 if ((lnk_status & LNK_TRN) || !(lnk_status & NEG_LINK_WD)) { 298 if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
299 !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
423 ctrl_err(ctrl, "Link Training Error occurs \n"); 300 ctrl_err(ctrl, "Link Training Error occurs \n");
424 retval = -1; 301 retval = -1;
425 return retval; 302 return retval;
@@ -435,16 +312,16 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
435 u8 atten_led_state; 312 u8 atten_led_state;
436 int retval = 0; 313 int retval = 0;
437 314
438 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); 315 retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
439 if (retval) { 316 if (retval) {
440 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); 317 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
441 return retval; 318 return retval;
442 } 319 }
443 320
444 ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n", 321 ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n",
445 __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); 322 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_ctrl);
446 323
447 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 324 atten_led_state = (slot_ctrl & PCI_EXP_SLTCTL_AIC) >> 6;
448 325
449 switch (atten_led_state) { 326 switch (atten_led_state) {
450 case 0: 327 case 0:
@@ -474,15 +351,15 @@ static int hpc_get_power_status(struct slot *slot, u8 *status)
474 u8 pwr_state; 351 u8 pwr_state;
475 int retval = 0; 352 int retval = 0;
476 353
477 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); 354 retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
478 if (retval) { 355 if (retval) {
479 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); 356 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
480 return retval; 357 return retval;
481 } 358 }
482 ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n", 359 ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n",
483 __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); 360 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_ctrl);
484 361
485 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 362 pwr_state = (slot_ctrl & PCI_EXP_SLTCTL_PCC) >> 10;
486 363
487 switch (pwr_state) { 364 switch (pwr_state) {
488 case 0: 365 case 0:
@@ -503,17 +380,15 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
503{ 380{
504 struct controller *ctrl = slot->ctrl; 381 struct controller *ctrl = slot->ctrl;
505 u16 slot_status; 382 u16 slot_status;
506 int retval = 0; 383 int retval;
507 384
508 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 385 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
509 if (retval) { 386 if (retval) {
510 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 387 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
511 __func__); 388 __func__);
512 return retval; 389 return retval;
513 } 390 }
514 391 *status = !!(slot_status & PCI_EXP_SLTSTA_MRLSS);
515 *status = (((slot_status & MRL_STATE) >> 5) == 0) ? 0 : 1;
516
517 return 0; 392 return 0;
518} 393}
519 394
@@ -521,18 +396,15 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
521{ 396{
522 struct controller *ctrl = slot->ctrl; 397 struct controller *ctrl = slot->ctrl;
523 u16 slot_status; 398 u16 slot_status;
524 u8 card_state; 399 int retval;
525 int retval = 0;
526 400
527 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 401 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
528 if (retval) { 402 if (retval) {
529 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 403 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
530 __func__); 404 __func__);
531 return retval; 405 return retval;
532 } 406 }
533 card_state = (u8)((slot_status & PRSN_STATE) >> 6); 407 *status = !!(slot_status & PCI_EXP_SLTSTA_PDS);
534 *status = (card_state == 1) ? 1 : 0;
535
536 return 0; 408 return 0;
537} 409}
538 410
@@ -540,32 +412,28 @@ static int hpc_query_power_fault(struct slot *slot)
540{ 412{
541 struct controller *ctrl = slot->ctrl; 413 struct controller *ctrl = slot->ctrl;
542 u16 slot_status; 414 u16 slot_status;
543 u8 pwr_fault; 415 int retval;
544 int retval = 0;
545 416
546 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 417 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
547 if (retval) { 418 if (retval) {
548 ctrl_err(ctrl, "Cannot check for power fault\n"); 419 ctrl_err(ctrl, "Cannot check for power fault\n");
549 return retval; 420 return retval;
550 } 421 }
551 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); 422 return !!(slot_status & PCI_EXP_SLTSTA_PFD);
552
553 return pwr_fault;
554} 423}
555 424
556static int hpc_get_emi_status(struct slot *slot, u8 *status) 425static int hpc_get_emi_status(struct slot *slot, u8 *status)
557{ 426{
558 struct controller *ctrl = slot->ctrl; 427 struct controller *ctrl = slot->ctrl;
559 u16 slot_status; 428 u16 slot_status;
560 int retval = 0; 429 int retval;
561 430
562 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 431 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
563 if (retval) { 432 if (retval) {
564 ctrl_err(ctrl, "Cannot check EMI status\n"); 433 ctrl_err(ctrl, "Cannot check EMI status\n");
565 return retval; 434 return retval;
566 } 435 }
567 *status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT; 436 *status = !!(slot_status & PCI_EXP_SLTSTA_EIS);
568
569 return retval; 437 return retval;
570} 438}
571 439
@@ -575,8 +443,8 @@ static int hpc_toggle_emi(struct slot *slot)
575 u16 cmd_mask; 443 u16 cmd_mask;
576 int rc; 444 int rc;
577 445
578 slot_cmd = EMI_CTRL; 446 slot_cmd = PCI_EXP_SLTCTL_EIC;
579 cmd_mask = EMI_CTRL; 447 cmd_mask = PCI_EXP_SLTCTL_EIC;
580 rc = pcie_write_cmd(slot->ctrl, slot_cmd, cmd_mask); 448 rc = pcie_write_cmd(slot->ctrl, slot_cmd, cmd_mask);
581 slot->last_emi_toggle = get_seconds(); 449 slot->last_emi_toggle = get_seconds();
582 450
@@ -590,7 +458,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
590 u16 cmd_mask; 458 u16 cmd_mask;
591 int rc; 459 int rc;
592 460
593 cmd_mask = ATTN_LED_CTRL; 461 cmd_mask = PCI_EXP_SLTCTL_AIC;
594 switch (value) { 462 switch (value) {
595 case 0 : /* turn off */ 463 case 0 : /* turn off */
596 slot_cmd = 0x00C0; 464 slot_cmd = 0x00C0;
@@ -606,7 +474,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
606 } 474 }
607 rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 475 rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
608 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 476 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
609 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 477 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
610 478
611 return rc; 479 return rc;
612} 480}
@@ -618,10 +486,10 @@ static void hpc_set_green_led_on(struct slot *slot)
618 u16 cmd_mask; 486 u16 cmd_mask;
619 487
620 slot_cmd = 0x0100; 488 slot_cmd = 0x0100;
621 cmd_mask = PWR_LED_CTRL; 489 cmd_mask = PCI_EXP_SLTCTL_PIC;
622 pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 490 pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
623 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 491 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
624 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 492 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
625} 493}
626 494
627static void hpc_set_green_led_off(struct slot *slot) 495static void hpc_set_green_led_off(struct slot *slot)
@@ -631,10 +499,10 @@ static void hpc_set_green_led_off(struct slot *slot)
631 u16 cmd_mask; 499 u16 cmd_mask;
632 500
633 slot_cmd = 0x0300; 501 slot_cmd = 0x0300;
634 cmd_mask = PWR_LED_CTRL; 502 cmd_mask = PCI_EXP_SLTCTL_PIC;
635 pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 503 pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
636 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 504 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
637 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 505 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
638} 506}
639 507
640static void hpc_set_green_led_blink(struct slot *slot) 508static void hpc_set_green_led_blink(struct slot *slot)
@@ -644,10 +512,10 @@ static void hpc_set_green_led_blink(struct slot *slot)
644 u16 cmd_mask; 512 u16 cmd_mask;
645 513
646 slot_cmd = 0x0200; 514 slot_cmd = 0x0200;
647 cmd_mask = PWR_LED_CTRL; 515 cmd_mask = PCI_EXP_SLTCTL_PIC;
648 pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 516 pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
649 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 517 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
650 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 518 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
651} 519}
652 520
653static int hpc_power_on_slot(struct slot * slot) 521static int hpc_power_on_slot(struct slot * slot)
@@ -661,15 +529,15 @@ static int hpc_power_on_slot(struct slot * slot)
661 ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot); 529 ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot);
662 530
663 /* Clear sticky power-fault bit from previous power failures */ 531 /* Clear sticky power-fault bit from previous power failures */
664 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 532 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
665 if (retval) { 533 if (retval) {
666 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 534 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
667 __func__); 535 __func__);
668 return retval; 536 return retval;
669 } 537 }
670 slot_status &= PWR_FAULT_DETECTED; 538 slot_status &= PCI_EXP_SLTSTA_PFD;
671 if (slot_status) { 539 if (slot_status) {
672 retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status); 540 retval = pciehp_writew(ctrl, PCI_EXP_SLTSTA, slot_status);
673 if (retval) { 541 if (retval) {
674 ctrl_err(ctrl, 542 ctrl_err(ctrl,
675 "%s: Cannot write to SLOTSTATUS register\n", 543 "%s: Cannot write to SLOTSTATUS register\n",
@@ -679,13 +547,13 @@ static int hpc_power_on_slot(struct slot * slot)
679 } 547 }
680 548
681 slot_cmd = POWER_ON; 549 slot_cmd = POWER_ON;
682 cmd_mask = PWR_CTRL; 550 cmd_mask = PCI_EXP_SLTCTL_PCC;
683 /* Enable detection that we turned off at slot power-off time */ 551 /* Enable detection that we turned off at slot power-off time */
684 if (!pciehp_poll_mode) { 552 if (!pciehp_poll_mode) {
685 slot_cmd |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 553 slot_cmd |= (PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
686 PRSN_DETECT_ENABLE); 554 PCI_EXP_SLTCTL_PDCE);
687 cmd_mask |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 555 cmd_mask |= (PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
688 PRSN_DETECT_ENABLE); 556 PCI_EXP_SLTCTL_PDCE);
689 } 557 }
690 558
691 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 559 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
@@ -695,7 +563,7 @@ static int hpc_power_on_slot(struct slot * slot)
695 return -1; 563 return -1;
696 } 564 }
697 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 565 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
698 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 566 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
699 567
700 return retval; 568 return retval;
701} 569}
@@ -752,7 +620,7 @@ static int hpc_power_off_slot(struct slot * slot)
752 changed = pcie_mask_bad_dllp(ctrl); 620 changed = pcie_mask_bad_dllp(ctrl);
753 621
754 slot_cmd = POWER_OFF; 622 slot_cmd = POWER_OFF;
755 cmd_mask = PWR_CTRL; 623 cmd_mask = PCI_EXP_SLTCTL_PCC;
756 /* 624 /*
757 * If we get MRL or presence detect interrupts now, the isr 625 * If we get MRL or presence detect interrupts now, the isr
758 * will notice the sticky power-fault bit too and issue power 626 * will notice the sticky power-fault bit too and issue power
@@ -761,10 +629,10 @@ static int hpc_power_off_slot(struct slot * slot)
761 * till the slot is powered on again. 629 * till the slot is powered on again.
762 */ 630 */
763 if (!pciehp_poll_mode) { 631 if (!pciehp_poll_mode) {
764 slot_cmd &= ~(PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 632 slot_cmd &= ~(PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
765 PRSN_DETECT_ENABLE); 633 PCI_EXP_SLTCTL_PDCE);
766 cmd_mask |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 634 cmd_mask |= (PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
767 PRSN_DETECT_ENABLE); 635 PCI_EXP_SLTCTL_PDCE);
768 } 636 }
769 637
770 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 638 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
@@ -774,7 +642,7 @@ static int hpc_power_off_slot(struct slot * slot)
774 goto out; 642 goto out;
775 } 643 }
776 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 644 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
777 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 645 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
778 out: 646 out:
779 if (changed) 647 if (changed)
780 pcie_unmask_bad_dllp(ctrl); 648 pcie_unmask_bad_dllp(ctrl);
@@ -795,19 +663,19 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
795 */ 663 */
796 intr_loc = 0; 664 intr_loc = 0;
797 do { 665 do {
798 if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) { 666 if (pciehp_readw(ctrl, PCI_EXP_SLTSTA, &detected)) {
799 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS\n", 667 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS\n",
800 __func__); 668 __func__);
801 return IRQ_NONE; 669 return IRQ_NONE;
802 } 670 }
803 671
804 detected &= (ATTN_BUTTN_PRESSED | PWR_FAULT_DETECTED | 672 detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
805 MRL_SENS_CHANGED | PRSN_DETECT_CHANGED | 673 PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
806 CMD_COMPLETED); 674 PCI_EXP_SLTSTA_CC);
807 intr_loc |= detected; 675 intr_loc |= detected;
808 if (!intr_loc) 676 if (!intr_loc)
809 return IRQ_NONE; 677 return IRQ_NONE;
810 if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) { 678 if (detected && pciehp_writew(ctrl, PCI_EXP_SLTSTA, detected)) {
811 ctrl_err(ctrl, "%s: Cannot write to SLOTSTATUS\n", 679 ctrl_err(ctrl, "%s: Cannot write to SLOTSTATUS\n",
812 __func__); 680 __func__);
813 return IRQ_NONE; 681 return IRQ_NONE;
@@ -817,31 +685,31 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
817 ctrl_dbg(ctrl, "%s: intr_loc %x\n", __func__, intr_loc); 685 ctrl_dbg(ctrl, "%s: intr_loc %x\n", __func__, intr_loc);
818 686
819 /* Check Command Complete Interrupt Pending */ 687 /* Check Command Complete Interrupt Pending */
820 if (intr_loc & CMD_COMPLETED) { 688 if (intr_loc & PCI_EXP_SLTSTA_CC) {
821 ctrl->cmd_busy = 0; 689 ctrl->cmd_busy = 0;
822 smp_mb(); 690 smp_mb();
823 wake_up(&ctrl->queue); 691 wake_up(&ctrl->queue);
824 } 692 }
825 693
826 if (!(intr_loc & ~CMD_COMPLETED)) 694 if (!(intr_loc & ~PCI_EXP_SLTSTA_CC))
827 return IRQ_HANDLED; 695 return IRQ_HANDLED;
828 696
829 p_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 697 p_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
830 698
831 /* Check MRL Sensor Changed */ 699 /* Check MRL Sensor Changed */
832 if (intr_loc & MRL_SENS_CHANGED) 700 if (intr_loc & PCI_EXP_SLTSTA_MRLSC)
833 pciehp_handle_switch_change(p_slot); 701 pciehp_handle_switch_change(p_slot);
834 702
835 /* Check Attention Button Pressed */ 703 /* Check Attention Button Pressed */
836 if (intr_loc & ATTN_BUTTN_PRESSED) 704 if (intr_loc & PCI_EXP_SLTSTA_ABP)
837 pciehp_handle_attention_button(p_slot); 705 pciehp_handle_attention_button(p_slot);
838 706
839 /* Check Presence Detect Changed */ 707 /* Check Presence Detect Changed */
840 if (intr_loc & PRSN_DETECT_CHANGED) 708 if (intr_loc & PCI_EXP_SLTSTA_PDC)
841 pciehp_handle_presence_change(p_slot); 709 pciehp_handle_presence_change(p_slot);
842 710
843 /* Check Power Fault Detected */ 711 /* Check Power Fault Detected */
844 if (intr_loc & PWR_FAULT_DETECTED) 712 if (intr_loc & PCI_EXP_SLTSTA_PFD)
845 pciehp_handle_power_fault(p_slot); 713 pciehp_handle_power_fault(p_slot);
846 714
847 return IRQ_HANDLED; 715 return IRQ_HANDLED;
@@ -854,7 +722,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
854 u32 lnk_cap; 722 u32 lnk_cap;
855 int retval = 0; 723 int retval = 0;
856 724
857 retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); 725 retval = pciehp_readl(ctrl, PCI_EXP_LNKCAP, &lnk_cap);
858 if (retval) { 726 if (retval) {
859 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); 727 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
860 return retval; 728 return retval;
@@ -883,13 +751,13 @@ static int hpc_get_max_lnk_width(struct slot *slot,
883 u32 lnk_cap; 751 u32 lnk_cap;
884 int retval = 0; 752 int retval = 0;
885 753
886 retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); 754 retval = pciehp_readl(ctrl, PCI_EXP_LNKCAP, &lnk_cap);
887 if (retval) { 755 if (retval) {
888 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); 756 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
889 return retval; 757 return retval;
890 } 758 }
891 759
892 switch ((lnk_cap & 0x03F0) >> 4){ 760 switch ((lnk_cap & PCI_EXP_LNKSTA_NLW) >> 4){
893 case 0: 761 case 0:
894 lnk_wdth = PCIE_LNK_WIDTH_RESRV; 762 lnk_wdth = PCIE_LNK_WIDTH_RESRV;
895 break; 763 break;
@@ -932,14 +800,14 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
932 int retval = 0; 800 int retval = 0;
933 u16 lnk_status; 801 u16 lnk_status;
934 802
935 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); 803 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
936 if (retval) { 804 if (retval) {
937 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", 805 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
938 __func__); 806 __func__);
939 return retval; 807 return retval;
940 } 808 }
941 809
942 switch (lnk_status & 0x0F) { 810 switch (lnk_status & PCI_EXP_LNKSTA_CLS) {
943 case 1: 811 case 1:
944 lnk_speed = PCIE_2PT5GB; 812 lnk_speed = PCIE_2PT5GB;
945 break; 813 break;
@@ -962,14 +830,14 @@ static int hpc_get_cur_lnk_width(struct slot *slot,
962 int retval = 0; 830 int retval = 0;
963 u16 lnk_status; 831 u16 lnk_status;
964 832
965 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); 833 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
966 if (retval) { 834 if (retval) {
967 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", 835 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
968 __func__); 836 __func__);
969 return retval; 837 return retval;
970 } 838 }
971 839
972 switch ((lnk_status & 0x03F0) >> 4){ 840 switch ((lnk_status & PCI_EXP_LNKSTA_NLW) >> 4){
973 case 0: 841 case 0:
974 lnk_wdth = PCIE_LNK_WIDTH_RESRV; 842 lnk_wdth = PCIE_LNK_WIDTH_RESRV;
975 break; 843 break;
@@ -1035,18 +903,19 @@ int pcie_enable_notification(struct controller *ctrl)
1035{ 903{
1036 u16 cmd, mask; 904 u16 cmd, mask;
1037 905
1038 cmd = PRSN_DETECT_ENABLE; 906 cmd = PCI_EXP_SLTCTL_PDCE;
1039 if (ATTN_BUTTN(ctrl)) 907 if (ATTN_BUTTN(ctrl))
1040 cmd |= ATTN_BUTTN_ENABLE; 908 cmd |= PCI_EXP_SLTCTL_ABPE;
1041 if (POWER_CTRL(ctrl)) 909 if (POWER_CTRL(ctrl))
1042 cmd |= PWR_FAULT_DETECT_ENABLE; 910 cmd |= PCI_EXP_SLTCTL_PFDE;
1043 if (MRL_SENS(ctrl)) 911 if (MRL_SENS(ctrl))
1044 cmd |= MRL_DETECT_ENABLE; 912 cmd |= PCI_EXP_SLTCTL_MRLSCE;
1045 if (!pciehp_poll_mode) 913 if (!pciehp_poll_mode)
1046 cmd |= HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; 914 cmd |= PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE;
1047 915
1048 mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | 916 mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
1049 PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; 917 PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE |
918 PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE);
1050 919
1051 if (pcie_write_cmd(ctrl, cmd, mask)) { 920 if (pcie_write_cmd(ctrl, cmd, mask)) {
1052 ctrl_err(ctrl, "Cannot enable software notification\n"); 921 ctrl_err(ctrl, "Cannot enable software notification\n");
@@ -1058,8 +927,9 @@ int pcie_enable_notification(struct controller *ctrl)
1058static void pcie_disable_notification(struct controller *ctrl) 927static void pcie_disable_notification(struct controller *ctrl)
1059{ 928{
1060 u16 mask; 929 u16 mask;
1061 mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | 930 mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
1062 PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; 931 PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE |
932 PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE);
1063 if (pcie_write_cmd(ctrl, 0, mask)) 933 if (pcie_write_cmd(ctrl, 0, mask))
1064 ctrl_warn(ctrl, "Cannot disable software notification\n"); 934 ctrl_warn(ctrl, "Cannot disable software notification\n");
1065} 935}
@@ -1156,9 +1026,9 @@ static inline void dbg_ctrl(struct controller *ctrl)
1156 EMI(ctrl) ? "yes" : "no"); 1026 EMI(ctrl) ? "yes" : "no");
1157 ctrl_info(ctrl, " Command Completed : %3s\n", 1027 ctrl_info(ctrl, " Command Completed : %3s\n",
1158 NO_CMD_CMPL(ctrl) ? "no" : "yes"); 1028 NO_CMD_CMPL(ctrl) ? "no" : "yes");
1159 pciehp_readw(ctrl, SLOTSTATUS, &reg16); 1029 pciehp_readw(ctrl, PCI_EXP_SLTSTA, &reg16);
1160 ctrl_info(ctrl, "Slot Status : 0x%04x\n", reg16); 1030 ctrl_info(ctrl, "Slot Status : 0x%04x\n", reg16);
1161 pciehp_readw(ctrl, SLOTCTRL, &reg16); 1031 pciehp_readw(ctrl, PCI_EXP_SLTCTL, &reg16);
1162 ctrl_info(ctrl, "Slot Control : 0x%04x\n", reg16); 1032 ctrl_info(ctrl, "Slot Control : 0x%04x\n", reg16);
1163} 1033}
1164 1034
@@ -1182,7 +1052,7 @@ struct controller *pcie_init(struct pcie_device *dev)
1182 ctrl_err(ctrl, "Cannot find PCI Express capability\n"); 1052 ctrl_err(ctrl, "Cannot find PCI Express capability\n");
1183 goto abort_ctrl; 1053 goto abort_ctrl;
1184 } 1054 }
1185 if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { 1055 if (pciehp_readl(ctrl, PCI_EXP_SLTCAP, &slot_cap)) {
1186 ctrl_err(ctrl, "Cannot read SLOTCAP register\n"); 1056 ctrl_err(ctrl, "Cannot read SLOTCAP register\n");
1187 goto abort_ctrl; 1057 goto abort_ctrl;
1188 } 1058 }
@@ -1207,17 +1077,17 @@ struct controller *pcie_init(struct pcie_device *dev)
1207 ctrl->no_cmd_complete = 1; 1077 ctrl->no_cmd_complete = 1;
1208 1078
1209 /* Check if Data Link Layer Link Active Reporting is implemented */ 1079 /* Check if Data Link Layer Link Active Reporting is implemented */
1210 if (pciehp_readl(ctrl, LNKCAP, &link_cap)) { 1080 if (pciehp_readl(ctrl, PCI_EXP_LNKCAP, &link_cap)) {
1211 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); 1081 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
1212 goto abort_ctrl; 1082 goto abort_ctrl;
1213 } 1083 }
1214 if (link_cap & LINK_ACTIVE_REPORTING) { 1084 if (link_cap & PCI_EXP_LNKCAP_DLLLARC) {
1215 ctrl_dbg(ctrl, "Link Active Reporting supported\n"); 1085 ctrl_dbg(ctrl, "Link Active Reporting supported\n");
1216 ctrl->link_active_reporting = 1; 1086 ctrl->link_active_reporting = 1;
1217 } 1087 }
1218 1088
1219 /* Clear all remaining event bits in Slot Status register */ 1089 /* Clear all remaining event bits in Slot Status register */
1220 if (pciehp_writew(ctrl, SLOTSTATUS, 0x1f)) 1090 if (pciehp_writew(ctrl, PCI_EXP_SLTSTA, 0x1f))
1221 goto abort_ctrl; 1091 goto abort_ctrl;
1222 1092
1223 /* Disable sotfware notification */ 1093 /* Disable sotfware notification */