Lines Matching +full:led +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-only
3 * LED driver for Marvell 88PM860x
25 #define LED1_BLINK_EN (1 << 1)
26 #define LED2_BLINK_EN (1 << 2)
47 int ret = -EINVAL; in led_power_set()
51 case 1: in led_power_set()
69 struct pm860x_led *led = container_of(cdev, struct pm860x_led, cdev); in pm860x_led_set() local
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()
95 ret |= buf[1] & LED_PWM_MASK; 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()
141 #define pm860x_led_dt_init(x, y) (-1)
146 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); in pm860x_led_probe()
147 struct pm860x_led_pdata *pdata = dev_get_platdata(&pdev->dev); in pm860x_led_probe()
152 data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL); in pm860x_led_probe()
154 return -ENOMEM; in pm860x_led_probe()
157 dev_err(&pdev->dev, "No REG resource for control\n"); in pm860x_led_probe()
158 return -ENXIO; in pm860x_led_probe()
160 data->reg_control = res->start; in pm860x_led_probe()
163 dev_err(&pdev->dev, "No REG resource for blink\n"); in pm860x_led_probe()
164 return -ENXIO; in pm860x_led_probe()
166 data->reg_blink = res->start; in pm860x_led_probe()
167 memset(data->name, 0, MFD_NAME_SIZE); in pm860x_led_probe()
168 switch (pdev->id) { in pm860x_led_probe()
170 data->blink_mask = LED1_BLINK_EN; in pm860x_led_probe()
171 sprintf(data->name, "led0-red"); in pm860x_led_probe()
173 case 1: in pm860x_led_probe()
174 data->blink_mask = LED1_BLINK_EN; in pm860x_led_probe()
175 sprintf(data->name, "led0-green"); in pm860x_led_probe()
178 data->blink_mask = LED1_BLINK_EN; in pm860x_led_probe()
179 sprintf(data->name, "led0-blue"); in pm860x_led_probe()
182 data->blink_mask = LED2_BLINK_EN; in pm860x_led_probe()
183 sprintf(data->name, "led1-red"); in pm860x_led_probe()
186 data->blink_mask = LED2_BLINK_EN; in pm860x_led_probe()
187 sprintf(data->name, "led1-green"); in pm860x_led_probe()
190 data->blink_mask = LED2_BLINK_EN; in pm860x_led_probe()
191 sprintf(data->name, "led1-blue"); in pm860x_led_probe()
194 data->chip = chip; in pm860x_led_probe()
195 data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; in pm860x_led_probe()
196 data->port = pdev->id; in pm860x_led_probe()
199 data->iset = pdata->iset; in pm860x_led_probe()
201 data->current_brightness = 0; in pm860x_led_probe()
202 data->cdev.name = data->name; in pm860x_led_probe()
203 data->cdev.brightness_set_blocking = pm860x_led_set; in pm860x_led_probe()
204 mutex_init(&data->lock); in pm860x_led_probe()
206 ret = led_classdev_register(chip->dev, &data->cdev); in pm860x_led_probe()
208 dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); in pm860x_led_probe()
211 pm860x_led_set(&data->cdev, 0); in pm860x_led_probe()
222 led_classdev_unregister(&data->cdev); in pm860x_led_remove()
229 .name = "88pm860x-led",
237 MODULE_DESCRIPTION("LED driver for Marvell PM860x");
240 MODULE_ALIAS("platform:88pm860x-led");