summaryrefslogtreecommitdiff
path: root/drivers/phy/phy-exynos-usb.h
blob: a9febfa58a408c93c78914d7cd521eafecee6d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * Samsung S5P/EXYNOS SoC series USB PHY driver
 *
 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
 * Author: Kamil Debski <k.debski@samsung.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef _PHY_SAMSUNG_NEW_H
#define _PHY_SAMSUNG_NEW_H

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>

#define CLKSEL_ERROR                       -1

#ifndef KHZ
#define KHZ 1000
#endif

#ifndef MHZ
#define MHZ (KHZ * KHZ)
#endif

enum phy_type {
	PHY_DEVICE,
	PHY_HOST,
};

enum samsung_cpu_type {
	TYPE_S3C64XX,
	TYPE_EXYNOS4210,
	TYPE_EXYNOS4212,
	TYPE_EXYNOS5250,
};

enum uphy_state {
	STATE_OFF,
	STATE_ON,
};

struct uphy_driver;
struct uphy_instance;
struct uphy_config;

struct uphy_instance {
	struct uphy_driver *drv;
	struct phy *phy;
	const struct common_phy *cfg;
	enum uphy_state state;
	int ref_cnt;
	u32 clk;
	unsigned long rate;
};

struct uphy_driver {
	struct device *dev;
	spinlock_t lock;
	void __iomem *reg_phy;
	void __iomem *reg_isol;
	void __iomem *reg_mode;
	const struct uphy_config *cfg;
	struct clk *clk;
	struct uphy_instance uphy_instances[0];
};

struct common_phy {
	char *label;
	enum phy_type type;
	unsigned int id;
	u32 (*rate_to_clk)(unsigned long);
	int (*power_on)(struct uphy_instance*);
	int (*power_off)(struct uphy_instance*);
};


struct uphy_config {
	enum samsung_cpu_type cpu;
	int num_phys;
	const struct common_phy *phys;
};

#endif