Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
sata_mv: shorten register names
sata_mv: workaround errata SATA#13
sata_mv: cosmetic renames
sata_mv: workaround errata SATA#26
sata_mv: workaround errata PCI#7
sata_mv: replace 0x1f with ATA_PIO4 (v2)
sata_mv: fix irq mask races
sata_mv: revert SoC irq breakage
libata: ahci enclosure management bios workaround
ata: Add TRIM infrastructure
ata_piix: VGN-BX297XP wants the controller power up on suspend
libata: Remove some redundant casts from pata_octeon_cf.c
pata_artop: typo

+344 -216
+1 -1
block/blk-settings.c
··· 431 431 * 432 432 * description: 433 433 * set required memory and length alignment for direct dma transactions. 434 - * this is used when buiding direct io requests for the queue. 434 + * this is used when building direct io requests for the queue. 435 435 * 436 436 **/ 437 437 void blk_queue_dma_alignment(struct request_queue *q, int mask)
+15 -2
drivers/ata/ahci.c
··· 78 78 static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, 79 79 ssize_t size); 80 80 #define MAX_SLOTS 8 81 + #define MAX_RETRY 15 81 82 82 83 enum { 83 84 AHCI_PCI_BAR = 5, ··· 1116 1115 struct ahci_port_priv *pp = ap->private_data; 1117 1116 struct ata_link *link; 1118 1117 struct ahci_em_priv *emp; 1118 + ssize_t rc; 1119 + int i; 1119 1120 1120 1121 /* enable FIS reception */ 1121 1122 ahci_start_fis_rx(ap); ··· 1129 1126 if (ap->flags & ATA_FLAG_EM) { 1130 1127 ata_for_each_link(link, ap, EDGE) { 1131 1128 emp = &pp->em_priv[link->pmp]; 1132 - ahci_transmit_led_message(ap, emp->led_state, 4); 1129 + 1130 + /* EM Transmit bit maybe busy during init */ 1131 + for (i = 0; i < MAX_RETRY; i++) { 1132 + rc = ahci_transmit_led_message(ap, 1133 + emp->led_state, 1134 + 4); 1135 + if (rc == -EBUSY) 1136 + udelay(100); 1137 + else 1138 + break; 1139 + } 1133 1140 } 1134 1141 } 1135 1142 ··· 1344 1331 em_ctl = readl(mmio + HOST_EM_CTL); 1345 1332 if (em_ctl & EM_CTL_TM) { 1346 1333 spin_unlock_irqrestore(ap->lock, flags); 1347 - return -EINVAL; 1334 + return -EBUSY; 1348 1335 } 1349 1336 1350 1337 /*
+7
drivers/ata/ata_piix.c
··· 1053 1053 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE M500"), 1054 1054 }, 1055 1055 }, 1056 + { 1057 + .ident = "VGN-BX297XP", 1058 + .matches = { 1059 + DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), 1060 + DMI_MATCH(DMI_PRODUCT_NAME, "VGN-BX297XP"), 1061 + }, 1062 + }, 1056 1063 1057 1064 { } /* terminate list */ 1058 1065 };
+3 -3
drivers/ata/pata_octeon_cf.c
··· 503 503 struct ata_port *ap = qc->ap; 504 504 struct octeon_cf_port *cf_port; 505 505 506 - cf_port = (struct octeon_cf_port *)ap->private_data; 506 + cf_port = ap->private_data; 507 507 DPRINTK("ENTER\n"); 508 508 /* issue r/w command */ 509 509 qc->cursg = qc->sg; ··· 596 596 if (ap->hsm_task_state != HSM_ST_LAST) 597 597 return 0; 598 598 599 - cf_port = (struct octeon_cf_port *)ap->private_data; 599 + cf_port = ap->private_data; 600 600 601 601 dma_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine)); 602 602 if (dma_cfg.s.size != 0xfffff) { ··· 657 657 continue; 658 658 659 659 ocd = ap->dev->platform_data; 660 - cf_port = (struct octeon_cf_port *)ap->private_data; 660 + cf_port = ap->private_data; 661 661 dma_int.u64 = 662 662 cvmx_read_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine)); 663 663 dma_cfg.u64 =
+277 -210
drivers/ata/sata_mv.c
··· 28 28 /* 29 29 * sata_mv TODO list: 30 30 * 31 - * --> More errata workarounds for PCI-X. 32 - * 33 - * --> Complete a full errata audit for all chipsets to identify others. 34 - * 35 31 * --> Develop a low-power-consumption strategy, and implement it. 36 32 * 37 33 * --> Add sysfs attributes for per-chip / per-HC IRQ coalescing thresholds. ··· 38 42 * 39 43 * Target mode, for those without docs, is the ability to directly 40 44 * connect two SATA ports. 45 + */ 46 + 47 + /* 48 + * 80x1-B2 errata PCI#11: 49 + * 50 + * Users of the 6041/6081 Rev.B2 chips (current is C0) 51 + * should be careful to insert those cards only onto PCI-X bus #0, 52 + * and only in device slots 0..7, not higher. The chips may not 53 + * work correctly otherwise (note: this is a pretty rare condition). 41 54 */ 42 55 43 56 #include <linux/kernel.h> ··· 69 64 #include <linux/libata.h> 70 65 71 66 #define DRV_NAME "sata_mv" 72 - #define DRV_VERSION "1.27" 67 + #define DRV_VERSION "1.28" 73 68 74 69 /* 75 70 * module options ··· 114 109 * Coalescing defers the interrupt until either the IO_THRESHOLD 115 110 * (count of completed I/Os) is met, or the TIME_THRESHOLD is met. 116 111 */ 117 - MV_COAL_REG_BASE = 0x18000, 118 - MV_IRQ_COAL_CAUSE = (MV_COAL_REG_BASE + 0x08), 112 + COAL_REG_BASE = 0x18000, 113 + IRQ_COAL_CAUSE = (COAL_REG_BASE + 0x08), 119 114 ALL_PORTS_COAL_IRQ = (1 << 4), /* all ports irq event */ 120 115 121 - MV_IRQ_COAL_IO_THRESHOLD = (MV_COAL_REG_BASE + 0xcc), 122 - MV_IRQ_COAL_TIME_THRESHOLD = (MV_COAL_REG_BASE + 0xd0), 116 + IRQ_COAL_IO_THRESHOLD = (COAL_REG_BASE + 0xcc), 117 + IRQ_COAL_TIME_THRESHOLD = (COAL_REG_BASE + 0xd0), 123 118 124 119 /* 125 120 * Registers for the (unused here) transaction coalescing feature: 126 121 */ 127 - MV_TRAN_COAL_CAUSE_LO = (MV_COAL_REG_BASE + 0x88), 128 - MV_TRAN_COAL_CAUSE_HI = (MV_COAL_REG_BASE + 0x8c), 122 + TRAN_COAL_CAUSE_LO = (COAL_REG_BASE + 0x88), 123 + TRAN_COAL_CAUSE_HI = (COAL_REG_BASE + 0x8c), 129 124 130 - MV_SATAHC0_REG_BASE = 0x20000, 131 - MV_FLASH_CTL_OFS = 0x1046c, 132 - MV_GPIO_PORT_CTL_OFS = 0x104f0, 133 - MV_RESET_CFG_OFS = 0x180d8, 125 + SATAHC0_REG_BASE = 0x20000, 126 + FLASH_CTL = 0x1046c, 127 + GPIO_PORT_CTL = 0x104f0, 128 + RESET_CFG = 0x180d8, 134 129 135 130 MV_PCI_REG_SZ = MV_MAJOR_REG_AREA_SZ, 136 131 MV_SATAHC_REG_SZ = MV_MAJOR_REG_AREA_SZ, ··· 185 180 186 181 /* PCI interface registers */ 187 182 188 - PCI_COMMAND_OFS = 0xc00, 189 - PCI_COMMAND_MRDTRIG = (1 << 7), /* PCI Master Read Trigger */ 183 + MV_PCI_COMMAND = 0xc00, 184 + MV_PCI_COMMAND_MWRCOM = (1 << 4), /* PCI Master Write Combining */ 185 + MV_PCI_COMMAND_MRDTRIG = (1 << 7), /* PCI Master Read Trigger */ 190 186 191 - PCI_MAIN_CMD_STS_OFS = 0xd30, 187 + PCI_MAIN_CMD_STS = 0xd30, 192 188 STOP_PCI_MASTER = (1 << 2), 193 189 PCI_MASTER_EMPTY = (1 << 3), 194 190 GLOB_SFT_RST = (1 << 4), 195 191 196 - MV_PCI_MODE_OFS = 0xd00, 192 + MV_PCI_MODE = 0xd00, 197 193 MV_PCI_MODE_MASK = 0x30, 198 194 199 195 MV_PCI_EXP_ROM_BAR_CTL = 0xd2c, 200 196 MV_PCI_DISC_TIMER = 0xd04, 201 197 MV_PCI_MSI_TRIGGER = 0xc38, 202 198 MV_PCI_SERR_MASK = 0xc28, 203 - MV_PCI_XBAR_TMOUT_OFS = 0x1d04, 199 + MV_PCI_XBAR_TMOUT = 0x1d04, 204 200 MV_PCI_ERR_LOW_ADDRESS = 0x1d40, 205 201 MV_PCI_ERR_HIGH_ADDRESS = 0x1d44, 206 202 MV_PCI_ERR_ATTRIBUTE = 0x1d48, 207 203 MV_PCI_ERR_COMMAND = 0x1d50, 208 204 209 - PCI_IRQ_CAUSE_OFS = 0x1d58, 210 - PCI_IRQ_MASK_OFS = 0x1d5c, 205 + PCI_IRQ_CAUSE = 0x1d58, 206 + PCI_IRQ_MASK = 0x1d5c, 211 207 PCI_UNMASK_ALL_IRQS = 0x7fffff, /* bits 22-0 */ 212 208 213 - PCIE_IRQ_CAUSE_OFS = 0x1900, 214 - PCIE_IRQ_MASK_OFS = 0x1910, 209 + PCIE_IRQ_CAUSE = 0x1900, 210 + PCIE_IRQ_MASK = 0x1910, 215 211 PCIE_UNMASK_ALL_IRQS = 0x40a, /* assorted bits */ 216 212 217 213 /* Host Controller Main Interrupt Cause/Mask registers (1 per-chip) */ 218 - PCI_HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, 219 - PCI_HC_MAIN_IRQ_MASK_OFS = 0x1d64, 220 - SOC_HC_MAIN_IRQ_CAUSE_OFS = 0x20020, 221 - SOC_HC_MAIN_IRQ_MASK_OFS = 0x20024, 214 + PCI_HC_MAIN_IRQ_CAUSE = 0x1d60, 215 + PCI_HC_MAIN_IRQ_MASK = 0x1d64, 216 + SOC_HC_MAIN_IRQ_CAUSE = 0x20020, 217 + SOC_HC_MAIN_IRQ_MASK = 0x20024, 222 218 ERR_IRQ = (1 << 0), /* shift by (2 * port #) */ 223 219 DONE_IRQ = (1 << 1), /* shift by (2 * port #) */ 224 220 HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */ ··· 240 234 HC_MAIN_RSVD_SOC = (0x3fffffb << 6), /* bits 31-9, 7-6 */ 241 235 242 236 /* SATAHC registers */ 243 - HC_CFG_OFS = 0, 237 + HC_CFG = 0x00, 244 238 245 - HC_IRQ_CAUSE_OFS = 0x14, 239 + HC_IRQ_CAUSE = 0x14, 246 240 DMA_IRQ = (1 << 0), /* shift by port # */ 247 241 HC_COAL_IRQ = (1 << 4), /* IRQ coalescing */ 248 242 DEV_IRQ = (1 << 8), /* shift by port # */ ··· 254 248 * Coalescing defers the interrupt until either the IO_THRESHOLD 255 249 * (count of completed I/Os) is met, or the TIME_THRESHOLD is met. 256 250 */ 257 - HC_IRQ_COAL_IO_THRESHOLD_OFS = 0x000c, 258 - HC_IRQ_COAL_TIME_THRESHOLD_OFS = 0x0010, 251 + HC_IRQ_COAL_IO_THRESHOLD = 0x000c, 252 + HC_IRQ_COAL_TIME_THRESHOLD = 0x0010, 259 253 260 - SOC_LED_CTRL_OFS = 0x2c, 254 + SOC_LED_CTRL = 0x2c, 261 255 SOC_LED_CTRL_BLINK = (1 << 0), /* Active LED blink */ 262 256 SOC_LED_CTRL_ACT_PRESENCE = (1 << 2), /* Multiplex dev presence */ 263 257 /* with dev activity LED */ 264 258 265 259 /* Shadow block registers */ 266 - SHD_BLK_OFS = 0x100, 267 - SHD_CTL_AST_OFS = 0x20, /* ofs from SHD_BLK_OFS */ 260 + SHD_BLK = 0x100, 261 + SHD_CTL_AST = 0x20, /* ofs from SHD_BLK */ 268 262 269 263 /* SATA registers */ 270 - SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */ 271 - SATA_ACTIVE_OFS = 0x350, 272 - SATA_FIS_IRQ_CAUSE_OFS = 0x364, 273 - SATA_FIS_IRQ_AN = (1 << 9), /* async notification */ 264 + SATA_STATUS = 0x300, /* ctrl, err regs follow status */ 265 + SATA_ACTIVE = 0x350, 266 + FIS_IRQ_CAUSE = 0x364, 267 + FIS_IRQ_CAUSE_AN = (1 << 9), /* async notification */ 274 268 275 - LTMODE_OFS = 0x30c, 269 + LTMODE = 0x30c, /* requires read-after-write */ 276 270 LTMODE_BIT8 = (1 << 8), /* unknown, but necessary */ 277 271 272 + PHY_MODE2 = 0x330, 278 273 PHY_MODE3 = 0x310, 279 - PHY_MODE4 = 0x314, 274 + 275 + PHY_MODE4 = 0x314, /* requires read-after-write */ 280 276 PHY_MODE4_CFG_MASK = 0x00000003, /* phy internal config field */ 281 277 PHY_MODE4_CFG_VALUE = 0x00000001, /* phy internal config field */ 282 278 PHY_MODE4_RSVD_ZEROS = 0x5de3fffa, /* Gen2e always write zeros */ 283 279 PHY_MODE4_RSVD_ONES = 0x00000005, /* Gen2e always write ones */ 284 280 285 - PHY_MODE2 = 0x330, 286 - SATA_IFCTL_OFS = 0x344, 287 - SATA_TESTCTL_OFS = 0x348, 288 - SATA_IFSTAT_OFS = 0x34c, 289 - VENDOR_UNIQUE_FIS_OFS = 0x35c, 281 + SATA_IFCTL = 0x344, 282 + SATA_TESTCTL = 0x348, 283 + SATA_IFSTAT = 0x34c, 284 + VENDOR_UNIQUE_FIS = 0x35c, 290 285 291 - FISCFG_OFS = 0x360, 286 + FISCFG = 0x360, 292 287 FISCFG_WAIT_DEV_ERR = (1 << 8), /* wait for host on DevErr */ 293 288 FISCFG_SINGLE_SYNC = (1 << 16), /* SYNC on DMA activation */ 294 289 295 290 MV5_PHY_MODE = 0x74, 296 - MV5_LTMODE_OFS = 0x30, 297 - MV5_PHY_CTL_OFS = 0x0C, 298 - SATA_INTERFACE_CFG_OFS = 0x050, 291 + MV5_LTMODE = 0x30, 292 + MV5_PHY_CTL = 0x0C, 293 + SATA_IFCFG = 0x050, 299 294 300 295 MV_M2_PREAMP_MASK = 0x7e0, 301 296 302 297 /* Port registers */ 303 - EDMA_CFG_OFS = 0, 298 + EDMA_CFG = 0, 304 299 EDMA_CFG_Q_DEPTH = 0x1f, /* max device queue depth */ 305 300 EDMA_CFG_NCQ = (1 << 5), /* for R/W FPDMA queued */ 306 301 EDMA_CFG_NCQ_GO_ON_ERR = (1 << 14), /* continue on error */ ··· 310 303 EDMA_CFG_EDMA_FBS = (1 << 16), /* EDMA FIS-Based Switching */ 311 304 EDMA_CFG_FBS = (1 << 26), /* FIS-Based Switching */ 312 305 313 - EDMA_ERR_IRQ_CAUSE_OFS = 0x8, 314 - EDMA_ERR_IRQ_MASK_OFS = 0xc, 306 + EDMA_ERR_IRQ_CAUSE = 0x8, 307 + EDMA_ERR_IRQ_MASK = 0xc, 315 308 EDMA_ERR_D_PAR = (1 << 0), /* UDMA data parity err */ 316 309 EDMA_ERR_PRD_PAR = (1 << 1), /* UDMA PRD parity err */ 317 310 EDMA_ERR_DEV = (1 << 2), /* device error */ ··· 380 373 EDMA_ERR_INTRL_PAR | 381 374 EDMA_ERR_IORDY, 382 375 383 - EDMA_REQ_Q_BASE_HI_OFS = 0x10, 384 - EDMA_REQ_Q_IN_PTR_OFS = 0x14, /* also contains BASE_LO */ 376 + EDMA_REQ_Q_BASE_HI = 0x10, 377 + EDMA_REQ_Q_IN_PTR = 0x14, /* also contains BASE_LO */ 385 378 386 - EDMA_REQ_Q_OUT_PTR_OFS = 0x18, 379 + EDMA_REQ_Q_OUT_PTR = 0x18, 387 380 EDMA_REQ_Q_PTR_SHIFT = 5, 388 381 389 - EDMA_RSP_Q_BASE_HI_OFS = 0x1c, 390 - EDMA_RSP_Q_IN_PTR_OFS = 0x20, 391 - EDMA_RSP_Q_OUT_PTR_OFS = 0x24, /* also contains BASE_LO */ 382 + EDMA_RSP_Q_BASE_HI = 0x1c, 383 + EDMA_RSP_Q_IN_PTR = 0x20, 384 + EDMA_RSP_Q_OUT_PTR = 0x24, /* also contains BASE_LO */ 392 385 EDMA_RSP_Q_PTR_SHIFT = 3, 393 386 394 - EDMA_CMD_OFS = 0x28, /* EDMA command register */ 387 + EDMA_CMD = 0x28, /* EDMA command register */ 395 388 EDMA_EN = (1 << 0), /* enable EDMA */ 396 389 EDMA_DS = (1 << 1), /* disable EDMA; self-negated */ 397 390 EDMA_RESET = (1 << 2), /* reset eng/trans/link/phy */ 398 391 399 - EDMA_STATUS_OFS = 0x30, /* EDMA engine status */ 392 + EDMA_STATUS = 0x30, /* EDMA engine status */ 400 393 EDMA_STATUS_CACHE_EMPTY = (1 << 6), /* GenIIe command cache empty */ 401 394 EDMA_STATUS_IDLE = (1 << 7), /* GenIIe EDMA enabled/idle */ 402 395 403 - EDMA_IORDY_TMOUT_OFS = 0x34, 404 - EDMA_ARB_CFG_OFS = 0x38, 396 + EDMA_IORDY_TMOUT = 0x34, 397 + EDMA_ARB_CFG = 0x38, 405 398 406 - EDMA_HALTCOND_OFS = 0x60, /* GenIIe halt conditions */ 407 - EDMA_UNKNOWN_RSVD_OFS = 0x6C, /* GenIIe unknown/reserved */ 399 + EDMA_HALTCOND = 0x60, /* GenIIe halt conditions */ 400 + EDMA_UNKNOWN_RSVD = 0x6C, /* GenIIe unknown/reserved */ 408 401 409 - BMDMA_CMD_OFS = 0x224, /* bmdma command register */ 410 - BMDMA_STATUS_OFS = 0x228, /* bmdma status register */ 411 - BMDMA_PRD_LOW_OFS = 0x22c, /* bmdma PRD addr 31:0 */ 412 - BMDMA_PRD_HIGH_OFS = 0x230, /* bmdma PRD addr 63:32 */ 402 + BMDMA_CMD = 0x224, /* bmdma command register */ 403 + BMDMA_STATUS = 0x228, /* bmdma status register */ 404 + BMDMA_PRD_LOW = 0x22c, /* bmdma PRD addr 31:0 */ 405 + BMDMA_PRD_HIGH = 0x230, /* bmdma PRD addr 63:32 */ 413 406 414 407 /* Host private flags (hp_flags) */ 415 408 MV_HP_FLAG_MSI = (1 << 0), ··· 541 534 void __iomem *base; 542 535 void __iomem *main_irq_cause_addr; 543 536 void __iomem *main_irq_mask_addr; 544 - u32 irq_cause_ofs; 545 - u32 irq_mask_ofs; 537 + u32 irq_cause_offset; 538 + u32 irq_mask_offset; 546 539 u32 unmask_all_irqs; 547 540 /* 548 541 * These consistent DMA memory pools give us guaranteed ··· 701 694 static const struct ata_port_info mv_port_info[] = { 702 695 { /* chip_504x */ 703 696 .flags = MV_GEN_I_FLAGS, 704 - .pio_mask = 0x1f, /* pio0-4 */ 697 + .pio_mask = ATA_PIO4, 705 698 .udma_mask = ATA_UDMA6, 706 699 .port_ops = &mv5_ops, 707 700 }, 708 701 { /* chip_508x */ 709 702 .flags = MV_GEN_I_FLAGS | MV_FLAG_DUAL_HC, 710 - .pio_mask = 0x1f, /* pio0-4 */ 703 + .pio_mask = ATA_PIO4, 711 704 .udma_mask = ATA_UDMA6, 712 705 .port_ops = &mv5_ops, 713 706 }, 714 707 { /* chip_5080 */ 715 708 .flags = MV_GEN_I_FLAGS | MV_FLAG_DUAL_HC, 716 - .pio_mask = 0x1f, /* pio0-4 */ 709 + .pio_mask = ATA_PIO4, 717 710 .udma_mask = ATA_UDMA6, 718 711 .port_ops = &mv5_ops, 719 712 }, 720 713 { /* chip_604x */ 721 714 .flags = MV_GEN_II_FLAGS, 722 - .pio_mask = 0x1f, /* pio0-4 */ 715 + .pio_mask = ATA_PIO4, 723 716 .udma_mask = ATA_UDMA6, 724 717 .port_ops = &mv6_ops, 725 718 }, 726 719 { /* chip_608x */ 727 720 .flags = MV_GEN_II_FLAGS | MV_FLAG_DUAL_HC, 728 - .pio_mask = 0x1f, /* pio0-4 */ 721 + .pio_mask = ATA_PIO4, 729 722 .udma_mask = ATA_UDMA6, 730 723 .port_ops = &mv6_ops, 731 724 }, 732 725 { /* chip_6042 */ 733 726 .flags = MV_GEN_IIE_FLAGS, 734 - .pio_mask = 0x1f, /* pio0-4 */ 727 + .pio_mask = ATA_PIO4, 735 728 .udma_mask = ATA_UDMA6, 736 729 .port_ops = &mv_iie_ops, 737 730 }, 738 731 { /* chip_7042 */ 739 732 .flags = MV_GEN_IIE_FLAGS, 740 - .pio_mask = 0x1f, /* pio0-4 */ 733 + .pio_mask = ATA_PIO4, 741 734 .udma_mask = ATA_UDMA6, 742 735 .port_ops = &mv_iie_ops, 743 736 }, 744 737 { /* chip_soc */ 745 738 .flags = MV_GEN_IIE_FLAGS, 746 - .pio_mask = 0x1f, /* pio0-4 */ 739 + .pio_mask = ATA_PIO4, 747 740 .udma_mask = ATA_UDMA6, 748 741 .port_ops = &mv_iie_ops, 749 742 }, ··· 847 840 848 841 static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc) 849 842 { 850 - return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ)); 843 + return (base + SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ)); 851 844 } 852 845 853 846 static inline void __iomem *mv_hc_base_from_port(void __iomem *base, ··· 902 895 void __iomem *port_mmio = mv_ap_base(ap); 903 896 struct mv_port_priv *pp = ap->private_data; 904 897 905 - pp->cached.fiscfg = readl(port_mmio + FISCFG_OFS); 906 - pp->cached.ltmode = readl(port_mmio + LTMODE_OFS); 907 - pp->cached.haltcond = readl(port_mmio + EDMA_HALTCOND_OFS); 908 - pp->cached.unknown_rsvd = readl(port_mmio + EDMA_UNKNOWN_RSVD_OFS); 898 + pp->cached.fiscfg = readl(port_mmio + FISCFG); 899 + pp->cached.ltmode = readl(port_mmio + LTMODE); 900 + pp->cached.haltcond = readl(port_mmio + EDMA_HALTCOND); 901 + pp->cached.unknown_rsvd = readl(port_mmio + EDMA_UNKNOWN_RSVD); 909 902 } 910 903 911 904 /** ··· 920 913 static inline void mv_write_cached_reg(void __iomem *addr, u32 *old, u32 new) 921 914 { 922 915 if (new != *old) { 916 + unsigned long laddr; 923 917 *old = new; 924 - writel(new, addr); 918 + /* 919 + * Workaround for 88SX60x1-B2 FEr SATA#13: 920 + * Read-after-write is needed to prevent generating 64-bit 921 + * write cycles on the PCI bus for SATA interface registers 922 + * at offsets ending in 0x4 or 0xc. 923 + * 924 + * Looks like a lot of fuss, but it avoids an unnecessary 925 + * +1 usec read-after-write delay for unaffected registers. 926 + */ 927 + laddr = (long)addr & 0xffff; 928 + if (laddr >= 0x300 && laddr <= 0x33c) { 929 + laddr &= 0x000f; 930 + if (laddr == 0x4 || laddr == 0xc) { 931 + writelfl(new, addr); /* read after write */ 932 + return; 933 + } 934 + } 935 + writel(new, addr); /* unaffected by the errata */ 925 936 } 926 937 } 927 938 ··· 956 931 index = pp->req_idx << EDMA_REQ_Q_PTR_SHIFT; 957 932 958 933 WARN_ON(pp->crqb_dma & 0x3ff); 959 - writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); 934 + writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI); 960 935 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | index, 961 - port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 962 - writelfl(index, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); 936 + port_mmio + EDMA_REQ_Q_IN_PTR); 937 + writelfl(index, port_mmio + EDMA_REQ_Q_OUT_PTR); 963 938 964 939 /* 965 940 * initialize response queue ··· 968 943 index = pp->resp_idx << EDMA_RSP_Q_PTR_SHIFT; 969 944 970 945 WARN_ON(pp->crpb_dma & 0xff); 971 - writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); 972 - writelfl(index, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); 946 + writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI); 947 + writelfl(index, port_mmio + EDMA_RSP_Q_IN_PTR); 973 948 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) | index, 974 - port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 949 + port_mmio + EDMA_RSP_Q_OUT_PTR); 975 950 } 976 951 977 952 static void mv_write_main_irq_mask(u32 mask, struct mv_host_priv *hpriv) ··· 1029 1004 u32 hc_irq_cause; 1030 1005 1031 1006 /* clear EDMA event indicators, if any */ 1032 - writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 1007 + writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE); 1033 1008 1034 1009 /* clear pending irq events */ 1035 1010 hc_irq_cause = ~((DEV_IRQ | DMA_IRQ) << hardport); 1036 - writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); 1011 + writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE); 1037 1012 1038 1013 /* clear FIS IRQ Cause */ 1039 1014 if (IS_GEN_IIE(hpriv)) 1040 - writelfl(0, port_mmio + SATA_FIS_IRQ_CAUSE_OFS); 1015 + writelfl(0, port_mmio + FIS_IRQ_CAUSE); 1041 1016 1042 1017 mv_enable_port_irqs(ap, port_irqs); 1043 1018 } ··· 1073 1048 * GEN_II/GEN_IIE with dual host controllers: 1074 1049 * one set of global thresholds for the entire chip. 1075 1050 */ 1076 - writel(clks, mmio + MV_IRQ_COAL_TIME_THRESHOLD); 1077 - writel(count, mmio + MV_IRQ_COAL_IO_THRESHOLD); 1051 + writel(clks, mmio + IRQ_COAL_TIME_THRESHOLD); 1052 + writel(count, mmio + IRQ_COAL_IO_THRESHOLD); 1078 1053 /* clear leftover coal IRQ bit */ 1079 - writel(~ALL_PORTS_COAL_IRQ, mmio + MV_IRQ_COAL_CAUSE); 1054 + writel(~ALL_PORTS_COAL_IRQ, mmio + IRQ_COAL_CAUSE); 1080 1055 if (count) 1081 1056 coal_enable = ALL_PORTS_COAL_DONE; 1082 1057 clks = count = 0; /* force clearing of regular regs below */ ··· 1086 1061 * All chips: independent thresholds for each HC on the chip. 1087 1062 */ 1088 1063 hc_mmio = mv_hc_base_from_port(mmio, 0); 1089 - writel(clks, hc_mmio + HC_IRQ_COAL_TIME_THRESHOLD_OFS); 1090 - writel(count, hc_mmio + HC_IRQ_COAL_IO_THRESHOLD_OFS); 1091 - writel(~HC_COAL_IRQ, hc_mmio + HC_IRQ_CAUSE_OFS); 1064 + writel(clks, hc_mmio + HC_IRQ_COAL_TIME_THRESHOLD); 1065 + writel(count, hc_mmio + HC_IRQ_COAL_IO_THRESHOLD); 1066 + writel(~HC_COAL_IRQ, hc_mmio + HC_IRQ_CAUSE); 1092 1067 if (count) 1093 1068 coal_enable |= PORTS_0_3_COAL_DONE; 1094 1069 if (is_dual_hc) { 1095 1070 hc_mmio = mv_hc_base_from_port(mmio, MV_PORTS_PER_HC); 1096 - writel(clks, hc_mmio + HC_IRQ_COAL_TIME_THRESHOLD_OFS); 1097 - writel(count, hc_mmio + HC_IRQ_COAL_IO_THRESHOLD_OFS); 1098 - writel(~HC_COAL_IRQ, hc_mmio + HC_IRQ_CAUSE_OFS); 1071 + writel(clks, hc_mmio + HC_IRQ_COAL_TIME_THRESHOLD); 1072 + writel(count, hc_mmio + HC_IRQ_COAL_IO_THRESHOLD); 1073 + writel(~HC_COAL_IRQ, hc_mmio + HC_IRQ_CAUSE); 1099 1074 if (count) 1100 1075 coal_enable |= PORTS_4_7_COAL_DONE; 1101 1076 } ··· 1133 1108 mv_set_edma_ptrs(port_mmio, hpriv, pp); 1134 1109 mv_clear_and_enable_port_irqs(ap, port_mmio, DONE_IRQ|ERR_IRQ); 1135 1110 1136 - writelfl(EDMA_EN, port_mmio + EDMA_CMD_OFS); 1111 + writelfl(EDMA_EN, port_mmio + EDMA_CMD); 1137 1112 pp->pp_flags |= MV_PP_FLAG_EDMA_EN; 1138 1113 } 1139 1114 } ··· 1153 1128 * as a rough guess at what even more drives might require. 1154 1129 */ 1155 1130 for (i = 0; i < timeout; ++i) { 1156 - u32 edma_stat = readl(port_mmio + EDMA_STATUS_OFS); 1131 + u32 edma_stat = readl(port_mmio + EDMA_STATUS); 1157 1132 if ((edma_stat & empty_idle) == empty_idle) 1158 1133 break; 1159 1134 udelay(per_loop); ··· 1173 1148 int i; 1174 1149 1175 1150 /* Disable eDMA. The disable bit auto clears. */ 1176 - writelfl(EDMA_DS, port_mmio + EDMA_CMD_OFS); 1151 + writelfl(EDMA_DS, port_mmio + EDMA_CMD); 1177 1152 1178 1153 /* Wait for the chip to confirm eDMA is off. */ 1179 1154 for (i = 10000; i > 0; i--) { 1180 - u32 reg = readl(port_mmio + EDMA_CMD_OFS); 1155 + u32 reg = readl(port_mmio + EDMA_CMD); 1181 1156 if (!(reg & EDMA_EN)) 1182 1157 return 0; 1183 1158 udelay(10); ··· 1287 1262 case SCR_STATUS: 1288 1263 case SCR_CONTROL: 1289 1264 case SCR_ERROR: 1290 - ofs = SATA_STATUS_OFS + (sc_reg_in * sizeof(u32)); 1265 + ofs = SATA_STATUS + (sc_reg_in * sizeof(u32)); 1291 1266 break; 1292 1267 case SCR_ACTIVE: 1293 - ofs = SATA_ACTIVE_OFS; /* active is not with the others */ 1268 + ofs = SATA_ACTIVE; /* active is not with the others */ 1294 1269 break; 1295 1270 default: 1296 1271 ofs = 0xffffffffU; ··· 1315 1290 unsigned int ofs = mv_scr_offset(sc_reg_in); 1316 1291 1317 1292 if (ofs != 0xffffffffU) { 1318 - writelfl(val, mv_ap_base(link->ap) + ofs); 1293 + void __iomem *addr = mv_ap_base(link->ap) + ofs; 1294 + if (sc_reg_in == SCR_CONTROL) { 1295 + /* 1296 + * Workaround for 88SX60x1 FEr SATA#26: 1297 + * 1298 + * COMRESETs have to take care not to accidently 1299 + * put the drive to sleep when writing SCR_CONTROL. 1300 + * Setting bits 12..15 prevents this problem. 1301 + * 1302 + * So if we see an outbound COMMRESET, set those bits. 1303 + * Ditto for the followup write that clears the reset. 1304 + * 1305 + * The proprietary driver does this for 1306 + * all chip versions, and so do we. 1307 + */ 1308 + if ((val & 0xf) == 1 || (readl(addr) & 0xf) == 1) 1309 + val |= 0xf000; 1310 + } 1311 + writelfl(val, addr); 1319 1312 return 0; 1320 1313 } else 1321 1314 return -EINVAL; ··· 1411 1368 } 1412 1369 1413 1370 port_mmio = mv_ap_base(ap); 1414 - mv_write_cached_reg(port_mmio + FISCFG_OFS, old_fiscfg, fiscfg); 1415 - mv_write_cached_reg(port_mmio + LTMODE_OFS, old_ltmode, ltmode); 1416 - mv_write_cached_reg(port_mmio + EDMA_HALTCOND_OFS, old_haltcond, haltcond); 1371 + mv_write_cached_reg(port_mmio + FISCFG, old_fiscfg, fiscfg); 1372 + mv_write_cached_reg(port_mmio + LTMODE, old_ltmode, ltmode); 1373 + mv_write_cached_reg(port_mmio + EDMA_HALTCOND, old_haltcond, haltcond); 1417 1374 } 1418 1375 1419 1376 static void mv_60x1_errata_sata25(struct ata_port *ap, int want_ncq) ··· 1422 1379 u32 old, new; 1423 1380 1424 1381 /* workaround for 88SX60x1 FEr SATA#25 (part 1) */ 1425 - old = readl(hpriv->base + MV_GPIO_PORT_CTL_OFS); 1382 + old = readl(hpriv->base + GPIO_PORT_CTL); 1426 1383 if (want_ncq) 1427 1384 new = old | (1 << 22); 1428 1385 else 1429 1386 new = old & ~(1 << 22); 1430 1387 if (new != old) 1431 - writel(new, hpriv->base + MV_GPIO_PORT_CTL_OFS); 1388 + writel(new, hpriv->base + GPIO_PORT_CTL); 1432 1389 } 1433 1390 1434 1391 /** ··· 1452 1409 new = *old | 1; 1453 1410 else 1454 1411 new = *old & ~1; 1455 - mv_write_cached_reg(mv_ap_base(ap) + EDMA_UNKNOWN_RSVD_OFS, old, new); 1412 + mv_write_cached_reg(mv_ap_base(ap) + EDMA_UNKNOWN_RSVD, old, new); 1456 1413 } 1457 1414 1458 1415 /* ··· 1480 1437 return; 1481 1438 hpriv->hp_flags |= MV_HP_QUIRK_LED_BLINK_EN; 1482 1439 hc_mmio = mv_hc_base_from_port(mv_host_base(host), ap->port_no); 1483 - led_ctrl = readl(hc_mmio + SOC_LED_CTRL_OFS); 1484 - writel(led_ctrl | SOC_LED_CTRL_BLINK, hc_mmio + SOC_LED_CTRL_OFS); 1440 + led_ctrl = readl(hc_mmio + SOC_LED_CTRL); 1441 + writel(led_ctrl | SOC_LED_CTRL_BLINK, hc_mmio + SOC_LED_CTRL); 1485 1442 } 1486 1443 1487 1444 static void mv_soc_led_blink_disable(struct ata_port *ap) ··· 1506 1463 1507 1464 hpriv->hp_flags &= ~MV_HP_QUIRK_LED_BLINK_EN; 1508 1465 hc_mmio = mv_hc_base_from_port(mv_host_base(host), ap->port_no); 1509 - led_ctrl = readl(hc_mmio + SOC_LED_CTRL_OFS); 1510 - writel(led_ctrl & ~SOC_LED_CTRL_BLINK, hc_mmio + SOC_LED_CTRL_OFS); 1466 + led_ctrl = readl(hc_mmio + SOC_LED_CTRL); 1467 + writel(led_ctrl & ~SOC_LED_CTRL_BLINK, hc_mmio + SOC_LED_CTRL); 1511 1468 } 1512 1469 1513 1470 static void mv_edma_cfg(struct ata_port *ap, int want_ncq, int want_edma) ··· 1571 1528 pp->pp_flags |= MV_PP_FLAG_NCQ_EN; 1572 1529 } 1573 1530 1574 - writelfl(cfg, port_mmio + EDMA_CFG_OFS); 1531 + writelfl(cfg, port_mmio + EDMA_CFG); 1575 1532 } 1576 1533 1577 1534 static void mv_port_free_dma_mem(struct ata_port *ap) ··· 1618 1575 struct device *dev = ap->host->dev; 1619 1576 struct mv_host_priv *hpriv = ap->host->private_data; 1620 1577 struct mv_port_priv *pp; 1578 + unsigned long flags; 1621 1579 int tag; 1622 1580 1623 1581 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); ··· 1654 1610 pp->sg_tbl_dma[tag] = pp->sg_tbl_dma[0]; 1655 1611 } 1656 1612 } 1613 + 1614 + spin_lock_irqsave(ap->lock, flags); 1657 1615 mv_save_cached_regs(ap); 1658 1616 mv_edma_cfg(ap, 0, 0); 1617 + spin_unlock_irqrestore(ap->lock, flags); 1618 + 1659 1619 return 0; 1660 1620 1661 1621 out_port_free_dma_mem: ··· 1678 1630 */ 1679 1631 static void mv_port_stop(struct ata_port *ap) 1680 1632 { 1633 + unsigned long flags; 1634 + 1635 + spin_lock_irqsave(ap->lock, flags); 1681 1636 mv_stop_edma(ap); 1682 1637 mv_enable_port_irqs(ap, 0); 1638 + spin_unlock_irqrestore(ap->lock, flags); 1683 1639 mv_port_free_dma_mem(ap); 1684 1640 } 1685 1641 ··· 1801 1749 mv_fill_sg(qc); 1802 1750 1803 1751 /* clear all DMA cmd bits */ 1804 - writel(0, port_mmio + BMDMA_CMD_OFS); 1752 + writel(0, port_mmio + BMDMA_CMD); 1805 1753 1806 1754 /* load PRD table addr. */ 1807 1755 writel((pp->sg_tbl_dma[qc->tag] >> 16) >> 16, 1808 - port_mmio + BMDMA_PRD_HIGH_OFS); 1756 + port_mmio + BMDMA_PRD_HIGH); 1809 1757 writelfl(pp->sg_tbl_dma[qc->tag], 1810 - port_mmio + BMDMA_PRD_LOW_OFS); 1758 + port_mmio + BMDMA_PRD_LOW); 1811 1759 1812 1760 /* issue r/w command */ 1813 1761 ap->ops->sff_exec_command(ap, &qc->tf); ··· 1828 1776 u32 cmd = (rw ? 0 : ATA_DMA_WR) | ATA_DMA_START; 1829 1777 1830 1778 /* start host DMA transaction */ 1831 - writelfl(cmd, port_mmio + BMDMA_CMD_OFS); 1779 + writelfl(cmd, port_mmio + BMDMA_CMD); 1832 1780 } 1833 1781 1834 1782 /** ··· 1847 1795 u32 cmd; 1848 1796 1849 1797 /* clear start/stop bit */ 1850 - cmd = readl(port_mmio + BMDMA_CMD_OFS); 1798 + cmd = readl(port_mmio + BMDMA_CMD); 1851 1799 cmd &= ~ATA_DMA_START; 1852 - writelfl(cmd, port_mmio + BMDMA_CMD_OFS); 1800 + writelfl(cmd, port_mmio + BMDMA_CMD); 1853 1801 1854 1802 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */ 1855 1803 ata_sff_dma_pause(ap); ··· 1873 1821 * Other bits are valid only if ATA_DMA_ACTIVE==0, 1874 1822 * and the ATA_DMA_INTR bit doesn't exist. 1875 1823 */ 1876 - reg = readl(port_mmio + BMDMA_STATUS_OFS); 1824 + reg = readl(port_mmio + BMDMA_STATUS); 1877 1825 if (reg & ATA_DMA_ACTIVE) 1878 1826 status = ATA_DMA_ACTIVE; 1879 1827 else ··· 2081 2029 int i, timeout = 200, final_word = nwords - 1; 2082 2030 2083 2031 /* Initiate FIS transmission mode */ 2084 - old_ifctl = readl(port_mmio + SATA_IFCTL_OFS); 2032 + old_ifctl = readl(port_mmio + SATA_IFCTL); 2085 2033 ifctl = 0x100 | (old_ifctl & 0xf); 2086 - writelfl(ifctl, port_mmio + SATA_IFCTL_OFS); 2034 + writelfl(ifctl, port_mmio + SATA_IFCTL); 2087 2035 2088 2036 /* Send all words of the FIS except for the final word */ 2089 2037 for (i = 0; i < final_word; ++i) 2090 - writel(fis[i], port_mmio + VENDOR_UNIQUE_FIS_OFS); 2038 + writel(fis[i], port_mmio + VENDOR_UNIQUE_FIS); 2091 2039 2092 2040 /* Flag end-of-transmission, and then send the final word */ 2093 - writelfl(ifctl | 0x200, port_mmio + SATA_IFCTL_OFS); 2094 - writelfl(fis[final_word], port_mmio + VENDOR_UNIQUE_FIS_OFS); 2041 + writelfl(ifctl | 0x200, port_mmio + SATA_IFCTL); 2042 + writelfl(fis[final_word], port_mmio + VENDOR_UNIQUE_FIS); 2095 2043 2096 2044 /* 2097 2045 * Wait for FIS transmission to complete. 2098 2046 * This typically takes just a single iteration. 2099 2047 */ 2100 2048 do { 2101 - ifstat = readl(port_mmio + SATA_IFSTAT_OFS); 2049 + ifstat = readl(port_mmio + SATA_IFSTAT); 2102 2050 } while (!(ifstat & 0x1000) && --timeout); 2103 2051 2104 2052 /* Restore original port configuration */ 2105 - writelfl(old_ifctl, port_mmio + SATA_IFCTL_OFS); 2053 + writelfl(old_ifctl, port_mmio + SATA_IFCTL); 2106 2054 2107 2055 /* See if it worked */ 2108 2056 if ((ifstat & 0x3000) != 0x1000) { ··· 2200 2148 2201 2149 /* Write the request in pointer to kick the EDMA to life */ 2202 2150 writelfl((pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK) | in_index, 2203 - port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 2151 + port_mmio + EDMA_REQ_Q_IN_PTR); 2204 2152 return 0; 2205 2153 2206 2154 case ATA_PROT_PIO: ··· 2311 2259 { 2312 2260 void __iomem *port_mmio = mv_ap_base(ap); 2313 2261 2314 - return readl(port_mmio + SATA_TESTCTL_OFS) >> 16; 2262 + return readl(port_mmio + SATA_TESTCTL) >> 16; 2315 2263 } 2316 2264 2317 2265 static void mv_pmp_eh_prep(struct ata_port *ap, unsigned int pmp_map) ··· 2344 2292 void __iomem *port_mmio = mv_ap_base(ap); 2345 2293 u32 in_ptr, out_ptr; 2346 2294 2347 - in_ptr = (readl(port_mmio + EDMA_REQ_Q_IN_PTR_OFS) 2295 + in_ptr = (readl(port_mmio + EDMA_REQ_Q_IN_PTR) 2348 2296 >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK; 2349 - out_ptr = (readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) 2297 + out_ptr = (readl(port_mmio + EDMA_REQ_Q_OUT_PTR) 2350 2298 >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK; 2351 2299 return (in_ptr == out_ptr); /* 1 == queue_is_empty */ 2352 2300 } ··· 2508 2456 sata_scr_read(&ap->link, SCR_ERROR, &serr); 2509 2457 sata_scr_write_flush(&ap->link, SCR_ERROR, serr); 2510 2458 2511 - edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 2459 + edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE); 2512 2460 if (IS_GEN_IIE(hpriv) && (edma_err_cause & EDMA_ERR_TRANS_IRQ_7)) { 2513 - fis_cause = readl(port_mmio + SATA_FIS_IRQ_CAUSE_OFS); 2514 - writelfl(~fis_cause, port_mmio + SATA_FIS_IRQ_CAUSE_OFS); 2461 + fis_cause = readl(port_mmio + FIS_IRQ_CAUSE); 2462 + writelfl(~fis_cause, port_mmio + FIS_IRQ_CAUSE); 2515 2463 } 2516 - writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 2464 + writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE); 2517 2465 2518 2466 if (edma_err_cause & EDMA_ERR_DEV) { 2519 2467 /* ··· 2531 2479 2532 2480 if (IS_GEN_IIE(hpriv) && (edma_err_cause & EDMA_ERR_TRANS_IRQ_7)) { 2533 2481 ata_ehi_push_desc(ehi, "fis_cause=%08x", fis_cause); 2534 - if (fis_cause & SATA_FIS_IRQ_AN) { 2482 + if (fis_cause & FIS_IRQ_CAUSE_AN) { 2535 2483 u32 ec = edma_err_cause & 2536 2484 ~(EDMA_ERR_TRANS_IRQ_7 | EDMA_ERR_IRQ_TRANSIENT); 2537 2485 sata_async_notification(ap); ··· 2633 2581 u16 edma_status = le16_to_cpu(response->flags); 2634 2582 /* 2635 2583 * edma_status from a response queue entry: 2636 - * LSB is from EDMA_ERR_IRQ_CAUSE_OFS (non-NCQ only). 2584 + * LSB is from EDMA_ERR_IRQ_CAUSE (non-NCQ only). 2637 2585 * MSB is saved ATA status from command completion. 2638 2586 */ 2639 2587 if (!ncq_enabled) { ··· 2665 2613 int ncq_enabled = (pp->pp_flags & MV_PP_FLAG_NCQ_EN); 2666 2614 2667 2615 /* Get the hardware queue position index */ 2668 - in_index = (readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) 2616 + in_index = (readl(port_mmio + EDMA_RSP_Q_IN_PTR) 2669 2617 >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK; 2670 2618 2671 2619 /* Process new responses from since the last time we looked */ ··· 2690 2638 if (work_done) 2691 2639 writelfl((pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK) | 2692 2640 (pp->resp_idx << EDMA_RSP_Q_PTR_SHIFT), 2693 - port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 2641 + port_mmio + EDMA_RSP_Q_OUT_PTR); 2694 2642 } 2695 2643 2696 2644 static void mv_port_intr(struct ata_port *ap, u32 port_cause) ··· 2747 2695 2748 2696 /* If asserted, clear the "all ports" IRQ coalescing bit */ 2749 2697 if (main_irq_cause & ALL_PORTS_COAL_DONE) 2750 - writel(~ALL_PORTS_COAL_IRQ, mmio + MV_IRQ_COAL_CAUSE); 2698 + writel(~ALL_PORTS_COAL_IRQ, mmio + IRQ_COAL_CAUSE); 2751 2699 2752 2700 for (port = 0; port < hpriv->n_ports; port++) { 2753 2701 struct ata_port *ap = host->ports[port]; ··· 2791 2739 ack_irqs |= (DMA_IRQ | DEV_IRQ) << p; 2792 2740 } 2793 2741 hc_mmio = mv_hc_base_from_port(mmio, port); 2794 - writelfl(~ack_irqs, hc_mmio + HC_IRQ_CAUSE_OFS); 2742 + writelfl(~ack_irqs, hc_mmio + HC_IRQ_CAUSE); 2795 2743 handled = 1; 2796 2744 } 2797 2745 /* ··· 2813 2761 unsigned int i, err_mask, printed = 0; 2814 2762 u32 err_cause; 2815 2763 2816 - err_cause = readl(mmio + hpriv->irq_cause_ofs); 2764 + err_cause = readl(mmio + hpriv->irq_cause_offset); 2817 2765 2818 2766 dev_printk(KERN_ERR, host->dev, "PCI ERROR; PCI IRQ cause=0x%08x\n", 2819 2767 err_cause); ··· 2821 2769 DPRINTK("All regs @ PCI error\n"); 2822 2770 mv_dump_all_regs(mmio, -1, to_pci_dev(host->dev)); 2823 2771 2824 - writelfl(0, mmio + hpriv->irq_cause_ofs); 2772 + writelfl(0, mmio + hpriv->irq_cause_offset); 2825 2773 2826 2774 for (i = 0; i < host->n_ports; i++) { 2827 2775 ap = host->ports[i]; ··· 2958 2906 2959 2907 static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio) 2960 2908 { 2961 - writel(0x0fcfffff, mmio + MV_FLASH_CTL_OFS); 2909 + writel(0x0fcfffff, mmio + FLASH_CTL); 2962 2910 } 2963 2911 2964 2912 static void mv5_read_preamp(struct mv_host_priv *hpriv, int idx, ··· 2977 2925 { 2978 2926 u32 tmp; 2979 2927 2980 - writel(0, mmio + MV_GPIO_PORT_CTL_OFS); 2928 + writel(0, mmio + GPIO_PORT_CTL); 2981 2929 2982 2930 /* FIXME: handle MV_HP_ERRATA_50XXB2 errata */ 2983 2931 ··· 2995 2943 int fix_apm_sq = (hpriv->hp_flags & MV_HP_ERRATA_50XXB0); 2996 2944 2997 2945 if (fix_apm_sq) { 2998 - tmp = readl(phy_mmio + MV5_LTMODE_OFS); 2946 + tmp = readl(phy_mmio + MV5_LTMODE); 2999 2947 tmp |= (1 << 19); 3000 - writel(tmp, phy_mmio + MV5_LTMODE_OFS); 2948 + writel(tmp, phy_mmio + MV5_LTMODE); 3001 2949 3002 - tmp = readl(phy_mmio + MV5_PHY_CTL_OFS); 2950 + tmp = readl(phy_mmio + MV5_PHY_CTL); 3003 2951 tmp &= ~0x3; 3004 2952 tmp |= 0x1; 3005 - writel(tmp, phy_mmio + MV5_PHY_CTL_OFS); 2953 + writel(tmp, phy_mmio + MV5_PHY_CTL); 3006 2954 } 3007 2955 3008 2956 tmp = readl(phy_mmio + MV5_PHY_MODE); ··· 3023 2971 mv_reset_channel(hpriv, mmio, port); 3024 2972 3025 2973 ZERO(0x028); /* command */ 3026 - writel(0x11f, port_mmio + EDMA_CFG_OFS); 2974 + writel(0x11f, port_mmio + EDMA_CFG); 3027 2975 ZERO(0x004); /* timer */ 3028 2976 ZERO(0x008); /* irq err cause */ 3029 2977 ZERO(0x00c); /* irq err mask */ ··· 3034 2982 ZERO(0x024); /* respq outp */ 3035 2983 ZERO(0x020); /* respq inp */ 3036 2984 ZERO(0x02c); /* test control */ 3037 - writel(0xbc, port_mmio + EDMA_IORDY_TMOUT_OFS); 2985 + writel(0xbc, port_mmio + EDMA_IORDY_TMOUT); 3038 2986 } 3039 2987 #undef ZERO 3040 2988 ··· 3080 3028 struct mv_host_priv *hpriv = host->private_data; 3081 3029 u32 tmp; 3082 3030 3083 - tmp = readl(mmio + MV_PCI_MODE_OFS); 3031 + tmp = readl(mmio + MV_PCI_MODE); 3084 3032 tmp &= 0xff00ffff; 3085 - writel(tmp, mmio + MV_PCI_MODE_OFS); 3033 + writel(tmp, mmio + MV_PCI_MODE); 3086 3034 3087 3035 ZERO(MV_PCI_DISC_TIMER); 3088 3036 ZERO(MV_PCI_MSI_TRIGGER); 3089 - writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT_OFS); 3037 + writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT); 3090 3038 ZERO(MV_PCI_SERR_MASK); 3091 - ZERO(hpriv->irq_cause_ofs); 3092 - ZERO(hpriv->irq_mask_ofs); 3039 + ZERO(hpriv->irq_cause_offset); 3040 + ZERO(hpriv->irq_mask_offset); 3093 3041 ZERO(MV_PCI_ERR_LOW_ADDRESS); 3094 3042 ZERO(MV_PCI_ERR_HIGH_ADDRESS); 3095 3043 ZERO(MV_PCI_ERR_ATTRIBUTE); ··· 3103 3051 3104 3052 mv5_reset_flash(hpriv, mmio); 3105 3053 3106 - tmp = readl(mmio + MV_GPIO_PORT_CTL_OFS); 3054 + tmp = readl(mmio + GPIO_PORT_CTL); 3107 3055 tmp &= 0x3; 3108 3056 tmp |= (1 << 5) | (1 << 6); 3109 - writel(tmp, mmio + MV_GPIO_PORT_CTL_OFS); 3057 + writel(tmp, mmio + GPIO_PORT_CTL); 3110 3058 } 3111 3059 3112 3060 /** ··· 3121 3069 static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio, 3122 3070 unsigned int n_hc) 3123 3071 { 3124 - void __iomem *reg = mmio + PCI_MAIN_CMD_STS_OFS; 3072 + void __iomem *reg = mmio + PCI_MAIN_CMD_STS; 3125 3073 int i, rc = 0; 3126 3074 u32 t; 3127 3075 ··· 3179 3127 void __iomem *port_mmio; 3180 3128 u32 tmp; 3181 3129 3182 - tmp = readl(mmio + MV_RESET_CFG_OFS); 3130 + tmp = readl(mmio + RESET_CFG); 3183 3131 if ((tmp & (1 << 0)) == 0) { 3184 3132 hpriv->signal[idx].amps = 0x7 << 8; 3185 3133 hpriv->signal[idx].pre = 0x1 << 5; ··· 3195 3143 3196 3144 static void mv6_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio) 3197 3145 { 3198 - writel(0x00000060, mmio + MV_GPIO_PORT_CTL_OFS); 3146 + writel(0x00000060, mmio + GPIO_PORT_CTL); 3199 3147 } 3200 3148 3201 3149 static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, ··· 3253 3201 * Workaround for 60x1-B2 errata SATA#13: 3254 3202 * Any write to PHY_MODE4 (above) may corrupt PHY_MODE3, 3255 3203 * so we must always rewrite PHY_MODE3 after PHY_MODE4. 3204 + * Or ensure we use writelfl() when writing PHY_MODE4. 3256 3205 */ 3257 3206 writel(m3, port_mmio + PHY_MODE3); 3258 3207 ··· 3305 3252 mv_reset_channel(hpriv, mmio, port); 3306 3253 3307 3254 ZERO(0x028); /* command */ 3308 - writel(0x101f, port_mmio + EDMA_CFG_OFS); 3255 + writel(0x101f, port_mmio + EDMA_CFG); 3309 3256 ZERO(0x004); /* timer */ 3310 3257 ZERO(0x008); /* irq err cause */ 3311 3258 ZERO(0x00c); /* irq err mask */ ··· 3316 3263 ZERO(0x024); /* respq outp */ 3317 3264 ZERO(0x020); /* respq inp */ 3318 3265 ZERO(0x02c); /* test control */ 3319 - writel(0xbc, port_mmio + EDMA_IORDY_TMOUT_OFS); 3266 + writel(0xbc, port_mmio + EDMA_IORDY_TMOUT); 3320 3267 } 3321 3268 3322 3269 #undef ZERO ··· 3361 3308 3362 3309 static void mv_setup_ifcfg(void __iomem *port_mmio, int want_gen2i) 3363 3310 { 3364 - u32 ifcfg = readl(port_mmio + SATA_INTERFACE_CFG_OFS); 3311 + u32 ifcfg = readl(port_mmio + SATA_IFCFG); 3365 3312 3366 3313 ifcfg = (ifcfg & 0xf7f) | 0x9b1000; /* from chip spec */ 3367 3314 if (want_gen2i) 3368 3315 ifcfg |= (1 << 7); /* enable gen2i speed */ 3369 - writelfl(ifcfg, port_mmio + SATA_INTERFACE_CFG_OFS); 3316 + writelfl(ifcfg, port_mmio + SATA_IFCFG); 3370 3317 } 3371 3318 3372 3319 static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio, ··· 3380 3327 * to disable the EDMA engine before doing the EDMA_RESET operation. 3381 3328 */ 3382 3329 mv_stop_edma_engine(port_mmio); 3383 - writelfl(EDMA_RESET, port_mmio + EDMA_CMD_OFS); 3330 + writelfl(EDMA_RESET, port_mmio + EDMA_CMD); 3384 3331 3385 3332 if (!IS_GEN_I(hpriv)) { 3386 3333 /* Enable 3.0gb/s link speed: this survives EDMA_RESET */ ··· 3389 3336 /* 3390 3337 * Strobing EDMA_RESET here causes a hard reset of the SATA transport, 3391 3338 * link, and physical layers. It resets all SATA interface registers 3392 - * (except for SATA_INTERFACE_CFG), and issues a COMRESET to the dev. 3339 + * (except for SATA_IFCFG), and issues a COMRESET to the dev. 3393 3340 */ 3394 - writelfl(EDMA_RESET, port_mmio + EDMA_CMD_OFS); 3341 + writelfl(EDMA_RESET, port_mmio + EDMA_CMD); 3395 3342 udelay(25); /* allow reset propagation */ 3396 - writelfl(0, port_mmio + EDMA_CMD_OFS); 3343 + writelfl(0, port_mmio + EDMA_CMD); 3397 3344 3398 3345 hpriv->ops->phy_errata(hpriv, mmio, port_no); 3399 3346 ··· 3405 3352 { 3406 3353 if (sata_pmp_supported(ap)) { 3407 3354 void __iomem *port_mmio = mv_ap_base(ap); 3408 - u32 reg = readl(port_mmio + SATA_IFCTL_OFS); 3355 + u32 reg = readl(port_mmio + SATA_IFCTL); 3409 3356 int old = reg & 0xf; 3410 3357 3411 3358 if (old != pmp) { 3412 3359 reg = (reg & ~0xf) | pmp; 3413 - writelfl(reg, port_mmio + SATA_IFCTL_OFS); 3360 + writelfl(reg, port_mmio + SATA_IFCTL); 3414 3361 } 3415 3362 } 3416 3363 } ··· 3485 3432 u32 hc_irq_cause; 3486 3433 3487 3434 /* clear EDMA errors on this port */ 3488 - writel(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 3435 + writel(0, port_mmio + EDMA_ERR_IRQ_CAUSE); 3489 3436 3490 3437 /* clear pending irq events */ 3491 3438 hc_irq_cause = ~((DEV_IRQ | DMA_IRQ) << hardport); 3492 - writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); 3439 + writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE); 3493 3440 3494 3441 mv_enable_port_irqs(ap, ERR_IRQ); 3495 3442 } ··· 3508 3455 */ 3509 3456 static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio) 3510 3457 { 3511 - void __iomem *shd_base = port_mmio + SHD_BLK_OFS; 3512 - unsigned serr_ofs; 3458 + void __iomem *serr, *shd_base = port_mmio + SHD_BLK; 3513 3459 3514 3460 /* PIO related setup 3515 3461 */ ··· 3523 3471 port->status_addr = 3524 3472 port->command_addr = shd_base + (sizeof(u32) * ATA_REG_STATUS); 3525 3473 /* special case: control/altstatus doesn't have ATA_REG_ address */ 3526 - port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST_OFS; 3474 + port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST; 3527 3475 3528 3476 /* unused: */ 3529 3477 port->cmd_addr = port->bmdma_addr = port->scr_addr = NULL; 3530 3478 3531 3479 /* Clear any currently outstanding port interrupt conditions */ 3532 - serr_ofs = mv_scr_offset(SCR_ERROR); 3533 - writelfl(readl(port_mmio + serr_ofs), port_mmio + serr_ofs); 3534 - writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 3480 + serr = port_mmio + mv_scr_offset(SCR_ERROR); 3481 + writelfl(readl(serr), serr); 3482 + writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE); 3535 3483 3536 3484 /* unmask all non-transient EDMA error interrupts */ 3537 - writelfl(~EDMA_ERR_IRQ_TRANSIENT, port_mmio + EDMA_ERR_IRQ_MASK_OFS); 3485 + writelfl(~EDMA_ERR_IRQ_TRANSIENT, port_mmio + EDMA_ERR_IRQ_MASK); 3538 3486 3539 3487 VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n", 3540 - readl(port_mmio + EDMA_CFG_OFS), 3541 - readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS), 3542 - readl(port_mmio + EDMA_ERR_IRQ_MASK_OFS)); 3488 + readl(port_mmio + EDMA_CFG), 3489 + readl(port_mmio + EDMA_ERR_IRQ_CAUSE), 3490 + readl(port_mmio + EDMA_ERR_IRQ_MASK)); 3543 3491 } 3544 3492 3545 3493 static unsigned int mv_in_pcix_mode(struct ata_host *host) ··· 3550 3498 3551 3499 if (IS_SOC(hpriv) || !IS_PCIE(hpriv)) 3552 3500 return 0; /* not PCI-X capable */ 3553 - reg = readl(mmio + MV_PCI_MODE_OFS); 3501 + reg = readl(mmio + MV_PCI_MODE); 3554 3502 if ((reg & MV_PCI_MODE_MASK) == 0) 3555 3503 return 0; /* conventional PCI mode */ 3556 3504 return 1; /* chip is in PCI-X mode */ ··· 3563 3511 u32 reg; 3564 3512 3565 3513 if (!mv_in_pcix_mode(host)) { 3566 - reg = readl(mmio + PCI_COMMAND_OFS); 3567 - if (reg & PCI_COMMAND_MRDTRIG) 3514 + reg = readl(mmio + MV_PCI_COMMAND); 3515 + if (reg & MV_PCI_COMMAND_MRDTRIG) 3568 3516 return 0; /* not okay */ 3569 3517 } 3570 3518 return 1; /* okay */ 3519 + } 3520 + 3521 + static void mv_60x1b2_errata_pci7(struct ata_host *host) 3522 + { 3523 + struct mv_host_priv *hpriv = host->private_data; 3524 + void __iomem *mmio = hpriv->base; 3525 + 3526 + /* workaround for 60x1-B2 errata PCI#7 */ 3527 + if (mv_in_pcix_mode(host)) { 3528 + u32 reg = readl(mmio + MV_PCI_COMMAND); 3529 + writelfl(reg & ~MV_PCI_COMMAND_MWRCOM, mmio + MV_PCI_COMMAND); 3530 + } 3571 3531 } 3572 3532 3573 3533 static int mv_chip_id(struct ata_host *host, unsigned int board_idx) ··· 3635 3571 3636 3572 switch (pdev->revision) { 3637 3573 case 0x7: 3574 + mv_60x1b2_errata_pci7(host); 3638 3575 hp_flags |= MV_HP_ERRATA_60X1B2; 3639 3576 break; 3640 3577 case 0x9: ··· 3712 3647 3713 3648 hpriv->hp_flags = hp_flags; 3714 3649 if (hp_flags & MV_HP_PCIE) { 3715 - hpriv->irq_cause_ofs = PCIE_IRQ_CAUSE_OFS; 3716 - hpriv->irq_mask_ofs = PCIE_IRQ_MASK_OFS; 3650 + hpriv->irq_cause_offset = PCIE_IRQ_CAUSE; 3651 + hpriv->irq_mask_offset = PCIE_IRQ_MASK; 3717 3652 hpriv->unmask_all_irqs = PCIE_UNMASK_ALL_IRQS; 3718 3653 } else { 3719 - hpriv->irq_cause_ofs = PCI_IRQ_CAUSE_OFS; 3720 - hpriv->irq_mask_ofs = PCI_IRQ_MASK_OFS; 3654 + hpriv->irq_cause_offset = PCI_IRQ_CAUSE; 3655 + hpriv->irq_mask_offset = PCI_IRQ_MASK; 3721 3656 hpriv->unmask_all_irqs = PCI_UNMASK_ALL_IRQS; 3722 3657 } 3723 3658 ··· 3746 3681 goto done; 3747 3682 3748 3683 if (IS_SOC(hpriv)) { 3749 - hpriv->main_irq_cause_addr = mmio + SOC_HC_MAIN_IRQ_CAUSE_OFS; 3750 - hpriv->main_irq_mask_addr = mmio + SOC_HC_MAIN_IRQ_MASK_OFS; 3684 + hpriv->main_irq_cause_addr = mmio + SOC_HC_MAIN_IRQ_CAUSE; 3685 + hpriv->main_irq_mask_addr = mmio + SOC_HC_MAIN_IRQ_MASK; 3751 3686 } else { 3752 - hpriv->main_irq_cause_addr = mmio + PCI_HC_MAIN_IRQ_CAUSE_OFS; 3753 - hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK_OFS; 3687 + hpriv->main_irq_cause_addr = mmio + PCI_HC_MAIN_IRQ_CAUSE; 3688 + hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK; 3754 3689 } 3755 3690 3756 3691 /* initialize shadow irq mask with register's value */ ··· 3792 3727 3793 3728 VPRINTK("HC%i: HC config=0x%08x HC IRQ cause " 3794 3729 "(before clear)=0x%08x\n", hc, 3795 - readl(hc_mmio + HC_CFG_OFS), 3796 - readl(hc_mmio + HC_IRQ_CAUSE_OFS)); 3730 + readl(hc_mmio + HC_CFG), 3731 + readl(hc_mmio + HC_IRQ_CAUSE)); 3797 3732 3798 3733 /* Clear any currently outstanding hc interrupt conditions */ 3799 - writelfl(0, hc_mmio + HC_IRQ_CAUSE_OFS); 3734 + writelfl(0, hc_mmio + HC_IRQ_CAUSE); 3800 3735 } 3801 3736 3802 - /* Clear any currently outstanding host interrupt conditions */ 3803 - writelfl(0, mmio + hpriv->irq_cause_ofs); 3737 + if (!IS_SOC(hpriv)) { 3738 + /* Clear any currently outstanding host interrupt conditions */ 3739 + writelfl(0, mmio + hpriv->irq_cause_offset); 3804 3740 3805 - /* and unmask interrupt generation for host regs */ 3806 - writelfl(hpriv->unmask_all_irqs, mmio + hpriv->irq_mask_ofs); 3741 + /* and unmask interrupt generation for host regs */ 3742 + writelfl(hpriv->unmask_all_irqs, mmio + hpriv->irq_mask_offset); 3743 + } 3807 3744 3808 3745 /* 3809 3746 * enable only global host interrupts for now. ··· 3911 3844 host->iomap = NULL; 3912 3845 hpriv->base = devm_ioremap(&pdev->dev, res->start, 3913 3846 res->end - res->start + 1); 3914 - hpriv->base -= MV_SATAHC0_REG_BASE; 3847 + hpriv->base -= SATAHC0_REG_BASE; 3915 3848 3916 3849 /* 3917 3850 * (Re-)program MBUS remapping windows if we are asked to.
+41
include/linux/ata.h
··· 29 29 #ifndef __LINUX_ATA_H__ 30 30 #define __LINUX_ATA_H__ 31 31 32 + #include <linux/kernel.h> 33 + #include <linux/string.h> 32 34 #include <linux/types.h> 33 35 #include <asm/byteorder.h> 34 36 ··· 93 91 ATA_ID_CFA_POWER = 160, 94 92 ATA_ID_CFA_KEY_MGMT = 162, 95 93 ATA_ID_CFA_MODES = 163, 94 + ATA_ID_DATA_SET_MGMT = 169, 96 95 ATA_ID_ROT_SPEED = 217, 97 96 ATA_ID_PIO4 = (1 << 1), 98 97 ··· 251 248 ATA_CMD_SMART = 0xB0, 252 249 ATA_CMD_MEDIA_LOCK = 0xDE, 253 250 ATA_CMD_MEDIA_UNLOCK = 0xDF, 251 + ATA_CMD_DSM = 0x06, 254 252 /* marked obsolete in the ATA/ATAPI-7 spec */ 255 253 ATA_CMD_RESTORE = 0x10, 256 254 ··· 324 320 ATA_SMART_ENABLE = 0xD8, 325 321 ATA_SMART_READ_VALUES = 0xD0, 326 322 ATA_SMART_READ_THRESHOLDS = 0xD1, 323 + 324 + /* feature values for Data Set Management */ 325 + ATA_DSM_TRIM = 0x01, 327 326 328 327 /* password used in LBA Mid / LBA High for executing SMART commands */ 329 328 ATA_SMART_LBAM_PASS = 0x4F, ··· 730 723 return 0; 731 724 } 732 725 726 + static inline int ata_id_has_trim(const u16 *id) 727 + { 728 + if (ata_id_major_version(id) >= 7 && 729 + (id[ATA_ID_DATA_SET_MGMT] & 1)) 730 + return 1; 731 + return 0; 732 + } 733 + 733 734 static inline int ata_id_current_chs_valid(const u16 *id) 734 735 { 735 736 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command ··· 876 861 *(u64 *)&id[ATA_ID_LBA_CAPACITY_2] = 877 862 ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); 878 863 #endif 864 + } 865 + 866 + /* 867 + * Write up to 'max' LBA Range Entries to the buffer that will cover the 868 + * extent from sector to sector + count. This is used for TRIM and for 869 + * ADD LBA(S) TO NV CACHE PINNED SET. 870 + */ 871 + static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max, 872 + u64 sector, unsigned long count) 873 + { 874 + __le64 *buffer = _buffer; 875 + unsigned i = 0; 876 + 877 + while (i < max) { 878 + u64 entry = sector | 879 + ((u64)(count > 0xffff ? 0xffff : count) << 48); 880 + buffer[i++] = __cpu_to_le64(entry); 881 + if (count <= 0xffff) 882 + break; 883 + count -= 0xffff; 884 + sector += 0xffff; 885 + } 886 + 887 + max = ALIGN(i * 8, 512); 888 + memset(buffer + i, 0, max - i * 8); 889 + return max; 879 890 } 880 891 881 892 static inline int is_multi_taskfile(struct ata_taskfile *tf)