1983e3700STom Rini /* 2983e3700STom Rini * TI SATA platform driver 3983e3700STom Rini * 4983e3700STom Rini * (C) Copyright 2013 5983e3700STom Rini * Texas Instruments, <www.ti.com> 6983e3700STom Rini * 7983e3700STom Rini * SPDX-License-Identifier: GPL-2.0+ 8983e3700STom Rini */ 9983e3700STom Rini 10983e3700STom Rini #include <common.h> 11983e3700STom Rini #include <ahci.h> 12983e3700STom Rini #include <scsi.h> 13983e3700STom Rini #include <asm/arch/clock.h> 14983e3700STom Rini #include <asm/arch/sata.h> 15983e3700STom Rini #include <sata.h> 16983e3700STom Rini #include <asm/io.h> 17983e3700STom Rini #include "pipe3-phy.h" 18983e3700STom Rini 19983e3700STom Rini static struct pipe3_dpll_map dpll_map_sata[] = { 20983e3700STom Rini {12000000, {1000, 7, 4, 6, 0} }, /* 12 MHz */ 21983e3700STom Rini {16800000, {714, 7, 4, 6, 0} }, /* 16.8 MHz */ 22983e3700STom Rini {19200000, {625, 7, 4, 6, 0} }, /* 19.2 MHz */ 23983e3700STom Rini {20000000, {600, 7, 4, 6, 0} }, /* 20 MHz */ 24983e3700STom Rini {26000000, {461, 7, 4, 6, 0} }, /* 26 MHz */ 25983e3700STom Rini {38400000, {312, 7, 4, 6, 0} }, /* 38.4 MHz */ 26983e3700STom Rini { }, /* Terminator */ 27983e3700STom Rini }; 28983e3700STom Rini 29983e3700STom Rini struct omap_pipe3 sata_phy = { 30983e3700STom Rini .pll_ctrl_base = (void __iomem *)TI_SATA_PLLCTRL_BASE, 31983e3700STom Rini /* .power_reg is updated at runtime */ 32983e3700STom Rini .dpll_map = dpll_map_sata, 33983e3700STom Rini }; 34983e3700STom Rini 35983e3700STom Rini int init_sata(int dev) 36983e3700STom Rini { 37983e3700STom Rini int ret; 38983e3700STom Rini u32 val; 39983e3700STom Rini 40983e3700STom Rini sata_phy.power_reg = (void __iomem *)(*ctrl)->control_phy_power_sata; 41983e3700STom Rini 42983e3700STom Rini /* Power up the PHY */ 43983e3700STom Rini phy_pipe3_power_on(&sata_phy); 44983e3700STom Rini 45983e3700STom Rini /* Enable SATA module, No Idle, No Standby */ 46983e3700STom Rini val = TI_SATA_IDLE_NO | TI_SATA_STANDBY_NO; 47983e3700STom Rini writel(val, TI_SATA_WRAPPER_BASE + TI_SATA_SYSCONFIG); 48983e3700STom Rini 49983e3700STom Rini ret = ahci_init((void __iomem *)DWC_AHSATA_BASE); 50983e3700STom Rini 51983e3700STom Rini return ret; 52983e3700STom Rini } 53983e3700STom Rini 54983e3700STom Rini int reset_sata(int dev) 55983e3700STom Rini { 56983e3700STom Rini return 0; 57983e3700STom Rini } 58983e3700STom Rini 59983e3700STom Rini /* On OMAP platforms SATA provides the SCSI subsystem */ 60983e3700STom Rini void scsi_init(void) 61983e3700STom Rini { 62983e3700STom Rini init_sata(0); 63983e3700STom Rini scsi_scan(1); 64983e3700STom Rini } 65983e3700STom Rini 66*4682c8a1SSimon Glass int scsi_bus_reset(struct udevice *dev) 67983e3700STom Rini { 68983e3700STom Rini ahci_reset((void __iomem *)DWC_AHSATA_BASE); 69983e3700STom Rini ahci_init((void __iomem *)DWC_AHSATA_BASE); 70*4682c8a1SSimon Glass 71*4682c8a1SSimon Glass return 0; 72983e3700STom Rini } 73