aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-01-30 17:48:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-01-30 17:48:30 -0500
commit76a250f9a5f983c07e0735fac8370a584c520770 (patch)
tree6dd225958563ce4ea8e7670c6fcb6e5c9fd7460a
parentf8cc87b6c1e333ce7adc9fb2cb698d93b16eabe3 (diff)
parentb3506c7ed216dd2db1f06c2845da45018e2c508d (diff)
Merge branch 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo: "Nothing too interesting. Several patches to convert mdelay() to usleep_range(), removal of unused pata_at32, and other low level driver specific changes" * 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: ata: pata_pdc2027x: Replace mdelay with msleep ata: pata_it821x: Replace mdelay with usleep_range in it821x_firmware_command ata: sata_mv: Replace mdelay with usleep_range in mv_reset_channel ata: remove pata_at32 phy: brcm-sata: remove unused variable phy: brcm-sata: fix semicolon.cocci warnings ata: ahci_brcm: Recover from failures to identify devices phy: brcm-sata: Implement calibrate callback ahci: Add Intel Cannon Lake PCH-H PCI ID ata_piix: constify pci_bits libata:pata_atiixp: Don't use unconnected secondary port on SB600 ata: ahci_brcm: Avoid clobbering SATA_TOP_CTRL_BUS_CTRL ahci: Allow setting a default LPM policy for mobile chipsets ahci: Add PCI ids for Intel Bay Trail, Cherry Trail and Apollo Lake AHCI ahci: Annotate PCI ids for mobile Intel chipsets as such
-rw-r--r--drivers/ata/Kconfig28
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c94
-rw-r--r--drivers/ata/ahci.h3
-rw-r--r--drivers/ata/ahci_brcm.c120
-rw-r--r--drivers/ata/ata_piix.c2
-rw-r--r--drivers/ata/pata_at32.c400
-rw-r--r--drivers/ata/pata_atiixp.c4
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_pdc2027x.c4
-rw-r--r--drivers/ata/sata_mv.c2
-rw-r--r--drivers/phy/broadcom/phy-brcm-sata.c31
12 files changed, 221 insertions, 470 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index cb5339166563..a7120d621154 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -92,6 +92,25 @@ config SATA_AHCI
92 92
93 If unsure, say N. 93 If unsure, say N.
94 94
95config SATA_MOBILE_LPM_POLICY
96 int "Default SATA Link Power Management policy for mobile chipsets"
97 range 0 4
98 default 0
99 depends on SATA_AHCI
100 help
101 Select the Default SATA Link Power Management (LPM) policy to use
102 for mobile / laptop variants of chipsets / "South Bridges".
103
104 The value set has the following meanings:
105 0 => Keep firmware settings
106 1 => Maximum performance
107 2 => Medium power
108 3 => Medium power with Device Initiated PM enabled
109 4 => Minimum power
110
111 Note "Minimum power" is known to cause issues, including disk
112 corruption, with some disks and should not be used.
113
95config SATA_AHCI_PLATFORM 114config SATA_AHCI_PLATFORM
96 tristate "Platform AHCI SATA support" 115 tristate "Platform AHCI SATA support"
97 help 116 help
@@ -925,15 +944,6 @@ endif # ATA_BMDMA
925 944
926comment "PIO-only SFF controllers" 945comment "PIO-only SFF controllers"
927 946
928config PATA_AT32
929 tristate "Atmel AVR32 PATA support (Experimental)"
930 depends on AVR32 && PLATFORM_AT32AP
931 help
932 This option enables support for the IDE devices on the
933 Atmel AT32AP platform.
934
935 If unsure, say N.
936
937config PATA_CMD640_PCI 947config PATA_CMD640_PCI
938 tristate "CMD640 PCI PATA support (Experimental)" 948 tristate "CMD640 PCI PATA support (Experimental)"
939 depends on PCI 949 depends on PCI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 8daec3e657f8..f1f5a3fbc777 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -96,7 +96,6 @@ obj-$(CONFIG_PATA_VIA) += pata_via.o
96obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o 96obj-$(CONFIG_PATA_WINBOND) += pata_sl82c105.o
97 97
98# SFF PIO only 98# SFF PIO only
99obj-$(CONFIG_PATA_AT32) += pata_at32.o
100obj-$(CONFIG_PATA_CMD640_PCI) += pata_cmd640.o 99obj-$(CONFIG_PATA_CMD640_PCI) += pata_cmd640.o
101obj-$(CONFIG_PATA_FALCON) += pata_falcon.o 100obj-$(CONFIG_PATA_FALCON) += pata_falcon.o
102obj-$(CONFIG_PATA_ISAPNP) += pata_isapnp.o 101obj-$(CONFIG_PATA_ISAPNP) += pata_isapnp.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 5443cb71d7ba..355a95a83a34 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -65,6 +65,7 @@ enum board_ids {
65 /* board IDs by feature in alphabetical order */ 65 /* board IDs by feature in alphabetical order */
66 board_ahci, 66 board_ahci,
67 board_ahci_ign_iferr, 67 board_ahci_ign_iferr,
68 board_ahci_mobile,
68 board_ahci_nomsi, 69 board_ahci_nomsi,
69 board_ahci_noncq, 70 board_ahci_noncq,
70 board_ahci_nosntf, 71 board_ahci_nosntf,
@@ -140,6 +141,13 @@ static const struct ata_port_info ahci_port_info[] = {
140 .udma_mask = ATA_UDMA6, 141 .udma_mask = ATA_UDMA6,
141 .port_ops = &ahci_ops, 142 .port_ops = &ahci_ops,
142 }, 143 },
144 [board_ahci_mobile] = {
145 AHCI_HFLAGS (AHCI_HFLAG_IS_MOBILE),
146 .flags = AHCI_FLAG_COMMON,
147 .pio_mask = ATA_PIO4,
148 .udma_mask = ATA_UDMA6,
149 .port_ops = &ahci_ops,
150 },
143 [board_ahci_nomsi] = { 151 [board_ahci_nomsi] = {
144 AHCI_HFLAGS (AHCI_HFLAG_NO_MSI), 152 AHCI_HFLAGS (AHCI_HFLAG_NO_MSI),
145 .flags = AHCI_FLAG_COMMON, 153 .flags = AHCI_FLAG_COMMON,
@@ -252,13 +260,13 @@ static const struct pci_device_id ahci_pci_tbl[] = {
252 { PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */ 260 { PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */
253 { PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */ 261 { PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */
254 { PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */ 262 { PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */
255 { PCI_VDEVICE(INTEL, 0x2929), board_ahci }, /* ICH9M */ 263 { PCI_VDEVICE(INTEL, 0x2929), board_ahci_mobile }, /* ICH9M */
256 { PCI_VDEVICE(INTEL, 0x292a), board_ahci }, /* ICH9M */ 264 { PCI_VDEVICE(INTEL, 0x292a), board_ahci_mobile }, /* ICH9M */
257 { PCI_VDEVICE(INTEL, 0x292b), board_ahci }, /* ICH9M */ 265 { PCI_VDEVICE(INTEL, 0x292b), board_ahci_mobile }, /* ICH9M */
258 { PCI_VDEVICE(INTEL, 0x292c), board_ahci }, /* ICH9M */ 266 { PCI_VDEVICE(INTEL, 0x292c), board_ahci_mobile }, /* ICH9M */
259 { PCI_VDEVICE(INTEL, 0x292f), board_ahci }, /* ICH9M */ 267 { PCI_VDEVICE(INTEL, 0x292f), board_ahci_mobile }, /* ICH9M */
260 { PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */ 268 { PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */
261 { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */ 269 { PCI_VDEVICE(INTEL, 0x294e), board_ahci_mobile }, /* ICH9M */
262 { PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */ 270 { PCI_VDEVICE(INTEL, 0x502a), board_ahci }, /* Tolapai */
263 { PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */ 271 { PCI_VDEVICE(INTEL, 0x502b), board_ahci }, /* Tolapai */
264 { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */ 272 { PCI_VDEVICE(INTEL, 0x3a05), board_ahci }, /* ICH10 */
@@ -268,9 +276,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
268 { PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */ 276 { PCI_VDEVICE(INTEL, 0x3b23), board_ahci }, /* PCH AHCI */
269 { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */ 277 { PCI_VDEVICE(INTEL, 0x3b24), board_ahci }, /* PCH RAID */
270 { PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */ 278 { PCI_VDEVICE(INTEL, 0x3b25), board_ahci }, /* PCH RAID */
271 { PCI_VDEVICE(INTEL, 0x3b29), board_ahci }, /* PCH AHCI */ 279 { PCI_VDEVICE(INTEL, 0x3b29), board_ahci_mobile }, /* PCH M AHCI */
272 { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */ 280 { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
273 { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */ 281 { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci_mobile }, /* PCH M RAID */
274 { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */ 282 { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
275 { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */ 283 { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */
276 { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */ 284 { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */
@@ -293,9 +301,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
293 { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */ 301 { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
294 { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */ 302 { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
295 { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */ 303 { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
296 { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */ 304 { PCI_VDEVICE(INTEL, 0x1c03), board_ahci_mobile }, /* CPT M AHCI */
297 { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */ 305 { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
298 { PCI_VDEVICE(INTEL, 0x1c05), board_ahci }, /* CPT RAID */ 306 { PCI_VDEVICE(INTEL, 0x1c05), board_ahci_mobile }, /* CPT M RAID */
299 { PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */ 307 { PCI_VDEVICE(INTEL, 0x1c06), board_ahci }, /* CPT RAID */
300 { PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */ 308 { PCI_VDEVICE(INTEL, 0x1c07), board_ahci }, /* CPT RAID */
301 { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */ 309 { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */
@@ -304,28 +312,28 @@ static const struct pci_device_id ahci_pci_tbl[] = {
304 { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */ 312 { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
305 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */ 313 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
306 { PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */ 314 { PCI_VDEVICE(INTEL, 0x1e02), board_ahci }, /* Panther Point AHCI */
307 { PCI_VDEVICE(INTEL, 0x1e03), board_ahci }, /* Panther Point AHCI */ 315 { PCI_VDEVICE(INTEL, 0x1e03), board_ahci_mobile }, /* Panther M AHCI */
308 { PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */ 316 { PCI_VDEVICE(INTEL, 0x1e04), board_ahci }, /* Panther Point RAID */
309 { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */ 317 { PCI_VDEVICE(INTEL, 0x1e05), board_ahci }, /* Panther Point RAID */
310 { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */ 318 { PCI_VDEVICE(INTEL, 0x1e06), board_ahci }, /* Panther Point RAID */
311 { PCI_VDEVICE(INTEL, 0x1e07), board_ahci }, /* Panther Point RAID */ 319 { PCI_VDEVICE(INTEL, 0x1e07), board_ahci_mobile }, /* Panther M RAID */
312 { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */ 320 { PCI_VDEVICE(INTEL, 0x1e0e), board_ahci }, /* Panther Point RAID */
313 { PCI_VDEVICE(INTEL, 0x8c02), board_ahci }, /* Lynx Point AHCI */ 321 { PCI_VDEVICE(INTEL, 0x8c02), board_ahci }, /* Lynx Point AHCI */
314 { PCI_VDEVICE(INTEL, 0x8c03), board_ahci }, /* Lynx Point AHCI */ 322 { PCI_VDEVICE(INTEL, 0x8c03), board_ahci_mobile }, /* Lynx M AHCI */
315 { PCI_VDEVICE(INTEL, 0x8c04), board_ahci }, /* Lynx Point RAID */ 323 { PCI_VDEVICE(INTEL, 0x8c04), board_ahci }, /* Lynx Point RAID */
316 { PCI_VDEVICE(INTEL, 0x8c05), board_ahci }, /* Lynx Point RAID */ 324 { PCI_VDEVICE(INTEL, 0x8c05), board_ahci_mobile }, /* Lynx M RAID */
317 { PCI_VDEVICE(INTEL, 0x8c06), board_ahci }, /* Lynx Point RAID */ 325 { PCI_VDEVICE(INTEL, 0x8c06), board_ahci }, /* Lynx Point RAID */
318 { PCI_VDEVICE(INTEL, 0x8c07), board_ahci }, /* Lynx Point RAID */ 326 { PCI_VDEVICE(INTEL, 0x8c07), board_ahci_mobile }, /* Lynx M RAID */
319 { PCI_VDEVICE(INTEL, 0x8c0e), board_ahci }, /* Lynx Point RAID */ 327 { PCI_VDEVICE(INTEL, 0x8c0e), board_ahci }, /* Lynx Point RAID */
320 { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci }, /* Lynx Point RAID */ 328 { PCI_VDEVICE(INTEL, 0x8c0f), board_ahci_mobile }, /* Lynx M RAID */
321 { PCI_VDEVICE(INTEL, 0x9c02), board_ahci }, /* Lynx Point-LP AHCI */ 329 { PCI_VDEVICE(INTEL, 0x9c02), board_ahci_mobile }, /* Lynx LP AHCI */
322 { PCI_VDEVICE(INTEL, 0x9c03), board_ahci }, /* Lynx Point-LP AHCI */ 330 { PCI_VDEVICE(INTEL, 0x9c03), board_ahci_mobile }, /* Lynx LP AHCI */
323 { PCI_VDEVICE(INTEL, 0x9c04), board_ahci }, /* Lynx Point-LP RAID */ 331 { PCI_VDEVICE(INTEL, 0x9c04), board_ahci_mobile }, /* Lynx LP RAID */
324 { PCI_VDEVICE(INTEL, 0x9c05), board_ahci }, /* Lynx Point-LP RAID */ 332 { PCI_VDEVICE(INTEL, 0x9c05), board_ahci_mobile }, /* Lynx LP RAID */
325 { PCI_VDEVICE(INTEL, 0x9c06), board_ahci }, /* Lynx Point-LP RAID */ 333 { PCI_VDEVICE(INTEL, 0x9c06), board_ahci_mobile }, /* Lynx LP RAID */
326 { PCI_VDEVICE(INTEL, 0x9c07), board_ahci }, /* Lynx Point-LP RAID */ 334 { PCI_VDEVICE(INTEL, 0x9c07), board_ahci_mobile }, /* Lynx LP RAID */
327 { PCI_VDEVICE(INTEL, 0x9c0e), board_ahci }, /* Lynx Point-LP RAID */ 335 { PCI_VDEVICE(INTEL, 0x9c0e), board_ahci_mobile }, /* Lynx LP RAID */
328 { PCI_VDEVICE(INTEL, 0x9c0f), board_ahci }, /* Lynx Point-LP RAID */ 336 { PCI_VDEVICE(INTEL, 0x9c0f), board_ahci_mobile }, /* Lynx LP RAID */
329 { PCI_VDEVICE(INTEL, 0x1f22), board_ahci }, /* Avoton AHCI */ 337 { PCI_VDEVICE(INTEL, 0x1f22), board_ahci }, /* Avoton AHCI */
330 { PCI_VDEVICE(INTEL, 0x1f23), board_ahci }, /* Avoton AHCI */ 338 { PCI_VDEVICE(INTEL, 0x1f23), board_ahci }, /* Avoton AHCI */
331 { PCI_VDEVICE(INTEL, 0x1f24), board_ahci }, /* Avoton RAID */ 339 { PCI_VDEVICE(INTEL, 0x1f24), board_ahci }, /* Avoton RAID */
@@ -353,26 +361,26 @@ static const struct pci_device_id ahci_pci_tbl[] = {
353 { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */ 361 { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */
354 { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */ 362 { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */
355 { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */ 363 { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */
356 { PCI_VDEVICE(INTEL, 0x9c83), board_ahci }, /* Wildcat Point-LP AHCI */ 364 { PCI_VDEVICE(INTEL, 0x9c83), board_ahci_mobile }, /* Wildcat LP AHCI */
357 { PCI_VDEVICE(INTEL, 0x9c85), board_ahci }, /* Wildcat Point-LP RAID */ 365 { PCI_VDEVICE(INTEL, 0x9c85), board_ahci_mobile }, /* Wildcat LP RAID */
358 { PCI_VDEVICE(INTEL, 0x9c87), board_ahci }, /* Wildcat Point-LP RAID */ 366 { PCI_VDEVICE(INTEL, 0x9c87), board_ahci_mobile }, /* Wildcat LP RAID */
359 { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci }, /* Wildcat Point-LP RAID */ 367 { PCI_VDEVICE(INTEL, 0x9c8f), board_ahci_mobile }, /* Wildcat LP RAID */
360 { PCI_VDEVICE(INTEL, 0x8c82), board_ahci }, /* 9 Series AHCI */ 368 { PCI_VDEVICE(INTEL, 0x8c82), board_ahci }, /* 9 Series AHCI */
361 { PCI_VDEVICE(INTEL, 0x8c83), board_ahci }, /* 9 Series AHCI */ 369 { PCI_VDEVICE(INTEL, 0x8c83), board_ahci_mobile }, /* 9 Series M AHCI */
362 { PCI_VDEVICE(INTEL, 0x8c84), board_ahci }, /* 9 Series RAID */ 370 { PCI_VDEVICE(INTEL, 0x8c84), board_ahci }, /* 9 Series RAID */
363 { PCI_VDEVICE(INTEL, 0x8c85), board_ahci }, /* 9 Series RAID */ 371 { PCI_VDEVICE(INTEL, 0x8c85), board_ahci_mobile }, /* 9 Series M RAID */
364 { PCI_VDEVICE(INTEL, 0x8c86), board_ahci }, /* 9 Series RAID */ 372 { PCI_VDEVICE(INTEL, 0x8c86), board_ahci }, /* 9 Series RAID */
365 { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series RAID */ 373 { PCI_VDEVICE(INTEL, 0x8c87), board_ahci_mobile }, /* 9 Series M RAID */
366 { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */ 374 { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */
367 { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series RAID */ 375 { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci_mobile }, /* 9 Series M RAID */
368 { PCI_VDEVICE(INTEL, 0x9d03), board_ahci }, /* Sunrise Point-LP AHCI */ 376 { PCI_VDEVICE(INTEL, 0x9d03), board_ahci_mobile }, /* Sunrise LP AHCI */
369 { PCI_VDEVICE(INTEL, 0x9d05), board_ahci }, /* Sunrise Point-LP RAID */ 377 { PCI_VDEVICE(INTEL, 0x9d05), board_ahci_mobile }, /* Sunrise LP RAID */
370 { PCI_VDEVICE(INTEL, 0x9d07), board_ahci }, /* Sunrise Point-LP RAID */ 378 { PCI_VDEVICE(INTEL, 0x9d07), board_ahci_mobile }, /* Sunrise LP RAID */
371 { PCI_VDEVICE(INTEL, 0xa102), board_ahci }, /* Sunrise Point-H AHCI */ 379 { PCI_VDEVICE(INTEL, 0xa102), board_ahci }, /* Sunrise Point-H AHCI */
372 { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H AHCI */ 380 { PCI_VDEVICE(INTEL, 0xa103), board_ahci_mobile }, /* Sunrise M AHCI */
373 { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */ 381 { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */
374 { PCI_VDEVICE(INTEL, 0xa106), board_ahci }, /* Sunrise Point-H RAID */ 382 { PCI_VDEVICE(INTEL, 0xa106), board_ahci }, /* Sunrise Point-H RAID */
375 { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H RAID */ 383 { PCI_VDEVICE(INTEL, 0xa107), board_ahci_mobile }, /* Sunrise M RAID */
376 { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */ 384 { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
377 { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/ 385 { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
378 { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Lewisburg AHCI*/ 386 { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Lewisburg AHCI*/
@@ -386,6 +394,11 @@ static const struct pci_device_id ahci_pci_tbl[] = {
386 { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/ 394 { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
387 { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/ 395 { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
388 { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/ 396 { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
397 { PCI_VDEVICE(INTEL, 0xa356), board_ahci }, /* Cannon Lake PCH-H RAID */
398 { PCI_VDEVICE(INTEL, 0x0f22), board_ahci_mobile }, /* Bay Trail AHCI */
399 { PCI_VDEVICE(INTEL, 0x0f23), board_ahci_mobile }, /* Bay Trail AHCI */
400 { PCI_VDEVICE(INTEL, 0x22a3), board_ahci_mobile }, /* Cherry Tr. AHCI */
401 { PCI_VDEVICE(INTEL, 0x5ae3), board_ahci_mobile }, /* ApolloLake AHCI */
389 402
390 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 403 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
391 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 404 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -593,6 +606,9 @@ static int marvell_enable = 1;
593module_param(marvell_enable, int, 0644); 606module_param(marvell_enable, int, 0644);
594MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)"); 607MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
595 608
609static int mobile_lpm_policy = CONFIG_SATA_MOBILE_LPM_POLICY;
610module_param(mobile_lpm_policy, int, 0644);
611MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");
596 612
597static void ahci_pci_save_initial_config(struct pci_dev *pdev, 613static void ahci_pci_save_initial_config(struct pci_dev *pdev,
598 struct ahci_host_priv *hpriv) 614 struct ahci_host_priv *hpriv)
@@ -1728,6 +1744,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1728 if (ap->flags & ATA_FLAG_EM) 1744 if (ap->flags & ATA_FLAG_EM)
1729 ap->em_message_type = hpriv->em_msg_type; 1745 ap->em_message_type = hpriv->em_msg_type;
1730 1746
1747 if ((hpriv->flags & AHCI_HFLAG_IS_MOBILE) &&
1748 mobile_lpm_policy >= ATA_LPM_UNKNOWN &&
1749 mobile_lpm_policy <= ATA_LPM_MIN_POWER)
1750 ap->target_lpm_policy = mobile_lpm_policy;
1731 1751
1732 /* disabled/not-implemented port */ 1752 /* disabled/not-implemented port */
1733 if (!(hpriv->port_map & (1 << i))) 1753 if (!(hpriv->port_map & (1 << i)))
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 749fd94441b0..a9d996e17d75 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -251,6 +251,9 @@ enum {
251 AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */ 251 AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */
252 AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read 252 AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read
253 only registers */ 253 only registers */
254 AHCI_HFLAG_IS_MOBILE = (1 << 25), /* mobile chipset, use
255 SATA_MOBILE_LPM_POLICY
256 as default lpm_policy */
254 257
255 /* ap->flags bits */ 258 /* ap->flags bits */
256 259
diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c
index 5936d1679bf3..ea430819c80b 100644
--- a/drivers/ata/ahci_brcm.c
+++ b/drivers/ata/ahci_brcm.c
@@ -70,6 +70,13 @@
70 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \ 70 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \
71 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT)) 71 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT))
72 72
73#define BUS_CTRL_ENDIAN_NSP_CONF \
74 (0x02 << DMADATA_ENDIAN_SHIFT | 0x02 << DMADESC_ENDIAN_SHIFT)
75
76#define BUS_CTRL_ENDIAN_CONF_MASK \
77 (0x3 << MMIO_ENDIAN_SHIFT | 0x3 << DMADESC_ENDIAN_SHIFT | \
78 0x3 << DMADATA_ENDIAN_SHIFT | 0x3 << PIODATA_ENDIAN_SHIFT)
79
73enum brcm_ahci_version { 80enum brcm_ahci_version {
74 BRCM_SATA_BCM7425 = 1, 81 BRCM_SATA_BCM7425 = 1,
75 BRCM_SATA_BCM7445, 82 BRCM_SATA_BCM7445,
@@ -89,14 +96,6 @@ struct brcm_ahci_priv {
89 enum brcm_ahci_version version; 96 enum brcm_ahci_version version;
90}; 97};
91 98
92static const struct ata_port_info ahci_brcm_port_info = {
93 .flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
94 .link_flags = ATA_LFLAG_NO_DB_DELAY,
95 .pio_mask = ATA_PIO4,
96 .udma_mask = ATA_UDMA6,
97 .port_ops = &ahci_platform_ops,
98};
99
100static inline u32 brcm_sata_readreg(void __iomem *addr) 99static inline u32 brcm_sata_readreg(void __iomem *addr)
101{ 100{
102 /* 101 /*
@@ -250,20 +249,105 @@ static u32 brcm_ahci_get_portmask(struct platform_device *pdev,
250static void brcm_sata_init(struct brcm_ahci_priv *priv) 249static void brcm_sata_init(struct brcm_ahci_priv *priv)
251{ 250{
252 void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL; 251 void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL;
252 u32 data;
253 253
254 /* Configure endianness */ 254 /* Configure endianness */
255 if (priv->version == BRCM_SATA_NSP) { 255 data = brcm_sata_readreg(ctrl);
256 u32 data = brcm_sata_readreg(ctrl); 256 data &= ~BUS_CTRL_ENDIAN_CONF_MASK;
257 257 if (priv->version == BRCM_SATA_NSP)
258 data &= ~((0x03 << DMADATA_ENDIAN_SHIFT) | 258 data |= BUS_CTRL_ENDIAN_NSP_CONF;
259 (0x03 << DMADESC_ENDIAN_SHIFT)); 259 else
260 data |= (0x02 << DMADATA_ENDIAN_SHIFT) | 260 data |= BUS_CTRL_ENDIAN_CONF;
261 (0x02 << DMADESC_ENDIAN_SHIFT); 261 brcm_sata_writereg(data, ctrl);
262 brcm_sata_writereg(data, ctrl); 262}
263 } else 263
264 brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, ctrl); 264static unsigned int brcm_ahci_read_id(struct ata_device *dev,
265 struct ata_taskfile *tf, u16 *id)
266{
267 struct ata_port *ap = dev->link->ap;
268 struct ata_host *host = ap->host;
269 struct ahci_host_priv *hpriv = host->private_data;
270 struct brcm_ahci_priv *priv = hpriv->plat_data;
271 void __iomem *mmio = hpriv->mmio;
272 unsigned int err_mask;
273 unsigned long flags;
274 int i, rc;
275 u32 ctl;
276
277 /* Try to read the device ID and, if this fails, proceed with the
278 * recovery sequence below
279 */
280 err_mask = ata_do_dev_read_id(dev, tf, id);
281 if (likely(!err_mask))
282 return err_mask;
283
284 /* Disable host interrupts */
285 spin_lock_irqsave(&host->lock, flags);
286 ctl = readl(mmio + HOST_CTL);
287 ctl &= ~HOST_IRQ_EN;
288 writel(ctl, mmio + HOST_CTL);
289 readl(mmio + HOST_CTL); /* flush */
290 spin_unlock_irqrestore(&host->lock, flags);
291
292 /* Perform the SATA PHY reset sequence */
293 brcm_sata_phy_disable(priv, ap->port_no);
294
295 /* Bring the PHY back on */
296 brcm_sata_phy_enable(priv, ap->port_no);
297
298 /* Re-initialize and calibrate the PHY */
299 for (i = 0; i < hpriv->nports; i++) {
300 rc = phy_init(hpriv->phys[i]);
301 if (rc)
302 goto disable_phys;
303
304 rc = phy_calibrate(hpriv->phys[i]);
305 if (rc) {
306 phy_exit(hpriv->phys[i]);
307 goto disable_phys;
308 }
309 }
310
311 /* Re-enable host interrupts */
312 spin_lock_irqsave(&host->lock, flags);
313 ctl = readl(mmio + HOST_CTL);
314 ctl |= HOST_IRQ_EN;
315 writel(ctl, mmio + HOST_CTL);
316 readl(mmio + HOST_CTL); /* flush */
317 spin_unlock_irqrestore(&host->lock, flags);
318
319 return ata_do_dev_read_id(dev, tf, id);
320
321disable_phys:
322 while (--i >= 0) {
323 phy_power_off(hpriv->phys[i]);
324 phy_exit(hpriv->phys[i]);
325 }
326
327 return AC_ERR_OTHER;
328}
329
330static void brcm_ahci_host_stop(struct ata_host *host)
331{
332 struct ahci_host_priv *hpriv = host->private_data;
333
334 ahci_platform_disable_resources(hpriv);
265} 335}
266 336
337static struct ata_port_operations ahci_brcm_platform_ops = {
338 .inherits = &ahci_ops,
339 .host_stop = brcm_ahci_host_stop,
340 .read_id = brcm_ahci_read_id,
341};
342
343static const struct ata_port_info ahci_brcm_port_info = {
344 .flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
345 .link_flags = ATA_LFLAG_NO_DB_DELAY,
346 .pio_mask = ATA_PIO4,
347 .udma_mask = ATA_UDMA6,
348 .port_ops = &ahci_brcm_platform_ops,
349};
350
267#ifdef CONFIG_PM_SLEEP 351#ifdef CONFIG_PM_SLEEP
268static int brcm_ahci_suspend(struct device *dev) 352static int brcm_ahci_suspend(struct device *dev)
269{ 353{
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index b702c20fbc2b..7ecb1322a514 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -458,7 +458,7 @@ static const struct piix_map_db *piix_map_db_table[] = {
458 [ich8_2port_sata_byt] = &ich8_2port_map_db, 458 [ich8_2port_sata_byt] = &ich8_2port_map_db,
459}; 459};
460 460
461static struct pci_bits piix_enable_bits[] = { 461static const struct pci_bits piix_enable_bits[] = {
462 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ 462 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
463 { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */ 463 { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */
464}; 464};
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c
deleted file mode 100644
index 9aeb7a6dd4d4..000000000000
--- a/drivers/ata/pata_at32.c
+++ /dev/null
@@ -1,400 +0,0 @@
1/*
2 * AVR32 SMC/CFC PATA Driver
3 *
4 * Copyright (C) 2007 Atmel Norway
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#define DEBUG
12
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/device.h>
17#include <linux/platform_device.h>
18#include <linux/delay.h>
19#include <linux/interrupt.h>
20#include <linux/irq.h>
21#include <linux/slab.h>
22#include <scsi/scsi_host.h>
23#include <linux/ata.h>
24#include <linux/libata.h>
25#include <linux/err.h>
26#include <linux/io.h>
27
28#include <mach/board.h>
29#include <mach/smc.h>
30
31#define DRV_NAME "pata_at32"
32#define DRV_VERSION "0.0.3"
33
34/*
35 * CompactFlash controller memory layout relative to the base address:
36 *
37 * Attribute memory: 0000 0000 -> 003f ffff
38 * Common memory: 0040 0000 -> 007f ffff
39 * I/O memory: 0080 0000 -> 00bf ffff
40 * True IDE Mode: 00c0 0000 -> 00df ffff
41 * Alt IDE Mode: 00e0 0000 -> 00ff ffff
42 *
43 * Only True IDE and Alt True IDE mode are needed for this driver.
44 *
45 * True IDE mode => CS0 = 0, CS1 = 1 (cmd, error, stat, etc)
46 * Alt True IDE mode => CS0 = 1, CS1 = 0 (ctl, alt_stat)
47 */
48#define CF_IDE_OFFSET 0x00c00000
49#define CF_ALT_IDE_OFFSET 0x00e00000
50#define CF_RES_SIZE 2048
51
52/*
53 * Define DEBUG_BUS if you are doing debugging of your own EBI -> PATA
54 * adaptor with a logic analyzer or similar.
55 */
56#undef DEBUG_BUS
57
58/*
59 * ATA PIO modes
60 *
61 * Name | Mb/s | Min cycle time | Mask
62 * --------+-------+----------------+--------
63 * Mode 0 | 3.3 | 600 ns | 0x01
64 * Mode 1 | 5.2 | 383 ns | 0x03
65 * Mode 2 | 8.3 | 240 ns | 0x07
66 * Mode 3 | 11.1 | 180 ns | 0x0f
67 * Mode 4 | 16.7 | 120 ns | 0x1f
68 *
69 * Alter PIO_MASK below according to table to set maximal PIO mode.
70 */
71enum {
72 PIO_MASK = ATA_PIO4,
73};
74
75/*
76 * Struct containing private information about device.
77 */
78struct at32_ide_info {
79 unsigned int irq;
80 struct resource res_ide;
81 struct resource res_alt;
82 void __iomem *ide_addr;
83 void __iomem *alt_addr;
84 unsigned int cs;
85 struct smc_config smc;
86};
87
88/*
89 * Setup SMC for the given ATA timing.
90 */
91static int pata_at32_setup_timing(struct device *dev,
92 struct at32_ide_info *info,
93 const struct ata_timing *ata)
94{
95 struct smc_config *smc = &info->smc;
96 struct smc_timing timing;
97
98 int active;
99 int recover;
100
101 memset(&timing, 0, sizeof(struct smc_timing));
102
103 /* Total cycle time */
104 timing.read_cycle = ata->cyc8b;
105
106 /* DIOR <= CFIOR timings */
107 timing.nrd_setup = ata->setup;
108 timing.nrd_pulse = ata->act8b;
109 timing.nrd_recover = ata->rec8b;
110
111 /* Convert nanosecond timing to clock cycles */
112 smc_set_timing(smc, &timing);
113
114 /* Add one extra cycle setup due to signal ring */
115 smc->nrd_setup = smc->nrd_setup + 1;
116
117 active = smc->nrd_setup + smc->nrd_pulse;
118 recover = smc->read_cycle - active;
119
120 /* Need at least two cycles recovery */
121 if (recover < 2)
122 smc->read_cycle = active + 2;
123
124 /* (CS0, CS1, DIR, OE) <= (CFCE1, CFCE2, CFRNW, NCSX) timings */
125 smc->ncs_read_setup = 1;
126 smc->ncs_read_pulse = smc->read_cycle - 2;
127
128 /* Write timings same as read timings */
129 smc->write_cycle = smc->read_cycle;
130 smc->nwe_setup = smc->nrd_setup;
131 smc->nwe_pulse = smc->nrd_pulse;
132 smc->ncs_write_setup = smc->ncs_read_setup;
133 smc->ncs_write_pulse = smc->ncs_read_pulse;
134
135 /* Do some debugging output of ATA and SMC timings */
136 dev_dbg(dev, "ATA: C=%d S=%d P=%d R=%d\n",
137 ata->cyc8b, ata->setup, ata->act8b, ata->rec8b);
138
139 dev_dbg(dev, "SMC: C=%d S=%d P=%d NS=%d NP=%d\n",
140 smc->read_cycle, smc->nrd_setup, smc->nrd_pulse,
141 smc->ncs_read_setup, smc->ncs_read_pulse);
142
143 /* Finally, configure the SMC */
144 return smc_set_configuration(info->cs, smc);
145}
146
147/*
148 * Procedures for libATA.
149 */
150static void pata_at32_set_piomode(struct ata_port *ap, struct ata_device *adev)
151{
152 struct ata_timing timing;
153 struct at32_ide_info *info = ap->host->private_data;
154
155 int ret;
156
157 /* Compute ATA timing */
158 ret = ata_timing_compute(adev, adev->pio_mode, &timing, 1000, 0);
159 if (ret) {
160 dev_warn(ap->dev, "Failed to compute ATA timing %d\n", ret);
161 return;
162 }
163
164 /* Setup SMC to ATA timing */
165 ret = pata_at32_setup_timing(ap->dev, info, &timing);
166 if (ret) {
167 dev_warn(ap->dev, "Failed to setup ATA timing %d\n", ret);
168 return;
169 }
170}
171
172static struct scsi_host_template at32_sht = {
173 ATA_PIO_SHT(DRV_NAME),
174};
175
176static struct ata_port_operations at32_port_ops = {
177 .inherits = &ata_sff_port_ops,
178 .cable_detect = ata_cable_40wire,
179 .set_piomode = pata_at32_set_piomode,
180};
181
182static int __init pata_at32_init_one(struct device *dev,
183 struct at32_ide_info *info)
184{
185 struct ata_host *host;
186 struct ata_port *ap;
187
188 host = ata_host_alloc(dev, 1);
189 if (!host)
190 return -ENOMEM;
191
192 ap = host->ports[0];
193
194 /* Setup ATA bindings */
195 ap->ops = &at32_port_ops;
196 ap->pio_mask = PIO_MASK;
197 ap->flags |= ATA_FLAG_SLAVE_POSS;
198
199 /*
200 * Since all 8-bit taskfile transfers has to go on the lower
201 * byte of the data bus and there is a bug in the SMC that
202 * makes it impossible to alter the bus width during runtime,
203 * we need to hardwire the address signals as follows:
204 *
205 * A_IDE(2:0) <= A_EBI(3:1)
206 *
207 * This makes all addresses on the EBI even, thus all data
208 * will be on the lower byte of the data bus. All addresses
209 * used by libATA need to be altered according to this.
210 */
211 ap->ioaddr.altstatus_addr = info->alt_addr + (0x06 << 1);
212 ap->ioaddr.ctl_addr = info->alt_addr + (0x06 << 1);
213
214 ap->ioaddr.data_addr = info->ide_addr + (ATA_REG_DATA << 1);
215 ap->ioaddr.error_addr = info->ide_addr + (ATA_REG_ERR << 1);
216 ap->ioaddr.feature_addr = info->ide_addr + (ATA_REG_FEATURE << 1);
217 ap->ioaddr.nsect_addr = info->ide_addr + (ATA_REG_NSECT << 1);
218 ap->ioaddr.lbal_addr = info->ide_addr + (ATA_REG_LBAL << 1);
219 ap->ioaddr.lbam_addr = info->ide_addr + (ATA_REG_LBAM << 1);
220 ap->ioaddr.lbah_addr = info->ide_addr + (ATA_REG_LBAH << 1);
221 ap->ioaddr.device_addr = info->ide_addr + (ATA_REG_DEVICE << 1);
222 ap->ioaddr.status_addr = info->ide_addr + (ATA_REG_STATUS << 1);
223 ap->ioaddr.command_addr = info->ide_addr + (ATA_REG_CMD << 1);
224
225 /* Set info as private data of ATA host */
226 host->private_data = info;
227
228 /* Register ATA device and return */
229 return ata_host_activate(host, info->irq, ata_sff_interrupt,
230 IRQF_SHARED | IRQF_TRIGGER_RISING,
231 &at32_sht);
232}
233
234/*
235 * This function may come in handy for people analyzing their own
236 * EBI -> PATA adaptors.
237 */
238#ifdef DEBUG_BUS
239
240static void __init pata_at32_debug_bus(struct device *dev,
241 struct at32_ide_info *info)
242{
243 const int d1 = 0xff;
244 const int d2 = 0x00;
245
246 int i;
247
248 /* Write 8-bit values (registers) */
249 iowrite8(d1, info->alt_addr + (0x06 << 1));
250 iowrite8(d2, info->alt_addr + (0x06 << 1));
251
252 for (i = 0; i < 8; i++) {
253 iowrite8(d1, info->ide_addr + (i << 1));
254 iowrite8(d2, info->ide_addr + (i << 1));
255 }
256
257 /* Write 16 bit values (data) */
258 iowrite16(d1, info->ide_addr);
259 iowrite16(d1 << 8, info->ide_addr);
260
261 iowrite16(d1, info->ide_addr);
262 iowrite16(d1 << 8, info->ide_addr);
263}
264
265#endif
266
267static int __init pata_at32_probe(struct platform_device *pdev)
268{
269 const struct ata_timing initial_timing =
270 {XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0};
271
272 struct device *dev = &pdev->dev;
273 struct at32_ide_info *info;
274 struct ide_platform_data *board = dev_get_platdata(&pdev->dev);
275 struct resource *res;
276
277 int irq;
278 int ret;
279
280 if (!board)
281 return -ENXIO;
282
283 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
284 if (!res)
285 return -ENXIO;
286
287 /* Retrive IRQ */
288 irq = platform_get_irq(pdev, 0);
289 if (irq < 0)
290 return irq;
291
292 /* Setup struct containing private information */
293 info = kzalloc(sizeof(struct at32_ide_info), GFP_KERNEL);
294 if (!info)
295 return -ENOMEM;
296
297 info->irq = irq;
298 info->cs = board->cs;
299
300 /* Request memory resources */
301 info->res_ide.start = res->start + CF_IDE_OFFSET;
302 info->res_ide.end = info->res_ide.start + CF_RES_SIZE - 1;
303 info->res_ide.name = "ide";
304 info->res_ide.flags = IORESOURCE_MEM;
305
306 ret = request_resource(res, &info->res_ide);
307 if (ret)
308 goto err_req_res_ide;
309
310 info->res_alt.start = res->start + CF_ALT_IDE_OFFSET;
311 info->res_alt.end = info->res_alt.start + CF_RES_SIZE - 1;
312 info->res_alt.name = "alt";
313 info->res_alt.flags = IORESOURCE_MEM;
314
315 ret = request_resource(res, &info->res_alt);
316 if (ret)
317 goto err_req_res_alt;
318
319 /* Setup non-timing elements of SMC */
320 info->smc.bus_width = 2; /* 16 bit data bus */
321 info->smc.nrd_controlled = 1; /* Sample data on rising edge of NRD */
322 info->smc.nwe_controlled = 0; /* Drive data on falling edge of NCS */
323 info->smc.nwait_mode = 3; /* NWAIT is in READY mode */
324 info->smc.byte_write = 0; /* Byte select access type */
325 info->smc.tdf_mode = 0; /* TDF optimization disabled */
326 info->smc.tdf_cycles = 0; /* No TDF wait cycles */
327
328 /* Setup SMC to ATA timing */
329 ret = pata_at32_setup_timing(dev, info, &initial_timing);
330 if (ret)
331 goto err_setup_timing;
332
333 /* Map ATA address space */
334 ret = -ENOMEM;
335 info->ide_addr = devm_ioremap(dev, info->res_ide.start, 16);
336 info->alt_addr = devm_ioremap(dev, info->res_alt.start, 16);
337 if (!info->ide_addr || !info->alt_addr)
338 goto err_ioremap;
339
340#ifdef DEBUG_BUS
341 pata_at32_debug_bus(dev, info);
342#endif
343
344 /* Setup and register ATA device */
345 ret = pata_at32_init_one(dev, info);
346 if (ret)
347 goto err_ata_device;
348
349 return 0;
350
351 err_ata_device:
352 err_ioremap:
353 err_setup_timing:
354 release_resource(&info->res_alt);
355 err_req_res_alt:
356 release_resource(&info->res_ide);
357 err_req_res_ide:
358 kfree(info);
359
360 return ret;
361}
362
363static int __exit pata_at32_remove(struct platform_device *pdev)
364{
365 struct ata_host *host = platform_get_drvdata(pdev);
366 struct at32_ide_info *info;
367
368 if (!host)
369 return 0;
370
371 info = host->private_data;
372 ata_host_detach(host);
373
374 if (!info)
375 return 0;
376
377 release_resource(&info->res_ide);
378 release_resource(&info->res_alt);
379
380 kfree(info);
381
382 return 0;
383}
384
385/* work with hotplug and coldplug */
386MODULE_ALIAS("platform:at32_ide");
387
388static struct platform_driver pata_at32_driver = {
389 .remove = __exit_p(pata_at32_remove),
390 .driver = {
391 .name = "at32_ide",
392 },
393};
394
395module_platform_driver_probe(pata_at32_driver, pata_at32_probe);
396
397MODULE_LICENSE("GPL");
398MODULE_DESCRIPTION("AVR32 SMC/CFC PATA Driver");
399MODULE_AUTHOR("Kristoffer Nyborg Gregertsen <kngregertsen@norway.atmel.com>");
400MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 49d705c9f0f7..4d49fd3c927b 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -278,6 +278,10 @@ static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
278 }; 278 };
279 const struct ata_port_info *ppi[] = { &info, &info }; 279 const struct ata_port_info *ppi[] = { &info, &info };
280 280
281 /* SB600 doesn't have secondary port wired */
282 if((pdev->device == PCI_DEVICE_ID_ATI_IXP600_IDE))
283 ppi[1] = &ata_dummy_port_info;
284
281 return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL, 285 return ata_pci_bmdma_init_one(pdev, ppi, &atiixp_sht, NULL,
282 ATA_HOST_PARALLEL_SCAN); 286 ATA_HOST_PARALLEL_SCAN);
283} 287}
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 7a21edf89e72..8468b300193b 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -683,7 +683,7 @@ static u8 *it821x_firmware_command(struct ata_port *ap, u8 cmd, int len)
683 ioread16_rep(ap->ioaddr.data_addr, buf, len/2); 683 ioread16_rep(ap->ioaddr.data_addr, buf, len/2);
684 return (u8 *)buf; 684 return (u8 *)buf;
685 } 685 }
686 mdelay(1); 686 usleep_range(500, 1000);
687 } 687 }
688 kfree(buf); 688 kfree(buf);
689 printk(KERN_ERR "it821x_firmware_command: timeout\n"); 689 printk(KERN_ERR "it821x_firmware_command: timeout\n");
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 6db2e34bd52f..1a18e675ba9f 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -580,7 +580,7 @@ static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int b
580 ioread16(mmio_base + PDC_PLL_CTL); /* flush */ 580 ioread16(mmio_base + PDC_PLL_CTL); /* flush */
581 581
582 /* Wait the PLL circuit to be stable */ 582 /* Wait the PLL circuit to be stable */
583 mdelay(30); 583 msleep(30);
584 584
585#ifdef PDC_DEBUG 585#ifdef PDC_DEBUG
586 /* 586 /*
@@ -620,7 +620,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
620 start_time = ktime_get(); 620 start_time = ktime_get();
621 621
622 /* Let the counter run for 100 ms. */ 622 /* Let the counter run for 100 ms. */
623 mdelay(100); 623 msleep(100);
624 624
625 /* Read the counter values again */ 625 /* Read the counter values again */
626 end_count = pdc_read_counter(host); 626 end_count = pdc_read_counter(host);
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index cc208b72b199..42d4589b43d4 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -3596,7 +3596,7 @@ static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio,
3596 hpriv->ops->phy_errata(hpriv, mmio, port_no); 3596 hpriv->ops->phy_errata(hpriv, mmio, port_no);
3597 3597
3598 if (IS_GEN_I(hpriv)) 3598 if (IS_GEN_I(hpriv))
3599 mdelay(1); 3599 usleep_range(500, 1000);
3600} 3600}
3601 3601
3602static void mv_pmp_select(struct ata_port *ap, int pmp) 3602static void mv_pmp_select(struct ata_port *ap, int pmp)
diff --git a/drivers/phy/broadcom/phy-brcm-sata.c b/drivers/phy/broadcom/phy-brcm-sata.c
index 3f953db70288..8708ea3b4d6d 100644
--- a/drivers/phy/broadcom/phy-brcm-sata.c
+++ b/drivers/phy/broadcom/phy-brcm-sata.c
@@ -150,6 +150,9 @@ enum sata_phy_regs {
150 TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK = 0x3ff, 150 TXPMD_TX_FREQ_CTRL_CONTROL2_FMIN_MASK = 0x3ff,
151 TXPMD_TX_FREQ_CTRL_CONTROL3 = 0x84, 151 TXPMD_TX_FREQ_CTRL_CONTROL3 = 0x84,
152 TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff, 152 TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK = 0x3ff,
153
154 RXPMD_REG_BANK = 0x1c0,
155 RXPMD_RX_FREQ_MON_CONTROL1 = 0x87,
153}; 156};
154 157
155enum sata_phy_ctrl_regs { 158enum sata_phy_ctrl_regs {
@@ -505,8 +508,36 @@ static int brcm_sata_phy_init(struct phy *phy)
505 return rc; 508 return rc;
506} 509}
507 510
511static void brcm_stb_sata_calibrate(struct brcm_sata_port *port)
512{
513 void __iomem *base = brcm_sata_pcb_base(port);
514 u32 tmp = BIT(8);
515
516 brcm_sata_phy_wr(base, RXPMD_REG_BANK, RXPMD_RX_FREQ_MON_CONTROL1,
517 ~tmp, tmp);
518}
519
520static int brcm_sata_phy_calibrate(struct phy *phy)
521{
522 struct brcm_sata_port *port = phy_get_drvdata(phy);
523 int rc = -EOPNOTSUPP;
524
525 switch (port->phy_priv->version) {
526 case BRCM_SATA_PHY_STB_28NM:
527 case BRCM_SATA_PHY_STB_40NM:
528 brcm_stb_sata_calibrate(port);
529 rc = 0;
530 break;
531 default:
532 break;
533 }
534
535 return rc;
536}
537
508static const struct phy_ops phy_ops = { 538static const struct phy_ops phy_ops = {
509 .init = brcm_sata_phy_init, 539 .init = brcm_sata_phy_init,
540 .calibrate = brcm_sata_phy_calibrate,
510 .owner = THIS_MODULE, 541 .owner = THIS_MODULE,
511}; 542};
512 543