The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/am9513reg.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: am9513reg.h,v 1.4 2008/04/28 20:23:49 martin Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Matthew Fredette.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _AM9513REG_H
   33 #define _AM9513REG_H
   34 
   35 /*
   36  * Driver support for the Am9513 timer chip.  See
   37  * http://www.amd.com/products/cpg/techdocs/misc/03402/03402.html
   38  * for data sheets.
   39  */
   40 
   41 struct am9513 {
   42         u_int16_t       am9513_clk_data;        /* data register */
   43         u_int16_t       am9513_clk_cmd;         /* command register */
   44 };
   45 
   46 #define AM9513_CLK_DATA         0
   47 #define AM9513_CLK_CMD          2
   48 
   49 /*
   50  * All of the below macros are for use in bitfields in the Counter
   51  * Mode (CM) Register.
   52  */
   53 
   54 /* Gating control, CM[13:15]: */
   55 /*
   56  * Legend: A[HL][LE]?
   57  *         | |    `-> L = level, E = edge
   58  *         | `-> H = high, L = low
   59  *         `-> active
   60  *
   61  *         P1 = plus one, M1 = minus one
   62  */
   63 #define AM9513_CM_GATING_NONE           (0x0 << 13)
   64 #define AM9513_CM_GATING_AH_TCN_M1      (0x1 << 13)
   65 #define AM9513_CM_GATING_AHL_GATEN_P1   (0x2 << 13)
   66 #define AM9513_CM_GATING_AHL_GATEN_M1   (0x3 << 13)
   67 #define AM9513_CM_GATING_AHL_GATEN      (0x4 << 13)
   68 #define AM9513_CM_GATING_ALL_GATEN      (0x5 << 13)
   69 #define AM9513_CM_GATING_AHE_GATEN      (0x6 << 13)
   70 #define AM9513_CM_GATING_ALE_GATEN      (0x7 << 13)
   71 
   72 /* Source edge, CM[12]: */
   73 #define AM9513_CM_SOURCE_EDGE_RISING  (0 << 12)
   74 #define AM9513_CM_SOURCE_EDGE_FALLING (1 << 12)
   75 
   76 /* Count sources, CM[8:11]: */
   77 #define AM9513_CM_SOURCE_TCN1   (0x0 << 8)
   78 #define AM9513_CM_SOURCE_SRC1   (0x1 << 8)
   79 #define AM9513_CM_SOURCE_SRC2   (0x2 << 8)
   80 #define AM9513_CM_SOURCE_SRC3   (0x3 << 8)
   81 #define AM9513_CM_SOURCE_SRC4   (0x4 << 8)
   82 #define AM9513_CM_SOURCE_SRC5   (0x5 << 8)
   83 #define AM9513_CM_SOURCE_GATE1  (0x6 << 8)
   84 #define AM9513_CM_SOURCE_GATE2  (0x7 << 8)
   85 #define AM9513_CM_SOURCE_GATE3  (0x8 << 8)
   86 #define AM9513_CM_SOURCE_GATE4  (0x9 << 8)
   87 #define AM9513_CM_SOURCE_GATE5  (0xA << 8)
   88 #define AM9513_CM_SOURCE_F1     (0xB << 8)
   89 #define AM9513_CM_SOURCE_F2     (0xC << 8)
   90 #define AM9513_CM_SOURCE_F3     (0xD << 8)
   91 #define AM9513_CM_SOURCE_F4     (0xE << 8)
   92 #define AM9513_CM_SOURCE_F5     (0xF << 8)
   93 
   94 /* Count control, CM[7]: */
   95 #define AM9513_CM_SPECIAL_GATE_ENA      (1 << 7)
   96 #define AM9513_CM_SPECIAL_GATE_DIS      (0 << 7)
   97 
   98 /* Counter reload source, CM[6]: */
   99 #define AM9513_CM_RELOAD_SOURCE_LOAD            (0 << 6)
  100 #define AM9513_CM_RELOAD_SOURCE_LOAD_OR_HOLD    (1 << 6)
  101 
  102 /* Counter repeat control, CM[5]: */
  103 #define AM9513_CM_REPEAT_DIS    (0 << 5)
  104 #define AM9513_CM_REPEAT_ENA    (1 << 5)
  105 
  106 /* Counter type, CM[4]: */
  107 #define AM9513_CM_TYPE_BIN      (0 << 4)
  108 #define AM9513_CM_TYPE_BCD      (1 << 4)
  109 
  110 /* Counter direction, CM[3]: */
  111 #define AM9513_CM_DIR_DOWN      (0 << 3)
  112 #define AM9513_CM_DIR_UP        (1 << 3)
  113 
  114 /* Output control, CM[0:2]: */
  115 #define AM9513_CM_OUTPUT_OL             (0x0 << 0)      /* inactive, output low */
  116 #define AM9513_CM_OUTPUT_AHTCP          (0x1 << 0)      /* active high terminal count pulse */
  117 #define AM9513_CM_OUTPUT_TC_TOGGLED     (0x2 << 0)      /* TC toggled */
  118 #define AM9513_CM_OUTPUT_OHI            (0x4 << 0)      /* inactive, output high impedance */
  119 #define AM9513_CM_OUTPUT_ALTCP          (0x5 << 0)      /* active low terminal count pulse */
  120 
  121 /* The modes are various combinations of the above: */
  122 
  123 /* Mode A: */
  124 #define AM9513_CM_MODE_A (AM9513_CM_GATING_NONE \
  125                           | AM9513_CM_SPECIAL_GATE_DIS \
  126                           | AM9513_CM_RELOAD_SOURCE_LOAD \
  127                           | AM9513_CM_REPEAT_DIS)
  128 
  129 /*
  130  * Mode B is just like mode A, except you OR in the
  131  * AM9513_CM_GATING_ value for the *level* you want:
  132  */
  133 #define AM9513_CM_MODE_B AM9513_CM_MODE_A
  134 
  135 /*
  136  * Mode C is just like mode A, except you OR in the
  137  * AM9513_CM_GATING_ value for the *edge* you want:
  138  */
  139 #define AM9513_CM_MODE_C AM9513_CM_MODE_A
  140 
  141 /* Mode D: */
  142 #define AM9513_CM_MODE_D (AM9513_CM_GATING_NONE \
  143                           | AM9513_CM_SPECIAL_GATE_DIS \
  144                           | AM9513_CM_RELOAD_SOURCE_LOAD \
  145                           | AM9513_CM_REPEAT_ENA)
  146 
  147 /*
  148  * Mode E is just like mode D, except you OR in the
  149  * AM9513_CM_GATING_ value for the *level* you want:
  150  */
  151 #define AM9513_CM_MODE_E AM9513_CM_MODE_D
  152 
  153 /*
  154  * Mode F is just like mode D, except you OR in the
  155  * AM9513_CM_GATING_ value for the *edge* you want:
  156  */
  157 #define AM9513_CM_MODE_F AM9513_CM_MODE_D
  158 
  159 /* Mode G: */
  160 #define AM9513_CM_MODE_G (AM9513_CM_GATING_NONE \
  161                           | AM9513_CM_SPECIAL_GATE_DIS \
  162                           | AM9513_CM_RELOAD_SOURCE_LOAD_OR_HOLD \
  163                           | AM9513_CM_REPEAT_DIS)
  164 
  165 /*
  166  * Mode H is just like mode G, except you OR in the
  167  * AM9513_CM_GATING_ value for the *level* you want:
  168  */
  169 #define AM9513_CM_MODE_H AM9513_CM_MODE_G
  170 
  171 /*
  172  * Mode I is just like mode G, except you OR in the
  173  * AM9513_CM_GATING_ value for the *edge* you want:
  174  */
  175 #define AM9513_CM_MODE_I AM9513_CM_MODE_G
  176 
  177 /* Mode J: */
  178 #define AM9513_CM_MODE_J (AM9513_CM_GATING_NONE \
  179                           | AM9513_CM_SPECIAL_GATE_DIS \
  180                           | AM9513_CM_RELOAD_SOURCE_LOAD_OR_HOLD \
  181                           | AM9513_CM_REPEAT_ENA)
  182 
  183 /*
  184  * Mode K is just like mode J, except you OR in the
  185  * AM9513_CM_GATING_ value for the *level* you want:
  186  */
  187 #define AM9513_CM_MODE_K AM9513_CM_MODE_J
  188 
  189 /*
  190  * Mode L is just like mode J, except you OR in the
  191  * AM9513_CM_GATING_ value for the *edge* you want:
  192  */
  193 #define AM9513_CM_MODE_L AM9513_CM_MODE_J
  194 
  195 /* Mode N: */
  196 #define AM9513_CM_MODE_N (AM9513_CM_GATING_NONE \
  197                           | AM9513_CM_SPECIAL_GATE_ENA \
  198                           | AM9513_CM_RELOAD_SOURCE_LOAD \
  199                           | AM9513_CM_REPEAT_DIS)
  200 
  201 /*
  202  * Mode O is just like mode N, except you OR in the
  203  * AM9513_CM_GATING_ value for the *edge* you want:
  204  */
  205 #define AM9513_CM_MODE_O AM9513_CM_MODE_N
  206 
  207 /* Mode Q; OR in the AM9513_CM_GATING_ value for the *level* you want: */
  208 #define AM9513_CM_MODE_Q (AM9513_CM_GATING_NONE \
  209                           | AM9513_CM_SPECIAL_GATE_ENA \
  210                           | AM9513_CM_RELOAD_SOURCE_LOAD \
  211                           | AM9513_CM_REPEAT_ENA)
  212 
  213 /*
  214  * Mode R is just like mode N, except you OR in the
  215  * AM9513_CM_GATING_ value for the *edge* you want:
  216  */
  217 #define AM9513_CM_MODE_R AM9513_CM_MODE_Q
  218 
  219 /* Mode S: */
  220 #define AM9513_CM_MODE_S (AM9513_CM_GATING_NONE \
  221                           | AM9513_CM_SPECIAL_GATE_ENA \
  222                           | AM9513_CM_RELOAD_SOURCE_LOAD_OR_HOLD \
  223                           | AM9513_CM_REPEAT_DIS)
  224 
  225 /* Mode V: */
  226 #define AM9513_CM_MODE_V (AM9513_CM_GATING_NONE \
  227                           | AM9513_CM_SPECIAL_GATE_ENA \
  228                           | AM9513_CM_RELOAD_SOURCE_LOAD_OR_HOLD \
  229                           | AM9513_CM_REPEAT_ENA)
  230 
  231 /* Given an AM9513_CM_SOURCE_F? value, return the divisor: */
  232 #define AM9513_CM_SOURCE_Fn_DIV(func) (1 << (((func) - AM9513_CM_SOURCE_F1) >> 6))
  233 
  234 /*
  235  * Given a basic frequency and an AM9513_CM_SOURCE_F? value, returns
  236  * the number of clock ticks for a certain frequency:
  237  */
  238 #define AM9513_TICKS(basic, func, hz) (((basic) / AM9513_CM_SOURCE_Fn_DIV(func)) / (hz))
  239 
  240 /* These are the timer numbers: */
  241 #define AM9513_TIMER1   (1)
  242 #define AM9513_TIMER2   (2)
  243 #define AM9513_TIMER3   (3)
  244 #define AM9513_TIMER4   (4)
  245 #define AM9513_TIMER5   (5)
  246 
  247 /*
  248  * This macro is used to compose a bitmask of times for those
  249  * commands that take a bitmask:
  250  */
  251 #define AM9513_TIMER_BIT(timer) (1 << ((timer) - 1))
  252 
  253 /* When in 16-bit mode, the high 8 bits of every command must be ones: */
  254 #define _AM9513_CMD(x) (0xFF00 | (x))
  255 
  256 /* Commands: */
  257 #define AM9513_CMD_LOAD_MODE(timer)             _AM9513_CMD(0x00 | (timer))
  258 #define AM9513_CMD_LOAD_LOAD(timer)             _AM9513_CMD(0x08 | (timer))
  259 #define AM9513_CMD_LOAD_HOLD(timer)             _AM9513_CMD(0x10 | (timer))
  260 #define AM9513_CMD_ARM(timers)                  _AM9513_CMD(0x20 | (timers))
  261 #define AM9513_CMD_LOAD(timers)                 _AM9513_CMD(0x40 | (timers))
  262 #define AM9513_CMD_LOAD_ARM(timers)             _AM9513_CMD(0x60 | (timers))
  263 #define AM9513_CMD_SAVE(timers)                 _AM9513_CMD(0xA0 | (timers))
  264 #define AM9513_CMD_DISARM(timers)               _AM9513_CMD(0xC0 | (timers))
  265 #define AM9513_CMD_CLEAR_OUTPUT(timer)          _AM9513_CMD(0xE0 | (timer))
  266 #define AM9513_CMD_RESET                        _AM9513_CMD(0xFF)
  267 
  268 /* These are mode register values for various uses */
  269 #define AM9513_TICK_MODE        (AM9513_F2+0x22)        /* F2 + Operating mode D */
  270 #define AM9513_UART_MODE        (AM9513_F1+0x22)        /* F1 + Operating mode D */
  271 #define AM9513_FAST_LO_MODE     (AM9513_F3+0x28)        /* F3, repeat, count up */
  272 #define AM9513_FAST_HI_MODE     (0x0028)                /* TC of LO, repeat, count up */
  273 
  274 #endif  /* _AM9513REG_H */

Cache object: 78664a8a8600fab2c895370168521c31


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.