2 * OMAP SoC specific OPP wrapper function
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated - http://www.ti.com/
7 * Copyright (C) 2010 Nokia Corporation.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
15 * kind, whether express or implied; without even the implied warranty
16 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 #include <linux/module.h>
21 #include <linux/pm_opp.h>
22 #include <linux/cpu.h>
24 #include "omap_device.h"
26 #include "omap_opp_data.h"
28 /* Temp variable to allow multiple calls */
29 static u8 __initdata omap_table_init
;
32 * omap_init_opp_table() - Initialize opp table as per the CPU type
33 * @opp_def: opp default list for this silicon
34 * @opp_def_size: number of opp entries for this silicon
36 * Register the initial OPP table with the OPP library based on the CPU
37 * type. This is meant to be used only by SoC specific registration.
39 int __init
omap_init_opp_table(struct omap_opp_def
*opp_def
,
44 if (of_have_populated_dt())
47 if (!opp_def
|| !opp_def_size
) {
48 pr_err("%s: invalid params!\n", __func__
);
53 * Initialize only if not already initialized even if the previous
54 * call failed, because, no reason we'd succeed again.
60 /* Lets now register with OPP library */
61 for (i
= 0; i
< opp_def_size
; i
++, opp_def
++) {
62 struct omap_hwmod
*oh
;
65 if (!opp_def
->hwmod_name
) {
66 pr_err("%s: NULL name of omap_hwmod, failing [%d].\n",
71 if (!strncmp(opp_def
->hwmod_name
, "mpu", 3)) {
73 * All current OMAPs share voltage rail and
74 * clock source, so CPU0 is used to represent
77 dev
= get_cpu_device(0);
79 oh
= omap_hwmod_lookup(opp_def
->hwmod_name
);
81 pr_debug("%s: no hwmod or odev for %s, [%d] cannot add OPPs.\n",
82 __func__
, opp_def
->hwmod_name
, i
);
85 dev
= &oh
->od
->pdev
->dev
;
88 r
= dev_pm_opp_add(dev
, opp_def
->freq
, opp_def
->u_volt
);
90 dev_err(dev
, "%s: add OPP %ld failed for %s [%d] result=%d\n",
91 __func__
, opp_def
->freq
,
92 opp_def
->hwmod_name
, i
, r
);
94 if (!opp_def
->default_available
)
95 r
= dev_pm_opp_disable(dev
, opp_def
->freq
);
97 dev_err(dev
, "%s: disable %ld failed for %s [%d] result=%d\n",
98 __func__
, opp_def
->freq
,
99 opp_def
->hwmod_name
, i
, r
);