From: Kumar Gala <galak@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/7] ppc/p4080: Add support for CoreNet style platform LAWs
Date: Fri, 18 Sep 2009 15:59:50 -0500 [thread overview]
Message-ID: <1253307595-28655-3-git-send-email-galak@kernel.crashing.org> (raw)
In-Reply-To: <1253307595-28655-2-git-send-email-galak@kernel.crashing.org>
On CoreNet based platforms the LAW address is split between an high &
low register and we no longer shift the address. Also, the target IDs
on CoreNet platforms have been completely re-assigned.
Additionally, added a new find_law() API to which LAW an address hits in.
This is need for the CoreNet style boot release code since it will need
to determine what the target ID should be set to for boot window
translation.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
drivers/misc/fsl_law.c | 99 ++++++++++++++++++++++++++++++++++++++++++++-
include/asm-ppc/fsl_law.h | 29 +++++++++++++
2 files changed, 127 insertions(+), 1 deletions(-)
diff --git a/drivers/misc/fsl_law.c b/drivers/misc/fsl_law.c
index aa877c6..fba16ed 100644
--- a/drivers/misc/fsl_law.c
+++ b/drivers/misc/fsl_law.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Freescale Semiconductor, Inc.
+ * Copyright 2008-2009 Freescale Semiconductor, Inc.
*
* (C) Copyright 2000
* Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -48,6 +48,24 @@ DECLARE_GLOBAL_DATA_PTR;
void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
{
+#ifdef CONFIG_FSL_CORENET
+ volatile ccsr_local_t *ccm;
+ volatile u32 *base, *lawbarh, *lawbarl, *lawar;
+
+ ccm = (void *)(CONFIG_SYS_FSL_CORENET_CCM_ADDR);
+
+ base = &(ccm->lawbarh0);
+ lawbarh = base + idx * 4;
+ lawbarl = lawbarh + 1;
+ lawar = lawbarl + 1;
+
+ gd->used_laws |= (1 << idx);
+
+ out_be32(lawar, 0);
+ out_be32(lawbarh, ((u64)addr >> 32));
+ out_be32(lawbarl, addr & 0xffffffff);
+ out_be32(lawar, LAWAR_EN | ((u32)id << 20) | (u32)sz);
+#else
volatile u32 *base = (volatile u32 *)(CONFIG_SYS_IMMR + 0xc08);
volatile u32 *lawbar = base + 8 * idx;
volatile u32 *lawar = base + 8 * idx + 2;
@@ -57,6 +75,7 @@ void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
out_be32(lawar, 0);
out_be32(lawbar, addr >> 12);
out_be32(lawar, LAWAR_EN | ((u32)id << 20) | (u32)sz);
+#endif
/* Read back so that we sync the writes */
in_be32(lawar);
@@ -96,6 +115,23 @@ int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
void disable_law(u8 idx)
{
+#ifdef CONFIG_FSL_CORENET
+ volatile ccsr_local_t *ccm;
+ volatile u32 *base, *lawbarh, *lawbarl, *lawar;
+
+ ccm = (void *)(CONFIG_SYS_FSL_CORENET_CCM_ADDR);
+
+ base = &(ccm->lawbarh0);
+ lawbarh = base + idx * 4;
+ lawbarl = lawbarh + 1;
+ lawar = lawbarl + 1;
+
+ gd->used_laws &= ~(1 << idx);
+
+ out_be32(lawar, 0);
+ out_be32(lawbarh, 0);
+ out_be32(lawbarl, 0);
+#else
volatile u32 *base = (volatile u32 *)(CONFIG_SYS_IMMR + 0xc08);
volatile u32 *lawbar = base + 8 * idx;
volatile u32 *lawar = base + 8 * idx + 2;
@@ -104,10 +140,65 @@ void disable_law(u8 idx)
out_be32(lawar, 0);
out_be32(lawbar, 0);
+#endif
return;
}
+#ifdef CONFIG_FSL_CORENET
+#define GET_LAW_ADDR ((u64)in_be32(lawbarh) << 32) | in_be32(lawbarl)
+#else
+#define GET_LAW_ADDR ((u64)in_be32(lawbar) << 12)
+#endif
+
+struct law_entry find_law(phys_addr_t addr)
+{
+ struct law_entry entry;
+ int i;
+
+ entry.index = -1;
+ entry.addr = 0;
+ entry.size = 0;
+ entry.trgt_id = 0;
+
+ for(i = 0; i < FSL_HW_NUM_LAWS; i++) {
+
+ u64 upper;
+ u32 temp;
+#ifdef CONFIG_FSL_CORENET
+ volatile ccsr_local_t *ccm;
+ volatile u32 *base, *lawbarh, *lawbarl, *lawar;
+
+ ccm = (void *)(CONFIG_SYS_FSL_CORENET_CCM_ADDR);
+
+ base = &(ccm->lawbarh0);
+ lawbarh = base + i * 4;
+ lawbarl = lawbarh + 1;
+ lawar = lawbarl + 1;
+#else
+ volatile u32 *base = (volatile u32 *)(CONFIG_SYS_IMMR + 0xc08);
+ volatile u32 *lawbar = base + 8 * i;
+ volatile u32 *lawar = base + 8 * i + 2;
+#endif
+ temp = in_be32(lawar);
+
+ if (!(temp & LAWAR_EN))
+ continue;
+
+ entry.addr = GET_LAW_ADDR;
+ entry.size = temp & 0x3f;
+ entry.trgt_id = (temp >> 20) & 0xff;
+
+ upper = entry.addr + (2ull << entry.size);
+ if ((addr >= entry.addr) && (addr < upper)) {
+ entry.index = i;
+ break;
+ }
+ }
+
+ return entry;
+}
+
void print_laws(void)
{
volatile u32 *base = (volatile u32 *)(CONFIG_SYS_IMMR + 0xc08);
@@ -173,7 +264,13 @@ void init_laws(void)
{
int i;
+#if FSL_HW_NUM_LAWS < 32
gd->used_laws = ~((1 << FSL_HW_NUM_LAWS) - 1);
+#elif FSL_HW_NUM_LAWS == 32
+ gd->used_laws = 0;
+#else
+#error FSL_HW_NUM_LAWS can not be greater than 32 w/o code changes
+#endif
for (i = 0; i < num_law_entries; i++) {
if (law_table[i].index == -1)
diff --git a/include/asm-ppc/fsl_law.h b/include/asm-ppc/fsl_law.h
index e06a1a6..d80b30b 100644
--- a/include/asm-ppc/fsl_law.h
+++ b/include/asm-ppc/fsl_law.h
@@ -1,3 +1,11 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * Version 2 as published by the Free Software Foundation.
+ */
+
#ifndef _FSL_LAW_H_
#define _FSL_LAW_H_
@@ -36,6 +44,25 @@ enum law_size {
LAW_SIZE_32G,
};
+#ifdef CONFIG_FSL_CORENET
+enum law_trgt_if {
+ LAW_TRGT_IF_PCIE_1 = 0x00,
+ LAW_TRGT_IF_PCIE_2 = 0x01,
+ LAW_TRGT_IF_PCIE_3 = 0x02,
+ LAW_TRGT_IF_RIO_1 = 0x08,
+ LAW_TRGT_IF_RIO_2 = 0x09,
+
+ LAW_TRGT_IF_DDR_1 = 0x10,
+ LAW_TRGT_IF_DDR_2 = 0x11, /* 2nd controller */
+ LAW_TRGT_IF_DDR_INTRLV = 0x14,
+
+ LAW_TRGT_IF_BMAN = 0x18,
+ LAW_TRGT_IF_DCSR = 0x1d,
+ LAW_TRGT_IF_LBC = 0x1f,
+ LAW_TRGT_IF_QMAN = 0x3c,
+};
+#define LAW_TRGT_IF_DDR LAW_TRGT_IF_DDR_1
+#else
enum law_trgt_if {
LAW_TRGT_IF_PCI = 0x00,
LAW_TRGT_IF_PCI_2 = 0x01,
@@ -64,6 +91,7 @@ enum law_trgt_if {
#if defined(CONFIG_MPC8572) || defined(CONFIG_P2020)
#define LAW_TRGT_IF_PCIE_3 LAW_TRGT_IF_PCI
#endif
+#endif /* CONFIG_FSL_CORENET */
struct law_entry {
int index;
@@ -76,6 +104,7 @@ extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if
extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
extern int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
extern int set_ddr_laws(u64 start, u64 sz, enum law_trgt_if id);
+extern struct law_entry find_law(phys_addr_t addr);
extern void disable_law(u8 idx);
extern void init_laws(void);
extern void print_laws(void);
--
1.6.0.6
next prev parent reply other threads:[~2009-09-18 20:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 20:59 [U-Boot] [PATCH 0/7] ppc/p4080: infrastructure patches Kumar Gala
2009-09-18 20:59 ` [U-Boot] [PATCH 1/7] ppc/p4080: Add p4080 platform immap definitions Kumar Gala
2009-09-18 20:59 ` Kumar Gala [this message]
2009-09-18 20:59 ` [U-Boot] [PATCH 3/7] ppc/p4080: CoreNet platfrom style CCSRBAR setting Kumar Gala
2009-09-18 20:59 ` [U-Boot] [PATCH 4/7] ppc/p4080: CoreNet platfrom style secondary core release Kumar Gala
2009-09-18 20:59 ` [U-Boot] [PATCH 5/7] ppc/p4080: Add various p4080 related defines (and p4040) Kumar Gala
2009-09-18 20:59 ` [U-Boot] [PATCH 6/7] ppc/p4080: Handle timebase enabling and frequency reporting Kumar Gala
2009-09-18 20:59 ` [U-Boot] [PATCH 7/7] ppc/p4080: Determine various chip frequencies on CoreNet platforms Kumar Gala
2009-09-18 22:09 ` [U-Boot] [PATCH 6/7] ppc/p4080: Handle timebase enabling and frequency reporting Scott Wood
2009-09-22 22:09 ` Wolfgang Denk
2009-09-22 22:07 ` [U-Boot] [PATCH 4/7] ppc/p4080: CoreNet platfrom style secondary core release Wolfgang Denk
2009-09-23 17:03 ` Kumar Gala
2009-09-18 21:55 ` [U-Boot] [PATCH 2/7] ppc/p4080: Add support for CoreNet style platform LAWs Scott Wood
2009-09-18 21:56 ` Scott Wood
2009-09-18 21:58 ` Ben Warren
2009-09-18 22:48 ` Kumar Gala
2009-09-22 22:05 ` Wolfgang Denk
2009-09-23 16:07 ` Kumar Gala
2009-09-18 21:20 ` [U-Boot] [PATCH 1/7] ppc/p4080: Add p4080 platform immap definitions Scott Wood
2009-09-18 21:33 ` Kumar Gala
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=1253307595-28655-3-git-send-email-galak@kernel.crashing.org \
--to=galak@kernel.crashing.org \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox