source: mainline/uspace/drv/infrastructure/rootamdm37x/prm/clock_control.h@ 167c7b3

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 167c7b3 was 167c7b3, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

rootamdm37x: Fix freq calculations.

prm.clocks→clksel stores value of OSC_SYS_CLK not SYS_CLK.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2012 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup amdm37xdrvprm
30 * @{
31 */
32/** @file
33 * @brief Clock Control Clock Management IO register structure.
34 */
35#ifndef AMDM37X_PRM_CLOCK_CONTROL_H
36#define AMDM37X_PRM_CLOCK_CONTROL_H
37#include <sys/types.h>
38#include <macros.h>
39
40/* AM/DM37x TRM p.536 and p.589 */
41#define CLOCK_CONTROL_PRM_BASE_ADDRESS 0x48306d00
42#define CLOCK_CONTROL_PRM_SIZE 8192
43
44/** Clock control PRM register map
45 */
46typedef struct {
47 PADD32[16];
48 ioport32_t clksel;
49#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_MASK (0x7)
50#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M (0x0)
51#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M (0x1)
52#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M (0x2)
53#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M (0x3)
54#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M (0x4)
55#define CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M (0x5)
56
57 PADD32[12];
58 ioport32_t clkout_ctrl;
59#define CLOCK_CONTROL_PRM_CLKOUT_CTRL_CLKOUOUT_EN_FLAG (1 << 7)
60
61} clock_control_prm_regs_t;
62
63static inline unsigned sys_clk_freq_kHz(unsigned reg_val)
64{
65 switch(reg_val)
66 {
67 case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_12M: return 12000;
68 case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_13M: return 13000;
69 case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_19_2M: return 19200;
70 case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_26M: return 26000;
71 case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_38_4M: return 38400;
72 case CLOCK_CONTROL_PRM_CLKSEL_SYS_CLKIN_16_8M: return 16800;
73 }
74 return 0;
75}
76
77
78#endif
79/**
80 * @}
81 */
Note: See TracBrowser for help on using the repository browser.