1 /* $NetBSD: lm700x.h,v 1.2 2007/10/19 11:59:55 ad Exp $ */ 2 /* $OpenBSD: lm700x.h,v 1.2 2001/12/06 16:28:18 mickey Exp $ */ 3 /* $RuOBSD: lm700x.h,v 1.2 2001/10/18 16:51:36 pva Exp $ */ 4 5 /* 6 * Copyright (c) 2001 Vladimir Popov <jumbo@narod.ru> 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LM700X_H_ 31 #define _LM700X_H_ 32 33 #include <sys/types.h> 34 35 #include <sys/bus.h> 36 37 #define LM700X_REGISTER_LENGTH 24 38 39 #define LM700X_DATA_MASK 0xFFC000 40 #define LM700X_FREQ_MASK 0x003FFF 41 42 #define LM700X_FREQ(x) (x << 0) /* 0x003FFF */ 43 #define LM700X_LSI(x) (x << 14) /* 0x00C000 */ /* always zero */ 44 #define LM700X_BAND(x) (x << 16) /* 0x070000 */ 45 #define LM700X_STEREO LM700X_BAND(3) 46 #define LM700X_MONO LM700X_BAND(1) 47 #define LM700X_TIME_BASE(x) (x << 19) /* 0x080000 */ /* always zero */ 48 #define LM700X_REF_FREQ(x) (x << 20) /* 0x700000 */ 49 #define LM700X_REF_100 LM700X_REF_FREQ(0) 50 #define LM700X_REF_025 LM700X_REF_FREQ(2) 51 #define LM700X_REF_050 LM700X_REF_FREQ(4) 52 /* The rest is for an AM band */ 53 54 #define LM700X_DIVIDER_AM (0 << 23) /* 0x000000 */ 55 #define LM700X_DIVIDER_FM (1 << 23) /* 0x800000 */ 56 57 #define LM700X_WRITE_DELAY 6 /* 6 microseconds */ 58 59 struct lm700x_t { 60 bus_space_tag_t iot; 61 bus_space_handle_t ioh; 62 bus_size_t offset; 63 64 u_int32_t wzcl; /* write zero clock low */ 65 u_int32_t wzch; /* write zero clock high */ 66 u_int32_t wocl; /* write one clock low */ 67 u_int32_t woch; /* write one clock high */ 68 u_int32_t initdata; 69 u_int32_t rsetdata; 70 71 void (*init)(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t); 72 void (*rset)(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t); 73 }; 74 75 u_int32_t lm700x_encode_freq(u_int32_t, u_int32_t); 76 u_int32_t lm700x_encode_ref(u_int8_t); 77 u_int8_t lm700x_decode_ref(u_int32_t); 78 void lm700x_hardware_write(struct lm700x_t *, u_int32_t, u_int32_t); 79 80 #endif /* _LM700X_H_ */ 81