15 #include <linux/module.h>
16 #include <linux/kernel.h>
21 #include <linux/slab.h>
27 #define DA9052_OPENDRAIN_OUTPUT 2
28 #define DA9052_SET_HIGH_LVL_OUTPUT (1 << 3)
29 #define DA9052_MASK_UPPER_NIBBLE 0xF0
30 #define DA9052_MASK_LOWER_NIBBLE 0x0F
31 #define DA9052_NIBBLE_SHIFT 4
32 #define DA9052_MAX_BRIGHTNESS 0x5f
43 static unsigned char led_reg[] = {
57 dev_err(led->
da9052->dev,
"Failed to set led brightness, %d\n",
66 da9052_set_led_brightness(led);
69 static void da9052_led_set(
struct led_classdev *led_cdev,
90 dev_err(da9052->
dev,
"Failed to write GPIO 14-15 reg, %d\n",
99 dev_err(da9052->
dev,
"Failed to write GPIO 14-15 reg, %d\n",
108 struct da9052 *da9052;
115 pdata = da9052->
dev->platform_data;
123 dev_err(&pdev->
dev,
"No platform data for LED\n");
131 dev_err(&pdev->
dev,
"Failed to alloc memory\n");
136 for (i = 0; i < pled->
num_leds; i++) {
138 led[
i].
cdev.brightness_set = da9052_led_set;
148 dev_err(&pdev->
dev,
"Failed to register led %d\n",
153 error = da9052_set_led_brightness(&led[i]);
155 dev_err(&pdev->
dev,
"Unable to init led %d\n",
160 error = da9052_configure_leds(led->
da9052);
162 dev_err(&pdev->
dev,
"Failed to configure GPIO LED%d\n", error);
166 platform_set_drvdata(pdev, led);
171 for (i = i - 1; i >= 0; i--) {
181 struct da9052_led *led = platform_get_drvdata(pdev);
183 struct da9052 *da9052;
188 pdata = da9052->
dev->platform_data;
191 for (i = 0; i < pled->
num_leds; i++) {
193 da9052_set_led_brightness(&led[i]);
203 .name =
"da9052-leds",
206 .probe = da9052_led_probe,