blob: 144f2c368d042a5960e2bce24eb071850f0bb77c [file] [log] [blame]
tang yuantian9f51db22015-10-16 16:06:05 +08001/*
2 * Copyright 2015 Freescale Semiconductor, Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6#include <common.h>
7#include <asm/io.h>
8#include <asm/arch/immap_ls102xa.h>
9#include <ahci.h>
10#include <scsi.h>
11
12/* port register default value */
13#define AHCI_PORT_PHY_1_CFG 0xa003fffe
Tang Yuantiandd10f752015-12-16 13:50:57 +080014#define AHCI_PORT_PHY_2_CFG 0x28183414
15#define AHCI_PORT_PHY_3_CFG 0x0e080e06
16#define AHCI_PORT_PHY_4_CFG 0x064a080b
17#define AHCI_PORT_PHY_5_CFG 0x2aa86470
18#define AHCI_PORT_TRANS_CFG 0x08000029
tang yuantian9f51db22015-10-16 16:06:05 +080019
20#define SATA_ECC_REG_ADDR 0x20220520
21#define SATA_ECC_DISABLE 0x00020000
22
23int ls1021a_sata_init(void)
24{
25 struct ccsr_ahci __iomem *ccsr_ahci = (void *)AHCI_BASE_ADDR;
26
27#ifdef CONFIG_SYS_FSL_ERRATUM_A008407
28 out_le32((void *)SATA_ECC_REG_ADDR, SATA_ECC_DISABLE);
29#endif
30
31 out_le32(&ccsr_ahci->ppcfg, AHCI_PORT_PHY_1_CFG);
32 out_le32(&ccsr_ahci->pp2c, AHCI_PORT_PHY_2_CFG);
33 out_le32(&ccsr_ahci->pp3c, AHCI_PORT_PHY_3_CFG);
34 out_le32(&ccsr_ahci->pp4c, AHCI_PORT_PHY_4_CFG);
35 out_le32(&ccsr_ahci->pp5c, AHCI_PORT_PHY_5_CFG);
36 out_le32(&ccsr_ahci->ptc, AHCI_PORT_TRANS_CFG);
37
38 ahci_init((void __iomem *)AHCI_BASE_ADDR);
39 scsi_scan(0);
40
41 return 0;
42}