intel-lpss-pci.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Intel LPSS PCI support.
  3. *
  4. * Copyright (C) 2015, Intel Corporation
  5. *
  6. * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  7. * Mika Westerberg <mika.westerberg@linux.intel.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/ioport.h>
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/pci.h>
  17. #include <linux/pm.h>
  18. #include <linux/pm_runtime.h>
  19. #include "intel-lpss.h"
  20. static int intel_lpss_pci_probe(struct pci_dev *pdev,
  21. const struct pci_device_id *id)
  22. {
  23. struct intel_lpss_platform_info *info;
  24. int ret;
  25. ret = pcim_enable_device(pdev);
  26. if (ret)
  27. return ret;
  28. info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info),
  29. GFP_KERNEL);
  30. if (!info)
  31. return -ENOMEM;
  32. info->mem = &pdev->resource[0];
  33. info->irq = pdev->irq;
  34. /* Probably it is enough to set this for iDMA capable devices only */
  35. pci_set_master(pdev);
  36. ret = intel_lpss_probe(&pdev->dev, info);
  37. if (ret)
  38. return ret;
  39. pm_runtime_put(&pdev->dev);
  40. pm_runtime_allow(&pdev->dev);
  41. return 0;
  42. }
  43. static void intel_lpss_pci_remove(struct pci_dev *pdev)
  44. {
  45. pm_runtime_forbid(&pdev->dev);
  46. pm_runtime_get_sync(&pdev->dev);
  47. intel_lpss_remove(&pdev->dev);
  48. }
  49. static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops);
  50. static const struct intel_lpss_platform_info spt_info = {
  51. .clk_rate = 120000000,
  52. };
  53. static const struct intel_lpss_platform_info spt_uart_info = {
  54. .clk_rate = 120000000,
  55. .clk_con_id = "baudclk",
  56. };
  57. static const struct pci_device_id intel_lpss_pci_ids[] = {
  58. /* SPT-LP */
  59. { PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info },
  60. { PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info },
  61. { PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info },
  62. { PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info },
  63. { PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_info },
  64. { PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_info },
  65. { PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_info },
  66. { PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_info },
  67. { PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_info },
  68. { PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_info },
  69. { PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info },
  70. /* SPT-H */
  71. { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
  72. { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
  73. { PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info },
  74. { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info },
  75. { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_info },
  76. { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_info },
  77. { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info },
  78. { }
  79. };
  80. MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
  81. static struct pci_driver intel_lpss_pci_driver = {
  82. .name = "intel-lpss",
  83. .id_table = intel_lpss_pci_ids,
  84. .probe = intel_lpss_pci_probe,
  85. .remove = intel_lpss_pci_remove,
  86. .driver = {
  87. .pm = &intel_lpss_pci_pm_ops,
  88. },
  89. };
  90. module_pci_driver(intel_lpss_pci_driver);
  91. MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
  92. MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
  93. MODULE_DESCRIPTION("Intel LPSS PCI driver");
  94. MODULE_LICENSE("GPL v2");