blob: c93921d5cc209513d7e9f766f3d4b35f4b8ff475 [file] [log] [blame]
Kevin Hilman6f88e9b2010-07-26 16:34:31 -06001/*
2 * pm.c - Common OMAP2+ power management-related code
3 *
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Copyright (C) 2010 Nokia Corporation
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#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/io.h>
15#include <linux/err.h>
16
17#include <plat/omap-pm.h>
18#include <plat/omap_device.h>
19#include <plat/common.h>
20
21static struct omap_device_pm_latency *pm_lats;
22
23static struct device *mpu_dev;
Thara Gopinathb3294e22010-09-01 13:44:53 +053024static struct device *iva_dev;
Kevin Hilman6f88e9b2010-07-26 16:34:31 -060025static struct device *l3_dev;
Thara Gopinathb3294e22010-09-01 13:44:53 +053026static struct device *dsp_dev;
Kevin Hilman6f88e9b2010-07-26 16:34:31 -060027
28struct device *omap2_get_mpuss_device(void)
29{
30 WARN_ON_ONCE(!mpu_dev);
31 return mpu_dev;
32}
33
Thara Gopinathb3294e22010-09-01 13:44:53 +053034struct device *omap2_get_iva_device(void)
Kevin Hilman6f88e9b2010-07-26 16:34:31 -060035{
Thara Gopinathb3294e22010-09-01 13:44:53 +053036 WARN_ON_ONCE(!iva_dev);
37 return iva_dev;
Kevin Hilman6f88e9b2010-07-26 16:34:31 -060038}
39
40struct device *omap2_get_l3_device(void)
41{
42 WARN_ON_ONCE(!l3_dev);
43 return l3_dev;
44}
45
Thara Gopinathb3294e22010-09-01 13:44:53 +053046struct device *omap4_get_dsp_device(void)
47{
48 WARN_ON_ONCE(!dsp_dev);
49 return dsp_dev;
50}
51EXPORT_SYMBOL(omap4_get_dsp_device);
52
Kevin Hilman6f88e9b2010-07-26 16:34:31 -060053/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
54static int _init_omap_device(char *name, struct device **new_dev)
55{
56 struct omap_hwmod *oh;
57 struct omap_device *od;
58
59 oh = omap_hwmod_lookup(name);
60 if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
61 __func__, name))
62 return -ENODEV;
63
64 od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
65 if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
66 __func__, name))
67 return -ENODEV;
68
69 *new_dev = &od->pdev.dev;
70
71 return 0;
72}
73
74/*
75 * Build omap_devices for processors and bus.
76 */
77static void omap2_init_processor_devices(void)
78{
79 _init_omap_device("mpu", &mpu_dev);
Thara Gopinathb3294e22010-09-01 13:44:53 +053080 _init_omap_device("iva", &iva_dev);
81 if (cpu_is_omap44xx())
82 _init_omap_device("dsp", &dsp_dev);
Kevin Hilman6f88e9b2010-07-26 16:34:31 -060083 _init_omap_device("l3_main", &l3_dev);
84}
85
86static int __init omap2_common_pm_init(void)
87{
88 omap2_init_processor_devices();
89 omap_pm_if_init();
90
91 return 0;
92}
93device_initcall(omap2_common_pm_init);
94