From patchwork Fri Apr 17 22:33:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 6235781 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F17F2BF4A6 for ; Fri, 17 Apr 2015 22:39:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B2D720260 for ; Fri, 17 Apr 2015 22:39:30 +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 446C92024D for ; Fri, 17 Apr 2015 22:39:29 +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 1YjEsh-0003vJ-S5; Fri, 17 Apr 2015 22:37:03 +0000 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YjErB-0003AH-H4 for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2015 22:35:30 +0000 Received: by pabtp1 with SMTP id tp1so138821054pab.2 for ; Fri, 17 Apr 2015 15:35:08 -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=keyJobO5VQUzbVoW27o2nBkOoER3dWzoGb9MhaCErW2+2qXYHuSgHQZJE2QeNLASyy 617SfSaXRRbT0XG7XEqf030Mtymc4IQBSNyepS3R92IW8dX7TqJr/XxOP9QLCo+QVRiP eEzcbpqDQcrxVDLoqdD0z+uJv7bTN/PNvJaa+D89NVm3zBcolyDyh7KnF+N0j6Zi1Iau VQKiJpujci2TB5SfmQF38x51TtDu4IB7bCQI6CTz8Ao/1ssMmkOceoK85+OY/wrIm5/7 3LkDEePiZ2T1231Cy8Fuh3nH4KBFXsBCW4K0avVZo3Nu/m1sfLKOQ6hwgG9c40/2NGF/ mAyg== X-Received: by 10.70.54.103 with SMTP id i7mr9237137pdp.134.1429310108633; Fri, 17 Apr 2015 15:35:08 -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 og11sm11074060pdb.91.2015.04.17.15.35.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Apr 2015 15:35:07 -0700 (PDT) From: Florian Fainelli To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/7] ARM: BCM63xx: Add Broadcom BCM63xx PMB controller helpers Date: Fri, 17 Apr 2015 15:33:50 -0700 Message-Id: <1429310032-19402-6-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1429310032-19402-1-git-send-email-f.fainelli@gmail.com> References: <1429310032-19402-1-git-send-email-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150417_153529_628311_C0B83F96 X-CRM114-Status: GOOD ( 14.93 ) X-Spam-Score: -0.8 (/) Cc: mark.rutland@arm.com, Florian Fainelli , linux@arm.linux.org.uk, arnd@arndb.de, nico@linaro.org, cernekee@gmail.com, will.deacon@arm.com, bcm-kernel-feedback-list@broadcom.com, 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=ham 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 */