diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-26 17:39:40 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-26 17:39:40 -0400 |
| commit | 75a442efb1ca613f8d1cc71a32c2c9b0aefae4a5 (patch) | |
| tree | 6161c21803db3f03bcbd26715761e2d310246bb8 /drivers/phy | |
| parent | b55b048718c8c833186c87ceeea86b78346cda2e (diff) | |
| parent | 737bee9308c457090711684b976e0fe02785a094 (diff) | |
Merge branch 'for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata updates from Tejun Heo:
"libata saw quite a bit of activities in this cycle:
- SMR drive support still being worked on
- bug fixes and improvements to misc SCSI command emulation
- some low level driver updates"
* 'for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (39 commits)
libata-scsi: better style in ata_msense_*()
AHCI: Clear GHC.IS to prevent unexpectly asserting INTx
ata: sata_dwc_460ex: remove redundant dev_err call
ata: define ATA_PROT_* in terms of ATA_PROT_FLAG_*
libata: remove ATA_PROT_FLAG_DATA
libata: remove ata_is_nodata
ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48}
libata-scsi: minor cleanup for ata_scsi_zbc_out_xlat
libata-scsi: Fix ZBC management out command translation
libata-scsi: Fix translation of REPORT ZONES command
ata: Handle ATA NCQ NO-DATA commands correctly
libata-eh: decode all taskfile protocols
ata: fixup ATA_PROT_NODATA
libsas: use ata_is_ncq() and ata_has_dma() accessors
libata: use ata_is_ncq() accessors
libata: return boolean values from ata_is_*
libata-scsi: avoid repeated calculation of number of TRIM ranges
libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit
libata-scsi: rename ata_msense_ctl_mode() to ata_msense_control()
libata-scsi: fix D_SENSE bit relection in control mode page
...
Diffstat (limited to 'drivers/phy')
| -rw-r--r-- | drivers/phy/phy-brcm-sata.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c index 6c4c5cb791ca..18d662610075 100644 --- a/drivers/phy/phy-brcm-sata.c +++ b/drivers/phy/phy-brcm-sata.c | |||
| @@ -45,6 +45,7 @@ enum brcm_sata_phy_version { | |||
| 45 | BRCM_SATA_PHY_STB_28NM, | 45 | BRCM_SATA_PHY_STB_28NM, |
| 46 | BRCM_SATA_PHY_STB_40NM, | 46 | BRCM_SATA_PHY_STB_40NM, |
| 47 | BRCM_SATA_PHY_IPROC_NS2, | 47 | BRCM_SATA_PHY_IPROC_NS2, |
| 48 | BRCM_SATA_PHY_IPROC_NSP, | ||
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 50 | struct brcm_sata_port { | 51 | struct brcm_sata_port { |
| @@ -73,6 +74,13 @@ enum sata_phy_regs { | |||
| 73 | 74 | ||
| 74 | PLL_REG_BANK_0 = 0x050, | 75 | PLL_REG_BANK_0 = 0x050, |
| 75 | PLL_REG_BANK_0_PLLCONTROL_0 = 0x81, | 76 | PLL_REG_BANK_0_PLLCONTROL_0 = 0x81, |
| 77 | PLLCONTROL_0_FREQ_DET_RESTART = BIT(13), | ||
| 78 | PLLCONTROL_0_FREQ_MONITOR = BIT(12), | ||
| 79 | PLLCONTROL_0_SEQ_START = BIT(15), | ||
| 80 | PLL_CAP_CONTROL = 0x85, | ||
| 81 | PLL_ACTRL2 = 0x8b, | ||
| 82 | PLL_ACTRL2_SELDIV_MASK = 0x1f, | ||
| 83 | PLL_ACTRL2_SELDIV_SHIFT = 9, | ||
| 76 | 84 | ||
| 77 | PLL1_REG_BANK = 0x060, | 85 | PLL1_REG_BANK = 0x060, |
| 78 | PLL1_ACTRL2 = 0x82, | 86 | PLL1_ACTRL2 = 0x82, |
| @@ -80,6 +88,7 @@ enum sata_phy_regs { | |||
| 80 | PLL1_ACTRL4 = 0x84, | 88 | PLL1_ACTRL4 = 0x84, |
| 81 | 89 | ||
| 82 | OOB_REG_BANK = 0x150, | 90 | OOB_REG_BANK = 0x150, |
| 91 | OOB1_REG_BANK = 0x160, | ||
| 83 | OOB_CTRL1 = 0x80, | 92 | OOB_CTRL1 = 0x80, |
| 84 | OOB_CTRL1_BURST_MAX_MASK = 0xf, | 93 | OOB_CTRL1_BURST_MAX_MASK = 0xf, |
| 85 | OOB_CTRL1_BURST_MAX_SHIFT = 12, | 94 | OOB_CTRL1_BURST_MAX_SHIFT = 12, |
| @@ -271,6 +280,73 @@ static int brcm_ns2_sata_init(struct brcm_sata_port *port) | |||
| 271 | return 0; | 280 | return 0; |
| 272 | } | 281 | } |
| 273 | 282 | ||
| 283 | static int brcm_nsp_sata_init(struct brcm_sata_port *port) | ||
| 284 | { | ||
| 285 | struct brcm_sata_phy *priv = port->phy_priv; | ||
| 286 | struct device *dev = port->phy_priv->dev; | ||
| 287 | void __iomem *base = priv->phy_base; | ||
| 288 | unsigned int oob_bank; | ||
| 289 | unsigned int val, try; | ||
| 290 | |||
| 291 | /* Configure OOB control */ | ||
| 292 | if (port->portnum == 0) | ||
| 293 | oob_bank = OOB_REG_BANK; | ||
| 294 | else if (port->portnum == 1) | ||
| 295 | oob_bank = OOB1_REG_BANK; | ||
| 296 | else | ||
| 297 | return -EINVAL; | ||
| 298 | |||
| 299 | val = 0x0; | ||
| 300 | val |= (0x0f << OOB_CTRL1_BURST_MAX_SHIFT); | ||
| 301 | val |= (0x06 << OOB_CTRL1_BURST_MIN_SHIFT); | ||
| 302 | val |= (0x0f << OOB_CTRL1_WAKE_IDLE_MAX_SHIFT); | ||
| 303 | val |= (0x06 << OOB_CTRL1_WAKE_IDLE_MIN_SHIFT); | ||
| 304 | brcm_sata_phy_wr(base, oob_bank, OOB_CTRL1, 0x0, val); | ||
| 305 | |||
| 306 | val = 0x0; | ||
| 307 | val |= (0x2e << OOB_CTRL2_RESET_IDLE_MAX_SHIFT); | ||
| 308 | val |= (0x02 << OOB_CTRL2_BURST_CNT_SHIFT); | ||
| 309 | val |= (0x16 << OOB_CTRL2_RESET_IDLE_MIN_SHIFT); | ||
| 310 | brcm_sata_phy_wr(base, oob_bank, OOB_CTRL2, 0x0, val); | ||
| 311 | |||
| 312 | |||
| 313 | brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_ACTRL2, | ||
| 314 | ~(PLL_ACTRL2_SELDIV_MASK << PLL_ACTRL2_SELDIV_SHIFT), | ||
| 315 | 0x0c << PLL_ACTRL2_SELDIV_SHIFT); | ||
| 316 | |||
| 317 | brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_CAP_CONTROL, | ||
| 318 | 0xff0, 0x4f0); | ||
| 319 | |||
| 320 | val = PLLCONTROL_0_FREQ_DET_RESTART | PLLCONTROL_0_FREQ_MONITOR; | ||
| 321 | brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0, | ||
| 322 | ~val, val); | ||
| 323 | val = PLLCONTROL_0_SEQ_START; | ||
| 324 | brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0, | ||
| 325 | ~val, 0); | ||
| 326 | mdelay(10); | ||
| 327 | brcm_sata_phy_wr(base, PLL_REG_BANK_0, PLL_REG_BANK_0_PLLCONTROL_0, | ||
| 328 | ~val, val); | ||
| 329 | |||
| 330 | /* Wait for pll_seq_done bit */ | ||
| 331 | try = 50; | ||
| 332 | while (try--) { | ||
| 333 | val = brcm_sata_phy_rd(base, BLOCK0_REG_BANK, | ||
| 334 | BLOCK0_XGXSSTATUS); | ||
| 335 | if (val & BLOCK0_XGXSSTATUS_PLL_LOCK) | ||
| 336 | break; | ||
| 337 | msleep(20); | ||
| 338 | } | ||
| 339 | if (!try) { | ||
| 340 | /* PLL did not lock; give up */ | ||
| 341 | dev_err(dev, "port%d PLL did not lock\n", port->portnum); | ||
| 342 | return -ETIMEDOUT; | ||
| 343 | } | ||
| 344 | |||
| 345 | dev_dbg(dev, "port%d initialized\n", port->portnum); | ||
| 346 | |||
| 347 | return 0; | ||
| 348 | } | ||
| 349 | |||
| 274 | static int brcm_sata_phy_init(struct phy *phy) | 350 | static int brcm_sata_phy_init(struct phy *phy) |
| 275 | { | 351 | { |
| 276 | int rc; | 352 | int rc; |
| @@ -284,6 +360,9 @@ static int brcm_sata_phy_init(struct phy *phy) | |||
| 284 | case BRCM_SATA_PHY_IPROC_NS2: | 360 | case BRCM_SATA_PHY_IPROC_NS2: |
| 285 | rc = brcm_ns2_sata_init(port); | 361 | rc = brcm_ns2_sata_init(port); |
| 286 | break; | 362 | break; |
| 363 | case BRCM_SATA_PHY_IPROC_NSP: | ||
| 364 | rc = brcm_nsp_sata_init(port); | ||
| 365 | break; | ||
| 287 | default: | 366 | default: |
| 288 | rc = -ENODEV; | 367 | rc = -ENODEV; |
| 289 | }; | 368 | }; |
| @@ -303,6 +382,8 @@ static const struct of_device_id brcm_sata_phy_of_match[] = { | |||
| 303 | .data = (void *)BRCM_SATA_PHY_STB_40NM }, | 382 | .data = (void *)BRCM_SATA_PHY_STB_40NM }, |
| 304 | { .compatible = "brcm,iproc-ns2-sata-phy", | 383 | { .compatible = "brcm,iproc-ns2-sata-phy", |
| 305 | .data = (void *)BRCM_SATA_PHY_IPROC_NS2 }, | 384 | .data = (void *)BRCM_SATA_PHY_IPROC_NS2 }, |
| 385 | { .compatible = "brcm,iproc-nsp-sata-phy", | ||
| 386 | .data = (void *)BRCM_SATA_PHY_IPROC_NSP }, | ||
| 306 | {}, | 387 | {}, |
| 307 | }; | 388 | }; |
| 308 | MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match); | 389 | MODULE_DEVICE_TABLE(of, brcm_sata_phy_of_match); |
