Linux 4.16.11
[linux/fpc-iii.git] / drivers / scsi / ufs / tc-dwc-g210-pltfrm.c
blob2d3f5270f875d72fb3f9da08c2dfe3eb84574d85
1 /*
2 * Synopsys G210 Test Chip driver
4 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
6 * Authors: Joao Pinto <jpinto@synopsys.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/of.h>
17 #include <linux/delay.h>
19 #include "ufshcd-pltfrm.h"
20 #include "ufshcd-dwc.h"
21 #include "tc-dwc-g210.h"
23 /**
24 * UFS DWC specific variant operations
26 static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
27 .name = "tc-dwc-g210-pltfm",
28 .link_startup_notify = ufshcd_dwc_link_startup_notify,
29 .phy_initialization = tc_dwc_g210_config_20_bit,
32 static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = {
33 .name = "tc-dwc-g210-pltfm",
34 .link_startup_notify = ufshcd_dwc_link_startup_notify,
35 .phy_initialization = tc_dwc_g210_config_40_bit,
38 static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
40 .compatible = "snps,g210-tc-6.00-20bit",
41 .data = &tc_dwc_g210_20bit_pltfm_hba_vops,
44 .compatible = "snps,g210-tc-6.00-40bit",
45 .data = &tc_dwc_g210_40bit_pltfm_hba_vops,
47 { },
49 MODULE_DEVICE_TABLE(of, tc_dwc_g210_pltfm_match);
51 /**
52 * tc_dwc_g210_pltfm_probe()
53 * @pdev: pointer to platform device structure
56 static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
58 int err;
59 const struct of_device_id *of_id;
60 struct ufs_hba_variant_ops *vops;
61 struct device *dev = &pdev->dev;
63 of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node);
64 vops = (struct ufs_hba_variant_ops *)of_id->data;
66 /* Perform generic probe */
67 err = ufshcd_pltfrm_init(pdev, vops);
68 if (err)
69 dev_err(dev, "ufshcd_pltfrm_init() failed %d\n", err);
71 return err;
74 /**
75 * tc_dwc_g210_pltfm_remove()
76 * @pdev: pointer to platform device structure
79 static int tc_dwc_g210_pltfm_remove(struct platform_device *pdev)
81 struct ufs_hba *hba = platform_get_drvdata(pdev);
83 pm_runtime_get_sync(&(pdev)->dev);
84 ufshcd_remove(hba);
86 return 0;
89 static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops = {
90 .suspend = ufshcd_pltfrm_suspend,
91 .resume = ufshcd_pltfrm_resume,
92 .runtime_suspend = ufshcd_pltfrm_runtime_suspend,
93 .runtime_resume = ufshcd_pltfrm_runtime_resume,
94 .runtime_idle = ufshcd_pltfrm_runtime_idle,
97 static struct platform_driver tc_dwc_g210_pltfm_driver = {
98 .probe = tc_dwc_g210_pltfm_probe,
99 .remove = tc_dwc_g210_pltfm_remove,
100 .shutdown = ufshcd_pltfrm_shutdown,
101 .driver = {
102 .name = "tc-dwc-g210-pltfm",
103 .pm = &tc_dwc_g210_pltfm_pm_ops,
104 .of_match_table = of_match_ptr(tc_dwc_g210_pltfm_match),
108 module_platform_driver(tc_dwc_g210_pltfm_driver);
110 MODULE_ALIAS("platform:tc-dwc-g210-pltfm");
111 MODULE_DESCRIPTION("Synopsys Test Chip G210 platform glue driver");
112 MODULE_AUTHOR("Joao Pinto <Joao.Pinto@synopsys.com>");
113 MODULE_LICENSE("Dual BSD/GPL");