All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Amireddy Mallikarjuna reddy <mallikarjunax.reddy@linux.intel.com>
Cc: linux-leds@vger.kernel.org, dmurphy@ti.com,
	devicetree@vger.kernel.org, robh+dt@kernel.org,
	linux-kernel@vger.kernel.org, cheol.yong.kim@intel.com,
	qi-ming.wu@intel.com, malliamireddy009@gmail.com,
	yixin.zhu@intel.com
Subject: Re: [PATCH v1 2/2] leds: lgm: Add LED controller driver for LGM Soc
Date: Thu, 5 Nov 2020 11:11:23 +0100	[thread overview]
Message-ID: <20201105101123.GB7994@amd> (raw)
In-Reply-To: <5372c8410909f7b6b020cd379980dbe4e30e31d3.1604331498.git.mallikarjunax.reddy@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3854 bytes --]

Hi!

> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index ed943140e1fd..6445b39fe4fc 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -886,6 +886,16 @@ config LEDS_SGM3140
>  	  This option enables support for the SGM3140 500mA Buck/Boost Charge
>  	  Pump LED Driver.
>  
> +config LEDS_LGM_SSO
> +	tristate "LED support for Intel LGM SOC series"
> +	depends on LEDS_CLASS
> +	depends on MFD_SYSCON
> +	depends on OF
> +	help
> +          Parallel to serial conversion, which is also called SSO controller,
> +          can drive external shift register for LED outputs.
> +	  This enables LED support for Serial Shift Output Controller(SSO).

Something is wrong with indentation here.

> diff --git a/drivers/leds/leds-lgm-sso.c b/drivers/leds/leds-lgm-sso.c

Could we put it into drivers/leds/blink/ directory? You'll need to
create it.

> index 000000000000..f1bae1c6ed3c
> --- /dev/null
> +++ b/drivers/leds/leds-lgm-sso.c
> @@ -0,0 +1,881 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Intel LGM Soc LED SSO driver

Spell out LGM, SSO. Soc->SoC.

Pointer to documentation would be welcome here.

> +enum {
> +	US_SW = 0,
> +	US_GPTC = 1,
> +	US_FPID = 2
> +};

This is not really useful without additional comments.

> +static u32 sso_rectify_brightness(u32 brightness)
> +{
> +	if (brightness > LED_FULL)
> +		return LED_FULL;
> +	else
> +		return brightness;
> +}

Why?

> +static int sso_rectify_blink_rate(struct sso_led_priv *priv, u32 rate)
> +{
> +	int i;
> +
> +	for (i = 0; i < MAX_FREQ_RANK; i++) {
> +		if (rate <= priv->freq[i])
> +			return i;
> +	}
> +
> +	return i - 1;
> +}

Can return -1. Is that expected?

> +
> +		desc->np = to_of_node(fwnode_child);
> +		if (fwnode_property_read_string(fwnode_child, "label",
> +						&desc->name)) {
> +			dev_err(dev, "LED no label name!\n");
> +			goto __dt_err;
> +		}

Can you use appropriate helper from the core? labels are getting
deprecated...


> +		if (fwnode_property_present(fwnode_child,
> +					    "retain-state-suspended"))
> +			desc->retain_state_suspended = 1;

Was this documented in the binding?

> +		if (fwnode_property_read_u32(fwnode_child, "intel,led-pin",
> +					     &prop)) {
> +			dev_err(dev, "Failed to find led pin id!\n");
> +			goto __dt_err;

Would not we normally use something like reg = <x> to indicate pin?

> +		if (fwnode_property_present(fwnode_child,
> +					    "intel,sso-hw-trigger"))
> +			desc->hw_trig = 1;

Should not that be selectable on runtime?

> +		if (fwnode_property_read_u32(fwnode_child,
> +					     "intel,sso-brightness", &prop))
> +			desc->brightness = priv->brightness;
> +		else
> +			desc->brightness = sso_rectify_brightness(prop);

Can you look at "default-state" property?

> +	ret = sso_gpio_gc_init(dev, priv);
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}

Just return ret.

> +
> +	ret = clk_prepare_enable(priv->gclk);
> +	if (ret) {
> +		dev_err(dev, "Failed to prepate/enable sso gate clock!\n");
> +		return ret;
> +	}
> +
> +	priv->fpid_clk = devm_clk_get(dev, "fpid");
> +	if (IS_ERR(priv->fpid_clk)) {
> +		dev_err(dev, "Failed to get fpid clock!\n");
> +		return PTR_ERR(priv->fpid_clk);
> +	}

clk disable here?

> +	ret = clk_prepare_enable(priv->fpid_clk);
> +	if (ret) {
> +		dev_err(dev, "Failed to prepare/enable fpid clock!\n");
> +		return ret;
> +	}
> +	priv->fpid_clkrate = clk_get_rate(priv->fpid_clk);
> +
> +	priv->mmap = syscon_node_to_regmap(dev->of_node);
> +	if (IS_ERR(priv->mmap)) {
> +		dev_err(dev, "Failed to map iomem!\n");
> +		return PTR_ERR(priv->mmap);
> +	}

clk disable here? ... and probably elsewhere?

Best regards,
							Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2020-11-05 10:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05  9:43 [PATCH v1 1/2] dt-bindings: leds: Add bindings for intel LGM SOC Amireddy Mallikarjuna reddy
2020-11-05  9:43 ` [PATCH v1 2/2] leds: lgm: Add LED controller driver for LGM Soc Amireddy Mallikarjuna reddy
2020-11-05 10:11   ` Pavel Machek [this message]
2020-11-11 22:34     ` Reddy, MallikarjunaX
2020-11-05  9:52 ` [PATCH v1 1/2] dt-bindings: leds: Add bindings for intel LGM SOC Pavel Machek
2020-11-11 22:34   ` Reddy, MallikarjunaX
2020-11-05 18:48 ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201105101123.GB7994@amd \
    --to=pavel@ucw.cz \
    --cc=cheol.yong.kim@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=malliamireddy009@gmail.com \
    --cc=mallikarjunax.reddy@linux.intel.com \
    --cc=qi-ming.wu@intel.com \
    --cc=robh+dt@kernel.org \
    --cc=yixin.zhu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.