[RESEND PATCH v6] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> Acked-by: Rob Herring <r...@kernel.org> --- Change Log: v6: It supports polarity specified in DTB and #pwm-cells can be set to 3. v5: remove the generic compatible string "hisilicon, hibvt-pwm". v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 271 + 4 files changed, 302 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..fa7849d --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,21 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string + The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 3. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + compatible = "hisilicon,hi3516cv300-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <3>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..d0e8f85 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,271 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARIT
[RESEND PATCH v6] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan Acked-by: Rob Herring --- Change Log: v6: It supports polarity specified in DTB and #pwm-cells can be set to 3. v5: remove the generic compatible string "hisilicon, hibvt-pwm". v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 271 + 4 files changed, 302 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..fa7849d --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,21 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string + The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 3. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + compatible = "hisilicon,hi3516cv300-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <3>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..d0e8f85 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,271 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#defin
Re: [PATCH v6] pwm: add pwm driver for HiSilicon BVT SOCs
Hi, Thierry, Are there any issues with the PWM driver below. I would like to request some comment and advice form you, if you had reviewed the driver code. With best wishes, Jian Yuan On 2016/11/28 17:42, Jian Yuan wrote: > From: yuanjian <yuanjia...@hisilicon.com> > > Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like > Hi3519V100, Hi3516CV300, etc. > The PWM controller is primarily in charge of controlling P-Iris lens. > > Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> > Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> > --- > Acked-by: Rob Herring <r...@kernel.org> > > Change Log: > v6: > It supports polarity specified in DTB and #pwm-cells can be set to 3. > v5: > remove the generic compatible string "hisilicon, hibvt-pwm". > v4: > Add #pwm-cells in the bindings document. > v3: > fixed issues pointed by thierry. > Add PWM compatible string for Hi3519V100. > Implement .apply() function which support atomic, instead of > .enable()/.disable()/.config(). > v2: > The number of PWMs is change to be probeable based on the compatible string. > > .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ > drivers/pwm/Kconfig| 9 + > drivers/pwm/Makefile | 1 + > drivers/pwm/pwm-hibvt.c| 271 > + > 4 files changed, 302 insertions(+) > create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > create mode 100644 drivers/pwm/pwm-hibvt.c > > diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > new file mode 100644 > index 000..fa7849d > --- /dev/null > +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > @@ -0,0 +1,21 @@ > +Hisilicon PWM controller > + > +Required properties: > +-compatible: should contain one SoC specific compatible string > + The SoC specific strings supported including: > + "hisilicon,hi3516cv300-pwm" > + "hisilicon,hi3519v100-pwm" > +- reg: physical base address and length of the controller's registers. > +- clocks: phandle and clock specifier of the PWM reference clock. > +- resets: phandle and reset specifier for the PWM controller reset. > +- #pwm-cells: Should be 3. See pwm.txt in this directory for a description of > + the cells format. > + > +Example: > + pwm: pwm@1213 { > + compatible = "hisilicon,hi3516cv300-pwm"; > + reg = <0x1213 0x1>; > + clocks = <_ctrl HI3516CV300_PWM_CLK>; > + resets = <_ctrl 0x38 0>; > + #pwm-cells = <3>; > + }; > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig > index c182efc..b2d7408 100644 > --- a/drivers/pwm/Kconfig > +++ b/drivers/pwm/Kconfig > @@ -158,6 +158,15 @@ config PWM_FSL_FTM > To compile this driver as a module, choose M here: the module > will be called pwm-fsl-ftm. > > +config PWM_HIBVT > + tristate "HiSilicon BVT PWM support" > + depends on ARCH_HISI || COMPILE_TEST > + help > + Generic PWM framework driver for HiSilicon BVT SoCs. > + > + To compile this driver as a module, choose M here: the module > + will be called pwm-hibvt. > + > config PWM_IMG > tristate "Imagination Technologies PWM driver" > depends on HAS_IOMEM > diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile > index dd35bc1..37ec39e 100644 > --- a/drivers/pwm/Makefile > +++ b/drivers/pwm/Makefile > @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X) += pwm-clps711x.o > obj-$(CONFIG_PWM_CRC)+= pwm-crc.o > obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o > obj-$(CONFIG_PWM_FSL_FTM)+= pwm-fsl-ftm.o > +obj-$(CONFIG_PWM_HIBVT) += pwm-hibvt.o > obj-$(CONFIG_PWM_IMG)+= pwm-img.o > obj-$(CONFIG_PWM_IMX)+= pwm-imx.o > obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o > diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c > new file mode 100644 > index 000..d0e8f85 > --- /dev/null > +++ b/drivers/pwm/pwm-hibvt.c > @@ -0,0 +1,271 @@ > +/* > + * PWM Controller Driver for HiSilicon BVT SoCs > + * > + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the
Re: [PATCH v6] pwm: add pwm driver for HiSilicon BVT SOCs
Hi, Thierry, Are there any issues with the PWM driver below. I would like to request some comment and advice form you, if you had reviewed the driver code. With best wishes, Jian Yuan On 2016/11/28 17:42, Jian Yuan wrote: > From: yuanjian > > Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like > Hi3519V100, Hi3516CV300, etc. > The PWM controller is primarily in charge of controlling P-Iris lens. > > Reviewed-by: Jiancheng Xue > Signed-off-by: Jian Yuan > --- > Acked-by: Rob Herring > > Change Log: > v6: > It supports polarity specified in DTB and #pwm-cells can be set to 3. > v5: > remove the generic compatible string "hisilicon, hibvt-pwm". > v4: > Add #pwm-cells in the bindings document. > v3: > fixed issues pointed by thierry. > Add PWM compatible string for Hi3519V100. > Implement .apply() function which support atomic, instead of > .enable()/.disable()/.config(). > v2: > The number of PWMs is change to be probeable based on the compatible string. > > .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ > drivers/pwm/Kconfig| 9 + > drivers/pwm/Makefile | 1 + > drivers/pwm/pwm-hibvt.c| 271 > + > 4 files changed, 302 insertions(+) > create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > create mode 100644 drivers/pwm/pwm-hibvt.c > > diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > new file mode 100644 > index 000..fa7849d > --- /dev/null > +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt > @@ -0,0 +1,21 @@ > +Hisilicon PWM controller > + > +Required properties: > +-compatible: should contain one SoC specific compatible string > + The SoC specific strings supported including: > + "hisilicon,hi3516cv300-pwm" > + "hisilicon,hi3519v100-pwm" > +- reg: physical base address and length of the controller's registers. > +- clocks: phandle and clock specifier of the PWM reference clock. > +- resets: phandle and reset specifier for the PWM controller reset. > +- #pwm-cells: Should be 3. See pwm.txt in this directory for a description of > + the cells format. > + > +Example: > + pwm: pwm@1213 { > + compatible = "hisilicon,hi3516cv300-pwm"; > + reg = <0x1213 0x1>; > + clocks = <_ctrl HI3516CV300_PWM_CLK>; > + resets = <_ctrl 0x38 0>; > + #pwm-cells = <3>; > + }; > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig > index c182efc..b2d7408 100644 > --- a/drivers/pwm/Kconfig > +++ b/drivers/pwm/Kconfig > @@ -158,6 +158,15 @@ config PWM_FSL_FTM > To compile this driver as a module, choose M here: the module > will be called pwm-fsl-ftm. > > +config PWM_HIBVT > + tristate "HiSilicon BVT PWM support" > + depends on ARCH_HISI || COMPILE_TEST > + help > + Generic PWM framework driver for HiSilicon BVT SoCs. > + > + To compile this driver as a module, choose M here: the module > + will be called pwm-hibvt. > + > config PWM_IMG > tristate "Imagination Technologies PWM driver" > depends on HAS_IOMEM > diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile > index dd35bc1..37ec39e 100644 > --- a/drivers/pwm/Makefile > +++ b/drivers/pwm/Makefile > @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X) += pwm-clps711x.o > obj-$(CONFIG_PWM_CRC)+= pwm-crc.o > obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o > obj-$(CONFIG_PWM_FSL_FTM)+= pwm-fsl-ftm.o > +obj-$(CONFIG_PWM_HIBVT) += pwm-hibvt.o > obj-$(CONFIG_PWM_IMG)+= pwm-img.o > obj-$(CONFIG_PWM_IMX)+= pwm-imx.o > obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o > diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c > new file mode 100644 > index 000..d0e8f85 > --- /dev/null > +++ b/drivers/pwm/pwm-hibvt.c > @@ -0,0 +1,271 @@ > +/* > + * PWM Controller Driver for HiSilicon BVT SoCs > + * > + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHAN
[PATCH v6] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Acked-by: Rob Herring <r...@kernel.org> Change Log: v6: It supports polarity specified in DTB and #pwm-cells can be set to 3. v5: remove the generic compatible string "hisilicon, hibvt-pwm". v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 271 + 4 files changed, 302 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..fa7849d --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,21 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string + The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 3. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + compatible = "hisilicon,hi3516cv300-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <3>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..d0e8f85 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,271 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARIT
[PATCH v6] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Acked-by: Rob Herring Change Log: v6: It supports polarity specified in DTB and #pwm-cells can be set to 3. v5: remove the generic compatible string "hisilicon, hibvt-pwm". v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 271 + 4 files changed, 302 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..fa7849d --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,21 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string + The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 3. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + compatible = "hisilicon,hi3516cv300-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <3>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..d0e8f85 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,271 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#defin
Re: [PATCH v5] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/11/17 7:55, Vladimir Zapolskiy wrote: > On 11/16/2016 11:50 AM, Jian Yuan wrote: >> From: yuanjian <yuanjia...@hisilicon.com> >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >> --- >> Change Log: >> v5: >> remove the generic compatible string "hisilicon, hibvt-pwm". >> v4: >> Add #pwm-cells in the bindings document. >> v3: >> fixed issues pointed by thierry. >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 269 >> + >> 4 files changed, 301 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..fe63950 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,22 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string >> + The SoC specific strings supported including: >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. >> +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description >> of > > Since the controller has separate polarity control register, and > the driver handles polarity settings, please test/change #pwm-cells > set to 3. It is better to do it right now before someone wants > to change number of cells in future and support polarity specified > in DTB. > Goog advice. I would add it in next patch v6. >> + the cells format. >> + >> +Example: >> +pwm: pwm@1213 { >> + > > Remove empty line above. > Ok. >> +compatible = "hisilicon,hi3516cv300-pwm"; >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +#pwm-cells = <2>; > > After tesing #pwm-cells = <3> don't forget to updated this line. > Got it. Thanks, Jian Yuan >> +}; > > -- > With best wishes, > Vladimir > > . >
Re: [PATCH v5] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/11/17 7:55, Vladimir Zapolskiy wrote: > On 11/16/2016 11:50 AM, Jian Yuan wrote: >> From: yuanjian >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue >> Signed-off-by: Jian Yuan >> --- >> Change Log: >> v5: >> remove the generic compatible string "hisilicon, hibvt-pwm". >> v4: >> Add #pwm-cells in the bindings document. >> v3: >> fixed issues pointed by thierry. >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 269 >> + >> 4 files changed, 301 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..fe63950 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,22 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string >> + The SoC specific strings supported including: >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. >> +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description >> of > > Since the controller has separate polarity control register, and > the driver handles polarity settings, please test/change #pwm-cells > set to 3. It is better to do it right now before someone wants > to change number of cells in future and support polarity specified > in DTB. > Goog advice. I would add it in next patch v6. >> + the cells format. >> + >> +Example: >> +pwm: pwm@1213 { >> + > > Remove empty line above. > Ok. >> +compatible = "hisilicon,hi3516cv300-pwm"; >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +#pwm-cells = <2>; > > After tesing #pwm-cells = <3> don't forget to updated this line. > Got it. Thanks, Jian Yuan >> +}; > > -- > With best wishes, > Vladimir > > . >
Re: [RESEND PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/11/16 21:48, Rob Herring wrote: > On Tue, Nov 15, 2016 at 08:41:32PM +0800, Jian Yuan wrote: >> From: yuanjian <yuanjia...@hisilicon.com> >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. > > Wrap your lines at ~72 chars. > >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >> --- >> Change Log: >> v4: >> Add #pwm-cells in the bindings document. >> v3: >> fixed issues pointed by thierry. >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 270 >> + >> 4 files changed, 303 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..609284f >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,23 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string and one >> generic compatible > > ditto > Ok. >> +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. >> +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description >> of >> + the cells format. >> + >> +Example: >> +pwm: pwm@1213 { >> + >> +compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; >> +compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; > > ?? > It had been removed in next patch v5. You can check it out. With best wishes. >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +#pwm-cells = <2>; >> +}; > > . >
Re: [RESEND PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/11/16 21:48, Rob Herring wrote: > On Tue, Nov 15, 2016 at 08:41:32PM +0800, Jian Yuan wrote: >> From: yuanjian >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. > > Wrap your lines at ~72 chars. > >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue >> Signed-off-by: Jian Yuan >> --- >> Change Log: >> v4: >> Add #pwm-cells in the bindings document. >> v3: >> fixed issues pointed by thierry. >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 270 >> + >> 4 files changed, 303 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..609284f >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,23 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string and one >> generic compatible > > ditto > Ok. >> +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. >> +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description >> of >> + the cells format. >> + >> +Example: >> +pwm: pwm@1213 { >> + >> +compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; >> +compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; > > ?? > It had been removed in next patch v5. You can check it out. With best wishes. >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +#pwm-cells = <2>; >> +}; > > . >
[PATCH v5] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Change Log: v5: remove the generic compatible string "hisilicon, hibvt-pwm". v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 269 + 4 files changed, 301 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..fe63950 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,22 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string + The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <2>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..feadb3d --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,269 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#de
[PATCH v5] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Change Log: v5: remove the generic compatible string "hisilicon, hibvt-pwm". v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 22 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 269 + 4 files changed, 301 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..fe63950 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,22 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string + The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <2>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..feadb3d --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,269 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASK GENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hi
[RESEND PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Change Log: v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..609284f --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,23 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <2>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define
[RESEND PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Change Log: v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..609284f --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,23 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <2>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KE
Re: [PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/10/21 15:34, Thierry Reding wrote: > On Fri, Oct 21, 2016 at 09:22:36AM +0200, Thierry Reding wrote: >> On Mon, Oct 10, 2016 at 04:53:39PM -0500, Rob Herring wrote: >>> On Mon, Oct 10, 2016 at 07:05:16PM +0800, Jian Yuan wrote: >>>> From: yuanjian <yuanjia...@hisilicon.com> >>>> >>>> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >>>> Hi3519V100, Hi3516CV300, etc. >>>> The PWM controller is primarily in charge of controlling P-Iris lens. >>>> >>>> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >>>> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >>>> --- >>>> Change Log: >>>> v4: >>>> Add #pwm-cells in the bindings document. >>>> v3: >>>> fixed issues pointed by thierry. >>>> Add PWM compatible string for Hi3519V100. >>>> Implement .apply() function which support atomic, instead of >>>> .enable()/.disable()/.config(). >>>> v2: >>>> The number of PWMs is change to be probeable based on the compatible >>>> string. >>>> >>>> .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ >>>> drivers/pwm/Kconfig| 9 + >>>> drivers/pwm/Makefile | 1 + >>>> drivers/pwm/pwm-hibvt.c| 270 >>>> + >>>> 4 files changed, 303 insertions(+) >>>> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> create mode 100644 drivers/pwm/pwm-hibvt.c >>>> >>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> new file mode 100644 >>>> index 000..609284f >>>> --- /dev/null >>>> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> @@ -0,0 +1,23 @@ >>>> +Hisilicon PWM controller >>>> + >>>> +Required properties: >>>> +-compatible: should contain one SoC specific compatible string and one >>>> generic compatible >>>> +string "hisilicon, hibvt-pwm". The SoC specific strings supported >>>> including: >>> >>> Extra space ^ >>> >>> With that, for the binding: >>> >>> Acked-by: Rob Herring <r...@kernel.org> >> >> I'm wondering what the use is of the generic compatible string? Not only >> is the driver not listing it, nor is it in any way useful since there is >> nothing the driver could do based on the generic compatible string (each >> version of the IP currently supported has a different number of PWM >> channels). > > Actually it's worse. The driver does have an entry for the generic > compatible string but it doesn't assign .data in that case (which is > really what I was saying above). Now according to the bindings it is > disallowed to have only the generic compatible string, which is good > because doing so would crash the driver on probe. > > So, if it's not allowed to have only the generic compatible string, > why even have one at all? We always have an SoC-specific compatible > string as well, so the generic one is completely redundant. > > Thierry > Hi, Thierry, are there some other issue about driver except the generic compatible string? awaiting your reply. thanks. Jian Yuan.
Re: [PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/10/21 15:34, Thierry Reding wrote: > On Fri, Oct 21, 2016 at 09:22:36AM +0200, Thierry Reding wrote: >> On Mon, Oct 10, 2016 at 04:53:39PM -0500, Rob Herring wrote: >>> On Mon, Oct 10, 2016 at 07:05:16PM +0800, Jian Yuan wrote: >>>> From: yuanjian >>>> >>>> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >>>> Hi3519V100, Hi3516CV300, etc. >>>> The PWM controller is primarily in charge of controlling P-Iris lens. >>>> >>>> Reviewed-by: Jiancheng Xue >>>> Signed-off-by: Jian Yuan >>>> --- >>>> Change Log: >>>> v4: >>>> Add #pwm-cells in the bindings document. >>>> v3: >>>> fixed issues pointed by thierry. >>>> Add PWM compatible string for Hi3519V100. >>>> Implement .apply() function which support atomic, instead of >>>> .enable()/.disable()/.config(). >>>> v2: >>>> The number of PWMs is change to be probeable based on the compatible >>>> string. >>>> >>>> .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ >>>> drivers/pwm/Kconfig| 9 + >>>> drivers/pwm/Makefile | 1 + >>>> drivers/pwm/pwm-hibvt.c| 270 >>>> + >>>> 4 files changed, 303 insertions(+) >>>> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> create mode 100644 drivers/pwm/pwm-hibvt.c >>>> >>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> new file mode 100644 >>>> index 000..609284f >>>> --- /dev/null >>>> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >>>> @@ -0,0 +1,23 @@ >>>> +Hisilicon PWM controller >>>> + >>>> +Required properties: >>>> +-compatible: should contain one SoC specific compatible string and one >>>> generic compatible >>>> +string "hisilicon, hibvt-pwm". The SoC specific strings supported >>>> including: >>> >>> Extra space ^ >>> >>> With that, for the binding: >>> >>> Acked-by: Rob Herring >> >> I'm wondering what the use is of the generic compatible string? Not only >> is the driver not listing it, nor is it in any way useful since there is >> nothing the driver could do based on the generic compatible string (each >> version of the IP currently supported has a different number of PWM >> channels). > > Actually it's worse. The driver does have an entry for the generic > compatible string but it doesn't assign .data in that case (which is > really what I was saying above). Now according to the bindings it is > disallowed to have only the generic compatible string, which is good > because doing so would crash the driver on probe. > > So, if it's not allowed to have only the generic compatible string, > why even have one at all? We always have an SoC-specific compatible > string as well, so the generic one is completely redundant. > > Thierry > Hi, Thierry, are there some other issue about driver except the generic compatible string? awaiting your reply. thanks. Jian Yuan.
Re: [PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/10/11 5:53, Rob Herring wrote: > On Mon, Oct 10, 2016 at 07:05:16PM +0800, Jian Yuan wrote: >> From: yuanjian <yuanjia...@hisilicon.com> >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >> --- >> Change Log: >> v4: >> Add #pwm-cells in the bindings document. >> v3: >> fixed issues pointed by thierry. >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 270 >> + >> 4 files changed, 303 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..609284f >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,23 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string and one >> generic compatible >> +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: > > Extra space ^ > > With that, for the binding: > > Acked-by: Rob Herring <r...@kernel.org> > Hi, Rob, I am ready to remove the generic compatible string, because I think it's not useful and it would affect the driver on probe when only a generic compatible string existed. changed as follows: pwm: pwm@1213 { compatible = "hisilicon,hi3516cv300-pwm"; reg = <0x1213 0x1>; clocks = <_ctrl HI3516CV300_PWM_CLK>; resets = <_ctrl 0x38 0>; #pwm-cells = <2>; }; Is that ok? Jian Yuan. >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. >> +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description >> of >> + the cells format. >> + >> +Example: >> +pwm: pwm@1213 { >> + >> +compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; >> +compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +#pwm-cells = <2>; >> +}; > > . >
Re: [PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/10/11 5:53, Rob Herring wrote: > On Mon, Oct 10, 2016 at 07:05:16PM +0800, Jian Yuan wrote: >> From: yuanjian >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue >> Signed-off-by: Jian Yuan >> --- >> Change Log: >> v4: >> Add #pwm-cells in the bindings document. >> v3: >> fixed issues pointed by thierry. >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 270 >> + >> 4 files changed, 303 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..609284f >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,23 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string and one >> generic compatible >> +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: > > Extra space ^ > > With that, for the binding: > > Acked-by: Rob Herring > Hi, Rob, I am ready to remove the generic compatible string, because I think it's not useful and it would affect the driver on probe when only a generic compatible string existed. changed as follows: pwm: pwm@1213 { compatible = "hisilicon,hi3516cv300-pwm"; reg = <0x1213 0x1>; clocks = <_ctrl HI3516CV300_PWM_CLK>; resets = <_ctrl 0x38 0>; #pwm-cells = <2>; }; Is that ok? Jian Yuan. >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. >> +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description >> of >> + the cells format. >> + >> +Example: >> +pwm: pwm@1213 { >> + >> +compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; >> +compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +#pwm-cells = <2>; >> +}; > > . >
[PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Change Log: v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..609284f --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,23 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <2>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define
[PATCH v4] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Change Log: v4: Add #pwm-cells in the bindings document. v3: fixed issues pointed by thierry. Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 23 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..609284f --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,23 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. +- #pwm-cells: Should be 2. See pwm.txt in this directory for a description of + the cells format. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + #pwm-cells = <2>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KE
[PATCH v3] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Change Log: v3: Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 20 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 300 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..2ecf4e4 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,20 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASK GENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +str
[PATCH v3] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Change Log: v3: Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 20 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 300 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..2ecf4e4 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,20 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASK GENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hibvt_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem
Re: [PATCH v3] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/9/20 22:43, Rob Herring wrote: > On Mon, Sep 12, 2016 at 09:51:46AM +0800, Jian Yuan wrote: >> From: yuanjian <yuanjia...@hisilicon.com> >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >> --- >> Change Log: >> v3: >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 20 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 270 >> + >> 4 files changed, 300 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..2ecf4e4 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,20 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string and one >> generic compatible >> +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. > > You are missing #pwm-cells. > Ok, thanks.
Re: [PATCH v3] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/9/20 22:43, Rob Herring wrote: > On Mon, Sep 12, 2016 at 09:51:46AM +0800, Jian Yuan wrote: >> From: yuanjian >> >> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like >> Hi3519V100, Hi3516CV300, etc. >> The PWM controller is primarily in charge of controlling P-Iris lens. >> >> Reviewed-by: Jiancheng Xue >> Signed-off-by: Jian Yuan >> --- >> Change Log: >> v3: >> Add PWM compatible string for Hi3519V100. >> Implement .apply() function which support atomic, instead of >> .enable()/.disable()/.config(). >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 20 ++ >> drivers/pwm/Kconfig| 9 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 270 >> + >> 4 files changed, 300 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..2ecf4e4 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,20 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one SoC specific compatible string and one >> generic compatible >> +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: >> +"hisilicon,hi3516cv300-pwm" >> +"hisilicon,hi3519v100-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: phandle and reset specifier for the PWM controller reset. > > You are missing #pwm-cells. > Ok, thanks.
[PATCH v3] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Change Log: v3: Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 20 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 300 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..2ecf4e4 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,20 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASK GENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +str
[PATCH v3] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add PWM driver for the PWM controller found on HiSilicon BVT SOCs, like Hi3519V100, Hi3516CV300, etc. The PWM controller is primarily in charge of controlling P-Iris lens. Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Change Log: v3: Add PWM compatible string for Hi3519V100. Implement .apply() function which support atomic, instead of .enable()/.disable()/.config(). v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 20 ++ drivers/pwm/Kconfig| 9 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 270 + 4 files changed, 300 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..2ecf4e4 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,20 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one SoC specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The SoC specific strings supported including: + "hisilicon,hi3516cv300-pwm" + "hisilicon,hi3519v100-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: phandle and reset specifier for the PWM controller reset. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + compatible = "hisilicon,hi3519v100-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..b2d7408 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI || COMPILE_TEST + help + Generic PWM framework driver for HiSilicon BVT SoCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..1c14c21 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,270 @@ +/* + * PWM Controller Driver for HiSilicon BVT SoCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASK BIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASK GENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hibvt_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem
Re: [PATCH v2] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/8/24 21:05, Thierry Reding wrote: > On Mon, Aug 22, 2016 at 03:50:13PM +0800, Jian Yuan wrote: >> From: yuanjian <yuanjia...@hisilicon.com> >> >> Add pwm driver for HiSilicon BVT SOCs > > pwm -> PWM, please. It'd be good to have more information here about > what the hardware can do, where to find it, etc. > Not sure what you mean? Should I describe what the PWM or the BVT SoCs can do? >> >> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >> --- >> Change Log: >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ >> drivers/pwm/Kconfig| 10 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 274 >> + >> 4 files changed, 303 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..1274119 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,18 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one soc specific compatible string and one >> generic compatible >> +string "hisilicon, hibvt-pwm". The soc specific strings supported including: > > Why the generic compatible string? You've already shown in the driver > that the two versions you support aren't compatible. > The generic compatible string should be contained in every devicetree bindings that BVT Socs support. But I'll add another specific compatible string to distinguish it from "hisilicon,hi3516cv300-pwm". > Also soc -> SoC, please. > >> +"hisilicon,hi3516cv300-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: offset address and offset bit for reset or unreset of the >> controller. > > That's weird. Usually this should say just that the property should > contain the phandle plus a reset specifier for the controller reset. The > above description already defines what the specifier looks like, which > may not be true on all SoCs that this hardware gets integrated into. > Ok. >> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig >> index c182efc..3c48768 100644 >> --- a/drivers/pwm/Kconfig >> +++ b/drivers/pwm/Kconfig >> @@ -158,6 +158,15 @@ config PWM_FSL_FTM >>To compile this driver as a module, choose M here: the module >>will be called pwm-fsl-ftm. >> >> +config PWM_HIBVT >> +tristate "HiSilicon BVT PWM support" >> +depends on ARCH_HISI >> +help >> + Generic PWM framework driver for hisilicon BVT SOCs. > > Please use a consistent spelling for HiSilicon. Also: SOC -> SoC. > Ok. >> @@ -438,4 +447,5 @@ config PWM_VT8500 >>To compile this driver as a module, choose M here: the module >>will be called pwm-vt8500. >> >> + > > Please don't add this extra blank line. > Ok. >> diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c > [...] >> new file mode 100644 >> index 000..84f617e >> --- /dev/null >> +++ b/drivers/pwm/pwm-hibvt.c >> @@ -0,0 +1,274 @@ >> +/* >> + * PWM Controller Driver for HiSilicon BVT SOCs >> + * >> + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + * >> + * 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. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program. If not, see <http://www.gnu.org/licenses/>. >> + */ >> + >> +#include >> +#include >
Re: [PATCH v2] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/8/24 21:05, Thierry Reding wrote: > On Mon, Aug 22, 2016 at 03:50:13PM +0800, Jian Yuan wrote: >> From: yuanjian >> >> Add pwm driver for HiSilicon BVT SOCs > > pwm -> PWM, please. It'd be good to have more information here about > what the hardware can do, where to find it, etc. > Not sure what you mean? Should I describe what the PWM or the BVT SoCs can do? >> >> Reviewed-by: Jiancheng Xue >> Signed-off-by: Jian Yuan >> --- >> Change Log: >> v2: >> The number of PWMs is change to be probeable based on the compatible string. >> >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ >> drivers/pwm/Kconfig| 10 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 274 >> + >> 4 files changed, 303 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..1274119 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,18 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> +-compatible: should contain one soc specific compatible string and one >> generic compatible >> +string "hisilicon, hibvt-pwm". The soc specific strings supported including: > > Why the generic compatible string? You've already shown in the driver > that the two versions you support aren't compatible. > The generic compatible string should be contained in every devicetree bindings that BVT Socs support. But I'll add another specific compatible string to distinguish it from "hisilicon,hi3516cv300-pwm". > Also soc -> SoC, please. > >> +"hisilicon,hi3516cv300-pwm" >> +- reg: physical base address and length of the controller's registers. >> +- clocks: phandle and clock specifier of the PWM reference clock. >> +- resets: offset address and offset bit for reset or unreset of the >> controller. > > That's weird. Usually this should say just that the property should > contain the phandle plus a reset specifier for the controller reset. The > above description already defines what the specifier looks like, which > may not be true on all SoCs that this hardware gets integrated into. > Ok. >> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig >> index c182efc..3c48768 100644 >> --- a/drivers/pwm/Kconfig >> +++ b/drivers/pwm/Kconfig >> @@ -158,6 +158,15 @@ config PWM_FSL_FTM >>To compile this driver as a module, choose M here: the module >>will be called pwm-fsl-ftm. >> >> +config PWM_HIBVT >> +tristate "HiSilicon BVT PWM support" >> +depends on ARCH_HISI >> +help >> + Generic PWM framework driver for hisilicon BVT SOCs. > > Please use a consistent spelling for HiSilicon. Also: SOC -> SoC. > Ok. >> @@ -438,4 +447,5 @@ config PWM_VT8500 >>To compile this driver as a module, choose M here: the module >>will be called pwm-vt8500. >> >> + > > Please don't add this extra blank line. > Ok. >> diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c > [...] >> new file mode 100644 >> index 000..84f617e >> --- /dev/null >> +++ b/drivers/pwm/pwm-hibvt.c >> @@ -0,0 +1,274 @@ >> +/* >> + * PWM Controller Driver for HiSilicon BVT SOCs >> + * >> + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License as published by >> + * the Free Software Foundation; either version 2 of the License, or >> + * (at your option) any later version. >> + * >> + * 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. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program. If not, see <http://www.gnu.org/licenses/>. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >
[PATCH v2] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add pwm driver for HiSilicon BVT SOCs Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- Change Log: v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ drivers/pwm/Kconfig| 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 274 + 4 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..1274119 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,18 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one soc specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The soc specific strings supported including: + "hisilicon,hi3516cv300-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: offset address and offset bit for reset or unreset of the controller. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..3c48768 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI + help + Generic PWM framework driver for hisilicon BVT SOCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM @@ -438,4 +447,5 @@ config PWM_VT8500 To compile this driver as a module, choose M here: the module will be called pwm-vt8500. + endif diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..84f617e --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,274 @@ +/* + * PWM Controller Driver for HiSilicon BVT SOCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASKBIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASKGENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hibvt_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem*mmio_base; + struct reset_control *rstc; +}; + +static int pwm_num_array[] = {8, 4}; + +static inline +struct hibvt_pwm_chip *to_
[PATCH v2] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add pwm driver for HiSilicon BVT SOCs Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- Change Log: v2: The number of PWMs is change to be probeable based on the compatible string. .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ drivers/pwm/Kconfig| 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 274 + 4 files changed, 303 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..1274119 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,18 @@ +Hisilicon PWM controller + +Required properties: +-compatible: should contain one soc specific compatible string and one generic compatible +string "hisilicon, hibvt-pwm". The soc specific strings supported including: + "hisilicon,hi3516cv300-pwm" +- reg: physical base address and length of the controller's registers. +- clocks: phandle and clock specifier of the PWM reference clock. +- resets: offset address and offset bit for reset or unreset of the controller. + +Example: + pwm: pwm@1213 { + + compatible = "hisilicon,hi3516cv300-pwm", "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..3c48768 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI + help + Generic PWM framework driver for hisilicon BVT SOCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM @@ -438,4 +447,5 @@ config PWM_VT8500 To compile this driver as a module, choose M here: the module will be called pwm-vt8500. + endif diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..84f617e --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,274 @@ +/* + * PWM Controller Driver for HiSilicon BVT SOCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASKBIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASKGENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hibvt_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem*mmio_base; + struct reset_control *rstc; +}; + +static int pwm_num_array[] = {8, 4}; + +static inline +struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) +{ + return container_of(chip, struct hibvt_pwm_chip,
Re: [PATCH] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/8/1 20:43, Mark Rutland wrote: > On Mon, Aug 01, 2016 at 09:42:08AM +0800, Jian Yuan wrote: >> From: yuanjian <yuanjia...@hisilicon.com> >> >> Add pwm driver for HiSilicon BVT SOCs >> >> Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> >> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> >> --- >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ >> drivers/pwm/Kconfig| 10 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 272 >> + >> 4 files changed, 301 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..4efd83e >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,18 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> + - compatible: should be "hisilicon,hibvt-pwm" and one of the following: >> +"hisilicon,hi3516cv300-pwm". > > I take it "hisilicon,hibvt-pwm" is the fallback entry. > > It would be good to note that explicitly. > I do not understand what the fallback entry means. "hisilicon,hibvt-pwm" is a general compatible string, which is available for most HiSilicon BVT SOCs. Howerver, "hisilicon,hi3516cv300-pwm" is specially for hi3516cv300. Maybe I should note the compatible string as described above, right? >> + - reg: physical base address and length of the controller's registers. >> + - clocks: phandle and clock specifier of the PWM reference clock. >> + - resets: offset address and offset bit for reset or unreset of the >> controller. >> + - pwm-nums: pwm number of the controller. > > This should be 'num-pwms'. > > I assume this is the number of PWMs exposed by this controller. Is this > not probeable, or dicoverable based on the compatible string? > > How does this vary in practice? > "pwm-nums" means the maximum number of PWMS that this controller can support, which is the hardware capability. E.g.,HI3516CV300 PWM controller supports 4 PWM, while other chips support 8 PWM. I agree that the PWM number is probeable based on the compatible string. I shall change it, thanks. >> + >> +Example: >> +pwm: pwm@1213 { >> +compatible = "hisilicon,hibvt-pwm"; > > This is missing "hisilicon,hi3516cv300-pwm" as per the requirements of > the binding. > Ok, it's right. I'll fix it in next v2 patch. >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +pwm-nums = <4>; >> +}; > > Thanks, > Mark. > > . > Thanks, Jian.
Re: [PATCH] pwm: add pwm driver for HiSilicon BVT SOCs
On 2016/8/1 20:43, Mark Rutland wrote: > On Mon, Aug 01, 2016 at 09:42:08AM +0800, Jian Yuan wrote: >> From: yuanjian >> >> Add pwm driver for HiSilicon BVT SOCs >> >> Reviewed-by: Jiancheng Xue >> Signed-off-by: Jian Yuan >> --- >> .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ >> drivers/pwm/Kconfig| 10 + >> drivers/pwm/Makefile | 1 + >> drivers/pwm/pwm-hibvt.c| 272 >> + >> 4 files changed, 301 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> create mode 100644 drivers/pwm/pwm-hibvt.c >> >> diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> new file mode 100644 >> index 000..4efd83e >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt >> @@ -0,0 +1,18 @@ >> +Hisilicon PWM controller >> + >> +Required properties: >> + - compatible: should be "hisilicon,hibvt-pwm" and one of the following: >> +"hisilicon,hi3516cv300-pwm". > > I take it "hisilicon,hibvt-pwm" is the fallback entry. > > It would be good to note that explicitly. > I do not understand what the fallback entry means. "hisilicon,hibvt-pwm" is a general compatible string, which is available for most HiSilicon BVT SOCs. Howerver, "hisilicon,hi3516cv300-pwm" is specially for hi3516cv300. Maybe I should note the compatible string as described above, right? >> + - reg: physical base address and length of the controller's registers. >> + - clocks: phandle and clock specifier of the PWM reference clock. >> + - resets: offset address and offset bit for reset or unreset of the >> controller. >> + - pwm-nums: pwm number of the controller. > > This should be 'num-pwms'. > > I assume this is the number of PWMs exposed by this controller. Is this > not probeable, or dicoverable based on the compatible string? > > How does this vary in practice? > "pwm-nums" means the maximum number of PWMS that this controller can support, which is the hardware capability. E.g.,HI3516CV300 PWM controller supports 4 PWM, while other chips support 8 PWM. I agree that the PWM number is probeable based on the compatible string. I shall change it, thanks. >> + >> +Example: >> +pwm: pwm@1213 { >> +compatible = "hisilicon,hibvt-pwm"; > > This is missing "hisilicon,hi3516cv300-pwm" as per the requirements of > the binding. > Ok, it's right. I'll fix it in next v2 patch. >> +reg = <0x1213 0x1>; >> +clocks = <_ctrl HI3516CV300_PWM_CLK>; >> +resets = <_ctrl 0x38 0>; >> +pwm-nums = <4>; >> +}; > > Thanks, > Mark. > > . > Thanks, Jian.
[PATCH] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian <yuanjia...@hisilicon.com> Add pwm driver for HiSilicon BVT SOCs Reviewed-by: Jiancheng Xue <xuejianch...@hisilicon.com> Signed-off-by: Jian Yuan <yuanjia...@hisilicon.com> --- .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ drivers/pwm/Kconfig| 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 272 + 4 files changed, 301 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..4efd83e --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,18 @@ +Hisilicon PWM controller + +Required properties: + - compatible: should be "hisilicon,hibvt-pwm" and one of the following: + "hisilicon,hi3516cv300-pwm". + - reg: physical base address and length of the controller's registers. + - clocks: phandle and clock specifier of the PWM reference clock. + - resets: offset address and offset bit for reset or unreset of the controller. + - pwm-nums: pwm number of the controller. + +Example: + pwm: pwm@1213 { + compatible = "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + pwm-nums = <4>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..3c48768 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI + help + Generic PWM framework driver for hisilicon BVT SOCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM @@ -438,4 +447,5 @@ config PWM_VT8500 To compile this driver as a module, choose M here: the module will be called pwm-vt8500. + endif diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..a073cc4 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,272 @@ +/* + * PWM Controller Driver for HiSilicon BVT SOCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASKBIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASKGENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hibvt_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem*mmio_base; + struct reset_control *rstc; +}; + +static inline +struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pw
[PATCH] pwm: add pwm driver for HiSilicon BVT SOCs
From: yuanjian Add pwm driver for HiSilicon BVT SOCs Reviewed-by: Jiancheng Xue Signed-off-by: Jian Yuan --- .../devicetree/bindings/pwm/pwm-hibvt.txt | 18 ++ drivers/pwm/Kconfig| 10 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-hibvt.c| 272 + 4 files changed, 301 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/pwm-hibvt.txt create mode 100644 drivers/pwm/pwm-hibvt.c diff --git a/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt new file mode 100644 index 000..4efd83e --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/pwm-hibvt.txt @@ -0,0 +1,18 @@ +Hisilicon PWM controller + +Required properties: + - compatible: should be "hisilicon,hibvt-pwm" and one of the following: + "hisilicon,hi3516cv300-pwm". + - reg: physical base address and length of the controller's registers. + - clocks: phandle and clock specifier of the PWM reference clock. + - resets: offset address and offset bit for reset or unreset of the controller. + - pwm-nums: pwm number of the controller. + +Example: + pwm: pwm@1213 { + compatible = "hisilicon,hibvt-pwm"; + reg = <0x1213 0x1>; + clocks = <_ctrl HI3516CV300_PWM_CLK>; + resets = <_ctrl 0x38 0>; + pwm-nums = <4>; + }; diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index c182efc..3c48768 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -158,6 +158,15 @@ config PWM_FSL_FTM To compile this driver as a module, choose M here: the module will be called pwm-fsl-ftm. +config PWM_HIBVT + tristate "HiSilicon BVT PWM support" + depends on ARCH_HISI + help + Generic PWM framework driver for hisilicon BVT SOCs. + + To compile this driver as a module, choose M here: the module + will be called pwm-hibvt. + config PWM_IMG tristate "Imagination Technologies PWM driver" depends on HAS_IOMEM @@ -438,4 +447,5 @@ config PWM_VT8500 To compile this driver as a module, choose M here: the module will be called pwm-vt8500. + endif diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index dd35bc1..37ec39e 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_PWM_CLPS711X)+= pwm-clps711x.o obj-$(CONFIG_PWM_CRC) += pwm-crc.o obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o +obj-$(CONFIG_PWM_HIBVT)+= pwm-hibvt.o obj-$(CONFIG_PWM_IMG) += pwm-img.o obj-$(CONFIG_PWM_IMX) += pwm-imx.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o diff --git a/drivers/pwm/pwm-hibvt.c b/drivers/pwm/pwm-hibvt.c new file mode 100644 index 000..a073cc4 --- /dev/null +++ b/drivers/pwm/pwm-hibvt.c @@ -0,0 +1,272 @@ +/* + * PWM Controller Driver for HiSilicon BVT SOCs + * + * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PWM_CFG0_ADDR(x)(((x) * 0x20) + 0x0) +#define PWM_CFG1_ADDR(x)(((x) * 0x20) + 0x4) +#define PWM_CFG2_ADDR(x)(((x) * 0x20) + 0x8) +#define PWM_CTRL_ADDR(x)(((x) * 0x20) + 0xC) + +#define PWM_ENABLE_SHIFT0 +#define PWM_ENABLE_MASKBIT(0) + +#define PWM_POLARITY_SHIFT 1 +#define PWM_POLARITY_MASK BIT(1) + +#define PWM_KEEP_SHIFT 2 +#define PWM_KEEP_MASK BIT(2) + +#define PWM_PERIOD_MASKGENMASK(31, 0) +#define PWM_DUTY_MASK GENMASK(31, 0) + +struct hibvt_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem*mmio_base; + struct reset_control *rstc; +}; + +static inline +struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) +{ + return container_of(chip, struct hibvt_pwm_chip, chi