/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2004, 2005 David Young. All rights reserved.
*
* Programmed for NetBSD by David Young.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. The name of David Young may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David
* Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
/*
* Control the Philips SA2400 RF front-end and the baseband processor
* built into the Realtek RTL8180.
*/
#include <sys/sysmacros.h>
#include "rtwreg.h"
#include "rtwvar.h"
#include "max2820reg.h"
#include "sa2400reg.h"
#include "rtwphyio.h"
#include "rtwphy.h"
static int
enum rtw_pwrstate power)
{
}
static int
{
}
static int
{
}
static int
{
}
static int
{
if (dflantb)
}
static int
{
int rc;
if (antdiv)
return (rc);
return (rc);
return (0);
}
static int
{
}
#ifdef _RTW_FUTURE_DEBUG_
/*
* make sure we're using the same settings as the reference driver
*/
static void
{
switch (freq) {
case 2412:
break;
case 2417:
break;
case 2422:
break;
case 2427:
break;
case 2432:
break;
case 2437:
break;
case 2442:
break;
case 2447:
break;
case 2452:
break;
case 2457:
break;
case 2462:
break;
case 2467:
break;
case 2472:
break;
case 2484:
break;
}
}
#endif /* _RTW_FUTURE_DEBUG_ */
/* freq is in MHz */
static int
{
int rc;
/*
* XO = 44MHz, R = 11, hence N is in units of XO / R = 4MHz.
*
* The channel spacing (5MHz) is not divisible by 4MHz, so
* we set the fractional part of N to compensate.
*/
/* verify_syna(freq, syna); */
/*
* Divide the 44MHz crystal down to 4MHz. Set the fractional
* compensation charge pump value to agree with the fractional
* modulus.
*/
syna)) != 0)
return (rc);
synb)) != 0)
return (rc);
sync)) != 0)
return (rc);
}
static int
{
switch (power) {
case RTW_ON:
break;
case RTW_SLEEP:
break;
case RTW_OFF:
break;
}
opmode));
}
static int
{
/*
* we are not supposed to be in RXMGC mode when we do
* this?
*/
manrx));
}
static int
{
if (start)
else
SA2400_OPMODE, opmode));
}
static int
{
int rc;
/*
* calibrate VCO
*/
return (rc);
/*
* XXX superfluous: SA2400 automatically entered SLEEP mode.
*/
return (rtw_sa2400_vcocal_start(sa, 0));
}
static int
{
SA2400_OPMODE, opmode));
}
static int
{
int rc;
dccal);
if (rc != 0)
return (rc);
dccal);
if (rc != 0)
return (rc);
return (0);
}
static int
{
agc));
}
static void
{
}
static int
{
int i, rc;
/*
* XXX reference driver calibrates VCO twice. Is it a bug?
*/
for (i = 0; i < 2; i++) {
return (rc);
}
/*
* VCO calibration erases synthesizer registers, so re-tune
*/
return (rc);
return (rc);
/*
* analog PHY needs DC calibration
*/
return (rtw_sa2400_dc_calibration(sa));
return (0);
}
static int
enum rtw_pwrstate power)
{
int rc;
return (rc);
/*
* skip configuration if it's time to sleep or to power-down.
*/
/*
* go to sleep for configuration
*/
return (rc);
return (rc);
return (rc);
return (rc);
return (rc);
/*
*/
}
struct rtw_rf *
{
return (NULL);
/*
* XXX magic
*/
}
/*
* freq is in MHz
*/
static int
{
return (-1);
}
static void
{
}
/*ARGSUSED*/
static int
enum rtw_pwrstate power)
{
int rc;
MAX2820_TEST_DEFAULT)) != 0)
return (rc);
MAX2820_ENABLE_DEFAULT)) != 0)
return (rc);
/*
* skip configuration if it's time to sleep or to power-down.
*/
return (rc);
return (0);
MAX2820_SYNTH_R_44MHZ)) != 0)
return (rc);
return (rc);
/*
* XXX The MAX2820 datasheet indicates that 1C and 2C should not
* be changed from 7, however, the reference driver sets them
* to 4 and 1, respectively.
*/
return (rc);
}
/*ARGSUSED*/
static int
{
/* TBD */
return (0);
}
static int
{
switch (power) {
case RTW_OFF:
case RTW_SLEEP:
default:
enable = 0x0;
break;
case RTW_ON:
break;
}
MAX2820_ENABLE, enable));
}
struct rtw_rf *
{
return (NULL);
/*
* XXX magic
*/
bb->bb_chestlim = 0;
}
/*
* freq is in MHz
*/
int
enum rtw_pwrstate power)
{
int rc;
/*
* XXX is this really necessary?
*/
return (rc);
freq)) != 0)
return (rc);
return (rc);
/*
* initialize RF
*/
return (rc);
#ifdef _RTW_FUTURE_DEBUG_
/* what is this redundant tx power setting here for? */
return (rc);
#endif /* _RTW_FUTURE_DEBUG */
cs_threshold, freq));
}