1 /* $NetBSD: lm700x.c,v 1.1.20.3 2004/09/21 13:28:04 skrll Exp $ */
2 /* $OpenBSD: lm700x.c,v 1.2 2001/12/06 16:28:18 mickey Exp $ */
5 * Copyright (c) 2001 Vladimir Popov <jumbo@narod.ru>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
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, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /* Implementation of most common lm700x routines */
32 * Sanyo LM7001 Direct PLL Frequency Synthesizer
33 * ??? See http://www.redsword.com/tjacobs/geeb/fmcard.htm
35 * The LM7001J and LM7001JM (used in Aztech/PackardBell cards) are PLL
36 * frequency synthesizer LSIs for tuners. These LSIs are software compatible
37 * with LM7000 (used in Radiotrack, Radioreveal RA300, some Mediaforte cards),
38 * but do not include an IF calculation circuit.
40 * The FM VCO circuit includes a high-speed programmable divider that can
44 * Seven reference frequencies: 1, 5, 9, 10, 25, 50, and 100 kHz;
45 * Band-switching outputs (3 bits);
46 * Controller clock output (400 kHz);
47 * Serial input circuit for data input (using the CE, CL and DATA pins).
49 * The LM7001J and LM7001JM have a 24-bit shift register.
52 #include <sys/cdefs.h>
53 __KERNEL_RCSID(0, "$NetBSD: lm700x.c,v 1.1.20.3 2004/09/21 13:28:04 skrll Exp $");
55 #include <sys/param.h>
56 #include <sys/radioio.h>
58 #include <dev/ic/lm700x.h>
61 lm700x_encode_freq(u_int32_t nfreq
, u_int32_t rf
)
64 nfreq
/= lm700x_decode_ref(rf
);
69 lm700x_hardware_write(struct lm700x_t
*lm
, u_int32_t data
, u_int32_t addon
)
73 lm
->init(lm
->iot
, lm
->ioh
, lm
->offset
, lm
->rsetdata
| addon
);
75 for (i
= 0; i
< LM700X_REGISTER_LENGTH
; i
++)
76 if (data
& (1 << i
)) {
77 bus_space_write_1(lm
->iot
, lm
->ioh
, lm
->offset
,
79 DELAY(LM700X_WRITE_DELAY
);
80 bus_space_write_1(lm
->iot
, lm
->ioh
, lm
->offset
,
82 DELAY(LM700X_WRITE_DELAY
);
83 bus_space_write_1(lm
->iot
, lm
->ioh
, lm
->offset
,
86 bus_space_write_1(lm
->iot
, lm
->ioh
, lm
->offset
,
88 DELAY(LM700X_WRITE_DELAY
);
89 bus_space_write_1(lm
->iot
, lm
->ioh
, lm
->offset
,
91 DELAY(LM700X_WRITE_DELAY
);
92 bus_space_write_1(lm
->iot
, lm
->ioh
, lm
->offset
,
96 lm
->rset(lm
->iot
, lm
->ioh
, lm
->offset
, lm
->rsetdata
| addon
);
100 lm700x_encode_ref(u_int8_t rf
)
105 ret
= LM700X_REF_025
;
106 else if (rf
> 35 && rf
< 75)
107 ret
= LM700X_REF_050
;
109 ret
= LM700X_REF_100
;
115 lm700x_decode_ref(u_int32_t rf
)