2011-01-04 21:28:29 +01:00
/*
2011-11-18 00:17:53 +00:00
* Atheros AR913X / AR933X SoC built - in WMAC device support
2011-01-04 21:28:29 +01:00
*
2011-11-18 00:17:53 +00:00
* Copyright ( C ) 2008 - 2011 Gabor Juhos < juhosg @ openwrt . org >
2011-01-04 21:28:29 +01:00
* Copyright ( C ) 2008 Imre Kaloz < kaloz @ openwrt . org >
*
* This program is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation .
*/
# include <linux/init.h>
# include <linux/delay.h>
# include <linux/irq.h>
# include <linux/platform_device.h>
# include <linux/ath9k_platform.h>
# include <asm/mach-ath79/ath79.h>
# include <asm/mach-ath79/ar71xx_regs.h>
2011-11-18 00:17:54 +00:00
# include "dev-wmac.h"
2011-01-04 21:28:29 +01:00
2011-11-18 00:17:53 +00:00
static struct ath9k_platform_data ath79_wmac_data ;
2011-01-04 21:28:29 +01:00
2011-11-18 00:17:53 +00:00
static struct resource ath79_wmac_resources [ ] = {
2011-01-04 21:28:29 +01:00
{
2011-11-18 00:17:53 +00:00
/* .start and .end fields are filled dynamically */
2011-01-04 21:28:29 +01:00
. flags = IORESOURCE_MEM ,
} , {
. start = ATH79_CPU_IRQ_IP2 ,
. end = ATH79_CPU_IRQ_IP2 ,
. flags = IORESOURCE_IRQ ,
} ,
} ;
2011-11-18 00:17:53 +00:00
static struct platform_device ath79_wmac_device = {
2011-01-04 21:28:29 +01:00
. name = " ath9k " ,
. id = - 1 ,
2011-11-18 00:17:53 +00:00
. resource = ath79_wmac_resources ,
. num_resources = ARRAY_SIZE ( ath79_wmac_resources ) ,
2011-01-04 21:28:29 +01:00
. dev = {
2011-11-18 00:17:53 +00:00
. platform_data = & ath79_wmac_data ,
2011-01-04 21:28:29 +01:00
} ,
} ;
2011-11-18 00:17:53 +00:00
static void __init ar913x_wmac_setup ( void )
2011-01-04 21:28:29 +01:00
{
/* reset the WMAC */
ath79_device_reset_set ( AR913X_RESET_AMBA2WMAC ) ;
mdelay ( 10 ) ;
ath79_device_reset_clear ( AR913X_RESET_AMBA2WMAC ) ;
mdelay ( 10 ) ;
2011-11-18 00:17:53 +00:00
ath79_wmac_resources [ 0 ] . start = AR913X_WMAC_BASE ;
ath79_wmac_resources [ 0 ] . end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1 ;
}
2011-11-18 00:17:53 +00:00
static int ar933x_wmac_reset ( void )
{
ath79_device_reset_set ( AR933X_RESET_WMAC ) ;
2012-03-14 10:28:35 +01:00
ath79_device_reset_clear ( AR933X_RESET_WMAC ) ;
2011-11-18 00:17:53 +00:00
return 0 ;
}
static int ar933x_r1_get_wmac_revision ( void )
{
return ath79_soc_rev ;
}
static void __init ar933x_wmac_setup ( void )
{
u32 t ;
ar933x_wmac_reset ( ) ;
ath79_wmac_device . name = " ar933x_wmac " ;
ath79_wmac_resources [ 0 ] . start = AR933X_WMAC_BASE ;
ath79_wmac_resources [ 0 ] . end = AR933X_WMAC_BASE + AR933X_WMAC_SIZE - 1 ;
t = ath79_reset_rr ( AR933X_RESET_REG_BOOTSTRAP ) ;
if ( t & AR933X_BOOTSTRAP_REF_CLK_40 )
ath79_wmac_data . is_clk_25mhz = false ;
else
ath79_wmac_data . is_clk_25mhz = true ;
if ( ath79_soc_rev = = 1 )
ath79_wmac_data . get_mac_revision = ar933x_r1_get_wmac_revision ;
ath79_wmac_data . external_reset = ar933x_wmac_reset ;
}
2011-11-18 00:17:53 +00:00
void __init ath79_register_wmac ( u8 * cal_data )
{
if ( soc_is_ar913x ( ) )
ar913x_wmac_setup ( ) ;
2011-12-11 16:11:41 +01:00
else if ( soc_is_ar933x ( ) )
2011-11-18 00:17:53 +00:00
ar933x_wmac_setup ( ) ;
2011-11-18 00:17:53 +00:00
else
BUG ( ) ;
if ( cal_data )
memcpy ( ath79_wmac_data . eeprom_data , cal_data ,
sizeof ( ath79_wmac_data . eeprom_data ) ) ;
2011-11-18 00:17:53 +00:00
platform_device_register ( & ath79_wmac_device ) ;
2011-01-04 21:28:29 +01:00
}