// SPDX-License-Identifier: GPL-2.0+//// Copyright (c) 2012-2014 Samsung Electronics Co., Ltd// http://www.samsung.com#include<linux/bug.h>#include<linux/err.h>#include<linux/gpio/consumer.h>#include<linux/slab.h>#include<linux/module.h>#include<linux/of.h>#include<linux/regmap.h>#include<linux/platform_device.h>#include<linux/regulator/driver.h>#include<linux/regulator/machine.h>#include<linux/regulator/of_regulator.h>#include<linux/mfd/samsung/core.h>#include<linux/mfd/samsung/s2mps11.h>#include<linux/mfd/samsung/s2mps13.h>#include<linux/mfd/samsung/s2mps14.h>#include<linux/mfd/samsung/s2mps15.h>#include<linux/mfd/samsung/s2mpu02.h>/* The highest number of possible regulators for supported devices. */#define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAXstructs2mps11_info{intramp_delay2;intramp_delay34;intramp_delay5;intramp_delay16;intramp_delay7810;intramp_delay9;enumsec_device_typedev_type;/* * One bit for each S2MPS11/S2MPS13/S2MPS14/S2MPU02 regulator whether * the suspend mode was enabled. */DECLARE_BITMAP(suspend_state,S2MPS_REGULATOR_MAX);/* * Array (size: number of regulators) with GPIO-s for external * sleep control. */structgpio_desc**ext_control_gpiod;};staticintget_ramp_delay(intramp_delay){unsignedcharcnt=0;ramp_delay/=6250;while(true){ramp_delay=ramp_delay>>1;if(ramp_delay==0)break;cnt++;}if(cnt>3)cnt=3;returncnt;}staticints2mps11_regulator_set_voltage_time_sel(structregulator_dev*rdev,unsignedintold_selector,unsignedintnew_selector){structs2mps11_info*s2mps11=rdev_get_drvdata(rdev);intrdev_id=rdev_get_id(rdev);unsignedintramp_delay=0;intold_volt,new_volt;switch(rdev_id){caseS2MPS11_BUCK2:ramp_delay=s2mps11->ramp_delay2;break;caseS2MPS11_BUCK3:caseS2MPS11_BUCK4:ramp_delay=s2mps11->ramp_delay34;break;caseS2MPS11_BUCK5:ramp_delay=s2mps11->ramp_delay5;break;caseS2MPS11_BUCK6:caseS2MPS11_BUCK1:ramp_delay=s2mps11->ramp_delay16;break;caseS2MPS11_BUCK7:caseS2MPS11_BUCK8:caseS2MPS11_BUCK10:ramp_delay=s2mps11->ramp_delay7810;break;caseS2MPS11_BUCK9:ramp_delay=s2mps11->ramp_delay9;}if(ramp_delay==0)ramp_delay=rdev->desc->ramp_delay;old_volt=rdev->desc->min_uV+