From patchwork Tue Aug 19 16:07:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4744401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2679BC0338 for ; Tue, 19 Aug 2014 16:10:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 150FD2015A for ; Tue, 19 Aug 2014 16:10:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 023ED200F0 for ; Tue, 19 Aug 2014 16:10:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJlxj-0003YV-Dt; Tue, 19 Aug 2014 16:08:43 +0000 Received: from mail-qg0-f74.google.com ([209.85.192.74]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJlxQ-0003Fg-9v for linux-arm-kernel@lists.infradead.org; Tue, 19 Aug 2014 16:08:24 +0000 Received: by mail-qg0-f74.google.com with SMTP id a108so409027qge.3 for ; Tue, 19 Aug 2014 09:08:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wyu0Yx2fa21tdlZPREtRIFiJuoGHQgLTWpKijuTOssA=; b=huhiAu5zbW4e8xM2ivy7TnA+rJ/8LNb+t5cDyZ1yNDSOFxcE0+PiznU8+X8Xx0YWXL gk/OOreXDF+QQ8fhsAO9QQ+JbGzsr7sQYftOssWWbUjC9p9b7Wf3R4snqf9PpFBw/LR1 bwGd52AGREhBcjJCJrVf2CU8uJiVeP8rC4yrPVJ4gWXEcuA/RTmDsIrZeMARHlAkqg5U k6AQMDAn6WT/0h8CAmYFg2I43MeZ2Pn81osEFl5tuGH3SYfXw5cGpQ7pT/B9B0HP1VfA RQCnP0eRDv/42yt2aBuzh9+hbgkuaZHBZvxLsVbPz100bRlx/5joAkFhvxuOrIlp47CN 0h2Q== X-Gm-Message-State: ALoCoQl5MYzPoZJF9fnUKVcGii2vHhNyvFJ95z1/kIX0lsFqzlHblKkaB2W1bHWSUGz6V7JGFee3 X-Received: by 10.236.216.67 with SMTP id f63mr18598500yhp.10.1408464482400; Tue, 19 Aug 2014 09:08:02 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id t75si324001yhe.5.2014.08.19.09.08.02 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Aug 2014 09:08:02 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.15]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 07FDA31C522; Tue, 19 Aug 2014 09:08:02 -0700 (PDT) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id 8F5C580A95; Tue, 19 Aug 2014 09:08:01 -0700 (PDT) From: Doug Anderson To: Heiko Stuebner , Thierry Reding , Caesar Wang Subject: [PATCH v3 1/4] ARM: rockchip: rk3288: Switch to use the proper PWM IP Date: Tue, 19 Aug 2014 09:07:53 -0700 Message-Id: <1408464476-28316-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1408464476-28316-1-git-send-email-dianders@chromium.org> References: <1408464476-28316-1-git-send-email-dianders@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140819_090824_424114_5A299461 X-CRM114-Status: GOOD ( 16.95 ) X-Spam-Score: -2.0 (--) Cc: linux@arm.linux.org.uk, Dmitry Torokhov , Doug Anderson , linux-kernel@vger.kernel.org, Eddie Cai , olof@lixom.net, Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The rk3288 SoC has an option to switch all of the PWMs in the system between the old IP block and the new IP block. The new IP block is working and tested and the suggested PWM to use, so setup the SoC to use it and then we can pretend that the other IP block doesn't exist. This code could go lots of other places, but we've put it here. Why? - Pushing it to the bootloader just makes the code harder to update in the field. If we later find a bug in the new IP block and want to change our mind about what to use we want it to be easy to update. - Putting this code in the driver for IP block is a lot of extra work, device tree bindings, etc. Now that the new IP block is validated it's likely no future SoCs will need this code. Why pollute the PWM driver with this? This is an rk3288 thing so it should be in rk3288 code. - There's a single bit that switches over PWMs, which makes it extra hard to put this under the PWM device tree nodes. Signed-off-by: Doug Anderson --- Changes in v3: None Changes in v2: - Check for failed ioremap() arch/arm/mach-rockchip/rockchip.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c index 8ab9e0e..93c59f6 100644 --- a/arch/arm/mach-rockchip/rockchip.c +++ b/arch/arm/mach-rockchip/rockchip.c @@ -24,6 +24,29 @@ #include #include "core.h" +static void __init rk3288_init_machine(void) +{ + void *grf = ioremap(0xff770000, 0x10000); + + if (!grf) { + pr_warn("%s: Couldn't map GRF\n", __func__); + return; + } + + /* Set pwm_sel to RK design PWM in GRF_SOC_CON2; affects all PWMs */ + writel(0x00010001, grf + 0x24c); + + iounmap(grf); +} + +static void __init rockchip_init_machine(void) +{ + if (of_machine_is_compatible("rockchip,rk3288")) + rk3288_init_machine(); + + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); +} + static const char * const rockchip_board_dt_compat[] = { "rockchip,rk2928", "rockchip,rk3066a", @@ -34,6 +57,7 @@ static const char * const rockchip_board_dt_compat[] = { }; DT_MACHINE_START(ROCKCHIP_DT, "Rockchip Cortex-A9 (Device Tree)") + .init_machine = rockchip_init_machine, .l2c_aux_val = 0, .l2c_aux_mask = ~0, .dt_compat = rockchip_board_dt_compat,