1 // SPDX-License-Identifier: GPL-2.0-only
3 * Synopsys G210 Test Chip driver
5 * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
7 * Authors: Joao Pinto <jpinto@synopsys.com>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
14 #include <linux/delay.h>
15 #include <linux/pm_runtime.h>
17 #include "ufshcd-pltfrm.h"
18 #include "ufshcd-dwc.h"
19 #include "tc-dwc-g210.h"
22 * UFS DWC specific variant operations
24 static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops
= {
25 .name
= "tc-dwc-g210-pltfm",
26 .link_startup_notify
= ufshcd_dwc_link_startup_notify
,
27 .phy_initialization
= tc_dwc_g210_config_20_bit
,
30 static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops
= {
31 .name
= "tc-dwc-g210-pltfm",
32 .link_startup_notify
= ufshcd_dwc_link_startup_notify
,
33 .phy_initialization
= tc_dwc_g210_config_40_bit
,
36 static const struct of_device_id tc_dwc_g210_pltfm_match
[] = {
38 .compatible
= "snps,g210-tc-6.00-20bit",
39 .data
= &tc_dwc_g210_20bit_pltfm_hba_vops
,
42 .compatible
= "snps,g210-tc-6.00-40bit",
43 .data
= &tc_dwc_g210_40bit_pltfm_hba_vops
,
47 MODULE_DEVICE_TABLE(of
, tc_dwc_g210_pltfm_match
);
50 * tc_dwc_g210_pltfm_probe()
51 * @pdev: pointer to platform device structure
54 static int tc_dwc_g210_pltfm_probe(struct platform_device
*pdev
)
57 const struct of_device_id
*of_id
;
58 struct ufs_hba_variant_ops
*vops
;
59 struct device
*dev
= &pdev
->dev
;
61 of_id
= of_match_node(tc_dwc_g210_pltfm_match
, dev
->of_node
);
62 vops
= (struct ufs_hba_variant_ops
*)of_id
->data
;
64 /* Perform generic probe */
65 err
= ufshcd_pltfrm_init(pdev
, vops
);
67 dev_err(dev
, "ufshcd_pltfrm_init() failed %d\n", err
);
73 * tc_dwc_g210_pltfm_remove()
74 * @pdev: pointer to platform device structure
77 static void tc_dwc_g210_pltfm_remove(struct platform_device
*pdev
)
79 struct ufs_hba
*hba
= platform_get_drvdata(pdev
);
81 pm_runtime_get_sync(&(pdev
)->dev
);
85 static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops
= {
86 SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend
, ufshcd_system_resume
)
87 SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend
, ufshcd_runtime_resume
, NULL
)
90 static struct platform_driver tc_dwc_g210_pltfm_driver
= {
91 .probe
= tc_dwc_g210_pltfm_probe
,
92 .remove
= tc_dwc_g210_pltfm_remove
,
94 .name
= "tc-dwc-g210-pltfm",
95 .pm
= &tc_dwc_g210_pltfm_pm_ops
,
96 .of_match_table
= of_match_ptr(tc_dwc_g210_pltfm_match
),
100 module_platform_driver(tc_dwc_g210_pltfm_driver
);
102 MODULE_ALIAS("platform:tc-dwc-g210-pltfm");
103 MODULE_DESCRIPTION("Synopsys Test Chip G210 platform glue driver");
104 MODULE_AUTHOR("Joao Pinto <Joao.Pinto@synopsys.com>");
105 MODULE_LICENSE("Dual BSD/GPL");