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