Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions Documentation/devicetree/bindings/leds/worldsemi,ws2812b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/worldsemi,ws2812b.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: WS2812B LEDs driven using SPI

maintainers:
- Chuanhong Guo <gch981213@gmail.com>

description: |
WorldSemi WS2812B is a individually addressable LED chip that can be chained
together and controlled individually using a single wire.
This binding describes a chain of WS2812B LEDs connected to the SPI MOSI pin.
Typical setups includes connecting the data pin of the LED chain to MOSI as
the only device or using CS and MOSI with a tri-state voltage-level shifter
for the data pin.
The SPI frequency needs to be 2.105MHz~2.85MHz for the timing to be correct
and the controller needs to send all the bytes continuously.

allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#

properties:
compatible:
const: worldsemi,ws2812b

reg:
maxItems: 1

spi-max-frequency:
minimum: 2105000
maximum: 2850000

"#address-cells":
const: 1

"#size-cells":
const: 0

patternProperties:
"^multi-led@[0-9a-f]+$":
type: object
$ref: leds-class-multicolor.yaml#
unevaluatedProperties: false

properties:
color-index:
description: |
A 3-item array specifying color of each components in this LED. It
should be one of the LED_COLOR_ID_* prefixed definitions from the
header include/dt-bindings/leds/common.h. Defaults to
<LED_COLOR_ID_GREEN LED_COLOR_ID_RED LED_COLOR_ID_BLUE>
if unspecified.
$ref: /schemas/types.yaml#/definitions/uint32-array
maxItems: 3

reg:
description: |
Which LED this node represents. The reg of the first LED on the chain
is 0.
maxItems: 1

required:
- reg
- color
- function

required:
- compatible

additionalProperties: false

examples:
- |
#include <dt-bindings/leds/common.h>
spi {
#address-cells = <1>;
#size-cells = <0>;

led-controller@0 {
compatible = "worldsemi,ws2812b";
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
spi-max-frequency = <2850000>;
multi-led@0 {
reg = <0>;
color-index = <LED_COLOR_ID_RED LED_COLOR_ID_GREEN LED_COLOR_ID_BLUE>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_STATUS;
function-enumerator = <0>;
};
multi-led@1 {
reg = <1>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_STATUS;
function-enumerator = <1>;
};
multi-led@2 {
reg = <2>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_STATUS;
function-enumerator = <2>;
};
multi-led@3 {
reg = <3>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_STATUS;
function-enumerator = <3>;
};
};
};

...
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/vendor-prefixes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,8 @@ patternProperties:
description: Wondermedia Technologies, Inc.
"^wobo,.*":
description: Wobo
"^worldsemi,.*":
description: WorldSemi Co., Limited
"^wolfvision,.*":
description: WolfVision GmbH
"^x-powers,.*":
Expand Down
33 changes: 32 additions & 1 deletion drivers/gpu/drm/msm/dp/dp_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct msm_dp_display_private {
struct mutex plugged_lock;
bool plugged;

struct delayed_work hpd_recovery_work;

struct drm_device *drm_dev;

struct drm_dp_aux *aux;
Expand Down Expand Up @@ -232,6 +234,8 @@ static void msm_dp_display_unbind(struct device *dev, struct device *master,
struct msm_dp_display_private *dp = dev_get_dp_display_private(dev);
struct msm_drm_private *priv = dev_get_drvdata(master);

cancel_delayed_work_sync(&dp->hpd_recovery_work);

of_dp_aux_depopulate_bus(dp->aux);

drm_dp_cec_unregister_connector(dp->aux);
Expand Down Expand Up @@ -380,6 +384,23 @@ static int msm_dp_display_handle_irq_hpd(struct msm_dp_display_private *dp)
return 0;
}

static void msm_dp_hpd_recovery_work(struct work_struct *work)
{
struct delayed_work *dw = to_delayed_work(work);
struct msm_dp_display_private *dp =
container_of(dw, struct msm_dp_display_private, hpd_recovery_work);

if (!dp->msm_dp_display.power_on || !dp->plugged)
return;

msm_dp_ctrl_off_link_stream(dp->ctrl);
msm_dp_ctrl_on_link(dp->ctrl);
msm_dp_ctrl_on_stream(dp->ctrl, false);

drm_connector_set_link_status_property(dp->msm_dp_display.connector,
DRM_MODE_LINK_STATUS_GOOD);
}

static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
{
int ret;
Expand All @@ -406,10 +427,19 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)

ret = msm_dp_display_process_hpd_high(dp);

if (!ret && dp->msm_dp_display.power_on && !was_plugged)
if (!ret && dp->msm_dp_display.power_on && !was_plugged) {
/*
* The sink was replugged while the DP stream is active.
* Userspace may not perform a modeset in response to
* LINK_STATUS_BAD on Wayland compositors. Schedule deferred
* link recovery to avoid racing with DPU commits.
*/
drm_connector_set_link_status_property(dp->msm_dp_display.connector,
DRM_MODE_LINK_STATUS_BAD);

schedule_delayed_work(&dp->hpd_recovery_work, msecs_to_jiffies(500));
}

drm_dbg_dp(dp->drm_dev, "After, type=%d sink_count=%d\n",
dp->msm_dp_display.connector_type,
dp->link->sink_count);
Expand Down Expand Up @@ -1243,6 +1273,7 @@ static int msm_dp_display_probe(struct platform_device *pdev)
dp->hpd_isr_status = 0;

mutex_init(&dp->plugged_lock);
INIT_DELAYED_WORK(&dp->hpd_recovery_work, msm_dp_hpd_recovery_work);

rc = msm_dp_display_get_io(dp);
if (rc)
Expand Down
11 changes: 11 additions & 0 deletions drivers/leds/rgb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@ config LEDS_MT6370_RGB
This driver can also be built as a module. If so, the module
will be called "leds-mt6370-rgb".

config LEDS_WS2812B
tristate "SPI driven WS2812B RGB LED support"
depends on OF
depends on SPI
help
This option enables support for driving daisy-chained WS2812B RGB
LED chips using SPI bus. This driver simulates the single-wire
protocol by sending bits over the SPI MOSI pin. For this to work,
the SPI frequency should be 2.105MHz~2.85MHz and the controller
needs to transfer all the bytes continuously.

endif # LEDS_CLASS_MULTICOLOR
1 change: 1 addition & 0 deletions drivers/leds/rgb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ obj-$(CONFIG_LEDS_NCP5623) += leds-ncp5623.o
obj-$(CONFIG_LEDS_PWM_MULTICOLOR) += leds-pwm-multicolor.o
obj-$(CONFIG_LEDS_QCOM_LPG) += leds-qcom-lpg.o
obj-$(CONFIG_LEDS_MT6370_RGB) += leds-mt6370-rgb.o
obj-$(CONFIG_LEDS_WS2812B) += leds-ws2812b.o
Loading