Thermal/int340x/processor_thermal: Add thermal zone support
[linux-2.6-block.git] / drivers / thermal / int340x_thermal / int3402_thermal.c
CommitLineData
77e337c6
AL
1/*
2 * INT3402 thermal driver for memory temperature reporting
3 *
4 * Copyright (C) 2014, Intel Corporation
5 * Authors: Aaron Lu <aaron.lu@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12
13#include <linux/module.h>
14#include <linux/platform_device.h>
15#include <linux/acpi.h>
16#include <linux/thermal.h>
820cdeba 17#include "int340x_thermal_zone.h"
77e337c6
AL
18
19struct int3402_thermal_data {
77e337c6 20 acpi_handle *handle;
820cdeba 21 struct int34x_thermal_zone *int340x_zone;
77e337c6
AL
22};
23
77e337c6
AL
24static int int3402_thermal_probe(struct platform_device *pdev)
25{
26 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
27 struct int3402_thermal_data *d;
77e337c6
AL
28
29 if (!acpi_has_method(adev->handle, "_TMP"))
30 return -ENODEV;
31
32 d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL);
33 if (!d)
34 return -ENOMEM;
35
820cdeba
SP
36 d->int340x_zone = int340x_thermal_zone_add(adev, NULL);
37 if (IS_ERR(d->int340x_zone))
38 return PTR_ERR(d->int340x_zone);
39
40 d->handle = adev->handle;
41 platform_set_drvdata(pdev, d);
77e337c6
AL
42
43 return 0;
44}
45
46static int int3402_thermal_remove(struct platform_device *pdev)
47{
820cdeba
SP
48 struct int3402_thermal_data *d = platform_get_drvdata(pdev);
49
50 int340x_thermal_zone_remove(d->int340x_zone);
77e337c6 51
77e337c6
AL
52 return 0;
53}
54
55static const struct acpi_device_id int3402_thermal_match[] = {
56 {"INT3402", 0},
57 {}
58};
59
60MODULE_DEVICE_TABLE(acpi, int3402_thermal_match);
61
62static struct platform_driver int3402_thermal_driver = {
63 .probe = int3402_thermal_probe,
64 .remove = int3402_thermal_remove,
65 .driver = {
66 .name = "int3402 thermal",
77e337c6
AL
67 .acpi_match_table = int3402_thermal_match,
68 },
69};
70
71module_platform_driver(int3402_thermal_driver);
72
73MODULE_DESCRIPTION("INT3402 Thermal driver");
74MODULE_LICENSE("GPL");