From patchwork Tue Jan 28 05:53:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sonic Zhang X-Patchwork-Id: 314586 X-Patchwork-Delegate: hs@denx.de 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 9B5CA2C00A2 for ; Tue, 28 Jan 2014 17:05:32 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 18FE54B0ED; Tue, 28 Jan 2014 07:05:30 +0100 (CET) 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 sEIQW0g1Y+Qt; Tue, 28 Jan 2014 07:05:29 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 257604B143; Tue, 28 Jan 2014 07:05:28 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 30C294B14B for ; Tue, 28 Jan 2014 07:05:20 +0100 (CET) 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 pqrSoI4f-ZL9 for ; Tue, 28 Jan 2014 07:05:15 +0100 (CET) X-Greylist: delayed 908 seconds by postgrey-1.27 at theia; Tue, 28 Jan 2014 07:05:10 CET 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 am1outboundpool.messaging.microsoft.com (am1ehsobe005.messaging.microsoft.com [213.199.154.208]) by theia.denx.de (Postfix) with ESMTPS id 1BE1E4B0ED for ; Tue, 28 Jan 2014 07:05:09 +0100 (CET) Received: from mail19-am1-R.bigfish.com (10.3.201.227) by AM1EHSOBE009.bigfish.com (10.3.204.29) with Microsoft SMTP Server id 14.1.225.22; Tue, 28 Jan 2014 05:50:01 +0000 Received: from mail19-am1 (localhost [127.0.0.1]) by mail19-am1-R.bigfish.com (Postfix) with ESMTP id DB0603601D9; Tue, 28 Jan 2014 05:50:00 +0000 (UTC) X-Forefront-Antispam-Report: CIP:137.71.25.57; KIP:(null); UIP:(null); IPV:NLI; H:nwd2mta2.analog.com; RD:nwd2mail11.analog.com; EFVD:NLI X-SpamScore: 1 X-BigFish: VS1(zzzz1f42h2148h1ee6h1ce5h1fdah201ch2073h2146h1202h1fd0h1e76h2189h1d1ah1cabh1d2ah21bch1fc6hzz1de098h8275bh1de097hz31h87h2a8h839hd24he5bh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h13eah1441h14ddh1504h1537h15a8h162dh1631h1758h17eeh1898h18e1h1946h19b5h1b0ah224fh1d0ch1d2eh1d3fh1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h129fi1155h) Received-SPF: softfail (mail19-am1: transitioning domain of gmail.com does not designate 137.71.25.57 as permitted sender) client-ip=137.71.25.57; envelope-from=sonic.adi@gmail.com; helo=nwd2mta2.analog.com ; 2.analog.com ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail19-am1 (localhost.localdomain [127.0.0.1]) by mail19-am1 (MessageSwitch) id 1390888199495517_22599; Tue, 28 Jan 2014 05:49:59 +0000 (UTC) Received: from AM1EHSMHS015.bigfish.com (unknown [10.3.201.233]) by mail19-am1.bigfish.com (Postfix) with ESMTP id 73B3F2A0088; Tue, 28 Jan 2014 05:49:59 +0000 (UTC) Received: from nwd2mta2.analog.com (137.71.25.57) by AM1EHSMHS015.bigfish.com (10.3.207.153) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 28 Jan 2014 05:49:59 +0000 Received: from NWD2HUBCAS5.ad.analog.com (nwd2hubcas5.ad.analog.com [10.64.72.161]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id s0S80UJ1022653 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 28 Jan 2014 03:00:30 -0500 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS5.ad.analog.com (10.64.72.161) with Microsoft SMTP Server id 14.3.158.1; Tue, 28 Jan 2014 00:49:19 -0500 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.6/8.14.6) with ESMTP id s0S5nH27005778; Tue, 28 Jan 2014 00:49:17 -0500 Received: from nine.analog.com (unknown [10.99.24.98]) by linux.site (Postfix) with ESMTP id CA3F33AB7D13; Mon, 27 Jan 2014 14:42:32 -0700 (MST) From: Sonic Zhang To: Sonic Zhang , Date: Tue, 28 Jan 2014 13:53:34 +0800 Message-ID: <1390888416-23534-2-git-send-email-sonic.adi@gmail.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1390888416-23534-1-git-send-email-sonic.adi@gmail.com> References: <1390888416-23534-1-git-send-email-sonic.adi@gmail.com> MIME-Version: 1.0 X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: Sonic Zhang , adi-u-boot-devel@lists.sourceforge.net Subject: [U-Boot] [PATCH 2/4] blackfin: add spi and i2c specific get clock functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Sonic Zhang Signed-off-by: Sonic Zhang --- arch/blackfin/include/asm/blackfin_local.h | 7 ------- arch/blackfin/include/asm/clock.h | 11 +++++++++++ drivers/i2c/bfin-twi_i2c.c | 3 ++- drivers/spi/bfin_spi.c | 7 ++++--- drivers/spi/bfin_spi6xx.c | 7 ++++--- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/arch/blackfin/include/asm/blackfin_local.h b/arch/blackfin/include/asm/blackfin_local.h index 4d6eeab..868c82e 100644 --- a/arch/blackfin/include/asm/blackfin_local.h +++ b/arch/blackfin/include/asm/blackfin_local.h @@ -42,13 +42,6 @@ # include -extern u_long get_vco(void); -extern u_long get_cclk(void); -extern u_long get_sclk(void); -extern u_long get_sclk0(void); -extern u_long get_sclk1(void); -extern u_long get_dclk(void); - # define bfin_revid() (bfin_read_CHIPID() >> 28) extern int bfin_os_log_check(void); diff --git a/arch/blackfin/include/asm/clock.h b/arch/blackfin/include/asm/clock.h index fc84fe4..59d3faa 100644 --- a/arch/blackfin/include/asm/clock.h +++ b/arch/blackfin/include/asm/clock.h @@ -68,10 +68,21 @@ static inline uint32_t early_get_uart_clk(void) return uclk; } +extern u_long get_vco(void); +extern u_long get_cclk(void); +extern u_long get_sclk(void); + #ifdef CGU_DIV +extern u_long get_sclk0(void); +extern u_long get_sclk1(void); +extern u_long get_dclk(void); # define get_uart_clk get_sclk0 +# define get_i2c_clk get_sclk0 +# define get_spi_clk get_sclk0 #else # define get_uart_clk get_sclk +# define get_i2c_clk get_sclk +# define get_spi_clk get_sclk #endif #endif diff --git a/drivers/i2c/bfin-twi_i2c.c b/drivers/i2c/bfin-twi_i2c.c index 5c37280..cfab064 100644 --- a/drivers/i2c/bfin-twi_i2c.c +++ b/drivers/i2c/bfin-twi_i2c.c @@ -10,6 +10,7 @@ #include #include +#include #include /* Every register is 32bit aligned, but only 16bits in size */ @@ -274,7 +275,7 @@ unsigned int i2c_get_bus_speed(void) */ void i2c_init(int speed, int slaveaddr) { - uint8_t prescale = ((get_sclk() / 1000 / 1000 + 5) / 10) & 0x7F; + uint8_t prescale = ((get_i2c_clk() / 1000 / 1000 + 5) / 10) & 0x7F; /* Set TWI internal clock as 10MHz */ twi->control = prescale; diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c index aa89d89..71a31d0 100644 --- a/drivers/spi/bfin_spi.c +++ b/drivers/spi/bfin_spi.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -140,12 +141,12 @@ static const unsigned short cs_pins[][7] = { void spi_set_speed(struct spi_slave *slave, uint hz) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); - ulong sclk; + ulong clk; u32 baud; - sclk = get_sclk(); + clk = get_spi_clk(); /* baud should be rounded up */ - baud = DIV_ROUND_UP(sclk, 2 * hz); + baud = DIV_ROUND_UP(clk, 2 * hz); if (baud < 2) baud = 2; else if (baud > (u16)-1) diff --git a/drivers/spi/bfin_spi6xx.c b/drivers/spi/bfin_spi6xx.c index 07b833d..eba01d1 100644 --- a/drivers/spi/bfin_spi6xx.c +++ b/drivers/spi/bfin_spi6xx.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -135,11 +136,11 @@ static const unsigned short cs_pins[][7] = { void spi_set_speed(struct spi_slave *slave, uint hz) { struct bfin_spi_slave *bss = to_bfin_spi_slave(slave); - ulong sclk; + ulong clk; u32 clock; - sclk = get_sclk1(); - clock = sclk / hz; + clk = get_spi_clk(); + clock = clk / hz; if (clock) clock--; bss->clock = clock;