From patchwork Thu Apr 23 23:09:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 6265761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4DC179F1C4 for ; Thu, 23 Apr 2015 23:15:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65DD320377 for ; Thu, 23 Apr 2015 23:15:47 +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 84B01202E5 for ; Thu, 23 Apr 2015 23:15:46 +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 1YlQJK-0007Od-Rm; Thu, 23 Apr 2015 23:13:34 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YlQHn-0006bA-F5 for linux-arm-kernel@lists.infradead.org; Thu, 23 Apr 2015 23:12:00 +0000 Received: by pacyx8 with SMTP id yx8so30766392pac.1 for ; Thu, 23 Apr 2015 16:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mkygL/3MOB6o+O8zTSYSMLpPhp+i7Vp0LnsvQUXwz5A=; b=ta3+eBAtHCdCKs+L4tANqAz2AKrA5EYaPrPERi0zhiKnm0yQaakAxVccctSHCTlQni AiZrZcs2nWSgC5JOmL/eH9KMwlkP0z7mH1sBYETr2pdzjoMeTAXDzRtRsx9KxF381rQJ g6BdCF0Q4rZrLMDAc6JPgjM2Xsz/0g7cBQeH9v2LSo6TgW1eIPkYbZ1M1tsM1I8THQz/ velWoLHtU/OYAm/x80S15bXGd7M5/HIeOh/rmwqUl5ozLNCJi0D8kvvcsMVfwwIIQtKZ OQckhX++Zlwy41qNSE6TCWQgM5qoFdOLyM0+96EpR/LGs5TdstM0CrSKLvtRqqAy1LDU grow== X-Received: by 10.67.15.102 with SMTP id fn6mr9925351pad.120.1429830698372; Thu, 23 Apr 2015 16:11:38 -0700 (PDT) Received: from fainelli-desktop.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id og11sm9126441pdb.91.2015.04.23.16.11.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Apr 2015 16:11:37 -0700 (PDT) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/9] ARM: BCM63xx: Add Broadcom BCM63xx PMB controller helpers Date: Thu, 23 Apr 2015 16:09:58 -0700 Message-Id: <1429830602-10988-6-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1429830602-10988-1-git-send-email-f.fainelli@gmail.com> References: <1429830602-10988-1-git-send-email-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150423_161159_584766_8A1A67CA X-CRM114-Status: GOOD ( 15.39 ) X-Spam-Score: -0.8 (/) Cc: mark.rutland@arm.com, Florian Fainelli , linux@arm.linux.org.uk, arnd@arndb.de, khilman@kernel.org, cernekee@gmail.com, will.deacon@arm.com, bcm-kernel-feedback-list@broadcom.com, nico@linaro.org, gregory.0xf0@gmail.com, olof@lixom.net, computersforpeace@gmail.com 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=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 This patch adds both common register definitions and helper functions used to issue read/write commands to the Broadcom BCM63xx PMB controller which is used to power on and release from reset internal on-chip peripherals such as the integrated Ethernet switch, AHCI, USB, as well as the secondary CPU core. This is going to be utilized by the BCM63138 SMP code, as well as by the BCM63138 reset controller later. Signed-off-by: Florian Fainelli --- include/linux/bcm63xx_pmb.h | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 include/linux/bcm63xx_pmb.h diff --git a/include/linux/bcm63xx_pmb.h b/include/linux/bcm63xx_pmb.h new file mode 100644 index 000000000000..2a2ea1bfb6cf --- /dev/null +++ b/include/linux/bcm63xx_pmb.h @@ -0,0 +1,76 @@ +#ifndef __BCM63XX_PMB_H +#define __BCM63XX_PMB_H + +#include +#include +#include + +/* PMB Master controller register */ +#define PMB_CTRL 0x00 +#define PMC_PMBM_START (1 << 31) +#define PMC_PMBM_TIMEOUT (1 << 30) +#define PMC_PMBM_SLAVE_ERR (1 << 29) +#define PMC_PMBM_BUSY (1 << 28) +#define PMC_PMBM_READ (0 << 20) +#define PMC_PMBM_WRITE (1 << 20) +#define PMB_WR_DATA 0x04 +#define PMB_TIMEOUT 0x08 +#define PMB_RD_DATA 0x0C + +#define PMB_BUS_ID_SHIFT 8 + +/* Perform the low-level PMB master operation, shared between reads and + * writes, caller must hold the spinlock + */ +static inline int __bpcm_do_op(void __iomem *master, unsigned int addr, + u32 off, u32 op) +{ + unsigned int timeout = 1000; + u32 cmd; + + cmd = (PMC_PMBM_START | op | (addr & 0xff) << 12 | off); + __raw_writel(cmd, master + PMB_CTRL); + do { + cmd = __raw_readl(master + PMB_CTRL); + if (!(cmd & PMC_PMBM_START)) + return 0; + + if (cmd & PMC_PMBM_SLAVE_ERR) + return -EIO; + + if (cmd & PMC_PMBM_TIMEOUT) + return -ETIMEDOUT; + + udelay(1); + } while (timeout-- > 0); + + return -ETIMEDOUT; +} + +static inline int bpcm_rd(void __iomem *master, unsigned int addr, + u32 off, u32 *val) +{ + int ret = 0; + + ret = __bpcm_do_op(master, addr, off >> 2, PMC_PMBM_READ); + *val = __raw_readl(master + PMB_RD_DATA); + + return ret; +} + +static inline int bpcm_wr(void __iomem *master, unsigned int addr, + u32 off, u32 val) +{ + int ret = 0; + + __raw_writel(val, master + PMB_WR_DATA); + /* Ensure that writes to the PMB_WR_DATA registers are taken + * into account before attempting to start the PMB transaction + */ + mb(); + ret = __bpcm_do_op(master, addr, off >> 2, PMC_PMBM_WRITE); + + return ret; +} + +#endif /* __BCM63XX_PMB_H */