Changeset 3fa48ee in rtems


Ignore:
Timestamp:
Dec 1, 2007, 12:22:30 AM (12 years ago)
Author:
Till Straumann <strauman@…>
Branches:
4.10, 4.11, 4.9, master
Children:
bd1cc5f0
Parents:
d18d7fe0
Message:

2007-11-30 Till Straumann <strauman@…>

  • mpc6xx/clock/c_clock.c, mpc6xx/clock/c_clock.h: added support for bookE/ppc405 style CPUs where the decrementer works slightly differently.
Location:
c/src/lib/libcpu/powerpc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/ChangeLog

    rd18d7fe0 r3fa48ee  
     12007-11-30      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * mpc6xx/clock/c_clock.c, mpc6xx/clock/c_clock.h:
     4        added support for bookE/ppc405 style CPUs where the
     5        decrementer works slightly differently.
     6
     72007-11-30      Till Straumann <strauman@slac.stanford.edu>
     8
     9        * mpc6xx/mmu/bat.c, mpc6xx/mmu/pte121.c
    1102007-11-29      Till Straumann <strauman@slac.stanford.edu>
    211
  • c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c

    rd18d7fe0 r3fa48ee  
    2626#include <assert.h>
    2727#include <libcpu/c_clock.h>
     28#include <libcpu/cpuIdent.h>
     29#include <libcpu/spr.h>
    2830#include <rtems/bspIo.h>                     /* for printk() */
     31
     32SPR_RW(BOOKE_TCR)
     33SPR_RW(BOOKE_TSR)
     34SPR_RW(BOOKE_DECAR)
     35SPR_RW(DEC)
    2936
    3037extern int BSP_connect_clock_handler (void);
     
    5158void clockOff(void* unused)
    5259{
     60rtems_interrupt_level l;
     61
     62  if ( ppc_cpu_is_bookE() ) {
     63    rtems_interrupt_disable(l);
     64    _write_BOOKE_TCR(_read_BOOKE_TCR() & ~BOOKE_TCR_DIE);
     65    rtems_interrupt_enable(l);
     66  } else {
    5367  /*
    5468   * Nothing to do as we cannot disable all interrupts and
    5569   * the decrementer interrupt enable is MSR_EE
    5670   */
    57 }
     71  }
     72}
     73
    5874void clockOn(void* unused)
    5975{
     76rtems_interrupt_level l;
     77
    6078  PPC_Set_decrementer( Clock_Decrementer_value );
     79
     80  if ( ppc_cpu_is_bookE() ) {
     81    _write_BOOKE_DECAR( Clock_Decrementer_value );
     82
     83    rtems_interrupt_disable(l);
     84
     85    /* clear pending/stale irq */
     86    _write_BOOKE_TSR( BOOKE_TSR_DIS );
     87    /* enable */
     88    _write_BOOKE_TCR( _read_BOOKE_TCR() | BOOKE_TCR_DIE );
     89
     90    rtems_interrupt_enable(l);
     91
     92  }
    6193}
    6294
     
    102134}
    103135
     136/*
     137 *  Clock_isr_bookE
     138 *
     139 *  This is the clock tick interrupt handler
     140 *  for bookE CPUs. For efficiency reasons we
     141 *  provide a separate handler rather than
     142 *  checking the CPU type each time.
     143 *
     144 *  Input parameters:
     145 *    vector - vector number
     146 *
     147 *  Output parameters:  NONE
     148 *
     149 *  Return values:      NONE
     150 *
     151 */
     152void clockIsrBookE(void *unused)
     153{
     154  /* Note: TSR bit has already been cleared in the exception handler */
     155
     156  /*
     157   *  The driver has seen another tick.
     158   */
     159
     160  Clock_driver_ticks += 1;
     161
     162  /*
     163   *  Real Time Clock counter/timer is set to automatically reload.
     164   */
     165  clock_handler();
     166
     167}
     168
    104169int clockIsOn(void* unused)
    105170{
    106   uint32_t   msr_value;
    107 
    108   _CPU_MSR_GET( msr_value );
    109   if (msr_value & MSR_EE) return 1;
    110   return 0;
     171uint32_t   msr_value;
     172
     173        _CPU_MSR_GET( msr_value );
     174
     175        if ( ppc_cpu_is_bookE() && ! (_read_BOOKE_TCR() & BOOKE_TCR_DIE) )
     176                msr_value = 0;
     177
     178        if (msr_value & MSR_EE) return 1;
     179
     180        return 0;
    111181}
    112182
     
    168238)
    169239{
     240rtems_interrupt_level l,tcr;
     241
    170242  Clock_Decrementer_value = (BSP_bus_frequency/BSP_time_base_divisor)*
    171243            (rtems_configuration_get_microseconds_per_tick()/1000);
     
    175247   */
    176248  PPC_Set_decrementer( (unsigned)-1 );
     249
     250  /* On a bookE CPU the decrementer works differently. It doesn't
     251   * count past zero but we can enable auto-reload :-)
     252   */
     253  if ( ppc_cpu_is_bookE() ) {
     254
     255    rtems_interrupt_disable(l);
     256
     257    tcr  = _read_BOOKE_TCR();
     258        tcr |= BOOKE_TCR_ARE;
     259        tcr &= ~BOOKE_TCR_DIE;
     260    _write_BOOKE_TCR(tcr);
     261
     262    rtems_interrupt_enable(l);
     263
     264  }
    177265
    178266  /*
  • c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.h

    rd18d7fe0 r3fa48ee  
    3333extern void clockOn     (void* unused);
    3434extern void clockIsr    (void* unused);
     35/* bookE decrementer is slightly different */
     36extern void clockIsrBookE (void *unused);
    3537extern int  clockIsOn   (void* unused);
    3638
Note: See TracChangeset for help on using the changeset viewer.