Changeset ec28f31 in rtems


Ignore:
Timestamp:
Sep 19, 2017, 7:12:02 AM (20 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
44c0114
Parents:
fd70e206
git-author:
Sebastian Huber <sebastian.huber@…> (09/19/17 07:12:02)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/19/17 08:57:27)
Message:

bsp/qoriq: Add decrementer clock driver

Update #3085.

Location:
c/src/lib/libbsp/powerpc/qoriq
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/qoriq/clock/clock-config.c

    rfd70e206 rec28f31  
    88
    99/*
    10  * Copyright (c) 2011, 2016 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2011, 2017 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
     
    3232static rtems_isr Clock_isr(void *arg);
    3333
     34static struct timecounter qoriq_clock_tc;
     35
     36#ifdef QORIQ_IS_HYPERVISOR_GUEST
     37
     38#define CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR
     39
     40void qoriq_decrementer_dispatch(void)
     41{
     42  PPC_SET_SPECIAL_PURPOSE_REGISTER(BOOKE_TSR, BOOKE_TSR_DIS);
     43  Clock_isr(NULL);
     44}
     45
     46static uint32_t qoriq_clock_get_timecount(struct timecounter *tc)
     47{
     48  return ppc_alternate_time_base();
     49}
     50
     51static void qoriq_clock_initialize(void)
     52{
     53  uint64_t frequency = bsp_time_base_frequency;
     54  uint32_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
     55  uint32_t interval = (uint32_t) ((frequency * us_per_tick) / 1000000);
     56
     57  PPC_SET_SPECIAL_PURPOSE_REGISTER(BOOKE_DECAR, interval - 1);
     58  PPC_SET_SPECIAL_PURPOSE_REGISTER_BITS(
     59    BOOKE_TCR,
     60    BOOKE_TCR_DIE | BOOKE_TCR_ARE
     61  );
     62  ppc_set_decrementer_register(interval - 1);
     63
     64  qoriq_clock_tc.tc_get_timecount = qoriq_clock_get_timecount;
     65  qoriq_clock_tc.tc_counter_mask = 0xffffffff;
     66  qoriq_clock_tc.tc_frequency = qoriq_clock_frequency;
     67  qoriq_clock_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
     68  rtems_timecounter_install(&qoriq_clock_tc);
     69}
     70
     71#else /* !QORIQ_IS_HYPERVISOR_GUEST */
     72
    3473static volatile qoriq_pic_global_timer *const qoriq_clock =
    3574  #if QORIQ_CLOCK_TIMER < 4
     
    4786
    4887#define CLOCK_INTERRUPT (QORIQ_IRQ_GT_BASE + QORIQ_CLOCK_TIMER)
    49 
    50 static struct timecounter qoriq_clock_tc;
    5188
    5289static void qoriq_clock_handler_install(void)
     
    124161}
    125162
    126 #define Clock_driver_support_initialize_hardware() \
    127   qoriq_clock_initialize()
    128 
    129163#define Clock_driver_support_install_isr(clock_isr) \
    130164  qoriq_clock_handler_install()
     
    136170  qoriq_clock_cleanup()
    137171
     172#endif /* QORIQ_IS_HYPERVISOR_GUEST */
     173
     174#define Clock_driver_support_initialize_hardware() \
     175  qoriq_clock_initialize()
     176
    138177/* Include shared source clock driver code */
    139178#include "../../../shared/clockdrv_shell.h"
  • c/src/lib/libbsp/powerpc/qoriq/include/bsp.h

    rfd70e206 rec28f31  
    114114void qoriq_initialize_exceptions(void *interrupt_stack_begin);
    115115
     116void qoriq_decrementer_dispatch(void);
     117
     118extern uint32_t bsp_time_base_frequency;
     119
     120extern uint32_t qoriq_clock_frequency;
     121
    116122#ifdef __cplusplus
    117123}
  • c/src/lib/libbsp/powerpc/qoriq/irq/irq.c

    rfd70e206 rec28f31  
    8989{
    9090        unsigned int vector;
     91
     92        if (exception_number == 10) {
     93                qoriq_decrementer_dispatch();
     94                return;
     95        }
    9196
    9297        ev_int_iack(0, &vector);
  • c/src/lib/libbsp/powerpc/qoriq/start/start.S

    rfd70e206 rec28f31  
    426426#endif
    427427        /* Decrementer */
    428         PPC_REG_STORE_UPDATE    r1, -EXC_GENERIC_SIZE(r1)
     428#ifdef QORIQ_IS_HYPERVISOR_GUEST
     429        PPC_REG_STORE_UPDATE    r1, -PPC_EXC_INTERRUPT_FRAME_SIZE(r1)
     430#else
     431        PPC_REG_STORE_UPDATE    r1, -EXC_GENERIC_SIZE(r1)
     432#endif
    429433        PPC_REG_STORE   r3, GPR3_OFFSET(r1)
    430434        li      r3, 10
    431         b       ppc_exc_fatal_normal
     435#ifdef QORIQ_IS_HYPERVISOR_GUEST
     436        b       ppc_exc_interrupt
     437#else
     438        b       ppc_exc_fatal_normal
     439#endif
    432440        START_NOP_FOR_LINKER_TOC_POINTER_RESTORE
    433441        /* Fixed-interval timer interrupt */
  • c/src/lib/libbsp/powerpc/qoriq/startup/bspstart.c

    rfd70e206 rec28f31  
    4949
    5050/* Configuration parameter for clock driver, ... */
    51 uint32_t bsp_clicks_per_usec;
     51uint32_t bsp_time_base_frequency;
     52
     53uint32_t qoriq_clock_frequency;
    5254
    5355void BSP_panic(char *s)
     
    98100    bsp_fatal(QORIQ_FATAL_FDT_NO_BUS_FREQUENCY);
    99101  }
    100   bsp_clicks_per_usec = fdt32_to_cpu(*val_fdt) / 1000000;
     102  bsp_time_base_frequency = fdt32_to_cpu(*val_fdt);
    101103
    102104  #ifdef __PPC_CPU_E6500__
     
    105107      bsp_fatal(QORIQ_FATAL_FDT_NO_CLOCK_FREQUENCY);
    106108    }
     109    qoriq_clock_frequency = fdt32_to_cpu(*val_fdt);
    107110  #endif
    108111  rtems_counter_initialize_converter(fdt32_to_cpu(*val_fdt));
Note: See TracChangeset for help on using the changeset viewer.