Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Lubomir Rintel <lkundrak@v3.sk>
4 */
5
6#include <linux/delay.h>
7#include <linux/io.h>
8#include <linux/module.h>
9#include <linux/phy/phy.h>
10#include <linux/platform_device.h>
11
12#define HSIC_CTRL 0x08
13#define HSIC_ENABLE BIT(7)
14#define PLL_BYPASS BIT(4)
15
16static int mmp3_hsic_phy_init(struct phy *phy)
17{
18 void __iomem *base = (void __iomem *)phy_get_drvdata(phy);
19 u32 hsic_ctrl;
20
21 hsic_ctrl = readl_relaxed(base + HSIC_CTRL);
22 hsic_ctrl |= HSIC_ENABLE;
23 hsic_ctrl |= PLL_BYPASS;
24 writel_relaxed(hsic_ctrl, base + HSIC_CTRL);
25
26 return 0;
27}
28
29static const struct phy_ops mmp3_hsic_phy_ops = {
30 .init = mmp3_hsic_phy_init,
31 .owner = THIS_MODULE,
32};
33
34static const struct of_device_id mmp3_hsic_phy_of_match[] = {
35 { .compatible = "marvell,mmp3-hsic-phy", },
36 { },
37};
38MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match);
39
40static int mmp3_hsic_phy_probe(struct platform_device *pdev)
41{
42 struct device *dev = &pdev->dev;
43 struct phy_provider *provider;
44 struct resource *resource;
45 void __iomem *base;
46 struct phy *phy;
47
48 resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
49 base = devm_ioremap_resource(dev, resource);
50 if (IS_ERR(base))
51 return PTR_ERR(base);
52
53 phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops);
54 if (IS_ERR(phy)) {
55 dev_err(dev, "failed to create PHY\n");
56 return PTR_ERR(phy);
57 }
58
59 phy_set_drvdata(phy, (void *)base);
60 provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
61 if (IS_ERR(provider)) {
62 dev_err(dev, "failed to register PHY provider\n");
63 return PTR_ERR(provider);
64 }
65
66 return 0;
67}
68
69static struct platform_driver mmp3_hsic_phy_driver = {
70 .probe = mmp3_hsic_phy_probe,
71 .driver = {
72 .name = "mmp3-hsic-phy",
73 .of_match_table = mmp3_hsic_phy_of_match,
74 },
75};
76module_platform_driver(mmp3_hsic_phy_driver);
77
78MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
79MODULE_DESCRIPTION("Marvell MMP3 USB HSIC PHY Driver");
80MODULE_LICENSE("GPL");