Skip to content

Commit

Permalink
MIPS: Alchemy: Rewrite GPIO support.
Browse files Browse the repository at this point in the history
The current in-kernel Alchemy GPIO support is far too inflexible for
all my use cases.  To address this, the following changes are made:

* create generic functions which deal with manipulating the on-chip
  GPIO1/2 blocks.  Such functions are universally useful.
* Macros for GPIO2 shared interrupt management and block control.
* support for both built-in CONFIG_GPIOLIB and fast, inlined GPIO macros.

  If CONFIG_GPIOLIB is not enabled, provide linux gpio framework
  compatibility by directly inlining the GPIO1/2 functions.  GPIO access
  is limited to on-chip ones and they can be accessed as documented in
  the datasheets (GPIO0-31 and 200-215).

  If CONFIG_GPIOLIB is selected, two (2) gpio_chip-s, one for GPIO1 and
  one for GPIO2, are registered.  GPIOs can still be accessed by using
  the numberspace established in the databooks.

  However this is not yet flexible enough for my uses:  My Alchemy
  systems have a documented "external" gpio interface (fixed, different
  numberspace) and can support a variety of baseboards, some of which
  are equipped with I2C gpio expanders.  I want to be able to provide
  the default 16 GPIOs of the CPU board numbered as 0..15 and also
  support gpio expanders, if present, starting as gpio16.

  To achieve this, a new Kconfig symbol for Alchemy is introduced,
  CONFIG_ALCHEMY_GPIO_INDIRECT, which boards can enable to signal
  that they don't want the Alchemy numberspace exposed to the outside
  world, but instead want to provide their own.  Boards are now respon-
  sible for providing the linux gpio interface glue code (either in a
  custom gpio.h header (in board include directory) or with gpio_chips).

  To make the board-specific inlined gpio functions work, the MIPS
  Makefile must be changed so that the mach-au1x00/gpio.h header is
  included _after_ the board headers, by moving the inclusion of
  the mach-au1x00/ to the end of the header list.

  See arch/mips/include/asm/mach-au1x00/gpio.h for more info.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Acked-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Manuel Lauss authored and Ralf Baechle committed Jun 17, 2009
1 parent eeb09e6 commit 51e02b0
Show file tree
Hide file tree
Showing 7 changed files with 770 additions and 233 deletions.
5 changes: 4 additions & 1 deletion arch/mips/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ load-$(CONFIG_MACH_JAZZ) += 0xffffffff80080000
# Common Alchemy Au1x00 stuff
#
core-$(CONFIG_SOC_AU1X00) += arch/mips/alchemy/common/
cflags-$(CONFIG_SOC_AU1X00) += -I$(srctree)/arch/mips/include/asm/mach-au1x00

#
# AMD Alchemy Pb1000 eval board
Expand Down Expand Up @@ -281,6 +280,10 @@ load-$(CONFIG_MIPS_MTX1) += 0xffffffff80100000
libs-$(CONFIG_MIPS_XXS1500) += arch/mips/alchemy/xxs1500/
load-$(CONFIG_MIPS_XXS1500) += 0xffffffff80100000

# must be last for Alchemy systems for GPIO to work properly
cflags-$(CONFIG_SOC_AU1X00) += -I$(srctree)/arch/mips/include/asm/mach-au1x00


#
# Cobalt Server
#
Expand Down
19 changes: 18 additions & 1 deletion arch/mips/alchemy/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# au1000-style gpio
config ALCHEMY_GPIO_AU1000
bool

# select this in your board config if you don't want to use the gpio
# namespace as documented in the manuals. In this case however you need
# to create the necessary gpio_* functions in your board code/headers!
# see arch/mips/include/asm/mach-au1x00/gpio.h for more information.
config ALCHEMY_GPIO_INDIRECT
def_bool n

choice
prompt "Machine type"
depends on MACH_ALCHEMY
Expand Down Expand Up @@ -108,22 +119,27 @@ endchoice
config SOC_AU1000
bool
select SOC_AU1X00
select ALCHEMY_GPIO_AU1000

config SOC_AU1100
bool
select SOC_AU1X00
select ALCHEMY_GPIO_AU1000

config SOC_AU1500
bool
select SOC_AU1X00
select ALCHEMY_GPIO_AU1000

config SOC_AU1550
bool
select SOC_AU1X00
select ALCHEMY_GPIO_AU1000

config SOC_AU1200
bool
select SOC_AU1X00
select ALCHEMY_GPIO_AU1000

config SOC_AU1X00
bool
Expand All @@ -134,4 +150,5 @@ config SOC_AU1X00
select SYS_HAS_CPU_MIPS32_R1
select SYS_SUPPORTS_32BIT_KERNEL
select SYS_SUPPORTS_APM_EMULATION
select ARCH_REQUIRE_GPIOLIB
select GENERIC_GPIO
select ARCH_WANT_OPTIONAL_GPIOLIB
9 changes: 8 additions & 1 deletion arch/mips/alchemy/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@

obj-y += prom.o irq.o puts.o time.o reset.o \
clocks.o platform.o power.o setup.o \
sleeper.o dma.o dbdma.o gpio.o
sleeper.o dma.o dbdma.o

# optional gpiolib support
ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),)
ifeq ($(CONFIG_GPIOLIB),y)
obj-$(CONFIG_ALCHEMY_GPIO_AU1000) += gpiolib-au1000.o
endif
endif

obj-$(CONFIG_PCI) += pci.o

Expand Down
201 changes: 0 additions & 201 deletions arch/mips/alchemy/common/gpio.c

This file was deleted.

Loading

0 comments on commit 51e02b0

Please sign in to comment.