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)  * LED driver for WM8350 driven LEDS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright(C) 2007, 2008 Wolfson Microelectronics PLC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/mfd/wm8350/pmic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/regulator/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /* Microamps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static const int isink_cur[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	19,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	23,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	27,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	39,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	46,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	54,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	65,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	77,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	92,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	109,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	130,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	154,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	183,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	218,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	259,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	308,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	367,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	436,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	518,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	616,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	733,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	872,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	1037,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	1233,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	1466,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	1744,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	2073,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	2466,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	2933,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	3487,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	4147,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	4932,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	5865,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	6975,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	8294,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	9864,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	11730,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	13949,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	16589,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	19728,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	23460,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	27899,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	33178,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	39455,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	46920,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	55798,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	66355,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	78910,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	93840,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	111596,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	132710,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	157820,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	187681,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	223191
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define to_wm8350_led(led_cdev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	container_of(led_cdev, struct wm8350_led, cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static int wm8350_led_enable(struct wm8350_led *led)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (led->enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	ret = regulator_enable(led->isink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		dev_err(led->cdev.dev, "Failed to enable ISINK: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	ret = regulator_enable(led->dcdc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		dev_err(led->cdev.dev, "Failed to enable DCDC: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		regulator_disable(led->isink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		return ret;
^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) 	led->enabled = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static int wm8350_led_disable(struct wm8350_led *led)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (!led->enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	ret = regulator_disable(led->dcdc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		dev_err(led->cdev.dev, "Failed to disable DCDC: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	ret = regulator_disable(led->isink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		dev_err(led->cdev.dev, "Failed to disable ISINK: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		ret = regulator_enable(led->dcdc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		if (ret != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			dev_err(led->cdev.dev, "Failed to reenable DCDC: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 				ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	led->enabled = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static int wm8350_led_set(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			   enum led_brightness value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct wm8350_led *led = to_wm8350_led(led_cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	int uA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	led->value = value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	spin_lock_irqsave(&led->value_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if (led->value == LED_OFF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		spin_unlock_irqrestore(&led->value_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		return wm8350_led_disable(led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/* This scales linearly into the index of valid current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 * settings which results in a linear scaling of perceived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	 * brightness due to the non-linear current settings provided
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	 * by the hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	uA = (led->max_uA_index * led->value) / LED_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	spin_unlock_irqrestore(&led->value_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	BUG_ON(uA >= ARRAY_SIZE(isink_cur));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	ret = regulator_set_current_limit(led->isink, isink_cur[uA],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 					  isink_cur[uA]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	if (ret != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		dev_err(led->cdev.dev, "Failed to set %duA: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 			isink_cur[uA], ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	return wm8350_led_enable(led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) static void wm8350_led_shutdown(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	struct wm8350_led *led = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	led->value = LED_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	wm8350_led_disable(led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static int wm8350_led_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	struct regulator *isink, *dcdc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct wm8350_led *led;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	struct wm8350_led_platform_data *pdata = dev_get_platdata(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (pdata == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		dev_err(&pdev->dev, "no platform data\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	if (pdata->max_uA < isink_cur[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		dev_err(&pdev->dev, "Invalid maximum current %duA\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 			pdata->max_uA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		return -EINVAL;
^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) 	isink = devm_regulator_get(&pdev->dev, "led_isink");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (IS_ERR(isink)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		dev_err(&pdev->dev, "%s: can't get ISINK\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		return PTR_ERR(isink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	dcdc = devm_regulator_get(&pdev->dev, "led_vcc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (IS_ERR(dcdc)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		dev_err(&pdev->dev, "%s: can't get DCDC\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		return PTR_ERR(dcdc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (led == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	led->cdev.brightness_set_blocking = wm8350_led_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	led->cdev.default_trigger = pdata->default_trigger;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	led->cdev.name = pdata->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	led->cdev.flags |= LED_CORE_SUSPENDRESUME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	led->enabled = regulator_is_enabled(isink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	led->isink = isink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	led->dcdc = dcdc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	for (i = 0; i < ARRAY_SIZE(isink_cur) - 1; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		if (isink_cur[i] >= pdata->max_uA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	led->max_uA_index = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if (pdata->max_uA != isink_cur[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		dev_warn(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			 "Maximum current %duA is not directly supported,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			 " check platform data\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			 pdata->max_uA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	spin_lock_init(&led->value_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	led->value = LED_OFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	platform_set_drvdata(pdev, led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return led_classdev_register(&pdev->dev, &led->cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static int wm8350_led_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct wm8350_led *led = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	led_classdev_unregister(&led->cdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	wm8350_led_disable(led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static struct platform_driver wm8350_led_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		   .name = "wm8350-led",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		   },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	.probe = wm8350_led_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	.remove = wm8350_led_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	.shutdown = wm8350_led_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) module_platform_driver(wm8350_led_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) MODULE_AUTHOR("Mark Brown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) MODULE_DESCRIPTION("WM8350 LED driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) MODULE_ALIAS("platform:wm8350-led");