Lines Matching +full:led +full:- +full:3

1 // SPDX-License-Identifier: GPL-2.0-only
3 * LED driver for Marvell 88PM860x
23 #define LED_ON_CONTINUOUS (0x0F << 3)
47 int ret = -EINVAL; in led_power_set()
56 case 3: in led_power_set()
69 struct pm860x_led *led = container_of(cdev, struct pm860x_led, cdev); in pm860x_led_set() local
71 unsigned char buf[3]; in pm860x_led_set()
74 chip = led->chip; in pm860x_led_set()
75 mutex_lock(&led->lock); in pm860x_led_set()
76 led->brightness = value >> 3; in pm860x_led_set()
78 if ((led->current_brightness == 0) && led->brightness) { in pm860x_led_set()
79 led_power_set(chip, led->port, 1); in pm860x_led_set()
80 if (led->iset) { in pm860x_led_set()
81 pm860x_set_bits(led->i2c, led->reg_control, in pm860x_led_set()
82 LED_CURRENT_MASK, led->iset); in pm860x_led_set()
84 pm860x_set_bits(led->i2c, led->reg_blink, in pm860x_led_set()
86 pm860x_set_bits(led->i2c, PM8606_WLED3B, led->blink_mask, in pm860x_led_set()
87 led->blink_mask); in pm860x_led_set()
89 pm860x_set_bits(led->i2c, led->reg_control, LED_PWM_MASK, in pm860x_led_set()
90 led->brightness); in pm860x_led_set()
92 if (led->brightness == 0) { in pm860x_led_set()
93 pm860x_bulk_read(led->i2c, led->reg_control, 3, buf); in pm860x_led_set()
98 /* unset current since no led is lighting */ in pm860x_led_set()
99 pm860x_set_bits(led->i2c, led->reg_control, in pm860x_led_set()
101 pm860x_set_bits(led->i2c, PM8606_WLED3B, in pm860x_led_set()
102 led->blink_mask, 0); in pm860x_led_set()
103 led_power_set(chip, led->port, 0); in pm860x_led_set()
106 led->current_brightness = led->brightness; in pm860x_led_set()
107 dev_dbg(chip->dev, "Update LED. (reg:%d, brightness:%d)\n", in pm860x_led_set()
108 led->reg_control, led->brightness); in pm860x_led_set()
109 mutex_unlock(&led->lock); in pm860x_led_set()
121 if (!dev_of_node(pdev->dev.parent)) in pm860x_led_dt_init()
122 return -ENODEV; in pm860x_led_dt_init()
123 nproot = of_get_child_by_name(dev_of_node(pdev->dev.parent), "leds"); in pm860x_led_dt_init()
125 dev_err(&pdev->dev, "failed to find leds node\n"); in pm860x_led_dt_init()
126 return -ENODEV; in pm860x_led_dt_init()
129 if (of_node_name_eq(np, data->name)) { in pm860x_led_dt_init()
130 of_property_read_u32(np, "marvell,88pm860x-iset", in pm860x_led_dt_init()
132 data->iset = PM8606_LED_CURRENT(iset); in pm860x_led_dt_init()
140 #define pm860x_led_dt_init(x, y) (-1)
145 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); in pm860x_led_probe()
146 struct pm860x_led_pdata *pdata = dev_get_platdata(&pdev->dev); in pm860x_led_probe()
151 data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL); in pm860x_led_probe()
153 return -ENOMEM; in pm860x_led_probe()
156 dev_err(&pdev->dev, "No REG resource for control\n"); in pm860x_led_probe()
157 return -ENXIO; in pm860x_led_probe()
159 data->reg_control = res->start; in pm860x_led_probe()
162 dev_err(&pdev->dev, "No REG resource for blink\n"); in pm860x_led_probe()
163 return -ENXIO; in pm860x_led_probe()
165 data->reg_blink = res->start; in pm860x_led_probe()
166 memset(data->name, 0, MFD_NAME_SIZE); in pm860x_led_probe()
167 switch (pdev->id) { in pm860x_led_probe()
169 data->blink_mask = LED1_BLINK_EN; in pm860x_led_probe()
170 sprintf(data->name, "led0-red"); in pm860x_led_probe()
173 data->blink_mask = LED1_BLINK_EN; in pm860x_led_probe()
174 sprintf(data->name, "led0-green"); in pm860x_led_probe()
177 data->blink_mask = LED1_BLINK_EN; in pm860x_led_probe()
178 sprintf(data->name, "led0-blue"); in pm860x_led_probe()
180 case 3: in pm860x_led_probe()
181 data->blink_mask = LED2_BLINK_EN; in pm860x_led_probe()
182 sprintf(data->name, "led1-red"); in pm860x_led_probe()
185 data->blink_mask = LED2_BLINK_EN; in pm860x_led_probe()
186 sprintf(data->name, "led1-green"); in pm860x_led_probe()
189 data->blink_mask = LED2_BLINK_EN; in pm860x_led_probe()
190 sprintf(data->name, "led1-blue"); in pm860x_led_probe()
193 data->chip = chip; in pm860x_led_probe()
194 data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; in pm860x_led_probe()
195 data->port = pdev->id; in pm860x_led_probe()
198 data->iset = pdata->iset; in pm860x_led_probe()
200 data->current_brightness = 0; in pm860x_led_probe()
201 data->cdev.name = data->name; in pm860x_led_probe()
202 data->cdev.brightness_set_blocking = pm860x_led_set; in pm860x_led_probe()
203 mutex_init(&data->lock); in pm860x_led_probe()
205 ret = led_classdev_register(chip->dev, &data->cdev); in pm860x_led_probe()
207 dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); in pm860x_led_probe()
210 pm860x_led_set(&data->cdev, 0); in pm860x_led_probe()
221 led_classdev_unregister(&data->cdev); in pm860x_led_remove()
226 .name = "88pm860x-led",
234 MODULE_DESCRIPTION("LED driver for Marvell PM860x");
237 MODULE_ALIAS("platform:88pm860x-led");