blob: 53c39ce1fb6899d2c86992edf129d8e77ec87f0c [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Roger Quadrosa087a7f2013-11-11 16:56:41 +02002/*
3 * TI SATA platform driver
4 *
5 * (C) Copyright 2013
6 * Texas Instruments, <www.ti.com>
Roger Quadrosa087a7f2013-11-11 16:56:41 +02007 */
8
9#include <common.h>
10#include <ahci.h>
11#include <scsi.h>
12#include <asm/arch/clock.h>
13#include <asm/arch/sata.h>
Dan Murphye9024ef2014-02-03 06:59:02 -060014#include <sata.h>
Roger Quadrosa087a7f2013-11-11 16:56:41 +020015#include <asm/io.h>
Tom Rini12f613c2022-05-12 17:22:26 -040016#include <asm/omap_common.h>
Roger Quadrosa087a7f2013-11-11 16:56:41 +020017#include "pipe3-phy.h"
18
19static struct pipe3_dpll_map dpll_map_sata[] = {
20 {12000000, {1000, 7, 4, 6, 0} }, /* 12 MHz */
21 {16800000, {714, 7, 4, 6, 0} }, /* 16.8 MHz */
22 {19200000, {625, 7, 4, 6, 0} }, /* 19.2 MHz */
23 {20000000, {600, 7, 4, 6, 0} }, /* 20 MHz */
24 {26000000, {461, 7, 4, 6, 0} }, /* 26 MHz */
25 {38400000, {312, 7, 4, 6, 0} }, /* 38.4 MHz */
26 { }, /* Terminator */
27};
28
29struct omap_pipe3 sata_phy = {
30 .pll_ctrl_base = (void __iomem *)TI_SATA_PLLCTRL_BASE,
31 /* .power_reg is updated at runtime */
32 .dpll_map = dpll_map_sata,
33};
34
Dan Murphye9024ef2014-02-03 06:59:02 -060035int init_sata(int dev)
Roger Quadrosa087a7f2013-11-11 16:56:41 +020036{
37 int ret;
38 u32 val;
39
Roger Quadrosa087a7f2013-11-11 16:56:41 +020040 sata_phy.power_reg = (void __iomem *)(*ctrl)->control_phy_power_sata;
41
42 /* Power up the PHY */
43 phy_pipe3_power_on(&sata_phy);
44
45 /* Enable SATA module, No Idle, No Standby */
46 val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO;
47 writel(val, TI_SATA_WRAPPER_BASE + TI_SATA_SYSCONFIG);
48
Scott Wood9efaca32015-04-17 09:19:01 -050049 ret = ahci_init((void __iomem *)DWC_AHSATA_BASE);
Roger Quadrosa087a7f2013-11-11 16:56:41 +020050
51 return ret;
52}
Roger Quadros3160b1b2014-09-23 18:07:02 +030053
Nikita Kiryanov10ee8ec2014-11-21 12:47:23 +020054int reset_sata(int dev)
55{
56 return 0;
57}
58
Roger Quadros3160b1b2014-09-23 18:07:02 +030059/* On OMAP platforms SATA provides the SCSI subsystem */
60void scsi_init(void)
61{
62 init_sata(0);
Roger Quadrosd59baeb2014-09-23 18:07:03 +030063 scsi_scan(1);
Roger Quadros3160b1b2014-09-23 18:07:02 +030064}
Dmitry Lifshitz8decf5d2014-12-15 16:02:57 +020065
Simon Glass4682c8a2017-06-14 21:28:40 -060066int scsi_bus_reset(struct udevice *dev)
Dmitry Lifshitz8decf5d2014-12-15 16:02:57 +020067{
Scott Wood9efaca32015-04-17 09:19:01 -050068 ahci_reset((void __iomem *)DWC_AHSATA_BASE);
69 ahci_init((void __iomem *)DWC_AHSATA_BASE);
Simon Glass4682c8a2017-06-14 21:28:40 -060070
71 return 0;
Dmitry Lifshitz8decf5d2014-12-15 16:02:57 +020072}