MIPS: support for the Atheros AR231X SoCs
Subsystems (5)
cover MIPS: support for the Atheros AR231X SoCs
This patch set contains initial support for the following Atheros SoCs: AR5312, AR2312, AR2313, AR2315, AR2316, AR2317, AR2318.
- Patches 1 through 15 add support for different parts of AR231x SoCs.
- Patch 12 provided only for reference, since it should be rewritten to use spi-nor framework.
- Patch 16 do a tiny cleanup in the ath5k driver.
- Patch 17 updates ath5k dependecy, since I rename the original ATHEROS_AR231X config symbol to AR231X.
- Patch 18 removes !PCI dependency from ath5k AHB support, since AR2315 has a builtin PCI controller.
The original code was based on 3.14.18 kernel and successfully tested with AR2313, AR2315, AR2316, AR2317 SoCs. After rebasing the code was build tested only.
This code has been written by OpenWRT developers and it resided in OpenWRT's tree for a long time. My work was to cleanup the code and its rebase on the latest linux-mips tree (3.17-rc2).
Sergey Ryazanov (18):
MIPS: ar231x: add common parts
MIPS: ar231x: add basic AR5312 SoC support
MIPS: ar231x: add basic AR2315 SoC support
MIPS: ar231x: add interrupts handling routines
MIPS: ar231x: add early printk support
MIPS: ar231x: add UART support
MIPS: ar231x: add board configuration detection
gpio: add driver for Atheros AR5312 SoC GPIO controller
gpio: add driver for Atheros AR5312 SoC GPIO controller
MIPS: ar231x: add SoC type detection
MIPS: ar231x: add AR5312 flash support
mtd: add Atheros AR2315 SPI Flash driver
watchdog: add Atheros AR2315 watchdog driver
MIPS: ar231x: add AR2315 PCI host controller driver
MIPS: ar231x: add Wireless device support
ath5k: correct conditional compilation
ath5k: update dependency
ath5k: correct dependency
arch/mips/Kbuild.platforms | 1 + arch/mips/Kconfig | 15 + arch/mips/ar231x/Kconfig | 18 + arch/mips/ar231x/Makefile | 16 + arch/mips/ar231x/Platform | 6 + arch/mips/ar231x/ar2315.c | 378 ++++++++++++++ arch/mips/ar231x/ar2315.h | 22 + arch/mips/ar231x/ar5312.c | 374 +++++++++++++ arch/mips/ar231x/ar5312.h | 22 + arch/mips/ar231x/board.c | 222 ++++++++ arch/mips/ar231x/devices.c | 111 ++++ arch/mips/ar231x/devices.h | 39 ++ arch/mips/ar231x/early_printk.c | 45 ++ arch/mips/ar231x/prom.c | 31 ++ arch/mips/include/asm/mach-ar231x/ar2315_regs.h | 581 +++++++++++++++++++++ arch/mips/include/asm/mach-ar231x/ar231x.h | 34 ++ .../mips/include/asm/mach-ar231x/ar231x_platform.h | 73 +++ arch/mips/include/asm/mach-ar231x/ar5312_regs.h | 215 ++++++++ .../asm/mach-ar231x/cpu-feature-overrides.h | 84 +++ arch/mips/include/asm/mach-ar231x/dma-coherence.h | 76 +++ arch/mips/include/asm/mach-ar231x/gpio.h | 16 + arch/mips/include/asm/mach-ar231x/war.h | 25 + arch/mips/pci/Makefile | 1 + arch/mips/pci/pci-ar2315.c | 345 ++++++++++++ drivers/gpio/Kconfig | 14 + drivers/gpio/Makefile | 2 + drivers/gpio/gpio-ar2315.c | 233 +++++++++ drivers/gpio/gpio-ar5312.c | 121 +++++ drivers/mtd/devices/Kconfig | 5 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/ar2315.c | 459 ++++++++++++++++ drivers/mtd/devices/ar2315_spiflash.h | 106 ++++ drivers/net/wireless/ath/ath5k/Kconfig | 10 +- drivers/net/wireless/ath/ath5k/ath5k.h | 2 +- drivers/net/wireless/ath/ath5k/base.c | 4 +- drivers/net/wireless/ath/ath5k/led.c | 4 +- drivers/watchdog/Kconfig | 7 + drivers/watchdog/Makefile | 1 + drivers/watchdog/ar2315-wtd.c | 202 +++++++ 39 files changed, 3911 insertions(+), 10 deletions(-) create mode 100644 arch/mips/ar231x/Kconfig create mode 100644 arch/mips/ar231x/Makefile create mode 100644 arch/mips/ar231x/Platform create mode 100644 arch/mips/ar231x/ar2315.c create mode 100644 arch/mips/ar231x/ar2315.h create mode 100644 arch/mips/ar231x/ar5312.c create mode 100644 arch/mips/ar231x/ar5312.h create mode 100644 arch/mips/ar231x/board.c create mode 100644 arch/mips/ar231x/devices.c create mode 100644 arch/mips/ar231x/devices.h create mode 100644 arch/mips/ar231x/early_printk.c create mode 100644 arch/mips/ar231x/prom.c create mode 100644 arch/mips/include/asm/mach-ar231x/ar2315_regs.h create mode 100644 arch/mips/include/asm/mach-ar231x/ar231x.h create mode 100644 arch/mips/include/asm/mach-ar231x/ar231x_platform.h create mode 100644 arch/mips/include/asm/mach-ar231x/ar5312_regs.h create mode 100644 arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h create mode 100644 arch/mips/include/asm/mach-ar231x/dma-coherence.h create mode 100644 arch/mips/include/asm/mach-ar231x/gpio.h create mode 100644 arch/mips/include/asm/mach-ar231x/war.h create mode 100644 arch/mips/pci/pci-ar2315.c create mode 100644 drivers/gpio/gpio-ar2315.c create mode 100644 drivers/gpio/gpio-ar5312.c create mode 100644 drivers/mtd/devices/ar2315.c create mode 100644 drivers/mtd/devices/ar2315_spiflash.h create mode 100644 drivers/watchdog/ar2315-wtd.c
Signature · 1 line
1.8.1.5
RFC 1/18 MIPS: ar231x: add common parts
Add common code for Atheros AR5312 and Atheros AR2315 SoCs families.
--- arch/mips/Kbuild.platforms | 1 + arch/mips/Kconfig | 13 ++++ arch/mips/ar231x/Makefile | 11 ++++ arch/mips/ar231x/Platform | 6 ++ arch/mips/ar231x/board.c | 53 +++++++++++++++ arch/mips/ar231x/devices.c | 20 ++++++ arch/mips/ar231x/devices.h | 22 +++++++ arch/mips/ar231x/prom.c | 26 ++++++++ arch/mips/include/asm/mach-ar231x/ar231x.h | 29 +++++++++ .../asm/mach-ar231x/cpu-feature-overrides.h | 76 ++++++++++++++++++++++ arch/mips/include/asm/mach-ar231x/dma-coherence.h | 64 ++++++++++++++++++ arch/mips/include/asm/mach-ar231x/gpio.h | 16 +++++ arch/mips/include/asm/mach-ar231x/war.h | 25 +++++++ 13 files changed, 362 insertions(+) create mode 100644 arch/mips/ar231x/Makefile create mode 100644 arch/mips/ar231x/Platform create mode 100644 arch/mips/ar231x/board.c create mode 100644 arch/mips/ar231x/devices.c create mode 100644 arch/mips/ar231x/devices.h create mode 100644 arch/mips/ar231x/prom.c create mode 100644 arch/mips/include/asm/mach-ar231x/ar231x.h create mode 100644 arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h create mode 100644 arch/mips/include/asm/mach-ar231x/dma-coherence.h create mode 100644 arch/mips/include/asm/mach-ar231x/gpio.h create mode 100644 arch/mips/include/asm/mach-ar231x/war.h
arch/mips/Kbuild.platforms +1 -0
@@ -1,6 +1,7 @@ # All platforms listed in alphabetic order platforms += alchemy +platforms += ar231x platforms += ar7 platforms += ath79 platforms += bcm47xx
arch/mips/Kconfig +13 -0
@@ -73,6 +73,19 @@ config MIPS_ALCHEMY select SYS_SUPPORTS_ZBOOT select COMMON_CLK +config AR231X + bool "Atheros AR231x/AR531x SoC support" + select CEVT_R4K + select CSRC_R4K + select DMA_NONCOHERENT + select IRQ_CPU + select SYS_HAS_CPU_MIPS32_R1 + select SYS_SUPPORTS_BIG_ENDIAN + select SYS_SUPPORTS_32BIT_KERNEL + select ARCH_REQUIRE_GPIOLIB + help + Support for Atheros AR231x and Atheros AR531x based boards + config AR7 bool "Texas Instruments AR7" select BOOT_ELF32
arch/mips/ar231x/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# +# 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 +# for more details. +# +# Copyright (C) 2006 FON Technology, SL. +# Copyright (C) 2006 Imre Kaloz <[email protected]> +# Copyright (C) 2006-2009 Felix Fietkau <[email protected]> +# + +obj-y += board.o prom.o devices.o
arch/mips/ar231x/Platform new file +6 -0
@@ -0,0 +1,6 @@ +# +# Atheros AR531X/AR231X WiSoC +# +platform-$(CONFIG_AR231X) += ar231x/ +cflags-$(CONFIG_AR231X) += -I$(srctree)/arch/mips/include/asm/mach-ar231x +load-$(CONFIG_AR231X) += 0xffffffff80041000
arch/mips/ar231x/board.c new file +53 -0
53 lines not on this page · raw message
arch/mips/ar231x/devices.c new file +20 -0
@@ -0,0 +1,20 @@ +#include <linux/kernel.h> +#include <linux/init.h> +#include <asm/bootinfo.h> + +#include "devices.h" + +int ar231x_devtype =DEV_TYPE_UNKNOWN ; + +static const char *const devtype_strings[] = { + [DEV_TYPE_UNKNOWN ] ="Atheros (unknown)" , +}; + +const char *get_system_type (void ) +{ +if ((ar231x_devtype >=ARRAY_SIZE (devtype_strings)) || + !devtype_strings[ar231x_devtype]) +return devtype_strings[DEV_TYPE_UNKNOWN ]; +return devtype_strings[ar231x_devtype]; +} +
arch/mips/ar231x/devices.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef __AR231X_DEVICES_H +#define __AR231X_DEVICES_H + +#include <linux/cpu.h> + +enum { +DEV_TYPE_UNKNOWN +}; + +extern int ar231x_devtype; + +static inline bool is_2315 (void ) +{ +return (current_cpu_data.cputype ==CPU_4KEC ); +} + +static inline bool is_5312 (void ) +{ +return !is_2315 (); +} + +#endif
arch/mips/ar231x/prom.c new file +26 -0
@@ -0,0 +1,26 @@ +/* +* 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 +* for more details. +* +* Copyright MontaVista Software Inc +* Copyright (C) 2003 Atheros Communications, Inc., All Rights Reserved. +* Copyright (C) 2006 FON Technology, SL. +* Copyright (C) 2006 Imre Kaloz <[email protected]> +* Copyright (C) 2006 Felix Fietkau <[email protected]> +*/ + +/* +* Prom setup file for ar231x +*/ + +#include <linux/init.h> +#include <asm/bootinfo.h> + +void __init prom_init (void ) +{ +} + +void __init prom_free_prom_memory (void ) +{ +}
arch/mips/include/asm/mach-ar231x/ar231x.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef __ASM_MACH_AR231X_H +#define __ASM_MACH_AR231X_H + +#include <linux/io.h> + +#define AR231X_REG_MS (_val, _field) (((_val) & _field##_M) >> _field##_S) + +static inline u32 ar231x_read_reg (u32 reg) +{ +return __raw_readl ((void __iomem *)KSEG1ADDR (reg)); +} + +static inline void ar231x_write_reg (u32 reg,u32 val) +{ +__raw_writel (val, (void __iomem *)KSEG1ADDR (reg)); +} + +static inline u32 ar231x_mask_reg (u32 reg,u32 mask,u32 val) +{ +u32 ret =ar231x_read_reg (reg); + + ret &= ~mask; + ret |= val; +ar231x_write_reg (reg, ret); + +return ret; +} + +#endif /* __ASM_MACH_AR231X_H */
arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h new file +76 -0
76 lines not on this page · raw message
arch/mips/include/asm/mach-ar231x/dma-coherence.h new file +64 -0
64 lines not on this page · raw message
arch/mips/include/asm/mach-ar231x/gpio.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef __ASM_MACH_AR231X_GPIO_H +#define __ASM_MACH_AR231X_GPIO_H + +#include <asm-generic/gpio.h> + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq __gpio_to_irq + +static inline int irq_to_gpio (unsigned irq) +{ +return -EINVAL ; +} + +#endif /* __ASM_MACH_AR231X_GPIO_H */
arch/mips/include/asm/mach-ar231x/war.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* 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 +* for more details. +* +* Copyright (C) 2008 Felix Fietkau <[email protected]> +*/ +#ifndef __ASM_MACH_AR231X_WAR_H +#define __ASM_MACH_AR231X_WAR_H + +#define R4600_V1_INDEX_ICACHEOP_WAR 0 +#define R4600_V1_HIT_CACHEOP_WAR 0 +#define R4600_V2_HIT_CACHEOP_WAR 0 +#define R5432_CP0_INTERRUPT_WAR 0 +#define BCM1250_M3_WAR 0 +#define SIBYTE_1956_WAR 0 +#define MIPS4K_ICACHE_REFILL_WAR 0 +#define MIPS_CACHE_SYNC_WAR 0 +#define TX49XX_ICACHE_INDEX_INV_WAR 0 +#define RM9000_CDEX_SMP_WAR 0 +#define ICACHE_REFILLS_WORKAROUND_WAR 0 +#define R10000_LLSC_WAR 0 +#define MIPS34K_MISSED_ITLB_WAR 0 + +#endif /* __ASM_MACH_AR231X_WAR_H */
Signature · 1 line
1.8.1.5
RFC 2/18 MIPS: ar231x: add basic AR5312 SoC support
In reply to Sergey RyazanovAdd basic support for Atheros AR5312/AR2312 SoCs: registers definition file and initial setup code.
--- arch/mips/Kconfig | 1 + arch/mips/ar231x/Kconfig | 4 + arch/mips/ar231x/Makefile | 2 + arch/mips/ar231x/ar5312.c | 143 ++++++++++++++++++ arch/mips/ar231x/ar5312.h | 18 +++ arch/mips/ar231x/board.c | 5 + arch/mips/ar231x/prom.c | 3 + arch/mips/include/asm/mach-ar231x/ar5312_regs.h | 190 ++++++++++++++++++++++++ 8 files changed, 366 insertions(+) create mode 100644 arch/mips/ar231x/Kconfig create mode 100644 arch/mips/ar231x/ar5312.c create mode 100644 arch/mips/ar231x/ar5312.h create mode 100644 arch/mips/include/asm/mach-ar231x/ar5312_regs.h
arch/mips/Kconfig +1 -0
@@ -845,6 +845,7 @@ config MIPS_PARAVIRT endchoice source "arch/mips/alchemy/Kconfig" +source "arch/mips/ar231x/Kconfig" source "arch/mips/ath79/Kconfig" source "arch/mips/bcm47xx/Kconfig" source "arch/mips/bcm63xx/Kconfig"
arch/mips/ar231x/Kconfig new file +4 -0
@@ -0,0 +1,4 @@ +config SOC_AR5312 + bool "Atheros AR5312/AR2312+ SoC support" + depends on AR231X + default y
arch/mips/ar231x/Makefile +2 -0
@@ -9,3 +9,5 @@ # obj-y += board.o prom.o devices.o + +obj-$(CONFIG_SOC_AR5312) += ar5312.o
arch/mips/ar231x/ar5312.c new file +143 -0
143 lines not on this page · raw message
arch/mips/ar231x/ar5312.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __AR5312_H +#define __AR5312_H + +#ifdef CONFIG_SOC_AR5312 + +void ar5312_plat_time_init (void ); +void ar5312_plat_mem_setup (void ); +void ar5312_prom_init (void ); + +#else + +static inline void ar5312_plat_time_init (void ) {} +static inline void ar5312_plat_mem_setup (void ) {} +static inline void ar5312_prom_init (void ) {} + +#endif + +#endif /* __AR5312_H */
arch/mips/ar231x/board.c +5 -0
@@ -16,6 +16,8 @@#include <asm/bootinfo.h> #include <asm/time.h> +#include "ar5312.h" +static void ar231x_halt (void ) {local_irq_disable ();
@@ -28,6 +30,8 @@ void __init plat_mem_setup(void) _machine_halt = ar231x_halt; pm_power_off = ar231x_halt; +ar5312_plat_mem_setup (); +/* Disable data watchpoints */ write_c0_watchlo0 (0 ); }
@@ -38,6 +42,7 @@ asmlinkage void plat_irq_dispatch(void)void __init plat_time_init (void ) { +ar5312_plat_time_init (); }unsigned int __cpuinit get_c0_compare_int (void )
arch/mips/ar231x/prom.c +3 -0
@@ -17,8 +17,11 @@#include <linux/init.h> #include <asm/bootinfo.h> +#include "ar5312.h" +void __init prom_init (void ) { +ar5312_prom_init (); }void __init prom_free_prom_memory (void )
arch/mips/include/asm/mach-ar231x/ar5312_regs.h new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
1.8.1.5
RFC 3/18 MIPS: ar231x: add basic AR2315 SoC support
In reply to Sergey RyazanovAdd basic support for Atheros AR2315+ SoCs: registers definition file and initial setup code.
--- arch/mips/ar231x/Kconfig | 5 + arch/mips/ar231x/Makefile | 1 + arch/mips/ar231x/ar2315.c | 136 ++++++ arch/mips/ar231x/ar2315.h | 18 + arch/mips/ar231x/board.c | 3 + arch/mips/ar231x/prom.c | 2 + arch/mips/include/asm/mach-ar231x/ar2315_regs.h | 529 +++++++++++++++++++++ .../asm/mach-ar231x/cpu-feature-overrides.h | 10 +- 8 files changed, 703 insertions(+), 1 deletion(-) create mode 100644 arch/mips/ar231x/ar2315.c create mode 100644 arch/mips/ar231x/ar2315.h create mode 100644 arch/mips/include/asm/mach-ar231x/ar2315_regs.h
arch/mips/ar231x/Kconfig +5 -0
@@ -2,3 +2,8 @@ config SOC_AR5312 bool "Atheros AR5312/AR2312+ SoC support" depends on AR231X default y + +config SOC_AR2315 + bool "Atheros AR2315+ SoC support" + depends on AR231X + default y
arch/mips/ar231x/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-y += board.o prom.o devices.o obj-$(CONFIG_SOC_AR5312) += ar5312.o +obj-$(CONFIG_SOC_AR2315) += ar2315.o
arch/mips/ar231x/ar2315.c new file +136 -0
136 lines not on this page · raw message
arch/mips/ar231x/ar2315.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __AR2315_H +#define __AR2315_H + +#ifdef CONFIG_SOC_AR2315 + +void ar2315_plat_time_init (void ); +void ar2315_plat_mem_setup (void ); +void ar2315_prom_init (void ); + +#else + +static inline void ar2315_plat_time_init (void ) {} +static inline void ar2315_plat_mem_setup (void ) {} +static inline void ar2315_prom_init (void ) {} + +#endif + +#endif /* __AR2315_H */
arch/mips/ar231x/board.c +3 -0
@@ -17,6 +17,7 @@#include <asm/time.h> #include "ar5312.h" +#include "ar2315.h" static void ar231x_halt (void ) {
@@ -31,6 +32,7 @@ void __init plat_mem_setup(void) pm_power_off = ar231x_halt;ar5312_plat_mem_setup (); +ar2315_plat_mem_setup ();/* Disable data watchpoints */ write_c0_watchlo0 (0 );
@@ -43,6 +45,7 @@ asmlinkage void plat_irq_dispatch(void)void __init plat_time_init (void ) {ar5312_plat_time_init (); +ar2315_plat_time_init (); }unsigned int __cpuinit get_c0_compare_int (void )
arch/mips/ar231x/prom.c +2 -0
@@ -18,10 +18,12 @@#include <asm/bootinfo.h> #include "ar5312.h" +#include "ar2315.h" void __init prom_init (void ) {ar5312_prom_init (); +ar2315_prom_init (); }void __init prom_free_prom_memory (void )
arch/mips/include/asm/mach-ar231x/ar2315_regs.h new file +529 -0
529 lines not on this page · raw message
arch/mips/include/asm/mach-ar231x/cpu-feature-overrides.h +9 -1
@@ -36,11 +36,15 @@/* #define cpu_has_mcheck ? */ #define cpu_has_ejtag 1 +#if !defined(CONFIG_SOC_AR5312 ) +# define cpu_has_llsc 1 +#else /* * The MIPS 4Kc V0.9 core in the AR5312/AR2312 have problems with the * ll/sc instructions. */ -#define cpu_has_llsc 0 +# define cpu_has_llsc 0 +#endif #define cpu_has_mips16 0#define cpu_has_mdmx 0
@@ -56,6 +60,10 @@#define cpu_has_mips32r1 1 +#if !defined(CONFIG_SOC_AR5312 ) +# define cpu_has_mips32r2 1 +#endif +#define cpu_has_mips64r1 0#define cpu_has_mips64r2 0
Signature · 1 line
1.8.1.5
RFC 4/18 MIPS: ar231x: add interrupts handling routines
In reply to Sergey RyazanovAdd interrupts initialization and handling routines, also add AHB bus error interrupt handlers for both SoCs families.
--- arch/mips/ar231x/ar2315.c | 90 +++++++++++++++++++++++++ arch/mips/ar231x/ar2315.h | 2 + arch/mips/ar231x/ar5312.c | 89 ++++++++++++++++++++++++ arch/mips/ar231x/ar5312.h | 2 + arch/mips/ar231x/board.c | 8 +++ arch/mips/ar231x/devices.h | 1 + arch/mips/include/asm/mach-ar231x/ar2315_regs.h | 23 +++++++ arch/mips/include/asm/mach-ar231x/ar231x.h | 4 ++ arch/mips/include/asm/mach-ar231x/ar5312_regs.h | 23 +++++++ 9 files changed, 242 insertions(+)
arch/mips/ar231x/ar2315.c +90 -0
@@ -27,6 +27,96 @@#include "devices.h" #include "ar2315.h" +static irqreturn_t ar2315_ahb_err_handler (int cpl,void *dev_id) +{ +ar231x_write_reg (AR2315_AHB_ERR0 ,AR2315_AHB_ERROR_DET ); +ar231x_read_reg (AR2315_AHB_ERR1 ); + +pr_emerg ("AHB fatal error\n" ); +machine_restart ("AHB error" );/* Catastrophic failure */ + +return IRQ_HANDLED ; +} + +static struct irqaction ar2315_ahb_err_interrupt = { + .handler = ar2315_ahb_err_handler, + .name ="ar2315-ahb-error" , +}; + +static void ar2315_misc_irq_handler (unsigned irq,struct irq_desc *desc) +{ +u32 pending =ar231x_read_reg (AR2315_ISR ) &ar231x_read_reg (AR2315_IMR ); + +if (pending &AR2315_ISR_SPI ) +generic_handle_irq (AR2315_MISC_IRQ_SPI ); +else if (pending &AR2315_ISR_TIMER ) +generic_handle_irq (AR2315_MISC_IRQ_TIMER ); +else if (pending &AR2315_ISR_AHB ) +generic_handle_irq (AR2315_MISC_IRQ_AHB ); +else +spurious_interrupt (); +} + +static void ar2315_misc_irq_unmask (struct irq_data *d) +{ +u32 imr =ar231x_read_reg (AR2315_IMR ); + + imr |=1 << (d->irq -AR231X_MISC_IRQ_BASE ); +ar231x_write_reg (AR2315_IMR , imr); +} + +static void ar2315_misc_irq_mask (struct irq_data *d) +{ +u32 imr =ar231x_read_reg (AR2315_IMR ); + + imr &= ~(1 << (d->irq -AR231X_MISC_IRQ_BASE )); +ar231x_write_reg (AR2315_IMR , imr); +} + +static struct irq_chip ar2315_misc_irq_chip = { + .name ="ar2315-misc" , + .irq_unmask = ar2315_misc_irq_unmask, + .irq_mask = ar2315_misc_irq_mask, +}; + +/* +* Called when an interrupt is received, this function +* determines exactly which interrupt it was, and it +* invokes the appropriate handler. +* +* Implicitly, we also define interrupt priority by +* choosing which to dispatch first. +*/ +static void ar2315_irq_dispatch (void ) +{ +u32 pending =read_c0_status () &read_c0_cause (); + +if (pending &CAUSEF_IP2 ) +do_IRQ (AR2315_IRQ_MISC ); +else if (pending &CAUSEF_IP7 ) +do_IRQ (AR231X_IRQ_CPU_CLOCK ); +else +spurious_interrupt (); +} + +void __init ar2315_arch_init_irq (void ) +{ +unsigned i; + +if (!is_2315 ()) +return ; + + ar231x_irq_dispatch = ar2315_irq_dispatch; +for (i =0 ; i <AR2315_MISC_IRQ_COUNT ; i++) { +unsigned irq =AR231X_MISC_IRQ_BASE + i; + +irq_set_chip_and_handler (irq, &ar2315_misc_irq_chip, + handle_level_irq); + } +setup_irq (AR2315_MISC_IRQ_AHB , &ar2315_ahb_err_interrupt); +irq_set_chained_handler (AR2315_IRQ_MISC , ar2315_misc_irq_handler); +} +static void ar2315_restart (char *command) {void (*mips_reset_vec)(void ) = (void *)0xbfc00000 ;
arch/mips/ar231x/ar2315.h +2 -0
@@ -3,12 +3,14 @@#ifdef CONFIG_SOC_AR2315 +void ar2315_arch_init_irq (void );void ar2315_plat_time_init (void );void ar2315_plat_mem_setup (void );void ar2315_prom_init (void );#else +static inline void ar2315_arch_init_irq (void ) {}static inline void ar2315_plat_time_init (void ) {}static inline void ar2315_plat_mem_setup (void ) {}static inline void ar2315_prom_init (void ) {}
arch/mips/ar231x/ar5312.c +89 -0
95 lines not on this page · raw message
arch/mips/ar231x/ar5312.h +2 -0
@@ -3,12 +3,14 @@#ifdef CONFIG_SOC_AR5312 +void ar5312_arch_init_irq (void );void ar5312_plat_time_init (void );void ar5312_plat_mem_setup (void );void ar5312_prom_init (void );#else +static inline void ar5312_arch_init_irq (void ) {}static inline void ar5312_plat_time_init (void ) {}static inline void ar5312_plat_mem_setup (void ) {}static inline void ar5312_prom_init (void ) {}
arch/mips/ar231x/board.c +8 -0
@@ -16,9 +16,12 @@#include <asm/bootinfo.h> #include <asm/time.h> +#include "devices.h" #include "ar5312.h" #include "ar2315.h" +void (*ar231x_irq_dispatch)(void ); +static void ar231x_halt (void ) {local_irq_disable ();
@@ -40,6 +43,7 @@ void __init plat_mem_setup(void) asmlinkage void plat_irq_dispatch(void) { +ar231x_irq_dispatch (); }void __init plat_time_init (void )
@@ -57,5 +61,9 @@ void __init arch_init_irq(void) {clear_c0_status (ST0_IM );mips_cpu_irq_init (); + +/* Initialize interrupt controllers */ +ar5312_arch_init_irq (); +ar2315_arch_init_irq (); }
arch/mips/ar231x/devices.h +1 -0
@@ -8,6 +8,7 @@ enum { };extern int ar231x_devtype; +extern void (*ar231x_irq_dispatch)(void );static inline bool is_2315 (void ) {
arch/mips/include/asm/mach-ar231x/ar2315_regs.h +23 -0
@@ -15,6 +15,29 @@#define __ASM_MACH_AR231X_AR2315_REGS_H/* +* IRQs +*/ +#define AR2315_IRQ_MISC (MIPS_CPU_IRQ_BASE + 2)/* C0_CAUSE: 0x0400 */ +#define AR2315_IRQ_WLAN0 (MIPS_CPU_IRQ_BASE + 3)/* C0_CAUSE: 0x0800 */ +#define AR2315_IRQ_ENET0 (MIPS_CPU_IRQ_BASE + 4)/* C0_CAUSE: 0x1000 */ +#define AR2315_IRQ_LCBUS_PCI (MIPS_CPU_IRQ_BASE + 5)/* C0_CAUSE: 0x2000 */ +#define AR2315_IRQ_WLAN0_POLL (MIPS_CPU_IRQ_BASE + 6)/* C0_CAUSE: 0x4000 */ + +/* +* Miscellaneous interrupts, which share IP2. +*/ +#define AR2315_MISC_IRQ_UART0 (AR231X_MISC_IRQ_BASE+0) +#define AR2315_MISC_IRQ_I2C_RSVD (AR231X_MISC_IRQ_BASE+1) +#define AR2315_MISC_IRQ_SPI (AR231X_MISC_IRQ_BASE+2) +#define AR2315_MISC_IRQ_AHB (AR231X_MISC_IRQ_BASE+3) +#define AR2315_MISC_IRQ_APB (AR231X_MISC_IRQ_BASE+4) +#define AR2315_MISC_IRQ_TIMER (AR231X_MISC_IRQ_BASE+5) +#define AR2315_MISC_IRQ_GPIO (AR231X_MISC_IRQ_BASE+6) +#define AR2315_MISC_IRQ_WATCHDOG (AR231X_MISC_IRQ_BASE+7) +#define AR2315_MISC_IRQ_IR_RSVD (AR231X_MISC_IRQ_BASE+8) +#define AR2315_MISC_IRQ_COUNT 9 + +/* * Address map */ #define AR2315_SPI_READ 0x08000000/* SPI flash */
arch/mips/include/asm/mach-ar231x/ar231x.h +4 -0
@@ -3,6 +3,10 @@#include <linux/io.h> +#define AR231X_MISC_IRQ_BASE 0x20 + +#define AR231X_IRQ_CPU_CLOCK (MIPS_CPU_IRQ_BASE + 7)/* C0_CAUSE: 0x8000 */ +#define AR231X_REG_MS (_val, _field) (((_val) & _field##_M) >> _field##_S)static inline u32 ar231x_read_reg (u32 reg)
arch/mips/include/asm/mach-ar231x/ar5312_regs.h +23 -0
@@ -12,6 +12,29 @@#define __ASM_MACH_AR231X_AR5312_REGS_H/* +* IRQs +*/ +#define AR5312_IRQ_WLAN0 (MIPS_CPU_IRQ_BASE + 2)/* C0_CAUSE: 0x0400 */ +#define AR5312_IRQ_ENET0 (MIPS_CPU_IRQ_BASE + 3)/* C0_CAUSE: 0x0800 */ +#define AR5312_IRQ_ENET1 (MIPS_CPU_IRQ_BASE + 4)/* C0_CAUSE: 0x1000 */ +#define AR5312_IRQ_WLAN1 (MIPS_CPU_IRQ_BASE + 5)/* C0_CAUSE: 0x2000 */ +#define AR5312_IRQ_MISC (MIPS_CPU_IRQ_BASE + 6)/* C0_CAUSE: 0x4000 */ + +/* +* Miscellaneous interrupts, which share IP6. +*/ +#define AR5312_MISC_IRQ_TIMER (AR231X_MISC_IRQ_BASE+0) +#define AR5312_MISC_IRQ_AHB_PROC (AR231X_MISC_IRQ_BASE+1) +#define AR5312_MISC_IRQ_AHB_DMA (AR231X_MISC_IRQ_BASE+2) +#define AR5312_MISC_IRQ_GPIO (AR231X_MISC_IRQ_BASE+3) +#define AR5312_MISC_IRQ_UART0 (AR231X_MISC_IRQ_BASE+4) +#define AR5312_MISC_IRQ_UART0_DMA (AR231X_MISC_IRQ_BASE+5) +#define AR5312_MISC_IRQ_WATCHDOG (AR231X_MISC_IRQ_BASE+6) +#define AR5312_MISC_IRQ_LOCAL (AR231X_MISC_IRQ_BASE+7) +#define AR5312_MISC_IRQ_SPI (AR231X_MISC_IRQ_BASE+8) +#define AR5312_MISC_IRQ_COUNT 9 + +/* * Address Map * * The AR5312 supports 2 enet MACS, even though many reference boards only
Signature · 1 line
1.8.1.5
RFC 5/18 MIPS: ar231x: add early printk support
In reply to Sergey Ryazanov--- arch/mips/Kconfig | 1 + arch/mips/ar231x/Makefile | 2 ++ arch/mips/ar231x/early_printk.c | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 arch/mips/ar231x/early_printk.c
arch/mips/Kconfig +1 -0
@@ -83,6 +83,7 @@ config AR231X select SYS_SUPPORTS_BIG_ENDIAN select SYS_SUPPORTS_32BIT_KERNEL select ARCH_REQUIRE_GPIOLIB + select SYS_HAS_EARLY_PRINTK help Support for Atheros AR231x and Atheros AR531x based boards
arch/mips/ar231x/Makefile +2 -0
@@ -10,5 +10,7 @@ obj-y += board.o prom.o devices.o +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o + obj-$(CONFIG_SOC_AR5312) += ar5312.o obj-$(CONFIG_SOC_AR2315) += ar2315.o
arch/mips/ar231x/early_printk.c new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
1.8.1.5
RFC 6/18 MIPS: ar231x: add UART support
In reply to Sergey Ryazanov--- arch/mips/ar231x/ar2315.c | 4 ++++ arch/mips/ar231x/ar5312.c | 4 ++++ arch/mips/ar231x/devices.c | 17 +++++++++++++++++ arch/mips/ar231x/devices.h | 2 ++ 4 files changed, 27 insertions(+)
arch/mips/ar231x/ar2315.c +4 -0
@@ -53,6 +53,8 @@ static void ar2315_misc_irq_handler(unsigned irq, struct irq_desc *desc)generic_handle_irq (AR2315_MISC_IRQ_TIMER ); else if (pending & AR2315_ISR_AHB) generic_handle_irq(AR2315_MISC_IRQ_AHB); + else if (pending & AR2315_ISR_UART0) + generic_handle_irq(AR2315_MISC_IRQ_UART0); elsespurious_interrupt (); }
@@ -207,6 +209,8 @@ void __init ar2315_plat_mem_setup(void)ar231x_write_reg (AR2315_WDC ,AR2315_WDC_IGNORE_EXPIRATION ); _machine_restart = ar2315_restart; +ar231x_serial_setup (AR2315_UART0 ,AR2315_MISC_IRQ_UART0 , +ar2315_apb_frequency ()); }void __init ar2315_prom_init (void )
arch/mips/ar231x/ar5312.c +4 -0
@@ -55,6 +55,8 @@ static void ar5312_misc_irq_handler(unsigned irq, struct irq_desc *desc) (void )ar231x_read_reg (AR5312_TIMER ); }else if (pending &AR5312_ISR_AHBPROC )generic_handle_irq (AR5312_MISC_IRQ_AHB_PROC ); +else if ((pending &AR5312_ISR_UART0 )) +generic_handle_irq (AR5312_MISC_IRQ_UART0 );else if (pending &AR5312_ISR_WD )generic_handle_irq (AR5312_MISC_IRQ_WATCHDOG );else
@@ -211,6 +213,8 @@ void __init ar5312_plat_mem_setup(void)ar231x_write_reg (AR5312_WD_CTRL ,AR5312_WD_CTRL_IGNORE_EXPIRATION ); _machine_restart = ar5312_restart; +ar231x_serial_setup (AR5312_UART0 ,AR5312_MISC_IRQ_UART0 , +ar5312_sys_frequency ()); }void __init ar5312_prom_init (void )
arch/mips/ar231x/devices.c +17 -0
@@ -1,5 +1,6 @@#include <linux/kernel.h> #include <linux/init.h> +#include <linux/serial_8250.h> #include <asm/bootinfo.h> #include "devices.h"
@@ -18,3 +19,19 @@ const char *get_system_type(void)return devtype_strings[ar231x_devtype]; } +void __init ar231x_serial_setup (u32 mapbase,int irq,unsigned int uartclk) +{ +struct uart_port s; + +memset (&s,0 ,sizeof (s)); + + s.flags =UPF_BOOT_AUTOCONF |UPF_SKIP_TEST |UPF_IOREMAP ; + s.iotype =UPIO_MEM32 ; + s.irq = irq; + s.regshift =2 ; + s.mapbase = mapbase; + s.uartclk = uartclk; + +early_serial_setup (&s); +} +
arch/mips/ar231x/devices.h +2 -0
@@ -10,6 +10,8 @@ enum {extern int ar231x_devtype;extern void (*ar231x_irq_dispatch)(void ); +void ar231x_serial_setup (u32 mapbase,int irq,unsigned int uartclk); +static inline bool is_2315 (void ) {return (current_cpu_data.cputype ==CPU_4KEC );
Signature · 1 line
1.8.1.5
RFC 7/18 MIPS: ar231x: add board configuration detection
In reply to Sergey RyazanovAll boards based on AR5312/AR2315 SoC have a special structure located at the end of flash. This structure contains board-specific data such as Ethernet and Wireless MAC addresses. The flash is mapped to the memmory at predefined location.
--- arch/mips/ar231x/ar2315.c | 17 +++ arch/mips/ar231x/ar2315.h | 2 + arch/mips/ar231x/ar5312.c | 41 ++++++ arch/mips/ar231x/ar5312.h | 2 + arch/mips/ar231x/board.c | 153 +++++++++++++++++++++ arch/mips/ar231x/devices.c | 13 ++ arch/mips/ar231x/devices.h | 2 + .../mips/include/asm/mach-ar231x/ar231x_platform.h | 73 ++++++++++ 8 files changed, 303 insertions(+) create mode 100644 arch/mips/include/asm/mach-ar231x/ar231x_platform.h
arch/mips/ar231x/ar2315.c +17 -0
@@ -119,6 +119,23 @@ void __init ar2315_arch_init_irq(void)irq_set_chained_handler (AR2315_IRQ_MISC , ar2315_misc_irq_handler); } +/* +* 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 +* be mapped multiple times. +*/ +static const u8 *const __initconst +ar2315_flash_limit = (u8 *)KSEG1ADDR (AR2315_SPI_READ +0x1000000 ); + +void __init ar2315_init_devices (void ) +{ +if (!is_2315 ()) +return ; + +/* Find board configuration */ +ar231x_find_config (ar2315_flash_limit); +} +static void ar2315_restart (char *command) {void (*mips_reset_vec)(void ) = (void *)0xbfc00000 ;
arch/mips/ar231x/ar2315.h +2 -0
@@ -4,6 +4,7 @@#ifdef CONFIG_SOC_AR2315 void ar2315_arch_init_irq (void ); +void ar2315_init_devices (void );void ar2315_plat_time_init (void );void ar2315_plat_mem_setup (void );void ar2315_prom_init (void );
@@ -11,6 +12,7 @@ void ar2315_prom_init(void);#else static inline void ar2315_arch_init_irq (void ) {} +static inline void ar2315_init_devices (void ) {}static inline void ar2315_plat_time_init (void ) {}static inline void ar2315_plat_mem_setup (void ) {}static inline void ar2315_prom_init (void ) {}
arch/mips/ar231x/ar5312.c +41 -0
47 lines not on this page · raw message
arch/mips/ar231x/ar5312.h +2 -0
@@ -4,6 +4,7 @@#ifdef CONFIG_SOC_AR5312 void ar5312_arch_init_irq (void ); +void ar5312_init_devices (void );void ar5312_plat_time_init (void );void ar5312_plat_mem_setup (void );void ar5312_prom_init (void );
@@ -11,6 +12,7 @@ void ar5312_prom_init(void);#else static inline void ar5312_arch_init_irq (void ) {} +static inline void ar5312_init_devices (void ) {}static inline void ar5312_plat_time_init (void ) {}static inline void ar5312_plat_mem_setup (void ) {}static inline void ar5312_prom_init (void ) {}
arch/mips/ar231x/board.c +153 -0
165 lines not on this page · raw message
arch/mips/ar231x/devices.c +13 -0
@@ -3,8 +3,12 @@#include <linux/serial_8250.h> #include <asm/bootinfo.h> +#include <ar231x_platform.h> #include "devices.h" +#include "ar5312.h" +#include "ar2315.h" +struct ar231x_board_config ar231x_board;int ar231x_devtype =DEV_TYPE_UNKNOWN ;static const char *const devtype_strings[] = {
@@ -35,3 +39,12 @@ void __init ar231x_serial_setup(u32 mapbase, int irq, unsigned int uartclk)early_serial_setup (&s); } +static int __init ar231x_register_devices (void ) +{ +ar5312_init_devices (); +ar2315_init_devices (); + +return 0 ; +} + +device_initcall (ar231x_register_devices);
arch/mips/ar231x/devices.h +2 -0
@@ -8,8 +8,10 @@ enum { };extern int ar231x_devtype; +extern struct ar231x_board_config ar231x_board;extern void (*ar231x_irq_dispatch)(void ); +int ar231x_find_config (const u8 *flash_limit);void ar231x_serial_setup (u32 mapbase,int irq,unsigned int uartclk);static inline bool is_2315 (void )
arch/mips/include/asm/mach-ar231x/ar231x_platform.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
1.8.1.5
RFC 8/18 gpio: add driver for Atheros AR5312 SoC GPIO controller
In reply to Sergey RyazanovAtheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
--- arch/mips/ar231x/Kconfig | 1 + arch/mips/ar231x/ar5312.c | 19 ++++ arch/mips/include/asm/mach-ar231x/ar5312_regs.h | 2 + drivers/gpio/Kconfig | 7 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ar5312.c | 121 ++++++++++++++++++++++++ 6 files changed, 151 insertions(+) create mode 100644 drivers/gpio/gpio-ar5312.c
arch/mips/ar231x/Kconfig +1 -0
@@ -1,6 +1,7 @@ config SOC_AR5312 bool "Atheros AR5312/AR2312+ SoC support" depends on AR231X + select GPIO_AR5312 default y config SOC_AR2315
arch/mips/ar231x/ar5312.c +19 -0
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/kernel.h> +#include <linux/platform_device.h> #include <linux/reboot.h> #include <asm/bootinfo.h> #include <asm/reboot.h>
@@ -118,6 +119,22 @@ void __init ar5312_arch_init_irq(void)irq_set_chained_handler (AR5312_IRQ_MISC , ar5312_misc_irq_handler); } +static struct resource ar5312_gpio_res[] = { + { + .name ="ar5312-gpio" , + .flags =IORESOURCE_MEM , + .start =AR5312_GPIO , + .end =AR5312_GPIO +0x0c -1 , + }, +}; + +static struct platform_device ar5312_gpio = { + .name ="ar5312-gpio" , + .id =-1 , + .resource = ar5312_gpio_res, + .num_resources =ARRAY_SIZE (ar5312_gpio_res), +}; +static void __init ar5312_flash_init (void ) {u32 ctl;
@@ -157,6 +174,8 @@ void __init ar5312_init_devices(void)/* Locate board/radio config data */ ar231x_find_config (ar5312_flash_limit); + +platform_device_register (&ar5312_gpio); }static void ar5312_restart (char *command)
arch/mips/include/asm/mach-ar231x/ar5312_regs.h +2 -0
@@ -210,4 +210,6 @@#define AR5312_MEM_CFG1_AC1_M 0x00007000/* bank 1: SDRAM addr check */ #define AR5312_MEM_CFG1_AC1_S 12 +#define AR5312_GPIO (AR5312_APBBASE + 0x2000) +#endif /* __ASM_MACH_AR231X_AR5312_REGS_H */
drivers/gpio/Kconfig +7 -0
@@ -112,6 +112,13 @@ config GPIO_MAX730X comment "Memory mapped GPIO drivers:" +config GPIO_AR5312 + bool "AR5312 SoC GPIO support" + default y if SOC_AR5312 + depends on SOC_AR5312 + help + Say yes here to enable GPIO support for Atheros AR5312/AR2312+ SoCs. + config GPIO_CLPS711X tristate "CLPS711X GPIO support" depends on ARCH_CLPS711X || COMPILE_TEST
drivers/gpio/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o +obj-$(CONFIG_GPIO_AR5312) += gpio-ar5312.o obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o
drivers/gpio/gpio-ar5312.c new file +121 -0
121 lines not on this page · raw message
Signature · 1 line
1.8.1.5
Re: [RFC 08/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
Quoted 7 lines · Sergey Ryazanov
Atheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
Signed-off-by Sergey Ryazanov <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>
(...)
arch/mips/include/asm/mach-ar231x/ar5312_regs.h
Quoted 3 lines
arch/mips/ar231x/Kconfig +0
-0arch/mips/ar231x/ar5312.c +0
-0arch/mips/include/asm/mach-ar231x/ar5312_regs.h +0
-0
Please put these MIPS-related changes into a separate patch to be handled through the MIPS git tree.
This driver seems surplus, it's just MMIO. Usedrivers/gpio/gpio-generic.c instead.
Yours,
Linus Walleij
Re: [RFC 08/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
Quoted 2 lines · Linus Walleij
This driver seems surplus, it's just MMIO. Use
drivers/gpio/gpio-generic.cinstead.
Bah, I'm talking crap. It does IRQs so it needs to be a custom driver for sure. I'll take a second look.
Yours,
Linus Walleij
Re: [RFC 08/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
In reply to Linus Walleij2014-09-29 13:03 GMT+04:00 Linus Walleij <[email protected]>:
Quoted 9 lines · Sergey Ryazanov
Quoted 8 lines
Atheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
Signed-off-by Sergey Ryazanov <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>
Quoted 9 lines
(...)
arch/mips/include/asm/mach-ar231x/ar5312_regs.h
Quoted 3 lines
arch/mips/ar231x/Kconfig +0
-0arch/mips/ar231x/ar5312.c +0
-0arch/mips/include/asm/mach-ar231x/ar5312_regs.h +0
-0Please put these MIPS-related changes into a separate patch to be handled through the MIPS git tree.
Already do that in non RFC patch.
Signature · 2 lines
BR, Sergey
RFC 9/18 gpio: add driver for Atheros AR5312 SoC GPIO controller
In reply to Sergey RyazanovAtheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
--- arch/mips/ar231x/Kconfig | 1 + arch/mips/ar231x/ar2315.c | 49 ++++- arch/mips/include/asm/mach-ar231x/ar2315_regs.h | 5 + arch/mips/include/asm/mach-ar231x/ar231x.h | 1 + drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-ar2315.c | 233 ++++++++++++++++++++++++ 7 files changed, 294 insertions(+), 3 deletions(-) create mode 100644 drivers/gpio/gpio-ar2315.c
arch/mips/ar231x/Kconfig +1 -0
@@ -7,4 +7,5 @@ config SOC_AR5312 config SOC_AR2315 bool "Atheros AR2315+ SoC support" depends on AR231X + select GPIO_AR2315 default y
arch/mips/ar231x/ar2315.c +46 -3
80 lines not on this page · raw message
arch/mips/include/asm/mach-ar231x/ar2315_regs.h +5 -0
@@ -283,6 +283,11 @@#define AR2315_AMBACLK_CLK_DIV_M 0x0000000c#define AR2315_AMBACLK_CLK_DIV_S 2 +/* GPIO MMR base address */ +#define AR2315_GPIO (AR2315_DSLBASE + 0x0088) + +#define AR2315_RESET_GPIO 5 +/* * PCI Clock Control */
arch/mips/include/asm/mach-ar231x/ar231x.h +1 -0
@@ -4,6 +4,7 @@#include <linux/io.h> #define AR231X_MISC_IRQ_BASE 0x20 +#define AR231X_GPIO_IRQ_BASE 0x30#define AR231X_IRQ_CPU_CLOCK (MIPS_CPU_IRQ_BASE + 7)/* C0_CAUSE: 0x8000 */
drivers/gpio/Kconfig +7 -0
@@ -112,6 +112,13 @@ config GPIO_MAX730X comment "Memory mapped GPIO drivers:" +config GPIO_AR2315 + bool "AR2315 SoC GPIO support" + default y if SOC_AR2315 + depends on SOC_AR2315 + help + Say yes here to enable GPIO support for Atheros AR2315+ SoCs. + config GPIO_AR5312 bool "AR5312 SoC GPIO support" default y if SOC_AR5312
drivers/gpio/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o +obj-$(CONFIG_GPIO_AR2315) += gpio-ar2315.o obj-$(CONFIG_GPIO_AR5312) += gpio-ar5312.o obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o
drivers/gpio/gpio-ar2315.c new file +233 -0
233 lines not on this page · raw message
Signature · 1 line
1.8.1.5
Re: [RFC 09/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
Quoted 8 lines · Sergey Ryazanov
Atheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
Signed-off-by Sergey Ryazanov <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>
(...)
arch/mips/ar231x/ar2315.c static void ar2315_restart(char *command) · line 188
Quoted 7 lines
arch/mips/ar231x/ar2315.c +5
-2-/* Attempt to jump to the mips reset location - the boot loader -* itself might be able to recover the system */ +/* Cold reset does not work on the AR2315/6, use the GPIO reset bits +* a workaround. Give it some time to attempt a gpio based hardware +* reset (atheros reference design workaround) */ +gpio_request_one (AR2315_RESET_GPIO ,GPIOF_OUT_INIT_LOW ,"Reset" ); +mdelay (100 );
Please try to use the new GPIO descriptor API.
See Documentation/gpio/consumer.txt
(...)
drivers/gpio/gpio-ar2315.c line 44
Quoted 6 lines
+++
b/drivers/gpio/gpio-ar2315.cdrivers/gpio/gpio-ar2315.c new file +4
-0+static u32 ar2315_gpio_intmask; +static u32 ar2315_gpio_intval; +static unsigned ar2315_gpio_irq_base; +static void __iomem *ar2315_mem;
Get rid of these local variables and put them into an allocated state container, see Documentation/driver-model/design-patterns.txt
Get rid of _gpio_irq_base altogether. (See comments below.)
(...)
drivers/gpio/gpio-ar2315.c line 49
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static inline u32 ar2315_gpio_reg_read (unsigned reg) +{ +return __raw_readl (ar2315_mem + reg); +}
Use readl_relaxed()
drivers/gpio/gpio-ar2315.c line 54
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static inline void ar2315_gpio_reg_write (unsigned reg,u32 val) +{ +__raw_writel (val, ar2315_mem + reg); +}
Use writel_relaxed()
drivers/gpio/gpio-ar2315.c line 73
Quoted 13 lines
drivers/gpio/gpio-ar2315.c new file +13
-0+static void ar2315_gpio_irq_handler (unsigned irq,struct irq_desc *desc) +{ +u32 pend; +int bit =-1 ; + +/* only do one gpio interrupt at a time */ + pend =ar2315_gpio_reg_read (AR2315_GPIO_DI ); + pend ^= ar2315_gpio_intval; + pend &= ar2315_gpio_intmask; + +if (pend) { + bit =fls (pend) -1 ; + pend &= ~(1 << bit);
Do this:
#include <linux/bitops.h>
pend &= ~BIT(bit);
Quoted 1 line
+
ar2315_gpio_intmask|= (1 << gpio);
|= BIT(gpio);
drivers/gpio/gpio-ar2315.c line 110
Quoted 6 lines
drivers/gpio/gpio-ar2315.c new file +6
-0+ar2315_gpio_int_setup (gpio,AR2315_GPIO_INT_TRIG_EDGE ); +} + +static void ar2315_gpio_irq_mask (struct irq_data *d) +{ +unsigned gpio = d->irq - ar2315_gpio_irq_base;
Wait, no. No keeping irq bases around like that please.
unsigned offset = d->hwirq;
And call it offset rather than "gpio" everywhere please, since it is local to this GPIO controller, not the global GPIO numberspace.
drivers/gpio/gpio-ar2315.c line 113
Quoted 2 lines
drivers/gpio/gpio-ar2315.c new file +2
-0+/* Disable interrupt */ + ar2315_gpio_intmask &= ~(1 << gpio);
&= ~BIT(gpio);
drivers/gpio/gpio-ar2315.c line 140
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static int ar2315_gpio_get_val (struct gpio_chip *chip,unsigned gpio) +{ +return (ar2315_gpio_reg_read (AR2315_GPIO_DI ) >> gpio) &1 ; +}
Do this:
return !!(ar2315_gpio_reg_read(AR2315_GPIO_DI) & BIT(gpio));
drivers/gpio/gpio-ar2315.c line 147
Quoted 6 lines
drivers/gpio/gpio-ar2315.c new file +6
-0+static void ar2315_gpio_set_val (struct gpio_chip *chip,unsigned gpio,int val) +{ +u32 reg =ar2315_gpio_reg_read (AR2315_GPIO_DO ); + + reg = val ? reg | (1 << gpio) : reg & ~(1 << gpio); +ar2315_gpio_reg_write (AR2315_GPIO_DO , reg);
Convoluted, I would use an if() else construct rather than the ? operator.
drivers/gpio/gpio-ar2315.c line 166
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static int ar2315_gpio_to_irq (struct gpio_chip *chip,unsigned gpio) +{ +return ar2315_gpio_irq_base + gpio; +}
Don't implement this at all. You're using the gpiolib irqchip helpers! It will just overrun this implementation.
Yours,
Linus Walleij
Re: [RFC 09/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
Quoted 36 lines · Linus Walleij
Quoted 8 lines · Sergey Ryazanov
Atheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
Signed-off-by Sergey Ryazanov <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>(...)
arch/mips/ar231x/ar2315.c static void ar2315_restart(char *command) · line 188
Quoted 7 lines
arch/mips/ar231x/ar2315.c +5
-2-/* Attempt to jump to the mips reset location - the boot loader -* itself might be able to recover the system */ +/* Cold reset does not work on the AR2315/6, use the GPIO reset bits +* a workaround. Give it some time to attempt a gpio based hardware +* reset (atheros reference design workaround) */ +gpio_request_one (AR2315_RESET_GPIO ,GPIOF_OUT_INIT_LOW ,"Reset" ); +mdelay (100 );Please try to use the new GPIO descriptor API.
SeeDocumentation/gpio/consumer.txt(...)
drivers/gpio/gpio-ar2315.c line 44
Quoted 6 lines
+++
b/drivers/gpio/gpio-ar2315.cdrivers/gpio/gpio-ar2315.c new file +4
-0+static u32 ar2315_gpio_intmask; +static u32 ar2315_gpio_intval; +static unsigned ar2315_gpio_irq_base; +static void __iomem *ar2315_mem;Get rid of these local variables and put them into an allocated state container, see
Documentation/driver-model/design-patterns.txtGet rid of
_gpio_irq_basealtogether. (See comments below.)
Quoted 7 lines
(...)
drivers/gpio/gpio-ar2315.c line 49
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static inline u32 ar2315_gpio_reg_read (unsigned reg) +{ +return __raw_readl (ar2315_mem + reg); +}Use
readl_relaxed()
ar2315/ar5312 is big endian, so readl_relaxed would mess up the byte order. There does not seem to be a big endian equivalent for _relaxed.
Regards
Jonas
Re: [RFC 09/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
In reply to Linus Walleij2014-09-29 13:18 GMT+04:00 Linus Walleij <[email protected]>:
Quoted 19 lines · Sergey Ryazanov
Quoted 9 lines
Atheros AR5312 SoC have a builtin GPIO controller, which could be accessed via memory mapped registers. This patch adds new driver for them.
Signed-off-by Sergey Ryazanov <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>(...)
arch/mips/ar231x/ar2315.c static void ar2315_restart(char *command) · line 188
Quoted 7 lines
arch/mips/ar231x/ar2315.c +5
-2-/* Attempt to jump to the mips reset location - the boot loader -* itself might be able to recover the system */ +/* Cold reset does not work on the AR2315/6, use the GPIO reset bits +* a workaround. Give it some time to attempt a gpio based hardware +* reset (atheros reference design workaround) */ +gpio_request_one (AR2315_RESET_GPIO ,GPIOF_OUT_INIT_LOW ,"Reset" ); +mdelay (100 );
Quoted 3 lines
Please try to use the new GPIO descriptor API.
SeeDocumentation/gpio/consumer.txt
I will investigate this possibility.
Quoted 12 lines
(...)
drivers/gpio/gpio-ar2315.c line 44
Quoted 6 lines
+++
b/drivers/gpio/gpio-ar2315.cdrivers/gpio/gpio-ar2315.c new file +4
-0+static u32 ar2315_gpio_intmask; +static u32 ar2315_gpio_intval; +static unsigned ar2315_gpio_irq_base; +static void __iomem *ar2315_mem;Get rid of these local variables and put them into an allocated state container, see
Documentation/driver-model/design-patterns.txt
AR2315 SoC contains only one GPIO unit, so there are no reasons to increase driver complexity. But if you insist, I will add state container.
Quoted 50 lines
Get rid of
_gpio_irq_basealtogether. (See comments below.)(...)
drivers/gpio/gpio-ar2315.c line 49
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static inline u32 ar2315_gpio_reg_read (unsigned reg) +{ +return __raw_readl (ar2315_mem + reg); +}Use
readl_relaxed()drivers/gpio/gpio-ar2315.c line 54
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static inline void ar2315_gpio_reg_write (unsigned reg,u32 val) +{ +__raw_writel (val, ar2315_mem + reg); +}Use
writel_relaxed()drivers/gpio/gpio-ar2315.c line 73
Quoted 13 lines
drivers/gpio/gpio-ar2315.c new file +13
-0+static void ar2315_gpio_irq_handler (unsigned irq,struct irq_desc *desc) +{ +u32 pend; +int bit =-1 ; + +/* only do one gpio interrupt at a time */ + pend =ar2315_gpio_reg_read (AR2315_GPIO_DI ); + pend ^= ar2315_gpio_intval; + pend &= ar2315_gpio_intmask; + +if (pend) { + bit =fls (pend) -1 ; + pend &= ~(1 << bit);Do this:
#include <
linux/bitops.h>pend &= ~BIT(bit);
Quoted 1 line
+
ar2315_gpio_intmask|= (1 << gpio);|= BIT(gpio);
drivers/gpio/gpio-ar2315.c line 110
Quoted 6 lines
drivers/gpio/gpio-ar2315.c new file +6
-0+ar2315_gpio_int_setup (gpio,AR2315_GPIO_INT_TRIG_EDGE ); +} + +static void ar2315_gpio_irq_mask (struct irq_data *d) +{ +unsigned gpio = d->irq - ar2315_gpio_irq_base;Wait, no. No keeping irq bases around like that please.
Quoted 5 lines
unsigned offset =
d->hwirq;And call it offset rather than "gpio" everywhere please, since it is local to this GPIO controller, not the global GPIO numberspace.
Sure.
Quoted 5 lines
drivers/gpio/gpio-ar2315.c line 113
Quoted 2 lines
drivers/gpio/gpio-ar2315.c new file +2
-0+/* Disable interrupt */ + ar2315_gpio_intmask &= ~(1 << gpio);&= ~BIT(gpio);
Quoted 8 lines
drivers/gpio/gpio-ar2315.c line 140
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static int ar2315_gpio_get_val (struct gpio_chip *chip,unsigned gpio) +{ +return (ar2315_gpio_reg_read (AR2315_GPIO_DI ) >> gpio) &1 ; +}Do this:
return !!(ar2315_gpio_reg_read(AR2315_GPIO_DI) & BIT(gpio));
Ok.
Quoted 9 lines
drivers/gpio/gpio-ar2315.c line 147
Quoted 6 lines
drivers/gpio/gpio-ar2315.c new file +6
-0+static void ar2315_gpio_set_val (struct gpio_chip *chip,unsigned gpio,int val) +{ +u32 reg =ar2315_gpio_reg_read (AR2315_GPIO_DO ); + + reg = val ? reg | (1 << gpio) : reg & ~(1 << gpio); +ar2315_gpio_reg_write (AR2315_GPIO_DO , reg);Convoluted, I would use an
if()else construct rather than the ? operator.
Convoluted, but 3 lines shorter :) And checkpatch has no objections.
Quoted 8 lines
drivers/gpio/gpio-ar2315.c line 166
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static int ar2315_gpio_to_irq (struct gpio_chip *chip,unsigned gpio) +{ +return ar2315_gpio_irq_base + gpio; +}Don't implement this at all. You're using the gpiolib irqchip helpers! It will just overrun this implementation.
Seems that I missed some new gpiolib features. I will try to rewrite this.
Thank you for detailed review!
Signature · 2 lines
BR, Sergey
Re: [RFC 09/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
Quoted 11 lines · Sergey Ryazanov
2014-09-29 13:18 GMT+04:00 Linus Walleij <[email protected]>:
Quoted 9 lines
drivers/gpio/gpio-ar2315.c line 44
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static u32 ar2315_gpio_intmask; +static u32 ar2315_gpio_intval; +static unsigned ar2315_gpio_irq_base; +static void __iomem *ar2315_mem;Get rid of these local variables and put them into an allocated state container, see
Documentation/driver-model/design-patterns.txt
Quoted 3 lines
AR2315 SoC contains only one GPIO unit, so there are no reasons to increase driver complexity. But if you insist, I will add state container.
I insist. It makes the driver easier to maintain if it looks like most other drivers instead of using static locals.
Quoted 3 lines
Quoted 2 lines
Convoluted, I would use an
if()else construct rather than the ? operator.Convoluted, but 3 lines shorter :) And checkpatch has no objections.
True but it's me who is going to be maintaining this, not checkpatch.
Yours,
Linus Walleij
Re: [RFC 09/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
2014-10-21 12:29 GMT+04:00 Linus Walleij <[email protected]>:
Quoted 13 lines
Quoted 11 lines · Sergey Ryazanov
2014-09-29 13:18 GMT+04:00 Linus Walleij <[email protected]>:
Quoted 9 lines
drivers/gpio/gpio-ar2315.c line 44
Quoted 4 lines
drivers/gpio/gpio-ar2315.c new file +4
-0+static u32 ar2315_gpio_intmask; +static u32 ar2315_gpio_intval; +static unsigned ar2315_gpio_irq_base; +static void __iomem *ar2315_mem;Get rid of these local variables and put them into an allocated state container, see
Documentation/driver-model/design-patterns.txt
Quoted 7 lines
Quoted 3 lines
AR2315 SoC contains only one GPIO unit, so there are no reasons to increase driver complexity. But if you insist, I will add state container.
I insist. It makes the driver easier to maintain if it looks like most other drivers instead of using static locals.
No problem. I rewrite the driver using the state container.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Convoluted, I would use an
if()else construct rather than the ? operator.Convoluted, but 3 lines shorter :) And checkpatch has no objections.
True but it's me who is going to be maintaining this, not checkpatch.
I missed that. Added to my todo list.
BTW, the use of the irq_domain framework is required or I could opencode some stuff?
Quoted 2 lines
Yours,
Linus Walleij
Signature · 2 lines
BR, Sergey
Re: [RFC 09/18] gpio: add driver for Atheros AR5312 SoC GPIO controller
Quoted 2 lines · Sergey Ryazanov
BTW, the use of the
irq_domainframework is required or I could opencode some stuff?
Whatever makes sense. If you write something that looks very convoluted compared to doing it with irqdomain, you're doing something wrong.
But shouldn't this driver be using GPIOLIB_IRQCHIP by the way? That includes irqdomain handling.
Yours,
Linus Walleij
RFC 10/18 MIPS: ar231x: add SoC type detection
In reply to Sergey RyazanovDetect SoC type based on device ID and board configuration data.
--- arch/mips/ar231x/ar2315.c | 22 +++++++++++++++++++++- arch/mips/ar231x/ar5312.c | 22 ++++++++++++++++++++++ arch/mips/ar231x/devices.c | 7 +++++++ arch/mips/ar231x/devices.h | 11 +++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-)
arch/mips/ar231x/ar2315.c +21 -1
@@ -24,6 +24,7 @@#include <asm/reboot.h> #include <asm/time.h> +#include <ar231x_platform.h> #include <ar2315_regs.h> #include <ar231x.h>
@@ -275,7 +276,7 @@ void __init ar2315_plat_mem_setup(void)void __init ar2315_prom_init (void ) { -u32 memsize, memcfg; +u32 memsize, memcfg, devid;if (!is_2315 ())return ;
@@ -286,5 +287,24 @@ void __init ar2315_prom_init(void) memsize <<=1 +AR231X_REG_MS (memcfg,AR2315_MEM_CFG_ROW_WIDTH ); memsize <<=3 ;add_memory_region (0 , memsize,BOOT_MEM_RAM ); + +/* Detect the hardware based on the device ID */ + devid =ar231x_read_reg (AR2315_SREV ) &AR2315_REV_CHIP ; +switch (devid) { +case 0x91 :/* Need to check */ + ar231x_devtype =DEV_TYPE_AR2318 ; +break ; +case 0x90 : + ar231x_devtype =DEV_TYPE_AR2317 ; +break ; +case 0x87 : + ar231x_devtype =DEV_TYPE_AR2316 ; +break ; +case 0x86 : +default : + ar231x_devtype =DEV_TYPE_AR2315 ; +break ; + } + ar231x_board.devid = devid; }
arch/mips/ar231x/ar5312.c +22 -0
@@ -22,6 +22,7 @@#include <asm/reboot.h> #include <asm/time.h> +#include <ar231x_platform.h> #include <ar5312_regs.h> #include <ar231x.h>
@@ -167,6 +168,8 @@ ar5312_flash_limit = (u8 *)KSEG1ADDR(AR5312_FLASH + 0x800000);void __init ar5312_init_devices (void ) { +struct ar231x_boarddata *config; +if (!is_5312 ())return ;
@@ -174,6 +177,19 @@ void __init ar5312_init_devices(void)/* Locate board/radio config data */ ar231x_find_config (ar5312_flash_limit); + config = ar231x_board.config; + +/* AR2313 has CPU minor rev. 10 */ +if ((current_cpu_data.processor_id &0xff ) ==0x0a ) + ar231x_devtype =DEV_TYPE_AR2313 ; + +/* AR2312 shares the same Silicon ID as AR5312 */ +else if (config->flags &BD_ISCASPER ) + ar231x_devtype =DEV_TYPE_AR2312 ; + +/* Everything else is probably AR5312 or compatible */ +else + ar231x_devtype =DEV_TYPE_AR5312 ;platform_device_register (&ar5312_gpio); }
@@ -280,6 +296,7 @@ void __init ar5312_plat_mem_setup(void)void __init ar5312_prom_init (void ) {u32 memsize, memcfg, bank0_ac, bank1_ac; +u32 devid;if (!is_5312 ())return ;
@@ -292,5 +309,10 @@ void __init ar5312_prom_init(void) (bank1_ac ? (1 << (bank1_ac +1 )) :0 ); memsize <<=20 ;add_memory_region (0 , memsize,BOOT_MEM_RAM ); + + devid =ar231x_read_reg (AR5312_REV ); + devid >>=AR5312_REV_WMAC_MIN_S ; + devid &=AR5312_REV_CHIP ; + ar231x_board.devid = (u16 )devid; }
arch/mips/ar231x/devices.c +7 -0
@@ -12,6 +12,13 @@ struct ar231x_board_config ar231x_board;int ar231x_devtype =DEV_TYPE_UNKNOWN ;static const char *const devtype_strings[] = { + [DEV_TYPE_AR5312 ] ="Atheros AR5312" , + [DEV_TYPE_AR2312 ] ="Atheros AR2312" , + [DEV_TYPE_AR2313 ] ="Atheros AR2313" , + [DEV_TYPE_AR2315 ] ="Atheros AR2315" , + [DEV_TYPE_AR2316 ] ="Atheros AR2316" , + [DEV_TYPE_AR2317 ] ="Atheros AR2317" , + [DEV_TYPE_AR2318 ] ="Atheros AR2318" , [DEV_TYPE_UNKNOWN ] ="Atheros (unknown)" , };
arch/mips/ar231x/devices.h +11 -0
@@ -4,6 +4,17 @@#include <linux/cpu.h> enum { +/* handled by ar5312.c */ +DEV_TYPE_AR2312 , +DEV_TYPE_AR2313 , +DEV_TYPE_AR5312 , + +/* handled by ar2315.c */ +DEV_TYPE_AR2315 , +DEV_TYPE_AR2316 , +DEV_TYPE_AR2317 , +DEV_TYPE_AR2318 , +DEV_TYPE_UNKNOWN };
Signature · 1 line
1.8.1.5
RFC 11/18 MIPS: ar231x: add AR5312 flash support
In reply to Sergey Ryazanov--- arch/mips/ar231x/ar5312.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
arch/mips/ar231x/ar5312.c +32 -2
@@ -17,6 +17,7 @@#include <linux/init.h> #include <linux/kernel.h> #include <linux/platform_device.h> +#include <linux/mtd/physmap.h> #include <linux/reboot.h> #include <asm/bootinfo.h> #include <asm/reboot.h>
@@ -120,6 +121,24 @@ void __init ar5312_arch_init_irq(void)irq_set_chained_handler (AR5312_IRQ_MISC , ar5312_misc_irq_handler); } +static struct physmap_flash_data ar5312_flash_data = { + .width =2 , +}; + +static struct resource ar5312_flash_resource = { + .start =AR5312_FLASH , + .end =AR5312_FLASH +0x800000 -1 , + .flags =IORESOURCE_MEM , +}; + +static struct platform_device ar5312_physmap_flash = { + .name ="physmap-flash" , + .id =0 , + .dev.platform_data = &ar5312_flash_data, + .resource = &ar5312_flash_resource, + .num_resources =1 , +}; +static struct resource ar5312_gpio_res[] = { { .name ="ar5312-gpio" ,
@@ -138,13 +157,23 @@ static struct platform_device ar5312_gpio = {static void __init ar5312_flash_init (void ) { -u32 ctl; +u32 ctl =ar231x_read_reg (AR5312_FLASHCTL0 ) &AR5312_FLASHCTL_MW ; + +/* fixup flash width */ +switch (ctl) { +case AR5312_FLASHCTL_MW16 : + ar5312_flash_data.width =2 ; +break ; +case AR5312_FLASHCTL_MW8 : +default : + ar5312_flash_data.width =1 ; +break ; + }/* * Configure flash bank 0. * Assume 8M window size. Flash will be aliased if it's smaller */ - ctl =ar231x_read_reg (AR5312_FLASHCTL0 ) &AR5312_FLASHCTL_MW ; ctl |=AR5312_FLASHCTL_E |AR5312_FLASHCTL_AC_8M |AR5312_FLASHCTL_RBLE ; ctl |=0x01 <<AR5312_FLASHCTL_IDCY_S ; ctl |=0x07 <<AR5312_FLASHCTL_WST1_S ;
@@ -191,6 +220,7 @@ void __init ar5312_init_devices(void)else ar231x_devtype =DEV_TYPE_AR5312 ; +platform_device_register (&ar5312_physmap_flash);platform_device_register (&ar5312_gpio); }
Signature · 1 line
1.8.1.5
RFC 12/18 mtd: add Atheros AR2315 SPI Flash driver
In reply to Sergey RyazanovAtheros AR2315 SoC have a SPI Flash unit with hybrid flash access: flash read is performed via memory mapping, on the other hand flash write is performed by explicitly issued SPI command.
---
This driver is not ready for merging since it should be rewrited using spi-nor framework.
--- arch/mips/ar231x/ar2315.c | 23 ++ drivers/mtd/devices/Kconfig | 5 + drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/ar2315.c | 459 ++++++++++++++++++++++++++++++++++ drivers/mtd/devices/ar2315_spiflash.h | 106 ++++++++ 5 files changed, 594 insertions(+) create mode 100644 drivers/mtd/devices/ar2315.c create mode 100644 drivers/mtd/devices/ar2315_spiflash.h
arch/mips/ar231x/ar2315.c +23 -0
@@ -126,6 +126,28 @@ void __init ar2315_arch_init_irq(void)irq_set_chained_handler (AR2315_IRQ_MISC , ar2315_misc_irq_handler); } +static struct resource ar2315_spiflash_res[] = { + { + .name ="spiflash_read" , + .flags =IORESOURCE_MEM , + .start =AR2315_SPI_READ , + .end =AR2315_SPI_READ +0x1000000 -1 , + }, + { + .name ="spiflash_mmr" , + .flags =IORESOURCE_MEM , + .start =AR2315_SPI_MMR , + .end =AR2315_SPI_MMR +12 -1 , + }, +}; + +static struct platform_device ar2315_spiflash = { + .id =-1 , + .name ="ar2315-spiflash" , + .resource = ar2315_spiflash_res, + .num_resources =ARRAY_SIZE (ar2315_spiflash_res) +}; +static struct resource ar2315_gpio_res[] = { { .name ="ar2315-gpio" ,
@@ -171,6 +193,7 @@ void __init ar2315_init_devices(void)ar231x_find_config (ar2315_flash_limit);platform_device_register (&ar2315_gpio); +platform_device_register (&ar2315_spiflash); }static void ar2315_restart (char *command)
drivers/mtd/devices/Kconfig +5 -0
@@ -112,6 +112,11 @@ config MTD_SST25L Set up your spi devices with the right board-specific platform data, if you want to specify device partitioning. +config MTD_AR2315 + tristate "Atheros AR2315+ SPI Flash support" + depends on SOC_AR2315 + default y + config MTD_BCM47XXSFLASH tristate "R/O support for serial flash on BCMA bus" depends on BCMA_SFLASH
drivers/mtd/devices/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_MTD_M25P80) += m25p80.o obj-$(CONFIG_MTD_NAND_OMAP_BCH) += elm.o obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o obj-$(CONFIG_MTD_SST25L) += sst25l.o +obj-$(CONFIG_MTD_AR2315) += ar2315.o obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o obj-$(CONFIG_MTD_ST_SPI_FSM) += st_spi_fsm.o
drivers/mtd/devices/ar2315.c new file +459 -0
459 lines not on this page · raw message
drivers/mtd/devices/ar2315_spiflash.h new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
1.8.1.5
RFC 13/18 watchdog: add Atheros AR2315 watchdog driver
In reply to Sergey Ryazanov--- arch/mips/ar231x/ar2315.c | 26 +++++- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/ar2315-wtd.c | 202 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 drivers/watchdog/ar2315-wtd.c
arch/mips/ar231x/ar2315.c +25 -1
@@ -62,7 +62,10 @@ static void ar2315_misc_irq_handler(unsigned irq, struct irq_desc *desc)generic_handle_irq (AR2315_MISC_IRQ_GPIO ); }else if (pending &AR2315_ISR_UART0 )generic_handle_irq (AR2315_MISC_IRQ_UART0 ); -else +else if (pending &AR2315_ISR_WD ) { +ar231x_write_reg (AR2315_ISR ,AR2315_ISR_WD ); +generic_handle_irq (AR2315_MISC_IRQ_WATCHDOG ); + }else spurious_interrupt (); }
@@ -148,6 +151,26 @@ static struct platform_device ar2315_spiflash = { .num_resources = ARRAY_SIZE(ar2315_spiflash_res) }; +static struct resource ar2315_wdt_res[] = { + { + .flags =IORESOURCE_MEM , + .start =AR2315_WD , + .end =AR2315_WD +8 -1 , + }, + { + .flags =IORESOURCE_IRQ , + .start =AR2315_MISC_IRQ_WATCHDOG , + .end =AR2315_MISC_IRQ_WATCHDOG , + } +}; + +static struct platform_device ar2315_wdt = { + .id =-1 , + .name ="ar2315-wdt" , + .resource = ar2315_wdt_res, + .num_resources =ARRAY_SIZE (ar2315_wdt_res) +}; +static struct resource ar2315_gpio_res[] = { { .name ="ar2315-gpio" ,
@@ -193,6 +216,7 @@ void __init ar2315_init_devices(void)ar231x_find_config (ar2315_flash_limit);platform_device_register (&ar2315_gpio); +platform_device_register (&ar2315_wdt);platform_device_register (&ar2315_spiflash); }
drivers/watchdog/Kconfig +7 -0
@@ -1186,6 +1186,13 @@ config RALINK_WDT help Hardware driver for the Ralink SoC Watchdog Timer. +config AR2315_WDT + tristate "Atheros AR2315+ WiSoCs Watchdog Timer" + depends on SOC_AR2315 + help + Hardware driver for the built-in watchdog timer on the Atheros + AR2315/AR2316 WiSoCs. + # PARISC Architecture # POWERPC Architecture
drivers/watchdog/Makefile +1 -0
@@ -133,6 +133,7 @@ obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o obj-$(CONFIG_AR7_WDT) += ar7_wdt.o +obj-$(CONFIG_AR2315_WDT) += ar2315-wtd.o obj-$(CONFIG_TXX9_WDT) += txx9wdt.o obj-$(CONFIG_OCTEON_WDT) += octeon-wdt.o octeon-wdt-y := octeon-wdt-main.o octeon-wdt-nmi.o
drivers/watchdog/ar2315-wtd.c new file +202 -0
202 lines not on this page · raw message
Signature · 1 line
1.8.1.5
Guenter Roeck
maintainerRe: [RFC 13/18] watchdog: add Atheros AR2315 watchdog driver
Quoted 8 lines · Sergey Ryazanov
Signed-off-by Sergey Ryazanov <[email protected]>Cc Wim Van Sebroeck <[email protected]>--- arch/mips/ar231x/ar2315.c | 26 +++++- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/ar2315-wtd.c | 202 ++++++++++++++++++++++++++++++++++++++++++
This should be two patches: One to instantiate the watchdog, the second the watchdog driver itself. The weatchdog driver should use the watchdog infrastructure.
Guenter
Quoted 96 lines
4 files changed, 235 insertions(+), 1 deletion(-)create mode 100644
drivers/watchdog/ar2315-wtd.carch/mips/ar231x/ar2315.c +25
-1@@ -62,7 +62,10 @@ static void ar2315_misc_irq_handler(unsigned irq, struct irq_desc *desc)generic_handle_irq (AR2315_MISC_IRQ_GPIO ); }else if (pending &AR2315_ISR_UART0 )generic_handle_irq (AR2315_MISC_IRQ_UART0 ); -else +else if (pending &AR2315_ISR_WD ) { +ar231x_write_reg (AR2315_ISR ,AR2315_ISR_WD ); +generic_handle_irq (AR2315_MISC_IRQ_WATCHDOG ); + }else spurious_interrupt (); }@@ -148,6 +151,26 @@ static struct platform_device ar2315_spiflash = { .num_resources = ARRAY_SIZE(ar2315_spiflash_res) }; +static struct resource ar2315_wdt_res[] = { + { + .flags =IORESOURCE_MEM , + .start =AR2315_WD , + .end =AR2315_WD +8 -1 , + }, + { + .flags =IORESOURCE_IRQ , + .start =AR2315_MISC_IRQ_WATCHDOG , + .end =AR2315_MISC_IRQ_WATCHDOG , + } +}; + +static struct platform_device ar2315_wdt = { + .id =-1 , + .name ="ar2315-wdt" , + .resource = ar2315_wdt_res, + .num_resources =ARRAY_SIZE (ar2315_wdt_res) +}; +static struct resource ar2315_gpio_res[] = { { .name ="ar2315-gpio" ,@@ -193,6 +216,7 @@ void __init ar2315_init_devices(void)ar231x_find_config (ar2315_flash_limit);platform_device_register (&ar2315_gpio); +platform_device_register (&ar2315_wdt);platform_device_register (&ar2315_spiflash); }drivers/watchdog/Kconfig +7
-0@@ -1186,6 +1186,13 @@ config RALINK_WDT help Hardware driver for the Ralink SoC Watchdog Timer. +config AR2315_WDT + tristate "Atheros AR2315+ WiSoCs Watchdog Timer" + depends on SOC_AR2315 + help + Hardware driver for the built-in watchdog timer on the Atheros + AR2315/AR2316 WiSoCs. + # PARISC Architecture # POWERPC Architecturedrivers/watchdog/Makefile +1
-0@@ -133,6 +133,7 @@ obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o obj-$(CONFIG_AR7_WDT) += ar7_wdt.o +obj-$(CONFIG_AR2315_WDT) += ar2315-wtd.o obj-$(CONFIG_TXX9_WDT) += txx9wdt.o obj-$(CONFIG_OCTEON_WDT) += octeon-wdt.o octeon-wdt-y := octeon-wdt-main.o octeon-wdt-nmi.odrivers/watchdog/ar2315-wtd.c new file +6
-0@@ -0,0 +1,202 @@ +/* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*
drivers/watchdog/ar2315-wtd.c line 16
Quoted 10 lines
drivers/watchdog/ar2315-wtd.c new file +10
-0+* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +* +* Copyright (C) 2008 John Crispin <[email protected]> +* Based on EP93xx and ifxmips wdt driver
2008 ?
Quoted 12 lines
drivers/watchdog/ar2315-wtd.c new file +12
-0+*/ + +#include <linux/interrupt.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/types.h> +#include <linux/miscdevice.h> +#include <linux/watchdog.h> +#include <linux/fs.h> +#include <linux/ioport.h> +#include <linux/notifier.h> +#include <linux/reboot.h>
drivers/watchdog/ar2315-wtd.c line 38
Quoted 10 lines
drivers/watchdog/ar2315-wtd.c new file +10
-0+#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/io.h> +#include <linux/uaccess.h> + +#define DRIVER_NAME "ar2315-wdt" + +#define CLOCK_RATE 40000000 +#define HEARTBEAT (x) (x < 1 || x > 90 ? 20 : x) +
Whatever the logic is here, it does not make much sense to me.
Quoted 165 lines
drivers/watchdog/ar2315-wtd.c new file +164
-0+#define WDT_REG_TIMER 0x00 +#define WDT_REG_CTRL 0x04 + +#define WDT_CTRL_ACT_NONE 0x00000000/* No action */ +#define WDT_CTRL_ACT_NMI 0x00000001/* NMI on watchdog */ +#define WDT_CTRL_ACT_RESET 0x00000002/* reset on watchdog */ + +static int wdt_timeout =20 ; +static int started; +static int in_use; +static void __iomem *wdt_base; + +static inline void ar2315_wdt_wr (unsigned reg,u32 val) +{ +iowrite32 (val, wdt_base + reg); +} + +static void ar2315_wdt_enable (void ) +{ +ar2315_wdt_wr (WDT_REG_TIMER , wdt_timeout *CLOCK_RATE ); +} + +static ssize_t ar2315_wdt_write (struct file *file,const char __user *data, +size_t len,loff_t *ppos) +{ +if (len) +ar2315_wdt_enable (); +return len; +} + +static int ar2315_wdt_open (struct inode *inode,struct file *file) +{ +if (in_use) +return -EBUSY ; +ar2315_wdt_enable (); + in_use =1 ; + started =1 ; +return nonseekable_open (inode, file); +} + +static int ar2315_wdt_release (struct inode *inode,struct file *file) +{ + in_use =0 ; +return 0 ; +} + +static irqreturn_t ar2315_wdt_interrupt (int irq,void *dev) +{ +struct platform_device *pdev = (struct platform_device *)dev; + +if (started) { +dev_crit (&pdev->dev,"watchdog expired, rebooting system\n" ); +emergency_restart (); + }else { +ar2315_wdt_wr (WDT_REG_CTRL ,0 ); +ar2315_wdt_wr (WDT_REG_TIMER ,0 ); + } +return IRQ_HANDLED ; +} + +static struct watchdog_info ident = { + .options =WDIOF_SETTIMEOUT |WDIOF_KEEPALIVEPING , + .identity ="ar2315 Watchdog" , +}; + +static long ar2315_wdt_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +int new_wdt_timeout; +int ret = -ENOIOCTLCMD ; + +switch (cmd) { +case WDIOC_GETSUPPORT : + ret =copy_to_user ((void __user *)arg, &ident,sizeof (ident)) ? + -EFAULT :0 ; +break ; +case WDIOC_KEEPALIVE : +ar2315_wdt_enable (); + ret =0 ; +break ; +case WDIOC_SETTIMEOUT : + ret =get_user (new_wdt_timeout, (int __user *)arg); +if (ret) +break ; + wdt_timeout =HEARTBEAT (new_wdt_timeout); +ar2315_wdt_enable (); +break ; +case WDIOC_GETTIMEOUT : + ret =put_user (wdt_timeout, (int __user *)arg); +break ; + } +return ret; +} + +static const struct file_operations ar2315_wdt_fops = { + .owner =THIS_MODULE , + .llseek = no_llseek, + .write = ar2315_wdt_write, + .unlocked_ioctl = ar2315_wdt_ioctl, + .open = ar2315_wdt_open, + .release = ar2315_wdt_release, +}; + +static struct miscdevice ar2315_wdt_miscdev = { + .minor =WATCHDOG_MINOR , + .name ="watchdog" , + .fops = &ar2315_wdt_fops, +}; + +static int ar2315_wdt_probe (struct platform_device *dev) +{ +struct resource *mem_res, *irq_res; +int ret =0 ; + +if (wdt_base) +return -EBUSY ; + + irq_res =platform_get_resource (dev,IORESOURCE_IRQ ,0 ); +if (!irq_res) { +dev_err (&dev->dev,"no IRQ resource\n" ); +return -ENOENT ; + } + + mem_res =platform_get_resource (dev,IORESOURCE_MEM ,0 ); + wdt_base =devm_ioremap_resource (&dev->dev, mem_res); +if (IS_ERR (wdt_base)) +return PTR_ERR (wdt_base); + + ret =devm_request_irq (&dev->dev, irq_res->start, ar2315_wdt_interrupt, +IRQF_DISABLED ,DRIVER_NAME , dev); +if (ret) { +dev_err (&dev->dev,"failed to register inetrrupt\n" ); + goto out; + } + + ret =misc_register (&ar2315_wdt_miscdev); +if (ret) +dev_err (&dev->dev,"failed to register miscdev\n" ); + +out: +return ret; +} + +static int ar2315_wdt_remove (struct platform_device *dev) +{ +misc_deregister (&ar2315_wdt_miscdev); +return 0 ; +} + +static struct platform_driver ar2315_wdt_driver = { + .probe = ar2315_wdt_probe, + .remove = ar2315_wdt_remove, + .driver = { + .name =DRIVER_NAME , + .owner =THIS_MODULE , + }, +}; + +module_platform_driver (ar2315_wdt_driver); + +MODULE_DESCRIPTION ("Atheros AR2315 hardware watchdog driver" ); +MODULE_AUTHOR ("John Crispin <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:" DRIVER_NAME );
Re: [RFC 13/18] watchdog: add Atheros AR2315 watchdog driver
2014-09-15 7:01 GMT+04:00, Guenter Roeck <[email protected]>:
Quoted 11 lines · Sergey Ryazanov
Quoted 9 lines
Signed-off-by Sergey Ryazanov <[email protected]>Cc Wim Van Sebroeck <[email protected]>--- arch/mips/ar231x/ar2315.c | 26 +++++- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/ar2315-wtd.c | 202++++++++++++++++++++++++++++++++++++++++++
Quoted 4 lines
This should be two patches: One to instantiate the watchdog, the second the watchdog driver itself. The weatchdog driver should use the watchdog infrastructure.
Ok. Will do in v2.
[skipped]
Quoted 6 lines
Quoted 3 lines
+ *
+ * Copyright (C) 2008 John Crispin <[email protected]>
+ * Based on EP93xx and ifxmips wdt driver2008 ?
Yes. This driver is pretty old.
[skipped]
Quoted 6 lines
drivers/watchdog/ar2315-wtd.c line 38
Quoted 4 lines
drivers/watchdog/ar2315-wtd.c new file +4
-0+ +#define CLOCK_RATE 40000000 +#define HEARTBEAT (x) (x < 1 || x > 90 ? 20 : x) +Whatever the logic is here, it does not make much sense to me.
90 second is maximal value which we could write to register, and value below 1 second is senseless. So this macros always return a value which make sense: specified by user or default.
Signature · 2 lines
BR, Sergey
Guenter Roeck
maintainerRe: [RFC 13/18] watchdog: add Atheros AR2315 watchdog driver
Quoted 36 lines · Sergey Ryazanov
2014-09-15 7:01 GMT+04:00, Guenter Roeck <[email protected]>:
Quoted 11 lines · Sergey Ryazanov
Quoted 9 lines
Signed-off-by Sergey Ryazanov <[email protected]>Cc Wim Van Sebroeck <[email protected]>--- arch/mips/ar231x/ar2315.c | 26 +++++- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/ar2315-wtd.c | 202++++++++++++++++++++++++++++++++++++++++++
Quoted 4 lines
This should be two patches: One to instantiate the watchdog, the second the watchdog driver itself. The weatchdog driver should use the watchdog infrastructure.
Ok. Will do in v2.
[skipped]
Quoted 6 lines
Quoted 3 lines
+ *
+ * Copyright (C) 2008 John Crispin <[email protected]>
+ * Based on EP93xx and ifxmips wdt driver2008 ?
Yes. This driver is pretty old.
[skipped]
Quoted 6 lines
drivers/watchdog/ar2315-wtd.c line 38
Quoted 4 lines
drivers/watchdog/ar2315-wtd.c new file +4
-0+ +#define CLOCK_RATE 40000000 +#define HEARTBEAT (x) (x < 1 || x > 90 ? 20 : x) +Whatever the logic is here, it does not make much sense to me.
Quoted 4 lines
90 second is maximal value which we could write to register, and value below 1 second is senseless. So this macros always return a value which make sense: specified by user or default.
I would agree that the value generates would be clamped, for example by using the clamp_val macro. Bit your logic is such that the user gets a timeout of 90 seconds when specifying 90 seconds, and 20 seconds when specifying 91 seconds.
Doesn't really matter much if you use the watchdog framework, as it takes care of range checking.
Guenter
RFC 14/18 MIPS: ar231x: add AR2315 PCI host controller driver
In reply to Sergey RyazanovAdd PCI host controller driver and DMA address calculation hook.
--- arch/mips/ar231x/Kconfig | 7 + arch/mips/ar231x/ar2315.c | 19 ++ arch/mips/include/asm/mach-ar231x/ar2315_regs.h | 24 ++ arch/mips/include/asm/mach-ar231x/dma-coherence.h | 18 +- arch/mips/pci/Makefile | 1 + arch/mips/pci/pci-ar2315.c | 345 ++++++++++++++++++++++ 6 files changed, 411 insertions(+), 3 deletions(-) create mode 100644 arch/mips/pci/pci-ar2315.c
arch/mips/ar231x/Kconfig +7 -0
@@ -9,3 +9,10 @@ config SOC_AR2315 depends on AR231X select GPIO_AR2315 default y + +config PCI_AR2315 + bool "Atheros AR2315 PCI controller support" + depends on SOC_AR2315 + select HW_HAS_PCI + select PCI + default y
arch/mips/ar231x/ar2315.c +19 -0
@@ -103,6 +103,11 @@ static void ar2315_irq_dispatch(void) {u32 pending =read_c0_status () &read_c0_cause (); +#ifdef CONFIG_PCI_AR2315 +if (pending &CAUSEF_IP5 ) +do_IRQ (AR2315_IRQ_LCBUS_PCI ); + else +#endif if (pending &CAUSEF_IP2 )do_IRQ (AR2315_IRQ_MISC );else if (pending &CAUSEF_IP7 )
@@ -355,3 +360,17 @@ void __init ar2315_prom_init(void) ar231x_board.devid = devid; } +#ifdef CONFIG_PCI_AR2315 +static int __init ar2315_pci_init (void ) +{ +struct platform_device *pdev; + +if (!is_2315 () || ar231x_devtype !=DEV_TYPE_AR2315 ) +return -ENODEV ; + + pdev =platform_device_register_simple ("ar2315-pci" ,-1 ,NULL ,0 ); + +return pdev ?0 : -ENODEV ; +} +arch_initcall (ar2315_pci_init); +#endif
arch/mips/include/asm/mach-ar231x/ar2315_regs.h +24 -0
@@ -38,6 +38,16 @@#define AR2315_MISC_IRQ_COUNT 9/* +* PCI interrupts, which share IP5 +* Keep ordered according to AR2315_PCI_INT_XXX bits +*/ +#define AR2315_PCI_IRQ_BASE 0x50 +#define AR2315_PCI_IRQ_EXT (AR2315_PCI_IRQ_BASE+0) +#define AR2315_PCI_IRQ_ABORT (AR2315_PCI_IRQ_BASE+1) +#define AR2315_PCI_IRQ_COUNT 2 +#define AR2315_PCI_IRQ_SHIFT 25/* in AR2315_PCI_INT_STATUS */ + +/* * Address map */ #define AR2315_SPI_READ 0x08000000/* SPI flash */
@@ -554,4 +564,18 @@#define AR2315_IRCFG_SEQ_END_WIN_THRESH 0x001f0000#define AR2315_IRCFG_NUM_BACKOFF_WORDS 0x01e00000 +/* +* We need some arbitrary non-zero value to be programmed to the BAR1 register +* of PCI host controller to enable DMA. The same value should be used as the +* offset to calculate the physical address of DMA buffer for PCI devices. +*/ +#define AR2315_PCI_HOST_SDRAM_BASEADDR 0x20000000 + +/* ??? access BAR */ +#define AR2315_PCI_HOST_MBAR0 0x10000000 +/* RAM access BAR */ +#define AR2315_PCI_HOST_MBAR1 AR2315_PCI_HOST_SDRAM_BASEADDR +/* ??? access BAR */ +#define AR2315_PCI_HOST_MBAR2 0x30000000 +#endif /* __ASM_MACH_AR231X_AR2315_REGS_H */
arch/mips/include/asm/mach-ar231x/dma-coherence.h +15 -3
@@ -11,23 +11,35 @@#define __ASM_MACH_AR231X_DMA_COHERENCE_H#include <linux/device.h> +#include <ar2315_regs.h> + +static inline dma_addr_t ar231x_dev_offset (struct device *dev) +{ +#ifdef CONFIG_PCI +extern struct bus_type pci_bus_type; + +if (dev && dev->bus == &pci_bus_type) +return AR2315_PCI_HOST_SDRAM_BASEADDR ; +#endif +return 0 ; +}static inline dma_addr_t plat_map_dma_mem (struct device *dev,void *addr,size_t size) { -return virt_to_phys (addr); +return virt_to_phys (addr) +ar231x_dev_offset (dev); }static inline dma_addr_t plat_map_dma_mem_page (struct device *dev,struct page *page) { -return page_to_phys (page); +return page_to_phys (page) +ar231x_dev_offset (dev); }static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) { -return dma_addr; +return dma_addr -ar231x_dev_offset (dev); } static inline void
arch/mips/pci/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_BCM47XX) += pci-bcm47xx.o obj-$(CONFIG_BCM63XX) += pci-bcm63xx.o fixup-bcm63xx.o \ ops-bcm63xx.o obj-$(CONFIG_MIPS_ALCHEMY) += pci-alchemy.o +obj-$(CONFIG_PCI_AR2315) += pci-ar2315.o obj-$(CONFIG_SOC_AR71XX) += pci-ar71xx.o obj-$(CONFIG_PCI_AR724X) += pci-ar724x.o obj-$(CONFIG_MIPS_PCI_VIRTIO) += pci-virtio-guest.o
arch/mips/pci/pci-ar2315.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
1.8.1.5
RFC 15/18 MIPS: ar231x: add Wireless device support
In reply to Sergey RyazanovAtheros AR5312 and AR2315 both have a builtin wireless device, this patch add helper code and register platform device for all supported WiSoCs.
--- arch/mips/ar231x/ar2315.c | 8 ++++--- arch/mips/ar231x/ar5312.c | 28 +++++++++++++++++++++++- arch/mips/ar231x/devices.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++ arch/mips/ar231x/devices.h | 1 + 4 files changed, 87 insertions(+), 4 deletions(-)
arch/mips/ar231x/ar2315.c +5 -3
@@ -103,12 +103,13 @@ static void ar2315_irq_dispatch(void) {u32 pending =read_c0_status () &read_c0_cause (); +if (pending &CAUSEF_IP3 ) +do_IRQ (AR2315_IRQ_WLAN0 );#ifdef CONFIG_PCI_AR2315 -if (pending &CAUSEF_IP5 ) + else if (pending & CAUSEF_IP5) do_IRQ(AR2315_IRQ_LCBUS_PCI); - else#endif -if (pending &CAUSEF_IP2 ) + else if (pending & CAUSEF_IP2) do_IRQ(AR2315_IRQ_MISC); else if (pending & CAUSEF_IP7) do_IRQ(AR231X_IRQ_CPU_CLOCK);
@@ -223,6 +224,7 @@ void __init ar2315_init_devices(void)platform_device_register (&ar2315_gpio);platform_device_register (&ar2315_wdt);platform_device_register (&ar2315_spiflash); +ar231x_add_wmac (0 ,AR2315_WLAN0 ,AR2315_IRQ_WLAN0 ); }static void ar2315_restart (char *command)
arch/mips/ar231x/ar5312.c +27 -1
@@ -95,7 +95,11 @@ static void ar5312_irq_dispatch(void) {u32 pending =read_c0_status () &read_c0_cause (); -if (pending &CAUSEF_IP6 ) +if (pending &CAUSEF_IP2 ) +do_IRQ (AR5312_IRQ_WLAN0 ); +else if (pending &CAUSEF_IP5 ) +do_IRQ (AR5312_IRQ_WLAN1 ); +else if (pending &CAUSEF_IP6 )do_IRQ (AR5312_IRQ_MISC );else if (pending &CAUSEF_IP7 )do_IRQ (AR231X_IRQ_CPU_CLOCK );
@@ -222,6 +226,28 @@ void __init ar5312_init_devices(void)platform_device_register (&ar5312_physmap_flash);platform_device_register (&ar5312_gpio); + +switch (ar231x_devtype) { +case DEV_TYPE_AR5312 : +if (!ar231x_board.radio) +return ; + +if (!(config->flags &BD_WLAN0 )) +break ; + +ar231x_add_wmac (0 ,AR5312_WLAN0 ,AR5312_IRQ_WLAN0 ); +break ; +case DEV_TYPE_AR2312 : +case DEV_TYPE_AR2313 : +if (!ar231x_board.radio) +return ; +break ; +default : +break ; + } + +if (config->flags &BD_WLAN1 ) +ar231x_add_wmac (1 ,AR5312_WLAN1 ,AR5312_IRQ_WLAN1 ); }static void ar5312_restart (char *command)
arch/mips/ar231x/devices.c +54 -0
72 lines not on this page · raw message
arch/mips/ar231x/devices.h +1 -0
@@ -24,6 +24,7 @@ extern void (*ar231x_irq_dispatch)(void);int ar231x_find_config (const u8 *flash_limit);void ar231x_serial_setup (u32 mapbase,int irq,unsigned int uartclk); +int ar231x_add_wmac (int nr,u32 base,int irq);static inline bool is_2315 (void ) {
Signature · 1 line
1.8.1.5
RFC 16/18 ath5k: correct conditional compilation
In reply to Sergey RyazanovThis code parts should depend on a config symbol defined in the driver instead of arch specific one.
--- drivers/net/wireless/ath/ath5k/ath5k.h | 2 +- drivers/net/wireless/ath/ath5k/base.c | 4 ++-- drivers/net/wireless/ath/ath5k/led.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath5k/ath5k.h +1 -1
@@ -1647,7 +1647,7 @@ static inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah)return &(ath5k_hw_common (ah)->regulatory); } -#ifdef CONFIG_ATHEROS_AR231X +#ifdef CONFIG_ATH5K_AHB #define AR5K_AR2315_PCI_BASE ((void __iomem *)0xb0100000)static inline void __iomem *ath5k_ahb_reg (struct ath5k_hw *ah,u16 reg)
drivers/net/wireless/ath/ath5k/base.c +2 -2
@@ -99,7 +99,7 @@ static int ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan,/* Known SREVs */ static const struct ath5k_srev_name srev_names[] = { -#ifdef CONFIG_ATHEROS_AR231X +#ifdef CONFIG_ATH5K_AHB {"5312" ,AR5K_VERSION_MAC ,AR5K_SREV_AR5312_R2 }, {"5312" ,AR5K_VERSION_MAC ,AR5K_SREV_AR5312_R7 }, { "2313", AR5K_VERSION_MAC, AR5K_SREV_AR2313_R8 },
@@ -142,7 +142,7 @@ static const struct ath5k_srev_name srev_names[] = { { "5413", AR5K_VERSION_RAD, AR5K_SREV_RAD_5413 }, { "5424", AR5K_VERSION_RAD, AR5K_SREV_RAD_5424 }, { "5133", AR5K_VERSION_RAD, AR5K_SREV_RAD_5133 }, -#ifdef CONFIG_ATHEROS_AR231X +#ifdef CONFIG_ATH5K_AHB { "2316", AR5K_VERSION_RAD, AR5K_SREV_RAD_2316 }, { "2317", AR5K_VERSION_RAD, AR5K_SREV_RAD_2317 }, #endif
drivers/net/wireless/ath/ath5k/led.c +2 -2
@@ -162,7 +162,7 @@ int ath5k_init_leds(struct ath5k_hw *ah) {int ret =0 ;struct ieee80211_hw *hw = ah->hw; -#ifndef CONFIG_ATHEROS_AR231X +#ifndef CONFIG_ATH5K_AHB struct pci_dev *pdev = ah->pdev;#endif char name[ATH5K_LED_MAX_NAME_LEN +1 ];
@@ -171,7 +171,7 @@ int ath5k_init_leds(struct ath5k_hw *ah)if (!ah->pdev)return 0 ; -#ifdef CONFIG_ATHEROS_AR231X +#ifdef CONFIG_ATH5K_AHB match =NULL ;#else match =pci_match_id (&ath5k_led_devices[0 ], pdev);
Signature · 1 line
1.8.1.5
RFC 17/18 ath5k: update dependency
In reply to Sergey RyazanovRename the ATHEROS_AR231X config symbol to AR231X.
--- drivers/net/wireless/ath/ath5k/Kconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath5k/Kconfig +5 -5
@@ -1,13 +1,13 @@ config ATH5K tristate "Atheros 5xxx wireless cards support" - depends on (PCI || ATHEROS_AR231X) && MAC80211 + depends on (PCI || AR231X) && MAC80211 select ATH_COMMON select MAC80211_LEDS select LEDS_CLASS select NEW_LEDS select AVERAGE - select ATH5K_AHB if (ATHEROS_AR231X && !PCI) - select ATH5K_PCI if (!ATHEROS_AR231X && PCI) + select ATH5K_AHB if (AR231X && !PCI) + select ATH5K_PCI if (!AR231X && PCI) ---help--- This module adds support for wireless adapters based on Atheros 5xxx chipset.
@@ -54,14 +54,14 @@ config ATH5K_TRACER config ATH5K_AHB bool "Atheros 5xxx AHB bus support" - depends on (ATHEROS_AR231X && !PCI) + depends on (AR231X && !PCI) ---help--- This adds support for WiSoC type chipsets of the 5xxx Atheros family. config ATH5K_PCI bool "Atheros 5xxx PCI bus support" - depends on (!ATHEROS_AR231X && PCI) + depends on (!AR231X && PCI) ---help--- This adds support for PCI type chipsets of the 5xxx Atheros family.
Signature · 1 line
1.8.1.5
RFC 18/18 ath5k: correct dependency
In reply to Sergey RyazanovSome of AR231x SoCs (e.g. AR2315) have PCI bus support, so remove !PCI dependency, which block AHB support build.
--- drivers/net/wireless/ath/ath5k/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath5k/Kconfig +3 -3
@@ -6,8 +6,8 @@ config ATH5K select LEDS_CLASS select NEW_LEDS select AVERAGE - select ATH5K_AHB if (AR231X && !PCI) - select ATH5K_PCI if (!AR231X && PCI) + select ATH5K_AHB if AR231X + select ATH5K_PCI if !AR231X ---help--- This module adds support for wireless adapters based on Atheros 5xxx chipset.
@@ -54,7 +54,7 @@ config ATH5K_TRACER config ATH5K_AHB bool "Atheros 5xxx AHB bus support" - depends on (AR231X && !PCI) + depends on AR231X ---help--- This adds support for WiSoC type chipsets of the 5xxx Atheros family.
Signature · 1 line
1.8.1.5