Lines Matching +full:0 +full:- +full:1152
1 // SPDX-License-Identifier: GPL-2.0-only
20 #define BCM63138_LED_MASK ((1 << BCM63138_LED_BITS) - 1) /* 0xf */
23 #define BCM63138_GLB_CTRL 0x00
28 #define BCM63138_MASK 0x04
29 #define BCM63138_HW_LED_EN 0x08
30 #define BCM63138_SERIAL_LED_SHIFT_SEL 0x0c
31 #define BCM63138_FLASH_RATE_CTRL1 0x10
32 #define BCM63138_FLASH_RATE_CTRL2 0x14
33 #define BCM63138_FLASH_RATE_CTRL3 0x18
34 #define BCM63138_FLASH_RATE_CTRL4 0x1c
35 #define BCM63138_BRIGHT_CTRL1 0x20
36 #define BCM63138_BRIGHT_CTRL2 0x24
37 #define BCM63138_BRIGHT_CTRL3 0x28
38 #define BCM63138_BRIGHT_CTRL4 0x2c
39 #define BCM63138_POWER_LED_CFG 0x30
40 #define BCM63138_POWER_LUT_BASE0 0x34 /* -> b0 */
41 #define BCM63138_HW_POLARITY 0xb4
42 #define BCM63138_SW_DATA 0xb8
43 #define BCM63138_SW_POLARITY 0xbc
44 #define BCM63138_PARALLEL_LED_POLARITY 0xc0
45 #define BCM63138_SERIAL_LED_POLARITY 0xc4
46 #define BCM63138_HW_LED_STATUS 0xc8
47 #define BCM63138_FLASH_CTRL_STATUS 0xcc
48 #define BCM63138_FLASH_BRT_CTRL 0xd0
49 #define BCM63138_FLASH_P_LED_OUT_STATUS 0xd4
50 #define BCM63138_FLASH_S_LED_OUT_STATUS 0xd8
72 writel(data, leds->base + reg); in bcm63138_leds_write()
78 return readl(leds->base + reg); in bcm63138_leds_read()
97 int reg_offset = (led->pin >> fls((BCM63138_LEDS_PER_REG - 1))) * 4; in bcm63138_leds_set_flash_rate()
98 int shift = (led->pin & (BCM63138_LEDS_PER_REG - 1)) * BCM63138_LED_BITS; in bcm63138_leds_set_flash_rate()
108 int reg_offset = (led->pin >> fls((BCM63138_LEDS_PER_REG - 1))) * 4; in bcm63138_leds_set_bright()
109 int shift = (led->pin & (BCM63138_LEDS_PER_REG - 1)) * BCM63138_LED_BITS; in bcm63138_leds_set_bright()
119 u32 bit = BIT(led->pin); in bcm63138_leds_enable_led()
121 bcm63138_leds_update_bits(leds, BCM63138_SW_DATA, bit, value ? bit : 0); in bcm63138_leds_enable_led()
132 struct bcm63138_leds *leds = led->leds; in bcm63138_leds_brightness_set()
134 guard(spinlock_irqsave)(&leds->lock); in bcm63138_leds_brightness_set()
138 bcm63138_leds_set_flash_rate(leds, led, 0); in bcm63138_leds_brightness_set()
148 struct bcm63138_leds *leds = led->leds; in bcm63138_leds_blink_set()
157 dev_dbg(led_cdev->dev, "Blinking at unequal delays is not supported\n"); in bcm63138_leds_blink_set()
158 return -EINVAL; in bcm63138_leds_blink_set()
162 case 1152 ... 1408: /* 1280 ms ± 10% */ in bcm63138_leds_blink_set()
163 value = 0x7; in bcm63138_leds_blink_set()
166 value = 0x6; in bcm63138_leds_blink_set()
169 value = 0x5; in bcm63138_leds_blink_set()
172 value = 0x4; in bcm63138_leds_blink_set()
175 value = 0x3; in bcm63138_leds_blink_set()
178 dev_dbg(led_cdev->dev, "Blinking delay value %lu is unsupported\n", in bcm63138_leds_blink_set()
180 return -EINVAL; in bcm63138_leds_blink_set()
183 guard(spinlock_irqsave)(&leds->lock); in bcm63138_leds_blink_set()
188 return 0; in bcm63138_leds_blink_set()
201 struct device *dev = leds->dev; in bcm63138_leds_create_led()
213 led->leds = leds; in bcm63138_leds_create_led()
215 if (of_property_read_u32(np, "reg", &led->pin)) { in bcm63138_leds_create_led()
220 if (led->pin >= BCM63138_MAX_LEDS) { in bcm63138_leds_create_led()
221 dev_err(dev, "Invalid \"reg\" value %d\n", led->pin); in bcm63138_leds_create_led()
225 led->active_low = of_property_read_bool(np, "active-low"); in bcm63138_leds_create_led()
227 led->cdev.max_brightness = BCM63138_MAX_BRIGHTNESS; in bcm63138_leds_create_led()
228 led->cdev.brightness_set = bcm63138_leds_brightness_set; in bcm63138_leds_create_led()
229 led->cdev.blink_set = bcm63138_leds_blink_set; in bcm63138_leds_create_led()
231 err = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); in bcm63138_leds_create_led()
237 pinctrl = devm_pinctrl_get_select_default(led->cdev.dev); in bcm63138_leds_create_led()
238 if (IS_ERR(pinctrl) && PTR_ERR(pinctrl) != -ENODEV) { in bcm63138_leds_create_led()
239 dev_warn(led->cdev.dev, "Failed to select %pOF pinctrl: %ld\n", in bcm63138_leds_create_led()
243 bit = BIT(led->pin); in bcm63138_leds_create_led()
245 led->active_low ? 0 : bit); in bcm63138_leds_create_led()
246 bcm63138_leds_update_bits(leds, BCM63138_HW_LED_EN, bit, 0); in bcm63138_leds_create_led()
247 bcm63138_leds_set_flash_rate(leds, led, 0); in bcm63138_leds_create_led()
248 bcm63138_leds_enable_led(leds, led, led->cdev.brightness); in bcm63138_leds_create_led()
258 struct device_node *np = dev_of_node(&pdev->dev); in bcm63138_leds_probe()
259 struct device *dev = &pdev->dev; in bcm63138_leds_probe()
265 return -ENOMEM; in bcm63138_leds_probe()
267 leds->dev = dev; in bcm63138_leds_probe()
269 leds->base = devm_platform_ioremap_resource(pdev, 0); in bcm63138_leds_probe()
270 if (IS_ERR(leds->base)) in bcm63138_leds_probe()
271 return PTR_ERR(leds->base); in bcm63138_leds_probe()
273 spin_lock_init(&leds->lock); in bcm63138_leds_probe()
276 if (!of_property_read_u32(np, "brcm,serial-shift-bits", &shift_bits)) { in bcm63138_leds_probe()
278 GENMASK(shift_bits - 1, 0)); in bcm63138_leds_probe()
284 bcm63138_leds_write(leds, BCM63138_HW_LED_EN, 0); in bcm63138_leds_probe()
285 bcm63138_leds_write(leds, BCM63138_SERIAL_LED_POLARITY, 0); in bcm63138_leds_probe()
286 bcm63138_leds_write(leds, BCM63138_PARALLEL_LED_POLARITY, 0); in bcm63138_leds_probe()
292 return 0; in bcm63138_leds_probe()
296 { .compatible = "brcm,bcm63138-leds", },
303 .name = "leds-bcm63xxx",