18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Samsung SoC USB 1.1/2.0 PHY driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2013 Samsung Electronics Co., Ltd.
68c2ecf20Sopenharmony_ci * Author: Kamil Debski <k.debski@samsung.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _PHY_EXYNOS_USB2_H
108c2ecf20Sopenharmony_ci#define _PHY_EXYNOS_USB2_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/clk.h>
138c2ecf20Sopenharmony_ci#include <linux/phy/phy.h>
148c2ecf20Sopenharmony_ci#include <linux/device.h>
158c2ecf20Sopenharmony_ci#include <linux/regmap.h>
168c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
178c2ecf20Sopenharmony_ci#include <linux/regulator/consumer.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define KHZ 1000
208c2ecf20Sopenharmony_ci#define MHZ (KHZ * KHZ)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct samsung_usb2_phy_driver;
238c2ecf20Sopenharmony_cistruct samsung_usb2_phy_instance;
248c2ecf20Sopenharmony_cistruct samsung_usb2_phy_config;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct samsung_usb2_phy_instance {
278c2ecf20Sopenharmony_ci	const struct samsung_usb2_common_phy *cfg;
288c2ecf20Sopenharmony_ci	struct phy *phy;
298c2ecf20Sopenharmony_ci	struct samsung_usb2_phy_driver *drv;
308c2ecf20Sopenharmony_ci	int int_cnt;
318c2ecf20Sopenharmony_ci	int ext_cnt;
328c2ecf20Sopenharmony_ci};
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistruct samsung_usb2_phy_driver {
358c2ecf20Sopenharmony_ci	const struct samsung_usb2_phy_config *cfg;
368c2ecf20Sopenharmony_ci	struct clk *clk;
378c2ecf20Sopenharmony_ci	struct clk *ref_clk;
388c2ecf20Sopenharmony_ci	struct regulator *vbus;
398c2ecf20Sopenharmony_ci	unsigned long ref_rate;
408c2ecf20Sopenharmony_ci	u32 ref_reg_val;
418c2ecf20Sopenharmony_ci	struct device *dev;
428c2ecf20Sopenharmony_ci	void __iomem *reg_phy;
438c2ecf20Sopenharmony_ci	struct regmap *reg_pmu;
448c2ecf20Sopenharmony_ci	struct regmap *reg_sys;
458c2ecf20Sopenharmony_ci	spinlock_t lock;
468c2ecf20Sopenharmony_ci	struct samsung_usb2_phy_instance instances[];
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct samsung_usb2_common_phy {
508c2ecf20Sopenharmony_ci	int (*power_on)(struct samsung_usb2_phy_instance *);
518c2ecf20Sopenharmony_ci	int (*power_off)(struct samsung_usb2_phy_instance *);
528c2ecf20Sopenharmony_ci	unsigned int id;
538c2ecf20Sopenharmony_ci	char *label;
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct samsung_usb2_phy_config {
588c2ecf20Sopenharmony_ci	const struct samsung_usb2_common_phy *phys;
598c2ecf20Sopenharmony_ci	int (*rate_to_clk)(unsigned long, u32 *);
608c2ecf20Sopenharmony_ci	unsigned int num_phys;
618c2ecf20Sopenharmony_ci	bool has_mode_switch;
628c2ecf20Sopenharmony_ci	bool has_refclk_sel;
638c2ecf20Sopenharmony_ci};
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciextern const struct samsung_usb2_phy_config exynos3250_usb2_phy_config;
668c2ecf20Sopenharmony_ciextern const struct samsung_usb2_phy_config exynos4210_usb2_phy_config;
678c2ecf20Sopenharmony_ciextern const struct samsung_usb2_phy_config exynos4x12_usb2_phy_config;
688c2ecf20Sopenharmony_ciextern const struct samsung_usb2_phy_config exynos5250_usb2_phy_config;
698c2ecf20Sopenharmony_ciextern const struct samsung_usb2_phy_config s5pv210_usb2_phy_config;
708c2ecf20Sopenharmony_ci#endif
71