[U-Boot] [PATCH 1/5] arch/powerpc/cpu/mpc8xxx: PAMU driver support
Ruchika Gupta
ruchika.gupta at freescale.com
Thu Mar 28 11:46:31 CET 2013
PAMU driver basic support for usage in Secure Boot.
In secure boot PAMU is not in bypass mode. Hence to use
any peripheral (SEC Job ring in our case), PAMU has to be
configured.
The Header file fsl_pamu.h and few functions in driver have been derived
from Freescale Libos.
Signed-off-by: Kuldip Giroh <kuldip.giroh at freescale.com>
Signed-off-by: Ruchika Gupta <ruchika.gupta at freescale.com>
---
Based upon git://git.denx.de/u-boot.git branch master
arch/powerpc/cpu/mpc8xxx/Makefile | 3 +-
arch/powerpc/cpu/mpc8xxx/fsl_pamu.c | 488 +++++++++++++++++++++++++++++++++
arch/powerpc/include/asm/fsl_pamu.h | 193 +++++++++++++
arch/powerpc/include/asm/immap_85xx.h | 18 ++
4 files changed, 701 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/cpu/mpc8xxx/fsl_pamu.c
create mode 100644 arch/powerpc/include/asm/fsl_pamu.h
diff --git a/arch/powerpc/cpu/mpc8xxx/Makefile b/arch/powerpc/cpu/mpc8xxx/Makefile
index 3dc8e05..097599e 100644
--- a/arch/powerpc/cpu/mpc8xxx/Makefile
+++ b/arch/powerpc/cpu/mpc8xxx/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright 2009-2010 Freescale Semiconductor, Inc.
+# Copyright 2009-2010, 2012 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
@@ -33,6 +33,7 @@ COBJS-$(CONFIG_FSL_IFC) += fsl_ifc.o
COBJS-$(CONFIG_FSL_LBC) += fsl_lbc.o
COBJS-$(CONFIG_SYS_SRIO) += srio.o
COBJS-$(CONFIG_FSL_LAW) += law.o
+COBJS-$(CONFIG_FSL_CORENET) += fsl_pamu.o
endif
diff --git a/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c b/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c
new file mode 100644
index 0000000..bdbec07
--- /dev/null
+++ b/arch/powerpc/cpu/mpc8xxx/fsl_pamu.c
@@ -0,0 +1,488 @@
+/*
+ * FSL PAMU driver
+ *
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Few functions in this file have been picked up from Freescale LibOS library
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <asm/fsl_pamu.h>
+
+paace_t *ppaact;
+paace_t *sec;
+
+static inline int __ilog2_roundup_64(uint64_t val)
+{
+
+ if ((val & (val - 1)) == 0)
+ return __ilog2_u64(val);
+ else
+ return __ilog2_u64(val) + 1;
+}
+
+
+static inline int count_lsb_zeroes(unsigned long val)
+{
+ return ffs(val) - 1;
+}
+
+static unsigned int map_addrspace_size_to_wse(uint64_t addrspace_size)
+{
+ /* window size is 2^(WSE+1) bytes */
+ return count_lsb_zeroes(addrspace_size >> PAMU_PAGE_SHIFT) +
+ PAMU_PAGE_SHIFT - 1;
+}
+
+static unsigned int map_subwindow_cnt_to_wce(uint32_t subwindow_cnt)
+{
+ /* window count is 2^(WCE+1) bytes */
+ return count_lsb_zeroes(subwindow_cnt) - 1;
+}
+
+static void pamu_setup_default_xfer_to_host_ppaace(paace_t *ppaace)
+{
+ set_bf(ppaace->addr_bitfields, PAACE_AF_PT, PAACE_PT_PRIMARY);
+ set_bf(ppaace->domain_attr.to_host.coherency_required, PAACE_DA_HOST_CR,
+ PAACE_M_COHERENCE_REQ);
+}
+
+static void pamu_setup_default_xfer_to_host_spaace(paace_t *spaace)
+{
+ set_bf(spaace->addr_bitfields, PAACE_AF_PT, PAACE_PT_SECONDARY);
+ set_bf(spaace->domain_attr.to_host.coherency_required, PAACE_DA_HOST_CR,
+ PAACE_M_COHERENCE_REQ);
+}
+
+static unsigned long get_fspi(void)
+{
+ static int i;
+ unsigned long fspi = i * DEFAULT_NUM_SUBWINDOWS;
+ i++;
+ return fspi;
+}
+
+
+/** Sets up PPAACE entry for specified liodn
+ *
+ * @param[in] liodn Logical IO device number
+ * @param[in] win_addr starting address of DSA window
+ * @param[in] win-size size of DSA window
+ * @param[in] omi Operation mapping index -- if ~omi == 0 then omi
+ not defined
+ * @param[in] stashid cache stash id for associated cpu -- if ~stashid == 0
+ then stashid not defined
+ * @param[in] snoopid snoop id for hardware coherency -- if ~snoopid == 0
+ then snoopid not defined
+ * @param[in] subwin_cnt number of sub-windows
+ *
+ * @return Returns 0 upon success else error code < 0 returned
+ */
+static int pamu_config_ppaace(uint32_t liodn, uint64_t win_addr,
+ uint64_t win_size, uint32_t omi,
+ uint32_t snoopid, uint32_t stashid,
+ uint32_t subwin_cnt)
+{
+ unsigned long fspi;
+ paace_t *ppaace;
+
+ if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE)
+ return -1;
+
+ if (win_addr & (win_size - 1))
+ return -2;
+
+ if (liodn > NUM_PPAACT_ENTRIES) {
+ printf("Entries in PPACT not sufficient\n");
+ return -3;
+ }
+
+ ppaace = &ppaact[liodn];
+
+ /* window size is 2^(WSE+1) bytes */
+ set_bf(ppaace->addr_bitfields, PPAACE_AF_WSE,
+ map_addrspace_size_to_wse(win_size));
+
+ pamu_setup_default_xfer_to_host_ppaace(ppaace);
+
+ if (sizeof(phys_addr_t) > 4)
+ ppaace->wbah = (u64)win_addr >> (PAMU_PAGE_SHIFT + 20);
+ else
+ ppaace->wbah = 0;
+
+ set_bf(ppaace->addr_bitfields, PPAACE_AF_WBAL,
+ (win_addr >> PAMU_PAGE_SHIFT));
+
+ /* set up operation mapping if it's configured */
+ if (omi < OME_NUMBER_ENTRIES) {
+ set_bf(ppaace->impl_attr, PAACE_IA_OTM, PAACE_OTM_INDEXED);
+ ppaace->op_encode.index_ot.omi = omi;
+ } else if (~omi != 0)
+ return -3;
+
+ /* configure stash id */
+ if (~stashid != 0)
+ set_bf(ppaace->impl_attr, PAACE_IA_CID, stashid);
+
+ /* configure snoop id */
+ if (~snoopid != 0)
+ ppaace->domain_attr.to_host.snpid = snoopid;
+
+ if (subwin_cnt) {
+ /* We have a single SPAACE for 1 LIODN. So index would
+ be always 0 */
+ fspi = get_fspi();
+
+ /* window count is 2^(WCE+1) bytes */
+ set_bf(ppaace->impl_attr, PAACE_IA_WCE,
+ map_subwindow_cnt_to_wce(subwin_cnt));
+ set_bf(ppaace->addr_bitfields, PPAACE_AF_MW, 0x1);
+ ppaace->fspi = fspi;
+ } else
+ set_bf(ppaace->addr_bitfields, PAACE_AF_AP, PAACE_AP_PERMS_ALL);
+
+ asm volatile("sync" : : : "memory");
+ /* Mark the ppace entry valid */
+ ppaace->addr_bitfields |= PAACE_V_VALID;
+ asm volatile("sync" : : : "memory");
+
+ return 0;
+}
+
+static int pamu_config_spaace(uint32_t liodn,
+ uint64_t subwin_size, uint64_t subwin_addr, uint64_t size,
+ uint32_t omi, uint32_t snoopid, uint32_t stashid)
+{
+ paace_t *paace;
+ unsigned long fspi;
+ /* Align start addr of subwin to subwindoe size */
+ uint64_t sec_addr = subwin_addr & ~(subwin_size - 1);
+ uint64_t end_addr = subwin_addr + size;
+ int size_shift = __ilog2_u64(subwin_size);
+ uint64_t win_size = 0;
+ uint32_t index, swse;
+
+ /* Recalculate the size */
+ size = end_addr - sec_addr;
+
+ if (!subwin_size)
+ return -1;
+
+ if (liodn > NUM_PPAACT_ENTRIES) {
+ printf("LIODN Number to be programmed %d"
+ "greater than number of PPAACT entries %d\n",
+ liodn, NUM_PPAACT_ENTRIES);
+ return -1;
+ }
+
+ while (sec_addr < end_addr) {
+#ifdef DEBUG
+ printf("sec_addr < end_addr is %llx < %llx\n", sec_addr,
+ end_addr);
+#endif
+ paace = &ppaact[liodn];
+ if (!paace)
+ return -1;
+
+ fspi = paace->fspi;
+
+ /* Calculating the win_size here as if we map in index 0,
+ paace entry woudl need to be programmed for SWSE */
+ win_size = end_addr - sec_addr;
+ win_size = 1 << __ilog2_roundup_64(win_size);
+
+ if (win_size > subwin_size)
+ win_size = subwin_size;
+ else if (win_size < PAMU_PAGE_SIZE)
+ win_size = PAMU_PAGE_SIZE;
+
+#ifdef DEBUG
+ printf("win_size is %x\n", win_size);
+#endif
+
+ swse = map_addrspace_size_to_wse(win_size);
+ index = fspi + (sec_addr >> size_shift);
+
+ if (index == 0 || (index % DEFAULT_NUM_SUBWINDOWS) == 0) {
+ set_bf(paace->win_bitfields, PAACE_WIN_SWSE, swse);
+ set_bf(paace->addr_bitfields, PAACE_AF_AP,
+ PAACE_AP_PERMS_ALL);
+ sec_addr += subwin_size;
+ continue;
+ }
+
+ paace = sec + index - 1;
+
+#ifdef DEBUG
+ printf("SPAACT:Writing at location %p, index %d\n", paace,
+ index);
+#endif
+
+ pamu_setup_default_xfer_to_host_spaace(paace);
+ set_bf(paace->addr_bitfields, SPAACE_AF_LIODN, liodn);
+ set_bf(paace->addr_bitfields, PAACE_AF_AP, PAACE_AP_PERMS_ALL);
+
+ /* configure snoop id */
+ if (~snoopid != 0)
+ paace->domain_attr.to_host.snpid = snoopid;
+
+ if (paace->addr_bitfields & PAACE_V_VALID) {
+#ifdef DEBUG
+ printf("Reached overlap condition\n");
+ printf("%d < %d\n", get_bf(paace->win_bitfields,
+ PAACE_WIN_SWSE), swse);
+#endif
+ if (get_bf(paace->win_bitfields, PAACE_WIN_SWSE) < swse)
+ set_bf(paace->win_bitfields, PAACE_WIN_SWSE,
+ swse);
+ } else
+ set_bf(paace->win_bitfields, PAACE_WIN_SWSE, swse);
+
+ paace->addr_bitfields |= PAACE_V_VALID;
+ sec_addr += subwin_size;
+ }
+
+ return 0;
+}
+
+int pamu_init(void)
+{
+ u32 base_addr = CONFIG_SYS_PAMU_ADDR;
+ ccsr_pamu_t *regs;
+ u32 i = 0;
+ u64 ppaact_phys, ppaact_lim, ppaact_size;
+ u64 spaact_phys, spaact_lim, spaact_size;
+
+ ppaact_size = sizeof(paace_t) * NUM_PPAACT_ENTRIES;
+ spaact_size = sizeof(paace_t) * NUM_SPAACT_ENTRIES;
+
+ /* Allocate space for Primary PAACT Table */
+ ppaact = memalign(PAMU_TABLE_ALIGNMENT, ppaact_size);
+ if (!ppaact)
+ return -1;
+ memset(ppaact, 0, ppaact_size);
+
+ /* Allocate space for Secondary PAACT Table */
+ sec = memalign(PAMU_TABLE_ALIGNMENT, spaact_size);
+ if (!sec)
+ return -1;
+ memset(sec, 0, spaact_size);
+
+ ppaact_phys = virt_to_phys((void *)ppaact);
+ ppaact_lim = ppaact_phys + ppaact_size;
+
+ spaact_phys = (uint64_t)virt_to_phys((void *)sec);
+ spaact_lim = spaact_phys + spaact_size;
+
+ /* Configure all PAMU's */
+ for (i = 0; i < CONFIG_NUM_PAMU; i++) {
+ regs = (ccsr_pamu_t *)base_addr;
+
+ out_be32(®s->ppbah, ppaact_phys >> 32);
+ out_be32(®s->ppbal, (uint32_t)ppaact_phys);
+
+ out_be32(®s->pplah, (ppaact_lim) >> 32);
+ out_be32(®s->pplal, (uint32_t)ppaact_lim);
+
+ if (sec != NULL) {
+ out_be32(®s->spbah, spaact_phys >> 32);
+ out_be32(®s->spbal, (uint32_t)spaact_phys);
+ out_be32(®s->splah, spaact_lim >> 32);
+ out_be32(®s->splal, (uint32_t)spaact_lim);
+ }
+ asm volatile("sync" : : : "memory");
+
+ base_addr += PAMU_OFFSET;
+ }
+
+ return 0;
+}
+
+void pamu_enable(void)
+{
+ u32 i = 0;
+ u32 base_addr = CONFIG_SYS_PAMU_ADDR;
+ for (i = 0; i < CONFIG_NUM_PAMU; i++) {
+ setbits_be32((void *)base_addr + PAMU_PCR_OFFSET,
+ PAMU_PCR_PE);
+ asm volatile("sync" : : : "memory");
+ base_addr += PAMU_OFFSET;
+ }
+}
+
+void pamu_reset(void)
+{
+ u32 i = 0;
+ u32 base_addr = CONFIG_SYS_PAMU_ADDR;
+ ccsr_pamu_t *regs;
+
+ for (i = 0; i < CONFIG_NUM_PAMU; i++) {
+ regs = (ccsr_pamu_t *)base_addr;
+ /* Clear PPAACT Base register */
+ out_be32(®s->ppbah, 0);
+ out_be32(®s->ppbal, 0);
+ out_be32(®s->pplah, 0);
+ out_be32(®s->pplal, 0);
+ out_be32(®s->spbah, 0);
+ out_be32(®s->spbal, 0);
+ out_be32(®s->splah, 0);
+ out_be32(®s->splal, 0);
+
+ clrbits_be32((void *)regs + PAMU_PCR_OFFSET, PAMU_PCR_PE);
+ asm volatile("sync" : : : "memory");
+ base_addr += PAMU_OFFSET;
+ }
+}
+
+void pamu_disable(void)
+{
+ u32 i = 0;
+ u32 base_addr = CONFIG_SYS_PAMU_ADDR;
+
+
+ for (i = 0; i < CONFIG_NUM_PAMU; i++) {
+ clrbits_be32((void *)base_addr + PAMU_PCR_OFFSET, PAMU_PCR_PE);
+ asm volatile("sync" : : : "memory");
+ base_addr += PAMU_OFFSET;
+ }
+}
+
+
+static uint64_t find_max(uint64_t arr[], int num)
+{
+ int i = 0;
+ int max = 0;
+ for (i = 1 ; i < num; i++)
+ if (arr[max] < arr[i])
+ max = i;
+
+ return arr[max];
+}
+
+static uint64_t find_min(uint64_t arr[], int num)
+{
+ int i = 0;
+ int min = 0;
+ for (i = 1 ; i < num; i++)
+ if (arr[min] > arr[i])
+ min = i;
+
+ return arr[min];
+}
+
+static uint32_t get_win_cnt(uint64_t size)
+{
+ uint32_t win_cnt = DEFAULT_NUM_SUBWINDOWS;
+
+ while (win_cnt && (size/win_cnt) < PAMU_PAGE_SIZE)
+ win_cnt >>= 1;
+
+ return win_cnt;
+}
+
+int config_pamu(struct pamu_addr_tbl *tbl, int num_entries, uint32_t liodn)
+{
+ int i = 0;
+ int ret = 0;
+ uint32_t num_sec_windows = 0;
+ uint32_t num_windows = 0;
+ uint64_t min_addr, max_addr;
+ uint64_t size;
+ uint64_t subwin_size;
+ int sizebit;
+
+ min_addr = find_min(tbl->start_addr, num_entries);
+ max_addr = find_max(tbl->end_addr, num_entries);
+ size = max_addr - min_addr + 1;
+
+ if (!size)
+ return -1;
+
+ sizebit = __ilog2_roundup_64(size);
+ size = 1 << sizebit;
+#ifdef DEBUG
+ printf("min start_addr is %llx\n", min_addr);
+ printf("max end_addr is %llx\n", max_addr);
+ printf("size found is %llx\n", size);
+#endif
+
+ if (size < PAMU_PAGE_SIZE)
+ size = PAMU_PAGE_SIZE;
+
+ while (1) {
+ min_addr = min_addr & ~(size - 1);
+ if (min_addr + size > max_addr)
+ break;
+ size <<= 1;
+ if (!size)
+ return -1;
+ }
+#ifdef DEBUG
+ printf("PAACT :Base addr is %llx\n", min_addr);
+ printf("PAACT : Size is %llx\n", size);
+#endif
+ num_windows = get_win_cnt(size);
+ /* For a single window, no spaact entries are required
+ * sec_sub_window count = 0 */
+ if (num_windows > 1)
+ num_sec_windows = num_windows;
+ else
+ num_sec_windows = 0;
+
+ ret = pamu_config_ppaace(liodn, min_addr,
+ size , -1, -1, -1, num_sec_windows);
+
+ if (ret < 0)
+ return ret;
+
+#ifdef DEBUG
+ printf("configured ppace\n");
+#endif
+
+ if (num_sec_windows) {
+ subwin_size = size >> count_lsb_zeroes(num_sec_windows);
+#ifdef DEBUG
+ printf("subwin_size is %llx\n", subwin_size);
+#endif
+
+ for (i = 0; i < num_entries; i++) {
+ ret = pamu_config_spaace(liodn,
+ subwin_size, tbl->start_addr[i] - min_addr,
+ tbl->size[i], -1, -1, -1);
+
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return ret;
+}
diff --git a/arch/powerpc/include/asm/fsl_pamu.h b/arch/powerpc/include/asm/fsl_pamu.h
new file mode 100644
index 0000000..e2cfe97
--- /dev/null
+++ b/arch/powerpc/include/asm/fsl_pamu.h
@@ -0,0 +1,193 @@
+/* Copyright (c) 2012 Freescale Semiconductor, Inc.
+ * All Rights Reserved
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __PAMU_H
+#define __PAMU_H
+
+#define CONFIG_NUM_PAMU 16
+#define NUM_PPAACT_ENTRIES 512
+#define NUM_SPAACT_ENTRIES 128
+
+/* PAMU_OFFSET to the next pamu space in ccsr */
+#define PAMU_OFFSET 0x1000
+
+#define PAMU_TABLE_ALIGNMENT 0x00001000
+
+#define PAMU_PAGE_SHIFT 12
+#define PAMU_PAGE_SIZE 4096U
+
+#define PAACE_M_COHERENCE_REQ 0x01
+
+#define PAACE_DA_HOST_CR 0x80
+#define PAACE_DA_HOST_CR_SHIFT 7
+
+#define PAACE_AF_PT 0x00000002
+#define PAACE_AF_PT_SHIFT 1
+
+#define PAACE_PT_PRIMARY 0x0
+#define PAACE_PT_SECONDARY 0x1
+
+#define PPAACE_AF_WBAL 0xfffff000
+#define PPAACE_AF_WBAL_SHIFT 12
+
+#define OME_NUMBER_ENTRIES 16 /* based on P4080 2.0 silicon plan */
+
+#define PAACE_IA_CID 0x00FF0000
+#define PAACE_IA_CID_SHIFT 16
+#define PAACE_IA_WCE 0x000000F0
+#define PAACE_IA_WCE_SHIFT 4
+#define PAACE_IA_ATM 0x0000000C
+#define PAACE_IA_ATM_SHIFT 2
+#define PAACE_IA_OTM 0x00000003
+#define PAACE_IA_OTM_SHIFT 0
+
+#define PAACE_OTM_NO_XLATE 0x00
+#define PAACE_OTM_IMMEDIATE 0x01
+#define PAACE_OTM_INDEXED 0x02
+#define PAACE_OTM_RESERVED 0x03
+#define PAACE_ATM_NO_XLATE 0x00
+#define PAACE_ATM_WINDOW_XLATE 0x01
+#define PAACE_ATM_PAGE_XLATE 0x02
+#define PAACE_ATM_WIN_PG_XLATE \
+ (PAACE_ATM_WINDOW_XLATE | PAACE_ATM_PAGE_XLATE)
+#define PAACE_WIN_TWBAL 0xfffff000
+#define PAACE_WIN_TWBAL_SHIFT 12
+#define PAACE_WIN_SWSE 0x00000fc0
+#define PAACE_WIN_SWSE_SHIFT 6
+
+#define PAACE_AF_AP 0x00000018
+#define PAACE_AF_AP_SHIFT 3
+#define PAACE_AF_DD 0x00000004
+#define PAACE_AF_DD_SHIFT 2
+#define PAACE_AF_PT 0x00000002
+#define PAACE_AF_PT_SHIFT 1
+#define PAACE_AF_V 0x00000001
+#define PAACE_AF_V_SHIFT 0
+#define PPAACE_AF_WSE 0x00000fc0
+#define PPAACE_AF_WSE_SHIFT 6
+#define PPAACE_AF_MW 0x00000020
+#define PPAACE_AF_MW_SHIFT 5
+
+#define PAACE_AP_PERMS_DENIED 0x0
+#define PAACE_AP_PERMS_QUERY 0x1
+#define PAACE_AP_PERMS_UPDATE 0x2
+#define PAACE_AP_PERMS_ALL 0x3
+
+#define SPAACE_AF_LIODN 0xffff0000
+#define SPAACE_AF_LIODN_SHIFT 16
+#define PAACE_V_VALID 0x1
+
+#define set_bf(v, m, x) (v = ((v) & ~(m)) | (((x) << \
+ (m##_SHIFT)) & (m)))
+#define get_bf(v, m) (((v) & (m)) >> (m##_SHIFT))
+
+#define DEFAULT_NUM_SUBWINDOWS 128
+#define PAMU_PCR_OFFSET 0xc10
+#define PAMU_PCR_PE 0x40000000
+
+struct pamu_addr_tbl {
+ phys_addr_t start_addr[10];
+ phys_addr_t end_addr[10];
+ phys_size_t size[10];
+};
+
+typedef struct paace_t {
+ /* PAACE Offset 0x00 */
+ uint32_t wbah; /* only valid for Primary PAACE */
+ uint32_t addr_bitfields; /* See P/S PAACE_AF_* */
+
+ /* PAACE Offset 0x08 */
+ /* Interpretation of first 32 bits dependent on DD above */
+ union {
+ struct {
+ /* Destination ID, see PAACE_DID_* defines */
+ uint8_t did;
+ /* Partition ID */
+ uint8_t pid;
+ /* Snoop ID */
+ uint8_t snpid;
+ /* coherency_required : 1 reserved : 7 */
+ uint8_t coherency_required; /* See PAACE_DA_* */
+ } to_host;
+ struct {
+ /* Destination ID, see PAACE_DID_* defines */
+ uint8_t did;
+ uint8_t reserved1;
+ uint16_t reserved2;
+ } to_io;
+ } domain_attr;
+
+ /* Implementation attributes + window count + address & operation
+ * translation modes
+ */
+ uint32_t impl_attr; /* See PAACE_IA_* */
+
+ /* PAACE Offset 0x10 */
+ /* Translated window base address */
+ uint32_t twbah;
+ uint32_t win_bitfields; /* See PAACE_WIN_* */
+
+ /* PAACE Offset 0x18 */
+ /* first secondary paace entry */
+ uint32_t fspi; /* only valid for Primary PAACE */
+ union {
+ struct {
+ uint8_t ioea;
+ uint8_t moea;
+ uint8_t ioeb;
+ uint8_t moeb;
+ } immed_ot;
+ struct {
+ uint16_t reserved;
+ uint16_t omi;
+ } index_ot;
+ } op_encode;
+
+ /* PAACE Offset 0x20 */
+ uint32_t reserved1[2]; /* not currently implemented */
+
+ /* PAACE Offset 0x28 */
+ uint32_t reserved2[2]; /* not currently implemented */
+
+ /* PAACE Offset 0x30 */
+ uint32_t reserved3[2]; /* not currently implemented */
+
+ /* PAACE Offset 0x38 */
+ uint32_t reserved4[2]; /* not currently implemented */
+
+} paace_t;
+
+int pamu_init(void);
+void pamu_enable(void);
+void pamu_disable(void);
+int config_pamu(struct pamu_addr_tbl *tbl, int num_entries, uint32_t liodn);
+
+#endif
diff --git a/arch/powerpc/include/asm/immap_85xx.h b/arch/powerpc/include/asm/immap_85xx.h
index 4eb3f79..17e0f39 100644
--- a/arch/powerpc/include/asm/immap_85xx.h
+++ b/arch/powerpc/include/asm/immap_85xx.h
@@ -2829,6 +2829,21 @@ typedef struct ccsr_pme {
u8 res4[0x400];
} ccsr_pme_t;
+typedef struct ccsr_pamu {
+ u32 ppbah;
+ u32 ppbal;
+ u32 pplah;
+ u32 pplal;
+ u32 spbah;
+ u32 spbal;
+ u32 splah;
+ u32 splal;
+ u32 obah;
+ u32 obal;
+ u32 olah;
+ u32 olal;
+} ccsr_pamu_t;
+
typedef struct ccsr_usb_phy {
u8 res0[0x18];
u32 usb_enable_override;
@@ -2905,6 +2920,7 @@ struct ccsr_pman {
#define CONFIG_SYS_FSL_CORENET_SERDES_OFFSET 0xEA000
#define CONFIG_SYS_FSL_CORENET_SERDES2_OFFSET 0xEB000
#define CONFIG_SYS_FSL_CPC_OFFSET 0x10000
+#define CONFIG_SYS_FSL_PAMU_OFFSET 0x20000
#define CONFIG_SYS_MPC85xx_DMA1_OFFSET 0x100000
#define CONFIG_SYS_MPC85xx_DMA2_OFFSET 0x101000
#define CONFIG_SYS_MPC85xx_DMA_OFFSET CONFIG_SYS_MPC85xx_DMA1_OFFSET
@@ -3085,6 +3101,8 @@ struct ccsr_pman {
(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_FM2_OFFSET)
#define CONFIG_SYS_FSL_SRIO_ADDR \
(CONFIG_SYS_IMMR + CONFIG_SYS_FSL_SRIO_OFFSET)
+#define CONFIG_SYS_PAMU_ADDR \
+ (CONFIG_SYS_IMMR + CONFIG_SYS_FSL_PAMU_OFFSET)
#define CONFIG_SYS_PCI1_ADDR \
(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_PCI1_OFFSET)
--
1.7.7.6
More information about the U-Boot
mailing list