Lines Matching +full:int +full:- +full:map +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-or-later
19 * struct syscon_led - state container for syscon based LEDs
21 * @map: regmap to access the syscon device backing this LED
23 * @mask: the bit in the register corresponding to the LED
28 struct regmap *map; member
30 u32 mask; member
40 int ret; in syscon_led_set()
44 sled->state = false; in syscon_led_set()
46 val = sled->mask; in syscon_led_set()
47 sled->state = true; in syscon_led_set()
50 ret = regmap_update_bits(sled->map, sled->offset, sled->mask, val); in syscon_led_set()
52 dev_err(sled->cdev.dev, "error updating LED status\n"); in syscon_led_set()
55 static int syscon_led_probe(struct platform_device *pdev) in syscon_led_probe()
58 struct device *dev = &pdev->dev; in syscon_led_probe()
61 struct regmap *map; in syscon_led_probe() local
65 int ret; in syscon_led_probe()
67 parent = dev->parent; in syscon_led_probe()
70 return -ENODEV; in syscon_led_probe()
72 map = syscon_node_to_regmap(dev_of_node(parent)); in syscon_led_probe()
73 if (IS_ERR(map)) { in syscon_led_probe()
75 return PTR_ERR(map); in syscon_led_probe()
80 return -ENOMEM; in syscon_led_probe()
82 sled->map = map; in syscon_led_probe()
84 if (of_property_read_u32(np, "reg", &sled->offset) && in syscon_led_probe()
85 of_property_read_u32(np, "offset", &sled->offset)) in syscon_led_probe()
86 return -EINVAL; in syscon_led_probe()
87 if (of_property_read_u32(np, "mask", &sled->mask)) in syscon_led_probe()
88 return -EINVAL; in syscon_led_probe()
95 ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask); in syscon_led_probe()
98 sled->state = true; in syscon_led_probe()
101 ret = regmap_read(map, sled->offset, &value); in syscon_led_probe()
104 sled->state = !!(value & sled->mask); in syscon_led_probe()
107 ret = regmap_update_bits(map, sled->offset, sled->mask, 0); in syscon_led_probe()
110 sled->state = false; in syscon_led_probe()
112 sled->cdev.brightness_set = syscon_led_set; in syscon_led_probe()
114 ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data); in syscon_led_probe()
119 dev_info(dev, "registered LED %s\n", sled->cdev.name); in syscon_led_probe()
125 { .compatible = "register-bit-led", },
132 .name = "leds-syscon",