Skip to contentSkip to conversation

MIPS: initial support for the Atheros AR71XX/AR724X/AR913X SoCs

PATCH Superseded Gabor Juhos 9 participants 60 messages Nov 23, 2010 – Dec 9, 2010

Subsystems (8)
USB MIPS HID SPI +4 more subsystems

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover MIPS: initial support for the Atheros AR71XX/AR724X/AR913X SoCs

This patch set contains initial support for the
Atheros AR71XX/AR724X/AR913X SoCs.

Gabor Juhos (18):
MIPS: add initial support for the Atheros AR71XX/AR724X/AR931X SoCs
MIPS: ath79: add GPIOLIB support
MIPS: add generic support for multiple machines within a single
kernel
MIPS: ath79: utilize the MIPS multi-machine support
MIPS: ath79: add initial support for the Atheros PB44 reference board
MIPS: ath79: add common GPIO LEDs device
watchdog: add driver for the Atheros AR71XX/AR724X/AR913X SoCs
MIPS: ath79: add common watchdog device
input: add input driver for polled GPIO buttons
MIPS: ath79: add common GPIO buttons device
spi: add SPI controller driver for the Atheros AR71XX/AR724X/AR913X
SoCs
MIPS: ath79: add common SPI controller device
USB: ehci: add workaround for Synopsys HC bug
USB: ehci: add bus glue for the Atheros AR71XX/AR724X/AR913X SoCs
USB: ohci: add bus glue for the Atheros AR71XX/AR7240 SoCs
MIPS: ath79: add common USB Host Controller device
MIPS: ath79: add initial support for the Atheros AP81 reference board
MIPS: ath79: add common WMAC device for AR913X based boards

 arch/mips/Kbuild.platforms                         |    1 +
 arch/mips/Kconfig                                  |   20 ++
 arch/mips/ath79/Kconfig                            |   60 ++++
 arch/mips/ath79/Makefile                           |   29 ++
 arch/mips/ath79/Platform                           |    7 +
 arch/mips/ath79/common.c                           |  113 ++++++++
 arch/mips/ath79/common.h                           |   67 +++++
 arch/mips/ath79/dev-ar913x-wmac.c                  |   60 ++++
 arch/mips/ath79/dev-ar913x-wmac.h                  |   17 ++
 arch/mips/ath79/dev-common.c                       |   69 +++++
 arch/mips/ath79/dev-common.h                       |   18 ++
 arch/mips/ath79/dev-gpio-buttons.c                 |   58 ++++
 arch/mips/ath79/dev-gpio-buttons.h                 |   23 ++
 arch/mips/ath79/dev-leds-gpio.c                    |   56 ++++
 arch/mips/ath79/dev-leds-gpio.h                    |   21 ++
 arch/mips/ath79/dev-spi.c                          |   38 +++
 arch/mips/ath79/dev-spi.h                          |   22 ++
 arch/mips/ath79/dev-usb.c                          |  192 +++++++++++++
 arch/mips/ath79/dev-usb.h                          |   17 ++
 arch/mips/ath79/early_printk.c                     |   36 +++
 arch/mips/ath79/gpio.c                             |  196 +++++++++++++
 arch/mips/ath79/irq.c                              |  187 +++++++++++++
 arch/mips/ath79/mach-ap81.c                        |   98 +++++++
 arch/mips/ath79/mach-pb44.c                        |  119 ++++++++
 arch/mips/ath79/machtypes.h                        |   23 ++
 arch/mips/ath79/prom.c                             |   57 ++++
 arch/mips/ath79/setup.c                            |  279 +++++++++++++++++++
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h     |  248 +++++++++++++++++
 arch/mips/include/asm/mach-ath79/ath79.h           |   50 ++++
 .../include/asm/mach-ath79/ath79_ehci_platform.h   |   18 ++
 .../include/asm/mach-ath79/ath79_spi_platform.h    |   19 ++
 .../include/asm/mach-ath79/cpu-feature-overrides.h |   56 ++++
 arch/mips/include/asm/mach-ath79/gpio.h            |   26 ++
 arch/mips/include/asm/mach-ath79/irq.h             |   36 +++
 .../include/asm/mach-ath79/kernel-entry-init.h     |   32 +++
 arch/mips/include/asm/mach-ath79/war.h             |   25 ++
 arch/mips/include/asm/mips_machine.h               |   54 ++++
 arch/mips/kernel/Makefile                          |    1 +
 arch/mips/kernel/mips_machine.c                    |   86 ++++++
 arch/mips/kernel/proc.c                            |    7 +-
 arch/mips/kernel/vmlinux.lds.S                     |    7 +
 drivers/input/misc/Kconfig                         |   16 +
 drivers/input/misc/Makefile                        |    1 +
 drivers/input/misc/gpio_buttons.c                  |  232 ++++++++++++++++
 drivers/spi/Kconfig                                |    8 +
 drivers/spi/Makefile                               |    1 +
 drivers/spi/ath79_spi.c                            |  290 +++++++++++++++++++
 drivers/usb/host/Kconfig                           |   16 +
 drivers/usb/host/ehci-ath79.c                      |  176 ++++++++++++
 drivers/usb/host/ehci-hcd.c                        |    5 +
 drivers/usb/host/ehci-q.c                          |    3 +
 drivers/usb/host/ehci.h                            |    1 +
 drivers/usb/host/ohci-ath79.c                      |  162 +++++++++++
 drivers/usb/host/ohci-hcd.c                        |    5 +
 drivers/watchdog/Kconfig                           |    8 +
 drivers/watchdog/Makefile                          |    1 +
 drivers/watchdog/ath79_wdt.c                       |  293 ++++++++++++++++++++
 include/linux/gpio_buttons.h                       |   33 +++
 58 files changed, 3798 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/ath79/Kconfig
 create mode 100644 arch/mips/ath79/Makefile
 create mode 100644 arch/mips/ath79/Platform
 create mode 100644 arch/mips/ath79/common.c
 create mode 100644 arch/mips/ath79/common.h
 create mode 100644 arch/mips/ath79/dev-ar913x-wmac.c
 create mode 100644 arch/mips/ath79/dev-ar913x-wmac.h
 create mode 100644 arch/mips/ath79/dev-common.c
 create mode 100644 arch/mips/ath79/dev-common.h
 create mode 100644 arch/mips/ath79/dev-gpio-buttons.c
 create mode 100644 arch/mips/ath79/dev-gpio-buttons.h
 create mode 100644 arch/mips/ath79/dev-leds-gpio.c
 create mode 100644 arch/mips/ath79/dev-leds-gpio.h
 create mode 100644 arch/mips/ath79/dev-spi.c
 create mode 100644 arch/mips/ath79/dev-spi.h
 create mode 100644 arch/mips/ath79/dev-usb.c
 create mode 100644 arch/mips/ath79/dev-usb.h
 create mode 100644 arch/mips/ath79/early_printk.c
 create mode 100644 arch/mips/ath79/gpio.c
 create mode 100644 arch/mips/ath79/irq.c
 create mode 100644 arch/mips/ath79/mach-ap81.c
 create mode 100644 arch/mips/ath79/mach-pb44.c
 create mode 100644 arch/mips/ath79/machtypes.h
 create mode 100644 arch/mips/ath79/prom.c
 create mode 100644 arch/mips/ath79/setup.c
 create mode 100644 arch/mips/include/asm/mach-ath79/ar71xx_regs.h
 create mode 100644 arch/mips/include/asm/mach-ath79/ath79.h
 create mode 100644 arch/mips/include/asm/mach-ath79/ath79_ehci_platform.h
 create mode 100644 arch/mips/include/asm/mach-ath79/ath79_spi_platform.h
 create mode 100644 arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
 create mode 100644 arch/mips/include/asm/mach-ath79/gpio.h
 create mode 100644 arch/mips/include/asm/mach-ath79/irq.h
 create mode 100644 arch/mips/include/asm/mach-ath79/kernel-entry-init.h
 create mode 100644 arch/mips/include/asm/mach-ath79/war.h
 create mode 100644 arch/mips/include/asm/mips_machine.h
 create mode 100644 arch/mips/kernel/mips_machine.c
 create mode 100644 drivers/input/misc/gpio_buttons.c
 create mode 100644 drivers/spi/ath79_spi.c
 create mode 100644 drivers/usb/host/ehci-ath79.c
 create mode 100644 drivers/usb/host/ohci-ath79.c
 create mode 100644 drivers/watchdog/ath79_wdt.c
 create mode 100644 include/linux/gpio_buttons.h
Signature · 1 line
1.7.2.1
#1 lore raw

PATCH 1/18 MIPS: add initial support for the Atheros AR71XX/AR724X/AR931X SoCs

This patch adds initial support for various Atheros SoCs based on the MIPS 24Kc core. The following models are supported at the moment:

- AR7130
- AR7141
- AR7161
- AR9130
- AR9132
- AR7240
- AR7241
- AR7242

The current patch contains minimal support only, but the resulting kernel can boot into user-space with using of an initramfs image on various boards which are using these SoCs. Support for more built-in devices and individual boards will be implemented in further patches.

---

Changes since RFC:
- the ATH79_DEV_UART Kconfig option is removed, and the URT platform code has been moved into dev-common[ch]

 arch/mips/Kbuild.platforms                         |    1 +
 arch/mips/Kconfig                                  |   15 ++
 arch/mips/ath79/Kconfig                            |   12 +
 arch/mips/ath79/Makefile                           |   18 ++
 arch/mips/ath79/Platform                           |    7 +
 arch/mips/ath79/common.c                           |  113 +++++++++
 arch/mips/ath79/common.h                           |   62 +++++
 arch/mips/ath79/dev-common.c                       |   59 +++++
 arch/mips/ath79/dev-common.h                       |   17 ++
 arch/mips/ath79/early_printk.c                     |   36 +++
 arch/mips/ath79/irq.c                              |  187 ++++++++++++++
 arch/mips/ath79/prom.c                             |   57 +++++
 arch/mips/ath79/setup.c                            |  263 ++++++++++++++++++++
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h     |  207 +++++++++++++++
 arch/mips/include/asm/mach-ath79/ath79.h           |   50 ++++
 .../include/asm/mach-ath79/cpu-feature-overrides.h |   56 ++++
 arch/mips/include/asm/mach-ath79/irq.h             |   36 +++
 .../include/asm/mach-ath79/kernel-entry-init.h     |   32 +++
 arch/mips/include/asm/mach-ath79/war.h             |   25 ++
 19 files changed, 1253 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/Kconfig
 create mode 100644 arch/mips/ath79/Makefile
 create mode 100644 arch/mips/ath79/Platform
 create mode 100644 arch/mips/ath79/common.c
 create mode 100644 arch/mips/ath79/common.h
 create mode 100644 arch/mips/ath79/dev-common.c
 create mode 100644 arch/mips/ath79/dev-common.h
 create mode 100644 arch/mips/ath79/early_printk.c
 create mode 100644 arch/mips/ath79/irq.c
 create mode 100644 arch/mips/ath79/prom.c
 create mode 100644 arch/mips/ath79/setup.c
 create mode 100644 arch/mips/include/asm/mach-ath79/ar71xx_regs.h
 create mode 100644 arch/mips/include/asm/mach-ath79/ath79.h
 create mode 100644 arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h
 create mode 100644 arch/mips/include/asm/mach-ath79/irq.h
 create mode 100644 arch/mips/include/asm/mach-ath79/kernel-entry-init.h
 create mode 100644 arch/mips/include/asm/mach-ath79/war.h
arch/mips/Kbuild.platforms +1 -0
index 78439b8..7ff9b54 100644
@@ -2,6 +2,7 @@
 
 platforms += alchemy
 platforms += ar7
+platforms += ath79
 platforms += bcm47xx
 platforms += bcm63xx
 platforms += cavium-octeon
arch/mips/Kconfig +15 -0
index 7fc6bd1..50d4f5d 100644
@@ -65,6 +65,20 @@ config AR7
 	  Support for the Texas Instruments AR7 System-on-a-Chip
 	  family: TNETD7100, 7200 and 7300.
 
+config ATH79
+	bool "Atheros AR71XX/AR724X/AR913X based boards"
+	select BOOT_RAW
+	select CEVT_R4K
+	select CSRC_R4K
+	select DMA_NONCOHERENT
+	select IRQ_CPU
+	select SYS_HAS_CPU_MIPS32_R2
+	select SYS_HAS_EARLY_PRINTK
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_BIG_ENDIAN
+	help
+	  Support for the Atheros AR71XX/AR724X/AR913X SoCs.
+
 config BCM47XX
 	bool "Broadcom BCM47XX based boards"
 	select CEVT_R4K
@@ -717,6 +731,7 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
 endchoice
 
 source "arch/mips/alchemy/Kconfig"
+source "arch/mips/ath79/Kconfig"
 source "arch/mips/bcm63xx/Kconfig"
 source "arch/mips/jazz/Kconfig"
 source "arch/mips/jz4740/Kconfig"
arch/mips/ath79/Kconfig new file +12 -0
new file mode 100644
index 0000000..50b9334
@@ -0,0 +1,12 @@
+if ATH79
+
+config SOC_AR71XX
+	def_bool n
+
+config SOC_AR724X
+	def_bool n
+
+config SOC_AR913X
+	def_bool n
+
+endif
arch/mips/ath79/Makefile new file +18 -0
new file mode 100644
index 0000000..b4ec9c2
@@ -0,0 +1,18 @@
+#
+# Makefile for the Atheros AR71XX/AR724X/AR913X specific parts of the kernel
+#
+# Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+# Copyright (C) 2008 Imre Kaloz <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+
+obj-y	:= prom.o setup.o irq.o common.o
+
+obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
+
+#
+# Devices
+#
+obj-y					+= dev-common.o
arch/mips/ath79/Platform new file +7 -0
new file mode 100644
index 0000000..2bd6636
@@ -0,0 +1,7 @@
+#
+# Atheros AR71xx/AR724x/AR913x
+#
+
+platform-$(CONFIG_ATH79)	+= ath79/
+cflags-$(CONFIG_ATH79)		+= -I$(srctree)/arch/mips/include/asm/mach-ath79
+load-$(CONFIG_ATH79)		= 0xffffffff80060000
arch/mips/ath79/common.c new file +113 -0

113 lines not on this page · raw message

arch/mips/ath79/common.h new file +62 -0

62 lines not on this page · raw message

arch/mips/ath79/dev-common.c new file +59 -0

59 lines not on this page · raw message

arch/mips/ath79/dev-common.h new file +17 -0
new file mode 100644
index 0000000..1cec894
@@ -0,0 +1,17 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X common devices
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_DEV_COMMON_H
+#define _ATH79_DEV_COMMON_H
+
+void ath79_register_uart(void) __init;
+
+#endif /* _ATH79_DEV_COMMON_H */
arch/mips/ath79/early_printk.c new file +36 -0
new file mode 100644
index 0000000..7499b0e
@@ -0,0 +1,36 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X SoC early printk support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/io.h>
+#include <linux/serial_reg.h>
+#include <asm/addrspace.h>
+
+#include <asm/mach-ath79/ar71xx_regs.h>
+
+static inline void prom_wait_thre(void __iomem *base)
+{
+	u32 lsr;
+
+	do {
+		lsr = __raw_readl(base + UART_LSR * 4);
+		if (lsr & UART_LSR_THRE)
+			break;
+	} while (1);
+}
+
+void prom_putchar(unsigned char ch)
+{
+	void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));
+
+	prom_wait_thre(base);
+	__raw_writel(ch, base + UART_TX * 4);
+	prom_wait_thre(base);
+}
arch/mips/ath79/irq.c new file +187 -0

187 lines not on this page · raw message

arch/mips/ath79/prom.c new file +57 -0

57 lines not on this page · raw message

arch/mips/ath79/setup.c new file +263 -0

263 lines not on this page · raw message

arch/mips/include/asm/mach-ath79/ar71xx_regs.h new file +207 -0

207 lines not on this page · raw message

arch/mips/include/asm/mach-ath79/ath79.h new file +50 -0

50 lines not on this page · raw message

arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h new file +56 -0

56 lines not on this page · raw message

arch/mips/include/asm/mach-ath79/irq.h new file +36 -0
new file mode 100644
index 0000000..189bc6e
@@ -0,0 +1,36 @@
+/*
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+#ifndef __ASM_MACH_ATH79_IRQ_H
+#define __ASM_MACH_ATH79_IRQ_H
+
+#define MIPS_CPU_IRQ_BASE	0
+#define NR_IRQS			16
+
+#define ATH79_MISC_IRQ_BASE	8
+#define ATH79_MISC_IRQ_COUNT	8
+
+#define ATH79_CPU_IRQ_IP2	(MIPS_CPU_IRQ_BASE + 2)
+#define ATH79_CPU_IRQ_USB	(MIPS_CPU_IRQ_BASE + 3)
+#define ATH79_CPU_IRQ_GE0	(MIPS_CPU_IRQ_BASE + 4)
+#define ATH79_CPU_IRQ_GE1	(MIPS_CPU_IRQ_BASE + 5)
+#define ATH79_CPU_IRQ_MISC	(MIPS_CPU_IRQ_BASE + 6)
+#define ATH79_CPU_IRQ_TIMER	(MIPS_CPU_IRQ_BASE + 7)
+
+#define ATH79_MISC_IRQ_TIMER	(ATH79_MISC_IRQ_BASE + 0)
+#define ATH79_MISC_IRQ_ERROR	(ATH79_MISC_IRQ_BASE + 1)
+#define ATH79_MISC_IRQ_GPIO	(ATH79_MISC_IRQ_BASE + 2)
+#define ATH79_MISC_IRQ_UART	(ATH79_MISC_IRQ_BASE + 3)
+#define ATH79_MISC_IRQ_WDOG	(ATH79_MISC_IRQ_BASE + 4)
+#define ATH79_MISC_IRQ_PERFC	(ATH79_MISC_IRQ_BASE + 5)
+#define ATH79_MISC_IRQ_OHCI	(ATH79_MISC_IRQ_BASE + 6)
+#define ATH79_MISC_IRQ_DMA	(ATH79_MISC_IRQ_BASE + 7)
+
+#include_next <irq.h>
+
+#endif /* __ASM_MACH_ATH79_IRQ_H */
arch/mips/include/asm/mach-ath79/kernel-entry-init.h new file +32 -0
new file mode 100644
index 0000000..d8d046b
@@ -0,0 +1,32 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X specific kernel entry setup
+ *
+ *  Copyright (C) 2009 Gabor Juhos <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+#ifndef __ASM_MACH_ATH79_KERNEL_ENTRY_H
+#define __ASM_MACH_ATH79_KERNEL_ENTRY_H
+
+	/*
+	 * Some bootloaders set the 'Kseg0 coherency algorithm' to
+	 * 'Cacheable, noncoherent, write-through, no write allocate'
+	 * and this cause performance issues. Let's go and change it to
+	 * 'Cacheable, noncoherent, write-back, write allocate'
+	 */
+	.macro	kernel_entry_setup
+	mfc0	t0, CP0_CONFIG
+	li	t1, ~CONF_CM_CMASK
+	and	t0, t1
+	ori	t0, CONF_CM_CACHABLE_NONCOHERENT
+	mtc0	t0, CP0_CONFIG
+	nop
+	.endm
+
+	.macro	smp_slave_setup
+	.endm
+
+#endif /* __ASM_MACH_ATH79_KERNEL_ENTRY_H */
arch/mips/include/asm/mach-ath79/war.h new file +25 -0
new file mode 100644
index 0000000..323d9f1
@@ -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) 2002, 2004, 2007 by Ralf Baechle <[email protected]>
+ */
+#ifndef __ASM_MACH_ATH79_WAR_H
+#define __ASM_MACH_ATH79_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_ATH79_WAR_H */
Signature · 1 line
1.7.2.1
#2 lore raw

