blob: 1da8f03c479e9940fe2f2ba7ab8a7b569e2a9691 [file] [log] [blame]
Thara Gopinathfa765822010-05-29 22:02:25 +05301/*
2 * Smart reflex Class 3 specific implementations
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
Jean Pihetb86aeaf2012-04-25 16:06:20 +053014#include <linux/power/smartreflex.h>
15#include "voltage.h"
Thara Gopinathfa765822010-05-29 22:02:25 +053016
Jean Pihet80821c92012-04-24 10:22:12 +053017static int sr_class3_enable(struct omap_sr *sr)
Thara Gopinathfa765822010-05-29 22:02:25 +053018{
Jean Pihet80821c92012-04-24 10:22:12 +053019 unsigned long volt = voltdm_get_voltage(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053020
21 if (!volt) {
Jean Pihet8b765d72012-04-24 10:41:27 +053022 pr_warning("%s: Curr voltage unknown. Cannot enable %s\n",
23 __func__, sr->name);
Thara Gopinathfa765822010-05-29 22:02:25 +053024 return -ENODATA;
25 }
26
Jean Pihet80821c92012-04-24 10:22:12 +053027 omap_vp_enable(sr->voltdm);
28 return sr_enable(sr->voltdm, volt);
Thara Gopinathfa765822010-05-29 22:02:25 +053029}
30
Jean Pihet80821c92012-04-24 10:22:12 +053031static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
Thara Gopinathfa765822010-05-29 22:02:25 +053032{
Jean Pihet80821c92012-04-24 10:22:12 +053033 sr_disable_errgen(sr->voltdm);
34 omap_vp_disable(sr->voltdm);
35 sr_disable(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053036 if (is_volt_reset)
Jean Pihet80821c92012-04-24 10:22:12 +053037 voltdm_reset(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053038
39 return 0;
40}
41
Jean Pihet80821c92012-04-24 10:22:12 +053042static int sr_class3_configure(struct omap_sr *sr)
Thara Gopinathfa765822010-05-29 22:02:25 +053043{
Jean Pihet80821c92012-04-24 10:22:12 +053044 return sr_configure_errgen(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053045}
46
47/* SR class3 structure */
48static struct omap_sr_class_data class3_data = {
49 .enable = sr_class3_enable,
50 .disable = sr_class3_disable,
51 .configure = sr_class3_configure,
52 .class_type = SR_CLASS3,
53};
54
55/* Smartreflex Class3 init API to be called from board file */
56static int __init sr_class3_init(void)
57{
58 pr_info("SmartReflex Class3 initialized\n");
59 return sr_register_class(&class3_data);
60}
61late_initcall(sr_class3_init);