Skip to content

Commit 14da699

Browse files
committed
phy: rename struct omap_control_usb to struct omap_control_phy
Rename struct omap_control_usb to struct omap_control_phy since it can be used to control PHY of USB, SATA and PCIE. Also move the driver and include files under *phy* and made the corresponding changes in the users of phy-omap-control. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Roger Quadros <rogerq@ti.com> Acked-by: Felipe Balbi <balbi@ti.com>
1 parent db68e80 commit 14da699

9 files changed

Lines changed: 123 additions & 122 deletions

File tree

drivers/phy/Kconfig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,22 @@ config PHY_MVEBU_SATA
3131
depends on OF
3232
select GENERIC_PHY
3333

34+
config OMAP_CONTROL_PHY
35+
tristate "OMAP CONTROL PHY Driver"
36+
help
37+
Enable this to add support for the PHY part present in the control
38+
module. This driver has API to power on the USB2 PHY and to write to
39+
the mailbox. The mailbox is present only in omap4 and the register to
40+
power on the USB2 PHY is present in OMAP4 and OMAP5. OMAP5 has an
41+
additional register to power on USB3 PHY/SATA PHY/PCIE PHY
42+
(PIPE3 PHY).
43+
3444
config OMAP_USB2
3545
tristate "OMAP USB2 PHY Driver"
3646
depends on ARCH_OMAP2PLUS
3747
depends on USB_PHY
3848
select GENERIC_PHY
39-
select OMAP_CONTROL_USB
49+
select OMAP_CONTROL_PHY
4050
help
4151
Enable this to support the transceiver that is part of SOC. This
4252
driver takes care of all the PHY functionality apart from comparator.
@@ -47,7 +57,7 @@ config TI_PIPE3
4757
tristate "TI PIPE3 PHY Driver"
4858
depends on ARCH_OMAP2PLUS || COMPILE_TEST
4959
select GENERIC_PHY
50-
select OMAP_CONTROL_USB
60+
select OMAP_CONTROL_PHY
5161
help
5262
Enable this to support the PIPE3 PHY that is part of TI SOCs. This
5363
driver takes care of all the PHY functionality apart from comparator.

drivers/phy/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj-$(CONFIG_BCM_KONA_USB2_PHY) += phy-bcm-kona-usb2.o
77
obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-exynos-dp-video.o
88
obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-video.o
99
obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
10+
obj-$(CONFIG_OMAP_CONTROL_PHY) += phy-omap-control.o
1011
obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o
1112
obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o
1213
obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* omap-control-usb.c - The USB part of control module.
2+
* omap-control-phy.c - The PHY part of control module.
33
*
44
* Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com
55
* This program is free software; you can redistribute it and/or modify
@@ -24,36 +24,36 @@
2424
#include <linux/err.h>
2525
#include <linux/io.h>
2626
#include <linux/clk.h>
27-
#include <linux/usb/omap_control_usb.h>
27+
#include <linux/phy/omap_control_phy.h>
2828

