From patchwork Thu Sep 8 22:11:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 113988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 984F4B6FD1 for ; Fri, 9 Sep 2011 08:15:01 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4741A28354; Fri, 9 Sep 2011 00:14:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 39bf9bPVn+zH; Fri, 9 Sep 2011 00:14:58 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 826012823D; Fri, 9 Sep 2011 00:14:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5B4DD28251 for ; Fri, 9 Sep 2011 00:14:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4+yluNs5zz6N for ; Fri, 9 Sep 2011 00:14:42 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by theia.denx.de (Postfix) with ESMTPS id 9FBBD28233 for ; Fri, 9 Sep 2011 00:14:41 +0200 (CEST) Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id p88MEYKU018388; Thu, 8 Sep 2011 15:14:34 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by wpaz37.hot.corp.google.com with ESMTP id p88MEUj0010370; Thu, 8 Sep 2011 15:14:31 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id 7F43E140A0C; Thu, 8 Sep 2011 15:14:30 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 8 Sep 2011 15:11:58 -0700 Message-Id: <1315519923-22365-2-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1315519923-22365-1-git-send-email-sjg@chromium.org> References: <1315519923-22365-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true Cc: Tom Warren Subject: [U-Boot] [PATCH 1/6] tegra2: Rename CLOCK_PLL_ID to CLOCK_ID X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Rename CLOCK_PLL_ID to CLOCK_ID which takes account of the fact that the code now deals with both PLL clocks and source clocks. This also tidied up the assert() to match the one sent upstream, and fixes an error in the PWM id. Signed-off-by: Simon Glass --- arch/arm/cpu/armv7/tegra2/ap20.c | 2 +- arch/arm/cpu/armv7/tegra2/clock.c | 21 +++++++++----- arch/arm/include/asm/arch-tegra2/clock.h | 43 ++++++++++++++--------------- board/nvidia/common/board.c | 2 +- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/arch/arm/cpu/armv7/tegra2/ap20.c b/arch/arm/cpu/armv7/tegra2/ap20.c index dc5f984..64d4c69 100644 --- a/arch/arm/cpu/armv7/tegra2/ap20.c +++ b/arch/arm/cpu/armv7/tegra2/ap20.c @@ -36,7 +36,7 @@ u32 s_first_boot = 1; void init_pllx(void) { struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE; - struct clk_pll *pll = &clkrst->crc_pll[CLOCK_PLL_ID_XCPU]; + struct clk_pll *pll = &clkrst->crc_pll[CLOCK_ID_XCPU]; u32 reg; /* If PLLX is already enabled, just return */ diff --git a/arch/arm/cpu/armv7/tegra2/clock.c b/arch/arm/cpu/armv7/tegra2/clock.c index 67eed14..8575e26 100644 --- a/arch/arm/cpu/armv7/tegra2/clock.c +++ b/arch/arm/cpu/armv7/tegra2/clock.c @@ -28,14 +28,19 @@ #include #include -#ifdef DEBUG -#define assert(x) \ - ({ if (!(x)) printf("Assertion failure '%s' %s line %d\n", \ - #x, __FILE__, __LINE__); }) +#if defined(DEBUG) +#define DEBUG_ASSERT 1 #else -#define assert(x) +#define DEBUG_ASSERT 0 #endif +#define assert(x) \ + ({ \ + if (DEBUG_ASSERT && !(x)) \ + printf("Assertion failure '%s' %s line %d\n", \ + #x, __FILE__, __LINE__); \ + }) + /* * Get the oscillator frequency, from the corresponding hardware configuration * field. @@ -50,7 +55,7 @@ enum clock_osc_freq clock_get_osc_freq(void) return (reg & OSC_FREQ_MASK) >> OSC_FREQ_SHIFT; } -unsigned long clock_start_pll(enum clock_pll_id clkid, u32 divm, u32 divn, +unsigned long clock_start_pll(enum clock_id clkid, u32 divm, u32 divn, u32 divp, u32 cpcon, u32 lfcon) { struct clk_rst_ctlr *clkrst = @@ -58,7 +63,7 @@ unsigned long clock_start_pll(enum clock_pll_id clkid, u32 divm, u32 divn, u32 data; struct clk_pll *pll; - assert(clock_pll_id_isvalid(clkid)); + assert(clock_id_isvalid(clkid)); pll = &clkrst->crc_pll[clkid]; /* @@ -74,7 +79,7 @@ unsigned long clock_start_pll(enum clock_pll_id clkid, u32 divm, u32 divn, data = (divm << PLL_DIVM_SHIFT) | (divn << PLL_DIVN_SHIFT) | (0 << PLL_BYPASS_SHIFT) | (1 << PLL_ENABLE_SHIFT); - if (clkid == CLOCK_PLL_ID_USB) + if (clkid == CLOCK_ID_USB) data |= divp << PLLU_VCO_FREQ_SHIFT; else data |= divp << PLL_DIVP_SHIFT; diff --git a/arch/arm/include/asm/arch-tegra2/clock.h b/arch/arm/include/asm/arch-tegra2/clock.h index d01aec8..8adb23c 100644 --- a/arch/arm/include/asm/arch-tegra2/clock.h +++ b/arch/arm/include/asm/arch-tegra2/clock.h @@ -22,7 +22,7 @@ /* Tegra2 clock control functions */ #ifndef _CLOCK_H - +#define _CLOCK_H /* Set of oscillator frequencies supported in the internal API. */ enum clock_osc_freq { @@ -36,22 +36,22 @@ enum clock_osc_freq { }; /* The PLLs supported by the hardware */ -enum clock_pll_id { - CLOCK_PLL_ID_FIRST, - CLOCK_PLL_ID_CGENERAL = CLOCK_PLL_ID_FIRST, - CLOCK_PLL_ID_MEMORY, - CLOCK_PLL_ID_PERIPH, - CLOCK_PLL_ID_AUDIO, - CLOCK_PLL_ID_USB, - CLOCK_PLL_ID_DISPLAY, +enum clock_id { + CLOCK_ID_FIRST, + CLOCK_ID_CGENERAL = CLOCK_ID_FIRST, + CLOCK_ID_MEMORY, + CLOCK_ID_PERIPH, + CLOCK_ID_AUDIO, + CLOCK_ID_USB, + CLOCK_ID_DISPLAY, /* now the simple ones */ - CLOCK_PLL_ID_FIRST_SIMPLE, - CLOCK_PLL_ID_XCPU = CLOCK_PLL_ID_FIRST_SIMPLE, - CLOCK_PLL_ID_EPCI, - CLOCK_PLL_ID_SFROM32KHZ, + CLOCK_ID_FIRST_SIMPLE, + CLOCK_ID_XCPU = CLOCK_ID_FIRST_SIMPLE, + CLOCK_ID_EPCI, + CLOCK_ID_SFROM32KHZ, - CLOCK_PLL_ID_COUNT, + CLOCK_ID_COUNT, }; /* The clocks supported by the hardware */ @@ -80,7 +80,7 @@ enum periph_id { /* 16 */ PERIPH_ID_TWC, - PERIPH_ID_PWC, + PERIPH_ID_PWM, PERIPH_ID_I2S2, PERIPH_ID_EPP, PERIPH_ID_VI, @@ -181,8 +181,7 @@ enum periph_id { #define PERIPH_MASK(id) (1 << ((id) & 0x1f)) /* return 1 if a PLL ID is in range */ -#define clock_pll_id_isvalid(id) ((id) >= CLOCK_PLL_ID_FIRST && \ - (id) < CLOCK_PLL_ID_COUNT) +#define clock_id_isvalid(id) ((id) >= CLOCK_ID_FIRST && (id) < CLOCK_ID_COUNT) /* return 1 if a peripheral ID is in range */ #define clock_periph_id_isvalid(id) ((id) >= PERIPH_ID_FIRST && \ @@ -194,7 +193,7 @@ enum periph_id { /* return the current oscillator clock frequency */ enum clock_osc_freq clock_get_osc_freq(void); -/* +/** * Start PLL using the provided configuration parameters. * * @param id clock id @@ -206,7 +205,7 @@ enum clock_osc_freq clock_get_osc_freq(void); * * @returns monotonic time in us that the PLL will be stable */ -unsigned long clock_start_pll(enum clock_pll_id id, u32 divm, u32 divn, +unsigned long clock_start_pll(enum clock_id id, u32 divm, u32 divn, u32 divp, u32 cpcon, u32 lfcon); /* @@ -224,7 +223,7 @@ void clock_enable(enum periph_id clkid); */ void clock_set_enable(enum periph_id clkid, int enable); -/* +/** * Reset a peripheral. This puts it in reset, waits for a delay, then takes * it out of reset and waits for th delay again. * @@ -233,7 +232,7 @@ void clock_set_enable(enum periph_id clkid, int enable); */ void reset_periph(enum periph_id periph_id, int us_delay); -/* +/** * Put a peripheral into or out of reset. * * @param periph_id peripheral to reset @@ -251,7 +250,7 @@ enum crc_reset_id { crc_rst_debug = 1 << 4, }; -/* +/** * Put parts of the CPU complex into or out of reset.\ * * @param cpu cpu number (0 or 1 on Tegra2) diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c index 160dac8..32d3cfb 100644 --- a/board/nvidia/common/board.c +++ b/board/nvidia/common/board.c @@ -77,7 +77,7 @@ int timer_init(void) static void clock_init_uart(void) { struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE; - struct clk_pll *pll = &clkrst->crc_pll[CLOCK_PLL_ID_PERIPH]; + struct clk_pll *pll = &clkrst->crc_pll[CLOCK_ID_PERIPH]; u32 reg; reg = readl(&pll->pll_base);