[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220730213913.GJ23307@duo.ucw.cz>
Date: Sat, 30 Jul 2022 23:39:13 +0200
From: Pavel Machek <pavel@....cz>
To: ChiaEn Wu <peterwu.pub@...il.com>
Cc: lee.jones@...aro.org, daniel.thompson@...aro.org,
jingoohan1@...il.com, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, matthias.bgg@...il.com,
sre@...nel.org, chunfeng.yun@...iatek.com,
gregkh@...uxfoundation.org, jic23@...nel.org, lars@...afoo.de,
lgirdwood@...il.com, broonie@...nel.org, linux@...ck-us.net,
heikki.krogerus@...ux.intel.com, deller@....de,
andy.shevchenko@...il.com, chiaen_wu@...htek.com,
alice_chen@...htek.com, cy_huang@...htek.com,
dri-devel@...ts.freedesktop.org, linux-leds@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org, linux-usb@...r.kernel.org,
linux-iio@...r.kernel.org, linux-fbdev@...r.kernel.org,
szunichen@...il.com
Subject: Re: [PATCH v6 11/13] leds: rgb: mt6370: Add MediaTek MT6370 current
sink type LED Indicator support
Hi!
> From: ChiYuan Huang <cy_huang@...htek.com>
>
> The MediaTek MT6370 is a highly-integrated smart power management IC,
> which includes a single cell Li-Ion/Li-Polymer switching battery
> charger, a USB Type-C & Power Delivery (PD) controller, dual
> Flash LED current sources, a RGB LED driver, a backlight WLED driver,
> a display bias driver and a general LDO for portable devices.
>
> In MediaTek MT6370, there are four channel current-sink RGB LEDs that
> support hardware pattern for constant current, PWM, and breath mode.
> Isink4 channel can also be used as a CHG_VIN power good indicator.
>
> +config LEDS_MT6370_RGB
> + tristate "LED Support for MediaTek MT6370 PMIC"
> + depends on MFD_MT6370
> + select LINEAR_RANGE
> + help
> + Say Y here to enable support for MT6370_RGB LED device.
> + In MT6370, there are four channel current-sink LED drivers that
> + support hardware pattern for constant current, PWM, and breath mode.
> + Isink4 channel can also be used as a CHG_VIN power good indicator.
That does not really belong here.
> +struct mt6370_priv {
> + /* Per LED access lock */
> + struct mutex lock;
Do we really need per-led locking?
> +static int mt6370_gen_breath_pattern(struct mt6370_priv *priv,
> + struct led_pattern *pattern, u32 len,
> + u8 *pattern_val, u32 val_len)
> +{
> + enum mt6370_led_ranges sel_range;
> + struct led_pattern *curr;
> + unsigned int sel;
> + u8 val[P_MAX_PATTERNS / 2] = {};
> + int i;
> +
> + if (len < P_MAX_PATTERNS && val_len < P_MAX_PATTERNS / 2)
> + return -EINVAL;
> +
> + /*
> + * Pattern list
> + * tr1: byte 0, b'[7: 4]
> + * tr2: byte 0, b'[3: 0]
> + * tf1: byte 1, b'[7: 4]
> + * tf2: byte 1, b'[3: 0]
> + * ton: byte 2, b'[7: 4]
> + * toff: byte 2, b'[3: 0]
> + */
> + for (i = 0; i < P_MAX_PATTERNS; i++) {
> + curr = pattern + i;
> +
> + sel_range = i == P_LED_TOFF ? R_LED_TOFF : R_LED_TRFON;
> +
> + linear_range_get_selector_within(priv->ranges + sel_range,
> + curr->delta_t, &sel);
> +
> + val[i / 2] |= sel << (4 * ((i + 1) % 2));
> + }
> +
> + memcpy(pattern_val, val, 3);
> +
> + return 0;
> +}
I wonder how this works... you are not creating private sysfs
interface, are you?
> +static int mt6370_init_led_properties(struct mt6370_led *led,
> + struct led_init_data *init_data)
> +{
> + struct mt6370_priv *priv = led->priv;
> + struct device *dev = priv->dev;
> + struct led_classdev *lcdev;
> + struct fwnode_handle *child;
> + enum mt6370_led_ranges sel_range;
> + u32 max_uA, max_level;
> + const char * const states[] = { "off", "keep", "on" };
We'd really preffer not to add "keep" / "on" support unless you need
it.
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "led %d, no color specified\n",
> + led->index);
led->LED.
> + if (num_color < 2)
> + return dev_err_probe(dev, -EINVAL,
> + "Multicolor must include
> 2 or more led channel\n");
"LED channels".
> +static int mt6370_isnk_init_default_state(struct mt6370_led *led)
> +{
> + struct mt6370_priv *priv = led->priv;
> + unsigned int enable, level;
> + int ret;
> +
> + ret = mt6370_get_led_brightness(priv, led->index, &level);
> + if (ret)
> + return ret;
> +
> + ret = regmap_field_read(priv->fields[F_RGB_EN], &enable);
> + if (ret)
> + return ret;
> +
> + if (!(enable & MT6370_CHEN_BIT(led->index)))
> + level = LED_OFF;
Just use 0 instead of LED_OFF.
Best regards,
Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists