14b45efe8SAndy Shevchenko /* 24b45efe8SAndy Shevchenko * Intel LPSS PCI support. 34b45efe8SAndy Shevchenko * 44b45efe8SAndy Shevchenko * Copyright (C) 2015, Intel Corporation 54b45efe8SAndy Shevchenko * 64b45efe8SAndy Shevchenko * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 74b45efe8SAndy Shevchenko * Mika Westerberg <mika.westerberg@linux.intel.com> 84b45efe8SAndy Shevchenko * 94b45efe8SAndy Shevchenko * This program is free software; you can redistribute it and/or modify 104b45efe8SAndy Shevchenko * it under the terms of the GNU General Public License version 2 as 114b45efe8SAndy Shevchenko * published by the Free Software Foundation. 124b45efe8SAndy Shevchenko */ 134b45efe8SAndy Shevchenko 144b45efe8SAndy Shevchenko #include <linux/ioport.h> 154b45efe8SAndy Shevchenko #include <linux/kernel.h> 164b45efe8SAndy Shevchenko #include <linux/module.h> 174b45efe8SAndy Shevchenko #include <linux/pci.h> 184b45efe8SAndy Shevchenko #include <linux/pm.h> 194b45efe8SAndy Shevchenko #include <linux/pm_runtime.h> 20028af594SMika Westerberg #include <linux/property.h> 214b45efe8SAndy Shevchenko 224b45efe8SAndy Shevchenko #include "intel-lpss.h" 234b45efe8SAndy Shevchenko 244b45efe8SAndy Shevchenko static int intel_lpss_pci_probe(struct pci_dev *pdev, 254b45efe8SAndy Shevchenko const struct pci_device_id *id) 264b45efe8SAndy Shevchenko { 274b45efe8SAndy Shevchenko struct intel_lpss_platform_info *info; 284b45efe8SAndy Shevchenko int ret; 294b45efe8SAndy Shevchenko 304b45efe8SAndy Shevchenko ret = pcim_enable_device(pdev); 314b45efe8SAndy Shevchenko if (ret) 324b45efe8SAndy Shevchenko return ret; 334b45efe8SAndy Shevchenko 344b45efe8SAndy Shevchenko info = devm_kmemdup(&pdev->dev, (void *)id->driver_data, sizeof(*info), 354b45efe8SAndy Shevchenko GFP_KERNEL); 364b45efe8SAndy Shevchenko if (!info) 374b45efe8SAndy Shevchenko return -ENOMEM; 384b45efe8SAndy Shevchenko 394b45efe8SAndy Shevchenko info->mem = &pdev->resource[0]; 404b45efe8SAndy Shevchenko info->irq = pdev->irq; 414b45efe8SAndy Shevchenko 424b45efe8SAndy Shevchenko /* Probably it is enough to set this for iDMA capable devices only */ 434b45efe8SAndy Shevchenko pci_set_master(pdev); 444b45efe8SAndy Shevchenko 454b45efe8SAndy Shevchenko ret = intel_lpss_probe(&pdev->dev, info); 464b45efe8SAndy Shevchenko if (ret) 474b45efe8SAndy Shevchenko return ret; 484b45efe8SAndy Shevchenko 494b45efe8SAndy Shevchenko pm_runtime_put(&pdev->dev); 504b45efe8SAndy Shevchenko pm_runtime_allow(&pdev->dev); 514b45efe8SAndy Shevchenko 524b45efe8SAndy Shevchenko return 0; 534b45efe8SAndy Shevchenko } 544b45efe8SAndy Shevchenko 554b45efe8SAndy Shevchenko static void intel_lpss_pci_remove(struct pci_dev *pdev) 564b45efe8SAndy Shevchenko { 574b45efe8SAndy Shevchenko pm_runtime_forbid(&pdev->dev); 584b45efe8SAndy Shevchenko pm_runtime_get_sync(&pdev->dev); 594b45efe8SAndy Shevchenko 604b45efe8SAndy Shevchenko intel_lpss_remove(&pdev->dev); 614b45efe8SAndy Shevchenko } 624b45efe8SAndy Shevchenko 634b45efe8SAndy Shevchenko static INTEL_LPSS_PM_OPS(intel_lpss_pci_pm_ops); 644b45efe8SAndy Shevchenko 654b45efe8SAndy Shevchenko static const struct intel_lpss_platform_info spt_info = { 664b45efe8SAndy Shevchenko .clk_rate = 120000000, 674b45efe8SAndy Shevchenko }; 684b45efe8SAndy Shevchenko 69028af594SMika Westerberg static struct property_entry spt_i2c_properties[] = { 70028af594SMika Westerberg PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 230), 71028af594SMika Westerberg { }, 72028af594SMika Westerberg }; 73028af594SMika Westerberg 74028af594SMika Westerberg static const struct intel_lpss_platform_info spt_i2c_info = { 75028af594SMika Westerberg .clk_rate = 120000000, 76f4d05266SHeikki Krogerus .properties = spt_i2c_properties, 77028af594SMika Westerberg }; 78028af594SMika Westerberg 79ec14c539SAndy Shevchenko static struct property_entry uart_properties[] = { 80ec14c539SAndy Shevchenko PROPERTY_ENTRY_U32("reg-io-width", 4), 81ec14c539SAndy Shevchenko PROPERTY_ENTRY_U32("reg-shift", 2), 82ec14c539SAndy Shevchenko PROPERTY_ENTRY_BOOL("snps,uart-16550-compatible"), 83ec14c539SAndy Shevchenko { }, 84ec14c539SAndy Shevchenko }; 85ec14c539SAndy Shevchenko 864b45efe8SAndy Shevchenko static const struct intel_lpss_platform_info spt_uart_info = { 874b45efe8SAndy Shevchenko .clk_rate = 120000000, 884b45efe8SAndy Shevchenko .clk_con_id = "baudclk", 89f4d05266SHeikki Krogerus .properties = uart_properties, 904b45efe8SAndy Shevchenko }; 914b45efe8SAndy Shevchenko 92ff0a04a6SAndy Shevchenko static const struct intel_lpss_platform_info bxt_info = { 93ff0a04a6SAndy Shevchenko .clk_rate = 100000000, 94ff0a04a6SAndy Shevchenko }; 95ff0a04a6SAndy Shevchenko 96ff0a04a6SAndy Shevchenko static const struct intel_lpss_platform_info bxt_uart_info = { 97ff0a04a6SAndy Shevchenko .clk_rate = 100000000, 98ff0a04a6SAndy Shevchenko .clk_con_id = "baudclk", 99f4d05266SHeikki Krogerus .properties = uart_properties, 100ff0a04a6SAndy Shevchenko }; 101ff0a04a6SAndy Shevchenko 1020343b2f4SMika Westerberg static struct property_entry bxt_i2c_properties[] = { 1030343b2f4SMika Westerberg PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 42), 1040343b2f4SMika Westerberg PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171), 1050343b2f4SMika Westerberg PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 208), 1060343b2f4SMika Westerberg { }, 1070343b2f4SMika Westerberg }; 1080343b2f4SMika Westerberg 109ff0a04a6SAndy Shevchenko static const struct intel_lpss_platform_info bxt_i2c_info = { 110ff0a04a6SAndy Shevchenko .clk_rate = 133000000, 111f4d05266SHeikki Krogerus .properties = bxt_i2c_properties, 112ff0a04a6SAndy Shevchenko }; 113ff0a04a6SAndy Shevchenko 114*77fc5ff6SMika Westerberg static const struct intel_lpss_platform_info kbl_info = { 115*77fc5ff6SMika Westerberg .clk_rate = 120000000, 116*77fc5ff6SMika Westerberg }; 117*77fc5ff6SMika Westerberg 118*77fc5ff6SMika Westerberg static const struct intel_lpss_platform_info kbl_uart_info = { 119*77fc5ff6SMika Westerberg .clk_rate = 120000000, 120*77fc5ff6SMika Westerberg .clk_con_id = "baudclk", 121*77fc5ff6SMika Westerberg }; 122*77fc5ff6SMika Westerberg 123*77fc5ff6SMika Westerberg static const struct intel_lpss_platform_info kbl_i2c_info = { 124*77fc5ff6SMika Westerberg .clk_rate = 133000000, 125*77fc5ff6SMika Westerberg }; 126*77fc5ff6SMika Westerberg 1274b45efe8SAndy Shevchenko static const struct pci_device_id intel_lpss_pci_ids[] = { 128023269ccSHuiquan Zhong /* BXT A-Step */ 129ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info }, 130ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0aae), (kernel_ulong_t)&bxt_i2c_info }, 131ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ab0), (kernel_ulong_t)&bxt_i2c_info }, 132ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ab2), (kernel_ulong_t)&bxt_i2c_info }, 133ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ab4), (kernel_ulong_t)&bxt_i2c_info }, 134ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ab6), (kernel_ulong_t)&bxt_i2c_info }, 135ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ab8), (kernel_ulong_t)&bxt_i2c_info }, 136ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0aba), (kernel_ulong_t)&bxt_i2c_info }, 137ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0abc), (kernel_ulong_t)&bxt_uart_info }, 138ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0abe), (kernel_ulong_t)&bxt_uart_info }, 139ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ac0), (kernel_ulong_t)&bxt_uart_info }, 140ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ac2), (kernel_ulong_t)&bxt_info }, 141ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ac4), (kernel_ulong_t)&bxt_info }, 142ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0ac6), (kernel_ulong_t)&bxt_info }, 143ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x0aee), (kernel_ulong_t)&bxt_uart_info }, 144023269ccSHuiquan Zhong /* BXT B-Step */ 145023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1aac), (kernel_ulong_t)&bxt_i2c_info }, 146023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1aae), (kernel_ulong_t)&bxt_i2c_info }, 147023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ab0), (kernel_ulong_t)&bxt_i2c_info }, 148023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ab2), (kernel_ulong_t)&bxt_i2c_info }, 149023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ab4), (kernel_ulong_t)&bxt_i2c_info }, 150023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ab6), (kernel_ulong_t)&bxt_i2c_info }, 151023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ab8), (kernel_ulong_t)&bxt_i2c_info }, 152023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1aba), (kernel_ulong_t)&bxt_i2c_info }, 153023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1abc), (kernel_ulong_t)&bxt_uart_info }, 154023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1abe), (kernel_ulong_t)&bxt_uart_info }, 155023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ac0), (kernel_ulong_t)&bxt_uart_info }, 156023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ac2), (kernel_ulong_t)&bxt_info }, 157023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ac4), (kernel_ulong_t)&bxt_info }, 158023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info }, 159023269ccSHuiquan Zhong { PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info }, 160023269ccSHuiquan Zhong 161ff0a04a6SAndy Shevchenko /* APL */ 162ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5aac), (kernel_ulong_t)&bxt_i2c_info }, 163ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5aae), (kernel_ulong_t)&bxt_i2c_info }, 164ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ab0), (kernel_ulong_t)&bxt_i2c_info }, 165ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ab2), (kernel_ulong_t)&bxt_i2c_info }, 166ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ab4), (kernel_ulong_t)&bxt_i2c_info }, 167ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ab6), (kernel_ulong_t)&bxt_i2c_info }, 168ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ab8), (kernel_ulong_t)&bxt_i2c_info }, 169ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5aba), (kernel_ulong_t)&bxt_i2c_info }, 170ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5abc), (kernel_ulong_t)&bxt_uart_info }, 171ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5abe), (kernel_ulong_t)&bxt_uart_info }, 172ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ac0), (kernel_ulong_t)&bxt_uart_info }, 173ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ac2), (kernel_ulong_t)&bxt_info }, 174ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ac4), (kernel_ulong_t)&bxt_info }, 175ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5ac6), (kernel_ulong_t)&bxt_info }, 176ff0a04a6SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x5aee), (kernel_ulong_t)&bxt_uart_info }, 1774b45efe8SAndy Shevchenko /* SPT-LP */ 1784b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x9d27), (kernel_ulong_t)&spt_uart_info }, 1794b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x9d28), (kernel_ulong_t)&spt_uart_info }, 1804b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x9d29), (kernel_ulong_t)&spt_info }, 1814b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x9d2a), (kernel_ulong_t)&spt_info }, 182028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0x9d60), (kernel_ulong_t)&spt_i2c_info }, 183028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0x9d61), (kernel_ulong_t)&spt_i2c_info }, 184028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0x9d62), (kernel_ulong_t)&spt_i2c_info }, 185028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0x9d63), (kernel_ulong_t)&spt_i2c_info }, 186028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0x9d64), (kernel_ulong_t)&spt_i2c_info }, 187028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0x9d65), (kernel_ulong_t)&spt_i2c_info }, 1884b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0x9d66), (kernel_ulong_t)&spt_uart_info }, 1894b45efe8SAndy Shevchenko /* SPT-H */ 1904b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info }, 1914b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info }, 1924b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0xa129), (kernel_ulong_t)&spt_info }, 1934b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0xa12a), (kernel_ulong_t)&spt_info }, 194028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0xa160), (kernel_ulong_t)&spt_i2c_info }, 195028af594SMika Westerberg { PCI_VDEVICE(INTEL, 0xa161), (kernel_ulong_t)&spt_i2c_info }, 1964b45efe8SAndy Shevchenko { PCI_VDEVICE(INTEL, 0xa166), (kernel_ulong_t)&spt_uart_info }, 197*77fc5ff6SMika Westerberg /* KBL-H */ 198*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2a7), (kernel_ulong_t)&kbl_uart_info }, 199*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2a8), (kernel_ulong_t)&kbl_uart_info }, 200*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2a9), (kernel_ulong_t)&kbl_info }, 201*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2aa), (kernel_ulong_t)&kbl_info }, 202*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2e0), (kernel_ulong_t)&kbl_i2c_info }, 203*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2e1), (kernel_ulong_t)&kbl_i2c_info }, 204*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2e2), (kernel_ulong_t)&kbl_i2c_info }, 205*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2e3), (kernel_ulong_t)&kbl_i2c_info }, 206*77fc5ff6SMika Westerberg { PCI_VDEVICE(INTEL, 0xa2e6), (kernel_ulong_t)&kbl_uart_info }, 2074b45efe8SAndy Shevchenko { } 2084b45efe8SAndy Shevchenko }; 2094b45efe8SAndy Shevchenko MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids); 2104b45efe8SAndy Shevchenko 2114b45efe8SAndy Shevchenko static struct pci_driver intel_lpss_pci_driver = { 2124b45efe8SAndy Shevchenko .name = "intel-lpss", 2134b45efe8SAndy Shevchenko .id_table = intel_lpss_pci_ids, 2144b45efe8SAndy Shevchenko .probe = intel_lpss_pci_probe, 2154b45efe8SAndy Shevchenko .remove = intel_lpss_pci_remove, 2164b45efe8SAndy Shevchenko .driver = { 2174b45efe8SAndy Shevchenko .pm = &intel_lpss_pci_pm_ops, 2184b45efe8SAndy Shevchenko }, 2194b45efe8SAndy Shevchenko }; 2204b45efe8SAndy Shevchenko 2214b45efe8SAndy Shevchenko module_pci_driver(intel_lpss_pci_driver); 2224b45efe8SAndy Shevchenko 2234b45efe8SAndy Shevchenko MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); 2244b45efe8SAndy Shevchenko MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); 2254b45efe8SAndy Shevchenko MODULE_DESCRIPTION("Intel LPSS PCI driver"); 2264b45efe8SAndy Shevchenko MODULE_LICENSE("GPL v2"); 227