• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Synopsys G210 Test Chip driver
3  *
4  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
5  *
6  * Authors: Joao Pinto <jpinto@synopsys.com>
7  *
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.
11  */
12 
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>
18 
19 #include "ufshcd-pltfrm.h"
20 #include "ufshcd-dwc.h"
21 #include "tc-dwc-g210.h"
22 
23 /*
24  * UFS DWC specific variant operations
25  */
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,
30 };
31 
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,
36 };
37 
38 static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
39 	{
40 		.compatible = "snps,g210-tc-6.00-20bit",
41 		.data = &tc_dwc_g210_20bit_pltfm_hba_vops,
42 	},
43 	{
44 		.compatible = "snps,g210-tc-6.00-40bit",
45 		.data = &tc_dwc_g210_40bit_pltfm_hba_vops,
46 	},
47 	{ },
48 };
49 MODULE_DEVICE_TABLE(of, tc_dwc_g210_pltfm_match);
50 
51 /**
52  * tc_dwc_g210_pltfm_probe()
53  * @pdev: pointer to platform device structure
54  *
55  */
tc_dwc_g210_pltfm_probe(struct platform_device * pdev)56 static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
57 {
58 	int err;
59 	const struct of_device_id *of_id;
60 	struct ufs_hba_variant_ops *vops;
61 	struct device *dev = &pdev->dev;
62 
63 	of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node);
64 	vops = (struct ufs_hba_variant_ops *)of_id->data;
65 
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);
70 
71 	return err;
72 }
73 
74 /**
75  * tc_dwc_g210_pltfm_remove()
76  * @pdev: pointer to platform device structure
77  *
78  */
tc_dwc_g210_pltfm_remove(struct platform_device * pdev)79 static int tc_dwc_g210_pltfm_remove(struct platform_device *pdev)
80 {
81 	struct ufs_hba *hba =  platform_get_drvdata(pdev);
82 
83 	pm_runtime_get_sync(&(pdev)->dev);
84 	ufshcd_remove(hba);
85 
86 	return 0;
87 }
88 
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,
95 };
96 
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),
105 	},
106 };
107 
108 module_platform_driver(tc_dwc_g210_pltfm_driver);
109 
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");
114