acpi_platform.c (0d4a42f6bd298e826620585e766a154ab460617a) acpi_platform.c (f58b082aed43400c03e53beacc50a9f9eb23ac91)
1/*
2 * ACPI support for platform bus type.
3 *
4 * Copyright (C) 2012, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Mathias Nyman <mathias.nyman@linux.intel.com>
7 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 *

--- 8 unchanged lines hidden (view full) ---

17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20
21#include "internal.h"
22
23ACPI_MODULE_NAME("platform");
24
1/*
2 * ACPI support for platform bus type.
3 *
4 * Copyright (C) 2012, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Mathias Nyman <mathias.nyman@linux.intel.com>
7 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8 *

--- 8 unchanged lines hidden (view full) ---

17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20
21#include "internal.h"
22
23ACPI_MODULE_NAME("platform");
24
25/* Flags for acpi_create_platform_device */
26#define ACPI_PLATFORM_CLK BIT(0)
27
28/*
29 * The following ACPI IDs are known to be suitable for representing as
30 * platform devices.
31 */
32static const struct acpi_device_id acpi_platform_device_ids[] = {
33
34 { "PNP0D40" },
35
25/*
26 * The following ACPI IDs are known to be suitable for representing as
27 * platform devices.
28 */
29static const struct acpi_device_id acpi_platform_device_ids[] = {
30
31 { "PNP0D40" },
32
36 /* Haswell LPSS devices */
37 { "INT33C0", ACPI_PLATFORM_CLK },
38 { "INT33C1", ACPI_PLATFORM_CLK },
39 { "INT33C2", ACPI_PLATFORM_CLK },
40 { "INT33C3", ACPI_PLATFORM_CLK },
41 { "INT33C4", ACPI_PLATFORM_CLK },
42 { "INT33C5", ACPI_PLATFORM_CLK },
43 { "INT33C6", ACPI_PLATFORM_CLK },
44 { "INT33C7", ACPI_PLATFORM_CLK },
45
46 { }
47};
48
33 { }
34};
35
49static int acpi_create_platform_clks(struct acpi_device *adev)
50{
51 static struct platform_device *pdev;
52
53 /* Create Lynxpoint LPSS clocks */
54 if (!pdev && !strncmp(acpi_device_hid(adev), "INT33C", 6)) {
55 pdev = platform_device_register_simple("clk-lpt", -1, NULL, 0);
56 if (IS_ERR(pdev))
57 return PTR_ERR(pdev);
58 }
59
60 return 0;
61}
62
63/**
64 * acpi_create_platform_device - Create platform device for ACPI device node
65 * @adev: ACPI device node to create a platform device for.
66 * @id: ACPI device ID used to match @adev.
67 *
68 * Check if the given @adev can be represented as a platform device and, if
69 * that's the case, create and register a platform device, populate its common
70 * resources and returns a pointer to it. Otherwise, return %NULL.
71 *
72 * Name of the platform device will be the same as @adev's.
73 */
36/**
37 * acpi_create_platform_device - Create platform device for ACPI device node
38 * @adev: ACPI device node to create a platform device for.
39 * @id: ACPI device ID used to match @adev.
40 *
41 * Check if the given @adev can be represented as a platform device and, if
42 * that's the case, create and register a platform device, populate its common
43 * resources and returns a pointer to it. Otherwise, return %NULL.
44 *
45 * Name of the platform device will be the same as @adev's.
46 */
74static int acpi_create_platform_device(struct acpi_device *adev,
75 const struct acpi_device_id *id)
47int acpi_create_platform_device(struct acpi_device *adev,
48 const struct acpi_device_id *id)
76{
49{
77 unsigned long flags = id->driver_data;
78 struct platform_device *pdev = NULL;
79 struct acpi_device *acpi_parent;
80 struct platform_device_info pdevinfo;
81 struct resource_list_entry *rentry;
82 struct list_head resource_list;
83 struct resource *resources;
84 int count;
85
50 struct platform_device *pdev = NULL;
51 struct acpi_device *acpi_parent;
52 struct platform_device_info pdevinfo;
53 struct resource_list_entry *rentry;
54 struct list_head resource_list;
55 struct resource *resources;
56 int count;
57
86 if (flags & ACPI_PLATFORM_CLK) {
87 int ret = acpi_create_platform_clks(adev);
88 if (ret) {
89 dev_err(&adev->dev, "failed to create clocks\n");
90 return ret;
91 }
92 }
93
94 /* If the ACPI node already has a physical device attached, skip it. */
95 if (adev->physical_node_count)
96 return 0;
97
98 INIT_LIST_HEAD(&resource_list);
99 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
100 if (count <= 0)
101 return 0;

--- 63 unchanged lines hidden ---
58 /* If the ACPI node already has a physical device attached, skip it. */
59 if (adev->physical_node_count)
60 return 0;
61
62 INIT_LIST_HEAD(&resource_list);
63 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
64 if (count <= 0)
65 return 0;

--- 63 unchanged lines hidden ---