blob: 7c18420c9ff6bd9fc50f813f6852a4cf322311b4 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Thara Gopinathfa765822010-05-29 22:02:25 +05302/*
3 * Smart reflex Class 3 specific implementations
4 *
5 * Author: Thara Gopinath <thara@ti.com>
6 *
7 * Copyright (C) 2010 Texas Instruments, Inc.
8 * Thara Gopinath <thara@ti.com>
Thara Gopinathfa765822010-05-29 22:02:25 +05309 */
10
Jean Pihetb86aeaf2012-04-25 16:06:20 +053011#include <linux/power/smartreflex.h>
Tony Lindgrendad2d9e2013-02-09 19:20:57 -080012#include "soc.h"
Jean Pihetb86aeaf2012-04-25 16:06:20 +053013#include "voltage.h"
Thara Gopinathfa765822010-05-29 22:02:25 +053014
Jean Pihet80821c92012-04-24 10:22:12 +053015static int sr_class3_enable(struct omap_sr *sr)
Thara Gopinathfa765822010-05-29 22:02:25 +053016{
Jean Pihet80821c92012-04-24 10:22:12 +053017 unsigned long volt = voltdm_get_voltage(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053018
19 if (!volt) {
Joe Perches3d0cb732014-09-13 11:31:16 -070020 pr_warn("%s: Curr voltage unknown. Cannot enable %s\n",
21 __func__, sr->name);
Thara Gopinathfa765822010-05-29 22:02:25 +053022 return -ENODATA;
23 }
24
Jean Pihet80821c92012-04-24 10:22:12 +053025 omap_vp_enable(sr->voltdm);
Andrii Tseglytskyi299066b2013-05-27 14:09:24 +030026 return sr_enable(sr, volt);
Thara Gopinathfa765822010-05-29 22:02:25 +053027}
28
Jean Pihet80821c92012-04-24 10:22:12 +053029static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
Thara Gopinathfa765822010-05-29 22:02:25 +053030{
Andrii Tseglytskyi3dfc35f2013-05-27 14:09:22 +030031 sr_disable_errgen(sr);
Jean Pihet80821c92012-04-24 10:22:12 +053032 omap_vp_disable(sr->voltdm);
Andrii Tseglytskyi299066b2013-05-27 14:09:24 +030033 sr_disable(sr);
Thara Gopinathfa765822010-05-29 22:02:25 +053034 if (is_volt_reset)
Jean Pihet80821c92012-04-24 10:22:12 +053035 voltdm_reset(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053036
37 return 0;
38}
39
Jean Pihet80821c92012-04-24 10:22:12 +053040static int sr_class3_configure(struct omap_sr *sr)
Thara Gopinathfa765822010-05-29 22:02:25 +053041{
Andrii Tseglytskyi3dfc35f2013-05-27 14:09:22 +030042 return sr_configure_errgen(sr);
Thara Gopinathfa765822010-05-29 22:02:25 +053043}
44
45/* SR class3 structure */
46static struct omap_sr_class_data class3_data = {
47 .enable = sr_class3_enable,
48 .disable = sr_class3_disable,
49 .configure = sr_class3_configure,
50 .class_type = SR_CLASS3,
51};
52
53/* Smartreflex Class3 init API to be called from board file */
54static int __init sr_class3_init(void)
55{
56 pr_info("SmartReflex Class3 initialized\n");
57 return sr_register_class(&class3_data);
58}
Tony Lindgrenb76c8b192013-01-11 11:24:18 -080059omap_late_initcall(sr_class3_init);