Skip to content

Commit

Permalink
[ARM] Orion: rework MPP handling
Browse files Browse the repository at this point in the history
Instead of having board code poke directly into the MPP configuration
registers, and separately calling orion5x_gpio_set_valid_pins() to
indicate which MPP pins can be used as GPIO pins, introduce a helper
function for configuring the roles of each of the MPP pins, and have
that helper function handle gpio validity internally.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Acked-by: Sylver Bruneau <sylver.bruneau@googlemail.com>
Acked-by: Russell King <linux@arm.linux.org.uk>
  • Loading branch information
Lennert Buytenhek authored and Lennert Buytenhek committed Jun 22, 2008
1 parent 386a048 commit 19cfd5c
Show file tree
Hide file tree
Showing 10 changed files with 376 additions and 114 deletions.
2 changes: 1 addition & 1 deletion arch/arm/mach-orion5x/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
obj-y += common.o addr-map.o pci.o gpio.o irq.o
obj-y += common.o addr-map.o pci.o gpio.o irq.o mpp.o
obj-$(CONFIG_MACH_DB88F5281) += db88f5281-setup.o
obj-$(CONFIG_MACH_RD88F5182) += rd88f5182-setup.o
obj-$(CONFIG_MACH_KUROBOX_PRO) += kurobox_pro-setup.o
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-orion5x/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int orion5x_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin);
* Valid GPIO pins according to MPP setup, used by machine-setup.
* (/mach-orion/gpio.c).
*/
void orion5x_gpio_set_valid_pins(u32 pins);
void orion5x_gpio_set_valid(unsigned pin, int valid);
void gpio_display(void); /* debug */

struct machine_desc;
Expand Down
47 changes: 27 additions & 20 deletions arch/arm/mach-orion5x/db88f5281-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <asm/arch/orion5x.h>
#include <asm/plat-orion/orion_nand.h>
#include "common.h"
#include "mpp.h"

/*****************************************************************************
* DB-88F5281 on board devices
Expand Down Expand Up @@ -298,33 +299,39 @@ static struct i2c_board_info __initdata db88f5281_i2c_rtc = {
/*****************************************************************************
* General Setup
****************************************************************************/
static struct orion5x_mpp_mode db88f5281_mpp_modes[] __initdata = {
{ 0, MPP_GPIO }, /* USB Over Current */
{ 1, MPP_GPIO }, /* USB Vbat input */
{ 2, MPP_PCI_ARB }, /* PCI_REQn[2] */
{ 3, MPP_PCI_ARB }, /* PCI_GNTn[2] */
{ 4, MPP_PCI_ARB }, /* PCI_REQn[3] */
{ 5, MPP_PCI_ARB }, /* PCI_GNTn[3] */
{ 6, MPP_GPIO }, /* JP0, CON17.2 */
{ 7, MPP_GPIO }, /* JP1, CON17.1 */
{ 8, MPP_GPIO }, /* JP2, CON11.2 */
{ 9, MPP_GPIO }, /* JP3, CON11.3 */
{ 10, MPP_GPIO }, /* RTC int */
{ 11, MPP_GPIO }, /* Baud Rate Generator */
{ 12, MPP_GPIO }, /* PCI int 1 */
{ 13, MPP_GPIO }, /* PCI int 2 */
{ 14, MPP_NAND }, /* NAND_REn[2] */
{ 15, MPP_NAND }, /* NAND_WEn[2] */
{ 16, MPP_UART }, /* UART1_RX */
{ 17, MPP_UART }, /* UART1_TX */
{ 18, MPP_UART }, /* UART1_CTSn */
{ 19, MPP_UART }, /* UART1_RTSn */
{ -1 },
};

