blob: 6c26dc15815c94ed2e1b051becc5d53167cbec27 [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>
Tony Lindgrendad2d9e2013-02-09 19:20:57 -080015#include "soc.h"
Jean Pihetb86aeaf2012-04-25 16:06:20 +053016#include "voltage.h"
Thara Gopinathfa765822010-05-29 22:02:25 +053017
Jean Pihet80821c92012-04-24 10:22:12 +053018static int sr_class3_enable(struct omap_sr *sr)
Thara Gopinathfa765822010-05-29 22:02:25 +053019{
Jean Pihet80821c92012-04-24 10:22:12 +053020 unsigned long volt = voltdm_get_voltage(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053021
22 if (!volt) {
Jean Pihet8b765d72012-04-24 10:41:27 +053023 pr_warning("%s: Curr voltage unknown. Cannot enable %s\n",
24 __func__, sr->name);
Thara Gopinathfa765822010-05-29 22:02:25 +053025 return -ENODATA;
26 }
27
Jean Pihet80821c92012-04-24 10:22:12 +053028 omap_vp_enable(sr->voltdm);
29 return sr_enable(sr->voltdm, volt);
Thara Gopinathfa765822010-05-29 22:02:25 +053030}
31
Jean Pihet80821c92012-04-24 10:22:12 +053032static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
Thara Gopinathfa765822010-05-29 22:02:25 +053033{
Andrii Tseglytskyi3dfc35f2013-05-27 14:09:22 +030034 sr_disable_errgen(sr);
Jean Pihet80821c92012-04-24 10:22:12 +053035 omap_vp_disable(sr->voltdm);
36 sr_disable(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053037 if (is_volt_reset)
Jean Pihet80821c92012-04-24 10:22:12 +053038 voltdm_reset(sr->voltdm);
Thara Gopinathfa765822010-05-29 22:02:25 +053039
40 return 0;
41}
42
Jean Pihet80821c92012-04-24 10:22:12 +053043static int sr_class3_configure(struct omap_sr *sr)
Thara Gopinathfa765822010-05-29 22:02:25 +053044{
Andrii Tseglytskyi3dfc35f2013-05-27 14:09:22 +030045 return sr_configure_errgen(sr);
Thara Gopinathfa765822010-05-29 22:02:25 +053046}
47
48/* SR class3 structure */
49static struct omap_sr_class_data class3_data = {
50 .enable = sr_class3_enable,
51 .disable = sr_class3_disable,
52 .configure = sr_class3_configure,
53 .class_type = SR_CLASS3,
54};
55
56/* Smartreflex Class3 init API to be called from board file */
57static int __init sr_class3_init(void)
58{
59 pr_info("SmartReflex Class3 initialized\n");
60 return sr_register_class(&class3_data);
61}
Tony Lindgrenb76c8b12013-01-11 11:24:18 -080062omap_late_initcall(sr_class3_init);