All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/17] tegra: Add support for PWFM
Date: Sat, 14 Jan 2012 16:47:18 -0800	[thread overview]
Message-ID: <1326588449-1794-7-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1326588449-1794-1-git-send-email-sjg@chromium.org>

The pulse width/frequency modulation peripheral supports generating
a repeating pulse. It is useful for controlling LCD brightness.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/tegra2/Makefile      |    1 +
 arch/arm/cpu/armv7/tegra2/pwfm.c        |   40 +++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/pwfm.h |   54 +++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
 create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h

diff --git a/arch/arm/cpu/armv7/tegra2/Makefile b/arch/arm/cpu/armv7/tegra2/Makefile
index 08c4137..9779e9e 100644
--- a/arch/arm/cpu/armv7/tegra2/Makefile
+++ b/arch/arm/cpu/armv7/tegra2/Makefile
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
 COBJS-$(CONFIG_TEGRA_PMU) += pmu.o
 COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o
 COBJS-$(CONFIG_TEGRA2_LP0) += crypto.o warmboot.o warmboot_avp.o
+COBJS-$(CONFIG_VIDEO_TEGRA) += pwfm.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/tegra2/pwfm.c b/arch/arm/cpu/armv7/tegra2/pwfm.c
new file mode 100644
index 0000000..cdb0cbe
--- /dev/null
+++ b/arch/arm/cpu/armv7/tegra2/pwfm.c
@@ -0,0 +1,40 @@
+/*
+ * Tegra2 pulse width frequency modulator definitions
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/pwfm.h>
+
+void pwfm_enable(struct pwfm_ctlr *pwfm, int rate, int pulse_width,
+		int freq_divider)
+{
+	u32 reg;
+
+	/* TODO: Can we use clock_adjust_periph_pll_div() here? */
+	clock_start_periph_pll(PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ, rate);
+
+	reg = PWFM_ENABLE_MASK;
+	reg |= pulse_width << PWFM_WIDTH_SHIFT;
+	reg |= freq_divider << PWFM_DIVIDER_SHIFT;
+	writel(reg, &pwfm->control);
+}
diff --git a/arch/arm/include/asm/arch-tegra2/pwfm.h b/arch/arm/include/asm/arch-tegra2/pwfm.h
new file mode 100644
index 0000000..69e2edd
--- /dev/null
+++ b/arch/arm/include/asm/arch-tegra2/pwfm.h
@@ -0,0 +1,54 @@
+/*
+ * Tegra pulse width frequency modulator definitions
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_ARCH_TEGRA_PWFM_H
+#define __ASM_ARCH_TEGRA_PWFM_H
+
+/* This is a single PWFM channel */
+struct pwfm_ctlr {
+	uint control;		/* Control register */
+};
+
+/* PWM_CONTROLLER_PWM_CSR_0/1/2/3_0 */
+#define PWFM_ENABLE_SHIFT	31
+#define PWFM_ENABLE_MASK	(0x1 << PWFM_ENABLE_SHIFT)
+
+#define PWFM_WIDTH_SHIFT	16
+#define PWFM_WIDTH_MASK		(0x7FFF << PWFM_WIDTH_SHIFT)
+
+#define PWFM_DIVIDER_SHIFT	0
+#define PWFM_DIVIDER_MASK	(0x1FFF << PWFM_DIVIDER_SHIFT)
+
+/**
+ * Program the PWFM with the given parameters.
+ *
+ * @param pwfm		Pointer to PWFM register
+ * @param rate		Clock rate to use for PWFM
+ * @param pulse_width	high pulse width: 0=always low, 1=1/256 pulse high,
+ *			n = n/256 pulse high
+ * @param freq_divider	frequency divider value (1 to use rate as is)
+ */
+void pwfm_enable(struct pwfm_ctlr *pwfm, int rate, int pulse_width,
+		int freq_divider);
+
+#endif	/* __ASM_ARCH_TEGRA_PWFM_H */
-- 
1.7.7.3

  parent reply	other threads:[~2012-01-15  0:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux Simon Glass
2012-01-15  1:36   ` Mike Frysinger
2012-06-13 12:15     ` Simon Glass
     [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-01-15  0:47   ` [PATCH 01/17] fdt: Add function to look up a phandle's register address Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 02/17] fdt: Add header guard to fdtdec.h Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 03/17] fdt: Correct GPIO name access in fdtdec Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 05/17] tegra: fdt: Add LCD definitions for Tegra Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 15/17] tegra: fdt: Add LCD definitions for Seaboard Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47 ` Simon Glass [this message]
2012-01-15  0:47 ` [U-Boot] [PATCH 07/17] tegra: Add SOC support for display/lcd Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 08/17] tegra: Add LCD driver Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 09/17] tegra: Add LCD support to Nvidia boards Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions Simon Glass
2012-02-10 20:38   ` Albert ARIBAUD
2012-03-04  6:20     ` Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU Simon Glass
2012-01-15  1:38   ` Mike Frysinger
2012-06-13 12:23     ` Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update Simon Glass
2012-01-15  1:42   ` Mike Frysinger
2012-01-15  1:57     ` Simon Glass
2012-01-15  2:16       ` Mike Frysinger
2012-06-13 12:25         ` Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 13/17] tegra: Align LCD frame buffer to section boundary Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 14/17] tegra: Support control of cache settings for LCD Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 16/17] lcd: Add CONSOLE_SCROLL_LINES option to speed console Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 17/17] tegra: Enable display/lcd support on Seaboard Simon Glass
2012-04-19 12:41 ` [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Christian Kroehnert
2012-07-14  8:03   ` Simon Glass
2012-07-17 16:11     ` Thierry Reding
2012-07-18  6:51       ` Simon Glass
2012-07-19 12:01         ` Christian Kroehnert
2012-07-24 19:16         ` Stephen Warren

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1326588449-1794-7-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

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

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