Changeset e29f1f5 in rtems


Ignore:
Timestamp:
Oct 19, 2015, 6:44:33 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
c07481c7
Parents:
c03c71b
git-author:
Sebastian Huber <sebastian.huber@…> (10/19/15 06:44:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/19/15 07:51:28)
Message:

bsp/qoriq: Use U-Boot provided FDT

Location:
c/src/lib/libbsp
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/qoriq/Makefile.am

    rc03c71b re29f1f5  
    2323        ../../shared/include/irq-info.h \
    2424        ../../shared/include/bootcard.h \
     25        ../../shared/include/fdt.h \
    2526        ../../shared/include/u-boot.h \
    2627        ../../shared/include/utility.h \
     
    6465        ../../shared/bspclean.c \
    6566        ../../shared/bspgetworkarea.c \
     67        ../../shared/src/bsp-fdt.c \
    6668        ../../shared/src/bsp-uboot-board-info.c \
    6769        ../shared/src/ppc-exc-handler-table.c \
  • c/src/lib/libbsp/powerpc/qoriq/README

    rc03c71b re29f1f5  
    33  http://en.wikipedia.org/wiki/QorIQ
    44
    5 Development board P1020RDB.
     5Development boards P1020RDB, T2080RDB and T4240RDB.
     6
     7For the T series boot via U-Boot is mandatory since the FDT is used.  Use
     8
     9  mkimage -A ppc -O linux -T kernel -a 0x4000 -e 0x4000 -n RTEMS -d app.bin.gz app.img
     10
     11to create a bootable image.  You must use the "linux" image type.  Boot it for
     12example via the
     13
     14  bootm 0xe9000000 - 0xe8800000
     15
     16U-Boot command.
  • c/src/lib/libbsp/powerpc/qoriq/configure.ac

    rc03c71b re29f1f5  
    5353RTEMS_BSPOPTS_HELP([BSP_USE_UART_INTERRUPTS],[enable usage of interrupts for the UART modules])
    5454
     55RTEMS_BSPOPTS_SET([U_BOOT_USE_FDT],[qoriq_t*],[1])
     56RTEMS_BSPOPTS_SET([U_BOOT_USE_FDT],[*],[])
     57RTEMS_BSPOPTS_HELP([U_BOOT_USE_FDT],[enables U-Boot support using FDT])
     58
     59RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_SIZE_MAX],[qoriq_t*],[131072])
     60RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_SIZE_MAX],[*],[])
     61RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_SIZE_MAX],[maximum size of the FDT blob in bytes])
     62
     63RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_READ_ONLY],[qoriq_t*],[1])
     64RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_READ_ONLY],[*],[])
     65RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_READ_ONLY],[place the FDT blob into the read-only data area])
     66
     67RTEMS_BSPOPTS_SET([HAS_UBOOT],[qoriq_t*],[])
    5568RTEMS_BSPOPTS_SET([HAS_UBOOT],[*],[1])
    56 RTEMS_BSPOPTS_HELP([HAS_UBOOT],[enables U-Boot support])
     69RTEMS_BSPOPTS_HELP([HAS_UBOOT],[enables legacy U-Boot support without FDT])
    5770
    5871RTEMS_BSPOPTS_SET([U_BOOT_64_BIT_PHYS_SIZE],[qoriq_t*],[1])
    5972RTEMS_BSPOPTS_SET([U_BOOT_64_BIT_PHYS_SIZE],[*],[])
    60 RTEMS_BSPOPTS_HELP([U_BOOT_64_BIT_PHYS_SIZE],[if defined, then use uint64_t for phys_size_t])
     73RTEMS_BSPOPTS_HELP([U_BOOT_64_BIT_PHYS_SIZE],[if defined, then use uint64_t for phys_size_t (only used by legacy U-Boot support)])
    6174
    6275RTEMS_BSPOPTS_SET([U_BOOT_GENERIC_BOARD_INFO],[qoriq_t*],[1])
    6376RTEMS_BSPOPTS_SET([U_BOOT_GENERIC_BOARD_INFO],[*],[])
    64 RTEMS_BSPOPTS_HELP([U_BOOT_GENERIC_BOARD_INFO],[if defined, then use the generic bd_t structure])
     77RTEMS_BSPOPTS_HELP([U_BOOT_GENERIC_BOARD_INFO],[if defined, then use the generic bd_t structure (only used by legacy U-Boot support)])
    6578
    6679RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_BEGIN],[qoriq_p2020*],[0x3fff0000])
    67 RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_BEGIN],[qoriq_t2080*],[0x7fef4000])
    68 RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_BEGIN],[qoriq_t4240*],[0x7ff33000])
     80RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_BEGIN],[qoriq_t*],[])
    6981RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_BEGIN],[*],[0x1fff0000])
    70 RTEMS_BSPOPTS_HELP([U_BOOT_BOOT_PAGE_BEGIN],[the begin address of the boot page set up by U-Boot])
     82RTEMS_BSPOPTS_HELP([U_BOOT_BOOT_PAGE_BEGIN],[the begin address of the boot page set up by U-Boot (only used by legacy U-Boot support)])
    7183
    7284RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_LAST],[qoriq_p2020*],[0x3fffffff])
    73 RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_LAST],[qoriq_t2080*],[0x7fef4fff])
    74 RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_LAST],[qoriq_t4240*],[0x7ff33fff])
     85RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_LAST],[qoriq_t*],[])
    7586RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_LAST],[*],[0x1fffffff])
    76 RTEMS_BSPOPTS_HELP([U_BOOT_BOOT_PAGE_LAST],[the last address of the boot page set up by U-Boot])
     87RTEMS_BSPOPTS_HELP([U_BOOT_BOOT_PAGE_LAST],[the last address of the boot page set up by U-Boot (only used by legacy U-Boot support)])
    7788
    7889RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_SPIN_OFFSET],[qoriq_p2020*],[0xf240])
    79 RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_SPIN_OFFSET],[qoriq_t*],[0x0200])
     90RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_SPIN_OFFSET],[qoriq_t*],[])
    8091RTEMS_BSPOPTS_SET([U_BOOT_BOOT_PAGE_SPIN_OFFSET],[*],[0xf2a0])
    81 RTEMS_BSPOPTS_HELP([U_BOOT_BOOT_PAGE_SPIN_OFFSET],[the offset to the spin table in the boot page set up by U-Boot])
     92RTEMS_BSPOPTS_HELP([U_BOOT_BOOT_PAGE_SPIN_OFFSET],[the offset to the spin table in the boot page set up by U-Boot (only used by legacy U-Boot support)])
    8293
    83 RTEMS_BSPOPTS_SET([QORIQ_CPU_COUNT],[qoriq_t2080*],[8])
    84 RTEMS_BSPOPTS_SET([QORIQ_CPU_COUNT],[qoriq_t4240*],[24])
     94RTEMS_BSPOPTS_SET([QORIQ_CPU_COUNT],[qoriq_t*],[24])
    8595RTEMS_BSPOPTS_SET([QORIQ_CPU_COUNT],[*],[2])
    86 RTEMS_BSPOPTS_HELP([QORIQ_CPU_COUNT],[virtual processor count])
     96RTEMS_BSPOPTS_HELP([QORIQ_CPU_COUNT],[maximum virtual processor count])
    8797
    8898RTEMS_BSPOPTS_SET([QORIQ_THREAD_COUNT],[qoriq_t*],[2])
  • c/src/lib/libbsp/powerpc/qoriq/preinstall.am

    rc03c71b re29f1f5  
    6969        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
    7070PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
     71
     72$(PROJECT_INCLUDE)/bsp/fdt.h: ../../shared/include/fdt.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
     73        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/fdt.h
     74PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/fdt.h
    7175
    7276$(PROJECT_INCLUDE)/bsp/u-boot.h: ../../shared/include/u-boot.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
  • c/src/lib/libbsp/powerpc/qoriq/start/start.S

    rc03c71b re29f1f5  
    5656        bl      bsp_uboot_copy_board_info
    5757#endif /* HAS_UBOOT */
     58
     59#ifdef U_BOOT_USE_FDT
     60        bl      bsp_fdt_copy
     61#endif /* U_BOOT_USE_FDT */
    5862
    5963        /* Get start stack */
  • c/src/lib/libbsp/powerpc/qoriq/startup/bspsmp.c

    rc03c71b re29f1f5  
    1515#include <rtems/score/smpimpl.h>
    1616
     17#include <libfdt.h>
     18
    1719#include <libcpu/powerpc-utility.h>
    1820
    1921#include <bsp.h>
     22#include <bsp/fdt.h>
    2023#include <bsp/mmu.h>
    2124#include <bsp/fatal.h>
     
    4245#define TLB_COUNT (TLB_END - TLB_BEGIN)
    4346
    44 /*
    45  * These values can be obtained with the debugger or a look into the
    46  * U-Boot sources (arch/powerpc/cpu/mpc85xx/release.S).
    47  */
    48 #define BOOT_BEGIN U_BOOT_BOOT_PAGE_BEGIN
    49 #define BOOT_LAST U_BOOT_BOOT_PAGE_LAST
    50 #define SPIN_TABLE (BOOT_BEGIN + U_BOOT_BOOT_PAGE_SPIN_OFFSET)
     47#ifdef HAS_UBOOT
     48  /*
     49   * These values can be obtained with the debugger or a look into the U-Boot
     50   * sources (arch/powerpc/cpu/mpc85xx/release.S).
     51   */
     52  #define BOOT_BEGIN U_BOOT_BOOT_PAGE_BEGIN
     53  #define BOOT_LAST U_BOOT_BOOT_PAGE_LAST
     54  #define SPIN_TABLE (BOOT_BEGIN + U_BOOT_BOOT_PAGE_SPIN_OFFSET)
     55#endif
    5156
    5257typedef struct {
     
    139144}
    140145
     146#ifdef U_BOOT_USE_FDT
     147static uboot_spin_table *spin_table_addr[QORIQ_CPU_COUNT / QORIQ_THREAD_COUNT];
     148#endif
     149
     150static uint32_t discover_processors(uint32_t *boot_begin, uint32_t *boot_last)
     151{
     152#if defined(HAS_UBOOT)
     153  *boot_begin = BOOT_BEGIN;
     154  *boot_last = BOOT_LAST;
     155
     156  return QORIQ_CPU_COUNT;
     157#elif defined(U_BOOT_USE_FDT)
     158  const void *fdt = bsp_fdt_get();
     159  int cpus = fdt_path_offset(fdt, "/cpus");
     160  int node = fdt_first_subnode(fdt, cpus);
     161  uint32_t cpu = 0;
     162  uintptr_t last = 0;
     163  uintptr_t begin = last - 1;
     164
     165  while (node >= 0) {
     166    int len;
     167    fdt64_t *addr_fdt = (fdt64_t *)
     168      fdt_getprop(fdt, node, "cpu-release-addr", &len);
     169
     170    if (addr_fdt != NULL && cpu < RTEMS_ARRAY_SIZE(spin_table_addr)) {
     171      uintptr_t addr = (uintptr_t) fdt64_to_cpu(*addr_fdt);
     172
     173      if (addr < begin) {
     174        begin = addr;
     175      }
     176
     177      if (addr > last) {
     178        last = addr;
     179      }
     180
     181      spin_table_addr[cpu] = (uboot_spin_table *) addr;
     182      ++cpu;
     183    }
     184
     185    node = fdt_next_subnode(fdt, node);
     186  }
     187
     188  *boot_begin = begin;
     189  *boot_last = last;
     190
     191  return cpu * QORIQ_THREAD_COUNT;
     192#endif
     193}
     194
    141195uint32_t _CPU_SMP_Initialize(void)
    142196{
     197  uint32_t cpu_count = 1;
     198
    143199  if (rtems_configuration_get_maximum_processors() > 0) {
    144200    qoriq_mmu_context mmu_context;
     201    uint32_t boot_begin;
     202    uint32_t boot_last;
     203
     204    cpu_count = discover_processors(&boot_begin, &boot_last);
    145205
    146206    qoriq_mmu_context_init(&mmu_context);
    147207    qoriq_mmu_add(
    148208      &mmu_context,
    149       BOOT_BEGIN,
    150       BOOT_LAST,
     209      boot_begin,
     210      boot_last,
    151211      0,
    152212      0,
     
    160220  start_thread_if_necessary(0);
    161221
    162   return QORIQ_CPU_COUNT;
     222  return cpu_count;
    163223}
    164224
     
    176236}
    177237
     238static uboot_spin_table *get_spin_table(uint32_t cpu_index)
     239{
     240#if defined(HAS_UBOOT)
     241#if QORIQ_THREAD_COUNT > 1
     242  return &((uboot_spin_table *) SPIN_TABLE)[cpu_index / 2 - 1];
     243#else
     244  return (uboot_spin_table *) SPIN_TABLE;
     245#endif
     246#elif defined(U_BOOT_USE_FDT)
     247  return spin_table_addr[cpu_index / 2];
     248#endif
     249}
     250
    178251bool _CPU_SMP_Start_processor(uint32_t cpu_index)
    179252{
    180253#if QORIQ_THREAD_COUNT > 1
    181254  if (is_started_by_u_boot(cpu_index)) {
    182     uboot_spin_table *spin_table =
    183       &((uboot_spin_table *) SPIN_TABLE)[cpu_index / 2 - 1];
     255    uboot_spin_table *spin_table = get_spin_table(cpu_index);
    184256
    185257    release_processor(spin_table, cpu_index);
     
    190262  }
    191263#else
    192   uboot_spin_table *spin_table = (uboot_spin_table *) SPIN_TABLE;
     264  uboot_spin_table *spin_table = get_spin_table(cpu_index);
    193265
    194266  release_processor(spin_table, cpu_index);
  • c/src/lib/libbsp/powerpc/qoriq/startup/bspstart.c

    rc03c71b re29f1f5  
    88
    99/*
    10  * Copyright (c) 2010-2012 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2010-2015 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2020 * http://www.rtems.org/license/LICENSE.
    2121 */
     22
     23#include <libfdt.h>
    2224
    2325#include <rtems.h>
     
    3032
    3133#include <bsp.h>
    32 #include <bsp/vectors.h>
    3334#include <bsp/bootcard.h>
     35#include <bsp/console-termios.h>
     36#include <bsp/fatal.h>
     37#include <bsp/fdt.h>
    3438#include <bsp/irq-generic.h>
    35 #include <bsp/u-boot.h>
    3639#include <bsp/linker-symbols.h>
    3740#include <bsp/mmu.h>
    3841#include <bsp/qoriq.h>
    39 #include <bsp/console-termios.h>
     42#include <bsp/u-boot.h>
     43#include <bsp/vectors.h>
    4044
    4145LINKER_SYMBOL(bsp_exc_vector_base);
     
    8791
    8892  /* Initialize some device driver parameters */
    89   #ifdef HAS_UBOOT
     93  #if defined(HAS_UBOOT)
    9094    BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq
    9195      / QORIQ_BUS_CLOCK_DIVIDER;
     
    98102      #endif
    99103    );
    100   #endif /* HAS_UBOOT */
     104  #elif defined(U_BOOT_USE_FDT)
     105    {
     106      const void *fdt = bsp_fdt_get();
     107      int node;
     108      int len;
     109      fdt32_t *val_fdt;
     110
     111      node = fdt_node_offset_by_prop_value(fdt, -1, "device_type", "cpu", 4);
     112
     113      val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "bus-frequency", &len);
     114      if (val_fdt == NULL || len != 4) {
     115        bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
     116      }
     117      BSP_bus_frequency = fdt32_to_cpu(*val_fdt) / QORIQ_BUS_CLOCK_DIVIDER;
     118
     119      val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "timebase-frequency", &len);
     120      if (val_fdt == NULL || len != 4) {
     121        bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
     122      }
     123      bsp_clicks_per_usec = fdt32_to_cpu(*val_fdt) / 1000000;
     124
     125      #ifdef __PPC_CPU_E6500__
     126        val_fdt = (fdt32_t *) fdt_getprop(fdt, node, "clock-frequency", &len);
     127        if (val_fdt == NULL || len != 4) {
     128          bsp_fatal(QORIQ_FATAL_FDT_NO_CLOCK_FREQUENCY);
     129        }
     130      #endif
     131      rtems_counter_initialize_converter(fdt32_to_cpu(*val_fdt));
     132    }
     133  #endif
    101134
    102135  /* Initialize some console parameters */
     
    115148      ctx->clock = BSP_bus_frequency;
    116149
    117       #ifdef HAS_UBOOT
    118         #ifdef U_BOOT_GENERIC_BOARD_INFO
    119           ctx->initial_baud = 115200;
    120         #else
    121           ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
    122         #endif
     150      #if defined(HAS_UBOOT) && !defined(U_BOOT_GENERIC_BOARD_INFO)
     151        ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
     152      #else
     153        ctx->initial_baud = 115200;
    123154      #endif
    124155    }
  • c/src/lib/libbsp/shared/include/fatal.h

    rc03c71b re29f1f5  
    115115
    116116  /* QorIQ fatal codes */
    117   QORIQ_FATAL_SMP_IPI_HANDLER_INSTALL = BSP_FATAL_CODE_BLOCK(10)
     117  QORIQ_FATAL_SMP_IPI_HANDLER_INSTALL = BSP_FATAL_CODE_BLOCK(10),
     118  QORIQ_FATAL_FDT_NO_BUS_FREQUENCY,
     119  QORIQ_FATAL_FDT_NO_CLOCK_FREQUENCY,
     120  QORIQ_FATAL_FDT_NO_TIMEBASE_FREQUENCY
    118121} bsp_fatal_code;
    119122
Note: See TracChangeset for help on using the changeset viewer.