PATCH 2/18 MIPS: ath79: add GPIOLIB support

In reply to Gabor Juhos

This patch implements generic GPIO routines for the built-in GPIO controllers of the Atheros AR71XX/AR724X/AR913X SoCs.

---

Changes since RFC: ---

 arch/mips/Kconfig                              |    1 +
 arch/mips/ath79/Makefile                       |    2 +-
 arch/mips/ath79/common.h                       |    5 +
 arch/mips/ath79/gpio.c                         |  196 ++++++++++++++++++++++++
 arch/mips/ath79/setup.c                        |    2 +-
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h |   21 +++
 arch/mips/include/asm/mach-ath79/gpio.h        |   26 +++
 7 files changed, 251 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/ath79/gpio.c
 create mode 100644 arch/mips/include/asm/mach-ath79/gpio.h
arch/mips/Kconfig +1 -0
index 50d4f5d..ec69df5 100644
@@ -67,6 +67,7 @@ config AR7
 
 config ATH79
 	bool "Atheros AR71XX/AR724X/AR913X based boards"
+	select ARCH_REQUIRE_GPIOLIB
 	select BOOT_RAW
 	select CEVT_R4K
 	select CSRC_R4K
arch/mips/ath79/Makefile +1 -1
index b4ec9c2..facbb70 100644
@@ -8,7 +8,7 @@
 # under the terms of the GNU General Public License version 2 as published
 # by the Free Software Foundation.
 
-obj-y	:= prom.o setup.o irq.o common.o
+obj-y	:= prom.o setup.o irq.o common.o gpio.o
 
 obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
 
arch/mips/ath79/common.h +5 -0
index 62d7503..041ca7e 100644
@@ -59,4 +59,9 @@ static inline int soc_is_ar913x(void)
 		ath79_soc == ATH79_SOC_AR9132);
 }
 
+void ath79_gpio_function_enable(u32 mask);
+void ath79_gpio_function_disable(u32 mask);
+void ath79_gpio_function_setup(u32 set, u32 clear);
+void ath79_gpio_init(void) __init;
+
 #endif /* __ATH79_COMMON_H */
arch/mips/ath79/gpio.c new file +196 -0

196 lines not on this page · raw message

arch/mips/ath79/setup.c +1 -1
index ee620e1..dbbf050 100644
@@ -230,7 +230,6 @@ void __init plat_mem_setup(void)
 					   AR71XX_RESET_SIZE);
 	ath79_pll_base = ioremap_nocache(AR71XX_PLL_BASE,
 					 AR71XX_PLL_SIZE);
-
 	ath79_ddr_base = ioremap_nocache(AR71XX_DDR_CTRL_BASE,
 					 AR71XX_DDR_CTRL_SIZE);
 
@@ -256,6 +255,7 @@ void __init plat_time_init(void)
 
 static int __init ath79_setup(void)
 {
+	ath79_gpio_init();
 	ath79_register_uart();
 	return 0;
 }
arch/mips/include/asm/mach-ath79/ar71xx_regs.h +21 -0
index 5a9e5e1..7f2933d 100644
@@ -25,6 +25,8 @@
 #define AR71XX_DDR_CTRL_SIZE	0x100
 #define AR71XX_UART_BASE	(AR71XX_APB_BASE + 0x00020000)
 #define AR71XX_UART_SIZE	0x100
+#define AR71XX_GPIO_BASE        (AR71XX_APB_BASE + 0x00040000)
+#define AR71XX_GPIO_SIZE        0x100
 #define AR71XX_PLL_BASE		(AR71XX_APB_BASE + 0x00050000)
 #define AR71XX_PLL_SIZE		0x100
 #define AR71XX_RESET_BASE	(AR71XX_APB_BASE + 0x00060000)
@@ -204,4 +206,23 @@
 #define AR71XX_SPI_IOC_CS_ALL	(AR71XX_SPI_IOC_CS0 | AR71XX_SPI_IOC_CS1 | \
 				 AR71XX_SPI_IOC_CS2)
 
+/*
+ * GPIO block
+ */
+#define AR71XX_GPIO_REG_OE		0x00
+#define AR71XX_GPIO_REG_IN		0x04
+#define AR71XX_GPIO_REG_OUT		0x08
+#define AR71XX_GPIO_REG_SET		0x0c
+#define AR71XX_GPIO_REG_CLEAR		0x10
+#define AR71XX_GPIO_REG_INT_MODE	0x14
+#define AR71XX_GPIO_REG_INT_TYPE	0x18
+#define AR71XX_GPIO_REG_INT_POLARITY	0x1c
+#define AR71XX_GPIO_REG_INT_PENDING	0x20
+#define AR71XX_GPIO_REG_INT_ENABLE	0x24
+#define AR71XX_GPIO_REG_FUNC		0x28
+
+#define AR71XX_GPIO_COUNT		16
+#define AR724X_GPIO_COUNT		18
+#define AR913X_GPIO_COUNT		22
+
 #endif /* __ASM_MACH_AR71XX_REGS_H */
arch/mips/include/asm/mach-ath79/gpio.h new file +26 -0
new file mode 100644
index 0000000..60dcb62
@@ -0,0 +1,26 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X GPIO API definitions
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#ifndef __ASM_MACH_ATH79_GPIO_H
+#define __ASM_MACH_ATH79_GPIO_H
+
+#define ARCH_NR_GPIOS	64
+#include <asm-generic/gpio.h>
+
+int gpio_to_irq(unsigned gpio);
+int irq_to_gpio(unsigned irq);
+int gpio_get_value(unsigned gpio);
+void gpio_set_value(unsigned gpio, int value);
+
+#define gpio_cansleep	__gpio_cansleep
+
+#endif /* __ASM_MACH_ATH79_GPIO_H */
Signature · 1 line
1.7.2.1
#3 lore raw

PATCH 3/18 MIPS: add generic support for multiple machines within a single kernel

In reply to Gabor Juhos

This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet.

---

Changes since RFC: ---

 arch/mips/Kconfig                    |    3 +
 arch/mips/include/asm/mips_machine.h |   54 +++++++++++++++++++++
 arch/mips/kernel/Makefile            |    1 +
 arch/mips/kernel/mips_machine.c      |   86 ++++++++++++++++++++++++++++++++++
 arch/mips/kernel/proc.c              |    7 ++-
 arch/mips/kernel/vmlinux.lds.S       |    7 +++
 6 files changed, 157 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/include/asm/mips_machine.h
 create mode 100644 arch/mips/kernel/mips_machine.c
arch/mips/Kconfig +3 -0
index ec69df5..307c2e4 100644
@@ -899,6 +899,9 @@ config MIPS_DISABLE_OBSOLETE_IDE
 config SYNC_R4K
 	bool
 
+config MIPS_MACHINE
+	def_bool n
+
 config NO_IOPORT
 	def_bool n
 
arch/mips/include/asm/mips_machine.h new file +54 -0

54 lines not on this page · raw message

arch/mips/kernel/Makefile +1 -0
index 22b2e0e..3977397 100644
@@ -95,6 +95,7 @@ obj-$(CONFIG_GPIO_TXX9)		+= gpio_txx9.o
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_SPINLOCK_TEST)	+= spinlock_test.o
+obj-$(CONFIG_MIPS_MACHINE)	+= mips_machine.o
 
 obj-$(CONFIG_OF)		+= prom.o
 
arch/mips/kernel/mips_machine.c new file +86 -0

86 lines not on this page · raw message

arch/mips/kernel/proc.c +6 -1
index 26109c4..4195abb 100644
@@ -12,6 +12,7 @@
 #include <asm/cpu-features.h>
 #include <asm/mipsregs.h>
 #include <asm/processor.h>
+#include <asm/mips_machine.h>
 
 unsigned int vced_count, vcei_count;
 
@@ -31,8 +32,12 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	/*
 	 * For the first processor also print the system type
 	 */
-	if (n == 0)
+	if (n == 0) {
 		seq_printf(m, "system type\t\t: %s\n", get_system_type());
+		if (mips_get_machine_name())
+			seq_printf(m, "machine\t\t\t: %s\n",
+				   mips_get_machine_name());
+	}
 
 	seq_printf(m, "processor\t\t: %ld\n", n);
 	sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",
arch/mips/kernel/vmlinux.lds.S +7 -0
index f25df73..570607b 100644
@@ -98,6 +98,13 @@ SECTIONS
 	INIT_TEXT_SECTION(PAGE_SIZE)
 	INIT_DATA_SECTION(16)
 
+	. = ALIGN(4);
+	.mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
+		__mips_machines_start = .;
+		*(.mips.machines.init)
+		__mips_machines_end = .;
+	}
+
 	/* .exit.text is discarded at runtime, not link time, to deal with
 	 * references from .rodata
 	 */
Signature · 1 line
1.7.2.1
#4 lore raw

