Changeset 142a9df in rtems


Ignore:
Timestamp:
Jul 10, 2009, 3:34:12 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
5c736abd
Parents:
55b891e2
Message:

2009-07-10 Xi Yang <hiyangxi@…>

  • Makefile.am, pxa255/ffuart/ffuart.c, pxa255/include/pxa255.h, pxa255/pmc/pmc.c: Add PMC support.
Location:
c/src/lib/libcpu/arm
Files:
5 edited

Legend:

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

    r55b891e2 r142a9df  
     12009-07-10      Xi Yang <hiyangxi@gmail.com>
     2
     3        * Makefile.am, pxa255/ffuart/ffuart.c, pxa255/include/pxa255.h,
     4        pxa255/pmc/pmc.c: Add PMC support.
     5
    162009-06-29      Xi Yang <hiyangxi@gmail.com>
    27
  • c/src/lib/libcpu/arm/Makefile.am

    r55b891e2 r142a9df  
    4444pxa255_ffuart_rel_CPPFLAGS = $(AM_CPPFLAGS)
    4545pxa255_ffuart_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
     46
     47## pxa255/pmc
     48noinst_PROGRAMS += pxa255/pmc.rel
     49pxa255_pmc_rel_SOURCES = pxa255/pmc/pmc.c
     50pxa255_pmc_rel_CPPFLAGS = $(AM_CPPFLAGS)
     51pxa255_pmc_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
     52
    4653## pxa255/interrupt
    4754include_HEADERS += pxa255/irq/irq.h
  • c/src/lib/libcpu/arm/pxa255/ffuart/ffuart.c

    r55b891e2 r142a9df  
    2121
    2222volatile int dbg_dly;
    23 void _start(void);
    2423
    2524/* static function prototypes */
  • c/src/lib/libcpu/arm/pxa255/include/pxa255.h

    r55b891e2 r142a9df  
    8282#define XSCALE_CLOCKS_CCCR      (*(volatile word_t *)(XSCALE_CLOCKS + 0x00))
    8383
    84 
    8584/*Use ffuart port as the console*/
    8685#define FFUART_BASE   0x40100000
    8786
    88 
    89 /*Write to KSYEYE_MAGIC_ADDRESS makes SKYEYE to exits*/
     87/*Write to SKYEYE_MAGIC_ADDRESS to make SKYEYE  exit*/
    9088
    9189#define SKYEYE_MAGIC_ADDRESS (*(volatile word_t *)(0xb0000000))
     
    9391
    9492/*PMC*/
    95 /*Clock counter overflow flag*/
    96 #define CCOF (0x01<<10)
    97 #define ENABLE_CC_INT (0x01<<6)
    98 #define ENABLE_PMC_CC (0x01)
    99 #define RESET_CC (0x01<<2)
     93#define PMC_PMNC 0
     94#define PMC_CCNT 1
     95#define PMC_INTEN 2
     96#define PMC_FLAG 3
     97#define PMC_EVTSEL 4
     98#define PMC_PMN0 5
     99#define PMC_PMN1 6
     100#define PMC_PMN2 7
     101#define PMC_PMN3 8
     102
     103#define PMC_PMNC_E (0x01)
     104#define PMC_PMNC_PCR (0x01 << 1)
     105#define PMC_PMNC_CCR (0x01 << 2)
     106#define PMC_PMNC_CCD (0x01 << 3)
     107#define PMC_PMNC_PCD (0x01 << 4)
    100108
    101109#endif
  • c/src/lib/libcpu/arm/pxa255/pmc/pmc.c

    r55b891e2 r142a9df  
    1313#include <pxa255.h>
    1414
    15 unsigned int int_latency;
    16 
    17 static void pmc_isr_on(const rtems_irq_connect_data *unused)
     15unsigned int xscale_read_pmc(int reg)
    1816{
    19   unsigned int operand;
    20   /*clean CC*/
    21   operand = 0x0;
    22   asm volatile("mcr p14,0,%0,c1,c0,0 \n"::"r"(operand));
    23    /*clean the Clock counter flag and enable the interrupt of CC*/
    24   operand = 0x0|RESET_CCOF|ENABLE_CC_INT|RESET_CC|ENABLE_PMC_CC;
    25   asm volatile("mcr p14,0,%0,c0,c0,0 \n"::"r"(operand));
    26   /*Set to the 4kHZ*/
    27   operand = (unsigned int)0xffffffff-(unsigned int)100000;
    28   asm volatile("mcr p14,0,%0,c1,c0,0 \n"::"r"(operand));
     17  unsigned int val = 0;
     18  switch(reg){
     19  case PMC_PMNC:
     20    asm volatile("mrc p14,0,%0,c0,c1,0\n":"=r"(val):);
     21    break;
     22  case PMC_CCNT:
     23    asm volatile("mrc p14,0,%0,c1,c1,0\n":"=r"(val):);
     24    break;
     25  case PMC_INTEN:
     26    asm volatile("mrc p14,0,%0,c4,c1,0\n":"=r"(val):);
     27    break;
     28  case PMC_FLAG:
     29    asm volatile("mrc p14,0,%0,c5,c1,0\n":"=r"(val):);
     30    break;
     31  case PMC_EVTSEL:
     32    asm volatile("mrc p14,0,%0,c8,c1,0\n":"=r"(val):);
     33    break;
     34  case PMC_PMN0:
     35    asm volatile("mrc p14,0,%0,c0,c2,0\n":"=r"(val):);
     36    break;
     37  case PMC_PMN1:
     38    asm volatile("mrc p14,0,%0,c1,c2,0\n":"=r"(val):);
     39    break;
     40  case PMC_PMN2:
     41    asm volatile("mrc p14,0,%0,c2,c2,0\n":"=r"(val):);
     42    break;
     43  case PMC_PMN3:
     44    asm volatile("mrc p14,0,%0,c3,c2,0\n":"=r"(val):);
     45    break;
     46  default:
     47    val = 0;
     48    break;
     49  }
     50  return val;
    2951}
    3052
    31 static void pmc_isr_off(const rtems_irq_connect_data *unused)
     53void xscale_write_pmc(int reg, unsigned int val)
    3254{
    33   unsigned int operand;
    34   operand = 0x0|RESET_CCOF;
    35   asm volatile("mcr p14,0,%0,c0,c0,0 \n"::"r"(operand));
     55  switch(reg){
     56  case PMC_PMNC:
     57    asm volatile("mcr p14,0,%0,c0,c1,0\n"::"r"(val));
     58    break;
     59  case PMC_CCNT:
     60    asm volatile("mcr p14,0,%0,c1,c1,0\n"::"r"(val));
     61    break;
     62  case PMC_INTEN:
     63    asm volatile("mcr p14,0,%0,c4,c1,0\n"::"r"(val));
     64    break;
     65  case PMC_FLAG:
     66    asm volatile("mcr p14,0,%0,c5,c1,0\n"::"r"(val));
     67    break;
     68  case PMC_EVTSEL:
     69    asm volatile("mcr p14,0,%0,c8,c1,0\n"::"r"(val));
     70    break;
     71  case PMC_PMN0:
     72    asm volatile("mcr p14,0,%0,c0,c2,0\n"::"r"(val));
     73    break;
     74  case PMC_PMN1:
     75    asm volatile("mcr p14,0,%0,c1,c2,0\n"::"r"(val));
     76    break;
     77  case PMC_PMN2:
     78    asm volatile("mcr p14,0,%0,c2,c2,0\n"::"r"(val));
     79    break;
     80  case PMC_PMN3:
     81    asm volatile("mcr p14,0,%0,c3,c2,0\n"::"r"(val));
     82    break;
     83  default:
     84    break;
     85  }
    3686}
    3787
    38 static int pmc_isr_is_on(const rtems_irq_connect_data *unused)
     88void xscale_pmc_enable_pmc(void)
    3989{
    40   unsigned int operand;
    41   asm volatile("mrc p14,0,%0,c0,c0,0 \n":"=r"(operand):);
    42   if((operand & ENABLE_PMC_CC ) && (operand & ENABLE_CC_INT))
    43     return 1;
    44   return 0;
     90  unsigned int val;
     91  val = xscale_read_pmc(PMC_PMNC);
     92  val = (val | PMC_PMNC_E)&(~PMC_PMNC_PCD);
     93  xscale_write_pmc(PMC_PMNC,val);
    4594}
     95void xscale_pmc_disable_pmc(void)
     96{
     97  unsigned int val;
     98  val = xscale_read_pmc(PMC_PMNC);
     99  val = val & (~PMC_PMNC_E);
     100  xscale_write_pmc(PMC_PMNC,val);
     101}
     102
     103void xscale_pmc_reset_pmc(void)
     104{
     105  unsigned int val;
     106  val = xscale_read_pmc(PMC_PMNC);
     107  val = val | PMC_PMNC_PCR;
     108  xscale_write_pmc(PMC_PMNC,val);
     109}
     110
     111void xscale_pmc_reset_ccnt(void)
     112{
     113  unsigned int val;
     114  val = xscale_read_pmc(PMC_PMNC);
     115  val = val | PMC_PMNC_CCR;
     116  xscale_write_pmc(PMC_PMNC,val);
     117}
     118
     119void xscale_pmc_setevent(int reg, unsigned char evt)
     120{
     121  unsigned int val;
     122  val = xscale_read_pmc(PMC_EVTSEL);
     123  if((reg >= PMC_PMN0) && (reg <= PMC_PMN3)){
     124    val &= ~(0xff<<(reg-PMC_PMN0)*8);
     125    val |= evt << (reg-PMC_PMN0)*8;
     126    xscale_write_pmc(PMC_EVTSEL,val);
     127  }
     128}
Note: See TracChangeset for help on using the changeset viewer.