Skip to contentSkip to conversation

Initial support for ImgTec PWM DAC and PDM DAC

PATCH In review Naidu Tellapati 2 participants 6 messages Nov 28, 2014 – Dec 5, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v6 cover Initial support for ImgTec PWM DAC and PDM DAC

The Pistachio SOC from Imagination Technologies includes – 4x PDM blocks and 1x “basic PWM� block with four output channels. These share 4 MFIO pins, each PWM channel being muxed with each PDM block output (0-3 muxed with 0-3) using the CR_PERIP_PWM_PDM_CONTROL register in the peripheral wrapper register bank (offset 0x140). The PDM and PWM outputs are used to control targets such as LCD backlight.

The PWM driver uses Linux PWM framework. Since the PDM does not fit into PWM framework we have implemented it as a MISC driver.

The series is based on v3.18-rc5.

Changes from v5:

* Used syscon for accessing PWM & PDM control register.

Changes from v4:

* Removed CR_prefix from the defined macros.

* Folded same data type varibles in one line.

* Removed cr-periph property from PWM DT binding document.

* Removed regmap_update_bits from img_pwm_enable and img_pwm_disable functions.

* Addressed few more comments given in v4.

Changes from v3:

* Addressed couple of comments given in v3.

Changes from v2:

* Added depends on MIPS || COMPILE_TEST.

* Corrected the logic while calculating time base steps.

* Addressed few other minor comments given in v2.

Changes from v1:

* Used regmap_update_bits at some places in the driver.

* Placed some #defines next to their register.

* Added depends on HAS_IOMEM in Kconfig.

* Removed unnecessary paragraph from file header.

* Defined register masks in a readable way.

* Renamed clk-names with clock-names.

* Added system interface clock in DT binding document.

* Addressed few other minor review comments given in v1.

Naidu Tellapati (4):
pwm: Imagination Technologies PWM DAC driver
DT: pwm: Add binding document for IMG PWM DAC
pdm: Imagination Technologies PDM DAC driver
DT: pdm: Add binding document for IMG PDM DAC

 Documentation/devicetree/bindings/misc/img-pdm.txt |   54 ++
 Documentation/devicetree/bindings/pwm/img-pwm.txt  |   24 +
 drivers/misc/Kconfig                               |   13 +
 drivers/misc/Makefile                              |    1 +
 drivers/misc/img-pdm.c                             |  672 ++++++++++++++++++++
 drivers/pwm/Kconfig                                |   13 +
 drivers/pwm/Makefile                               |    1 +
 drivers/pwm/pwm-img.c                              |  250 ++++++++
 include/linux/img_pdm.h                            |   35 +
 9 files changed, 1063 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/img-pdm.txt
 create mode 100644 Documentation/devicetree/bindings/pwm/img-pwm.txt
 create mode 100644 drivers/misc/img-pdm.c
 create mode 100644 drivers/pwm/pwm-img.c
 create mode 100644 include/linux/img_pdm.h
#1 lore raw

PATCH v6 1/4 pwm: Imagination Technologies PWM DAC driver

The Pistachio SOC from Imagination Technologies includes a Pulse Width Modulation DAC which produces 1 to 4 digital bit-outputs which represent digital waveforms. These PWM outputs are primarily in charge of controlling backlight LED devices.

---
 drivers/pwm/Kconfig   |   13 +++
 drivers/pwm/Makefile  |    1 +
 drivers/pwm/pwm-img.c |  250 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 264 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pwm/pwm-img.c
drivers/pwm/Kconfig +13 -0
index ef2dd2e..21b82b9 100644
@@ -110,6 +110,19 @@ config PWM_FSL_FTM
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-fsl-ftm.
 
+config PWM_IMG
+	tristate "Imagination Technologies PWM driver"
+	depends on HAS_IOMEM
+	depends on MFD_SYSCON
+	depends on COMMON_CLK
+	depends on MIPS || COMPILE_TEST
+	help
+	  Generic PWM framework driver for Imagination Technologies
+	  PWM block which supports 4 channels.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-img
+
 config PWM_IMX
 	tristate "i.MX PWM support"
 	depends on ARCH_MXC
drivers/pwm/Makefile +1 -0
index c458606..29655fd 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_PWM_BFIN)		+= pwm-bfin.o
 obj-$(CONFIG_PWM_CLPS711X)	+= pwm-clps711x.o
 obj-$(CONFIG_PWM_EP93XX)	+= pwm-ep93xx.o
 obj-$(CONFIG_PWM_FSL_FTM)	+= pwm-fsl-ftm.o