static void __init db88f5281_init(void)
{
/*
* Basic Orion setup. Need to be called early.
*/
orion5x_init();

/*
* Setup Multiplexing Pins:
* MPP0: GPIO (USB Over Current) MPP1: GPIO (USB Vbat input)
* MPP2: PCI_REQn[2] MPP3: PCI_GNTn[2]
* MPP4: PCI_REQn[3] MPP5: PCI_GNTn[3]
* MPP6: GPIO (JP0, CON17.2) MPP7: GPIO (JP1, CON17.1)
* MPP8: GPIO (JP2, CON11.2) MPP9: GPIO (JP3, CON11.3)
* MPP10: GPIO (RTC int) MPP11: GPIO (Baud Rate Generator)
* MPP12: GPIO (PCI int 1) MPP13: GPIO (PCI int 2)
* MPP14: NAND_REn[2] MPP15: NAND_WEn[2]
* MPP16: UART1_RX MPP17: UART1_TX
* MPP18: UART1_CTS MPP19: UART1_RTS
* MPP-DEV: DEV_D[16:31]
*/
orion5x_write(MPP_0_7_CTRL, 0x00222203);
orion5x_write(MPP_8_15_CTRL, 0x44000000);
orion5x_write(MPP_16_19_CTRL, 0);
orion5x_write(MPP_DEV_CTRL, 0);

orion5x_gpio_set_valid_pins(0x00003fc3);
orion5x_mpp_conf(db88f5281_mpp_modes);
orion5x_write(MPP_DEV_CTRL, 0); /* DEV_D[31:16] */

/*
* Configure peripherals.
Expand Down
54 changes: 26 additions & 28 deletions arch/arm/mach-orion5x/dns323-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <asm/mach/pci.h>
#include <asm/arch/orion5x.h>
#include "common.h"
#include "mpp.h"

#define DNS323_GPIO_LED_RIGHT_AMBER 1
#define DNS323_GPIO_LED_LEFT_AMBER 2
Expand Down Expand Up @@ -212,6 +213,29 @@ static struct platform_device dns323_button_device = {
/****************************************************************************
* General Setup
*/
static struct orion5x_mpp_mode dns323_mpp_modes[] __initdata = {
{ 0, MPP_PCIE_RST_OUTn },
{ 1, MPP_GPIO }, /* right amber LED (sata ch0) */
{ 2, MPP_GPIO }, /* left amber LED (sata ch1) */
{ 3, MPP_UNUSED },
{ 4, MPP_GPIO }, /* power button LED */
{ 5, MPP_GPIO }, /* power button LED */
{ 6, MPP_GPIO }, /* GMT G751-2f overtemp */
{ 7, MPP_GPIO }, /* M41T80 nIRQ/OUT/SQW */
{ 8, MPP_GPIO }, /* triggers power off */
{ 9, MPP_GPIO }, /* power button switch */
{ 10, MPP_GPIO }, /* reset button switch */
{ 11, MPP_UNUSED },
{ 12, MPP_UNUSED },
{ 13, MPP_UNUSED },
{ 14, MPP_UNUSED },
{ 15, MPP_UNUSED },
{ 16, MPP_UNUSED },
{ 17, MPP_UNUSED },
{ 18, MPP_UNUSED },
{ 19, MPP_UNUSED },
{ -1 },
};

/*
* On the DNS-323 the following devices are attached via I2C:
Expand Down Expand Up @@ -247,34 +271,8 @@ static void __init dns323_init(void)
/* Setup basic Orion functions. Need to be called early. */
orion5x_init();

/* set MPP to 0 as D-Link's 2.6.12.6 kernel did */
orion5x_write(MPP_0_7_CTRL, 0);
orion5x_write(MPP_8_15_CTRL, 0);
orion5x_write(MPP_16_19_CTRL, 0);
orion5x_write(MPP_DEV_CTRL, 0);

/* Define used GPIO pins
GPIO Map:
| 0 | | PEX_RST_OUT (not controlled by GPIO)
| 1 | Out | right amber LED (= sata ch0 LED) (low-active)
| 2 | Out | left amber LED (= sata ch1 LED) (low-active)
| 3 | Out | //unknown//
| 4 | Out | power button LED (low-active, together with pin #5)
| 5 | Out | power button LED (low-active, together with pin #4)
| 6 | In | GMT G751-2f overtemp. shutdown signal (low-active)
| 7 | In | M41T80 nIRQ/OUT/SQW signal
| 8 | Out | triggers power off (high-active)
| 9 | In | power button switch (low-active)
| 10 | In | reset button switch (low-active)
| 11 | Out | //unknown//
| 12 | Out | //unknown//
| 13 | Out | //unknown//
| 14 | Out | //unknown//
| 15 | Out | //unknown//
*/
orion5x_gpio_set_valid_pins(0x07f6);
orion5x_mpp_conf(dns323_mpp_modes);
orion5x_write(MPP_DEV_CTRL, 0); /* DEV_D[31:16] */

/*
* Configure peripherals.
Expand Down
7 changes: 5 additions & 2 deletions arch/arm/mach-orion5x/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ static DEFINE_SPINLOCK(gpio_lock);
static unsigned long gpio_valid[BITS_TO_LONGS(GPIO_MAX)];
static const char *gpio_label[GPIO_MAX]; /* non null for allocated GPIOs */

void __init orion5x_gpio_set_valid_pins(u32 pins)
void __init orion5x_gpio_set_valid(unsigned pin, int valid)
{
gpio_valid[0] = pins;
if (valid)
__set_bit(pin, gpio_valid);
else
__clear_bit(pin, gpio_valid);
}

/*
Expand Down
45 changes: 25 additions & 20 deletions arch/arm/mach-orion5x/kurobox_pro-setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <asm/arch/orion5x.h>
#include <asm/plat-orion/orion_nand.h>
#include "common.h"
#include "mpp.h"

/*****************************************************************************
* KUROBOX-PRO Info
Expand Down Expand Up @@ -179,6 +180,29 @@ static struct mv_sata_platform_data kurobox_pro_sata_data = {
/*****************************************************************************
* General Setup
****************************************************************************/
static struct orion5x_mpp_mode kurobox_pro_mpp_modes[] __initdata = {
{ 0, MPP_UNUSED },
{ 1, MPP_UNUSED },
{ 2, MPP_GPIO }, /* GPIO Micon */
{ 3, MPP_GPIO }, /* GPIO Rtc */
{ 4, MPP_UNUSED },
{ 5, MPP_UNUSED },
{ 6, MPP_NAND }, /* NAND Flash REn */
{ 7, MPP_NAND }, /* NAND Flash WEn */
{ 8, MPP_UNUSED },
{ 9, MPP_UNUSED },
{ 10, MPP_UNUSED },
{ 11, MPP_UNUSED },
{ 12, MPP_SATA_LED }, /* SATA 0 presence */
{ 13, MPP_SATA_LED }, /* SATA 1 presence */
{ 14, MPP_SATA_LED }, /* SATA 0 active */
{ 15, MPP_SATA_LED }, /* SATA 1 active */
{ 16, MPP_UNUSED },
{ 17, MPP_UNUSED },
{ 18, MPP_UNUSED },
{ 19, MPP_UNUSED },
{ -1 },
};

static void __init kurobox_pro_init(void)
{
Expand All @@ -187,26 +211,7 @@ static void __init kurobox_pro_init(void)
*/
orion5x_init();

/*
* Setup Multiplexing Pins --
* MPP[0-1] Not used
* MPP[2] GPIO Micon
* MPP[3] GPIO RTC
* MPP[4-5] Not used
* MPP[6] Nand Flash REn
* MPP[7] Nand Flash WEn
* MPP[8-11] Not used
* MPP[12] SATA 0 presence Indication
* MPP[13] SATA 1 presence Indication
* MPP[14] SATA 0 active Indication
* MPP[15] SATA 1 active indication
* MPP[16-19] Not used
*/
orion5x_write(MPP_0_7_CTRL, 0x44220003);
orion5x_write(MPP_8_15_CTRL, 0x55550000);
orion5x_write(MPP_16_19_CTRL, 0x0);

orion5x_gpio_set_valid_pins(0x0000000c);
orion5x_mpp_conf(kurobox_pro_mpp_modes);

/*
* Configure peripherals.
Expand Down
Loading

0 comments on commit 19cfd5c

Please sign in to comment.