Thara Gopinath | fa76582 | 2010-05-29 22:02:25 +0530 | [diff] [blame] | 1 | /* |
| 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 Pihet | b86aeaf | 2012-04-25 16:06:20 +0530 | [diff] [blame^] | 14 | #include <linux/power/smartreflex.h> |
| 15 | #include "voltage.h" |
Thara Gopinath | fa76582 | 2010-05-29 22:02:25 +0530 | [diff] [blame] | 16 | |
| 17 | static int sr_class3_enable(struct voltagedomain *voltdm) |
| 18 | { |
Kevin Hilman | d5c1282 | 2011-07-15 16:05:12 -0700 | [diff] [blame] | 19 | unsigned long volt = voltdm_get_voltage(voltdm); |
Thara Gopinath | fa76582 | 2010-05-29 22:02:25 +0530 | [diff] [blame] | 20 | |
| 21 | if (!volt) { |
| 22 | pr_warning("%s: Curr voltage unknown. Cannot enable sr_%s\n", |
| 23 | __func__, voltdm->name); |
| 24 | return -ENODATA; |
| 25 | } |
| 26 | |
| 27 | omap_vp_enable(voltdm); |
| 28 | return sr_enable(voltdm, volt); |
| 29 | } |
| 30 | |
| 31 | static int sr_class3_disable(struct voltagedomain *voltdm, int is_volt_reset) |
| 32 | { |
Nishanth Menon | ad54c3d | 2012-02-29 23:33:39 +0100 | [diff] [blame] | 33 | sr_disable_errgen(voltdm); |
Thara Gopinath | fa76582 | 2010-05-29 22:02:25 +0530 | [diff] [blame] | 34 | omap_vp_disable(voltdm); |
| 35 | sr_disable(voltdm); |
| 36 | if (is_volt_reset) |
Kevin Hilman | 5e5651b | 2011-04-05 16:27:21 -0700 | [diff] [blame] | 37 | voltdm_reset(voltdm); |
Thara Gopinath | fa76582 | 2010-05-29 22:02:25 +0530 | [diff] [blame] | 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static int sr_class3_configure(struct voltagedomain *voltdm) |
| 43 | { |
| 44 | return sr_configure_errgen(voltdm); |
| 45 | } |
| 46 | |
| 47 | /* SR class3 structure */ |
| 48 | static 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 */ |
| 56 | static int __init sr_class3_init(void) |
| 57 | { |
| 58 | pr_info("SmartReflex Class3 initialized\n"); |
| 59 | return sr_register_class(&class3_data); |
| 60 | } |
| 61 | late_initcall(sr_class3_init); |