uboot/arch/powerpc/cpu/mpc8xxx/pamu_table.c
<<
>>
Prefs
   1/*
   2 * Copyright 2012-2016 Freescale Semiconductor, Inc.
   3 *
   4 * SPDX-License-Identifier:     GPL-2.0+
   5 */
   6
   7#include <common.h>
   8#include <asm/fsl_pamu.h>
   9
  10DECLARE_GLOBAL_DATA_PTR;
  11
  12void construct_pamu_addr_table(struct pamu_addr_tbl *tbl, int *num_entries)
  13{
  14        int i = 0;
  15        int j;
  16
  17        tbl->start_addr[i] =
  18                        (uint64_t)virt_to_phys((void *)CONFIG_SYS_SDRAM_BASE);
  19        tbl->size[i] = (phys_size_t)(min(gd->ram_size, CONFIG_MAX_MEM_MAPPED));
  20        tbl->end_addr[i] = tbl->start_addr[i] +  tbl->size[i] - 1;
  21
  22        i++;
  23#ifdef CONFIG_SYS_FLASH_BASE_PHYS
  24        tbl->start_addr[i] =
  25                (uint64_t)virt_to_phys((void *)CONFIG_SYS_FLASH_BASE_PHYS);
  26        tbl->size[i] = 256 * 1024 * 1024; /* 256MB flash */
  27        tbl->end_addr[i] = tbl->start_addr[i] +  tbl->size[i] - 1;
  28
  29        i++;
  30#endif
  31        debug("PAMU address\t\t\tsize\n");
  32        for (j = 0; j < i ; j++)
  33                debug("%llx \t\t\t%llx\n",  tbl->start_addr[j],  tbl->size[j]);
  34
  35        *num_entries = i;
  36}
  37
  38int sec_config_pamu_table(uint32_t liodn_ns, uint32_t liodn_s)
  39{
  40        struct pamu_addr_tbl tbl;
  41        int num_entries = 0;
  42        int ret = 0;
  43
  44        construct_pamu_addr_table(&tbl, &num_entries);
  45
  46        ret = config_pamu(&tbl, num_entries, liodn_ns);
  47        if (ret)
  48                return ret;
  49
  50        ret = config_pamu(&tbl, num_entries, liodn_s);
  51        if (ret)
  52                return ret;
  53
  54        return ret;
  55}
  56