0001
0002
0003
0004
0005
0006 #include <linux/delay.h>
0007 #include <linux/io.h>
0008 #include <linux/module.h>
0009 #include <linux/phy/phy.h>
0010 #include <linux/platform_device.h>
0011
0012 #define HSIC_CTRL 0x08
0013 #define HSIC_ENABLE BIT(7)
0014 #define PLL_BYPASS BIT(4)
0015
0016 static int mmp3_hsic_phy_init(struct phy *phy)
0017 {
0018 void __iomem *base = (void __iomem *)phy_get_drvdata(phy);
0019 u32 hsic_ctrl;
0020
0021 hsic_ctrl = readl_relaxed(base + HSIC_CTRL);
0022 hsic_ctrl |= HSIC_ENABLE;
0023 hsic_ctrl |= PLL_BYPASS;
0024 writel_relaxed(hsic_ctrl, base + HSIC_CTRL);
0025
0026 return 0;
0027 }
0028
0029 static const struct phy_ops mmp3_hsic_phy_ops = {
0030 .init = mmp3_hsic_phy_init,
0031 .owner = THIS_MODULE,
0032 };
0033
0034 static const struct of_device_id mmp3_hsic_phy_of_match[] = {
0035 { .compatible = "marvell,mmp3-hsic-phy", },
0036 { },
0037 };
0038 MODULE_DEVICE_TABLE(of, mmp3_hsic_phy_of_match);
0039
0040 static int mmp3_hsic_phy_probe(struct platform_device *pdev)
0041 {
0042 struct device *dev = &pdev->dev;
0043 struct phy_provider *provider;
0044 struct resource *resource;
0045 void __iomem *base;
0046 struct phy *phy;
0047
0048 resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0049 base = devm_ioremap_resource(dev, resource);
0050 if (IS_ERR(base))
0051 return PTR_ERR(base);
0052
0053 phy = devm_phy_create(dev, NULL, &mmp3_hsic_phy_ops);
0054 if (IS_ERR(phy)) {
0055 dev_err(dev, "failed to create PHY\n");
0056 return PTR_ERR(phy);
0057 }
0058
0059 phy_set_drvdata(phy, (void *)base);
0060 provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
0061 if (IS_ERR(provider)) {
0062 dev_err(dev, "failed to register PHY provider\n");
0063 return PTR_ERR(provider);
0064 }
0065
0066 return 0;
0067 }
0068
0069 static struct platform_driver mmp3_hsic_phy_driver = {
0070 .probe = mmp3_hsic_phy_probe,
0071 .driver = {
0072 .name = "mmp3-hsic-phy",
0073 .of_match_table = mmp3_hsic_phy_of_match,
0074 },
0075 };
0076 module_platform_driver(mmp3_hsic_phy_driver);
0077
0078 MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
0079 MODULE_DESCRIPTION("Marvell MMP3 USB HSIC PHY Driver");
0080 MODULE_LICENSE("GPL");