All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jayachandran C" <jchandra@broadcom.com>
To: linux-mips@linux-mips.org, ralf@linux-mips.org
Cc: "Ganesan Ramalingam" <ganesanr@broadcom.com>,
	"Jayachandran C" <jchandra@broadcom.com>
Subject: [PATCH 08/10] MIPS: Netlogic: XLP2xx update for I2C controller
Date: Sun, 11 Aug 2013 14:43:58 +0530	[thread overview]
Message-ID: <1376212440-21038-9-git-send-email-jchandra@broadcom.com> (raw)
In-Reply-To: <1376212440-21038-1-git-send-email-jchandra@broadcom.com>

From: Ganesan Ramalingam <ganesanr@broadcom.com>

XLP2xx has a new I2C controller which has 4 buses connected to
it. Update the IO offset and IRQ mapping code to reflect this.

Signed-off-by: Ganesan Ramalingam <ganesanr@broadcom.com>
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
---
 arch/mips/include/asm/netlogic/xlp-hal/iomap.h |    3 +++
 arch/mips/include/asm/netlogic/xlp-hal/xlp.h   |    2 ++
 arch/mips/netlogic/xlp/nlm_hal.c               |   23 ++++++++++++++++-------
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/mips/include/asm/netlogic/xlp-hal/iomap.h b/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
index 9fac46f..61c84de 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/iomap.h
@@ -88,6 +88,9 @@
 #define XLP_IO_I2C0_OFFSET(node)	XLP_HDR_OFFSET(node, 0, 6, 2)
 #define XLP_IO_I2C1_OFFSET(node)	XLP_HDR_OFFSET(node, 0, 6, 3)
 #define XLP_IO_GPIO_OFFSET(node)	XLP_HDR_OFFSET(node, 0, 6, 4)
+/* on 2XX, all I2C busses are on the same block */
+#define XLP2XX_IO_I2C_OFFSET(node)	XLP_HDR_OFFSET(node, 0, 6, 7)
+
 /* system management */
 #define XLP_IO_SYS_OFFSET(node)		XLP_HDR_OFFSET(node, 0, 6, 5)
 #define XLP_IO_JTAG_OFFSET(node)	XLP_HDR_OFFSET(node, 0, 6, 6)
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
index 7a4a514..4950ea5 100644
--- a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
+++ b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h
@@ -50,6 +50,8 @@
 #define PIC_MMC_IRQ			29
 #define PIC_I2C_0_IRQ			30
 #define PIC_I2C_1_IRQ			31
+#define PIC_I2C_2_IRQ			32
+#define PIC_I2C_3_IRQ			33
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/mips/netlogic/xlp/nlm_hal.c b/arch/mips/netlogic/xlp/nlm_hal.c
index 22e2e02..04adb75 100644
--- a/arch/mips/netlogic/xlp/nlm_hal.c
+++ b/arch/mips/netlogic/xlp/nlm_hal.c
@@ -93,11 +93,14 @@ int nlm_irq_to_irt(int irq)
 	case PIC_MMC_IRQ:
 		devoff = XLP_IO_SD_OFFSET(0);
 		break;
-	case PIC_I2C_0_IRQ:
-		devoff = XLP_IO_I2C0_OFFSET(0);
-		break;
+	case PIC_I2C_0_IRQ:	/* I2C will be fixed up */
 	case PIC_I2C_1_IRQ:
-		devoff = XLP_IO_I2C1_OFFSET(0);
+	case PIC_I2C_2_IRQ:
+	case PIC_I2C_3_IRQ:
+		if (cpu_is_xlpii())
+			devoff = XLP2XX_IO_I2C_OFFSET(0);
+		else
+			devoff = XLP_IO_I2C0_OFFSET(0);
 		break;
 	default:
 		devoff = 0;
@@ -107,9 +110,15 @@ int nlm_irq_to_irt(int irq)
 	if (devoff != 0) {
 		pcibase = nlm_pcicfg_base(devoff);
 		irt = nlm_read_reg(pcibase, XLP_PCI_IRTINFO_REG) & 0xffff;
-		/* HW bug, I2C 1 irt entry is off by one */
-		if (irq == PIC_I2C_1_IRQ)
-			irt = irt + 1;
+		/* HW weirdness, I2C IRT entry has to be fixed up */
+		switch (irq) {
+		case PIC_I2C_1_IRQ:
+			irt = irt + 1; break;
+		case PIC_I2C_2_IRQ:
+			irt = irt + 2; break;
+		case PIC_I2C_3_IRQ:
+			irt = irt + 3; break;
+		}
 	} else if (irq >= PIC_PCIE_LINK_0_IRQ && irq <= PIC_PCIE_LINK_3_IRQ) {
 		/* HW bug, PCI IRT entries are bad on early silicon, fix */
 		irt = PIC_IRT_PCIE_LINK_INDEX(irq - PIC_PCIE_LINK_0_IRQ);
-- 
1.7.9.5

  parent reply	other threads:[~2013-08-11  9:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-11  9:13 [PATCH 00/10] Netlogic updates for 3.12 Jayachandran C
2013-08-11  9:13 ` [PATCH 01/10] MIPS: Netlogic: Read memory from DRAM BARs Jayachandran C
2013-08-21 14:01   ` [PATCH 01/10 v2] " Jayachandran C
2013-08-11  9:13 ` [PATCH 02/10] MIPS: Netlogic: Remove memory section from built-in DT Jayachandran C
2013-08-11  9:13 ` [PATCH 03/10] MIPS: Netlogic: Fix DT flash size parameter Jayachandran C
2013-08-11  9:13 ` [PATCH 04/10] MIPS: Netlogic: Add support for XLP2XX Jayachandran C
2013-08-11  9:13 ` [PATCH 05/10] MIPS: Netlogic: Call xlp_mmu_init on all threads Jayachandran C
2013-08-11  9:13 ` [PATCH 06/10] MIPS: Netlogic: XLP2XX CPU and PIC frequency Jayachandran C
2013-08-11  9:13 ` [PATCH 07/10] MIPS: Netlogic: Core wakeup changes for XLP2XX Jayachandran C
2013-08-11  9:13 ` Jayachandran C [this message]
2013-08-11  9:13 ` [PATCH 09/10] MIPS: Netlogic: Add support for USB on XLP2xx Jayachandran C
2013-08-21 14:02   ` [PATCH 09/10 v2] " Jayachandran C
2013-08-11  9:14 ` [PATCH 10/10] MIPS: Netlogic: built-in DTB for XLP2xx SoC boards Jayachandran C

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376212440-21038-9-git-send-email-jchandra@broadcom.com \
    --to=jchandra@broadcom.com \
    --cc=ganesanr@broadcom.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.