Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Smart reflex Class 3 specific implementations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Author: Thara Gopinath       <thara@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright (C) 2010 Texas Instruments, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * Thara Gopinath <thara@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/power/smartreflex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "soc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "voltage.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int sr_class3_enable(struct omap_sr *sr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	unsigned long volt = voltdm_get_voltage(sr->voltdm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	if (!volt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		pr_warn("%s: Curr voltage unknown. Cannot enable %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 			__func__, sr->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 		return -ENODATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	omap_vp_enable(sr->voltdm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	return sr_enable(sr, volt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	sr_disable_errgen(sr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	omap_vp_disable(sr->voltdm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	sr_disable(sr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	if (is_volt_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		voltdm_reset(sr->voltdm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static int sr_class3_configure(struct omap_sr *sr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	return sr_configure_errgen(sr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* SR class3 structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static struct omap_sr_class_data class3_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	.enable = sr_class3_enable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	.disable = sr_class3_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	.configure = sr_class3_configure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	.class_type = SR_CLASS3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Smartreflex Class3 init API to be called from board file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static int __init sr_class3_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	pr_info("SmartReflex Class3 initialized\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	return sr_register_class(&class3_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) omap_late_initcall(sr_class3_init);