Check SoC family (AR5312+ or AR2315+) before call instead of checking it
inside the called function. Also convert ar{5312,2315}_init_device()
function to void, since they both return zero and nobody care about
return value.
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
SVN-Revision: 44713
+obj-$(CONFIG_SOC_AR2315) += ar2315.o
--- /dev/null
+++ b/arch/mips/ath25/board.c
+obj-$(CONFIG_SOC_AR2315) += ar2315.o
--- /dev/null
+++ b/arch/mips/ath25/board.c
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ _machine_halt = ath25_halt;
+ pm_power_off = ath25_halt;
+
+ _machine_halt = ath25_halt;
+ pm_power_off = ath25_halt;
+
-+ ar5312_plat_mem_setup();
-+ ar2315_plat_mem_setup();
++ if (is_ar5312())
++ ar5312_plat_mem_setup();
++ else
++ ar2315_plat_mem_setup();
+
+ /* Disable data watchpoints */
+ write_c0_watchlo0(0);
+
+ /* Disable data watchpoints */
+ write_c0_watchlo0(0);
+
+void __init plat_time_init(void)
+{
+
+void __init plat_time_init(void)
+{
-+ ar5312_plat_time_init();
-+ ar2315_plat_time_init();
++ if (is_ar5312())
++ ar5312_plat_time_init();
++ else
++ ar2315_plat_time_init();
+}
+
+unsigned int __cpuinit get_c0_compare_int(void)
+}
+
+unsigned int __cpuinit get_c0_compare_int(void)
+ mips_cpu_irq_init();
+
+ /* Initialize interrupt controllers */
+ mips_cpu_irq_init();
+
+ /* Initialize interrupt controllers */
-+ ar5312_arch_init_irq();
-+ ar2315_arch_init_irq();
++ if (is_ar5312())
++ ar5312_arch_init_irq();
++ else
++ ar2315_arch_init_irq();
--- /dev/null
+++ b/arch/mips/ath25/prom.c
--- /dev/null
+++ b/arch/mips/ath25/prom.c
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+#include <asm/addrspace.h>
+#include "ar5312.h"
+#include "ar2315.h"
+#include <asm/addrspace.h>
+#include "ar5312.h"
+#include "ar2315.h"
+
+void __init prom_init(void)
+{
+
+void __init prom_init(void)
+{
-+ ar5312_prom_init();
-+ ar2315_prom_init();
++ if (is_ar5312())
++ ar5312_prom_init();
++ else
++ ar2315_prom_init();
+}
+
+void __init prom_free_prom_memory(void)
+}
+
+void __init prom_free_prom_memory(void)
+#endif /* __ASM_MACH_ATH25_AR5312_REGS_H */
--- /dev/null
+++ b/arch/mips/ath25/ar5312.c
+#endif /* __ASM_MACH_ATH25_AR5312_REGS_H */
--- /dev/null
+++ b/arch/mips/ath25/ar5312.c
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
-+ if (!is_ar5312())
-+ return;
-+
+ ath25_irq_dispatch = ar5312_irq_dispatch;
+ for (i = 0; i < AR5312_MISC_IRQ_COUNT; i++) {
+ int irq = AR231X_MISC_IRQ_BASE + i;
+ ath25_irq_dispatch = ar5312_irq_dispatch;
+ for (i = 0; i < AR5312_MISC_IRQ_COUNT; i++) {
+ int irq = AR231X_MISC_IRQ_BASE + i;
+ return (char *)KSEG1ADDR(AR5312_FLASH + 0x800000);
+}
+
+ return (char *)KSEG1ADDR(AR5312_FLASH + 0x800000);
+}
+
-+int __init ar5312_init_devices(void)
++void __init ar5312_init_devices(void)
+{
+ struct ath25_boarddata *config;
+ u32 fctl = 0;
+ u8 *c;
+
+{
+ struct ath25_boarddata *config;
+ u32 fctl = 0;
+ u8 *c;
+
-+ if (!is_ar5312())
-+ return 0;
-+
+ /* Locate board/radio config data */
+ ath25_find_config(ar5312_flash_limit());
+ config = ath25_board.config;
+ /* Locate board/radio config data */
+ ath25_find_config(ar5312_flash_limit());
+ config = ath25_board.config;
+ &ar5312_eth1_data);
+
+ if (!ath25_board.radio)
+ &ar5312_eth1_data);
+
+ if (!ath25_board.radio)
+
+ if (!(config->flags & BD_WLAN0))
+ break;
+
+ if (!(config->flags & BD_WLAN0))
+ break;
+ &ar5312_eth1_data);
+
+ if (!ath25_board.radio)
+ &ar5312_eth1_data);
+
+ if (!ath25_board.radio)
+ break;
+ default:
+ break;
+ break;
+ default:
+ break;
+
+ if (config->flags & BD_WLAN1)
+ ath25_add_wmac(1, AR5312_WLAN1, AR5312_IRQ_WLAN1_INTRS);
+
+ if (config->flags & BD_WLAN1)
+ ath25_add_wmac(1, AR5312_WLAN1, AR5312_IRQ_WLAN1_INTRS);
+}
+
+static void ar5312_restart(char *command)
+}
+
+static void ar5312_restart(char *command)
+
+void __init ar5312_plat_time_init(void)
+{
+
+void __init ar5312_plat_time_init(void)
+{
-+ if (!is_ar5312())
-+ return;
-+
+ mips_hpt_frequency = ar5312_cpu_frequency() / 2;
+}
+
+ mips_hpt_frequency = ar5312_cpu_frequency() / 2;
+}
+
+ u32 memsize, memcfg, bank0AC, bank1AC;
+ u32 devid;
+
+ u32 memsize, memcfg, bank0AC, bank1AC;
+ u32 devid;
+
-+ if (!is_ar5312())
-+ return;
-+
+ /* Detect memory size */
+ memcfg = ar231x_read_reg(AR5312_MEM_CFG1);
+ bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
+ /* Detect memory size */
+ memcfg = ar231x_read_reg(AR5312_MEM_CFG1);
+ bank0AC = (memcfg & MEM_CFG1_AC0) >> MEM_CFG1_AC0_S;
+
+void __init ar5312_plat_mem_setup(void)
+{
+
+void __init ar5312_plat_mem_setup(void)
+{
-+ if (!is_ar5312())
-+ return;
-+
+ /* Clear any lingering AHB errors */
+ ar231x_read_reg(AR5312_PROCADDR);
+ ar231x_read_reg(AR5312_DMAADDR);
+ /* Clear any lingering AHB errors */
+ ar231x_read_reg(AR5312_PROCADDR);
+ ar231x_read_reg(AR5312_DMAADDR);
+
--- /dev/null
+++ b/arch/mips/ath25/ar2315.c
+
--- /dev/null
+++ b/arch/mips/ath25/ar2315.c
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
-+ if (!is_ar2315())
-+ return;
-+
+ ath25_irq_dispatch = ar2315_irq_dispatch;
+ for (i = 0; i < AR2315_MISC_IRQ_COUNT; i++) {
+ int irq = AR231X_MISC_IRQ_BASE + i;
+ ath25_irq_dispatch = ar2315_irq_dispatch;
+ for (i = 0; i < AR2315_MISC_IRQ_COUNT; i++) {
+ int irq = AR231X_MISC_IRQ_BASE + i;
-+int __init ar2315_init_devices(void)
++void __init ar2315_init_devices(void)
-+ if (!is_ar2315())
-+ return 0;
-+
+ /* Find board configuration */
+ ath25_find_config(ar2315_flash_limit());
+ ar2315_eth_data.macaddr = ath25_board.config->enet0_mac;
+ /* Find board configuration */
+ ath25_find_config(ar2315_flash_limit());
+ ar2315_eth_data.macaddr = ath25_board.config->enet0_mac;
+ ath25_add_ethernet(0, AR2315_ENET0, "eth0_mii", AR2315_ENET0_MII,
+ AR2315_IRQ_ENET0_INTRS, &ar2315_eth_data);
+ ath25_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
+ ath25_add_ethernet(0, AR2315_ENET0, "eth0_mii", AR2315_ENET0_MII,
+ AR2315_IRQ_ENET0_INTRS, &ar2315_eth_data);
+ ath25_add_wmac(0, AR2315_WLAN0, AR2315_IRQ_WLAN0_INTRS);
+}
+
+static void ar2315_restart(char *command)
+}
+
+static void ar2315_restart(char *command)
+
+void __init ar2315_plat_time_init(void)
+{
+
+void __init ar2315_plat_time_init(void)
+{
-+ if (!is_ar2315())
-+ return;
-+
+ mips_hpt_frequency = ar2315_cpu_frequency() / 2;
+}
+
+ mips_hpt_frequency = ar2315_cpu_frequency() / 2;
+}
+
+{
+ u32 memsize, memcfg, devid;
+
+{
+ u32 memsize, memcfg, devid;
+
-+ if (!is_ar2315())
-+ return;
-+
+ memcfg = ar231x_read_reg(AR2315_MEM_CFG);
+ memsize = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
+ memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
+ memcfg = ar231x_read_reg(AR2315_MEM_CFG);
+ memsize = 1 + ((memcfg & SDRAM_DATA_WIDTH_M) >> SDRAM_DATA_WIDTH_S);
+ memsize <<= 1 + ((memcfg & SDRAM_COL_WIDTH_M) >> SDRAM_COL_WIDTH_S);
-+ if (!is_ar2315())
-+ return;
-+
+ /* Clear any lingering AHB errors */
+ config = read_c0_config();
+ write_c0_config(config & ~0x3);
+ /* Clear any lingering AHB errors */
+ config = read_c0_config();
+ write_c0_config(config & ~0x3);
+}
--- /dev/null
+++ b/arch/mips/ath25/ar2315.h
+}
--- /dev/null
+++ b/arch/mips/ath25/ar2315.h
+#ifndef __AR2315_H
+#define __AR2315_H
+
+#ifdef CONFIG_SOC_AR2315
+
+void ar2315_arch_init_irq(void);
+#ifndef __AR2315_H
+#define __AR2315_H
+
+#ifdef CONFIG_SOC_AR2315
+
+void ar2315_arch_init_irq(void);
-+int ar2315_init_devices(void);
++void ar2315_init_devices(void);
+void ar2315_plat_time_init(void);
+void ar2315_prom_init(void);
+void ar2315_plat_mem_setup(void);
+void ar2315_plat_time_init(void);
+void ar2315_prom_init(void);
+void ar2315_plat_mem_setup(void);
-+static inline int ar2315_init_devices(void)
++static inline void ar2315_init_devices(void)
+}
+
+static inline void ar2315_plat_time_init(void)
+}
+
+static inline void ar2315_plat_time_init(void)
+#endif
--- /dev/null
+++ b/arch/mips/ath25/ar5312.h
+#endif
--- /dev/null
+++ b/arch/mips/ath25/ar5312.h
+#ifndef __AR5312_H
+#define __AR5312_H
+
+#ifdef CONFIG_SOC_AR5312
+
+void ar5312_arch_init_irq(void);
+#ifndef __AR5312_H
+#define __AR5312_H
+
+#ifdef CONFIG_SOC_AR5312
+
+void ar5312_arch_init_irq(void);
-+int ar5312_init_devices(void);
++void ar5312_init_devices(void);
+void ar5312_plat_time_init(void);
+void ar5312_prom_init(void);
+void ar5312_plat_mem_setup(void);
+void ar5312_plat_time_init(void);
+void ar5312_prom_init(void);
+void ar5312_plat_mem_setup(void);
-+static inline int ar5312_init_devices(void)
++static inline void ar5312_init_devices(void)
+}
+
+static inline void ar5312_plat_time_init(void)
+}
+
+static inline void ar5312_plat_time_init(void)
+#endif
--- /dev/null
+++ b/arch/mips/ath25/devices.c
+#endif
--- /dev/null
+++ b/arch/mips/ath25/devices.c
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/serial.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/serial.h>
+
+static int __init ath25_register_devices(void)
+{
+
+static int __init ath25_register_devices(void)
+{
-+ ar5312_init_devices();
-+ ar2315_init_devices();
++ if (is_ar5312())
++ ar5312_init_devices();
++ else
++ ar2315_init_devices();
config SOC_AR2315
--- a/arch/mips/ath25/ar5312.c
+++ b/arch/mips/ath25/ar5312.c
config SOC_AR2315
--- a/arch/mips/ath25/ar5312.c
+++ b/arch/mips/ath25/ar5312.c
-@@ -187,6 +187,22 @@ static struct platform_device ar5312_phy
+@@ -184,6 +184,22 @@ static struct platform_device ar5312_phy
#ifdef CONFIG_LEDS_GPIO
static struct gpio_led ar5312_leds[] = {
{ .name = "wlan", .gpio = 0, .active_low = 1, },
#ifdef CONFIG_LEDS_GPIO
static struct gpio_led ar5312_leds[] = {
{ .name = "wlan", .gpio = 0, .active_low = 1, },
-@@ -277,6 +293,8 @@ int __init ar5312_init_devices(void)
+@@ -271,6 +287,8 @@ void __init ar5312_init_devices(void)
platform_device_register(&ar5312_physmap_flash);
platform_device_register(&ar5312_physmap_flash);
default y
--- a/arch/mips/ath25/ar2315.c
+++ b/arch/mips/ath25/ar2315.c
default y
--- a/arch/mips/ath25/ar2315.c
+++ b/arch/mips/ath25/ar2315.c
-@@ -207,6 +207,34 @@ static struct platform_device ar2315_wdt
+@@ -204,6 +204,34 @@ static struct platform_device ar2315_wdt
.num_resources = ARRAY_SIZE(ar2315_wdt_res)
};
.num_resources = ARRAY_SIZE(ar2315_wdt_res)
};
/*
* NB: We use mapping size that is larger than the actual flash size,
* but this shouldn't be a problem here, because the flash will simply
/*
* NB: We use mapping size that is larger than the actual flash size,
* but this shouldn't be a problem here, because the flash will simply
-@@ -270,6 +298,7 @@ int __init ar2315_init_devices(void)
+@@ -264,6 +292,7 @@ void __init ar2315_init_devices(void)
ath25_find_config(ar2315_flash_limit());
ar2315_eth_data.macaddr = ath25_board.config->enet0_mac;
ath25_find_config(ar2315_flash_limit());
ar2315_eth_data.macaddr = ath25_board.config->enet0_mac;
else if (pending & CAUSEF_IP2)
do_IRQ(AR2315_IRQ_MISC_INTRS);
else if (pending & CAUSEF_IP7)
else if (pending & CAUSEF_IP2)
do_IRQ(AR2315_IRQ_MISC_INTRS);
else if (pending & CAUSEF_IP7)
-@@ -445,3 +449,18 @@ void __init ar2315_plat_mem_setup(void)
+@@ -428,3 +432,18 @@ void __init ar2315_plat_mem_setup(void)
ath25_serial_setup(AR2315_UART0, AR2315_MISC_IRQ_UART0,
ar2315_apb_frequency());
}
ath25_serial_setup(AR2315_UART0, AR2315_MISC_IRQ_UART0,
ar2315_apb_frequency());
}