tc-dwc-g210-pltfrm.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/of.h>
  16. #include <linux/delay.h>
  17. #include "ufshcd-pltfrm.h"
  18. #include "ufshcd-dwc.h"
  19. #include "tc-dwc-g210.h"
  20. /**
  21. * UFS DWC specific variant operations
  22. */
  23. static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
  24. .name = "tc-dwc-g210-pltfm",
  25. .link_startup_notify = ufshcd_dwc_link_startup_notify,
  26. .phy_initialization = tc_dwc_g210_config_20_bit,
  27. };
  28. static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = {
  29. .name = "tc-dwc-g210-pltfm",
  30. .link_startup_notify = ufshcd_dwc_link_startup_notify,
  31. .phy_initialization = tc_dwc_g210_config_40_bit,
  32. };
  33. static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
  34. {
  35. .compatible = "snps,g210-tc-6.00-20bit",
  36. .data = &tc_dwc_g210_20bit_pltfm_hba_vops,
  37. },
  38. {
  39. .compatible = "snps,g210-tc-6.00-40bit",
  40. .data = &tc_dwc_g210_40bit_pltfm_hba_vops,
  41. },
  42. { },
  43. };
  44. MODULE_DEVICE_TABLE(of, tc_dwc_g210_pltfm_match);
  45. /**
  46. * tc_dwc_g210_pltfm_probe()
  47. * @pdev: pointer to platform device structure
  48. *
  49. */
  50. static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
  51. {
  52. int err;
  53. const struct of_device_id *of_id;
  54. struct ufs_hba_variant_ops *vops;
  55. struct device *dev = &pdev->dev;
  56. of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node);
  57. vops = (struct ufs_hba_variant_ops *)of_id->data;
  58. /* Perform generic probe */
  59. err = ufshcd_pltfrm_init(pdev, vops);
  60. if (err)
  61. dev_err(dev, "ufshcd_pltfrm_init() failed %d\n", err);
  62. return err;
  63. }
  64. /**
  65. * tc_dwc_g210_pltfm_remove()
  66. * @pdev: pointer to platform device structure
  67. *
  68. */
  69. static int tc_dwc_g210_pltfm_remove(struct platform_device *pdev)
  70. {
  71. struct ufs_hba *hba = platform_get_drvdata(pdev);
  72. pm_runtime_get_sync(&(pdev)->dev);
  73. ufshcd_remove(hba);
  74. return 0;
  75. }
  76. static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops = {
  77. .suspend = ufshcd_pltfrm_suspend,
  78. .resume = ufshcd_pltfrm_resume,
  79. .runtime_suspend = ufshcd_pltfrm_runtime_suspend,
  80. .runtime_resume = ufshcd_pltfrm_runtime_resume,
  81. .runtime_idle = ufshcd_pltfrm_runtime_idle,
  82. };
  83. static struct platform_driver tc_dwc_g210_pltfm_driver = {
  84. .probe = tc_dwc_g210_pltfm_probe,
  85. .remove = tc_dwc_g210_pltfm_remove,
  86. .shutdown = ufshcd_pltfrm_shutdown,
  87. .driver = {
  88. .name = "tc-dwc-g210-pltfm",
  89. .pm = &tc_dwc_g210_pltfm_pm_ops,
  90. .of_match_table = of_match_ptr(tc_dwc_g210_pltfm_match),
  91. },
  92. };
  93. module_platform_driver(tc_dwc_g210_pltfm_driver);
  94. MODULE_ALIAS("platform:tc-dwc-g210-pltfm");
  95. MODULE_DESCRIPTION("Synopsys Test Chip G210 platform glue driver");
  96. MODULE_AUTHOR("Joao Pinto <Joao.Pinto@synopsys.com>");
  97. MODULE_LICENSE("Dual BSD/GPL");