From patchwork Thu Aug 5 14:55:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raffaele Recalcati X-Patchwork-Id: 117330 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o75Etb8b012706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 5 Aug 2010 14:56:20 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o75EtbYG006031 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 5 Aug 2010 09:55:37 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o75EtaKu010539 for ; Thu, 5 Aug 2010 09:55:36 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C29588064B for ; Thu, 5 Aug 2010 09:55:33 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 29A0480626 for ; Thu, 5 Aug 2010 09:55:28 -0500 (CDT) Received: from red.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o75EtPlN002269 for ; Thu, 5 Aug 2010 09:55:25 -0500 (CDT) Received: from psmtp.com (na3sys009amx190.postini.com [74.125.149.171]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id o75EtOLQ027488 for ; Thu, 5 Aug 2010 09:55:25 -0500 Received: from source ([74.125.82.47]) by na3sys009amx190.postini.com ([74.125.148.10]) with SMTP; Thu, 05 Aug 2010 10:55:25 EDT Received: by wwb18 with SMTP id 18so2655050wwb.4 for ; Thu, 05 Aug 2010 07:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=YDC3yaIAqkHXV7i52pl70ctfgcCpfR0CheySZCfreMs=; b=ocDgSpjfOYsrTeIfdAEC/dkQs+faDWr2XlJi/NYfwbKtMEgRbCCC4EFlXctNDGA5pJ MZ56vcK941MEz7RTMD+F7nuUPrhwkrORzMp1FZ8gXjHB+Lx06pZOcCpA/dy6ekRDj0sN Hdi4BdJMytioSy06KjV4nIe1qO91j/eUU0A4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=h/sHS4evvgaNaJns7aMPi4crf4Q8MUywp0JMOdzCNwlfxyyJWthkQX+wSTuf47LhAJ T/Mb1/tUSiO3oekaPO8sx7zGCzqoAX0OoKIBKpp01rPq05KsR31PolgCHTFQMmIXYK0u cFB6grq6xuFHcytw/pQrSGP6qV8p3Pa25ya8o= Received: by 10.227.154.196 with SMTP id p4mr9246863wbw.195.1281020123512; Thu, 05 Aug 2010 07:55:23 -0700 (PDT) Received: from localhost.localdomain (host81-90-static.72-81-b.business.telecomitalia.it [81.72.90.81]) by mx.google.com with ESMTPS id h3sm230497wbb.3.2010.08.05.07.55.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 05 Aug 2010 07:55:21 -0700 (PDT) From: Raffaele Recalcati To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH v4] DaVinci: dm365: Added clockout2 management. Date: Thu, 5 Aug 2010 16:55:27 +0200 Message-Id: <1281020128-5947-1-git-send-email-lamiaposta71@gmail.com> X-Mailer: git-send-email 1.7.0.4 X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:75.24590/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: Raffaele Recalcati , Miguel Aguilar X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 05 Aug 2010 14:56:21 +0000 (UTC) diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index 42fd4a4..0101a6c 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -40,6 +40,40 @@ #include "mux.h" #define DM365_REF_FREQ 24000000 /* 24 MHz on the DM365 EVM */ +#define DIV1_MASK 0x78 /* DIV1 mask in PERI_CLKCTL */ +#define PERI_CLKCTL 0x48 +#define CLOCKOUT2EN 2 + +int dm365_clkout2_set_rate(struct clk *clk, unsigned long rate) +{ + int i; + unsigned long input; + unsigned ratio; + unsigned regval; + void __iomem *system_module_base; + + /* There must be a parent... */ + if (WARN_ON(!clk->parent)) + return -EINVAL; + + input = clk->parent->rate; + + if (input > rate) + ratio = DIV_ROUND_UP(input, rate) - 1; + + system_module_base = ioremap(DAVINCI_SYSTEM_MODULE_BASE, SZ_4K); + regval = __raw_readl(system_module_base + PERI_CLKCTL); + regval &= ~DIV1_MASK; + regval |= ratio << 3; + + /* to make changes work stop CLOCKOUT & start it again */ + regval |= BIT(CLOCKOUT2EN); + __raw_writel(regval, system_module_base + PERI_CLKCTL); + regval &= ~(1 << CLOCKOUT2EN); + __raw_writel(regval, system_module_base + PERI_CLKCTL); + iounmap(system_module_base); + return 0; +} static struct pll_data pll1_data = { .num = 1, @@ -145,6 +179,13 @@ static struct clk pll1_sysclk9 = { .parent = &pll1_clk, .flags = CLK_PLL, .div_reg = PLLDIV9, + .set_rate = davinci_set_sysclk_rate, +}; + +static struct clk clkout2_clk = { + .name = "clkout2", + .parent = &pll1_sysclk9, + .set_rate = dm365_clkout2_set_rate, }; static struct clk pll2_clk = { @@ -421,6 +462,7 @@ static struct clk_lookup dm365_clks[] = { CLK(NULL, "pll1_sysclk7", &pll1_sysclk7), CLK(NULL, "pll1_sysclk8", &pll1_sysclk8), CLK(NULL, "pll1_sysclk9", &pll1_sysclk9), + CLK(NULL, "clkout2", &clkout2_clk), CLK(NULL, "pll2", &pll2_clk), CLK(NULL, "pll2_aux", &pll2_aux_clk), CLK(NULL, "clkout1", &clkout1_clk),