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)  * Regulator haptic driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Author: Jaewon Kim <jaewon02.kim@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author: Hyunhee Kim <hyunhee.kim@samsung.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/platform_data/regulator-haptic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/regulator/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define MAX_MAGNITUDE_SHIFT	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct regulator_haptic {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	struct regulator *regulator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	bool active;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	bool suspended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	unsigned int max_volt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	unsigned int min_volt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	unsigned int magnitude;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	if (haptic->active != on) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		error = on ? regulator_enable(haptic->regulator) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			     regulator_disable(haptic->regulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 			dev_err(haptic->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 				"failed to switch regulator %s: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 				on ? "on" : "off", error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		haptic->active = on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static int regulator_haptic_set_voltage(struct regulator_haptic *haptic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 					 unsigned int magnitude)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	u64 volt_mag_multi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	unsigned int intensity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	volt_mag_multi = (u64)(haptic->max_volt - haptic->min_volt) * magnitude;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	intensity = (unsigned int)(volt_mag_multi >> MAX_MAGNITUDE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	error = regulator_set_voltage(haptic->regulator,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 				      intensity + haptic->min_volt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				      haptic->max_volt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		dev_err(haptic->dev, "cannot set regulator voltage to %d: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			intensity + haptic->min_volt, error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	regulator_haptic_toggle(haptic, !!magnitude);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static void regulator_haptic_work(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct regulator_haptic *haptic = container_of(work,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 					struct regulator_haptic, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	mutex_lock(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (!haptic->suspended)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		regulator_haptic_set_voltage(haptic, haptic->magnitude);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	mutex_unlock(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static int regulator_haptic_play_effect(struct input_dev *input, void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 					struct ff_effect *effect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct regulator_haptic *haptic = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	haptic->magnitude = effect->u.rumble.strong_magnitude;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	if (!haptic->magnitude)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		haptic->magnitude = effect->u.rumble.weak_magnitude;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	schedule_work(&haptic->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static void regulator_haptic_close(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct regulator_haptic *haptic = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	cancel_work_sync(&haptic->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	regulator_haptic_set_voltage(haptic, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static int __maybe_unused
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) regulator_haptic_parse_dt(struct device *dev, struct regulator_haptic *haptic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct device_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	node = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if(!node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		dev_err(dev, "Missing device tree data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	error = of_property_read_u32(node, "max-microvolt", &haptic->max_volt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		dev_err(dev, "cannot parse max-microvolt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	error = of_property_read_u32(node, "min-microvolt", &haptic->min_volt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		dev_err(dev, "cannot parse min-microvolt\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int regulator_haptic_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	const struct regulator_haptic_data *pdata = dev_get_platdata(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct regulator_haptic *haptic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	haptic = devm_kzalloc(&pdev->dev, sizeof(*haptic), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (!haptic)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	platform_set_drvdata(pdev, haptic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	haptic->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	mutex_init(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	INIT_WORK(&haptic->work, regulator_haptic_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (pdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		haptic->max_volt = pdata->max_volt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		haptic->min_volt = pdata->min_volt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	} else if (IS_ENABLED(CONFIG_OF)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		error = regulator_haptic_parse_dt(&pdev->dev, haptic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		dev_err(&pdev->dev, "Missing platform data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	haptic->regulator = devm_regulator_get_exclusive(&pdev->dev, "haptic");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (IS_ERR(haptic->regulator)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		dev_err(&pdev->dev, "failed to get regulator\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return PTR_ERR(haptic->regulator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	input_dev = devm_input_allocate_device(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (!input_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		return	-ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	haptic->input_dev = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	haptic->input_dev->name = "regulator-haptic";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	haptic->input_dev->dev.parent = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	haptic->input_dev->close = regulator_haptic_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	input_set_drvdata(haptic->input_dev, haptic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	input_set_capability(haptic->input_dev, EV_FF, FF_RUMBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	error = input_ff_create_memless(input_dev, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 					regulator_haptic_play_effect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		dev_err(&pdev->dev, "failed to create force-feedback\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	error = input_register_device(haptic->input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	if (error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		dev_err(&pdev->dev, "failed to register input device\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static int __maybe_unused regulator_haptic_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	struct platform_device *pdev = to_platform_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	struct regulator_haptic *haptic = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	error = mutex_lock_interruptible(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	regulator_haptic_set_voltage(haptic, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	haptic->suspended = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	mutex_unlock(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static int __maybe_unused regulator_haptic_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	struct platform_device *pdev = to_platform_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct regulator_haptic *haptic = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	unsigned int magnitude;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	mutex_lock(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	haptic->suspended = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	magnitude = READ_ONCE(haptic->magnitude);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	if (magnitude)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		regulator_haptic_set_voltage(haptic, magnitude);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	mutex_unlock(&haptic->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) static SIMPLE_DEV_PM_OPS(regulator_haptic_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		regulator_haptic_suspend, regulator_haptic_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static const struct of_device_id regulator_haptic_dt_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	{ .compatible = "regulator-haptic" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	{ /* sentinel */ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) MODULE_DEVICE_TABLE(of, regulator_haptic_dt_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static struct platform_driver regulator_haptic_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	.probe		= regulator_haptic_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	.driver		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		.name		= "regulator-haptic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		.of_match_table = regulator_haptic_dt_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		.pm		= &regulator_haptic_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) module_platform_driver(regulator_haptic_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) MODULE_AUTHOR("Jaewon Kim <jaewon02.kim@samsung.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) MODULE_AUTHOR("Hyunhee Kim <hyunhee.kim@samsung.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) MODULE_DESCRIPTION("Regulator haptic driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) MODULE_LICENSE("GPL");