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

Cache object: 5f7cc34c6c0c3a7e66038eae204ff69f


[ 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.