Linux Audio

Check our new training course

Loading...
v5.9
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Intel Low Power Subsystem PWM controller PCI driver
  4 *
  5 * Copyright (C) 2014, Intel Corporation
  6 *
  7 * Derived from the original pwm-lpss.c
  8 */
  9
 10#include <linux/kernel.h>
 11#include <linux/module.h>
 12#include <linux/pci.h>
 13#include <linux/pm_runtime.h>
 14
 15#include "pwm-lpss.h"
 16
 17/* BayTrail */
 18static const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
 19	.clk_rate = 25000000,
 20	.npwm = 1,
 21	.base_unit_bits = 16,
 22};
 23
 24/* Braswell */
 25static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
 26	.clk_rate = 19200000,
 27	.npwm = 1,
 28	.base_unit_bits = 16,
 29};
 30
 31/* Broxton */
 32static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
 33	.clk_rate = 19200000,
 34	.npwm = 4,
 35	.base_unit_bits = 22,
 36	.bypass = true,
 37};
 38
 39/* Tangier */
 40static const struct pwm_lpss_boardinfo pwm_lpss_tng_info = {
 41	.clk_rate = 19200000,
 42	.npwm = 4,
 43	.base_unit_bits = 22,
 44};
 45
 46static int pwm_lpss_probe_pci(struct pci_dev *pdev,
 47			      const struct pci_device_id *id)
 48{
 49	const struct pwm_lpss_boardinfo *info;
 50	struct pwm_lpss_chip *lpwm;
 51	int err;
 52
 53	err = pcim_enable_device(pdev);
 54	if (err < 0)
 55		return err;
 56
 57	info = (struct pwm_lpss_boardinfo *)id->driver_data;
 58	lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info);
 59	if (IS_ERR(lpwm))
 60		return PTR_ERR(lpwm);
 61
 62	pci_set_drvdata(pdev, lpwm);
 
 
 
 63
 64	pm_runtime_put(&pdev->dev);
 65	pm_runtime_allow(&pdev->dev);
 66
 67	return 0;
 68}
 69
 70static void pwm_lpss_remove_pci(struct pci_dev *pdev)
 71{
 72	struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev);
 73
 74	pm_runtime_forbid(&pdev->dev);
 75	pm_runtime_get_sync(&pdev->dev);
 76
 77	pwm_lpss_remove(lpwm);
 78}
 79
 80#ifdef CONFIG_PM
 81static int pwm_lpss_runtime_suspend_pci(struct device *dev)
 82{
 83	/*
 84	 * The PCI core will handle transition to D3 automatically. We only
 85	 * need to provide runtime PM hooks for that to happen.
 86	 */
 87	return 0;
 88}
 89
 90static int pwm_lpss_runtime_resume_pci(struct device *dev)
 91{
 92	return 0;
 93}
 94#endif
 95
 96static const struct dev_pm_ops pwm_lpss_pci_pm = {
 97	SET_RUNTIME_PM_OPS(pwm_lpss_runtime_suspend_pci,
 98			   pwm_lpss_runtime_resume_pci, NULL)
 99};
100
101static const struct pci_device_id pwm_lpss_pci_ids[] = {
102	{ PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info},
103	{ PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
104	{ PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
105	{ PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info},
106	{ PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
107	{ PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
108	{ PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
109	{ PCI_VDEVICE(INTEL, 0x31c8), (unsigned long)&pwm_lpss_bxt_info},
110	{ PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info},
111	{ },
112};
113MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids);
114
115static struct pci_driver pwm_lpss_driver_pci = {
116	.name = "pwm-lpss",
117	.id_table = pwm_lpss_pci_ids,
118	.probe = pwm_lpss_probe_pci,
119	.remove = pwm_lpss_remove_pci,
120	.driver = {
121		.pm = &pwm_lpss_pci_pm,
122	},
123};
124module_pci_driver(pwm_lpss_driver_pci);
125
126MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS");
127MODULE_LICENSE("GPL v2");
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * Intel Low Power Subsystem PWM controller PCI driver
 4 *
 5 * Copyright (C) 2014, Intel Corporation
 6 *
 7 * Derived from the original pwm-lpss.c
 8 */
 9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/pci.h>
13#include <linux/pm_runtime.h>
14
15#include "pwm-lpss.h"
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17static int pwm_lpss_probe_pci(struct pci_dev *pdev,
18			      const struct pci_device_id *id)
19{
20	const struct pwm_lpss_boardinfo *info;
21	struct pwm_chip *chip;
22	int err;
23
24	err = pcim_enable_device(pdev);
25	if (err < 0)
26		return err;
27
28	err = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
29	if (err)
30		return err;
 
31
32	info = (struct pwm_lpss_boardinfo *)id->driver_data;
33	chip = devm_pwm_lpss_probe(&pdev->dev, pcim_iomap_table(pdev)[0], info);
34	if (IS_ERR(chip))
35		return PTR_ERR(chip);
36
37	pm_runtime_put(&pdev->dev);
38	pm_runtime_allow(&pdev->dev);
39
40	return 0;
41}
42
43static void pwm_lpss_remove_pci(struct pci_dev *pdev)
44{
 
 
45	pm_runtime_forbid(&pdev->dev);
46	pm_runtime_get_sync(&pdev->dev);
 
 
 
 
 
 
 
 
 
 
 
 
47}
48
 
 
 
 
 
 
 
 
 
 
 
49static const struct pci_device_id pwm_lpss_pci_ids[] = {
50	{ PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info},
51	{ PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
52	{ PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
53	{ PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info},
54	{ PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
55	{ PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
56	{ PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
57	{ PCI_VDEVICE(INTEL, 0x31c8), (unsigned long)&pwm_lpss_bxt_info},
58	{ PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info},
59	{ },
60};
61MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids);
62
63static struct pci_driver pwm_lpss_driver_pci = {
64	.name = "pwm-lpss",
65	.id_table = pwm_lpss_pci_ids,
66	.probe = pwm_lpss_probe_pci,
67	.remove = pwm_lpss_remove_pci,
 
 
 
68};
69module_pci_driver(pwm_lpss_driver_pci);
70
71MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS");
72MODULE_LICENSE("GPL v2");
73MODULE_IMPORT_NS("PWM_LPSS");