2 * Intel Low Power Subsystem clocks.
4 * Copyright (C) 2013, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Heikki Krogerus <heikki.krogerus@linux.intel.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/acpi.h>
14 #include <linux/clk.h>
15 #include <linux/clk-provider.h>
16 #include <linux/err.h>
18 #include <linux/module.h>
20 static int clk_lpss_is_mmio_resource(struct acpi_resource *res, void *data)
23 return !acpi_dev_resource_memory(res, &r);
26 static acpi_status clk_lpss_find_mmio(acpi_handle handle, u32 level,
27 void *data, void **retval)
29 struct resource_list_entry *rentry;
30 struct list_head resource_list;
31 struct acpi_device *adev;
32 const char *uid = data;
35 if (acpi_bus_get_device(handle, &adev))
39 if (!adev->pnp.unique_id)
41 if (strcmp(uid, adev->pnp.unique_id))
45 INIT_LIST_HEAD(&resource_list);
46 ret = acpi_dev_get_resources(adev, &resource_list,
47 clk_lpss_is_mmio_resource, NULL);
51 list_for_each_entry(rentry, &resource_list, node)
52 if (resource_type(&rentry->res) == IORESOURCE_MEM) {
53 *(struct resource *)retval = rentry->res;
57 acpi_dev_free_resource_list(&resource_list);
62 * clk_register_lpss_gate - register LPSS clock gate
63 * @name: name of this clock gate
64 * @parent_name: parent clock name
65 * @hid: ACPI _HID of the device
66 * @uid: ACPI _UID of the device (optional)
67 * @offset: LPSS PRV_CLOCK_PARAMS offset
69 * Creates and registers LPSS clock gate.
71 struct clk *clk_register_lpss_gate(const char *name, const char *parent_name,
72 const char *hid, const char *uid,
75 struct resource res = { };
76 void __iomem *mmio_base;
81 * First try to look the device and its mmio resource from the
84 status = acpi_get_devices(hid, clk_lpss_find_mmio, (void *)uid,
86 if (ACPI_FAILURE(status) || !res.start)
87 return ERR_PTR(-ENODEV);
89 mmio_base = ioremap(res.start, resource_size(&res));
91 return ERR_PTR(-ENOMEM);
93 clk = clk_register_gate(NULL, name, parent_name, 0, mmio_base + offset,