From: Thierry Reding <thierry.reding@gmail.com>
To: YH Huang <yh.huang@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
srv_heupstream@mediatek.com, linux-mediatek@lists.infradead.org,
Sascha Hauer <kernel@pengutronix.de>,
yingjoe.chen@mediatek.com
Subject: Re: [PATCH v6 2/3] pwm: add MediaTek display PWM driver support
Date: Mon, 17 Aug 2015 15:23:00 +0200 [thread overview]
Message-ID: <20150817132259.GM8453@ulmo.nvidia.com> (raw)
In-Reply-To: <1437380237-28961-3-git-send-email-yh.huang@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 4042 bytes --]
On Mon, Jul 20, 2015 at 04:17:16PM +0800, YH Huang wrote:
> Add display PWM driver support to modify backlight for MT8173 and MT6595.
> The PWM has one channel to control the brightness of the display.
> When the (high_width / period) is closer to 1, the screen is brighter;
> otherwise, it is darker.
>
> Signed-off-by: YH Huang <yh.huang@mediatek.com>
> ---
> drivers/pwm/Kconfig | 10 ++
> drivers/pwm/Makefile | 1 +
> drivers/pwm/pwm-mtk-disp.c | 232 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 243 insertions(+)
> create mode 100644 drivers/pwm/pwm-mtk-disp.c
>
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index b1541f4..f5b03a4 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -211,6 +211,16 @@ config PWM_LPSS_PLATFORM
> To compile this driver as a module, choose M here: the module
> will be called pwm-lpss-platform.
>
> +config PWM_MTK_DISP
> + tristate "MediaTek display PWM driver"
> + depends on ARCH_MEDIATEK || COMPILE_TEST
This is going to break randconfig builds. From a quick look your driver
will fail to build at least on architectures that don't set HAVE_IOMEM.
I know that's quite exotic, but I've had to deal with fallout from
things like this in the past. If you want || COMPILE_TEST you should at
least add a "depends on HAVE_IOMEM".
linux/clk.h seems to have stubs for all of the functions that you use,
so those shouldn't be a problem.
> + help
> + Generic PWM framework driver for MediaTek disp-pwm device.
> + The PWM is used to control the backlight brightness for display.
> +
> + To compile this driver as a module, choose M here: the module
> + will be called pwm-mtk-disp.
> +
> config PWM_MXS
> tristate "Freescale MXS PWM support"
> depends on ARCH_MXS && OF
[...]
> diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c
> new file mode 100644
> index 0000000..69682a0
> --- /dev/null
> +++ b/drivers/pwm/pwm-mtk-disp.c
> @@ -0,0 +1,232 @@
> +/*
> + * MediaTek display pulse-width-modulation controller driver.
> + * Copyright (c) 2015 MediaTek Inc.
> + * Author: YH Huang <yh.huang@mediatek.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/pwm.h>
> +#include <linux/platform_device.h>
The above two aren't correctly sorted.
> +#include <linux/slab.h>
> +
> +#define DISP_PWM_EN 0x00
> +#define PWM_ENABLE_MASK BIT(0)
> +
> +#define DISP_PWM_COMMIT 0x08
> +#define PWM_COMMIT_MASK BIT(0)
> +
> +#define DISP_PWM_CON_0 0x10
> +#define PWM_CLKDIV_SHIFT 16
> +#define PWM_CLKDIV_MAX 0x3ff
> +#define PWM_CLKDIV_MASK (PWM_CLKDIV_MAX << PWM_CLKDIV_SHIFT)
> +
> +#define DISP_PWM_CON_1 0x14
> +#define PWM_PERIOD_MASK 0xfff
> +/* Shift log2(PWM_PERIOD_MASK + 1) as divisor */
> +#define PWM_PERIOD_BIT_SHIFT 12
There are still two names for the same value here. I thought we had
agreed on this becoming something like the below?
#define PWM_PERIOD_BIT_SHIFT 12
#define PWM_PERIOD_MASK ((1 << PWM_PERIOD_BIT_SHIFT) - 1)
Although PWM_PERIOD_BIT_WIDTH would probably be a better name. Or
PWM_PERIOD_BITS or similar.
> +static int mtk_disp_pwm_remove(struct platform_device *pdev)
> +{
> + struct mtk_disp_pwm *mdp = platform_get_drvdata(pdev);
> + int ret = pwmchip_remove(&mdp->chip);
I'd prefer this to be separate lines:
int ret;
ret = pwmchip_remove(&mdp->chip);
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 2/3] pwm: add MediaTek display PWM driver support
Date: Mon, 17 Aug 2015 15:23:00 +0200 [thread overview]
Message-ID: <20150817132259.GM8453@ulmo.nvidia.com> (raw)
In-Reply-To: <1437380237-28961-3-git-send-email-yh.huang@mediatek.com>
On Mon, Jul 20, 2015 at 04:17:16PM +0800, YH Huang wrote:
> Add display PWM driver support to modify backlight for MT8173 and MT6595.
> The PWM has one channel to control the brightness of the display.
> When the (high_width / period) is closer to 1, the screen is brighter;
> otherwise, it is darker.
>
> Signed-off-by: YH Huang <yh.huang@mediatek.com>
> ---
> drivers/pwm/Kconfig | 10 ++
> drivers/pwm/Makefile | 1 +
> drivers/pwm/pwm-mtk-disp.c | 232 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 243 insertions(+)
> create mode 100644 drivers/pwm/pwm-mtk-disp.c
>
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index b1541f4..f5b03a4 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -211,6 +211,16 @@ config PWM_LPSS_PLATFORM
> To compile this driver as a module, choose M here: the module
> will be called pwm-lpss-platform.
>
> +config PWM_MTK_DISP
> + tristate "MediaTek display PWM driver"
> + depends on ARCH_MEDIATEK || COMPILE_TEST
This is going to break randconfig builds. From a quick look your driver
will fail to build at least on architectures that don't set HAVE_IOMEM.
I know that's quite exotic, but I've had to deal with fallout from
things like this in the past. If you want || COMPILE_TEST you should at
least add a "depends on HAVE_IOMEM".
linux/clk.h seems to have stubs for all of the functions that you use,
so those shouldn't be a problem.
> + help
> + Generic PWM framework driver for MediaTek disp-pwm device.
> + The PWM is used to control the backlight brightness for display.
> +
> + To compile this driver as a module, choose M here: the module
> + will be called pwm-mtk-disp.
> +
> config PWM_MXS
> tristate "Freescale MXS PWM support"
> depends on ARCH_MXS && OF
[...]
> diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c
> new file mode 100644
> index 0000000..69682a0
> --- /dev/null
> +++ b/drivers/pwm/pwm-mtk-disp.c
> @@ -0,0 +1,232 @@
> +/*
> + * MediaTek display pulse-width-modulation controller driver.
> + * Copyright (c) 2015 MediaTek Inc.
> + * Author: YH Huang <yh.huang@mediatek.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/pwm.h>
> +#include <linux/platform_device.h>
The above two aren't correctly sorted.
> +#include <linux/slab.h>
> +
> +#define DISP_PWM_EN 0x00
> +#define PWM_ENABLE_MASK BIT(0)
> +
> +#define DISP_PWM_COMMIT 0x08
> +#define PWM_COMMIT_MASK BIT(0)
> +
> +#define DISP_PWM_CON_0 0x10
> +#define PWM_CLKDIV_SHIFT 16
> +#define PWM_CLKDIV_MAX 0x3ff
> +#define PWM_CLKDIV_MASK (PWM_CLKDIV_MAX << PWM_CLKDIV_SHIFT)
> +
> +#define DISP_PWM_CON_1 0x14
> +#define PWM_PERIOD_MASK 0xfff
> +/* Shift log2(PWM_PERIOD_MASK + 1) as divisor */
> +#define PWM_PERIOD_BIT_SHIFT 12
There are still two names for the same value here. I thought we had
agreed on this becoming something like the below?
#define PWM_PERIOD_BIT_SHIFT 12
#define PWM_PERIOD_MASK ((1 << PWM_PERIOD_BIT_SHIFT) - 1)
Although PWM_PERIOD_BIT_WIDTH would probably be a better name. Or
PWM_PERIOD_BITS or similar.
> +static int mtk_disp_pwm_remove(struct platform_device *pdev)
> +{
> + struct mtk_disp_pwm *mdp = platform_get_drvdata(pdev);
> + int ret = pwmchip_remove(&mdp->chip);
I'd prefer this to be separate lines:
int ret;
ret = pwmchip_remove(&mdp->chip);
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150817/cfca2726/attachment.sig>
next prev parent reply other threads:[~2015-08-17 13:23 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-20 8:17 [PATCH v6 0/3] Add MediaTek display PWM driver YH Huang
2015-07-20 8:17 ` YH Huang
2015-07-20 8:17 ` YH Huang
2015-07-20 8:17 ` [PATCH v6 1/3] dt-bindings: pwm: add MediaTek display PWM bindings YH Huang
2015-07-20 8:17 ` YH Huang
2015-07-20 8:17 ` YH Huang
[not found] ` <1437380237-28961-2-git-send-email-yh.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-07-24 8:40 ` Matthias Brugger
2015-07-24 8:40 ` Matthias Brugger
2015-07-24 8:40 ` Matthias Brugger
2015-07-24 9:00 ` Daniel Kurtz
2015-07-24 9:00 ` Daniel Kurtz
[not found] ` <CAGS+omAzhfCAoGArK8XUMhNFuqiErPcvGh0q=+Se1dHeBnJyUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-24 12:56 ` Matthias Brugger
2015-07-24 12:56 ` Matthias Brugger
2015-07-24 12:56 ` Matthias Brugger
2015-08-17 13:23 ` Thierry Reding
2015-08-17 13:23 ` Thierry Reding
[not found] ` <20150817132358.GN8453-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-08-18 2:23 ` YH Huang
2015-08-18 2:23 ` YH Huang
2015-08-18 2:23 ` YH Huang
[not found] ` <1437380237-28961-1-git-send-email-yh.huang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-07-20 8:17 ` [PATCH v6 2/3] pwm: add MediaTek display PWM driver support YH Huang
2015-07-20 8:17 ` YH Huang
2015-07-20 8:17 ` YH Huang
2015-08-17 13:23 ` Thierry Reding [this message]
2015-08-17 13:23 ` Thierry Reding
[not found] ` <20150817132259.GM8453-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-08-18 2:47 ` YH Huang
2015-08-18 2:47 ` YH Huang
2015-08-18 2:47 ` YH Huang
2015-07-20 8:17 ` [PATCH v6 3/3] arm64: dts: mt8173: add MT8173 display PWM driver support node YH Huang
2015-07-20 8:17 ` YH Huang
2015-07-20 8:17 ` YH Huang
2015-07-20 12:22 ` Daniel Kurtz
2015-07-20 12:22 ` Daniel Kurtz
2015-07-24 8:42 ` [PATCH v6 0/3] Add MediaTek display PWM driver Matthias Brugger
2015-07-24 8:42 ` Matthias Brugger
2015-07-24 9:10 ` YH Huang
2015-07-24 9:10 ` YH Huang
2015-07-24 9:10 ` YH Huang
2015-07-29 3:01 ` YH Huang
2015-07-29 3:01 ` YH Huang
2015-07-29 3:01 ` YH Huang
2015-08-03 6:21 ` YH Huang
2015-08-03 6:21 ` YH Huang
2015-08-03 6:21 ` YH Huang
2015-08-11 3:38 ` Daniel Kurtz
2015-08-11 3:38 ` Daniel Kurtz
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=20150817132259.GM8453@ulmo.nvidia.com \
--to=thierry.reding@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=srv_heupstream@mediatek.com \
--cc=yh.huang@mediatek.com \
--cc=yingjoe.chen@mediatek.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.