forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
phy: Add USB HSIC PHY driver for Marvell MMP3 SoC
Add PHY driver for the HSICs found on Marvell MMP3 SoC. The driver is rather straightforward -- the PHY essentially just needs to be enabled. Signed-off-by: Lubomir Rintel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* | ||
* Copyright (C) 2020 Lubomir Rintel <[email protected]> | ||
*/ | ||
|
||
#include <linux/delay.h> | ||
#include <linux/io.h> | ||
#include <linux/module.h> | ||
#include <linux/phy/phy.h> | ||
#include <linux/platform_device.h> | ||
|
||
#define HSIC_CTRL 0x08 | ||
#define HSIC_ENABLE BIT(7) | ||
#define PLL_BYPASS BIT(4) | ||
|
||
static int mmp3_hsic_phy_init(struct phy *phy) | ||
{ | ||
void __iomem *base = (void __iomem *)phy_get_drvdata(phy); | ||
u32 hsic_ctrl; | ||
|
||
hsic_ctrl = readl_relaxed(base + HSIC_CTRL); | ||
hsic_ctrl |= HSIC_ENABLE; | ||
hsic_ctrl |= PLL_BYPASS; | ||
writel_relaxed(hsic_ctrl, base + HSIC_CTRL); | ||
|
||
return 0; | ||
} | ||
|
||
static const struct phy_ops mmp3_hsic_phy_ops = { | ||
.init = mmp3_hsic_phy_init, | ||
.owner = THIS_MODULE, | ||
}; | ||
|
||
static const struct of_device_id mmp3_hsic_phy_of_match[] = { | ||
{ .compatible = "marvell,mmp3-hsic-phy", }, | ||
{ }, | ||
}; | ||
MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match); | ||
|
||
static int mmp3_hsic_phy_probe(struct platform_device *pdev) | ||
{ | ||
struct device *dev = &pdev->dev; | ||
struct phy_provider *provider; | ||
struct resource *resource; | ||
void __iomem *base; | ||
struct phy *phy; | ||
|
||
resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
base = devm_ioremap_resource(dev, resource); | ||
if (IS_ERR(base)) { | ||
dev_err(dev, "failed to remap PHY regs\n"); | ||
return PTR_ERR(base); | ||
} | ||
|
||
phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops); | ||
if (IS_ERR(phy)) { | ||
dev_err(dev, "failed to create PHY\n"); | ||
return PTR_ERR(phy); | ||
} | ||
|
||
phy_set_drvdata(phy, (void *)base); | ||
provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
if (IS_ERR(provider)) { | ||
dev_err(dev, "failed to register PHY provider\n"); | ||
return PTR_ERR(provider); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static struct platform_driver mmp3_hsic_phy_driver = { | ||
.probe = mmp3_hsic_phy_probe, | ||
.driver = { | ||
.name = "mmp3-hsic-phy", | ||
.of_match_table = mmp3_hsic_phy_of_match, | ||
}, | ||
}; | ||
module_platform_driver(mmp3_hsic_phy_driver); | ||
|
||
MODULE_AUTHOR("Lubomir Rintel <[email protected]>"); | ||
MODULE_DESCRIPTION("Marvell MMP3 USB HSIC PHY Driver"); | ||
MODULE_LICENSE("GPL"); |