18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * phy-ti-pipe3 - PIPE3 PHY driver. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com 68c2ecf20Sopenharmony_ci * Author: Kishon Vijay Abraham I <kishon@ti.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 118c2ecf20Sopenharmony_ci#include <linux/slab.h> 128c2ecf20Sopenharmony_ci#include <linux/phy/phy.h> 138c2ecf20Sopenharmony_ci#include <linux/of.h> 148c2ecf20Sopenharmony_ci#include <linux/clk.h> 158c2ecf20Sopenharmony_ci#include <linux/err.h> 168c2ecf20Sopenharmony_ci#include <linux/io.h> 178c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h> 188c2ecf20Sopenharmony_ci#include <linux/delay.h> 198c2ecf20Sopenharmony_ci#include <linux/phy/omap_control_phy.h> 208c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 218c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h> 228c2ecf20Sopenharmony_ci#include <linux/regmap.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define PLL_STATUS 0x00000004 258c2ecf20Sopenharmony_ci#define PLL_GO 0x00000008 268c2ecf20Sopenharmony_ci#define PLL_CONFIGURATION1 0x0000000C 278c2ecf20Sopenharmony_ci#define PLL_CONFIGURATION2 0x00000010 288c2ecf20Sopenharmony_ci#define PLL_CONFIGURATION3 0x00000014 298c2ecf20Sopenharmony_ci#define PLL_CONFIGURATION4 0x00000020 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define PLL_REGM_MASK 0x001FFE00 328c2ecf20Sopenharmony_ci#define PLL_REGM_SHIFT 0x9 338c2ecf20Sopenharmony_ci#define PLL_REGM_F_MASK 0x0003FFFF 348c2ecf20Sopenharmony_ci#define PLL_REGM_F_SHIFT 0x0 358c2ecf20Sopenharmony_ci#define PLL_REGN_MASK 0x000001FE 368c2ecf20Sopenharmony_ci#define PLL_REGN_SHIFT 0x1 378c2ecf20Sopenharmony_ci#define PLL_SELFREQDCO_MASK 0x0000000E 388c2ecf20Sopenharmony_ci#define PLL_SELFREQDCO_SHIFT 0x1 398c2ecf20Sopenharmony_ci#define PLL_SD_MASK 0x0003FC00 408c2ecf20Sopenharmony_ci#define PLL_SD_SHIFT 10 418c2ecf20Sopenharmony_ci#define SET_PLL_GO 0x1 428c2ecf20Sopenharmony_ci#define PLL_LDOPWDN BIT(15) 438c2ecf20Sopenharmony_ci#define PLL_TICOPWDN BIT(16) 448c2ecf20Sopenharmony_ci#define PLL_LOCK 0x2 458c2ecf20Sopenharmony_ci#define PLL_IDLE 0x1 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define SATA_PLL_SOFT_RESET BIT(18) 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK GENMASK(21, 14) 508c2ecf20Sopenharmony_ci#define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT 14 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK GENMASK(31, 22) 538c2ecf20Sopenharmony_ci#define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT 22 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define PIPE3_PHY_RX_POWERON (0x1 << PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT) 568c2ecf20Sopenharmony_ci#define PIPE3_PHY_TX_POWERON (0x2 << PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define PCIE_PCS_MASK 0xFF0000 598c2ecf20Sopenharmony_ci#define PCIE_PCS_DELAY_COUNT_SHIFT 0x10 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define PIPE3_PHY_RX_ANA_PROGRAMMABILITY 0x0000000C 628c2ecf20Sopenharmony_ci#define INTERFACE_MASK GENMASK(31, 27) 638c2ecf20Sopenharmony_ci#define INTERFACE_SHIFT 27 648c2ecf20Sopenharmony_ci#define INTERFACE_MODE_USBSS BIT(4) 658c2ecf20Sopenharmony_ci#define INTERFACE_MODE_SATA_1P5 BIT(3) 668c2ecf20Sopenharmony_ci#define INTERFACE_MODE_SATA_3P0 BIT(2) 678c2ecf20Sopenharmony_ci#define INTERFACE_MODE_PCIE BIT(0) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define LOSD_MASK GENMASK(17, 14) 708c2ecf20Sopenharmony_ci#define LOSD_SHIFT 14 718c2ecf20Sopenharmony_ci#define MEM_PLLDIV GENMASK(6, 5) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#define PIPE3_PHY_RX_TRIM 0x0000001C 748c2ecf20Sopenharmony_ci#define MEM_DLL_TRIM_SEL_MASK GENMASK(31, 30) 758c2ecf20Sopenharmony_ci#define MEM_DLL_TRIM_SHIFT 30 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define PIPE3_PHY_RX_DLL 0x00000024 788c2ecf20Sopenharmony_ci#define MEM_DLL_PHINT_RATE_MASK GENMASK(31, 30) 798c2ecf20Sopenharmony_ci#define MEM_DLL_PHINT_RATE_SHIFT 30 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define PIPE3_PHY_RX_DIGITAL_MODES 0x00000028 828c2ecf20Sopenharmony_ci#define MEM_HS_RATE_MASK GENMASK(28, 27) 838c2ecf20Sopenharmony_ci#define MEM_HS_RATE_SHIFT 27 848c2ecf20Sopenharmony_ci#define MEM_OVRD_HS_RATE BIT(26) 858c2ecf20Sopenharmony_ci#define MEM_OVRD_HS_RATE_SHIFT 26 868c2ecf20Sopenharmony_ci#define MEM_CDR_FASTLOCK BIT(23) 878c2ecf20Sopenharmony_ci#define MEM_CDR_FASTLOCK_SHIFT 23 888c2ecf20Sopenharmony_ci#define MEM_CDR_LBW_MASK GENMASK(22, 21) 898c2ecf20Sopenharmony_ci#define MEM_CDR_LBW_SHIFT 21 908c2ecf20Sopenharmony_ci#define MEM_CDR_STEPCNT_MASK GENMASK(20, 19) 918c2ecf20Sopenharmony_ci#define MEM_CDR_STEPCNT_SHIFT 19 928c2ecf20Sopenharmony_ci#define MEM_CDR_STL_MASK GENMASK(18, 16) 938c2ecf20Sopenharmony_ci#define MEM_CDR_STL_SHIFT 16 948c2ecf20Sopenharmony_ci#define MEM_CDR_THR_MASK GENMASK(15, 13) 958c2ecf20Sopenharmony_ci#define MEM_CDR_THR_SHIFT 13 968c2ecf20Sopenharmony_ci#define MEM_CDR_THR_MODE BIT(12) 978c2ecf20Sopenharmony_ci#define MEM_CDR_THR_MODE_SHIFT 12 988c2ecf20Sopenharmony_ci#define MEM_CDR_2NDO_SDM_MODE BIT(11) 998c2ecf20Sopenharmony_ci#define MEM_CDR_2NDO_SDM_MODE_SHIFT 11 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci#define PIPE3_PHY_RX_EQUALIZER 0x00000038 1028c2ecf20Sopenharmony_ci#define MEM_EQLEV_MASK GENMASK(31, 16) 1038c2ecf20Sopenharmony_ci#define MEM_EQLEV_SHIFT 16 1048c2ecf20Sopenharmony_ci#define MEM_EQFTC_MASK GENMASK(15, 11) 1058c2ecf20Sopenharmony_ci#define MEM_EQFTC_SHIFT 11 1068c2ecf20Sopenharmony_ci#define MEM_EQCTL_MASK GENMASK(10, 7) 1078c2ecf20Sopenharmony_ci#define MEM_EQCTL_SHIFT 7 1088c2ecf20Sopenharmony_ci#define MEM_OVRD_EQLEV BIT(2) 1098c2ecf20Sopenharmony_ci#define MEM_OVRD_EQLEV_SHIFT 2 1108c2ecf20Sopenharmony_ci#define MEM_OVRD_EQFTC BIT(1) 1118c2ecf20Sopenharmony_ci#define MEM_OVRD_EQFTC_SHIFT 1 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci#define SATA_PHY_RX_IO_AND_A2D_OVERRIDES 0x44 1148c2ecf20Sopenharmony_ci#define MEM_CDR_LOS_SOURCE_MASK GENMASK(10, 9) 1158c2ecf20Sopenharmony_ci#define MEM_CDR_LOS_SOURCE_SHIFT 9 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* 1188c2ecf20Sopenharmony_ci * This is an Empirical value that works, need to confirm the actual 1198c2ecf20Sopenharmony_ci * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status 1208c2ecf20Sopenharmony_ci * to be correctly reflected in the PIPE3PHY_PLL_STATUS register. 1218c2ecf20Sopenharmony_ci */ 1228c2ecf20Sopenharmony_ci#define PLL_IDLE_TIME 100 /* in milliseconds */ 1238c2ecf20Sopenharmony_ci#define PLL_LOCK_TIME 100 /* in milliseconds */ 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cienum pipe3_mode { PIPE3_MODE_PCIE = 1, 1268c2ecf20Sopenharmony_ci PIPE3_MODE_SATA, 1278c2ecf20Sopenharmony_ci PIPE3_MODE_USBSS }; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistruct pipe3_dpll_params { 1308c2ecf20Sopenharmony_ci u16 m; 1318c2ecf20Sopenharmony_ci u8 n; 1328c2ecf20Sopenharmony_ci u8 freq:3; 1338c2ecf20Sopenharmony_ci u8 sd; 1348c2ecf20Sopenharmony_ci u32 mf; 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistruct pipe3_dpll_map { 1388c2ecf20Sopenharmony_ci unsigned long rate; 1398c2ecf20Sopenharmony_ci struct pipe3_dpll_params params; 1408c2ecf20Sopenharmony_ci}; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct pipe3_settings { 1438c2ecf20Sopenharmony_ci u8 ana_interface; 1448c2ecf20Sopenharmony_ci u8 ana_losd; 1458c2ecf20Sopenharmony_ci u8 dig_fastlock; 1468c2ecf20Sopenharmony_ci u8 dig_lbw; 1478c2ecf20Sopenharmony_ci u8 dig_stepcnt; 1488c2ecf20Sopenharmony_ci u8 dig_stl; 1498c2ecf20Sopenharmony_ci u8 dig_thr; 1508c2ecf20Sopenharmony_ci u8 dig_thr_mode; 1518c2ecf20Sopenharmony_ci u8 dig_2ndo_sdm_mode; 1528c2ecf20Sopenharmony_ci u8 dig_hs_rate; 1538c2ecf20Sopenharmony_ci u8 dig_ovrd_hs_rate; 1548c2ecf20Sopenharmony_ci u8 dll_trim_sel; 1558c2ecf20Sopenharmony_ci u8 dll_phint_rate; 1568c2ecf20Sopenharmony_ci u8 eq_lev; 1578c2ecf20Sopenharmony_ci u8 eq_ftc; 1588c2ecf20Sopenharmony_ci u8 eq_ctl; 1598c2ecf20Sopenharmony_ci u8 eq_ovrd_lev; 1608c2ecf20Sopenharmony_ci u8 eq_ovrd_ftc; 1618c2ecf20Sopenharmony_ci}; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_cistruct ti_pipe3 { 1648c2ecf20Sopenharmony_ci void __iomem *pll_ctrl_base; 1658c2ecf20Sopenharmony_ci void __iomem *phy_rx; 1668c2ecf20Sopenharmony_ci void __iomem *phy_tx; 1678c2ecf20Sopenharmony_ci struct device *dev; 1688c2ecf20Sopenharmony_ci struct device *control_dev; 1698c2ecf20Sopenharmony_ci struct clk *wkupclk; 1708c2ecf20Sopenharmony_ci struct clk *sys_clk; 1718c2ecf20Sopenharmony_ci struct clk *refclk; 1728c2ecf20Sopenharmony_ci struct clk *div_clk; 1738c2ecf20Sopenharmony_ci struct pipe3_dpll_map *dpll_map; 1748c2ecf20Sopenharmony_ci struct regmap *phy_power_syscon; /* ctrl. reg. acces */ 1758c2ecf20Sopenharmony_ci struct regmap *pcs_syscon; /* ctrl. reg. acces */ 1768c2ecf20Sopenharmony_ci struct regmap *dpll_reset_syscon; /* ctrl. reg. acces */ 1778c2ecf20Sopenharmony_ci unsigned int dpll_reset_reg; /* reg. index within syscon */ 1788c2ecf20Sopenharmony_ci unsigned int power_reg; /* power reg. index within syscon */ 1798c2ecf20Sopenharmony_ci unsigned int pcie_pcs_reg; /* pcs reg. index in syscon */ 1808c2ecf20Sopenharmony_ci bool sata_refclk_enabled; 1818c2ecf20Sopenharmony_ci enum pipe3_mode mode; 1828c2ecf20Sopenharmony_ci struct pipe3_settings settings; 1838c2ecf20Sopenharmony_ci}; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_cistatic struct pipe3_dpll_map dpll_map_usb[] = { 1868c2ecf20Sopenharmony_ci {12000000, {1250, 5, 4, 20, 0} }, /* 12 MHz */ 1878c2ecf20Sopenharmony_ci {16800000, {3125, 20, 4, 20, 0} }, /* 16.8 MHz */ 1888c2ecf20Sopenharmony_ci {19200000, {1172, 8, 4, 20, 65537} }, /* 19.2 MHz */ 1898c2ecf20Sopenharmony_ci {20000000, {1000, 7, 4, 10, 0} }, /* 20 MHz */ 1908c2ecf20Sopenharmony_ci {26000000, {1250, 12, 4, 20, 0} }, /* 26 MHz */ 1918c2ecf20Sopenharmony_ci {38400000, {3125, 47, 4, 20, 92843} }, /* 38.4 MHz */ 1928c2ecf20Sopenharmony_ci { }, /* Terminator */ 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_cistatic struct pipe3_dpll_map dpll_map_sata[] = { 1968c2ecf20Sopenharmony_ci {12000000, {625, 4, 4, 6, 0} }, /* 12 MHz */ 1978c2ecf20Sopenharmony_ci {16800000, {625, 6, 4, 7, 0} }, /* 16.8 MHz */ 1988c2ecf20Sopenharmony_ci {19200000, {625, 7, 4, 6, 0} }, /* 19.2 MHz */ 1998c2ecf20Sopenharmony_ci {20000000, {750, 9, 4, 6, 0} }, /* 20 MHz */ 2008c2ecf20Sopenharmony_ci {26000000, {750, 12, 4, 6, 0} }, /* 26 MHz */ 2018c2ecf20Sopenharmony_ci {38400000, {625, 15, 4, 6, 0} }, /* 38.4 MHz */ 2028c2ecf20Sopenharmony_ci { }, /* Terminator */ 2038c2ecf20Sopenharmony_ci}; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_cistruct pipe3_data { 2068c2ecf20Sopenharmony_ci enum pipe3_mode mode; 2078c2ecf20Sopenharmony_ci struct pipe3_dpll_map *dpll_map; 2088c2ecf20Sopenharmony_ci struct pipe3_settings settings; 2098c2ecf20Sopenharmony_ci}; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_cistatic struct pipe3_data data_usb = { 2128c2ecf20Sopenharmony_ci .mode = PIPE3_MODE_USBSS, 2138c2ecf20Sopenharmony_ci .dpll_map = dpll_map_usb, 2148c2ecf20Sopenharmony_ci .settings = { 2158c2ecf20Sopenharmony_ci /* DRA75x TRM Table 26-17 Preferred USB3_PHY_RX SCP Register Settings */ 2168c2ecf20Sopenharmony_ci .ana_interface = INTERFACE_MODE_USBSS, 2178c2ecf20Sopenharmony_ci .ana_losd = 0xa, 2188c2ecf20Sopenharmony_ci .dig_fastlock = 1, 2198c2ecf20Sopenharmony_ci .dig_lbw = 3, 2208c2ecf20Sopenharmony_ci .dig_stepcnt = 0, 2218c2ecf20Sopenharmony_ci .dig_stl = 0x3, 2228c2ecf20Sopenharmony_ci .dig_thr = 1, 2238c2ecf20Sopenharmony_ci .dig_thr_mode = 1, 2248c2ecf20Sopenharmony_ci .dig_2ndo_sdm_mode = 0, 2258c2ecf20Sopenharmony_ci .dig_hs_rate = 0, 2268c2ecf20Sopenharmony_ci .dig_ovrd_hs_rate = 1, 2278c2ecf20Sopenharmony_ci .dll_trim_sel = 0x2, 2288c2ecf20Sopenharmony_ci .dll_phint_rate = 0x3, 2298c2ecf20Sopenharmony_ci .eq_lev = 0, 2308c2ecf20Sopenharmony_ci .eq_ftc = 0, 2318c2ecf20Sopenharmony_ci .eq_ctl = 0x9, 2328c2ecf20Sopenharmony_ci .eq_ovrd_lev = 0, 2338c2ecf20Sopenharmony_ci .eq_ovrd_ftc = 0, 2348c2ecf20Sopenharmony_ci }, 2358c2ecf20Sopenharmony_ci}; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_cistatic struct pipe3_data data_sata = { 2388c2ecf20Sopenharmony_ci .mode = PIPE3_MODE_SATA, 2398c2ecf20Sopenharmony_ci .dpll_map = dpll_map_sata, 2408c2ecf20Sopenharmony_ci .settings = { 2418c2ecf20Sopenharmony_ci /* DRA75x TRM Table 26-9 Preferred SATA_PHY_RX SCP Register Settings */ 2428c2ecf20Sopenharmony_ci .ana_interface = INTERFACE_MODE_SATA_3P0, 2438c2ecf20Sopenharmony_ci .ana_losd = 0x5, 2448c2ecf20Sopenharmony_ci .dig_fastlock = 1, 2458c2ecf20Sopenharmony_ci .dig_lbw = 3, 2468c2ecf20Sopenharmony_ci .dig_stepcnt = 0, 2478c2ecf20Sopenharmony_ci .dig_stl = 0x3, 2488c2ecf20Sopenharmony_ci .dig_thr = 1, 2498c2ecf20Sopenharmony_ci .dig_thr_mode = 1, 2508c2ecf20Sopenharmony_ci .dig_2ndo_sdm_mode = 0, 2518c2ecf20Sopenharmony_ci .dig_hs_rate = 0, /* Not in TRM preferred settings */ 2528c2ecf20Sopenharmony_ci .dig_ovrd_hs_rate = 0, /* Not in TRM preferred settings */ 2538c2ecf20Sopenharmony_ci .dll_trim_sel = 0x1, 2548c2ecf20Sopenharmony_ci .dll_phint_rate = 0x2, /* for 1.5 GHz DPLL clock */ 2558c2ecf20Sopenharmony_ci .eq_lev = 0, 2568c2ecf20Sopenharmony_ci .eq_ftc = 0x1f, 2578c2ecf20Sopenharmony_ci .eq_ctl = 0, 2588c2ecf20Sopenharmony_ci .eq_ovrd_lev = 1, 2598c2ecf20Sopenharmony_ci .eq_ovrd_ftc = 1, 2608c2ecf20Sopenharmony_ci }, 2618c2ecf20Sopenharmony_ci}; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_cistatic struct pipe3_data data_pcie = { 2648c2ecf20Sopenharmony_ci .mode = PIPE3_MODE_PCIE, 2658c2ecf20Sopenharmony_ci .settings = { 2668c2ecf20Sopenharmony_ci /* DRA75x TRM Table 26-62 Preferred PCIe_PHY_RX SCP Register Settings */ 2678c2ecf20Sopenharmony_ci .ana_interface = INTERFACE_MODE_PCIE, 2688c2ecf20Sopenharmony_ci .ana_losd = 0xa, 2698c2ecf20Sopenharmony_ci .dig_fastlock = 1, 2708c2ecf20Sopenharmony_ci .dig_lbw = 3, 2718c2ecf20Sopenharmony_ci .dig_stepcnt = 0, 2728c2ecf20Sopenharmony_ci .dig_stl = 0x3, 2738c2ecf20Sopenharmony_ci .dig_thr = 1, 2748c2ecf20Sopenharmony_ci .dig_thr_mode = 1, 2758c2ecf20Sopenharmony_ci .dig_2ndo_sdm_mode = 0, 2768c2ecf20Sopenharmony_ci .dig_hs_rate = 0, 2778c2ecf20Sopenharmony_ci .dig_ovrd_hs_rate = 0, 2788c2ecf20Sopenharmony_ci .dll_trim_sel = 0x2, 2798c2ecf20Sopenharmony_ci .dll_phint_rate = 0x3, 2808c2ecf20Sopenharmony_ci .eq_lev = 0, 2818c2ecf20Sopenharmony_ci .eq_ftc = 0x1f, 2828c2ecf20Sopenharmony_ci .eq_ctl = 1, 2838c2ecf20Sopenharmony_ci .eq_ovrd_lev = 0, 2848c2ecf20Sopenharmony_ci .eq_ovrd_ftc = 0, 2858c2ecf20Sopenharmony_ci }, 2868c2ecf20Sopenharmony_ci}; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_cistatic inline u32 ti_pipe3_readl(void __iomem *addr, unsigned offset) 2898c2ecf20Sopenharmony_ci{ 2908c2ecf20Sopenharmony_ci return __raw_readl(addr + offset); 2918c2ecf20Sopenharmony_ci} 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_cistatic inline void ti_pipe3_writel(void __iomem *addr, unsigned offset, 2948c2ecf20Sopenharmony_ci u32 data) 2958c2ecf20Sopenharmony_ci{ 2968c2ecf20Sopenharmony_ci __raw_writel(data, addr + offset); 2978c2ecf20Sopenharmony_ci} 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_cistatic struct pipe3_dpll_params *ti_pipe3_get_dpll_params(struct ti_pipe3 *phy) 3008c2ecf20Sopenharmony_ci{ 3018c2ecf20Sopenharmony_ci unsigned long rate; 3028c2ecf20Sopenharmony_ci struct pipe3_dpll_map *dpll_map = phy->dpll_map; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci rate = clk_get_rate(phy->sys_clk); 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci for (; dpll_map->rate; dpll_map++) { 3078c2ecf20Sopenharmony_ci if (rate == dpll_map->rate) 3088c2ecf20Sopenharmony_ci return &dpll_map->params; 3098c2ecf20Sopenharmony_ci } 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci dev_err(phy->dev, "No DPLL configuration for %lu Hz SYS CLK\n", rate); 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci return NULL; 3148c2ecf20Sopenharmony_ci} 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_cistatic int ti_pipe3_enable_clocks(struct ti_pipe3 *phy); 3178c2ecf20Sopenharmony_cistatic void ti_pipe3_disable_clocks(struct ti_pipe3 *phy); 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistatic int ti_pipe3_power_off(struct phy *x) 3208c2ecf20Sopenharmony_ci{ 3218c2ecf20Sopenharmony_ci int ret; 3228c2ecf20Sopenharmony_ci struct ti_pipe3 *phy = phy_get_drvdata(x); 3238c2ecf20Sopenharmony_ci 3248c2ecf20Sopenharmony_ci if (!phy->phy_power_syscon) { 3258c2ecf20Sopenharmony_ci omap_control_phy_power(phy->control_dev, 0); 3268c2ecf20Sopenharmony_ci return 0; 3278c2ecf20Sopenharmony_ci } 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg, 3308c2ecf20Sopenharmony_ci PIPE3_PHY_PWRCTL_CLK_CMD_MASK, 0); 3318c2ecf20Sopenharmony_ci return ret; 3328c2ecf20Sopenharmony_ci} 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_cistatic void ti_pipe3_calibrate(struct ti_pipe3 *phy); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_cistatic int ti_pipe3_power_on(struct phy *x) 3378c2ecf20Sopenharmony_ci{ 3388c2ecf20Sopenharmony_ci u32 val; 3398c2ecf20Sopenharmony_ci u32 mask; 3408c2ecf20Sopenharmony_ci unsigned long rate; 3418c2ecf20Sopenharmony_ci struct ti_pipe3 *phy = phy_get_drvdata(x); 3428c2ecf20Sopenharmony_ci bool rx_pending = false; 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci if (!phy->phy_power_syscon) { 3458c2ecf20Sopenharmony_ci omap_control_phy_power(phy->control_dev, 1); 3468c2ecf20Sopenharmony_ci return 0; 3478c2ecf20Sopenharmony_ci } 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci rate = clk_get_rate(phy->sys_clk); 3508c2ecf20Sopenharmony_ci if (!rate) { 3518c2ecf20Sopenharmony_ci dev_err(phy->dev, "Invalid clock rate\n"); 3528c2ecf20Sopenharmony_ci return -EINVAL; 3538c2ecf20Sopenharmony_ci } 3548c2ecf20Sopenharmony_ci rate = rate / 1000000; 3558c2ecf20Sopenharmony_ci mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK; 3568c2ecf20Sopenharmony_ci val = rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT; 3578c2ecf20Sopenharmony_ci regmap_update_bits(phy->phy_power_syscon, phy->power_reg, 3588c2ecf20Sopenharmony_ci mask, val); 3598c2ecf20Sopenharmony_ci /* 3608c2ecf20Sopenharmony_ci * For PCIe, TX and RX must be powered on simultaneously. 3618c2ecf20Sopenharmony_ci * For USB and SATA, TX must be powered on before RX 3628c2ecf20Sopenharmony_ci */ 3638c2ecf20Sopenharmony_ci mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK; 3648c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA || phy->mode == PIPE3_MODE_USBSS) { 3658c2ecf20Sopenharmony_ci val = PIPE3_PHY_TX_POWERON; 3668c2ecf20Sopenharmony_ci rx_pending = true; 3678c2ecf20Sopenharmony_ci } else { 3688c2ecf20Sopenharmony_ci val = PIPE3_PHY_TX_POWERON | PIPE3_PHY_RX_POWERON; 3698c2ecf20Sopenharmony_ci } 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci regmap_update_bits(phy->phy_power_syscon, phy->power_reg, 3728c2ecf20Sopenharmony_ci mask, val); 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci if (rx_pending) { 3758c2ecf20Sopenharmony_ci val = PIPE3_PHY_TX_POWERON | PIPE3_PHY_RX_POWERON; 3768c2ecf20Sopenharmony_ci regmap_update_bits(phy->phy_power_syscon, phy->power_reg, 3778c2ecf20Sopenharmony_ci mask, val); 3788c2ecf20Sopenharmony_ci } 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_PCIE) 3818c2ecf20Sopenharmony_ci ti_pipe3_calibrate(phy); 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci return 0; 3848c2ecf20Sopenharmony_ci} 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_cistatic int ti_pipe3_dpll_wait_lock(struct ti_pipe3 *phy) 3878c2ecf20Sopenharmony_ci{ 3888c2ecf20Sopenharmony_ci u32 val; 3898c2ecf20Sopenharmony_ci unsigned long timeout; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci timeout = jiffies + msecs_to_jiffies(PLL_LOCK_TIME); 3928c2ecf20Sopenharmony_ci do { 3938c2ecf20Sopenharmony_ci cpu_relax(); 3948c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS); 3958c2ecf20Sopenharmony_ci if (val & PLL_LOCK) 3968c2ecf20Sopenharmony_ci return 0; 3978c2ecf20Sopenharmony_ci } while (!time_after(jiffies, timeout)); 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci dev_err(phy->dev, "DPLL failed to lock\n"); 4008c2ecf20Sopenharmony_ci return -EBUSY; 4018c2ecf20Sopenharmony_ci} 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_cistatic int ti_pipe3_dpll_program(struct ti_pipe3 *phy) 4048c2ecf20Sopenharmony_ci{ 4058c2ecf20Sopenharmony_ci u32 val; 4068c2ecf20Sopenharmony_ci struct pipe3_dpll_params *dpll_params; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci dpll_params = ti_pipe3_get_dpll_params(phy); 4098c2ecf20Sopenharmony_ci if (!dpll_params) 4108c2ecf20Sopenharmony_ci return -EINVAL; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION1); 4138c2ecf20Sopenharmony_ci val &= ~PLL_REGN_MASK; 4148c2ecf20Sopenharmony_ci val |= dpll_params->n << PLL_REGN_SHIFT; 4158c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION1, val); 4168c2ecf20Sopenharmony_ci 4178c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2); 4188c2ecf20Sopenharmony_ci val &= ~PLL_SELFREQDCO_MASK; 4198c2ecf20Sopenharmony_ci val |= dpll_params->freq << PLL_SELFREQDCO_SHIFT; 4208c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val); 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION1); 4238c2ecf20Sopenharmony_ci val &= ~PLL_REGM_MASK; 4248c2ecf20Sopenharmony_ci val |= dpll_params->m << PLL_REGM_SHIFT; 4258c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION1, val); 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION4); 4288c2ecf20Sopenharmony_ci val &= ~PLL_REGM_F_MASK; 4298c2ecf20Sopenharmony_ci val |= dpll_params->mf << PLL_REGM_F_SHIFT; 4308c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION4, val); 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION3); 4338c2ecf20Sopenharmony_ci val &= ~PLL_SD_MASK; 4348c2ecf20Sopenharmony_ci val |= dpll_params->sd << PLL_SD_SHIFT; 4358c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION3, val); 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_GO, SET_PLL_GO); 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci return ti_pipe3_dpll_wait_lock(phy); 4408c2ecf20Sopenharmony_ci} 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_cistatic void ti_pipe3_calibrate(struct ti_pipe3 *phy) 4438c2ecf20Sopenharmony_ci{ 4448c2ecf20Sopenharmony_ci u32 val; 4458c2ecf20Sopenharmony_ci struct pipe3_settings *s = &phy->settings; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_ANA_PROGRAMMABILITY); 4488c2ecf20Sopenharmony_ci val &= ~(INTERFACE_MASK | LOSD_MASK | MEM_PLLDIV); 4498c2ecf20Sopenharmony_ci val |= (s->ana_interface << INTERFACE_SHIFT | s->ana_losd << LOSD_SHIFT); 4508c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_ANA_PROGRAMMABILITY, val); 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_DIGITAL_MODES); 4538c2ecf20Sopenharmony_ci val &= ~(MEM_HS_RATE_MASK | MEM_OVRD_HS_RATE | MEM_CDR_FASTLOCK | 4548c2ecf20Sopenharmony_ci MEM_CDR_LBW_MASK | MEM_CDR_STEPCNT_MASK | MEM_CDR_STL_MASK | 4558c2ecf20Sopenharmony_ci MEM_CDR_THR_MASK | MEM_CDR_THR_MODE | MEM_CDR_2NDO_SDM_MODE); 4568c2ecf20Sopenharmony_ci val |= s->dig_hs_rate << MEM_HS_RATE_SHIFT | 4578c2ecf20Sopenharmony_ci s->dig_ovrd_hs_rate << MEM_OVRD_HS_RATE_SHIFT | 4588c2ecf20Sopenharmony_ci s->dig_fastlock << MEM_CDR_FASTLOCK_SHIFT | 4598c2ecf20Sopenharmony_ci s->dig_lbw << MEM_CDR_LBW_SHIFT | 4608c2ecf20Sopenharmony_ci s->dig_stepcnt << MEM_CDR_STEPCNT_SHIFT | 4618c2ecf20Sopenharmony_ci s->dig_stl << MEM_CDR_STL_SHIFT | 4628c2ecf20Sopenharmony_ci s->dig_thr << MEM_CDR_THR_SHIFT | 4638c2ecf20Sopenharmony_ci s->dig_thr_mode << MEM_CDR_THR_MODE_SHIFT | 4648c2ecf20Sopenharmony_ci s->dig_2ndo_sdm_mode << MEM_CDR_2NDO_SDM_MODE_SHIFT; 4658c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_DIGITAL_MODES, val); 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_TRIM); 4688c2ecf20Sopenharmony_ci val &= ~MEM_DLL_TRIM_SEL_MASK; 4698c2ecf20Sopenharmony_ci val |= s->dll_trim_sel << MEM_DLL_TRIM_SHIFT; 4708c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_TRIM, val); 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_DLL); 4738c2ecf20Sopenharmony_ci val &= ~MEM_DLL_PHINT_RATE_MASK; 4748c2ecf20Sopenharmony_ci val |= s->dll_phint_rate << MEM_DLL_PHINT_RATE_SHIFT; 4758c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_DLL, val); 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_EQUALIZER); 4788c2ecf20Sopenharmony_ci val &= ~(MEM_EQLEV_MASK | MEM_EQFTC_MASK | MEM_EQCTL_MASK | 4798c2ecf20Sopenharmony_ci MEM_OVRD_EQLEV | MEM_OVRD_EQFTC); 4808c2ecf20Sopenharmony_ci val |= s->eq_lev << MEM_EQLEV_SHIFT | 4818c2ecf20Sopenharmony_ci s->eq_ftc << MEM_EQFTC_SHIFT | 4828c2ecf20Sopenharmony_ci s->eq_ctl << MEM_EQCTL_SHIFT | 4838c2ecf20Sopenharmony_ci s->eq_ovrd_lev << MEM_OVRD_EQLEV_SHIFT | 4848c2ecf20Sopenharmony_ci s->eq_ovrd_ftc << MEM_OVRD_EQFTC_SHIFT; 4858c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_EQUALIZER, val); 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA) { 4888c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->phy_rx, 4898c2ecf20Sopenharmony_ci SATA_PHY_RX_IO_AND_A2D_OVERRIDES); 4908c2ecf20Sopenharmony_ci val &= ~MEM_CDR_LOS_SOURCE_MASK; 4918c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->phy_rx, SATA_PHY_RX_IO_AND_A2D_OVERRIDES, 4928c2ecf20Sopenharmony_ci val); 4938c2ecf20Sopenharmony_ci } 4948c2ecf20Sopenharmony_ci} 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_cistatic int ti_pipe3_init(struct phy *x) 4978c2ecf20Sopenharmony_ci{ 4988c2ecf20Sopenharmony_ci struct ti_pipe3 *phy = phy_get_drvdata(x); 4998c2ecf20Sopenharmony_ci u32 val; 5008c2ecf20Sopenharmony_ci int ret = 0; 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci ti_pipe3_enable_clocks(phy); 5038c2ecf20Sopenharmony_ci /* 5048c2ecf20Sopenharmony_ci * Set pcie_pcs register to 0x96 for proper functioning of phy 5058c2ecf20Sopenharmony_ci * as recommended in AM572x TRM SPRUHZ6, section 18.5.2.2, table 5068c2ecf20Sopenharmony_ci * 18-1804. 5078c2ecf20Sopenharmony_ci */ 5088c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_PCIE) { 5098c2ecf20Sopenharmony_ci if (!phy->pcs_syscon) { 5108c2ecf20Sopenharmony_ci omap_control_pcie_pcs(phy->control_dev, 0x96); 5118c2ecf20Sopenharmony_ci return 0; 5128c2ecf20Sopenharmony_ci } 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT; 5158c2ecf20Sopenharmony_ci ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg, 5168c2ecf20Sopenharmony_ci PCIE_PCS_MASK, val); 5178c2ecf20Sopenharmony_ci return ret; 5188c2ecf20Sopenharmony_ci } 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci /* Bring it out of IDLE if it is IDLE */ 5218c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2); 5228c2ecf20Sopenharmony_ci if (val & PLL_IDLE) { 5238c2ecf20Sopenharmony_ci val &= ~PLL_IDLE; 5248c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val); 5258c2ecf20Sopenharmony_ci ret = ti_pipe3_dpll_wait_lock(phy); 5268c2ecf20Sopenharmony_ci } 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci /* SATA has issues if re-programmed when locked */ 5298c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS); 5308c2ecf20Sopenharmony_ci if ((val & PLL_LOCK) && phy->mode == PIPE3_MODE_SATA) 5318c2ecf20Sopenharmony_ci return ret; 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci /* Program the DPLL */ 5348c2ecf20Sopenharmony_ci ret = ti_pipe3_dpll_program(phy); 5358c2ecf20Sopenharmony_ci if (ret) { 5368c2ecf20Sopenharmony_ci ti_pipe3_disable_clocks(phy); 5378c2ecf20Sopenharmony_ci return -EINVAL; 5388c2ecf20Sopenharmony_ci } 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci ti_pipe3_calibrate(phy); 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_ci return ret; 5438c2ecf20Sopenharmony_ci} 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_cistatic int ti_pipe3_exit(struct phy *x) 5468c2ecf20Sopenharmony_ci{ 5478c2ecf20Sopenharmony_ci struct ti_pipe3 *phy = phy_get_drvdata(x); 5488c2ecf20Sopenharmony_ci u32 val; 5498c2ecf20Sopenharmony_ci unsigned long timeout; 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci /* If dpll_reset_syscon is not present we wont power down SATA DPLL 5528c2ecf20Sopenharmony_ci * due to Errata i783 5538c2ecf20Sopenharmony_ci */ 5548c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA && !phy->dpll_reset_syscon) 5558c2ecf20Sopenharmony_ci return 0; 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci /* PCIe doesn't have internal DPLL */ 5588c2ecf20Sopenharmony_ci if (phy->mode != PIPE3_MODE_PCIE) { 5598c2ecf20Sopenharmony_ci /* Put DPLL in IDLE mode */ 5608c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2); 5618c2ecf20Sopenharmony_ci val |= PLL_IDLE; 5628c2ecf20Sopenharmony_ci ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val); 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci /* wait for LDO and Oscillator to power down */ 5658c2ecf20Sopenharmony_ci timeout = jiffies + msecs_to_jiffies(PLL_IDLE_TIME); 5668c2ecf20Sopenharmony_ci do { 5678c2ecf20Sopenharmony_ci cpu_relax(); 5688c2ecf20Sopenharmony_ci val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS); 5698c2ecf20Sopenharmony_ci if ((val & PLL_TICOPWDN) && (val & PLL_LDOPWDN)) 5708c2ecf20Sopenharmony_ci break; 5718c2ecf20Sopenharmony_ci } while (!time_after(jiffies, timeout)); 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci if (!(val & PLL_TICOPWDN) || !(val & PLL_LDOPWDN)) { 5748c2ecf20Sopenharmony_ci dev_err(phy->dev, "Failed to power down: PLL_STATUS 0x%x\n", 5758c2ecf20Sopenharmony_ci val); 5768c2ecf20Sopenharmony_ci return -EBUSY; 5778c2ecf20Sopenharmony_ci } 5788c2ecf20Sopenharmony_ci } 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci /* i783: SATA needs control bit toggle after PLL unlock */ 5818c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA) { 5828c2ecf20Sopenharmony_ci regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg, 5838c2ecf20Sopenharmony_ci SATA_PLL_SOFT_RESET, SATA_PLL_SOFT_RESET); 5848c2ecf20Sopenharmony_ci regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg, 5858c2ecf20Sopenharmony_ci SATA_PLL_SOFT_RESET, 0); 5868c2ecf20Sopenharmony_ci } 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci ti_pipe3_disable_clocks(phy); 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci return 0; 5918c2ecf20Sopenharmony_ci} 5928c2ecf20Sopenharmony_cistatic const struct phy_ops ops = { 5938c2ecf20Sopenharmony_ci .init = ti_pipe3_init, 5948c2ecf20Sopenharmony_ci .exit = ti_pipe3_exit, 5958c2ecf20Sopenharmony_ci .power_on = ti_pipe3_power_on, 5968c2ecf20Sopenharmony_ci .power_off = ti_pipe3_power_off, 5978c2ecf20Sopenharmony_ci .owner = THIS_MODULE, 5988c2ecf20Sopenharmony_ci}; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_cistatic const struct of_device_id ti_pipe3_id_table[]; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_cistatic int ti_pipe3_get_clk(struct ti_pipe3 *phy) 6038c2ecf20Sopenharmony_ci{ 6048c2ecf20Sopenharmony_ci struct clk *clk; 6058c2ecf20Sopenharmony_ci struct device *dev = phy->dev; 6068c2ecf20Sopenharmony_ci 6078c2ecf20Sopenharmony_ci phy->refclk = devm_clk_get(dev, "refclk"); 6088c2ecf20Sopenharmony_ci if (IS_ERR(phy->refclk)) { 6098c2ecf20Sopenharmony_ci dev_err(dev, "unable to get refclk\n"); 6108c2ecf20Sopenharmony_ci /* older DTBs have missing refclk in SATA PHY 6118c2ecf20Sopenharmony_ci * so don't bail out in case of SATA PHY. 6128c2ecf20Sopenharmony_ci */ 6138c2ecf20Sopenharmony_ci if (phy->mode != PIPE3_MODE_SATA) 6148c2ecf20Sopenharmony_ci return PTR_ERR(phy->refclk); 6158c2ecf20Sopenharmony_ci } 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci if (phy->mode != PIPE3_MODE_SATA) { 6188c2ecf20Sopenharmony_ci phy->wkupclk = devm_clk_get(dev, "wkupclk"); 6198c2ecf20Sopenharmony_ci if (IS_ERR(phy->wkupclk)) { 6208c2ecf20Sopenharmony_ci dev_err(dev, "unable to get wkupclk\n"); 6218c2ecf20Sopenharmony_ci return PTR_ERR(phy->wkupclk); 6228c2ecf20Sopenharmony_ci } 6238c2ecf20Sopenharmony_ci } else { 6248c2ecf20Sopenharmony_ci phy->wkupclk = ERR_PTR(-ENODEV); 6258c2ecf20Sopenharmony_ci } 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci if (phy->mode != PIPE3_MODE_PCIE || phy->phy_power_syscon) { 6288c2ecf20Sopenharmony_ci phy->sys_clk = devm_clk_get(dev, "sysclk"); 6298c2ecf20Sopenharmony_ci if (IS_ERR(phy->sys_clk)) { 6308c2ecf20Sopenharmony_ci dev_err(dev, "unable to get sysclk\n"); 6318c2ecf20Sopenharmony_ci return -EINVAL; 6328c2ecf20Sopenharmony_ci } 6338c2ecf20Sopenharmony_ci } 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_PCIE) { 6368c2ecf20Sopenharmony_ci clk = devm_clk_get(dev, "dpll_ref"); 6378c2ecf20Sopenharmony_ci if (IS_ERR(clk)) { 6388c2ecf20Sopenharmony_ci dev_err(dev, "unable to get dpll ref clk\n"); 6398c2ecf20Sopenharmony_ci return PTR_ERR(clk); 6408c2ecf20Sopenharmony_ci } 6418c2ecf20Sopenharmony_ci clk_set_rate(clk, 1500000000); 6428c2ecf20Sopenharmony_ci 6438c2ecf20Sopenharmony_ci clk = devm_clk_get(dev, "dpll_ref_m2"); 6448c2ecf20Sopenharmony_ci if (IS_ERR(clk)) { 6458c2ecf20Sopenharmony_ci dev_err(dev, "unable to get dpll ref m2 clk\n"); 6468c2ecf20Sopenharmony_ci return PTR_ERR(clk); 6478c2ecf20Sopenharmony_ci } 6488c2ecf20Sopenharmony_ci clk_set_rate(clk, 100000000); 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ci clk = devm_clk_get(dev, "phy-div"); 6518c2ecf20Sopenharmony_ci if (IS_ERR(clk)) { 6528c2ecf20Sopenharmony_ci dev_err(dev, "unable to get phy-div clk\n"); 6538c2ecf20Sopenharmony_ci return PTR_ERR(clk); 6548c2ecf20Sopenharmony_ci } 6558c2ecf20Sopenharmony_ci clk_set_rate(clk, 100000000); 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_ci phy->div_clk = devm_clk_get(dev, "div-clk"); 6588c2ecf20Sopenharmony_ci if (IS_ERR(phy->div_clk)) { 6598c2ecf20Sopenharmony_ci dev_err(dev, "unable to get div-clk\n"); 6608c2ecf20Sopenharmony_ci return PTR_ERR(phy->div_clk); 6618c2ecf20Sopenharmony_ci } 6628c2ecf20Sopenharmony_ci } else { 6638c2ecf20Sopenharmony_ci phy->div_clk = ERR_PTR(-ENODEV); 6648c2ecf20Sopenharmony_ci } 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_ci return 0; 6678c2ecf20Sopenharmony_ci} 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_cistatic int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy) 6708c2ecf20Sopenharmony_ci{ 6718c2ecf20Sopenharmony_ci struct device *dev = phy->dev; 6728c2ecf20Sopenharmony_ci struct device_node *node = dev->of_node; 6738c2ecf20Sopenharmony_ci struct device_node *control_node; 6748c2ecf20Sopenharmony_ci struct platform_device *control_pdev; 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci phy->phy_power_syscon = syscon_regmap_lookup_by_phandle(node, 6778c2ecf20Sopenharmony_ci "syscon-phy-power"); 6788c2ecf20Sopenharmony_ci if (IS_ERR(phy->phy_power_syscon)) { 6798c2ecf20Sopenharmony_ci dev_dbg(dev, 6808c2ecf20Sopenharmony_ci "can't get syscon-phy-power, using control device\n"); 6818c2ecf20Sopenharmony_ci phy->phy_power_syscon = NULL; 6828c2ecf20Sopenharmony_ci } else { 6838c2ecf20Sopenharmony_ci if (of_property_read_u32_index(node, 6848c2ecf20Sopenharmony_ci "syscon-phy-power", 1, 6858c2ecf20Sopenharmony_ci &phy->power_reg)) { 6868c2ecf20Sopenharmony_ci dev_err(dev, "couldn't get power reg. offset\n"); 6878c2ecf20Sopenharmony_ci return -EINVAL; 6888c2ecf20Sopenharmony_ci } 6898c2ecf20Sopenharmony_ci } 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci if (!phy->phy_power_syscon) { 6928c2ecf20Sopenharmony_ci control_node = of_parse_phandle(node, "ctrl-module", 0); 6938c2ecf20Sopenharmony_ci if (!control_node) { 6948c2ecf20Sopenharmony_ci dev_err(dev, "Failed to get control device phandle\n"); 6958c2ecf20Sopenharmony_ci return -EINVAL; 6968c2ecf20Sopenharmony_ci } 6978c2ecf20Sopenharmony_ci 6988c2ecf20Sopenharmony_ci control_pdev = of_find_device_by_node(control_node); 6998c2ecf20Sopenharmony_ci if (!control_pdev) { 7008c2ecf20Sopenharmony_ci dev_err(dev, "Failed to get control device\n"); 7018c2ecf20Sopenharmony_ci return -EINVAL; 7028c2ecf20Sopenharmony_ci } 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci phy->control_dev = &control_pdev->dev; 7058c2ecf20Sopenharmony_ci } 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_PCIE) { 7088c2ecf20Sopenharmony_ci phy->pcs_syscon = syscon_regmap_lookup_by_phandle(node, 7098c2ecf20Sopenharmony_ci "syscon-pcs"); 7108c2ecf20Sopenharmony_ci if (IS_ERR(phy->pcs_syscon)) { 7118c2ecf20Sopenharmony_ci dev_dbg(dev, 7128c2ecf20Sopenharmony_ci "can't get syscon-pcs, using omap control\n"); 7138c2ecf20Sopenharmony_ci phy->pcs_syscon = NULL; 7148c2ecf20Sopenharmony_ci } else { 7158c2ecf20Sopenharmony_ci if (of_property_read_u32_index(node, 7168c2ecf20Sopenharmony_ci "syscon-pcs", 1, 7178c2ecf20Sopenharmony_ci &phy->pcie_pcs_reg)) { 7188c2ecf20Sopenharmony_ci dev_err(dev, 7198c2ecf20Sopenharmony_ci "couldn't get pcie pcs reg. offset\n"); 7208c2ecf20Sopenharmony_ci return -EINVAL; 7218c2ecf20Sopenharmony_ci } 7228c2ecf20Sopenharmony_ci } 7238c2ecf20Sopenharmony_ci } 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA) { 7268c2ecf20Sopenharmony_ci phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node, 7278c2ecf20Sopenharmony_ci "syscon-pllreset"); 7288c2ecf20Sopenharmony_ci if (IS_ERR(phy->dpll_reset_syscon)) { 7298c2ecf20Sopenharmony_ci dev_info(dev, 7308c2ecf20Sopenharmony_ci "can't get syscon-pllreset, sata dpll won't idle\n"); 7318c2ecf20Sopenharmony_ci phy->dpll_reset_syscon = NULL; 7328c2ecf20Sopenharmony_ci } else { 7338c2ecf20Sopenharmony_ci if (of_property_read_u32_index(node, 7348c2ecf20Sopenharmony_ci "syscon-pllreset", 1, 7358c2ecf20Sopenharmony_ci &phy->dpll_reset_reg)) { 7368c2ecf20Sopenharmony_ci dev_err(dev, 7378c2ecf20Sopenharmony_ci "couldn't get pllreset reg. offset\n"); 7388c2ecf20Sopenharmony_ci return -EINVAL; 7398c2ecf20Sopenharmony_ci } 7408c2ecf20Sopenharmony_ci } 7418c2ecf20Sopenharmony_ci } 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci return 0; 7448c2ecf20Sopenharmony_ci} 7458c2ecf20Sopenharmony_ci 7468c2ecf20Sopenharmony_cistatic int ti_pipe3_get_tx_rx_base(struct ti_pipe3 *phy) 7478c2ecf20Sopenharmony_ci{ 7488c2ecf20Sopenharmony_ci struct resource *res; 7498c2ecf20Sopenharmony_ci struct device *dev = phy->dev; 7508c2ecf20Sopenharmony_ci struct platform_device *pdev = to_platform_device(dev); 7518c2ecf20Sopenharmony_ci 7528c2ecf20Sopenharmony_ci res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 7538c2ecf20Sopenharmony_ci "phy_rx"); 7548c2ecf20Sopenharmony_ci phy->phy_rx = devm_ioremap_resource(dev, res); 7558c2ecf20Sopenharmony_ci if (IS_ERR(phy->phy_rx)) 7568c2ecf20Sopenharmony_ci return PTR_ERR(phy->phy_rx); 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 7598c2ecf20Sopenharmony_ci "phy_tx"); 7608c2ecf20Sopenharmony_ci phy->phy_tx = devm_ioremap_resource(dev, res); 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci return PTR_ERR_OR_ZERO(phy->phy_tx); 7638c2ecf20Sopenharmony_ci} 7648c2ecf20Sopenharmony_ci 7658c2ecf20Sopenharmony_cistatic int ti_pipe3_get_pll_base(struct ti_pipe3 *phy) 7668c2ecf20Sopenharmony_ci{ 7678c2ecf20Sopenharmony_ci struct resource *res; 7688c2ecf20Sopenharmony_ci struct device *dev = phy->dev; 7698c2ecf20Sopenharmony_ci struct platform_device *pdev = to_platform_device(dev); 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_PCIE) 7728c2ecf20Sopenharmony_ci return 0; 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 7758c2ecf20Sopenharmony_ci "pll_ctrl"); 7768c2ecf20Sopenharmony_ci phy->pll_ctrl_base = devm_ioremap_resource(dev, res); 7778c2ecf20Sopenharmony_ci return PTR_ERR_OR_ZERO(phy->pll_ctrl_base); 7788c2ecf20Sopenharmony_ci} 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_cistatic int ti_pipe3_probe(struct platform_device *pdev) 7818c2ecf20Sopenharmony_ci{ 7828c2ecf20Sopenharmony_ci struct ti_pipe3 *phy; 7838c2ecf20Sopenharmony_ci struct phy *generic_phy; 7848c2ecf20Sopenharmony_ci struct phy_provider *phy_provider; 7858c2ecf20Sopenharmony_ci struct device *dev = &pdev->dev; 7868c2ecf20Sopenharmony_ci int ret; 7878c2ecf20Sopenharmony_ci const struct of_device_id *match; 7888c2ecf20Sopenharmony_ci struct pipe3_data *data; 7898c2ecf20Sopenharmony_ci 7908c2ecf20Sopenharmony_ci phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); 7918c2ecf20Sopenharmony_ci if (!phy) 7928c2ecf20Sopenharmony_ci return -ENOMEM; 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_ci match = of_match_device(ti_pipe3_id_table, dev); 7958c2ecf20Sopenharmony_ci if (!match) 7968c2ecf20Sopenharmony_ci return -EINVAL; 7978c2ecf20Sopenharmony_ci 7988c2ecf20Sopenharmony_ci data = (struct pipe3_data *)match->data; 7998c2ecf20Sopenharmony_ci if (!data) { 8008c2ecf20Sopenharmony_ci dev_err(dev, "no driver data\n"); 8018c2ecf20Sopenharmony_ci return -EINVAL; 8028c2ecf20Sopenharmony_ci } 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_ci phy->dev = dev; 8058c2ecf20Sopenharmony_ci phy->mode = data->mode; 8068c2ecf20Sopenharmony_ci phy->dpll_map = data->dpll_map; 8078c2ecf20Sopenharmony_ci phy->settings = data->settings; 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_ci ret = ti_pipe3_get_pll_base(phy); 8108c2ecf20Sopenharmony_ci if (ret) 8118c2ecf20Sopenharmony_ci return ret; 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci ret = ti_pipe3_get_tx_rx_base(phy); 8148c2ecf20Sopenharmony_ci if (ret) 8158c2ecf20Sopenharmony_ci return ret; 8168c2ecf20Sopenharmony_ci 8178c2ecf20Sopenharmony_ci ret = ti_pipe3_get_sysctrl(phy); 8188c2ecf20Sopenharmony_ci if (ret) 8198c2ecf20Sopenharmony_ci return ret; 8208c2ecf20Sopenharmony_ci 8218c2ecf20Sopenharmony_ci ret = ti_pipe3_get_clk(phy); 8228c2ecf20Sopenharmony_ci if (ret) 8238c2ecf20Sopenharmony_ci return ret; 8248c2ecf20Sopenharmony_ci 8258c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, phy); 8268c2ecf20Sopenharmony_ci pm_runtime_enable(dev); 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ci /* 8298c2ecf20Sopenharmony_ci * Prevent auto-disable of refclk for SATA PHY due to Errata i783 8308c2ecf20Sopenharmony_ci */ 8318c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA) { 8328c2ecf20Sopenharmony_ci if (!IS_ERR(phy->refclk)) { 8338c2ecf20Sopenharmony_ci clk_prepare_enable(phy->refclk); 8348c2ecf20Sopenharmony_ci phy->sata_refclk_enabled = true; 8358c2ecf20Sopenharmony_ci } 8368c2ecf20Sopenharmony_ci } 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci generic_phy = devm_phy_create(dev, NULL, &ops); 8398c2ecf20Sopenharmony_ci if (IS_ERR(generic_phy)) 8408c2ecf20Sopenharmony_ci return PTR_ERR(generic_phy); 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci phy_set_drvdata(generic_phy, phy); 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci ti_pipe3_power_off(generic_phy); 8458c2ecf20Sopenharmony_ci 8468c2ecf20Sopenharmony_ci phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 8478c2ecf20Sopenharmony_ci return PTR_ERR_OR_ZERO(phy_provider); 8488c2ecf20Sopenharmony_ci} 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_cistatic int ti_pipe3_remove(struct platform_device *pdev) 8518c2ecf20Sopenharmony_ci{ 8528c2ecf20Sopenharmony_ci struct ti_pipe3 *phy = platform_get_drvdata(pdev); 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ci if (phy->mode == PIPE3_MODE_SATA) { 8558c2ecf20Sopenharmony_ci clk_disable_unprepare(phy->refclk); 8568c2ecf20Sopenharmony_ci phy->sata_refclk_enabled = false; 8578c2ecf20Sopenharmony_ci } 8588c2ecf20Sopenharmony_ci pm_runtime_disable(&pdev->dev); 8598c2ecf20Sopenharmony_ci 8608c2ecf20Sopenharmony_ci return 0; 8618c2ecf20Sopenharmony_ci} 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_cistatic int ti_pipe3_enable_clocks(struct ti_pipe3 *phy) 8648c2ecf20Sopenharmony_ci{ 8658c2ecf20Sopenharmony_ci int ret = 0; 8668c2ecf20Sopenharmony_ci 8678c2ecf20Sopenharmony_ci if (!IS_ERR(phy->refclk)) { 8688c2ecf20Sopenharmony_ci ret = clk_prepare_enable(phy->refclk); 8698c2ecf20Sopenharmony_ci if (ret) { 8708c2ecf20Sopenharmony_ci dev_err(phy->dev, "Failed to enable refclk %d\n", ret); 8718c2ecf20Sopenharmony_ci return ret; 8728c2ecf20Sopenharmony_ci } 8738c2ecf20Sopenharmony_ci } 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci if (!IS_ERR(phy->wkupclk)) { 8768c2ecf20Sopenharmony_ci ret = clk_prepare_enable(phy->wkupclk); 8778c2ecf20Sopenharmony_ci if (ret) { 8788c2ecf20Sopenharmony_ci dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); 8798c2ecf20Sopenharmony_ci goto disable_refclk; 8808c2ecf20Sopenharmony_ci } 8818c2ecf20Sopenharmony_ci } 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci if (!IS_ERR(phy->div_clk)) { 8848c2ecf20Sopenharmony_ci ret = clk_prepare_enable(phy->div_clk); 8858c2ecf20Sopenharmony_ci if (ret) { 8868c2ecf20Sopenharmony_ci dev_err(phy->dev, "Failed to enable div_clk %d\n", ret); 8878c2ecf20Sopenharmony_ci goto disable_wkupclk; 8888c2ecf20Sopenharmony_ci } 8898c2ecf20Sopenharmony_ci } 8908c2ecf20Sopenharmony_ci 8918c2ecf20Sopenharmony_ci return 0; 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_cidisable_wkupclk: 8948c2ecf20Sopenharmony_ci if (!IS_ERR(phy->wkupclk)) 8958c2ecf20Sopenharmony_ci clk_disable_unprepare(phy->wkupclk); 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_cidisable_refclk: 8988c2ecf20Sopenharmony_ci if (!IS_ERR(phy->refclk)) 8998c2ecf20Sopenharmony_ci clk_disable_unprepare(phy->refclk); 9008c2ecf20Sopenharmony_ci 9018c2ecf20Sopenharmony_ci return ret; 9028c2ecf20Sopenharmony_ci} 9038c2ecf20Sopenharmony_ci 9048c2ecf20Sopenharmony_cistatic void ti_pipe3_disable_clocks(struct ti_pipe3 *phy) 9058c2ecf20Sopenharmony_ci{ 9068c2ecf20Sopenharmony_ci if (!IS_ERR(phy->wkupclk)) 9078c2ecf20Sopenharmony_ci clk_disable_unprepare(phy->wkupclk); 9088c2ecf20Sopenharmony_ci if (!IS_ERR(phy->refclk)) 9098c2ecf20Sopenharmony_ci clk_disable_unprepare(phy->refclk); 9108c2ecf20Sopenharmony_ci if (!IS_ERR(phy->div_clk)) 9118c2ecf20Sopenharmony_ci clk_disable_unprepare(phy->div_clk); 9128c2ecf20Sopenharmony_ci} 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_cistatic const struct of_device_id ti_pipe3_id_table[] = { 9158c2ecf20Sopenharmony_ci { 9168c2ecf20Sopenharmony_ci .compatible = "ti,phy-usb3", 9178c2ecf20Sopenharmony_ci .data = &data_usb, 9188c2ecf20Sopenharmony_ci }, 9198c2ecf20Sopenharmony_ci { 9208c2ecf20Sopenharmony_ci .compatible = "ti,omap-usb3", 9218c2ecf20Sopenharmony_ci .data = &data_usb, 9228c2ecf20Sopenharmony_ci }, 9238c2ecf20Sopenharmony_ci { 9248c2ecf20Sopenharmony_ci .compatible = "ti,phy-pipe3-sata", 9258c2ecf20Sopenharmony_ci .data = &data_sata, 9268c2ecf20Sopenharmony_ci }, 9278c2ecf20Sopenharmony_ci { 9288c2ecf20Sopenharmony_ci .compatible = "ti,phy-pipe3-pcie", 9298c2ecf20Sopenharmony_ci .data = &data_pcie, 9308c2ecf20Sopenharmony_ci }, 9318c2ecf20Sopenharmony_ci {} 9328c2ecf20Sopenharmony_ci}; 9338c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, ti_pipe3_id_table); 9348c2ecf20Sopenharmony_ci 9358c2ecf20Sopenharmony_cistatic struct platform_driver ti_pipe3_driver = { 9368c2ecf20Sopenharmony_ci .probe = ti_pipe3_probe, 9378c2ecf20Sopenharmony_ci .remove = ti_pipe3_remove, 9388c2ecf20Sopenharmony_ci .driver = { 9398c2ecf20Sopenharmony_ci .name = "ti-pipe3", 9408c2ecf20Sopenharmony_ci .of_match_table = ti_pipe3_id_table, 9418c2ecf20Sopenharmony_ci }, 9428c2ecf20Sopenharmony_ci}; 9438c2ecf20Sopenharmony_ci 9448c2ecf20Sopenharmony_cimodule_platform_driver(ti_pipe3_driver); 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:ti_pipe3"); 9478c2ecf20Sopenharmony_ciMODULE_AUTHOR("Texas Instruments Inc."); 9488c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("TI PIPE3 phy driver"); 9498c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 950