Re: [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel

Hi,

Quoted 4 lines · Gabor Juhos

This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet.

Is this the way `arch/mips' wants to go to support multiple machine within a same kernel image ? Flattened Device Tree is the other way to achieve that. I remind the latter being proposed by Felix Fietkau on #openwrt.

Thanks,
- Arnaud

Quoted 242 lines

---

Changes since RFC: ---

 arch/mips/Kconfig                    |    3 + arch/mips/include/asm/mips_machine.h |   54 +++++++++++++++++++++ arch/mips/kernel/Makefile            |    1 + arch/mips/kernel/mips_machine.c      |   86 ++++++++++++++++++++++++++++++++++ arch/mips/kernel/proc.c              |    7 ++- arch/mips/kernel/vmlinux.lds.S       |    7 +++

 6 files changed, 157 insertions(+), 1 deletions(-)

 create mode 100644 arch/mips/include/asm/mips_machine.h create mode 100644 arch/mips/kernel/mips_machine.c

arch/mips/Kconfig +0 -0
index ec69df5..307c2e4 100644
@@ -899,6 +899,9 @@ config MIPS_DISABLE_OBSOLETE_IDE

 config SYNC_R4K
       bool

arch/mips/Kconfig +3 -0
+config MIPS_MACHINE
+       def_bool n
+

 config NO_IOPORT
       def_bool n

arch/mips/include/asm/mips_machine.h new file +54 -0
new file mode 100644
index 0000000..363bb35
@@ -0,0 +1,54 @@
+/*
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#ifndef __ASM_MIPS_MACHINE_H
+#define __ASM_MIPS_MACHINE_H
+
+#include <linux/init.h>
+#include <linux/stddef.h>
+
+#include <asm/bootinfo.h>
+
+struct mips_machine {
+       unsigned long           mach_type;
+       const char              *mach_id;
+       const char              *mach_name;
+       void                    (*mach_setup)(void);
+};
+
+#define MIPS_MACHINE(_type, _id, _name, _setup)                        \
+static const char machine_name_##_type[] __initconst           \
+                       __aligned(1) = _name;                   \
+static const char machine_id_##_type[] __initconst             \
+                       __aligned(1) = _id;                     \
+static struct mips_machine machine_##_type                     \
+               __used __section(.mips.machines.init) =         \
+{                                                              \
+       .mach_type      = _type,                                \
+       .mach_id        = machine_id_##_type,                   \
+       .mach_name      = machine_name_##_type,                 \
+       .mach_setup     = _setup,                               \
+};
+
+extern long __mips_machines_start;
+extern long __mips_machines_end;
+
+#ifdef CONFIG_MIPS_MACHINE
+int  mips_machtype_setup(char *id) __init;
+void mips_machine_setup(void) __init;
+void mips_set_machine_name(const char *name) __init;
+char *mips_get_machine_name(void);
+#else
+static inline int mips_machtype_setup(char *id) { return 1; }
+static inline void mips_machine_setup(void) { }
+static inline void mips_set_machine_name(const char *name) { }
+static inline char *mips_get_machine_name(void) { return NULL; }
+#endif /* CONFIG_MIPS_MACHINE */
+
+#endif /* __ASM_MIPS_MACHINE_H */
arch/mips/kernel/Makefile +0 -0
index 22b2e0e..3977397 100644
@@ -95,6 +95,7 @@ obj-$(CONFIG_GPIO_TXX9)               += gpio_txx9.o

 obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o obj-$(CONFIG_SPINLOCK_TEST)    += spinlock_test.o +obj-$(CONFIG_MIPS_MACHINE)     += mips_machine.o

 obj-$(CONFIG_OF)               += prom.o

arch/mips/kernel/mips_machine.c new file +86 -0
new file mode 100644
index 0000000..411a058
@@ -0,0 +1,86 @@
+/*
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ *
+ */
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include <asm/mips_machine.h>
+
+static struct mips_machine *mips_machine __initdata;
+static char *mips_machine_name = "Unknown";
+
+#define for_each_machine(mach) \
+       for ((mach) = (struct mips_machine *)&__mips_machines_start; \
+            (mach) && \
+            (unsigned long)(mach) < (unsigned long)&__mips_machines_end; \
+            (mach)++)
+
+__init void mips_set_machine_name(const char *name)
+{
+       char *p;
+
+       if (name == NULL)
+               return;
+
+       p = kstrdup(name, GFP_KERNEL);
+       if (!p)
+               pr_err("MIPS: no memory for machine_name\n");
+
+       mips_machine_name = p;
+}
+
+char *mips_get_machine_name(void)
+{
+       return mips_machine_name;
+}
+
+__init int mips_machtype_setup(char *id)
+{
+       struct mips_machine *mach;
+
+       for_each_machine(mach) {
+               if (mach->mach_id == NULL)
+                       continue;
+
+               if (strcmp(mach->mach_id, id) == 0) {
+                       mips_machtype = mach->mach_type;
+                       return 0;
+               }
+       }
+
+       pr_err("MIPS: no machine found for id '%s', supported machines:\n", id);
+       pr_err("%-24s %s\n", "id", "name");
+       for_each_machine(mach)
+               pr_err("%-24s %s\n", mach->mach_id, mach->mach_name);
+
+       return 1;
+}
+
+__setup("machtype=", mips_machtype_setup);
+
+__init void mips_machine_setup(void)
+{
+       struct mips_machine *mach;
+
+       for_each_machine(mach) {
+               if (mips_machtype == mach->mach_type) {
+                       mips_machine = mach;
+                       break;
+               }
+       }
+
+       if (!mips_machine)
+               return;
+
+       mips_set_machine_name(mips_machine->mach_name);
+       pr_info("MIPS: machine is %s\n", mips_machine_name);
+
+       if (mips_machine->mach_setup)
+               mips_machine->mach_setup();
+}
arch/mips/kernel/proc.c +6 -1
index 26109c4..4195abb 100644
@@ -12,6 +12,7 @@
  #include <asm/cpu-features.h>
  #include <asm/mipsregs.h>
  #include <asm/processor.h>
+#include <asm/mips_machine.h>
 
  unsigned int vced_count, vcei_count;
 
@@ -31,8 +32,12 @@ static int show_cpuinfo(struct seq_file *m, void *v)
        /*
         * For the first processor also print the system type
         */
-       if (n == 0)
+       if (n == 0) {
                seq_printf(m, "system type\t\t: %s\n", get_system_type());
+               if (mips_get_machine_name())
+                       seq_printf(m, "machine\t\t\t: %s\n",
+                                  mips_get_machine_name());
+       }
 
        seq_printf(m, "processor\t\t: %ld\n", n);
        sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",
arch/mips/kernel/vmlinux.lds.S +7 -1
index f25df73..570607b 100644
@@ -98,6 +98,13 @@ SECTIONS
        INIT_TEXT_SECTION(PAGE_SIZE)
        INIT_DATA_SECTION(16)
 
+       . = ALIGN(4);
+       .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) {
+               __mips_machines_start = .;
+               *(.mips.machines.init)
+               __mips_machines_end = .;
+       }
+
        /* .exit.text is discarded at runtime, not link time, to deal with
         * references from .rodata
         */
--

1.7.2.1

#5 lore raw

Re: [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel

Quoted 11 lines · Arnaud Lacombe

Hi,

Quoted 4 lines · Gabor Juhos

This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet.

Is this the way `arch/mips' wants to go to support multiple machine within a same kernel image ? Flattened Device Tree is the other way to achieve that. I remind the latter being proposed by Felix Fietkau on #openwrt.

We either do this now or later. If now it means more work and we'd have to wait until the work is done. If no one is working on it right now it seems easier to submit this as is for now and later get the port done to the device tree model.

Luis

#6 lore raw

Re: [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel

In reply to Arnaud Lacombe

Hi Arnaud,

Quoted 7 lines · Gabor Juhos
Quoted 4 lines

This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet.

Is this the way `arch/mips' wants to go to support multiple machine within a same kernel image ?

I don't know yet what will be the chosen way.

Quoted 2 lines

Flattened Device Tree is the other way to achieve that. I remind the latter being proposed by Felix Fietkau on #openwrt.

FDT makes sense when the bootloader supports that. FDT makes sense when the bootloader supports that, but i'm not aware of any AR71xx/AR724x/AR913x based board which has such bootloader. Additionally, the device-tree support for MIPS has been added only recently and none of the existing MIPS boards are using that yet AFAIK. If that will be widely used we can consider to switch to that later.

Regards,
Gabor

#7 lore raw

Re: [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel

Quoted 12 lines · Gabor Juhos

Hi Arnaud,

Quoted 7 lines · Gabor Juhos
Quoted 4 lines

This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet.

Is this the way `arch/mips' wants to go to support multiple machine within a same kernel image ?

I don't know yet what will be the chosen way.

Quoted 8 lines
Quoted 2 lines

Flattened Device Tree is the other way to achieve that. I remind the latter being proposed by Felix Fietkau on #openwrt.

FDT makes sense when the bootloader supports that. FDT makes sense when the bootloader supports that, but i'm not aware of any AR71xx/AR724x/AR913x based board which has such bootloader. Additionally, the device-tree support for MIPS has been added only recently and none of the existing MIPS boards are using that yet AFAIK. If that will be widely used we can consider to switch to that later.

We don't need boot loader support, we can make a simple loader stub that passes the FDT data to the kernel. It would certainly be better than our current cmdline hack ;)
I think using FDT would save us a lot of maintenance work, as we wouldn't have to change the kernel for every single new board that we add support for.

- Felix

#8 lore raw

Re: [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel

Quoted 21 lines · Felix Fietkau
Quoted 12 lines · Gabor Juhos

Hi Arnaud,

Quoted 7 lines · Gabor Juhos
Quoted 4 lines

This patch adds a generic solution to support multiple machines based on a given SoC within a single kernel image. It is implemented already for several other architectures but MIPS has no generic support for that yet.

Is this the way `arch/mips' wants to go to support multiple machine within a same kernel image ?

I don't know yet what will be the chosen way.

Quoted 8 lines
Quoted 2 lines

Flattened Device Tree is the other way to achieve that. I remind the latter being proposed by Felix Fietkau on #openwrt.

FDT makes sense when the bootloader supports that. FDT makes sense when the bootloader supports that, but i'm not aware of any AR71xx/AR724x/AR913x based board which has such bootloader. Additionally, the device-tree support for MIPS has been added only recently and none of the existing MIPS boards are using that yet AFAIK. If that will be widely used we can consider to switch to that later.

Quoted 7 lines

We don't need boot loader support, we can make a simple loader stub that passes the FDT data to the kernel. It would certainly be better than our current cmdline hack ;)
I think using FDT would save us a lot of maintenance work, as we wouldn't have to change the kernel for every single new board that we add support for.

For what it's worth, the FDT support in the kernel is almost completely generic. The appropriate hooks are already in the mips archetecture support, but most of the contents of arch/mips/kernel/prom.c will likely need to be moved to chip/board specific files.

Over the next few weeks I plan on sending out patches to the cavium-octeon support to convert it to use the FDT. So I don't think it is out of the question that other chips would start to use it as well.

David Daney

#9 lore raw

Re: [PATCH 03/18] MIPS: add generic support for multiple machines within a single kernel

Quoted 10 lines · David Daney

For what it's worth, the FDT support in the kernel is almost completely generic. The appropriate hooks are already in the mips archetecture support, but most of the contents of arch/mips/kernel/prom.c will likely need to be moved to chip/board specific files.

Over the next few weeks I plan on sending out patches to the cavium-octeon support to convert it to use the FDT. So I don't think it is out of the question that other chips would start to use it as well.

I'm willing to accept this patch because DT is still being introduced into the kernel. It's new, it's not entirely trivial and it will take some time until everybody is up to speed and I just can't stall new submissions until that changes. Even though this is a patch which we actually don't want ...

So queued for 2.6.38. Thanks!

Ralf

#10 lore raw

PATCH 4/18 MIPS: ath79: utilize the MIPS multi-machine support

In reply to Gabor Juhos

---

Changes since RFC: ---

 arch/mips/Kconfig           |    1 +
 arch/mips/ath79/machtypes.h |   21 +++++++++++++++++++++
 arch/mips/ath79/setup.c     |   15 +++++++++++++++
 3 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/machtypes.h
arch/mips/Kconfig +1 -0
index 307c2e4..047b8f7 100644
@@ -73,6 +73,7 @@ config ATH79
 	select CSRC_R4K
 	select DMA_NONCOHERENT
 	select IRQ_CPU
+	select MIPS_MACHINE
 	select SYS_HAS_CPU_MIPS32_R2
 	select SYS_HAS_EARLY_PRINTK
 	select SYS_SUPPORTS_32BIT_KERNEL
arch/mips/ath79/machtypes.h new file +21 -0
new file mode 100644
index 0000000..fac0e26
@@ -0,0 +1,21 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X machine type definitions
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_MACHTYPE_H
+#define _ATH79_MACHTYPE_H
+
+#include <asm/mips_machine.h>
+
+enum ath79_mach_type {
+	ATH79_MACH_GENERIC = 0,
+};
+
+#endif /* _ATH79_MACHTYPE_H */
arch/mips/ath79/setup.c +15 -0
index dbbf050..8600044 100644
@@ -18,11 +18,13 @@
 #include <asm/bootinfo.h>
 #include <asm/time.h>		/* for mips_hpt_frequency */
 #include <asm/reboot.h>		/* for _machine_{restart,halt} */
+#include <asm/mips_machine.h>
 
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include "common.h"
 #include "dev-common.h"
+#include "machtypes.h"
 
 #define ATH79_SYS_TYPE_LEN	64
 
@@ -257,7 +259,20 @@ static int __init ath79_setup(void)
 {
 	ath79_gpio_init();
 	ath79_register_uart();
+
+	mips_machine_setup();
+
 	return 0;
 }
 
 arch_initcall(ath79_setup);
+
+static void __init ath79_generic_init(void)
+{
+	/* Nothing to do */
+}
+
+MIPS_MACHINE(ATH79_MACH_GENERIC,
+	     "Generic",
+	     "Generic AR71XX/AR724X/AR913X based board",
+	     ath79_generic_init);
Signature · 1 line
1.7.2.1
#11 lore raw

PATCH 5/18 MIPS: ath79: add initial support for the Atheros PB44 reference board

In reply to Gabor Juhos

---

Changes since RFC:
- don't use 'default n' for the ATH79_MACH_PB44 Kconfig option

 arch/mips/ath79/Kconfig     |   11 ++++++++
 arch/mips/ath79/Makefile    |    5 ++++
 arch/mips/ath79/mach-pb44.c |   56 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/ath79/machtypes.h |    1 +
 4 files changed, 73 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/mach-pb44.c
arch/mips/ath79/Kconfig +11 -0
index 50b9334..fabb2b0 100644
@@ -1,5 +1,16 @@
 if ATH79
 
+menu "Atheros AR71XX/AR724X/AR913X machine selection"
+
+config ATH79_MACH_PB44
+	bool "Atheros PB44 reference board"
+	select SOC_AR71XX
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  Atheros PB44 reference board.
+
+endmenu
+
 config SOC_AR71XX
 	def_bool n
 
arch/mips/ath79/Makefile +5 -0
index facbb70..a9ba120 100644
@@ -16,3 +16,8 @@ obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
 # Devices
 #
 obj-y					+= dev-common.o
+
+#
+# Machines
+#
+obj-$(CONFIG_ATH79_MACH_PB44)		+= mach-pb44.o
arch/mips/ath79/mach-pb44.c new file +56 -0

56 lines not on this page · raw message

arch/mips/ath79/machtypes.h +1 -0
index fac0e26..a796fa3 100644
@@ -16,6 +16,7 @@
 
 enum ath79_mach_type {
 	ATH79_MACH_GENERIC = 0,
+	ATH79_MACH_PB44,		/* Atheros PB44 reference board */
 };
 
 #endif /* _ATH79_MACHTYPE_H */
Signature · 1 line
1.7.2.1
#12 lore raw

PATCH 6/18 MIPS: ath79: add common GPIO LEDs device

In reply to Gabor Juhos

Almost all boards have one or more LEDs connected to GPIO lines. This patch adds common code to register a platform_device for them.

The patch also adds support for the LEDs on the PB44 board.

---

Changes since RFC: ---

 arch/mips/ath79/Kconfig         |    4 +++
 arch/mips/ath79/Makefile        |    1 +
 arch/mips/ath79/dev-leds-gpio.c |   56 +++++++++++++++++++++++++++++++++++++++
 arch/mips/ath79/dev-leds-gpio.h |   21 ++++++++++++++
 arch/mips/ath79/mach-pb44.c     |   18 ++++++++++++
 5 files changed, 100 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/dev-leds-gpio.c
 create mode 100644 arch/mips/ath79/dev-leds-gpio.h
arch/mips/ath79/Kconfig +4 -0
index fabb2b0..5bc480e 100644
@@ -5,6 +5,7 @@ menu "Atheros AR71XX/AR724X/AR913X machine selection"
 config ATH79_MACH_PB44
 	bool "Atheros PB44 reference board"
 	select SOC_AR71XX
+	select ATH79_DEV_LEDS_GPIO
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Atheros PB44 reference board.
@@ -20,4 +21,7 @@ config SOC_AR724X
 config SOC_AR913X
 	def_bool n
 
+config ATH79_DEV_LEDS_GPIO
+	def_bool n
+
 endif
arch/mips/ath79/Makefile +1 -0
index a9ba120..d14b597 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
 # Devices
 #
 obj-y					+= dev-common.o
+obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)	+= dev-leds-gpio.o
 
 #
 # Machines
arch/mips/ath79/dev-leds-gpio.c new file +56 -0

56 lines not on this page · raw message

arch/mips/ath79/dev-leds-gpio.h new file +21 -0
new file mode 100644
index 0000000..0fb0ed1
@@ -0,0 +1,21 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X common GPIO LEDs support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_DEV_LEDS_GPIO_H
+#define _ATH79_DEV_LEDS_GPIO_H
+
+#include <linux/leds.h>
+
+void ath79_register_leds_gpio(int id,
+			      unsigned num_leds,
+			      struct gpio_led *leds) __init;
+
+#endif /* _ATH79_DEV_LEDS_GPIO_H */
arch/mips/ath79/mach-pb44.c +18 -0
index ffc24d7..e176779 100644
@@ -15,11 +15,14 @@
 #include <linux/i2c/pcf857x.h>
 
 #include "machtypes.h"
+#include "dev-leds-gpio.h"
 
 #define PB44_GPIO_I2C_SCL	0
 #define PB44_GPIO_I2C_SDA	1
 
 #define PB44_GPIO_EXP_BASE	16
+#define PB44_GPIO_LED_JUMP1	(PB44_GPIO_EXP_BASE + 9)
+#define PB44_GPIO_LED_JUMP2	(PB44_GPIO_EXP_BASE + 10)
 
 static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
 	.sda_pin        = PB44_GPIO_I2C_SDA,
@@ -45,11 +48,26 @@ static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
 	},
 };
 
+static struct gpio_led pb44_leds_gpio[] __initdata = {
+	{
+		.name		= "pb44:amber:jump1",
+		.gpio		= PB44_GPIO_LED_JUMP1,
+		.active_low	= 1,
+	}, {
+		.name		= "pb44:green:jump2",
+		.gpio		= PB44_GPIO_LED_JUMP2,
+		.active_low	= 1,
+	},
+};
+
 static void __init pb44_init(void)
 {
 	i2c_register_board_info(0, pb44_i2c_board_info,
 				ARRAY_SIZE(pb44_i2c_board_info));
 	platform_device_register(&pb44_i2c_gpio_device);
+
+	ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
+				 pb44_leds_gpio);
 }
 
 MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
Signature · 1 line
1.7.2.1
#13 lore raw

PATCH 7/18 watchdog: add driver for the Atheros AR71XX/AR724X/AR913X SoCs

In reply to Gabor Juhos

This patch adds a driver for the built-in hardware watchdog device of the Atheros AR71XX/AR724X/AR913X SoCs.

---

Changes since RFC: ---

 drivers/watchdog/Kconfig     |    8 +
 drivers/watchdog/Makefile    |    1 +
 drivers/watchdog/ath79_wdt.c |  293 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 302 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/ath79_wdt.c
drivers/watchdog/Kconfig +8 -0
index 4a29104..998eed3 100644
@@ -927,6 +927,14 @@ config BCM63XX_WDT
 	  To compile this driver as a loadable module, choose M here.
 	  The module will be called bcm63xx_wdt.
 
+config ATH79_WDT
+	tristate "Atheros AR71XX/AR724X/AR913X hardware watchdog"
+	depends on ATH79
+	help
+	  Hardware driver for the built-in watchdog timer on the Atheros
+	  AR71XX/AR724X/AR913X SoCs.
+
+
 # PARISC Architecture
 
 # POWERPC Architecture
drivers/watchdog/Makefile +1 -0
index 4b0ef38..6d7af07 100644
@@ -117,6 +117,7 @@ obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o
 obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
 obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
 obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
+obj-$(CONFIG_ATH79_WDT) += ath79_wdt.o
 obj-$(CONFIG_OCTEON_WDT) += octeon-wdt.o
 octeon-wdt-y := octeon-wdt-main.o octeon-wdt-nmi.o
 
drivers/watchdog/ath79_wdt.c new file +293 -0

293 lines not on this page · raw message

Signature · 1 line
1.7.2.1
#14 lore raw

PATCH 8/18 MIPS: ath79: add common watchdog device

In reply to Gabor Juhos

All supported SoCs have a built-in hardware watchdog driver. This patch registers a platform_device for that to make it usable.

---

Changes since RFC:
- remove the ATH79_DEV_WDT Kconfig option, and move the watchdog platform code into dev-common.[ch]

 arch/mips/ath79/dev-common.c |   10 ++++++++++
 arch/mips/ath79/dev-common.h |    1 +
 arch/mips/ath79/setup.c      |    1 +
 3 files changed, 12 insertions(+), 0 deletions(-)
arch/mips/ath79/dev-common.c +10 -0
index 897522c..74b1e3b 100644
@@ -57,3 +57,13 @@ void __init ath79_register_uart(void)
 	ath79_uart_data[0].uartclk = ath79_ahb_freq;
 	platform_device_register(&ath79_uart_device);
 }
+
+static struct platform_device ath79_wdt_device = {
+	.name		= "ath79-wdt",
+	.id		= -1,
+};
+
+void __init ath79_register_wdt(void)
+{
+	platform_device_register(&ath79_wdt_device);
+}
arch/mips/ath79/dev-common.h +1 -0
index 1cec894..65bf400 100644
@@ -13,5 +13,6 @@
 #define _ATH79_DEV_COMMON_H
 
 void ath79_register_uart(void) __init;
+void ath79_register_wdt(void) __init;
 
 #endif /* _ATH79_DEV_COMMON_H */
arch/mips/ath79/setup.c +1 -0
index 8600044..5abe56c 100644
@@ -259,6 +259,7 @@ static int __init ath79_setup(void)
 {
 	ath79_gpio_init();
 	ath79_register_uart();
+	ath79_register_wdt();
 
 	mips_machine_setup();
 
Signature · 1 line
1.7.2.1
#15 lore raw

PATCH 9/18 input: add input driver for polled GPIO buttons

In reply to Gabor Juhos

The existing gpio-keys driver can be usable only for GPIO lines with interrupt support. Several devices have buttons connected to a GPIO line which is not capable to generate interrupts. This patch adds a new input driver using the generic GPIO layer and the input-polldev to support such buttons.

Cc Dmitry Torokhov <[email protected]>
Cc Mike Frysinger <[email protected]>

---

Changes since RFC: ---

 drivers/input/misc/Kconfig        |   16 +++
 drivers/input/misc/Makefile       |    1 +
 drivers/input/misc/gpio_buttons.c |  232 +++++++++++++++++++++++++++++++++++++
 include/linux/gpio_buttons.h      |   33 +++++
 4 files changed, 282 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/gpio_buttons.c
 create mode 100644 include/linux/gpio_buttons.h
drivers/input/misc/Kconfig +16 -0
index b99b8cb..3439b79 100644
@@ -448,4 +448,20 @@ config INPUT_ADXL34X_SPI
 	  To compile this driver as a module, choose M here: the
 	  module will be called adxl34x-spi.
 
+config INPUT_GPIO_BUTTONS
+	tristate "Polled GPIO buttons interface"
+	depends on GENERIC_GPIO
+	select INPUT_POLLDEV
+	help
+	  This driver implements support for buttons connected
+	  to GPIO pins of various CPUs (and some other chips).
+
+	  Say Y here if your device has buttons connected
+	  directly to such GPIO pins.  Your board-specific
+	  setup logic must also provide a platform device,
+	  with configuration data saying which GPIOs are used.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called gpio-buttons.
+
 endif
drivers/input/misc/Makefile +1 -0
index 1fe1f6c..3791050 100644
@@ -42,4 +42,5 @@ obj-$(CONFIG_INPUT_WINBOND_CIR)		+= winbond-cir.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
+obj-$(CONFIG_INPUT_GPIO_BUTTONS)	+= gpio_buttons.o
 
drivers/input/misc/gpio_buttons.c new file +232 -0

232 lines not on this page · raw message

include/linux/gpio_buttons.h new file +33 -0
new file mode 100644
index 0000000..f85b993
@@ -0,0 +1,33 @@
+/*
+ *  Definitions for the GPIO buttons interface driver
+ *
+ *  Copyright (C) 2007-2010 Gabor Juhos <[email protected]>
+ *
+ *  This file was based on: /include/linux/gpio_keys.h
+ *	The original gpio_keys.h seems not to have a license.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _GPIO_BUTTONS_H_
+#define _GPIO_BUTTONS_H_
+
+struct gpio_button {
+	int	gpio;		/* GPIO line number */
+	int	active_low;
+	char	*desc;		/* button description */
+	int	type;		/* input event type (EV_KEY, EV_SW) */
+	int	code;		/* input event code (KEY_*, SW_*) */
+	int	threshold;	/* count threshold */
+};
+
+struct gpio_buttons_platform_data {
+	struct gpio_button *buttons;
+	int	nbuttons;		/* number of buttons */
+	int	poll_interval;		/* polling interval */
+};
+
+#endif /* _GPIO_BUTTONS_H_ */
Signature · 1 line
1.7.2.1
#16 lore raw

Re: [PATCH 09/18] input: add input driver for polled GPIO buttons

Hi Gabor,

Quoted 10 lines · Gabor Juhos

The existing gpio-keys driver can be usable only for GPIO lines with interrupt support. Several devices have buttons connected to a GPIO line which is not capable to generate interrupts. This patch adds a new input driver using the generic GPIO layer and the input-polldev to support such buttons.

Cc Dmitry Torokhov <[email protected]>
Cc Mike Frysinger <[email protected]>

I'm excited to see this patch posted. As I understand it, this "separate polling gpio button driver" approach is preferred to the "polling extensions in gpio-keys approach". I'm sorry I missed the RFC
[1] : I posted a revised version of Alex Clouter's and Paul Mundt's polling gpio-keys support [2]. But now I can try integrating this driver. :)

I will be posting a version of the patch shortly that is still using the polling-gpio-keys support -- because there are discussions in the machine-specific parts. Then I will try to integrate this driver into the series.

Best Regards,
Ben Gardiner

[1] http://article.gmane.org/gmane.linux.kernel.input/16468
[2] http://article.gmane.org/gmane.linux.kernel.input/16587

---
Nanometrics Inc.
http://www.nanometrics.ca

Tested-by on v1 9/18
#17 lore raw

Re: [PATCH 09/18] input: add input driver for polled GPIO buttons

In reply to Gabor Juhos

Hello Gabor,

Quoted 11 lines · Gabor Juhos

The existing gpio-keys driver can be usable only for GPIO lines with interrupt support. Several devices have buttons connected to a GPIO line which is not capable to generate interrupts. This patch adds a new input driver using the generic GPIO layer and the input-polldev to support such buttons.

Cc Dmitry Torokhov <[email protected]>
Cc Mike Frysinger <[email protected]>

---

I've tested this driver with the da850-evm pushbuttons and switches connected to i2c gpio expanders. It works well. The changes to the patch series were straightforward: .config, "gpio-keys" -> "gpio-buttons", struct gpio_key -> struct gpio_button etc.

I do have some comments about this patch. But the new driver is functional as-is.

Quoted 3 lines

 drivers/input/misc/Kconfig        |   16 +++ drivers/input/misc/Makefile       |    1 + drivers/input/misc/gpio_buttons.c |  232 +++++++++++++++++++++++++++++++++++++

Since the new gpio_buttons.c driver presents the same input event device as the gpio_keys.c driver, I think it should also be a drivers/input/keys device.

drivers/input/misc/gpio_buttons.c

Quoted 2 lines

 [...]

drivers/input/misc/gpio_buttons.c +0 -0

When I was converting the da850-evm platform code to use the new driver I felt that the changes did not indicate a switch to a polled driver as seems to be the intent with the introduction of a separate driver. All that was different in the platform code was 'button' where there use to be 'key' and button does not itself convey the knowledge that it is a polled input device.

I know names of drivers can be contentions but I will propose regardless that this driver be called gpio-polled-keys / gpio_polled_keys.c

Quoted 10 lines

new file mode 100644
index 0000000..51288a3

drivers/input/misc/gpio_buttons.c new file +5 -0
[...]
+static void gpio_buttons_poll(struct input_polled_dev *dev)
+{
+       struct gpio_buttons_dev *bdev = dev->private;
+       struct gpio_buttons_platform_data *pdata = bdev->pdata;
+       struct input_dev *input = dev->input;

drivers/input/misc/gpio_buttons.c line 80

Quoted 10 lines
drivers/input/misc/gpio_buttons.c new file +10 -0
+       int i;
+
+       for (i = 0; i < bdev->pdata->nbuttons; i++) {
+               struct gpio_button *button = &pdata->buttons[i];
+               struct gpio_button_data *bdata = &bdev->data[i];
+
+               if (bdata->count < button->threshold)
+                       bdata->count++;
+               else
+                       gpio_buttons_check_state(input, button, bdata);

I think that a count-theshold can still be performed here, but using the debounce_interval and polling_interval field specified in the gpio_button and gpio_buttons_platform_data structures, respectively, to calculate a threshold value.

In this way the gpio_button and gpio_keys_button structs are made more similar -- differing only in the presence of .wakeup in gpio_keys_button but not in gpio_button. Which may make it possible to re-use the gpio_keys_button structure.

Quoted 21 lines

[...]

include/linux/gpio_buttons.h new file +14 -0
new file mode 100644
index 0000000..f85b993
@@ -0,0 +1,33 @@
+/*
+ *  Definitions for the GPIO buttons interface driver
+ *
+ *  Copyright (C) 2007-2010 Gabor Juhos <[email protected]>
+ *
+ *  This file was based on: /include/linux/gpio_keys.h
+ *     The original gpio_keys.h seems not to have a license.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ */
+

include/linux/gpio_buttons.h line 24

Quoted 10 lines
include/linux/gpio_buttons.h new file +10 -0
+#ifndef _GPIO_BUTTONS_H_
+#define _GPIO_BUTTONS_H_
+
+struct gpio_button {
+       int     gpio;           /* GPIO line number */
+       int     active_low;
+       char    *desc;          /* button description */
+       int     type;           /* input event type (EV_KEY, EV_SW) */
+       int     code;           /* input event code (KEY_*, SW_*) */
+       int     threshold;      /* count threshold */

Could we instead use the existing struct gpio_keys_button; we could transform debounce_interval into a threshold as described above and add an error when a gpio_button_probe() sees a gpio_key with .wakeup == TRUE? It seems that this structure duplicates alot of the gpio_keys_button structure.

include/linux/gpio_buttons.h line 31

Quoted 6 lines

[...]

include/linux/gpio_buttons.h new file +5 -0
+struct gpio_buttons_platform_data {
+       struct gpio_button *buttons;
+       int     nbuttons;               /* number of buttons */
+       int     poll_interval;          /* polling interval */
+};

I think the units of poll_interval should be included in the comment. i.e. /* polling interval in msecs */

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw

Re: [PATCH 09/18] input: add input driver for polled GPIO buttons

Hi Ben,

Quoted 10 lines

<...>
I've tested this driver with the da850-evm pushbuttons and switches connected to i2c gpio expanders. It works well. The changes to the patch series were straightforward: .config, "gpio-keys" -> "gpio-buttons", struct gpio_key -> struct gpio_button etc.

I do have some comments about this patch. But the new driver is functional as-is.

Thanks!

Quoted 5 lines
Quoted 1 line

<...>

Since the new gpio_buttons.c driver presents the same input event device as the gpio_keys.c driver, I think it should also be a drivers/input/keys device.

Makes sense.

Quoted 11 lines

drivers/input/misc/gpio_buttons.c

Quoted 3 lines

[...]

drivers/input/misc/gpio_buttons.c +0 -0

When I was converting the da850-evm platform code to use the new driver I felt that the changes did not indicate a switch to a polled driver as seems to be the intent with the introduction of a separate driver. All that was different in the platform code was 'button' where there use to be 'key' and button does not itself convey the knowledge that it is a polled input device.

Quoted 3 lines

I know names of drivers can be contentions but I will propose regardless that this driver be called gpio-polled-keys / gpio_polled_keys.c

I agree, this would be more informative.

Quoted 10 lines

drivers/input/misc/gpio_buttons.c line 80

Quoted 9 lines

<...>

drivers/input/misc/gpio_buttons.c +8 -0
+       for (i = 0; i < bdev->pdata->nbuttons; i++) {
+               struct gpio_button *button = &pdata->buttons[i];
+               struct gpio_button_data *bdata = &bdev->data[i];
+
+               if (bdata->count < button->threshold)
+                       bdata->count++;
+               else
+                       gpio_buttons_check_state(input, button, bdata);
Quoted 4 lines

I think that a count-theshold can still be performed here, but using the debounce_interval and polling_interval field specified in the gpio_button and gpio_buttons_platform_data structures, respectively, to calculate a threshold value.

Good idea. We don't even have to compute a threshold value, we can use the debounce_interval and poll_interval fields directly. I mean something similar to this:

<...>

	if (bdata->interval < button->debounce_interval)
		bdata->interval += pdata->poll_interval;
	else
		gpio_buttons_check_state(input, button, bdata);

<...>

Quoted 14 lines

In this way the gpio_button and gpio_keys_button structs are made more similar -- differing only in the presence of .wakeup in gpio_keys_button but not in gpio_button. Which may make it possible to re-use the gpio_keys_button structure.

drivers/input/misc/gpio_buttons.c

Quoted 8 lines

<...>

drivers/input/misc/gpio_buttons.c +7 -0
+struct gpio_button {
+       int     gpio;           /* GPIO line number */
+       int     active_low;
+       char    *desc;          /* button description */
+       int     type;           /* input event type (EV_KEY, EV_SW) */
+       int     code;           /* input event code (KEY_*, SW_*) */
+       int     threshold;      /* count threshold */
Quoted 2 lines

Could we instead use the existing struct gpio_keys_button; we could transform debounce_interval into a threshold as described above

Sure, we can use that...

Quoted 2 lines

and add an error when a gpio_button_probe() sees a gpio_key with .wakeup == TRUE?

I don't think we should check that, we can simply ignore this field. Maybe we should add a comment to the .wakeup field to state that the polled driver does not use that.

Quoted 2 lines

It seems that this structure duplicates alot of the gpio_keys_button structure.

Yes, it is almost the same.

Quoted 9 lines

drivers/input/misc/gpio_buttons.c

Quoted 6 lines

[...]

drivers/input/misc/gpio_buttons.c +5 -0
+struct gpio_buttons_platform_data {
+       struct gpio_button *buttons;
+       int     nbuttons;               /* number of buttons */
+       int     poll_interval;          /* polling interval */
+};

I think the units of poll_interval should be included in the comment. i.e. /* polling interval in msecs */

Yes, you are right. Additionally, we should move this structure into gpio_keys.h, so we can get rid of the gpio_buttons.h file.

Thank you for the valuable comments. I will create a new patch.

Regards,
Gabor

#19 lore raw

Re: [PATCH 09/18] input: add input driver for polled GPIO buttons

Hi Gabor,

Quoted 5 lines · Gabor Juhos

Hi Ben,

Quoted 2 lines

Thanks!

You are most welcome.

Quoted 3 lines

[...]

Thank you for the valuable comments. I will create a new patch.

Actually, I've done a little hacking on the patch here while integrating with the da850-evm changes. I will post the series here, feel free to pick an choose the changes as you see fit -- hopefully it can save you some time.

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca

#20 lore raw

cover suggested changes to gpio_buttons driver

In reply to Gabor Juhos

These are just some suggested changes from the review in patch-form. I will do my best to make time for reviewing and testing any future versions of the patch that you submit but I will regrettably be moving to other projects for awhile. Until then I will not be able to spend much time on integration.

With these patches applied I was able to build the da850-evm buttons and keys support with minimal changes.As I said, these are just suggested changes, please feel free to squash, edit or drop them as you see fit. My motivation here is that if you pickup the driver name and config symbol names as-is then I will have no remaining integration to perform in the da850-evm series. I hope you don't mind that I have to patch and run here.

I look forward to your next version of the patch.

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca

Ben Gardiner (6):
fixup gpio_buttons: use the same debounce_interval member found in
gpio_key to obtain a threshold count based on polling interval
fixup gpio_buttons: use existing gpio_keys_button structure instead
of introducing new gpio_button structure
fixup gpio_buttons: detect and error-out if a button is requested for
wakeup
fixup gpio_buttons: show units of poll_interval platform data member fixup gpio_buttons: move gpio_buttons.c to drivers/input/keyboard
from drivers/input/misc
fixup gpio_buttons : rename gpio-buttons / gpio_buttons to
gpio-keys-polled / gpio_keys_polled

 drivers/input/keyboard/Kconfig                     |   16 ++++
 drivers/input/keyboard/Makefile                    |    2 +
 .../gpio_buttons.c => keyboard/gpio_keys_polled.c} |   86 +++++++++++---------
 drivers/input/misc/Kconfig                         |   16 ----
 drivers/input/misc/Makefile                        |    1 -
 .../linux/{gpio_buttons.h => gpio_keys_polled.h}   |   15 +---
 6 files changed, 69 insertions(+), 67 deletions(-)
 rename drivers/input/{misc/gpio_buttons.c => keyboard/gpio_keys_polled.c} (64%)
 rename include/linux/{gpio_buttons.h => gpio_keys_polled.h} (60%)
#21 lore raw

PATCH 1/6 fixup gpio_buttons: use the same debounce_interval member found in gpio_key to obtain a threshold count based on polling interval

my reasoning was that if the debounce interval was set then the platform _wants_ to supress spurious events so it was better to roundup and swallow real events than round down and not supress.

I'm fine also with using the poll_interval and debuonce_interval directly as you suggested.

---
 drivers/input/misc/gpio_buttons.c |    7 +++++--
 include/linux/gpio_buttons.h      |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/input/misc/gpio_buttons.c +5 -2
index 51288a3..f42906c 100644
@@ -68,13 +68,16 @@ static void gpio_buttons_poll(struct input_polled_dev *dev)
 	struct gpio_buttons_dev *bdev = dev->private;
 	struct gpio_buttons_platform_data *pdata = bdev->pdata;
 	struct input_dev *input = dev->input;
-	int i;
+	int i, threshold;
 
 	for (i = 0; i < bdev->pdata->nbuttons; i++) {
 		struct gpio_button *button = &pdata->buttons[i];
 		struct gpio_button_data *bdata = &bdev->data[i];
 
-		if (bdata->count < button->threshold)
+		threshold = round_up(button->debounce_interval,
+				pdata->poll_interval) /
+				pdata->poll_interval;
+		if (bdata->count < threshold)
 			bdata->count++;
 		else
 			gpio_buttons_check_state(input, button, bdata);
include/linux/gpio_buttons.h +1 -1
index f85b993..c016f07 100644
@@ -21,7 +21,7 @@ struct gpio_button {
 	char	*desc;		/* button description */
 	int	type;		/* input event type (EV_KEY, EV_SW) */
 	int	code;		/* input event code (KEY_*, SW_*) */
-	int	threshold;	/* count threshold */
+	int debounce_interval;	/* debounce ticks interval in msecs */
 };
 
 struct gpio_buttons_platform_data {
Signature · 1 line
1.7.0.4
#22 lore raw

PATCH 2/6 fixup gpio_buttons: use existing gpio_keys_button structure instead of introducing new gpio_button structure

In reply to Ben Gardiner
---
 drivers/input/misc/gpio_buttons.c |    6 +++---
 include/linux/gpio_buttons.h      |   11 ++---------
 2 files changed, 5 insertions(+), 12 deletions(-)
drivers/input/misc/gpio_buttons.c +3 -3
index f42906c..c34e978 100644
@@ -42,7 +42,7 @@ struct gpio_buttons_dev {
 };
 
 static void gpio_buttons_check_state(struct input_dev *input,
-				      struct gpio_button *button,
+				      struct gpio_keys_button *button,
 				      struct gpio_button_data *bdata)
 {
 	int state;
@@ -71,7 +71,7 @@ static void gpio_buttons_poll(struct input_polled_dev *dev)
 	int i, threshold;
 
 	for (i = 0; i < bdev->pdata->nbuttons; i++) {
-		struct gpio_button *button = &pdata->buttons[i];
+		struct gpio_keys_button *button = &pdata->buttons[i];
 		struct gpio_button_data *bdata = &bdev->data[i];
 
 		threshold = round_up(button->debounce_interval,
@@ -132,7 +132,7 @@ static int __devinit gpio_buttons_probe(struct platform_device *pdev)
 	input->id.version = 0x0100;
 
 	for (i = 0; i < pdata->nbuttons; i++) {
-		struct gpio_button *button = &pdata->buttons[i];
+		struct gpio_keys_button *button = &pdata->buttons[i];
 		unsigned int gpio = button->gpio;
 		unsigned int type = button->type ?: EV_KEY;
 
include/linux/gpio_buttons.h +2 -9
index c016f07..4d43de9 100644
@@ -15,17 +15,10 @@
 #ifndef _GPIO_BUTTONS_H_
 #define _GPIO_BUTTONS_H_
 
-struct gpio_button {
-	int	gpio;		/* GPIO line number */
-	int	active_low;
-	char	*desc;		/* button description */
-	int	type;		/* input event type (EV_KEY, EV_SW) */
-	int	code;		/* input event code (KEY_*, SW_*) */
-	int debounce_interval;	/* debounce ticks interval in msecs */
-};
+#include <linux/gpio_keys.h>
 
 struct gpio_buttons_platform_data {
-	struct gpio_button *buttons;
+	struct gpio_keys_button *buttons;
 	int	nbuttons;		/* number of buttons */
 	int	poll_interval;		/* polling interval */
 };
Signature · 1 line
1.7.0.4
#23 lore raw

PATCH 3/6 fixup gpio_buttons: detect and error-out if a button is requested for wakeup

In reply to Ben Gardiner

I'm fine also with ignoring the value of wakeup as you suggested.

---
 drivers/input/misc/gpio_buttons.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/input/misc/gpio_buttons.c +5 -0
index c34e978..0859b4d 100644
@@ -136,6 +136,11 @@ static int __devinit gpio_buttons_probe(struct platform_device *pdev)
 		unsigned int gpio = button->gpio;
 		unsigned int type = button->type ?: EV_KEY;
 
+		if (button->wakeup) {
+			dev_err(dev, DRV_NAME " does not support wakeup\n");
+			goto err_free_gpio;
+		}
+
 		error = gpio_request(gpio,
 				     button->desc ? button->desc : DRV_NAME);
 		if (error) {
Signature · 1 line
1.7.0.4
#24 lore raw

PATCH 4/6 fixup gpio_buttons: show units of poll_interval platform data member

In reply to Ben Gardiner
---
 include/linux/gpio_buttons.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/gpio_buttons.h +1 -1
index 4d43de9..f7f1467 100644
@@ -20,7 +20,7 @@
 struct gpio_buttons_platform_data {
 	struct gpio_keys_button *buttons;
 	int	nbuttons;		/* number of buttons */
-	int	poll_interval;		/* polling interval */
+	int	poll_interval;		/* polling interval in msecs*/
 };
 
 #endif /* _GPIO_BUTTONS_H_ */
Signature · 1 line
1.7.0.4
#25 lore raw

PATCH 5/6 fixup gpio_buttons: move gpio_buttons.c to drivers/input/keyboard from drivers/input/misc

In reply to Ben Gardiner
---
 drivers/input/keyboard/Kconfig                  |   16 ++++++++++++++++
 drivers/input/keyboard/Makefile                 |    2 ++
 drivers/input/{misc => keyboard}/gpio_buttons.c |    0
 drivers/input/misc/Kconfig                      |   16 ----------------
 drivers/input/misc/Makefile                     |    1 -
 5 files changed, 18 insertions(+), 17 deletions(-)
 rename drivers/input/{misc => keyboard}/gpio_buttons.c (100%)
drivers/input/keyboard/Kconfig +16 -0
index b8c51b9..4ab13fc 100644
@@ -485,4 +485,20 @@ config KEYBOARD_W90P910
 	  To compile this driver as a module, choose M here: the
 	  module will be called w90p910_keypad.
 
+config INPUT_GPIO_BUTTONS
+	tristate "Polled GPIO buttons interface"
+	depends on GENERIC_GPIO
+	select INPUT_POLLDEV
+	help
+	  This driver implements support for buttons connected
+	  to GPIO pins of various CPUs (and some other chips).
+
+	  Say Y here if your device has buttons connected
+	  directly to such GPIO pins.  Your board-specific
+	  setup logic must also provide a platform device,
+	  with configuration data saying which GPIOs are used.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called gpio-buttons.
+
 endif
drivers/input/keyboard/Makefile +2 -0
index a34452e..2a52e0c 100644
@@ -44,3 +44,5 @@ obj-$(CONFIG_KEYBOARD_TNETV107X)	+= tnetv107x-keypad.o
 obj-$(CONFIG_KEYBOARD_TWL4030)		+= twl4030_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910)		+= w90p910_keypad.o
+obj-$(CONFIG_INPUT_GPIO_BUTTONS)	+= gpio_buttons.o
+
drivers/input/keyboard/gpio_buttons.c renamed from drivers/input/misc/gpio_buttons.c +0 -0
similarity index 100%
rename from drivers/input/misc/gpio_buttons.c
rename to drivers/input/keyboard/gpio_buttons.c
drivers/input/misc/Kconfig +0 -16
index ef46534..a3adef6 100644
@@ -457,20 +457,4 @@ config INPUT_ADXL34X_SPI
 	  To compile this driver as a module, choose M here: the
 	  module will be called adxl34x-spi.
 
-config INPUT_GPIO_BUTTONS
-	tristate "Polled GPIO buttons interface"
-	depends on GENERIC_GPIO
-	select INPUT_POLLDEV
-	help
-	  This driver implements support for buttons connected
-	  to GPIO pins of various CPUs (and some other chips).
-
-	  Say Y here if your device has buttons connected
-	  directly to such GPIO pins.  Your board-specific
-	  setup logic must also provide a platform device,
-	  with configuration data saying which GPIOs are used.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called gpio-buttons.
-
 endif
drivers/input/misc/Makefile +0 -1
index 1f9f7bd..b041f5f 100644
@@ -43,5 +43,4 @@ obj-$(CONFIG_INPUT_WINBOND_CIR)		+= winbond-cir.o
 obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
-obj-$(CONFIG_INPUT_GPIO_BUTTONS)	+= gpio_buttons.o
 
Signature · 1 line
1.7.0.4
#26 lore raw

PATCH 6/6 fixup gpio_buttons : rename gpio-buttons / gpio_buttons to gpio-keys-polled / gpio_keys_polled

In reply to Ben Gardiner
---
 drivers/input/keyboard/Kconfig                     |    4 +-
 drivers/input/keyboard/Makefile                    |    2 +-
 .../{gpio_buttons.c => gpio_keys_polled.c}         |   68 ++++++++++----------
 .../linux/{gpio_buttons.h => gpio_keys_polled.h}   |    2 +-
 4 files changed, 38 insertions(+), 38 deletions(-)
 rename drivers/input/keyboard/{gpio_buttons.c => gpio_keys_polled.c} (71%)
 rename include/linux/{gpio_buttons.h => gpio_keys_polled.h} (94%)
drivers/input/keyboard/Kconfig +2 -2
index 4ab13fc..9648ff4 100644
@@ -485,8 +485,8 @@ config KEYBOARD_W90P910
 	  To compile this driver as a module, choose M here: the
 	  module will be called w90p910_keypad.
 
-config INPUT_GPIO_BUTTONS
-	tristate "Polled GPIO buttons interface"
+config KEYBOARD_GPIO_POLLED
+	tristate "Polled GPIO buttons"
 	depends on GENERIC_GPIO
 	select INPUT_POLLDEV
 	help
drivers/input/keyboard/Makefile +1 -1
index 2a52e0c..e6da817 100644
@@ -44,5 +44,5 @@ obj-$(CONFIG_KEYBOARD_TNETV107X)	+= tnetv107x-keypad.o
 obj-$(CONFIG_KEYBOARD_TWL4030)		+= twl4030_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910)		+= w90p910_keypad.o
-obj-$(CONFIG_INPUT_GPIO_BUTTONS)	+= gpio_buttons.o
+obj-$(CONFIG_KEYBOARD_GPIO_POLLED)	+= gpio_keys_polled.o
 
drivers/input/keyboard/gpio_keys_polled.c renamed from drivers/input/keyboard/gpio_buttons.c +34 -34

164 lines not on this page · raw message

include/linux/gpio_keys_polled.h renamed from include/linux/gpio_buttons.h +1 -1
similarity index 94%
rename from include/linux/gpio_buttons.h
rename to include/linux/gpio_keys_polled.h
index f7f1467..bf7f94a 100644
@@ -17,7 +17,7 @@
 
 #include <linux/gpio_keys.h>
 
-struct gpio_buttons_platform_data {
+struct gpio_keys_polled_platform_data {
 	struct gpio_keys_button *buttons;
 	int	nbuttons;		/* number of buttons */
 	int	poll_interval;		/* polling interval in msecs*/
Signature · 1 line
1.7.0.4
maintainer
#27 lore raw

Re: [PATCH WIP 0/6] suggested changes to gpio_buttons driver

In reply to Ben Gardiner

Hi Gabor, Ben,

Quoted 5 lines · Ben Gardiner

These are just some suggested changes from the review in patch-form. I will do my best to make time for reviewing and testing any future versions of the patch that you submit but I will regrettably be moving to other projects for awhile. Until then I will not be able to spend much time on integration.

Quoted 8 lines

With these patches applied I was able to build the da850-evm buttons and keys support with minimal changes.As I said, these are just suggested changes, please feel free to squash, edit or drop them as you see fit. My motivation here is that if you pickup the driver name and config symbol names as-is then I will have no remaining integration to perform in the da850-evm series. I hope you don't mind that I have to patch and run here.

I look forward to your next version of the patch.

I do like the original patch and even more so Ben changes. Could you tell me if the following still works for you (goes on top of Ben's) and if it does I'll fold everything together and queue for 2.6.38.

Thanks!

Signature · 14 lines
Dmitry

Input: gpio-buttons - misc changes

From: Dmitry Torokhov <[email protected]>

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/keyboard/gpio_keys_polled.c |   38 ++++++++++++++++++++++-------
 include/linux/gpio_keys.h                 |    2 ++
 include/linux/gpio_keys_polled.h          |   26 --------------------
 3 files changed, 31 insertions(+), 35 deletions(-)
 delete mode 100644 include/linux/gpio_keys_polled.h
drivers/input/keyboard/gpio_keys_polled.c +29 -9
index 390ed93..6ed6910 100644
@@ -25,7 +25,7 @@
 #include <linux/ioport.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
-#include <linux/gpio_keys_polled.h>
+#include <linux/gpio_keys.h>
 
 #define DRV_NAME	"gpio-keys-polled"
 
@@ -37,8 +37,9 @@ struct gpio_keys_button_data {
 
 struct gpio_keys_polled_dev {
 	struct input_polled_dev *poll_dev;
-	struct gpio_keys_polled_platform_data *pdata;
-	struct gpio_keys_button_data *data;
+	struct device *dev;
+	struct gpio_keys_platform_data *pdata;
+	struct gpio_keys_button_data data[0];
 };
 
 static void gpio_keys_polled_check_state(struct input_dev *input,
@@ -66,7 +67,7 @@ static void gpio_keys_polled_check_state(struct input_dev *input,
 static void gpio_keys_polled_poll(struct input_polled_dev *dev)
 {
 	struct gpio_keys_polled_dev *bdev = dev->private;
-	struct gpio_keys_polled_platform_data *pdata = bdev->pdata;
+	struct gpio_keys_platform_data *pdata = bdev->pdata;
 	struct input_dev *input = dev->input;
 	int i, threshold;
 
@@ -85,9 +86,27 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
 	}
 }
 
+static void gpio_keys_polled_open(struct input_polled_dev *dev)
+{
+	struct gpio_keys_polled_dev *bdev = dev->private;
+	struct gpio_keys_platform_data *pdata = bdev->pdata;
+
+	if (pdata->enable)
+		pdata->enable(bdev->dev);
+}
+
+static void gpio_keys_polled_close(struct input_polled_dev *dev)
+{
+	struct gpio_keys_polled_dev *bdev = dev->private;
+	struct gpio_keys_platform_data *pdata = bdev->pdata;
+
+	if (pdata->disable)
+		pdata->disable(bdev->dev);
+}
+
 static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 {
-	struct gpio_keys_polled_platform_data *pdata = pdev->dev.platform_data;
+	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
 	struct device *dev = &pdev->dev;
 	struct gpio_keys_polled_dev *bdev;
 	struct input_polled_dev *poll_dev;
@@ -106,8 +125,6 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	bdev->data = (struct gpio_keys_button_data *) &bdev[1];
-
 	poll_dev = input_allocate_polled_device();
 	if (!poll_dev) {
 		dev_err(dev, "no memory for polled device\n");
@@ -118,6 +135,8 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 	poll_dev->private = bdev;
 	poll_dev->poll = gpio_keys_polled_poll;
 	poll_dev->poll_interval = pdata->poll_interval;
+	poll_dev->open = gpio_keys_polled_open;
+	poll_dev->close = gpio_keys_polled_close;
 
 	input = poll_dev->input;
 
@@ -164,6 +183,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 	}
 
 	bdev->poll_dev = poll_dev;
+	bdev->dev = dev;
 	bdev->pdata = pdata;
 	platform_set_drvdata(pdev, bdev);
 
@@ -182,7 +202,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 	return 0;
 
 err_free_gpio:
-	for (i = i - 1; i >= 0; i--)
+	while (--i >= 0)
 		gpio_free(pdata->buttons[i].gpio);
 
 	input_free_polled_device(poll_dev);
@@ -197,7 +217,7 @@ err_free_bdev:
 static int __devexit gpio_keys_polled_remove(struct platform_device *pdev)
 {
 	struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
-	struct gpio_keys_polled_platform_data *pdata = bdev->pdata;
+	struct gpio_keys_platform_data *pdata = bdev->pdata;
 	int i;
 
 	input_unregister_polled_device(bdev->poll_dev);
include/linux/gpio_keys.h +2 -0
index ce73a30..dd1a56f 100644
@@ -16,6 +16,8 @@ struct gpio_keys_button {
 struct gpio_keys_platform_data {
 	struct gpio_keys_button *buttons;
 	int nbuttons;
+	unsigned int poll_interval;	/* polling interval in msecs -
+					   for polling driver only */
 	unsigned int rep:1;		/* enable input subsystem auto repeat */
 	int (*enable)(struct device *dev);
 	void (*disable)(struct device *dev);
include/linux/gpio_keys_polled.h deleted +0 -26
deleted file mode 100644
index bf7f94a..0000000
@@ -1,26 +0,0 @@
-/*
- *  Definitions for the GPIO buttons interface driver
- *
- *  Copyright (C) 2007-2010 Gabor Juhos <[email protected]>
- *
- *  This file was based on: /include/linux/gpio_keys.h
- *	The original gpio_keys.h seems not to have a license.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- */
-
-#ifndef _GPIO_BUTTONS_H_
-#define _GPIO_BUTTONS_H_
-
-#include <linux/gpio_keys.h>
-
-struct gpio_keys_polled_platform_data {
-	struct gpio_keys_button *buttons;
-	int	nbuttons;		/* number of buttons */
-	int	poll_interval;		/* polling interval in msecs*/
-};
-
-#endif /* _GPIO_BUTTONS_H_ */
#28 lore raw

Re: [PATCH WIP 0/6] suggested changes to gpio_buttons driver

Hi Dmitry,

Quoted 13 lines · Ben Gardiner
Quoted 12 lines

These are just some suggested changes from the review in patch-form. I will do my best to make time for reviewing and testing any future versions of the patch that you submit but I will regrettably be moving to other projects for awhile. Until then I will not be able to spend much time on integration.

With these patches applied I was able to build the da850-evm buttons and keys support with minimal changes.As I said, these are just suggested changes, please feel free to squash, edit or drop them as you see fit. My motivation here is that if you pickup the driver name and config symbol names as-is then I will have no remaining integration to perform in the da850-evm series. I hope you don't mind that I have to patch and run here.

Quoted 5 lines
Quoted 1 line

I look forward to your next version of the patch.

I do like the original patch and even more so Ben changes. Could you tell me if the following still works for you (goes on top of Ben's) and if it does I'll fold everything together and queue for 2.6.38.

It works for me, however I have additional fixes on top of Ben's changes. I will post an updated version soon.

The original driver was a part of a patch-set which adds support for a new MIPS platform. There are a couple of patches in that series which requires this one. It would be nice if the driver would be able to go through the MIPS tree to avoid cross-tree dependencies.

Regards,
Gabor

Tested-by
#29 lore raw

Re: [PATCH WIP 0/6] suggested changes to gpio_buttons driver

Hi Dmitry, Gabor,

Quoted 4 lines · Dmitry Torokhov
Quoted 1 line

[...]

I do like the original patch and even more so Ben changes. Could you tell me if the following still works for you (goes on top of Ben's) and if it does I'll fold everything together and queue for 2.6.38.

Thank you for considering the proposed changes and also for you r kind
words: it is encouraging to hear as a newcomer to kernel development.\

Quoted 11 lines

[...]
From: Dmitry Torokhov <[email protected]>

---

 drivers/input/keyboard/gpio_keys_polled.c |   38 ++++++++++++++++++++++------- include/linux/gpio_keys.h                 |    2 ++ include/linux/gpio_keys_polled.h          |   26 --------------------

 3 files changed, 31 insertions(+), 35 deletions(-)

 delete mode 100644 include/linux/gpio_keys_polled.h

I have tested your patch with the "da850-evm: add gpio-{keys,leds} for UI and BB expanders" on top of Gabor's "[PATCH 09/18] input: add input driver for polled GPIO buttons" patch and my "[PATCH WIP 0/6] suggested changes to gpio_buttons driver" series. Only minimal changes were needed in the later patches of the da850-evm series.

They can be summarized (as you probably expected) by:
s/gpio_keys_polled\.h/gpio_keys.\h/g and s/gpio_keys_polled_platform_data/gpio_keys_platform_data/g.

With those changes I observed the expected input events with evtest.

Quoted 3 lines · Gabor Juhos
Quoted 1 line

[...]

It works for me, however I have additional fixes on top of Ben's changes. I will post an updated version soon.

This "polled gpio keys" driver was your invention. FWIW, I think your upcoming updated version should be given consideration before proceeding with the collection of patches discussed above.

Quoted 4 lines

The original driver was a part of a patch-set which adds support for a new MIPS platform. There are a couple of patches in that series which requires this one. It would be nice if the driver would be able to go through the MIPS tree to avoid cross-tree dependencies.

Since the da850-evm series which depends on this patch is proposed for the linux-davinci tree I think that to avoid cross-tree dependencies they would all need to be taken in one tree. That is, unless there is zero chance of the da850-evm series being taken-up for 2.6.38 along with this driver. I have added Kevin Hilman, the linux-davinci maintainer, and Sekhar Nori, the da850-evm maintainer, to the CC of this email so that they can participate in the discussion of when and how the patches should be merged.

Kevin, Sekhar, do you think that "da850-evm: add gpio-{keys,leds} for UI and BB expanders" could be queued for 2.6.38?

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#30 lore raw

Re: [PATCH WIP 0/6] suggested changes to gpio_buttons driver

Hi Ben, Dmitry,

Quoted 22 lines
Quoted 3 lines

<...>
It works for me, however I have additional fixes on top of Ben's changes. I will post an updated version soon.

This "polled gpio keys" driver was your invention. FWIW, I think your upcoming updated version should be given consideration before proceeding with the collection of patches discussed above.

Quoted 4 lines

The original driver was a part of a patch-set which adds support for a new MIPS platform. There are a couple of patches in that series which requires this one. It would be nice if the driver would be able to go through the MIPS tree to avoid cross-tree dependencies.

Since the da850-evm series which depends on this patch is proposed for the linux-davinci tree I think that to avoid cross-tree dependencies they would all need to be taken in one tree. That is, unless there is zero chance of the da850-evm series being taken-up for 2.6.38 along with this driver. I have added Kevin Hilman, the linux-davinci maintainer, and Sekhar Nori, the da850-evm maintainer, to the CC of this email so that they can participate in the discussion of when and how the patches should be merged.

Quoted 2 lines

Kevin, Sekhar, do you think that "da850-evm: add gpio-{keys,leds} for UI and BB expanders" could be queued for 2.6.38?

Well, I had to rethink that a bit. In my original patch-set I have several patches which must be acked by other subsystem maintainers.

Given the possibility that my patch-set will not be merged for 2.6.38 I will drop the driver from that set so the driver can go through any tree. Additionally I will post my changes in a follow up e-mail. Those changes goes on top of Dmitry's changes, so the whole stuff can be folded into the original patch.

Regards,
Gabor

#31 lore raw

cover input: gpio_keys_polled fixes

This set contains my latest fixes on top of Dmitry's changes.

Gabor Juhos (8):
input: gpio_keys_polled: add MODULE_ALIAS
input: gpio_keys_polled: return -EINVAL if wakeup specified
input: gpio_keys_polled: avoid possible division by zero
input: gpio_keys_polled: use DIV_ROUND_UP to compute the threshold value
input: gpio_keys_polled: precompute threshold value in the probe routine
input: gpio_keys_polled: use tabs instead of spaces for indentation
input: gpio_keys_polled: remove a local variable
input: gpio_keys_polled: fix Kconfig help text

 drivers/input/keyboard/Kconfig            |    4 +-
 drivers/input/keyboard/gpio_keys_polled.c |   30 +++++++++++++++-------------
 2 files changed, 18 insertions(+), 16 deletions(-)
Signature · 1 line
1.7.2.1
Tested-by on the v1 series
#32 lore raw

Re: [PATCH 0/8] input: gpio_keys_polled fixes

Hi Gabor,

Quoted 7 lines · Gabor Juhos

This set contains my latest fixes on top of Dmitry's changes.

Gabor Juhos (8):
 input: gpio_keys_polled: add MODULE_ALIAS

 input: gpio_keys_polled: return -EINVAL if wakeup specified
 input: gpio_keys_polled: avoid possible division by zero

Good idea to return -EINVAL in those cases.

Quoted 1 line

 input: gpio_keys_polled: use DIV_ROUND_UP to compute the threshold value

That's what I was looking for, thank you for fixing that up.

Quoted 1 line

 input: gpio_keys_polled: precompute threshold value in the probe routine

Even better.

Quoted 3 lines

 input: gpio_keys_polled: use tabs instead of spaces for indentation
 input: gpio_keys_polled: remove a local variable
 input: gpio_keys_polled: fix Kconfig help text

I missed that remaining gpio-buttons reference, thanks for catching that.

Quoted 3 lines

 drivers/input/keyboard/Kconfig            |    4 +- drivers/input/keyboard/gpio_keys_polled.c |   30 +++++++++++++++-------------

 2 files changed, 18 insertions(+), 16 deletions(-)

I have tested this series with the "da850-evm: add gpio-{keys,leds} for UI and BB expanders" on top of your "[PATCH 09/18] input: add input driver for polled GPIO buttons" patch, my "[PATCH WIP 0/6] suggested changes to gpio_buttons driver" series and Dmitry's "Input:
gpio-buttons - misc changes" patch.

Only minimal changes were needed in the later patches of the da850-evm series. They can be summarized by:
s/gpio_keys_polled\.h/gpio_keys.\h/g and s/gpio_keys_polled_platform_data/gpio_keys_platform_data/g.

With those changes I observed the expected input events with evtest.

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#33 lore raw

Re: [PATCH 0/8] input: gpio_keys_polled fixes

Hi Ben,

Quoted 7 lines

<...>
I have tested this series with the "da850-evm: add gpio-{keys,leds} for UI and BB expanders" on top of your "[PATCH 09/18] input: add input driver for polled GPIO buttons" patch, my "[PATCH WIP 0/6] suggested changes to gpio_buttons driver" series and Dmitry's "Input:
gpio-buttons - misc changes" patch.

Quoted 6 lines

Only minimal changes were needed in the later patches of the da850-evm series. They can be summarized by:
s/gpio_keys_polled\.h/gpio_keys.\h/g and s/gpio_keys_polled_platform_data/gpio_keys_platform_data/g.

With those changes I observed the expected input events with evtest.

Superb.

Quoted 1 line

Thank you for the continuous testing.

Regards,
Gabor

maintainer
#34 lore raw

Re: [PATCH 0/8] input: gpio_keys_polled fixes

In reply to Ben Gardiner
Quoted 27 lines · Ben Gardiner

Hi Gabor,

Quoted 7 lines · Gabor Juhos

This set contains my latest fixes on top of Dmitry's changes.

Gabor Juhos (8):
 input: gpio_keys_polled: add MODULE_ALIAS

 input: gpio_keys_polled: return -EINVAL if wakeup specified
 input: gpio_keys_polled: avoid possible division by zero

Good idea to return -EINVAL in those cases.

Quoted 1 line

 input: gpio_keys_polled: use DIV_ROUND_UP to compute the threshold value

That's what I was looking for, thank you for fixing that up.

Quoted 1 line

 input: gpio_keys_polled: precompute threshold value in the probe routine

Even better.

Quoted 3 lines

 input: gpio_keys_polled: use tabs instead of spaces for indentation
 input: gpio_keys_polled: remove a local variable
 input: gpio_keys_polled: fix Kconfig help text

I missed that remaining gpio-buttons reference, thanks for catching that.

Quoted 3 lines

 drivers/input/keyboard/Kconfig            |    4 +- drivers/input/keyboard/gpio_keys_polled.c |   30 +++++++++++++++-------------

 2 files changed, 18 insertions(+), 16 deletions(-)
Quoted 5 lines

I have tested this series with the "da850-evm: add gpio-{keys,leds} for UI and BB expanders" on top of your "[PATCH 09/18] input: add input driver for polled GPIO buttons" patch, my "[PATCH WIP 0/6] suggested changes to gpio_buttons driver" series and Dmitry's "Input:
gpio-buttons - misc changes" patch.

Ok, so driver is in mainline now and you should have no problems with merging your platform code in .38 merge window.

Thanks.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#35 lore raw

Re: [PATCH 0/8] input: gpio_keys_polled fixes

Hi Dmitry,

Quoted 3 lines

<...>
Ok, so driver is in mainline now and you should have no problems with merging your platform code in .38 merge window.

Thank you!

-Gabor

#36 lore raw

Re: [PATCH 0/8] input: gpio_keys_polled fixes

In reply to Dmitry Torokhov

Hi Dmitry,

Quoted 1 line · Dmitry Torokhov

Ok, so driver is in mainline now [...]

I see it in v2.6.37-rc5 (at 0e7d0c860a0dee49dacb7bbb248d1eba637075ad ). With all the changes proposed folded-in and even a little Kconfig help text fixup. It is (still) working as expected.

Thank you very much for picking up the driver changes...

Quoted 2 lines

[...] and you should have no problems with
merging your platform code in .38 merge window.

and thank you for the vote of confidence. I will post an updated version shortly.

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca

#37 lore raw

PATCH 1/8 input: gpio_keys_polled: add MODULE_ALIAS

In reply to Gabor Juhos
---
 drivers/input/keyboard/gpio_keys_polled.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +1 -0
index 6ed6910..1bd335b 100644
@@ -258,3 +258,4 @@ module_exit(gpio_keys_polled_exit);
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Gabor Juhos <[email protected]>");
 MODULE_DESCRIPTION("Polled GPIO Buttons driver");
+MODULE_ALIAS("platform:" DRV_NAME)
Signature · 1 line
1.7.2.1
#38 lore raw

PATCH 2/8 input: gpio_keys_polled: return -EINVAL if wakeup specified

In reply to Gabor Juhos
---
 drivers/input/keyboard/gpio_keys_polled.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +1 -0
index 1bd335b..5275c9e 100644
@@ -157,6 +157,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 
 		if (button->wakeup) {
 			dev_err(dev, DRV_NAME " does not support wakeup\n");
+			error = -EINVAL;
 			goto err_free_gpio;
 		}
 
Signature · 1 line
1.7.2.1
#39 lore raw

PATCH 3/8 input: gpio_keys_polled: avoid possible division by zero

In reply to Gabor Juhos

The poll_interval field is used as a divider in the computation of the threshold value. Check the passed value in the probe routine, and return -EINVAL if it has not been set in the platform data.

---
 drivers/input/keyboard/gpio_keys_polled.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +2 -2
index 5275c9e..9636c2f 100644
@@ -114,8 +114,8 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 	int error;
 	int i;
 
-	if (!pdata)
-		return -ENXIO;
+	if (!pdata || !pdata->poll_interval)
+		return -EINVAL;
 
 	bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
 		       pdata->nbuttons * sizeof(struct gpio_keys_button_data),
Signature · 1 line
1.7.2.1
#40 lore raw

PATCH 4/8 input: gpio_keys_polled: use DIV_ROUND_UP to compute the threshold value

In reply to Gabor Juhos
---
 drivers/input/keyboard/gpio_keys_polled.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +2 -3
index 9636c2f..c9e0d1c 100644
@@ -75,9 +75,8 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
 		struct gpio_keys_button *button = &pdata->buttons[i];
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
 
-		threshold = round_up(button->debounce_interval,
-				pdata->poll_interval) /
-				pdata->poll_interval;
+		threshold = DIV_ROUND_UP(button->debounce_interval,
+					 pdata->poll_interval);
 		if (bdata->count < threshold)
 			bdata->count++;
 		else
Signature · 1 line
1.7.2.1
#41 lore raw

PATCH 5/8 input: gpio_keys_polled: precompute threshold value in the probe routine

In reply to Gabor Juhos

The threshold value will be a constant, so precompute that at probe time to save a few cycles in the polling thread. Also introduce a new bdata local variable in the probe routine to improve readability.

---
 drivers/input/keyboard/gpio_keys_polled.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +8 -6
index c9e0d1c..5af0be9 100644
@@ -32,6 +32,7 @@
 struct gpio_keys_button_data {
 	int last_state;
 	int count;
+	int threshold;
 	int can_sleep;
 };
 
@@ -69,15 +70,13 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
 	struct gpio_keys_polled_dev *bdev = dev->private;
 	struct gpio_keys_platform_data *pdata = bdev->pdata;
 	struct input_dev *input = dev->input;
-	int i, threshold;
+	int i;
 
 	for (i = 0; i < bdev->pdata->nbuttons; i++) {
 		struct gpio_keys_button *button = &pdata->buttons[i];
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
 
-		threshold = DIV_ROUND_UP(button->debounce_interval,
-					 pdata->poll_interval);
-		if (bdata->count < threshold)
+		if (bdata->count < bdata->threshold)
 			bdata->count++;
 		else
 			gpio_keys_polled_check_state(input, button, bdata);
@@ -151,6 +150,7 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 
 	for (i = 0; i < pdata->nbuttons; i++) {
 		struct gpio_keys_button *button = &pdata->buttons[i];
+		struct gpio_keys_button_data *bdata = &bdev->data[i];
 		unsigned int gpio = button->gpio;
 		unsigned int type = button->type ?: EV_KEY;
 
@@ -176,8 +176,10 @@ static int __devinit gpio_keys_polled_probe(struct platform_device *pdev)
 			goto err_free_gpio;
 		}
 
-		bdev->data[i].can_sleep = gpio_cansleep(gpio);
-		bdev->data[i].last_state = -1;
+		bdata->can_sleep = gpio_cansleep(gpio);
+		bdata->last_state = -1;
+		bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
+						pdata->poll_interval);
 
 		input_set_capability(input, type, button->code);
 	}
Signature · 1 line
1.7.2.1
#42 lore raw

PATCH 6/8 input: gpio_keys_polled: use tabs instead of spaces for indentation

In reply to Gabor Juhos
---
 drivers/input/keyboard/gpio_keys_polled.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +2 -2
index 5af0be9..7b6a333 100644
@@ -44,8 +44,8 @@ struct gpio_keys_polled_dev {
 };
 
 static void gpio_keys_polled_check_state(struct input_dev *input,
-				      struct gpio_keys_button *button,
-				      struct gpio_keys_button_data *bdata)
+					 struct gpio_keys_button *button,
+					 struct gpio_keys_button_data *bdata)
 {
 	int state;
 
Signature · 1 line
1.7.2.1
#43 lore raw

PATCH 7/8 input: gpio_keys_polled: remove a local variable

In reply to Gabor Juhos

The 'button' variable is used only once in the gpio_keys_polled_poll routine. Remove that and use the '&pdata->buttons[i]' value directly instead.

---
 drivers/input/keyboard/gpio_keys_polled.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +2 -3
index 7b6a333..61e1a92 100644
@@ -73,14 +73,13 @@ static void gpio_keys_polled_poll(struct input_polled_dev *dev)
 	int i;
 
 	for (i = 0; i < bdev->pdata->nbuttons; i++) {
-		struct gpio_keys_button *button = &pdata->buttons[i];
 		struct gpio_keys_button_data *bdata = &bdev->data[i];
 
 		if (bdata->count < bdata->threshold)
 			bdata->count++;
 		else
-			gpio_keys_polled_check_state(input, button, bdata);
-
+			gpio_keys_polled_check_state(input, &pdata->buttons[i],
+						     bdata);
 	}
 }
 
Signature · 1 line
1.7.2.1
#44 lore raw

PATCH 8/8 input: gpio_keys_polled: fix Kconfig help text

In reply to Gabor Juhos
---
 drivers/input/keyboard/Kconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/Kconfig +2 -2
index 9648ff4..897b758 100644
@@ -491,7 +491,7 @@ config KEYBOARD_GPIO_POLLED
 	select INPUT_POLLDEV
 	help
 	  This driver implements support for buttons connected
-	  to GPIO pins of various CPUs (and some other chips).
+	  to GPIO pins which is not capable to generate interrupts.
 
 	  Say Y here if your device has buttons connected
 	  directly to such GPIO pins.  Your board-specific
@@ -499,6 +499,6 @@ config KEYBOARD_GPIO_POLLED
 	  with configuration data saying which GPIOs are used.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called gpio-buttons.
+	  module will be called gpio_keys_polled.
 
 endif
Signature · 1 line
1.7.2.1
#45 lore raw

Re: [PATCH 8/8] input: gpio_keys_polled: fix Kconfig help text

drivers/input/keyboard/Kconfig config KEYBOARD_GPIO_POLLED · line 491

Quoted 5 lines · Gabor Juhos
drivers/input/keyboard/Kconfig +1 -1
@@ -491,7 +491,7 @@ config KEYBOARD_GPIO_POLLED
-	  to GPIO pins of various CPUs (and some other chips).
+	  to GPIO pins which is not capable to generate interrupts.

I suggest s/is/are/ or perhaps even s/which is //.

Signature · 2 lines
Great stuff, thanks!
Feri.
#46 lore raw

Re: [PATCH 8/8] input: gpio_keys_polled: fix Kconfig help text

2010.12.01. 23:53 keltezéssel, Ferenc Wagner írta:

Quoted 9 lines

drivers/input/keyboard/Kconfig config KEYBOARD_GPIO_POLLED · line 491

Quoted 5 lines · Gabor Juhos
drivers/input/keyboard/Kconfig +1 -1
@@ -491,7 +491,7 @@ config KEYBOARD_GPIO_POLLED
-	  to GPIO pins of various CPUs (and some other chips).
+	  to GPIO pins which is not capable to generate interrupts.

I suggest s/is/are/ or perhaps even s/which is //.

Ok, i will send an updated patch.

Thanks,
Gabor
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#47 lore raw

PATCH v2 8/8 input: gpio_keys_polled: fix Kconfig help text

In reply to Gabor Juhos

---
Changes since v1:
- remove 'which is ' from the help text

 drivers/input/keyboard/Kconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/Kconfig +2 -2
index 9648ff4..897b758 100644
@@ -491,7 +491,7 @@ config KEYBOARD_GPIO_POLLED
 	select INPUT_POLLDEV
 	help
 	  This driver implements support for buttons connected
-	  to GPIO pins of various CPUs (and some other chips).
+	  to GPIO pins not capable to generate interrupts.
 
 	  Say Y here if your device has buttons connected
 	  directly to such GPIO pins.  Your board-specific
@@ -499,6 +499,6 @@ config KEYBOARD_GPIO_POLLED
 	  with configuration data saying which GPIOs are used.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called gpio-buttons.
+	  module will be called gpio_keys_polled.
 
 endif
Signature · 1 line
1.7.2.1
maintainer
#48 lore raw

Re: [PATCH 09/18] input: add input driver for polled GPIO buttons

In reply to Gabor Juhos
Quoted 4 lines · Gabor Juhos

+ *
+ * This file was based on: /include/linux/gpio_keys.h
+ * The original gpio_keys.h seems not to have a license.
+ *

This is incorrect statement. Unless otherwise specified Linux kernel sources are licensed under GPL v2.

Thanks.

Signature · 1 line
Dmitry
#49 lore raw

PATCH 10/18 MIPS: ath79: add common GPIO buttons device

In reply to Gabor Juhos

Almost all boards have one or more push buttons connected to GPIO lines. This patch adds common code to register a platform_device for them.

The patch also adds support for the buttons on the PB44 board.

---

Changes since RFC: ---

 arch/mips/ath79/Kconfig            |    4 ++
 arch/mips/ath79/Makefile           |    1 +
 arch/mips/ath79/dev-gpio-buttons.c |   58 ++++++++++++++++++++++++++++++++++++
 arch/mips/ath79/dev-gpio-buttons.h |   23 ++++++++++++++
 arch/mips/ath79/mach-pb44.c        |   26 ++++++++++++++++
 5 files changed, 112 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/dev-gpio-buttons.c
 create mode 100644 arch/mips/ath79/dev-gpio-buttons.h
arch/mips/ath79/Kconfig +4 -0
index 5bc480e..185a8d6 100644
@@ -5,6 +5,7 @@ menu "Atheros AR71XX/AR724X/AR913X machine selection"
 config ATH79_MACH_PB44
 	bool "Atheros PB44 reference board"
 	select SOC_AR71XX
+	select ATH79_DEV_GPIO_BUTTONS
 	select ATH79_DEV_LEDS_GPIO
 	help
 	  Say 'Y' here if you want your kernel to support the
@@ -21,6 +22,9 @@ config SOC_AR724X
 config SOC_AR913X
 	def_bool n
 
+config ATH79_DEV_GPIO_BUTTONS
+	def_bool n
+
 config ATH79_DEV_LEDS_GPIO
 	def_bool n
 
arch/mips/ath79/Makefile +1 -0
index d14b597..0ceb45e 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
 # Devices
 #
 obj-y					+= dev-common.o
+obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS)	+= dev-gpio-buttons.o
 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)	+= dev-leds-gpio.o
 
 #
arch/mips/ath79/dev-gpio-buttons.c new file +58 -0

58 lines not on this page · raw message

arch/mips/ath79/dev-gpio-buttons.h new file +23 -0
new file mode 100644
index 0000000..57bf1d6f
@@ -0,0 +1,23 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X GPIO button support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_DEV_GPIO_BUTTONS_H
+#define _ATH79_DEV_GPIO_BUTTONS_H
+
+#include <linux/input.h>
+#include <linux/gpio_buttons.h>
+
+void ath79_register_gpio_buttons(int id,
+				 unsigned poll_interval,
+				 unsigned nbuttons,
+				 struct gpio_button *buttons) __init;
+
+#endif /* _ATH79_DEV_GPIO_BUTTONS_H */
arch/mips/ath79/mach-pb44.c +26 -0
index e176779..5e7b544 100644
@@ -15,15 +15,20 @@
 #include <linux/i2c/pcf857x.h>
 
 #include "machtypes.h"
+#include "dev-gpio-buttons.h"
 #include "dev-leds-gpio.h"
 
 #define PB44_GPIO_I2C_SCL	0
 #define PB44_GPIO_I2C_SDA	1
 
 #define PB44_GPIO_EXP_BASE	16
+#define PB44_GPIO_SW_RESET	(PB44_GPIO_EXP_BASE + 6)
+#define PB44_GPIO_SW_JUMP	(PB44_GPIO_EXP_BASE + 8)
 #define PB44_GPIO_LED_JUMP1	(PB44_GPIO_EXP_BASE + 9)
 #define PB44_GPIO_LED_JUMP2	(PB44_GPIO_EXP_BASE + 10)
 
+#define PB44_BUTTONS_POLL_INTERVAL	20
+
 static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
 	.sda_pin        = PB44_GPIO_I2C_SDA,
 	.scl_pin        = PB44_GPIO_I2C_SCL,
@@ -60,6 +65,24 @@ static struct gpio_led pb44_leds_gpio[] __initdata = {
 	},
 };
 
+static struct gpio_button pb44_gpio_buttons[] __initdata = {
+	{
+		.desc		= "soft_reset",
+		.type		= EV_KEY,
+		.code		= KEY_RESTART,
+		.threshold	= 3,
+		.gpio		= PB44_GPIO_SW_RESET,
+		.active_low	= 1,
+	} , {
+		.desc		= "jumpstart",
+		.type		= EV_KEY,
+		.code		= KEY_WPS_BUTTON,
+		.threshold	= 3,
+		.gpio		= PB44_GPIO_SW_JUMP,
+		.active_low	= 1,
+	}
+};
+
 static void __init pb44_init(void)
 {
 	i2c_register_board_info(0, pb44_i2c_board_info,
@@ -68,6 +91,9 @@ static void __init pb44_init(void)
 
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
 				 pb44_leds_gpio);
+	ath79_register_gpio_buttons(-1, PB44_BUTTONS_POLL_INTERVAL,
+				    ARRAY_SIZE(pb44_gpio_buttons),
+				    pb44_gpio_buttons);
 }
 
 MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
Signature · 1 line
1.7.2.1
#50 lore raw

PATCH 11/18 spi: add SPI controller driver for the Atheros AR71XX/AR724X/AR913X SoCs

In reply to Gabor Juhos

The Atheros AR71XX/AR724X/AR913X SoCs have a built-in SPI controller. This patch implements a driver for that.

Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc David Brownell <[email protected]>
Cc spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

---

Changes since RFC:
- remove DRV_DESC definition and use its previous value directly in the MODULE_DESCRIPTION() macro,
- use io{read,write}32 accesors instead of __raw_{read,write}l,
- use __dev{init,exit,exit_p} annotations where in the appropriate places,
- initialize 'master->bus_num' field to -1 if no platform data specified, so that a bus number can be dynamically assigned,
- rename ath79_spi_drv to ath79_spi_driver to avoid section mismatch warnings

 .../include/asm/mach-ath79/ath79_spi_platform.h    |   19 ++
 drivers/spi/Kconfig                                |    8 +
 drivers/spi/Makefile                               |    1 +
 drivers/spi/ath79_spi.c                            |  290 ++++++++++++++++++++
 4 files changed, 318 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-ath79/ath79_spi_platform.h
 create mode 100644 drivers/spi/ath79_spi.c
arch/mips/include/asm/mach-ath79/ath79_spi_platform.h new file +19 -0
new file mode 100644
index 0000000..aa71216
@@ -0,0 +1,19 @@
+/*
+ *  Platform data definition for Atheros AR71XX/AR724X/AR913X SPI controller
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_SPI_PLATFORM_H
+#define _ATH79_SPI_PLATFORM_H
+
+struct ath79_spi_platform_data {
+	unsigned	bus_num;
+	unsigned	num_chipselect;
+};
+
+#endif /* _ATH79_SPI_PLATFORM_H */
drivers/spi/Kconfig +8 -0
index 78f9fd0..f2093e1 100644
@@ -53,6 +53,14 @@ if SPI_MASTER
 
 comment "SPI Master Controller Drivers"
 
+config SPI_ATH79
+	tristate "Atheros AR71XX/AR724X/AR913X SPI controller driver"
+	depends on ATH79 && GENERIC_GPIO
+	select SPI_BITBANG
+	help
+	  This enables support for the SPI controller present on the
+	  Atheros AR71XX/AR724X/AR913X SoCs.
+
 config SPI_ATMEL
 	tristate "Atmel SPI Controller"
 	depends on (ARCH_AT91 || AVR32)
drivers/spi/Makefile +1 -0
index 8bc1a5a..875bc3d 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_SPI_MASTER)		+= spi.o
 
 # SPI master controller drivers (bus)
 obj-$(CONFIG_SPI_ATMEL)			+= atmel_spi.o
+obj-$(CONFIG_SPI_ATH79)			+= ath79_spi.o
 obj-$(CONFIG_SPI_BFIN)			+= spi_bfin5xx.o
 obj-$(CONFIG_SPI_BITBANG)		+= spi_bitbang.o
 obj-$(CONFIG_SPI_AU1550)		+= au1550_spi.o
drivers/spi/ath79_spi.c new file +290 -0

290 lines not on this page · raw message

Signature · 9 lines
1.7.2.1


------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
#51 lore raw

PATCH 12/18 MIPS: ath79: add common SPI controller device

In reply to Gabor Juhos

Several boards are using the built-in SPI controller of the AR71XX/AR724X/AR913X SoCs. This patch adds common platform_device and helper code to register it. Additionally, the patch registers the SPI bus on the PB44 board.

---

Changes since RFC: ---

 arch/mips/ath79/Kconfig                        |    4 ++
 arch/mips/ath79/Makefile                       |    1 +
 arch/mips/ath79/dev-spi.c                      |   38 ++++++++++++++++++++++++
 arch/mips/ath79/dev-spi.h                      |   22 ++++++++++++++
 arch/mips/ath79/mach-pb44.c                    |   17 ++++++++++
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h |    2 +
 6 files changed, 84 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/dev-spi.c
 create mode 100644 arch/mips/ath79/dev-spi.h
arch/mips/ath79/Kconfig +4 -0
index 185a8d6..cd6c738 100644
@@ -7,6 +7,7 @@ config ATH79_MACH_PB44
 	select SOC_AR71XX
 	select ATH79_DEV_GPIO_BUTTONS
 	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_SPI
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Atheros PB44 reference board.
@@ -28,4 +29,7 @@ config ATH79_DEV_GPIO_BUTTONS
 config ATH79_DEV_LEDS_GPIO
 	def_bool n
 
+config ATH79_DEV_SPI
+	def_bool n
+
 endif
arch/mips/ath79/Makefile +1 -0
index 0ceb45e..a8de078 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
 obj-y					+= dev-common.o
 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS)	+= dev-gpio-buttons.o
 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)	+= dev-leds-gpio.o
+obj-$(CONFIG_ATH79_DEV_SPI)		+= dev-spi.o
 
 #
 # Machines
arch/mips/ath79/dev-spi.c new file +38 -0
new file mode 100644
index 0000000..aa30163
@@ -0,0 +1,38 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X SPI controller device
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#include <linux/platform_device.h>
+#include <asm/mach-ath79/ar71xx_regs.h>
+#include "dev-spi.h"
+
+static struct resource ath79_spi_resources[] = {
+	{
+		.start	= AR71XX_SPI_BASE,
+		.end	= AR71XX_SPI_BASE + AR71XX_SPI_SIZE - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ath79_spi_device = {
+	.name		= "ath79-spi",
+	.id		= -1,
+	.resource	= ath79_spi_resources,
+	.num_resources	= ARRAY_SIZE(ath79_spi_resources),
+};
+
+void __init ath79_register_spi(struct ath79_spi_platform_data *pdata,
+			       struct spi_board_info const *info,
+			       unsigned n)
+{
+	spi_register_board_info(info, n);
+	ath79_spi_device.dev.platform_data = pdata;
+	platform_device_register(&ath79_spi_device);
+}
arch/mips/ath79/dev-spi.h new file +22 -0
new file mode 100644
index 0000000..9a98333
@@ -0,0 +1,22 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X SPI controller device
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_DEV_SPI_H
+#define _ATH79_DEV_SPI_H
+
+#include <linux/spi/spi.h>
+#include <asm/mach-ath79/ath79_spi_platform.h>
+
+void __init ath79_register_spi(struct ath79_spi_platform_data *pdata,
+			       struct spi_board_info const *info,
+			       unsigned n);
+
+#endif /* _ATH79_DEV_SPI_H */
arch/mips/ath79/mach-pb44.c +17 -0
index 5e7b544..257815e 100644
@@ -17,6 +17,7 @@
 #include "machtypes.h"
 #include "dev-gpio-buttons.h"
 #include "dev-leds-gpio.h"
+#include "dev-spi.h"
 
 #define PB44_GPIO_I2C_SCL	0
 #define PB44_GPIO_I2C_SDA	1
@@ -83,6 +84,20 @@ static struct gpio_button pb44_gpio_buttons[] __initdata = {
 	}
 };
 
+static struct spi_board_info pb44_spi_info[] = {
+	{
+		.bus_num	= 0,
+		.chip_select	= 0,
+		.max_speed_hz	= 25000000,
+		.modalias	= "m25p64",
+	},
+};
+
+static struct ath79_spi_platform_data pb44_spi_data = {
+	.bus_num		= 0,
+	.num_chipselect		= 1,
+};
+
 static void __init pb44_init(void)
 {
 	i2c_register_board_info(0, pb44_i2c_board_info,
@@ -94,6 +109,8 @@ static void __init pb44_init(void)
 	ath79_register_gpio_buttons(-1, PB44_BUTTONS_POLL_INTERVAL,
 				    ARRAY_SIZE(pb44_gpio_buttons),
 				    pb44_gpio_buttons);
+	ath79_register_spi(&pb44_spi_data, pb44_spi_info,
+			   ARRAY_SIZE(pb44_spi_info));
 }
 
 MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
arch/mips/include/asm/mach-ath79/ar71xx_regs.h +2 -0
index 7f2933d..4f2b621 100644
@@ -20,6 +20,8 @@
 #include <linux/bitops.h>
 
 #define AR71XX_APB_BASE		0x18000000
+#define AR71XX_SPI_BASE		0x1f000000
+#define AR71XX_SPI_SIZE		0x01000000
 
 #define AR71XX_DDR_CTRL_BASE	(AR71XX_APB_BASE + 0x00000000)
 #define AR71XX_DDR_CTRL_SIZE	0x100
Signature · 1 line
1.7.2.1
#52 lore raw

PATCH 13/18 USB: ehci: add workaround for Synopsys HC bug

In reply to Gabor Juhos

A Synopsys USB core used in various SoCs has a bug which might cause that the host controller not issuing ping.

When software uses the Doorbell mechanism to remove queue heads, the host controller still has references to the removed queue head even after indicating an Interrupt on Async Advance. This happens if the last executed queue head's Next Link queue head is removed.

Consequences of the defect:
The Host controller fetches the removed queue head, using memory that would otherwise be deallocated.This results in incorrect transactions on both the USB and system memory. This may result in undefined behavior.

Workarounds:

1) If no queue head is active (no Status field's Active bit is set) after removing the queue heads, the software can write one of the valid queue head addresses to the ASYNCLISTADDR register and deallocate the removed queue head's memory after 2 microframes.

If one or more of the queue heads is active (the Active bit is set in the Status field) after removing the queue heads, the software can delay memory deallocation after time X, where X is the time required for the Host Controller to go through all the queue heads once. X varies with the number of queue heads and the time required to process periodic
transactions: if more periodic transactions must be performed, the Host Controller has less time to process asynchronous transaction processing.

2) Do not use the Doorbell mechanism to remove the queue heads. Disable the Asynchronous Schedule Enable bit instead.

The bug has been discussed on the linux-usb-devel mailing-list four years ago, the original thread can be found here:
http://www.mail-archive.com/[email protected]/msg45345.html

This patch implements the first workaround as suggested by David Brownell. The built-in USB host controller of the Atheros AR7130/AR7141/AR7161 SoCs requires this to work properly.

Cc David Brownell <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

---

Changes since RFC: ---

 drivers/usb/host/ehci-q.c |    3 +++
 drivers/usb/host/ehci.h   |    1 +
 2 files changed, 4 insertions(+), 0 deletions(-)
drivers/usb/host/ehci-q.c +3 -0
index 233c288..343b8de 100644
@@ -1193,6 +1193,9 @@ static void end_unlink_async (struct ehci_hcd *ehci)
 		ehci->reclaim = NULL;
 		start_unlink_async (ehci, next);
 	}
+
+	if (ehci->has_synopsys_hc_bug)
+		writel((u32)ehci->async->qh_dma, &ehci->regs->async_next);
 }
 
 /* makes sure the async qh will become idle */
drivers/usb/host/ehci.h +1 -0
index bde823f..7c0151a 100644
@@ -131,6 +131,7 @@ struct ehci_hcd {			/* one per controller */
 	unsigned		need_io_watchdog:1;
 	unsigned		broken_periodic:1;
 	unsigned		fs_i_thresh:1;	/* Intel iso scheduling */
+	unsigned		has_synopsys_hc_bug:1; /* Synopsys HC */
 
 	/* required for usb32 quirk */
 	#define OHCI_CTRL_HCFS          (3 << 6)
Signature · 1 line
1.7.2.1
#53 lore raw

PATCH 14/18 USB: ehci: add bus glue for the Atheros AR71XX/AR724X/AR913X SoCs

In reply to Gabor Juhos

The Atheros AR71XX/AR724X/AR913X SoCs have a built-in EHCI controller. This patch adds the necessary glue code to make the generic EHCI driver usable for them.

---

Changes since RFC:
- don't use 'default y if SOC_*', select USB_ARCH_HAS_EHCI option in the platform specific Kconfig file instead
- add missing 'ath79_ehci_platform.h' file

 arch/mips/ath79/Kconfig                            |    3 +
 .../include/asm/mach-ath79/ath79_ehci_platform.h   |   18 ++
 drivers/usb/host/Kconfig                           |    8 +
 drivers/usb/host/ehci-ath79.c                      |  176 ++++++++++++++++++++
 drivers/usb/host/ehci-hcd.c                        |    5 +
 5 files changed, 210 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-ath79/ath79_ehci_platform.h
 create mode 100644 drivers/usb/host/ehci-ath79.c
arch/mips/ath79/Kconfig +3 -0
index cd6c738..647f535 100644
@@ -15,12 +15,15 @@ config ATH79_MACH_PB44
 endmenu
 
 config SOC_AR71XX
+	select USB_ARCH_HAS_EHCI
 	def_bool n
 
 config SOC_AR724X
+	select USB_ARCH_HAS_EHCI
 	def_bool n
 
 config SOC_AR913X
+	select USB_ARCH_HAS_EHCI
 	def_bool n
 
 config ATH79_DEV_GPIO_BUTTONS
arch/mips/include/asm/mach-ath79/ath79_ehci_platform.h new file +18 -0
new file mode 100644
index 0000000..6ee075f
@@ -0,0 +1,18 @@
+/*
+ *  Platform data definition for Atheros AR71XX/AR913X EHCI controller
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_EHCI_PLATFORM_H
+#define _ATH79_EHCI_PLATFORM_H
+
+struct ath79_ehci_platform_data {
+	u8	is_ar913x;
+};
+
+#endif /* _ATH79_EHCI_PLATFORM_H */
drivers/usb/host/Kconfig +8 -0
index 6f4f8e6..3a2667a 100644
@@ -147,6 +147,14 @@ config USB_W90X900_EHCI
 	---help---
 		Enables support for the W90X900 USB controller
 
+config USB_EHCI_ATH79
+	bool "EHCI support for AR71XX/AR724X/AR913X SoCs"
+	depends on USB_EHCI_HCD && ATH79
+	select USB_EHCI_ROOT_HUB_TT
+	---help---
+	  Enables support for the built-in EHCI controller present
+	  on the Atheros AR71XX/AR724X/AR913X SoCs.
+
 config USB_OXU210HP_HCD
 	tristate "OXU210HP HCD support"
 	depends on USB
drivers/usb/host/ehci-ath79.c new file +176 -0

176 lines not on this page · raw message

drivers/usb/host/ehci-hcd.c +5 -0
index 502a7e6..82f74aa 100644
@@ -1216,6 +1216,11 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_octeon_driver
 #endif
 
+#ifdef CONFIG_USB_EHCI_ATH79
+#include "ehci-ath79.c"
+#define PLATFORM_DRIVER		ehci_ath79_driver
+#endif
+
 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
     !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
     !defined(XILINX_OF_PLATFORM_DRIVER)
Signature · 1 line
1.7.2.1
#54 lore raw

PATCH 15/18 USB: ohci: add bus glue for the Atheros AR71XX/AR7240 SoCs

In reply to Gabor Juhos

The Atheros AR71XX/AR7240 SoCs have a built-in OHCI controller. This patch adds the necessary glue code to make the generic OHCI driver usable for them.

---

Changes since RFC:
- don't use 'defauly y if SOC_*', select the USB_ARCH_HAS_OHCI option in the platform specific Kconfig file instead
- remove ath79_ehci_platform.h, it belongs to the EHCI patch

 arch/mips/ath79/Kconfig       |    2 +
 drivers/usb/host/Kconfig      |    8 ++
 drivers/usb/host/ohci-ath79.c |  162 +++++++++++++++++++++++++++++++++++++++++
 drivers/usb/host/ohci-hcd.c   |    5 +
 4 files changed, 177 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/host/ohci-ath79.c
arch/mips/ath79/Kconfig +2 -0
index 647f535..d4456ce 100644
@@ -16,10 +16,12 @@ endmenu
 
 config SOC_AR71XX
 	select USB_ARCH_HAS_EHCI
+	select USB_ARCH_HAS_OHCI
 	def_bool n
 
 config SOC_AR724X
 	select USB_ARCH_HAS_EHCI
+	select USB_ARCH_HAS_OHCI
 	def_bool n
 
 config SOC_AR913X
drivers/usb/host/Kconfig +8 -0
index 3a2667a..39ed353 100644
@@ -240,6 +240,14 @@ config USB_OHCI_HCD_OMAP3
 	  Enables support for the on-chip OHCI controller on
 	  OMAP3 and later chips.
 
+config USB_OHCI_ATH79
+	bool "USB OHCI support for the Atheros AR71XX/AR724X SoCs"
+	depends on USB_OHCI_HCD && (SOC_AR71XX || SOC_AR724X)
+	default y
+	help
+	  Enables support for the uilt-in OHCI controller present on the
+	  Atheros AR71XX/AR724X SoCs.
+
 config USB_OHCI_HCD_PPC_SOC
 	bool "OHCI support for on-chip PPC USB controller"
 	depends on USB_OHCI_HCD && (STB03xxx || PPC_MPC52xx)
drivers/usb/host/ohci-ath79.c new file +162 -0

162 lines not on this page · raw message

drivers/usb/host/ohci-hcd.c +5 -0
index 5179acb..6daeb68 100644
@@ -1111,6 +1111,11 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ohci_octeon_driver
 #endif
 
+#ifdef CONFIG_USB_OHCI_ATH79
+#include "ohci-ath79.c"
+#define PLATFORM_DRIVER		ohci_hcd_ath79_driver
+#endif
+
 #if	!defined(PCI_DRIVER) &&		\
 	!defined(PLATFORM_DRIVER) &&	\
 	!defined(OMAP1_PLATFORM_DRIVER) &&	\
Signature · 1 line
1.7.2.1
#55 lore raw

PATCH 16/18 MIPS: ath79: add common USB Host Controller device

In reply to Gabor Juhos

Add common platform_device and helper code to make the registration of the built-in USB controllers easier on the board which are using them. Also register the USB controller on the PB44 board.

---

Changes since RFC: ---

 arch/mips/ath79/Kconfig                        |    4 +
 arch/mips/ath79/Makefile                       |    1 +
 arch/mips/ath79/dev-usb.c                      |  192 ++++++++++++++++++++++++
 arch/mips/ath79/dev-usb.h                      |   17 ++
 arch/mips/ath79/mach-pb44.c                    |    2 +
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h |   15 ++
 6 files changed, 231 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/dev-usb.c
 create mode 100644 arch/mips/ath79/dev-usb.h
arch/mips/ath79/Kconfig +4 -0
index d4456ce..5d67942 100644
@@ -8,6 +8,7 @@ config ATH79_MACH_PB44
 	select ATH79_DEV_GPIO_BUTTONS
 	select ATH79_DEV_LEDS_GPIO
 	select ATH79_DEV_SPI
+	select ATH79_DEV_USB
 	help
 	  Say 'Y' here if you want your kernel to support the
 	  Atheros PB44 reference board.
@@ -37,4 +38,7 @@ config ATH79_DEV_LEDS_GPIO
 config ATH79_DEV_SPI
 	def_bool n
 
+config ATH79_DEV_USB
+	def_bool n
+
 endif
arch/mips/ath79/Makefile +1 -0
index a8de078..494d106 100644
@@ -19,6 +19,7 @@ obj-y					+= dev-common.o
 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS)	+= dev-gpio-buttons.o
 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)	+= dev-leds-gpio.o
 obj-$(CONFIG_ATH79_DEV_SPI)		+= dev-spi.o
+obj-$(CONFIG_ATH79_DEV_USB)		+= dev-usb.o
 
 #
 # Machines
arch/mips/ath79/dev-usb.c new file +192 -0

192 lines not on this page · raw message

arch/mips/ath79/dev-usb.h new file +17 -0
new file mode 100644
index 0000000..dbe6d3d
@@ -0,0 +1,17 @@
+/*
+ *  Atheros AR71XX/AR724X/AR913X USB Host Controller support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_DEV_USB_H
+#define _ATH79_DEV_USB_H
+
+void ath79_register_usb(void) __init;
+
+#endif /* _ATH79_DEV_USB_H */
arch/mips/ath79/mach-pb44.c +2 -0
index 257815e..3e0bb05 100644
@@ -18,6 +18,7 @@
 #include "dev-gpio-buttons.h"
 #include "dev-leds-gpio.h"
 #include "dev-spi.h"
+#include "dev-usb.h"
 
 #define PB44_GPIO_I2C_SCL	0
 #define PB44_GPIO_I2C_SDA	1
@@ -111,6 +112,7 @@ static void __init pb44_init(void)
 				    pb44_gpio_buttons);
 	ath79_register_spi(&pb44_spi_data, pb44_spi_info,
 			   ARRAY_SIZE(pb44_spi_info));
+	ath79_register_usb();
 }
 
 MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
arch/mips/include/asm/mach-ath79/ar71xx_regs.h +15 -0
index 4f2b621..95be423 100644
@@ -20,6 +20,10 @@
 #include <linux/bitops.h>
 
 #define AR71XX_APB_BASE		0x18000000
+#define AR71XX_EHCI_BASE	0x1b000000
+#define AR71XX_EHCI_SIZE	0x1000
+#define AR71XX_OHCI_BASE	0x1c000000
+#define AR71XX_OHCI_SIZE	0x1000
 #define AR71XX_SPI_BASE		0x1f000000
 #define AR71XX_SPI_SIZE		0x01000000
 
@@ -27,6 +31,8 @@
 #define AR71XX_DDR_CTRL_SIZE	0x100
 #define AR71XX_UART_BASE	(AR71XX_APB_BASE + 0x00020000)
 #define AR71XX_UART_SIZE	0x100
+#define AR71XX_USB_CTRL_BASE	(AR71XX_APB_BASE + 0x00030000)
+#define AR71XX_USB_CTRL_SIZE	0x100
 #define AR71XX_GPIO_BASE        (AR71XX_APB_BASE + 0x00040000)
 #define AR71XX_GPIO_SIZE        0x100
 #define AR71XX_PLL_BASE		(AR71XX_APB_BASE + 0x00050000)
@@ -34,6 +40,9 @@
 #define AR71XX_RESET_BASE	(AR71XX_APB_BASE + 0x00060000)
 #define AR71XX_RESET_SIZE	0x100
 
+#define AR7240_OHCI_BASE	0x1b000000
+#define AR7240_OHCI_SIZE	0x1000
+
 /*
  * DDR_CTRL block
  */
@@ -102,6 +111,12 @@
 #define AR913X_AHB_DIV_MASK		0x1
 
 /*
+ * USB_CONFIG block
+ */
+#define AR71XX_USB_CTRL_REG_FLADJ	0x00
+#define AR71XX_USB_CTRL_REG_CONFIG	0x04
+
+/*
  * RESET block
  */
 #define AR71XX_RESET_REG_TIMER			0x00
Signature · 1 line
1.7.2.1
#56 lore raw

PATCH 17/18 MIPS: ath79: add initial support for the Atheros AP81 reference board

In reply to Gabor Juhos

---

Changes since RFC:
- don't use 'default n' for the ATH79_MACH_AP81 Kconfig option

 arch/mips/ath79/Kconfig     |   11 +++++
 arch/mips/ath79/Makefile    |    1 +
 arch/mips/ath79/mach-ap81.c |   93 +++++++++++++++++++++++++++++++++++++++++++
 arch/mips/ath79/machtypes.h |    1 +
 4 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/mach-ap81.c
arch/mips/ath79/Kconfig +11 -0
index 5d67942..1912d54 100644
@@ -2,6 +2,17 @@ if ATH79
 
 menu "Atheros AR71XX/AR724X/AR913X machine selection"
 
+config ATH79_MACH_AP81
+	bool "Atheros AP81 reference board"
+	select SOC_AR913X
+	select ATH79_DEV_GPIO_BUTTONS
+	select ATH79_DEV_LEDS_GPIO
+	select ATH79_DEV_SPI
+	select ATH79_DEV_USB
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  Atheros AP81 reference board.
+
 config ATH79_MACH_PB44
 	bool "Atheros PB44 reference board"
 	select SOC_AR71XX
arch/mips/ath79/Makefile +1 -0
index 494d106..1b111d8 100644
@@ -24,4 +24,5 @@ obj-$(CONFIG_ATH79_DEV_USB)		+= dev-usb.o
 #
 # Machines
 #
+obj-$(CONFIG_ATH79_MACH_AP81)		+= mach-ap81.o
 obj-$(CONFIG_ATH79_MACH_PB44)		+= mach-pb44.o
arch/mips/ath79/mach-ap81.c new file +93 -0

93 lines not on this page · raw message

arch/mips/ath79/machtypes.h +1 -0
index a796fa3..3940fe4 100644
@@ -16,6 +16,7 @@
 
 enum ath79_mach_type {
 	ATH79_MACH_GENERIC = 0,
+	ATH79_MACH_AP81,		/* Atheros AP81 reference board */
 	ATH79_MACH_PB44,		/* Atheros PB44 reference board */
 };
 
Signature · 1 line
1.7.2.1
#57 lore raw

PATCH 18/18 MIPS: ath79: add common WMAC device for AR913X based boards

In reply to Gabor Juhos

Add common platform_device and helper code to make the registration of the built-in wireless MAC easier on the Atheros AR9130/AR9132 based boards. Also register the WMAC device on the AR81 board.

---

Changes since RFC: ---

 arch/mips/ath79/Kconfig                        |    5 ++
 arch/mips/ath79/Makefile                       |    1 +
 arch/mips/ath79/dev-ar913x-wmac.c              |   60 ++++++++++++++++++++++++
 arch/mips/ath79/dev-ar913x-wmac.h              |   17 +++++++
 arch/mips/ath79/mach-ap81.c                    |    5 ++
 arch/mips/include/asm/mach-ath79/ar71xx_regs.h |    3 +
 6 files changed, 91 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/ath79/dev-ar913x-wmac.c
 create mode 100644 arch/mips/ath79/dev-ar913x-wmac.h
arch/mips/ath79/Kconfig +5 -0
index 1912d54..af01669 100644
@@ -5,6 +5,7 @@ menu "Atheros AR71XX/AR724X/AR913X machine selection"
 config ATH79_MACH_AP81
 	bool "Atheros AP81 reference board"
 	select SOC_AR913X
+	select ATH79_DEV_AR913X_WMAC
 	select ATH79_DEV_GPIO_BUTTONS
 	select ATH79_DEV_LEDS_GPIO
 	select ATH79_DEV_SPI
@@ -40,6 +41,10 @@ config SOC_AR913X
 	select USB_ARCH_HAS_EHCI
 	def_bool n
 
+config ATH79_DEV_AR913X_WMAC
+	depends on SOC_AR913X
+	def_bool n
+
 config ATH79_DEV_GPIO_BUTTONS
 	def_bool n
 
arch/mips/ath79/Makefile +1 -0
index 1b111d8..48398561 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_EARLY_PRINTK)		+= early_printk.o
 # Devices
 #
 obj-y					+= dev-common.o
+obj-$(CONFIG_ATH79_DEV_AR913X_WMAC)	+= dev-ar913x-wmac.o
 obj-$(CONFIG_ATH79_DEV_GPIO_BUTTONS)	+= dev-gpio-buttons.o
 obj-$(CONFIG_ATH79_DEV_LEDS_GPIO)	+= dev-leds-gpio.o
 obj-$(CONFIG_ATH79_DEV_SPI)		+= dev-spi.o
arch/mips/ath79/dev-ar913x-wmac.c new file +60 -0

60 lines not on this page · raw message

arch/mips/ath79/dev-ar913x-wmac.h new file +17 -0
new file mode 100644
index 0000000..5df653f
@@ -0,0 +1,17 @@
+/*
+ *  Atheros AR913X SoC built-in WMAC device support
+ *
+ *  Copyright (C) 2008-2010 Gabor Juhos <[email protected]>
+ *  Copyright (C) 2008 Imre Kaloz <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2 as published
+ *  by the Free Software Foundation.
+ */
+
+#ifndef _ATH79_DEV_AR913X_WMAC_H
+#define _ATH79_DEV_AR913X_WMAC_H
+
+void ath79_register_ar913x_wmac(u8 *cal_data) __init;
+
+#endif /* _ATH79_DEV_AR913X_WMAC_H */
arch/mips/ath79/mach-ap81.c +5 -0
index 9cfaff3..00ef1cd 100644
@@ -10,6 +10,7 @@
  */
 
 #include "machtypes.h"
+#include "dev-ar913x-wmac.h"
 #include "dev-gpio-buttons.h"
 #include "dev-leds-gpio.h"
 #include "dev-spi.h"
@@ -24,6 +25,7 @@
 #define AP81_GPIO_BTN_SW1	21
 
 #define AP81_BUTTONS_POLL_INTERVAL	20
+#define AP81_CAL_DATA_ADDR	0x1fff1000
 
 static struct gpio_led ap81_leds_gpio[] __initdata = {
 	{
@@ -79,6 +81,8 @@ static struct ath79_spi_platform_data ap81_spi_data = {
 
 static void __init ap81_setup(void)
 {
+	u8 *cal_data = (u8 *) KSEG1ADDR(AP81_CAL_DATA_ADDR);
+
 	ath79_register_leds_gpio(-1, ARRAY_SIZE(ap81_leds_gpio),
 				 ap81_leds_gpio);
 	ath79_register_gpio_buttons(-1, AP81_BUTTONS_POLL_INTERVAL,
@@ -87,6 +91,7 @@ static void __init ap81_setup(void)
 	ath79_register_spi(&ap81_spi_data, ap81_spi_info,
 			   ARRAY_SIZE(ap81_spi_info));
 	ath79_register_usb();
+	ath79_register_ar913x_wmac(cal_data);
 }
 
 MIPS_MACHINE(ATH79_MACH_AP81, "AP81", "Atheros AP81 reference board",
arch/mips/include/asm/mach-ath79/ar71xx_regs.h +3 -0
index 95be423..e8b0e2f 100644
@@ -43,6 +43,9 @@
 #define AR7240_OHCI_BASE	0x1b000000
 #define AR7240_OHCI_SIZE	0x1000
 
+#define AR913X_WMAC_BASE	(AR71XX_APB_BASE + 0x000C0000)
+#define AR913X_WMAC_SIZE	0x30000
+
 /*
  * DDR_CTRL block
  */
Signature · 1 line
1.7.2.1
#58 lore raw
In reply to Gabor Juhos

Hi,

Quoted 3 lines · Gabor Juhos

This patch set contains initial support for the
Atheros AR71XX/AR724X/AR913X SoCs.

Could you maybe describe what changed between the first submission and this serie ? AFAIK, there has been private review/discussions going on, so this would give a hit of the evolution.

Thanks,
- Arnaud

Quoted 128 lines

Gabor Juhos (18):
 MIPS: add initial support for the Atheros AR71XX/AR724X/AR931X SoCs
 MIPS: ath79: add GPIOLIB support
 MIPS: add generic support for multiple machines within a single kernel
 MIPS: ath79: utilize the MIPS multi-machine support
 MIPS: ath79: add initial support for the Atheros PB44 reference board
 MIPS: ath79: add common GPIO LEDs device
 watchdog: add driver for the Atheros AR71XX/AR724X/AR913X SoCs
 MIPS: ath79: add common watchdog device
 input: add input driver for polled GPIO buttons
 MIPS: ath79: add common GPIO buttons device
 spi: add SPI controller driver for the Atheros AR71XX/AR724X/AR913X SoCs
 MIPS: ath79: add common SPI controller device
 USB: ehci: add workaround for Synopsys HC bug
 USB: ehci: add bus glue for the Atheros AR71XX/AR724X/AR913X SoCs
 USB: ohci: add bus glue for the Atheros AR71XX/AR7240 SoCs
 MIPS: ath79: add common USB Host Controller device
 MIPS: ath79: add initial support for the Atheros AP81 reference board
 MIPS: ath79: add common WMAC device for AR913X based boards

 arch/mips/Kbuild.platforms                         |    1 + arch/mips/Kconfig                                  |   20 ++ arch/mips/ath79/Kconfig                            |   60 ++++

 arch/mips/ath79/Makefile                           |   29 ++
 arch/mips/ath79/Platform                           |    7 +
 arch/mips/ath79/common.c                           |  113 ++++++++
 arch/mips/ath79/common.h                           |   67 +++++

 arch/mips/ath79/dev-ar913x-wmac.c                  |   60 ++++ arch/mips/ath79/dev-ar913x-wmac.h                  |   17 ++ arch/mips/ath79/dev-common.c                       |   69 +++++ arch/mips/ath79/dev-common.h                       |   18 ++ arch/mips/ath79/dev-gpio-buttons.c                 |   58 ++++ arch/mips/ath79/dev-gpio-buttons.h                 |   23 ++ arch/mips/ath79/dev-leds-gpio.c                    |   56 ++++ arch/mips/ath79/dev-leds-gpio.h                    |   21 ++

 arch/mips/ath79/dev-spi.c                          |   38 +++
 arch/mips/ath79/dev-spi.h                          |   22 ++
 arch/mips/ath79/dev-usb.c                          |  192 +++++++++++++
 arch/mips/ath79/dev-usb.h                          |   17 ++
 arch/mips/ath79/early_printk.c                     |   36 +++
 arch/mips/ath79/gpio.c                             |  196 +++++++++++++
 arch/mips/ath79/irq.c                              |  187 +++++++++++++
 arch/mips/ath79/mach-ap81.c                        |   98 +++++++
 arch/mips/ath79/mach-pb44.c                        |  119 ++++++++
 arch/mips/ath79/machtypes.h                        |   23 ++

 arch/mips/ath79/prom.c                             |   57 ++++ arch/mips/ath79/setup.c                            |  279 +++++++++++++++++++ arch/mips/include/asm/mach-ath79/ar71xx_regs.h     |  248 +++++++++++++++++ arch/mips/include/asm/mach-ath79/ath79.h           |   50 ++++ .../include/asm/mach-ath79/ath79_ehci_platform.h   |   18 ++ .../include/asm/mach-ath79/ath79_spi_platform.h    |   19 ++ .../include/asm/mach-ath79/cpu-feature-overrides.h |   56 ++++ arch/mips/include/asm/mach-ath79/gpio.h            |   26 ++ arch/mips/include/asm/mach-ath79/irq.h             |   36 +++ .../include/asm/mach-ath79/kernel-entry-init.h     |   32 +++ arch/mips/include/asm/mach-ath79/war.h             |   25 ++ arch/mips/include/asm/mips_machine.h               |   54 ++++ arch/mips/kernel/Makefile                          |    1 + arch/mips/kernel/mips_machine.c                    |   86 ++++++ arch/mips/kernel/proc.c                            |    7 +- arch/mips/kernel/vmlinux.lds.S                     |    7 + drivers/input/misc/Kconfig                         |   16 + drivers/input/misc/Makefile                        |    1 + drivers/input/misc/gpio_buttons.c                  |  232 ++++++++++++++++ drivers/spi/Kconfig                                |    8 + drivers/spi/Makefile                               |    1 + drivers/spi/ath79_spi.c                            |  290 +++++++++++++++++++ drivers/usb/host/Kconfig                           |   16 + drivers/usb/host/ehci-ath79.c                      |  176 ++++++++++++ drivers/usb/host/ehci-hcd.c                        |    5 + drivers/usb/host/ehci-q.c                          |    3 + drivers/usb/host/ehci.h                            |    1 + drivers/usb/host/ohci-ath79.c                      |  162 +++++++++++ drivers/usb/host/ohci-hcd.c                        |    5 + drivers/watchdog/Kconfig                           |    8 + drivers/watchdog/Makefile                          |    1 + drivers/watchdog/ath79_wdt.c                       |  293 ++++++++++++++++++++ include/linux/gpio_buttons.h                       |   33 +++

 58 files changed, 3798 insertions(+), 1 deletions(-)

 create mode 100644 arch/mips/ath79/Kconfig
 create mode 100644 arch/mips/ath79/Makefile
 create mode 100644 arch/mips/ath79/Platform
 create mode 100644 arch/mips/ath79/common.c
 create mode 100644 arch/mips/ath79/common.h
 create mode 100644 arch/mips/ath79/dev-ar913x-wmac.c
 create mode 100644 arch/mips/ath79/dev-ar913x-wmac.h
 create mode 100644 arch/mips/ath79/dev-common.c
 create mode 100644 arch/mips/ath79/dev-common.h
 create mode 100644 arch/mips/ath79/dev-gpio-buttons.c
 create mode 100644 arch/mips/ath79/dev-gpio-buttons.h
 create mode 100644 arch/mips/ath79/dev-leds-gpio.c
 create mode 100644 arch/mips/ath79/dev-leds-gpio.h
 create mode 100644 arch/mips/ath79/dev-spi.c
 create mode 100644 arch/mips/ath79/dev-spi.h
 create mode 100644 arch/mips/ath79/dev-usb.c
 create mode 100644 arch/mips/ath79/dev-usb.h
 create mode 100644 arch/mips/ath79/early_printk.c
 create mode 100644 arch/mips/ath79/gpio.c
 create mode 100644 arch/mips/ath79/irq.c
 create mode 100644 arch/mips/ath79/mach-ap81.c
 create mode 100644 arch/mips/ath79/mach-pb44.c
 create mode 100644 arch/mips/ath79/machtypes.h
 create mode 100644 arch/mips/ath79/prom.c
 create mode 100644 arch/mips/ath79/setup.c
 create mode 100644 arch/mips/include/asm/mach-ath79/ar71xx_regs.h create mode 100644 arch/mips/include/asm/mach-ath79/ath79.h create mode 100644 arch/mips/include/asm/mach-ath79/ath79_ehci_platform.h create mode 100644 arch/mips/include/asm/mach-ath79/ath79_spi_platform.h create mode 100644 arch/mips/include/asm/mach-ath79/cpu-feature-overrides.h create mode 100644 arch/mips/include/asm/mach-ath79/gpio.h create mode 100644 arch/mips/include/asm/mach-ath79/irq.h create mode 100644 arch/mips/include/asm/mach-ath79/kernel-entry-init.h create mode 100644 arch/mips/include/asm/mach-ath79/war.h create mode 100644 arch/mips/include/asm/mips_machine.h
 create mode 100644 arch/mips/kernel/mips_machine.c
 create mode 100644 drivers/input/misc/gpio_buttons.c
 create mode 100644 drivers/spi/ath79_spi.c
 create mode 100644 drivers/usb/host/ehci-ath79.c
 create mode 100644 drivers/usb/host/ohci-ath79.c
 create mode 100644 drivers/watchdog/ath79_wdt.c
 create mode 100644 include/linux/gpio_buttons.h

--
1.7.2.1

#59 lore raw

Hi,

Quoted 10 lines · Arnaud Lacombe

Hi,

Quoted 3 lines · Gabor Juhos

This patch set contains initial support for the
Atheros AR71XX/AR724X/AR913X SoCs.

Could you maybe describe what changed between the first submission and this serie ? AFAIK, there has been private review/discussions going on, so this would give a hit of the evolution.

Please forget about that, it's included in each patch :)

- Arnaud