+obj-$(CONFIG_PWM_IMG)		+= pwm-img.o
 obj-$(CONFIG_PWM_IMX)		+= pwm-imx.o
 obj-$(CONFIG_PWM_JZ4740)	+= pwm-jz4740.o
 obj-$(CONFIG_PWM_LP3943)	+= pwm-lp3943.o
drivers/pwm/pwm-img.c new file +250 -0

250 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v6 2/4 DT: pwm: Add binding document for IMG PWM DAC

In reply to Naidu Tellapati

Add binding document for IMG Pulse Width Modulator (PWM) DAC present on the Pistachio SOC. The PWM DAC has four channels.

---
 Documentation/devicetree/bindings/pwm/img-pwm.txt |   24 +++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pwm/img-pwm.txt
Documentation/devicetree/bindings/pwm/img-pwm.txt new file +24 -0
new file mode 100644
index 0000000..fade5f2
@@ -0,0 +1,24 @@
+*Imagination Technologies PWM DAC driver
+
+Required properties:
+  - compatible: Should be "img,pistachio-pwm"
+  - reg: Should contain physical base address and length of pwm registers.
+  - clocks: Must contain an entry for each entry in clock-names.
+	See ../clock/clock-bindings.txt for details.
+  - clock-names: Must include the following entries.
+    - pwm: PWM operating clock.
+    - sys: PWM system interface clock.
+  - #pwm-cells: Should be 2. See pwm.txt in this directory for the
+	description of the cells format.
+  - img,cr-periph: Must contain a phandle to the peripheral control
+	syscon node which contains PWM control registers.
+
+Example:
+	pwm: pwm@18101300 {
+		compatible = "img,pistachio-pwm";
+		reg = <0x18101300 0x100>;
+		clocks = <&pwm_clk>, <&system_clk>;
+		clock-names = "pwm", "sys";
+		#pwm-cells = <2>;
+		img,cr-periph = <&cr_periph>;
+	};
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH v6 3/4 pdm: Imagination Technologies PDM DAC driver

In reply to Naidu Tellapati

The Pistachio SOC from Imagination Technologies includes a Pulse Density Modulation DAC which produces a form of analogue output according to the relative density of output pulses to the intended analogue signal amplitude. Four PDM outputs are provided that can be used to control targets such as LCD backlight.

---
 drivers/misc/Kconfig    |   13 +
 drivers/misc/Makefile   |    1 +
 drivers/misc/img-pdm.c  |  672 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/img_pdm.h |   35 +++
 4 files changed, 721 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/img-pdm.c
 create mode 100644 include/linux/img_pdm.h
drivers/misc/Kconfig +13 -0
index bbeb451..e2b9fa4 100644
@@ -515,6 +515,19 @@ config VEXPRESS_SYSCFG
 	  bus. System Configuration interface is one of the possible means
 	  of generating transactions on this bus.
 
+config IMG_PDM
+	tristate "Imagination Technologies PDM driver"
+	depends on HAS_IOMEM
+	depends on MFD_SYSCON
+	depends on COMMON_CLK
+	depends on MIPS || COMPILE_TEST
+	help
+	  PDM driver for Imagination Technologies PDM block which supports 4
+	  channels.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called img-pdm.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
index 7d5c4cd..9b00a75 100644
@@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE)		+= genwqe/
 obj-$(CONFIG_ECHO)		+= echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)	+= vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE)		+= cxl/
+obj-$(CONFIG_IMG)		+= img-pdm.o
drivers/misc/img-pdm.c new file +672 -0

672 lines not on this page · raw message

include/linux/img_pdm.h new file +35 -0
new file mode 100644
index 0000000..0203951
@@ -0,0 +1,35 @@
+/**
+ * Imagination Technologies Pulse Density Modulator driver
+ *
+ * Copyright (C) 2014 Imagination Technologies Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __IMG_PDM_H
+#define __IMG_PDM_H
+
+struct img_pdm_device {
+	struct clk *clk;
+	struct kobject **pdm_kobj;
+	struct regmap *periph_regs;
+	struct platform_device *pdev;
+};
+
+struct img_pdm_channel {
+	unsigned int pdm_id;
+	unsigned long flags;
+	struct img_pdm_device *pdm_dev;
+};
+
+void img_pdm_channel_put(struct device *dev);
+struct img_pdm_channel *img_pdm_channel_get(struct device *dev);
+int img_pdm_channel_enable_set(struct img_pdm_channel *chan, bool state);
+int img_pdm_channel_enable_get(struct img_pdm_channel *chan);
+int img_pdm_channel_pulse_in_get(struct img_pdm_channel *chan);
+int img_pdm_channel_pulse_in_set(struct img_pdm_channel *chan,
+				 unsigned int val);
+
+#endif /* ifndef _IMG_PDM_H */
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH v6 4/4 DT: pdm: Add binding document for IMG PDM DAC

