21 #include <linux/kernel.h>
22 #include <linux/slab.h>
35 #define UW2453_REGWRITE(reg, val) ((((reg) & 0xf) << 20) | ((val) & 0xfffff))
54 static const u8 uw2453_std_synth[] = {
74 static const u16 uw2453_synth_divide[] = {
96 #define CHAN_TO_PAIRIDX(a) ((a - 1) / 2)
97 #define RF_CHANPAIR(a,b) [CHAN_TO_PAIRIDX(a)]
98 static const u16 uw2453_std_vco_cfg[][7] = {
202 static const u16 uw2453_autocal_synth[] = {
220 static const u16 UW2453_AUTOCAL_VCO_CFG = 0x6662;
224 static u32 uw2453_txgain[] = {
253 #define UW2453_PRIV(rf) ((struct uw2453_priv *) (rf)->priv)
259 int idx = channel - 1;
271 return zd_rfwrite_locked(chip,
283 static int uw2453_init_mode(
struct zd_chip *chip)
285 static const u32 rv[] = {
295 static int uw2453_set_tx_gain_level(
struct zd_chip *chip,
int channel)
301 "int value %x on channel %d\n", int_value, channel);
305 return zd_rfwrite_locked(chip,
309 static int uw2453_init_hw(
struct zd_rf *rf)
312 int found_config = -1;
314 struct zd_chip *chip = zd_rf_to_chip(rf);
357 static const u32 rv[] = {
386 r = uw2453_init_mode(chip);
391 for (i = 0; i <
ARRAY_SIZE(uw2453_std_vco_cfg) - 1; i++) {
393 r = uw2453_synth_set_channel(chip, 1,
false);
398 r = uw2453_write_vco_cfg(chip, uw2453_std_vco_cfg[i][0]);
412 if (!(intr_status & 0xf)) {
414 "PLL locked on configuration %d\n", i);
420 if (found_config == -1) {
423 "PLL did not lock, using autocal\n");
425 r = uw2453_synth_set_channel(chip, 1,
true);
429 r = uw2453_write_vco_cfg(chip, UW2453_AUTOCAL_VCO_CFG);
438 return zd_iowrite16_locked(chip, 0x06,
ZD_CR203);
441 static int uw2453_set_channel(
struct zd_rf *rf,
u8 channel)
446 bool autocal = (config == -1);
447 struct zd_chip *chip = zd_rf_to_chip(rf);
454 r = uw2453_synth_set_channel(chip, channel, autocal);
459 vco_cfg = UW2453_AUTOCAL_VCO_CFG;
463 r = uw2453_write_vco_cfg(chip, vco_cfg);
467 r = uw2453_init_mode(chip);
475 r = uw2453_set_tx_gain_level(chip, channel);
479 return zd_iowrite16_locked(chip, 0x06,
ZD_CR203);
482 static int uw2453_switch_radio_on(
struct zd_rf *rf)
485 struct zd_chip *chip = zd_rf_to_chip(rf);
495 if (zd_chip_is_zd1211b(chip))
496 ioreqs[1].
value = 0x7f;
501 static int uw2453_switch_radio_off(
struct zd_rf *rf)
504 struct zd_chip *chip = zd_rf_to_chip(rf);
518 static void uw2453_clear(
struct zd_rf *rf)
530 rf->
clear = uw2453_clear;