From 1654861f6e02e74a2ba059d1f62dc0356429d7cf Mon Sep 17 00:00:00 2001 From: Sergey Ryazanov Date: Wed, 29 Oct 2014 03:18:45 +0400 Subject: MIPS: ath25: add SoC type detection Detect SoC type based on device ID and board configuration data. Signed-off-by: Sergey Ryazanov Cc: Linux MIPS Patchwork: https://patchwork.linux-mips.org/patch/8244/ Signed-off-by: Ralf Baechle --- arch/mips/ath25/ar5312.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'arch/mips/ath25/ar5312.c') diff --git a/arch/mips/ath25/ar5312.c b/arch/mips/ath25/ar5312.c index 41bd56d..26942a2 100644 --- a/arch/mips/ath25/ar5312.c +++ b/arch/mips/ath25/ar5312.c @@ -24,6 +24,8 @@ #include #include +#include + #include "devices.h" #include "ar5312.h" #include "ar5312_regs.h" @@ -191,10 +193,25 @@ static void __init ar5312_flash_init(void) void __init ar5312_init_devices(void) { + struct ath25_boarddata *config; + ar5312_flash_init(); /* Locate board/radio config data */ ath25_find_config(AR5312_FLASH_BASE, AR5312_FLASH_SIZE); + config = ath25_board.config; + + /* AR2313 has CPU minor rev. 10 */ + if ((current_cpu_data.processor_id & 0xff) == 0x0a) + ath25_soc = ATH25_SOC_AR2313; + + /* AR2312 shares the same Silicon ID as AR5312 */ + else if (config->flags & BD_ISCASPER) + ath25_soc = ATH25_SOC_AR2312; + + /* Everything else is probably AR5312 or compatible */ + else + ath25_soc = ATH25_SOC_AR5312; } static void ar5312_restart(char *command) @@ -282,6 +299,7 @@ void __init ar5312_plat_mem_setup(void) { void __iomem *sdram_base; u32 memsize, memcfg, bank0_ac, bank1_ac; + u32 devid; /* Detect memory size */ sdram_base = ioremap_nocache(AR5312_SDRAMCTL_BASE, @@ -297,6 +315,11 @@ void __init ar5312_plat_mem_setup(void) ar5312_rst_base = ioremap_nocache(AR5312_RST_BASE, AR5312_RST_SIZE); + devid = ar5312_rst_reg_read(AR5312_REV); + devid >>= AR5312_REV_WMAC_MIN_S; + devid &= AR5312_REV_CHIP; + ath25_board.devid = (u16)devid; + /* Clear any lingering AHB errors */ ar5312_rst_reg_read(AR5312_PROCADDR); ar5312_rst_reg_read(AR5312_DMAADDR); -- cgit v1.1