Lines Matching +full:num +full:- +full:columns
1 // SPDX-License-Identifier: GPL-2.0
23 #define AW200XX_DIM_MAX (BIT(6) - 1)
24 #define AW200XX_FADE_MAX (BIT(8) - 1)
41 AW200XX_REG(AW200XX_NUM_PAGES - 1, AW200XX_PAGE_SIZE - 1)
75 #define AW200XX_LED2REG(x, columns) \ argument
76 ((x) + (((x) / (columns)) * (AW200XX_DSIZE_COLUMNS_MAX - (columns))))
79 #define AW200XX_REG_DIM_PAGE1(x, columns) \ argument
80 AW200XX_REG(AW200XX_PAGE1, AW200XX_LED2REG(x, columns))
87 #define AW200XX_REG_DIM(x, columns) \ argument
88 AW200XX_REG(AW200XX_PAGE4, AW200XX_LED2REG(x, columns) * 2)
112 u32 num; member
131 int dim = led->dim; in dim_show()
144 struct aw200xx *chip = led->chip; in dim_store()
145 u32 columns = chip->cdef->display_size_columns; in dim_store() local
150 dim = -1; in dim_store()
157 return -EINVAL; in dim_store()
160 mutex_lock(&chip->mutex); in dim_store()
163 ret = regmap_write(chip->regmap, in dim_store()
164 AW200XX_REG_DIM_PAGE1(led->num, columns), in dim_store()
170 led->dim = dim; in dim_store()
174 mutex_unlock(&chip->mutex); in dim_store()
189 struct aw200xx *chip = led->chip; in aw200xx_brightness_set()
194 mutex_lock(&chip->mutex); in aw200xx_brightness_set()
196 reg = AW200XX_REG_DIM(led->num, chip->cdef->display_size_columns); in aw200xx_brightness_set()
198 dim = led->dim; in aw200xx_brightness_set()
202 ret = regmap_write(chip->regmap, reg, dim); in aw200xx_brightness_set()
206 ret = regmap_write(chip->regmap, in aw200xx_brightness_set()
210 mutex_unlock(&chip->mutex); in aw200xx_brightness_set()
231 led_imax_uA = global_imax_uA * AW200XX_DUTY_RATIO(chip->display_rows); in aw200xx_imax_from_global()
240 u32 duty = AW200XX_DUTY_RATIO(chip->display_rows); in aw200xx_imax_to_global()
252 * The AW200XX has a 4-bit register (GCCR) to configure the global current,
256 * +-----------+-----------------+-----------+-----------------+
258 * +-----------+-----------------+-----------+-----------------+
267 * +-----------+-----------------+-----------+-----------------+
309 return -EINVAL; in aw200xx_set_imax()
311 return regmap_update_bits(chip->regmap, AW200XX_REG_GCCR, in aw200xx_set_imax()
320 ret = regmap_write(chip->regmap, AW200XX_REG_RSTR, AW200XX_RSTR_RESET); in aw200xx_chip_reset()
327 regcache_mark_dirty(chip->regmap); in aw200xx_chip_reset()
328 return regmap_write(chip->regmap, AW200XX_REG_FCD, AW200XX_FCD_CLEAR); in aw200xx_chip_reset()
335 ret = regmap_write(chip->regmap, AW200XX_REG_DSIZE, in aw200xx_chip_init()
336 chip->display_rows - 1); in aw200xx_chip_init()
340 ret = regmap_write(chip->regmap, AW200XX_REG_SLPCR, in aw200xx_chip_init()
345 return regmap_update_bits(chip->regmap, AW200XX_REG_GCCR, in aw200xx_chip_init()
351 struct device *dev = &chip->client->dev; in aw200xx_chip_check()
355 ret = regmap_read(chip->regmap, AW200XX_REG_IDR, &chipid); in aw200xx_chip_check()
360 return dev_err_probe(dev, -ENODEV, in aw200xx_chip_check()
368 gpiod_set_value_cansleep(chip->hwen, 1); in aw200xx_enable()
382 return gpiod_set_value_cansleep(chip->hwen, 0); in aw200xx_disable()
396 if (ret || source >= chip->cdef->channels) in aw200xx_probe_get_display_rows()
403 return -EINVAL; in aw200xx_probe_get_display_rows()
405 chip->display_rows = max_source / chip->cdef->display_size_columns + 1; in aw200xx_probe_get_display_rows()
434 chip->num_leds--; in aw200xx_probe_fw()
438 if (source >= chip->cdef->channels) { in aw200xx_probe_fw()
440 source, chip->cdef->channels); in aw200xx_probe_fw()
441 chip->num_leds--; in aw200xx_probe_fw()
445 ret = fwnode_property_read_u32(child, "led-max-microamp", in aw200xx_probe_fw()
448 dev_info(&chip->client->dev, in aw200xx_probe_fw()
449 "DT property led-max-microamp is missing\n"); in aw200xx_probe_fw()
451 dev_err(dev, "Invalid value %u for led-max-microamp\n", in aw200xx_probe_fw()
453 chip->num_leds--; in aw200xx_probe_fw()
459 led = &chip->leds[i]; in aw200xx_probe_fw()
460 led->dim = -1; in aw200xx_probe_fw()
461 led->num = source; in aw200xx_probe_fw()
462 led->chip = chip; in aw200xx_probe_fw()
463 led->cdev.brightness_set_blocking = aw200xx_brightness_set; in aw200xx_probe_fw()
464 led->cdev.max_brightness = AW200XX_FADE_MAX; in aw200xx_probe_fw()
465 led->cdev.groups = dim_groups; in aw200xx_probe_fw()
468 ret = devm_led_classdev_register_ext(dev, &led->cdev, in aw200xx_probe_fw()
476 if (!chip->num_leds) in aw200xx_probe_fw()
477 return -EINVAL; in aw200xx_probe_fw()
547 cdef = device_get_match_data(&client->dev); in aw200xx_probe()
549 return -ENODEV; in aw200xx_probe()
551 count = device_get_child_node_count(&client->dev); in aw200xx_probe()
552 if (!count || count > cdef->channels) in aw200xx_probe()
553 return dev_err_probe(&client->dev, -EINVAL, in aw200xx_probe()
556 chip = devm_kzalloc(&client->dev, struct_size(chip, leds, count), in aw200xx_probe()
559 return -ENOMEM; in aw200xx_probe()
561 chip->cdef = cdef; in aw200xx_probe()
562 chip->num_leds = count; in aw200xx_probe()
563 chip->client = client; in aw200xx_probe()
566 chip->regmap = devm_regmap_init_i2c(client, &aw200xx_regmap_config); in aw200xx_probe()
567 if (IS_ERR(chip->regmap)) in aw200xx_probe()
568 return PTR_ERR(chip->regmap); in aw200xx_probe()
570 chip->hwen = devm_gpiod_get_optional(&client->dev, "enable", in aw200xx_probe()
572 if (IS_ERR(chip->hwen)) in aw200xx_probe()
573 return dev_err_probe(&client->dev, PTR_ERR(chip->hwen), in aw200xx_probe()
578 ret = devm_add_action(&client->dev, aw200xx_disable_action, chip); in aw200xx_probe()
586 ret = devm_mutex_init(&client->dev, &chip->mutex); in aw200xx_probe()
591 mutex_lock(&chip->mutex); in aw200xx_probe()
597 ret = devm_add_action(&client->dev, aw200xx_chip_reset_action, chip); in aw200xx_probe()
601 ret = aw200xx_probe_fw(&client->dev, chip); in aw200xx_probe()
611 mutex_unlock(&chip->mutex); in aw200xx_probe()