2929
/**
30-
* omap_control_usb_phy_power - power on/off the phy using control module reg
30+
* omap_control_phy_power - power on/off the phy using control module reg
3131
* @dev: the control module device
3232
* @on: 0 or 1, based on powering on or off the PHY
3333
*/
34-
void omap_control_usb_phy_power(struct device *dev, int on)
34+
void omap_control_phy_power(struct device *dev, int on)
3535
{
3636
u32 val;
3737
unsigned long rate;
38-
struct omap_control_usb *control_usb;
38+
struct omap_control_phy *control_phy;
3939

4040
if (IS_ERR(dev) || !dev) {
4141
pr_err("%s: invalid device\n", __func__);
4242
return;
4343
}
4444

45-
control_usb = dev_get_drvdata(dev);
46-
if (!control_usb) {
47-
dev_err(dev, "%s: invalid control usb device\n", __func__);
45+
control_phy = dev_get_drvdata(dev);
46+
if (!control_phy) {
47+
dev_err(dev, "%s: invalid control phy device\n", __func__);
4848
return;
4949
}
5050

51-
if (control_usb->type == OMAP_CTRL_TYPE_OTGHS)
51+
if (control_phy->type == OMAP_CTRL_TYPE_OTGHS)
5252
return;
5353

54-
val = readl(control_usb->power);
54+
val = readl(control_phy->power);
5555

56-
switch (control_usb->type) {
56+
switch (control_phy->type) {
5757
case OMAP_CTRL_TYPE_USB2:
5858
if (on)
5959
val &= ~OMAP_CTRL_DEV_PHY_PD;
@@ -62,19 +62,20 @@ void omap_control_usb_phy_power(struct device *dev, int on)
6262
break;
6363

6464
case OMAP_CTRL_TYPE_PIPE3:
65-
rate = clk_get_rate(control_usb->sys_clk);
65+
rate = clk_get_rate(control_phy->sys_clk);
6666
rate = rate/1000000;
6767

6868
if (on) {
69-
val &= ~(OMAP_CTRL_USB_PWRCTL_CLK_CMD_MASK |
70-
OMAP_CTRL_USB_PWRCTL_CLK_FREQ_MASK);
71-
val |= OMAP_CTRL_USB3_PHY_TX_RX_POWERON <<
72-
OMAP_CTRL_USB_PWRCTL_CLK_CMD_SHIFT;
73-
val |= rate << OMAP_CTRL_USB_PWRCTL_CLK_FREQ_SHIFT;
69+
val &= ~(OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
70+
OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK);
71+
val |= OMAP_CTRL_PIPE3_PHY_TX_RX_POWERON <<
72+
OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
73+
val |= rate <<
74+
OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
7475
} else {
75-
val &= ~OMAP_CTRL_USB_PWRCTL_CLK_CMD_MASK;
76-
val |= OMAP_CTRL_USB3_PHY_TX_RX_POWEROFF <<
77-
OMAP_CTRL_USB_PWRCTL_CLK_CMD_SHIFT;
76+
val &= ~OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK;
77+
val |= OMAP_CTRL_PIPE3_PHY_TX_RX_POWEROFF <<
78+
OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
7879
}
7980
break;
8081

@@ -100,66 +101,66 @@ void omap_control_usb_phy_power(struct device *dev, int on)
100101
break;
101102
default:
102103
dev_err(dev, "%s: type %d not recognized\n",
103-
__func__, control_usb->type);
104+
__func__, control_phy->type);
104105
break;
105106
}
106107

107-
writel(val, control_usb->power);
108+
writel(val, control_phy->power);
108109
}
109-
EXPORT_SYMBOL_GPL(omap_control_usb_phy_power);
110+
EXPORT_SYMBOL_GPL(omap_control_phy_power);
110111

111112
/**
112113
* omap_control_usb_host_mode - set AVALID, VBUSVALID and ID pin in grounded
113-
* @ctrl_usb: struct omap_control_usb *
114+
* @ctrl_phy: struct omap_control_phy *
114115
*
115116
* Writes to the mailbox register to notify the usb core that a usb
116117
* device has been connected.
117118
*/
118-
static void omap_control_usb_host_mode(struct omap_control_usb *ctrl_usb)
119+
static void omap_control_usb_host_mode(struct omap_control_phy *ctrl_phy)
119120
{
120121
u32 val;
121122

122-
val = readl(ctrl_usb->otghs_control);
123+
val = readl(ctrl_phy->otghs_control);
123124
val &= ~(OMAP_CTRL_DEV_IDDIG | OMAP_CTRL_DEV_SESSEND);
124125
val |= OMAP_CTRL_DEV_AVALID | OMAP_CTRL_DEV_VBUSVALID;
125-
writel(val, ctrl_usb->otghs_control);
126+
writel(val, ctrl_phy->otghs_control);
126127
}
127128

128129
/**
129130
* omap_control_usb_device_mode - set AVALID, VBUSVALID and ID pin in high
130131
* impedance
131-
* @ctrl_usb: struct omap_control_usb *
132+
* @ctrl_phy: struct omap_control_phy *
132133
*
133134
* Writes to the mailbox register to notify the usb core that it has been
134135
* connected to a usb host.
135136
*/
136-
static void omap_control_usb_device_mode(struct omap_control_usb *ctrl_usb)
137+
static void omap_control_usb_device_mode(struct omap_control_phy *ctrl_phy)
137138
{
138139
u32 val;
139140

140-
val = readl(ctrl_usb->otghs_control);
141+
val = readl(ctrl_phy->otghs_control);
141142
val &= ~OMAP_CTRL_DEV_SESSEND;
142143
val |= OMAP_CTRL_DEV_IDDIG | OMAP_CTRL_DEV_AVALID |
143144
OMAP_CTRL_DEV_VBUSVALID;
144-
writel(val, ctrl_usb->otghs_control);
145+
writel(val, ctrl_phy->otghs_control);
145146
}
146147

147148
/**
148149
* omap_control_usb_set_sessionend - Enable SESSIONEND and IDIG to high
149150
* impedance
150-
* @ctrl_usb: struct omap_control_usb *
151+
* @ctrl_phy: struct omap_control_phy *
151152
*
152153
* Writes to the mailbox register to notify the usb core it's now in
153154
* disconnected state.
154155
*/
155-
static void omap_control_usb_set_sessionend(struct omap_control_usb *ctrl_usb)
156+
static void omap_control_usb_set_sessionend(struct omap_control_phy *ctrl_phy)
156157
{
157158
u32 val;
158159

159-
val = readl(ctrl_usb->otghs_control);
160+
val = readl(ctrl_phy->otghs_control);
160161
val &= ~(OMAP_CTRL_DEV_AVALID | OMAP_CTRL_DEV_VBUSVALID);
161162
val |= OMAP_CTRL_DEV_IDDIG | OMAP_CTRL_DEV_SESSEND;
162-
writel(val, ctrl_usb->otghs_control);
163+
writel(val, ctrl_phy->otghs_control);
163164
}
164165

165166
/**
@@ -174,30 +175,30 @@ static void omap_control_usb_set_sessionend(struct omap_control_usb *ctrl_usb)
174175
void omap_control_usb_set_mode(struct device *dev,
175176
enum omap_control_usb_mode mode)
176177
{
177-
struct omap_control_usb *ctrl_usb;
178+
struct omap_control_phy *ctrl_phy;
178179

179180
if (IS_ERR(dev) || !dev)
180181
return;
181182

182-
ctrl_usb = dev_get_drvdata(dev);
183+
ctrl_phy = dev_get_drvdata(dev);
183184

184-
if (!ctrl_usb) {
185-
dev_err(dev, "Invalid control usb device\n");
185+
if (!ctrl_phy) {
186+
dev_err(dev, "Invalid control phy device\n");
186187
return;
187188
}
188189

189-
if (ctrl_usb->type != OMAP_CTRL_TYPE_OTGHS)
190+
if (ctrl_phy->type != OMAP_CTRL_TYPE_OTGHS)
190191
return;
191192

192193
switch (mode) {
193194
case USB_MODE_HOST:
194-
omap_control_usb_host_mode(ctrl_usb);
195+
omap_control_usb_host_mode(ctrl_phy);
195196
break;
196197
case USB_MODE_DEVICE:
197-
omap_control_usb_device_mode(ctrl_usb);
198+
omap_control_usb_device_mode(ctrl_phy);
198199
break;
199200
case USB_MODE_DISCONNECT:
200-
omap_control_usb_set_sessionend(ctrl_usb);
201+
omap_control_usb_set_sessionend(ctrl_phy);
201202
break;
202203
default:
203204
dev_vdbg(dev, "invalid omap control usb mode\n");
@@ -207,13 +208,13 @@ EXPORT_SYMBOL_GPL(omap_control_usb_set_mode);
207208

208209
#ifdef CONFIG_OF
209210

210-
static const enum omap_control_usb_type otghs_data = OMAP_CTRL_TYPE_OTGHS;
211-
static const enum omap_control_usb_type usb2_data = OMAP_CTRL_TYPE_USB2;
212-
static const enum omap_control_usb_type pipe3_data = OMAP_CTRL_TYPE_PIPE3;
213-
static const enum omap_control_usb_type dra7usb2_data = OMAP_CTRL_TYPE_DRA7USB2;
214-
static const enum omap_control_usb_type am437usb2_data = OMAP_CTRL_TYPE_AM437USB2;
211+
static const enum omap_control_phy_type otghs_data = OMAP_CTRL_TYPE_OTGHS;
212+
static const enum omap_control_phy_type usb2_data = OMAP_CTRL_TYPE_USB2;
213+
static const enum omap_control_phy_type pipe3_data = OMAP_CTRL_TYPE_PIPE3;
214+
static const enum omap_control_phy_type dra7usb2_data = OMAP_CTRL_TYPE_DRA7USB2;
215+
static const enum omap_control_phy_type am437usb2_data = OMAP_CTRL_TYPE_AM437USB2;
215216

216-
static const struct of_device_id omap_control_usb_id_table[] = {
217+
static const struct of_device_id omap_control_phy_id_table[] = {
217218
{
218219
.compatible = "ti,control-phy-otghs",
219220
.data = &otghs_data,
@@ -236,84 +237,84 @@ static const struct of_device_id omap_control_usb_id_table[] = {
236237
},
237238
{},
238239
};
239-
MODULE_DEVICE_TABLE(of, omap_control_usb_id_table);
240+
MODULE_DEVICE_TABLE(of, omap_control_phy_id_table);
240241
#endif
241242

242243

243-
static int omap_control_usb_probe(struct platform_device *pdev)
244+
static int omap_control_phy_probe(struct platform_device *pdev)
244245
{
245246
struct resource *res;
246247
const struct of_device_id *of_id;
247-
struct omap_control_usb *control_usb;
248+
struct omap_control_phy *control_phy;
248249

249-
of_id = of_match_device(of_match_ptr(omap_control_usb_id_table),
250-
&pdev->dev);
250+
of_id = of_match_device(of_match_ptr(omap_control_phy_id_table),
251+
&pdev->dev);
251252
if (!of_id)
252253
return -EINVAL;
253254

254-
control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb),
255+
control_phy = devm_kzalloc(&pdev->dev, sizeof(*control_phy),
255256
GFP_KERNEL);
256-
if (!control_usb) {
257-
dev_err(&pdev->dev, "unable to alloc memory for control usb\n");
257+
if (!control_phy) {
258+
dev_err(&pdev->dev, "unable to alloc memory for control phy\n");
258259
return -ENOMEM;
259260
}
260261

261-
control_usb->dev = &pdev->dev;
262-
control_usb->type = *(enum omap_control_usb_type *)of_id->data;
262+
control_phy->dev = &pdev->dev;
263+
control_phy->type = *(enum omap_control_phy_type *)of_id->data;
263264

264-
if (control_usb->type == OMAP_CTRL_TYPE_OTGHS) {
265+
if (control_phy->type == OMAP_CTRL_TYPE_OTGHS) {
265266
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
266267
"otghs_control");
267-
control_usb->otghs_control = devm_ioremap_resource(
268+
control_phy->otghs_control = devm_ioremap_resource(
268269
&pdev->dev, res);
269-
if (IS_ERR(control_usb->otghs_control))
270-
return PTR_ERR(control_usb->otghs_control);
270+
if (IS_ERR(control_phy->otghs_control))
271+
return PTR_ERR(control_phy->otghs_control);
271272
} else {
272273
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
273274
"power");
274-
control_usb->power = devm_ioremap_resource(&pdev->dev, res);
275-
if (IS_ERR(control_usb->power)) {
275+
control_phy->power = devm_ioremap_resource(&pdev->dev, res);
276+
if (IS_ERR(control_phy->power)) {
276277
dev_err(&pdev->dev, "Couldn't get power register\n");
277-
return PTR_ERR(control_usb->power);
278+
return PTR_ERR(control_phy->power);
278279
}
279280
}
280281

281-
if (control_usb->type == OMAP_CTRL_TYPE_PIPE3) {
282-
control_usb->sys_clk = devm_clk_get(control_usb->dev,
282+
if (control_phy->type == OMAP_CTRL_TYPE_PIPE3) {
283+
control_phy->sys_clk = devm_clk_get(control_phy->dev,
283284
"sys_clkin");
284-
if (IS_ERR(control_usb->sys_clk)) {
285+
if (IS_ERR(control_phy->sys_clk)) {
285286
pr_err("%s: unable to get sys_clkin\n", __func__);
286287
return -EINVAL;
287288
}
288289
}
289290

290-
dev_set_drvdata(control_usb->dev, control_usb);
291+
dev_set_drvdata(control_phy->dev, control_phy);
291292

292293
return 0;
293294
}
294295

295-
static struct platform_driver omap_control_usb_driver = {
296-
.probe = omap_control_usb_probe,
296+
static struct platform_driver omap_control_phy_driver = {
297+
.probe = omap_control_phy_probe,
297298
.driver = {
298-
.name = "omap-control-usb",
299+
.name = "omap-control-phy",
299300
.owner = THIS_MODULE,
300-
.of_match_table = of_match_ptr(omap_control_usb_id_table),
301+
.of_match_table = of_match_ptr(omap_control_phy_id_table),
301302
},
302303
};
303304

304-
static int __init omap_control_usb_init(void)
305+
static int __init omap_control_phy_init(void)
305306
{
306-
return platform_driver_register(&omap_control_usb_driver);
307+
return platform_driver_register(&omap_control_phy_driver);
307308
}
308-
subsys_initcall(omap_control_usb_init);
309+
subsys_initcall(omap_control_phy_init);
309310

310-
static void __exit omap_control_usb_exit(void)
311+
static void __exit omap_control_phy_exit(void)
311312
{
312-
platform_driver_unregister(&omap_control_usb_driver);
313+
platform_driver_unregister(&omap_control_phy_driver);
313314
}
314-
module_exit(omap_control_usb_exit);
315+
module_exit(omap_control_phy_exit);
315316

316-
MODULE_ALIAS("platform: omap_control_usb");
317+
MODULE_ALIAS("platform: omap_control_phy");
317318
MODULE_AUTHOR("Texas Instruments Inc.");
318-
MODULE_DESCRIPTION("OMAP Control Module USB Driver");
319+
MODULE_DESCRIPTION("OMAP Control Module PHY Driver");
319320
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)