0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/acpi.h>
0011 #include <linux/kernel.h>
0012 #include <linux/module.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/pm_runtime.h>
0015
0016 #include "pwm-lpss.h"
0017
0018
0019 static const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
0020 .clk_rate = 25000000,
0021 .npwm = 1,
0022 .base_unit_bits = 16,
0023 };
0024
0025
0026 static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
0027 .clk_rate = 19200000,
0028 .npwm = 1,
0029 .base_unit_bits = 16,
0030 .other_devices_aml_touches_pwm_regs = true,
0031 };
0032
0033
0034 static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
0035 .clk_rate = 19200000,
0036 .npwm = 4,
0037 .base_unit_bits = 22,
0038 .bypass = true,
0039 };
0040
0041 static int pwm_lpss_probe_platform(struct platform_device *pdev)
0042 {
0043 const struct pwm_lpss_boardinfo *info;
0044 const struct acpi_device_id *id;
0045 struct pwm_lpss_chip *lpwm;
0046 struct resource *r;
0047
0048 id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
0049 if (!id)
0050 return -ENODEV;
0051
0052 info = (const struct pwm_lpss_boardinfo *)id->driver_data;
0053 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
0054
0055 lpwm = pwm_lpss_probe(&pdev->dev, r, info);
0056 if (IS_ERR(lpwm))
0057 return PTR_ERR(lpwm);
0058
0059 platform_set_drvdata(pdev, lpwm);
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076 if (info->other_devices_aml_touches_pwm_regs)
0077 dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE|
0078 DPM_FLAG_SMART_SUSPEND);
0079
0080 pm_runtime_set_active(&pdev->dev);
0081 pm_runtime_enable(&pdev->dev);
0082
0083 return 0;
0084 }
0085
0086 static int pwm_lpss_remove_platform(struct platform_device *pdev)
0087 {
0088 pm_runtime_disable(&pdev->dev);
0089 return 0;
0090 }
0091
0092 static const struct acpi_device_id pwm_lpss_acpi_match[] = {
0093 { "80860F09", (unsigned long)&pwm_lpss_byt_info },
0094 { "80862288", (unsigned long)&pwm_lpss_bsw_info },
0095 { "80862289", (unsigned long)&pwm_lpss_bsw_info },
0096 { "80865AC8", (unsigned long)&pwm_lpss_bxt_info },
0097 { },
0098 };
0099 MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
0100
0101 static struct platform_driver pwm_lpss_driver_platform = {
0102 .driver = {
0103 .name = "pwm-lpss",
0104 .acpi_match_table = pwm_lpss_acpi_match,
0105 },
0106 .probe = pwm_lpss_probe_platform,
0107 .remove = pwm_lpss_remove_platform,
0108 };
0109 module_platform_driver(pwm_lpss_driver_platform);
0110
0111 MODULE_DESCRIPTION("PWM platform driver for Intel LPSS");
0112 MODULE_LICENSE("GPL v2");
0113 MODULE_ALIAS("platform:pwm-lpss");