dt-bindings: leds: add Broadcom's BCM63xxx controller
Subsystems (2)
PATCH 1/2 dt-bindings: leds: add Broadcom's BCM63xxx controller
From: Rafał Miłecki <[email protected]>
Broadcom used 2 LEDs hardware blocks for their BCM63xx SoCs:
1. Older one (BCM6318, BCM6328, BCM6362, BCM63268, BCM6838)
2. Newer one (BCM6848, BCM6858, BCM63138, BCM63148, BCM63381, BCM68360)
The newer one was also later also used on BCM4908 SoC.
Old block is already documented in the leds-bcm6328.yaml. This binding documents the new one which uses different registers & programming. It's most commonly used in BCM63138 thus the binding name 63xxx.
--- .../bindings/leds/leds-bcm63xxx.yaml | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-bcm63xxx.yaml
Documentation/devicetree/bindings/leds/leds-bcm63xxx.yaml new file +94 -0
@@ -0,0 +1,94 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-bcm63xxx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom's BCM63xxx LEDs controller + +maintainers: + - Rafał Miłecki <[email protected]> + +description: | + This LEDs controller is used on BCM4908, BCM6848, BCM6858, BCM63138, BCM63148, + BCM63381 and BCM68360. + + It supports up to 32 LEDs that can be connected parallelly or serially. It + also includes limited support for hardware blinking. + + Binding serially connected LEDs isn't documented yet. + +properties: + compatible: + items: + - enum: + - brcm,bcm4908-leds + - brcm,bcm6848-leds + - brcm,bcm6858-leds + - brcm,bcm63138-leds + - brcm,bcm63148-leds + - brcm,bcm63381-leds + - brcm,bcm68360-leds + - const: brcm,bcm63xxx-leds + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[a-f0-9]+$": + type: object + + $ref: common.yaml# + + properties: + reg: + maxItems: 1 + description: LED pin number + + active-low: + type: boolean + description: Makes LED active low. + + required: + - reg + + unevaluatedProperties: false + +required: + - reg + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + + leds@ff800800 { + compatible = "brcm,bcm4908-leds", "brcm,bcm63xxx-leds"; + reg = <0xff800800 0xdc>; + + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0x0>; + function = LED_FUNCTION_POWER; + color = <LED_COLOR_ID_GREEN>; + default-state = "on"; + }; + + led@3 { + reg = <0x3>; + function = LED_FUNCTION_STATUS; + color = <LED_COLOR_ID_GREEN>; + active-low; + }; + };
Signature · 1 line
2.31.1
PATCH 2/2 leds: bcm63xxx: add support for BCM63xxx controller
From: Rafał Miłecki <[email protected]>
It's a new controller used on BCM4908, some BCM68xx and some BCM63xxx SoCs.
--- drivers/leds/Kconfig | 11 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-bcm63xxx.c | 299 +++++++++++++++++++++++++++++++++++ 3 files changed, 311 insertions(+) create mode 100644 drivers/leds/leds-bcm63xxx.c
drivers/leds/Kconfig +11 -0
@@ -122,6 +122,17 @@ config LEDS_BCM6358 This option enables support for LEDs connected to the BCM6358 LED HW controller accessed via MMIO registers. +config LEDS_BCM63XXX + tristate "LED Support for Broadcom BCM63xxx SoCs" + depends on LEDS_CLASS + depends on ARCH_BCM4908 || BCM63XX || COMPILE_TEST + depends on HAS_IOMEM + depends on OF + default ARCH_BCM4908 + help + This option enables support for LED controller that is part of + BCM63xxx family SoCs. + config LEDS_CPCAP tristate "LED Support for Motorola CPCAP" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o obj-$(CONFIG_LEDS_AW2013) += leds-aw2013.o obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o +obj-$(CONFIG_LEDS_BCM63XXX) += leds-bcm63xxx.o obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
drivers/leds/leds-bcm63xxx.c new file +299 -0
299 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH 2/2] leds: bcm63xxx: add support for BCM63xxx controller
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
It's a new controller used on BCM4908, some BCM68xx and some BCM63xxx SoCs.
Signed-off-by Rafał Miłecki <[email protected]>
Same comment as the binding, please s/bcm63xxx/bcm63xx/ for matchign existing drivers/patterns.
[snip]
drivers/leds/leds-bcm63xxx.c line 17
Quoted 4 lines
drivers/leds/leds-bcm63xxx.c new file +4
-0+ +#define BCM63XXX_MAX_LEDS 32> + +#define BCM63XXX_GLB_CTRL 0x00 +#define BCM63XXX_MASK 0x04
This define appears unused.
drivers/leds/leds-bcm63xxx.c line 30
Quoted 13 lines
drivers/leds/leds-bcm63xxx.c new file +13
-0+#define BCM63XXX_HW_LED_EN 0x08 +#define BCM63XXX_SERIAL_LED_SHIFT_SEL 0x0c +#define BCM63XXX_FLASH_RATE_CTRL1 0x10 +#define BCM63XXX_FLASH_RATE_CTRL2 0x14 +#define BCM63XXX_FLASH_RATE_CTRL3 0x18 +#define BCM63XXX_FLASH_RATE_CTRL4 0x1c +#define BCM63XXX_BRIGHT_CTRL1 0x20 +#define BCM63XXX_BRIGHT_CTRL2 0x24 +#define BCM63XXX_BRIGHT_CTRL3 0x28 +#define BCM63XXX_BRIGHT_CTRL4 0x2c +#define BCM63XXX_POWER_LED_CFG 0x30 +#define BCM63XXX_HW_POLARITY 0xb4 +#define BCM63XXX_SW_DATA 0xb8
This is called SW_LED_IP in the register but I guess this name is a bit clearer.
Quoted 45 lines
drivers/leds/leds-bcm63xxx.c new file +45
-0+#define BCM63XXX_SW_POLARITY 0xbc +#define BCM63XXX_PARALLEL_LED_POLARITY 0xc0 +#define BCM63XXX_SERIAL_LED_POLARITY 0xc4 +#define BCM63XXX_HW_LED_STATUS 0xc8 +#define BCM63XXX_FLASH_CTRL_STATUS 0xcc +#define BCM63XXX_FLASH_BRT_CTRL 0xd0 +#define BCM63XXX_FLASH_P_LED_OUT_STATUS 0xd4 +#define BCM63XXX_FLASH_S_LED_OUT_STATUS 0xd8 + +struct bcm63xxx_leds { +struct device *dev; +void __iomem *base; +spinlock_t lock; +}; + +struct bcm63xxx_led { +struct bcm63xxx_leds *leds; +struct led_classdev cdev; +u32 pin; +bool active_low; +}; + +/* +* I/O access +*/ + +static void bcm63xxx_leds_write (struct bcm63xxx_leds *leds,unsigned int reg, +u32 data) +{ +writel (data, leds->base + reg); +} + +static unsigned long bcm63xxx_leds_read (struct bcm63xxx_leds *leds, +unsigned int reg) +{ +return readl (leds->base + reg); +} + +static void bcm63xxx_leds_update_bits (struct bcm63xxx_leds *leds, +unsigned int reg,u32 mask,u32 val) +{ +WARN_ON (val & ~mask); + +bcm63xxx_leds_write (leds, reg, (bcm63xxx_leds_read (leds, reg) & ~mask) | (val & mask)); +}
drivers/leds/leds-bcm63xxx.c line 85
Quoted 10 lines
drivers/leds/leds-bcm63xxx.c new file +10
-0+ +/* +* Helpers +*/ + +static void bcm63xxx_leds_set_flash_rate (struct bcm63xxx_leds *leds, +struct bcm63xxx_led *led, +u8 value) +{ +int reg_offset = (led->pin >>3 ) *4 ;
Maybe add some definitions here, like LEDS_PER_WORD and LED_SHIFT and LED_MASK?
[snip]
drivers/leds/leds-bcm63xxx.c line 178
Quoted 2 lines
drivers/leds/leds-bcm63xxx.c new file +2
-0+static int bcm63xxx_leds_create_led (struct bcm63xxx_leds *leds,struct device_node *np) +{
You are not checking the return value of this function, make it void?
[snip]
Quoted 10 lines
drivers/leds/leds-bcm63xxx.c new file +10
-0+static int bcm63xxx_leds_probe (struct platform_device *pdev) +{ +struct device_node *np =dev_of_node (&pdev->dev); +struct device *dev = &pdev->dev; +struct bcm63xxx_leds *leds; +struct device_node *child; + + leds =devm_kzalloc (dev,sizeof (*leds),GFP_KERNEL ); +if (!leds) +return -ENOMEM ;
drivers/leds/leds-bcm63xxx.c line 266
Quoted 10 lines
drivers/leds/leds-bcm63xxx.c new file +10
-0+ + leds->dev = dev; + + leds->base =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (leds->base)) +return PTR_ERR (leds->base); + +spin_lock_init (&leds->lock); + +bcm63xxx_leds_write (leds,BCM63XXX_GLB_CTRL ,0xa );
We would need a define for that:
0x2 -> SERIAL_LED_DATA_PPOL0x8 -> SERIAL_LED_EN_POL
drivers/leds/leds-bcm63xxx.c line 267
Quoted 1 line
drivers/leds/leds-bcm63xxx.c new file +1
-0+bcm63xxx_leds_write (leds,BCM63XXX_BRIGHT_CTRL1 ,0x88888888 );
Cannot we let the LED subsystem change the default brightness?
Signature · 1 line
Florian
Re: [PATCH 2/2] leds: bcm63xxx: add support for BCM63xxx controller
Quoted 11 lines · Florian Fainelli
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
It's a new controller used on BCM4908, some BCM68xx and some BCM63xxx SoCs.
Signed-off-by Rafał Miłecki <[email protected]>Same comment as the binding, please s/bcm63xxx/bcm63xx/ for matchign existing
drivers/patterns.
Quoted 8 lines
[snip]
drivers/leds/leds-bcm63xxx.c line 17
Quoted 4 lines
drivers/leds/leds-bcm63xxx.c new file +4
-0+ +#define BCM63XXX_MAX_LEDS 32> + +#define BCM63XXX_GLB_CTRL 0x00 +#define BCM63XXX_MASK 0x04This define appears unused.
Just like few other registers. I think it's still worth to define all hw registers.
Quoted 5 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Broadcom used 2 LEDs hardware blocks for their BCM63xx SoCs:
1. Older one (BCM6318, BCM6328, BCM6362, BCM63268, BCM6838)
2. Newer one (BCM6848, BCM6858, BCM63138, BCM63148, BCM63381, BCM68360)
Just so the existing pattern/regexps continue to work, I would be naming this "bcm63xx" to be consistent with the rest of existing code-base.
Signature · 1 line
Florian
Quoted 9 lines · Florian Fainelli
Quoted 5 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Broadcom used 2 LEDs hardware blocks for their BCM63xx SoCs:
1. Older one (BCM6318, BCM6328, BCM6362, BCM63268, BCM6838)
2. Newer one (BCM6848, BCM6858, BCM63138, BCM63148, BCM63381, BCM68360)Just so the existing pattern/regexps continue to work, I would be naming this "bcm63xx" to be consistent with the rest of existing code-base.
The problem I saw with "bcm63xx" is that it seems to match all SoCs:
those with old block and those with new block. So I guess both groups have the same right to use that "bcm63xx" based binding.
To avoid favouring old or new block I decided to avoid "bcm63xx".
Given above explanation: do you still prefer using "bcm63xx" based binding for the new block? I'm OK with that, I just want to make sure you're aware of that minor issue. Please let me know :)
Quoted 15 lines · Rafał Miłecki
Quoted 9 lines · Florian Fainelli
Quoted 5 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Broadcom used 2 LEDs hardware blocks for their BCM63xx SoCs:
1. Older one (BCM6318, BCM6328, BCM6362, BCM63268, BCM6838)
2. Newer one (BCM6848, BCM6858, BCM63138, BCM63148, BCM63381, BCM68360)Just so the existing pattern/regexps continue to work, I would be naming this "bcm63xx" to be consistent with the rest of existing code-base.
The problem I saw with "bcm63xx" is that it seems to match all SoCs:
those with old block and those with new block. So I guess both groups have the same right to use that "bcm63xx" based binding.
Quoted 5 lines
To avoid favouring old or new block I decided to avoid "bcm63xx".
Given above explanation: do you still prefer using "bcm63xx" based binding for the new block? I'm OK with that, I just want to make sure you're aware of that minor issue. Please let me know :)
Maybe we use leds-bcm63138.c then since this is the first chip in the list that featured that block, similar to how leds-bcm6328.c was created? Then my second choice would be leds-bcm63xx.c just so the existing patterns match, really and because it's easy to visually not be able to tell the difference between two x versus three x.
Thanks
Signature · 1 line
Florian
Quoted 22 lines · Florian Fainelli
Quoted 15 lines · Rafał Miłecki
Quoted 9 lines · Florian Fainelli
Quoted 5 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Broadcom used 2 LEDs hardware blocks for their BCM63xx SoCs:
1. Older one (BCM6318, BCM6328, BCM6362, BCM63268, BCM6838)
2. Newer one (BCM6848, BCM6858, BCM63138, BCM63148, BCM63381, BCM68360)Just so the existing pattern/regexps continue to work, I would be naming this "bcm63xx" to be consistent with the rest of existing code-base.
The problem I saw with "bcm63xx" is that it seems to match all SoCs:
those with old block and those with new block. So I guess both groups have the same right to use that "bcm63xx" based binding.Quoted 5 lines
To avoid favouring old or new block I decided to avoid "bcm63xx".
Given above explanation: do you still prefer using "bcm63xx" based binding for the new block? I'm OK with that, I just want to make sure you're aware of that minor issue. Please let me know :)
Quoted 5 lines
Maybe we use
leds-bcm63138.cthen since this is the first chip in the list that featured that block, similar to howleds-bcm6328.cwas created? Then my second choice would beleds-bcm63xx.cjust so the existing patterns match, really and because it's easy to visually not be able to tell the difference between two x versus three x.
Sounds good to me, thanks for your review!