source: rtems/c/src/lib/libbsp/powerpc/qoriq/clock/clock-config.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup QorIQ
5 *
6 * @brief QorIQ clock configuration.
7 */
8
9/*
10 * Copyright (c) 2011-2012 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 */
22
23#include <libcpu/powerpc-utility.h>
24
25#include <bsp.h>
26#include <bsp/qoriq.h>
27#include <bsp/irq.h>
28
29/* This is defined in clockdrv_shell.h */
30static rtems_isr Clock_isr(void *arg);
31
32static uint32_t qoriq_clock_nanoseconds_per_timer_tick;
33
34static volatile qoriq_pic_global_timer *const qoriq_clock =
35  #if QORIQ_CLOCK_TIMER < 4
36    &qoriq.pic.gta [QORIQ_CLOCK_TIMER];
37  #else
38    &qoriq.pic.gtb [QORIQ_CLOCK_TIMER - 4];
39  #endif
40
41#define CLOCK_INTERRUPT (QORIQ_IRQ_GT_BASE + QORIQ_CLOCK_TIMER)
42
43static void qoriq_clock_handler_install(rtems_isr_entry *old_isr)
44{
45  rtems_status_code sc = RTEMS_SUCCESSFUL;
46
47  *old_isr = NULL;
48
49  sc = qoriq_pic_set_affinity(
50    CLOCK_INTERRUPT,
51    ppc_processor_id()
52  );
53  if (sc != RTEMS_SUCCESSFUL) {
54    rtems_fatal_error_occurred(0xdeadbeef);
55  }
56
57  sc = qoriq_pic_set_priority(
58    CLOCK_INTERRUPT,
59    QORIQ_PIC_PRIORITY_LOWEST,
60    NULL
61  );
62  if (sc != RTEMS_SUCCESSFUL) {
63    rtems_fatal_error_occurred(0xdeadbeef);
64  }
65
66  sc = rtems_interrupt_handler_install(
67    CLOCK_INTERRUPT,
68    "Clock",
69    RTEMS_INTERRUPT_UNIQUE,
70    Clock_isr,
71    NULL
72  );
73  if (sc != RTEMS_SUCCESSFUL) {
74    rtems_fatal_error_occurred(0xdeadbeef);
75  }
76}
77
78static void qoriq_clock_initialize(void)
79{
80  uint32_t timer_frequency = BSP_bus_frequency / 8;
81  uint32_t nanoseconds_per_second = 1000000000;
82  uint32_t interval = (uint32_t) (((uint64_t) timer_frequency
83    * (uint64_t) rtems_configuration_get_microseconds_per_tick()) / 1000000);
84
85  qoriq_clock_nanoseconds_per_timer_tick =
86    nanoseconds_per_second / timer_frequency;
87
88  qoriq_clock->bcr = GTBCR_COUNT(interval);
89}
90
91static void qoriq_clock_cleanup(void)
92{
93  rtems_status_code sc = RTEMS_SUCCESSFUL;
94
95  qoriq_clock->bcr = GTBCR_CI;
96
97  sc = rtems_interrupt_handler_remove(
98    CLOCK_INTERRUPT,
99    Clock_isr,
100    NULL
101  );
102  if (sc != RTEMS_SUCCESSFUL) {
103    rtems_fatal_error_occurred(0xdeadbeef);
104  }
105}
106
107static uint32_t qoriq_clock_nanoseconds_since_last_tick(void)
108{
109  uint32_t current = GTCCR_COUNT_GET(qoriq_clock->ccr);
110  uint32_t base = qoriq_clock->bcr;
111
112  return (base - current) * qoriq_clock_nanoseconds_per_timer_tick;
113}
114
115#define Clock_driver_support_at_tick()
116#define Clock_driver_support_initialize_hardware() \
117  qoriq_clock_initialize()
118#define Clock_driver_support_install_isr(clock_isr, old_isr) \
119  qoriq_clock_handler_install(&old_isr)
120#define Clock_driver_support_shutdown_hardware() \
121  qoriq_clock_cleanup()
122#define Clock_driver_nanoseconds_since_last_tick \
123  qoriq_clock_nanoseconds_since_last_tick
124
125/* Include shared source clock driver code */
126#include "../../../shared/clockdrv_shell.h"
Note: See TracBrowser for help on using the repository browser.