Andy Shevchenko | 4b45efe | 2015-07-27 18:04:03 +0300 | [diff] [blame^] | 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 | |
| 14 | #include <linux/ioport.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/pci.h> |
| 18 | #include <linux/pm.h> |
| 19 | #include <linux/pm_runtime.h> |
| 20 | |
| 21 | #include "intel-lpss.h" |
| 22 | |
| 23 | static int intel_lpss_pci_probe(struct pci_dev *pdev, |
| 24 | const struct pci_device_id *id) |
| 25 | { |
| 26 | struct intel_lpss_platform_info *info; |
| 27 | int ret; |
| 28 | |
| 29 | ret = pcim_enable_device(pdev); |
| 30 | if (ret) |
| 31 | return ret; |
| 32 | |
| 33 | info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info), |
| 34 | GFP_KERNEL); |
| 35 | if (!info) |
| 36 | return -ENOMEM; |
| 37 | |
| 38 | info->mem = &pdev->resource[0]; |
| 39 | info->irq = pdev->irq; |
| 40 | |
| 41 | /* Probably it is enough to set this for iDMA capable devices only */ |
| 42 | pci_set_master(pdev); |
| 43 | |
| 44 | ret = intel_lpss_probe(&pdev->dev, info); |
| 45 | if (ret) |
| 46 | return ret; |
| 47 | |
| 48 | pm_runtime_put(&pdev->dev); |
| 49 | pm_runtime_allow(&pdev->dev); |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static void intel_lpss_pci_remove(struct pci_dev *pdev) |
| 55 | { |
| 56 | pm_runtime_forbid(&pdev->dev); |
| 57 | pm_runtime_get_sync(&pdev->dev); |
| 58 | |
| 59 | intel_lpss_remove(&pdev->dev); |
| 60 | } |
| 61 | |
| 62 | static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops); |
| 63 | |
| 64 | static const struct intel_lpss_platform_info spt_info = { |
| 65 | .clk_rate = 120000000, |
| 66 | }; |
| 67 | |
| 68 | static const struct intel_lpss_platform_info spt_uart_info = { |
| 69 | .clk_rate = 120000000, |
| 70 | .clk_con_id = "baudclk", |
| 71 | }; |
| 72 | |
| 73 | static const struct pci_device_id intel_lpss_pci_ids[] = { |
| 74 | /* SPT-LP */ |
| 75 | { PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info }, |
| 76 | { PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info }, |
| 77 | { PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info }, |
| 78 | { PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info }, |
| 79 | { PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_info }, |
| 80 | { PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_info }, |
| 81 | { PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_info }, |
| 82 | { PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_info }, |
| 83 | { PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_info }, |
| 84 | { PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_info }, |
| 85 | { PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info }, |
| 86 | /* SPT-H */ |
| 87 | { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info }, |
| 88 | { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info }, |
| 89 | { PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info }, |
| 90 | { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info }, |
| 91 | { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_info }, |
| 92 | { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_info }, |
| 93 | { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info }, |
| 94 | { } |
| 95 | }; |
| 96 | MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids); |
| 97 | |
| 98 | static struct pci_driver intel_lpss_pci_driver = { |
| 99 | .name = "intel-lpss", |
| 100 | .id_table = intel_lpss_pci_ids, |
| 101 | .probe = intel_lpss_pci_probe, |
| 102 | .remove = intel_lpss_pci_remove, |
| 103 | .driver = { |
| 104 | .pm = &intel_lpss_pci_pm_ops, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | module_pci_driver(intel_lpss_pci_driver); |
| 109 | |
| 110 | MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); |
| 111 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); |
| 112 | MODULE_DESCRIPTION("Intel LPSS PCI driver"); |
| 113 | MODULE_LICENSE("GPL v2"); |