aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/x86/Makefile2
-rw-r--r--drivers/clk/x86/clk-lpss.c99
-rw-r--r--drivers/clk/x86/clk-lpss.h36
-rw-r--r--drivers/clk/x86/clk-lpt.c40
4 files changed, 2 insertions, 175 deletions
diff --git a/drivers/clk/x86/Makefile b/drivers/clk/x86/Makefile
index f9ba4fab0ddc..04781389d0fb 100644
--- a/drivers/clk/x86/Makefile
+++ b/drivers/clk/x86/Makefile
@@ -1,2 +1,2 @@
1clk-x86-lpss-objs := clk-lpss.o clk-lpt.o 1clk-x86-lpss-objs := clk-lpt.o
2obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o 2obj-$(CONFIG_X86_INTEL_LPSS) += clk-x86-lpss.o
diff --git a/drivers/clk/x86/clk-lpss.c b/drivers/clk/x86/clk-lpss.c
deleted file mode 100644
index b5e229f3c3d9..000000000000
--- a/drivers/clk/x86/clk-lpss.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * Intel Low Power Subsystem clocks.
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Heikki Krogerus <heikki.krogerus@linux.intel.com>
7 *
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.
11 */
12
13#include <linux/acpi.h>
14#include <linux/clk.h>
15#include <linux/clk-provider.h>
16#include <linux/err.h>
17#include <linux/io.h>
18#include <linux/module.h>
19
20static int clk_lpss_is_mmio_resource(struct acpi_resource *res, void *data)
21{
22 struct resource r;
23 return !acpi_dev_resource_memory(res, &r);
24}
25
26static acpi_status clk_lpss_find_mmio(acpi_handle handle, u32 level,
27 void *data, void **retval)
28{
29 struct resource_list_entry *rentry;
30 struct list_head resource_list;
31 struct acpi_device *adev;
32 const char *uid = data;
33 int ret;
34
35 if (acpi_bus_get_device(handle, &adev))
36 return AE_OK;
37
38 if (uid) {
39 if (!adev->pnp.unique_id)
40 return AE_OK;
41 if (strcmp(uid, adev->pnp.unique_id))
42 return AE_OK;
43 }
44
45 INIT_LIST_HEAD(&resource_list);
46 ret = acpi_dev_get_resources(adev, &resource_list,
47 clk_lpss_is_mmio_resource, NULL);
48 if (ret < 0)
49 return AE_NO_MEMORY;
50
51 list_for_each_entry(rentry, &resource_list, node)
52 if (resource_type(&rentry->res) == IORESOURCE_MEM) {
53 *(struct resource *)retval = rentry->res;
54 break;
55 }
56
57 acpi_dev_free_resource_list(&resource_list);
58 return AE_OK;
59}
60
61/**
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
68 *
69 * Creates and registers LPSS clock gate.
70 */
71struct clk *clk_register_lpss_gate(const char *name, const char *parent_name,
72 const char *hid, const char *uid,
73 unsigned offset)
74{
75 struct resource res = { };
76 void __iomem *mmio_base;
77 acpi_status status;
78 struct clk *clk;
79
80 /*
81 * First try to look the device and its mmio resource from the
82 * ACPI namespace.
83 */
84 status = acpi_get_devices(hid, clk_lpss_find_mmio, (void *)uid,
85 (void **)&res);
86 if (ACPI_FAILURE(status) || !res.start)
87 return ERR_PTR(-ENODEV);
88
89 mmio_base = ioremap(res.start, resource_size(&res));
90 if (!mmio_base)
91 return ERR_PTR(-ENOMEM);
92
93 clk = clk_register_gate(NULL, name, parent_name, 0, mmio_base + offset,
94 0, 0, NULL);
95 if (IS_ERR(clk))
96 iounmap(mmio_base);
97
98 return clk;
99}
diff --git a/drivers/clk/x86/clk-lpss.h b/drivers/clk/x86/clk-lpss.h
deleted file mode 100644
index e9460f442297..000000000000
--- a/drivers/clk/x86/clk-lpss.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Intel Low Power Subsystem clock.
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Authors: Mika Westerberg <mika.westerberg@linux.intel.com>
6 * Heikki Krogerus <heikki.krogerus@linux.intel.com>
7 *
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.
11 */
12
13#ifndef __CLK_LPSS_H
14#define __CLK_LPSS_H
15
16#include <linux/err.h>
17#include <linux/errno.h>
18#include <linux/clk.h>
19
20#ifdef CONFIG_ACPI
21extern struct clk *clk_register_lpss_gate(const char *name,
22 const char *parent_name,
23 const char *hid, const char *uid,
24 unsigned offset);
25#else
26static inline struct clk *clk_register_lpss_gate(const char *name,
27 const char *parent_name,
28 const char *hid,
29 const char *uid,
30 unsigned offset)
31{
32 return ERR_PTR(-ENODEV);
33}
34#endif
35
36#endif /* __CLK_LPSS_H */
diff --git a/drivers/clk/x86/clk-lpt.c b/drivers/clk/x86/clk-lpt.c
index 81298aeef7e3..5cf4f4686406 100644
--- a/drivers/clk/x86/clk-lpt.c
+++ b/drivers/clk/x86/clk-lpt.c
@@ -10,7 +10,6 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/acpi.h>
14#include <linux/clk.h> 13#include <linux/clk.h>
15#include <linux/clkdev.h> 14#include <linux/clkdev.h>
16#include <linux/clk-provider.h> 15#include <linux/clk-provider.h>
@@ -18,8 +17,6 @@
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/platform_device.h> 18#include <linux/platform_device.h>
20 19
21#include "clk-lpss.h"
22
23#define PRV_CLOCK_PARAMS 0x800 20#define PRV_CLOCK_PARAMS 0x800
24 21
25static int lpt_clk_probe(struct platform_device *pdev) 22static int lpt_clk_probe(struct platform_device *pdev)
@@ -34,40 +31,6 @@ static int lpt_clk_probe(struct platform_device *pdev)
34 31
35 /* Shared DMA clock */ 32 /* Shared DMA clock */
36 clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto"); 33 clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto");
37
38 /* SPI clocks */
39 clk = clk_register_lpss_gate("spi0_clk", "lpss_clk", "INT33C0", NULL,
40 PRV_CLOCK_PARAMS);
41 if (!IS_ERR(clk))
42 clk_register_clkdev(clk, NULL, "INT33C0:00");
43
44 clk = clk_register_lpss_gate("spi1_clk", "lpss_clk", "INT33C1", NULL,
45 PRV_CLOCK_PARAMS);
46 if (!IS_ERR(clk))
47 clk_register_clkdev(clk, NULL, "INT33C1:00");
48
49 /* I2C clocks */
50 clk = clk_register_lpss_gate("i2c0_clk", "lpss_clk", "INT33C2", NULL,
51 PRV_CLOCK_PARAMS);
52 if (!IS_ERR(clk))
53 clk_register_clkdev(clk, NULL, "INT33C2:00");
54
55 clk = clk_register_lpss_gate("i2c1_clk", "lpss_clk", "INT33C3", NULL,
56 PRV_CLOCK_PARAMS);
57 if (!IS_ERR(clk))
58 clk_register_clkdev(clk, NULL, "INT33C3:00");
59
60 /* UART clocks */
61 clk = clk_register_lpss_gate("uart0_clk", "lpss_clk", "INT33C4", NULL,
62 PRV_CLOCK_PARAMS);
63 if (!IS_ERR(clk))
64 clk_register_clkdev(clk, NULL, "INT33C4:00");
65
66 clk = clk_register_lpss_gate("uart1_clk", "lpss_clk", "INT33C5", NULL,
67 PRV_CLOCK_PARAMS);
68 if (!IS_ERR(clk))
69 clk_register_clkdev(clk, NULL, "INT33C5:00");
70
71 return 0; 34 return 0;
72} 35}
73 36
@@ -79,8 +42,7 @@ static struct platform_driver lpt_clk_driver = {
79 .probe = lpt_clk_probe, 42 .probe = lpt_clk_probe,
80}; 43};
81 44
82static int __init lpt_clk_init(void) 45int __init lpt_clk_init(void)
83{ 46{
84 return platform_driver_register(&lpt_clk_driver); 47 return platform_driver_register(&lpt_clk_driver);
85} 48}
86arch_initcall(lpt_clk_init);