diff options
author | Simon Glass <sjg@chromium.org> | 2011-05-20 15:17:07 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-24 10:01:50 -0700 |
commit | 074d98d2650bf86c0360f5299f551a90fe6e7204 (patch) | |
tree | 7dbed4730076d9322814634243ba03eb4c9d7b19 /arch/arm | |
parent | 40e9147ccc3a8a8d841d044373a8e756534640bd (diff) |
tegra2: Add PWFM support
This adds support for the PWFM which provides for generation of a
selectable-frequency output with configurable duty cycle.
BUG=chromium-os:13228
TEST=Build, boot on Seaboard
Change-Id: Ic9e29fa9d4576e3cf70f5d67e5012158647c3fb5
Reviewed-on: http://gerrit.chromium.org/gerrit/1364
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/cpu/armv7/tegra2/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/cpu/armv7/tegra2/pwfm.c | 37 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-tegra2/pwfm.h | 44 |
3 files changed, 82 insertions, 1 deletions
diff --git a/arch/arm/cpu/armv7/tegra2/Makefile b/arch/arm/cpu/armv7/tegra2/Makefile index 74919b11a17..e23b8e87bf2 100644 --- a/arch/arm/cpu/armv7/tegra2/Makefile +++ b/arch/arm/cpu/armv7/tegra2/Makefile @@ -33,7 +33,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o SOBJS := lowlevel_init.o -COBJS := ap20.o board.o clock.o pinmux.o sys_info.o timer.o +COBJS := ap20.o board.o clock.o pinmux.o pwfm.o sys_info.o timer.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/tegra2/pwfm.c b/arch/arm/cpu/armv7/tegra2/pwfm.c new file mode 100644 index 00000000000..1a37243fa47 --- /dev/null +++ b/arch/arm/cpu/armv7/tegra2/pwfm.c @@ -0,0 +1,37 @@ +/* + * 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 + */ + +/* Tegra2 pulse width frequency modulator definitions */ + +#include <asm/io.h> +#include <asm/arch/bitfield.h> +#include <asm/arch/pwfm.h> + +void pwfm_setup(struct pwfm_ctlr *pwfm, int enable, int pulse_width, + int freq_divider) +{ + u32 reg; + + reg = bf_pack(PWFM_ENABLE, enable) | + bf_pack(PWFM_WIDTH, pulse_width) | + bf_pack(PWFM_DIVIDER, freq_divider); + 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 00000000000..9e6abc212ae --- /dev/null +++ b/arch/arm/include/asm/arch-tegra2/pwfm.h @@ -0,0 +1,44 @@ +/* + * 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 + */ + +/* Tegra2 pulse width frequency modulator definitions */ + +/* 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_RANGE 31:31 +#define PWFM_WIDTH_RANGE 30:16 +#define PWFM_DIVIDER_RANGE 12:0 + + +/** + * Program the PWFM with the given parameters. + * + * @param enable 1 to enable, 0 to disable + * @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 + */ +void pwfm_setup(struct pwfm_ctlr *pwfm, int enable, int pulse_width, + int freq_divider); |