In reply to Naidu Tellapati

Add binding document for the Pulse Density Modulator (PDM) DAC present on the Pistachio SOC.

---
 Documentation/devicetree/bindings/misc/img-pdm.txt |   54 ++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/img-pdm.txt
Documentation/devicetree/bindings/misc/img-pdm.txt new file +54 -0
new file mode 100644
index 0000000..a530f4b
@@ -0,0 +1,54 @@
+*Imagination Technologies Pulse Density Modulator (PDM) DAC.
+
+Required properties:
+- compatible: Must be "img,pistachio-pdm"
+- clocks: phandle to input PDM clock
+- clock-names: Must include the following entry:
+  - pdm: input clock to pdm block.
+- img,cr-periph: Must contain a phandle to the peripheral control
+  syscon node which contains PDM control registers.
+- #pdm-cells: Must be 2.
+- The first cell is the PDM channel number (valid values: 0, 1, 2, 3)
+- The second cell is 12-bit pulse-in value
+
+Specifying PDM information for devices
+======================================
+
+1. PDM User nodes
+
+PDM properties should be named "pdms". The exact meaning of each pdms property
+is described above.
+
+	pdm-specifier : array of #pdm-cells specifying the given PDM
+						(controller specific)
+
+The following example could be used to describe a PDM-based backlight device:
+
+	pdm: pdm {
+		#pdm-cells = <2>;
+	};
+
+	[...]
+
+	bl: backlight {
+		pdms = <&pdm 2 0>;
+	};
+
+pdm-specifier typically encodes the chip-relative PDM channel number and the
+12-bit pulse-in value.
+
+2. PDM Controller nodes
+
+PDM controller nodes must specify the number of cells used for the specifier
+using the '#pdm-cells' property.
+
+An example PDM controller might look like this:
+
+Example:
+	pdm: pdm@18148000 {
+		compatible = "img,pistachio-pdm";
+		clocks = <&pdm_clk>;
+		clk-names = "pdm";
+		img,cr-periph = <&cr_periph>;
+		#pdm-cells = <2>;
+	};
Signature · 1 line
1.7.0.4
#5 lore raw
In reply to Naidu Tellapati

Hi Thierry,

Quoted 56 lines · Naidu Tellapati

The Pistachio SOC from Imagination Technologies includes – 4x PDM blocks and 1x “basic PWM� block with four output channels. These share 4 MFIO pins, each PWM channel being muxed with each PDM block output (0-3 muxed with 0-3) using the CR_PERIP_PWM_PDM_CONTROL register in the peripheral wrapper register bank (offset 0x140). The PDM and PWM outputs are used to control targets such as LCD backlight.

The PWM driver uses Linux PWM framework. Since the PDM does not fit into PWM framework we have implemented it as a MISC driver.

The series is based on v3.18-rc5.

Changes from v5:

* Used syscon for accessing PWM & PDM control register.

Changes from v4:

* Removed CR_prefix from the defined macros.

* Folded same data type varibles in one line.

* Removed cr-periph property from PWM DT binding document.

* Removed regmap_update_bits from img_pwm_enable and img_pwm_disable functions.

* Addressed few more comments given in v4.

Changes from v3:

* Addressed couple of comments given in v3.

Changes from v2:

* Added depends on MIPS || COMPILE_TEST.

* Corrected the logic while calculating time base steps.

* Addressed few other minor comments given in v2.

Changes from v1:

* Used regmap_update_bits at some places in the driver.

* Placed some #defines next to their register.

* Added depends on HAS_IOMEM in Kconfig.

* Removed unnecessary paragraph from file header.

* Defined register masks in a readable way.

* Renamed clk-names with clock-names.

* Added system interface clock in DT binding document.

Quoted 8 lines

* Addressed few other minor review comments given in v1.

Naidu Tellapati (4):
pwm: Imagination Technologies PWM DAC driver
DT: pwm: Add binding document for IMG PWM DAC
pdm: Imagination Technologies PDM DAC driver
DT: pdm: Add binding document for IMG PDM DAC

Any comments on this series? I was aiming at merging this for v3.19, hope it's not too late already!

Thanks,

Signature · 1 line
Ezequiel