fsl_law.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2000
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <asm/fsl_law.h>
  27. #include <asm/io.h>
  28. #define LAWAR_EN 0x80000000
  29. #define FSL_HW_NUM_LAWS 10 /* number of LAWs in the hw implementation */
  30. void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
  31. {
  32. volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08);
  33. volatile u32 *lawbar = base + 8 * idx;
  34. volatile u32 *lawar = base + 8 * idx + 2;
  35. out_be32(lawbar, addr >> 12);
  36. out_be32(lawar, LAWAR_EN | ((u32)id << 20) | (u32)sz);
  37. return ;
  38. }
  39. void disable_law(u8 idx)
  40. {
  41. volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08);
  42. volatile u32 *lawbar = base + 8 * idx;
  43. volatile u32 *lawar = base + 8 * idx + 2;
  44. out_be32(lawar, 0);
  45. out_be32(lawbar, 0);
  46. return;
  47. }
  48. void print_laws(void)
  49. {
  50. volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08);
  51. volatile u32 *lawbar = base;
  52. volatile u32 *lawar = base + 2;
  53. int i;
  54. printf("\nLocal Access Window Configuration\n");
  55. for(i = 0; i < FSL_HW_NUM_LAWS; i++) {
  56. printf("\tLAWBAR%d : 0x%08x, LAWAR%d : 0x%08x\n",
  57. i, in_be32(lawbar), i, in_be32(lawar));
  58. lawbar += 8;
  59. lawar += 8;
  60. }
  61. return;
  62. }
  63. void init_laws(void)
  64. {
  65. int i;
  66. u8 law_idx = 0;
  67. for (i = 0; i < num_law_entries; i++) {
  68. if (law_table[i].index != -1)
  69. law_idx = law_table[i].index;
  70. set_law(law_idx++, law_table[i].addr,
  71. law_table[i].size, law_table[i].trgt_id);
  72. }
  73. return ;
  74. }