Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19cfd5c0 authored by Lennert Buytenhek's avatar Lennert Buytenhek Committed by Lennert Buytenhek
Browse files

[ARM] Orion: rework MPP handling



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: default avatarLennert Buytenhek <buytenh@marvell.com>
Acked-by: default avatarSylver Bruneau <sylver.bruneau@googlemail.com>
Acked-by: default avatarRussell King <linux@arm.linux.org.uk>
parent 386a048a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
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
+1 −1
Original line number Diff line number Diff line
@@ -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;
+27 −20
Original line number Diff line number Diff line
@@ -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
@@ -298,6 +299,30 @@ 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)
{
	/*
@@ -305,26 +330,8 @@ static void __init db88f5281_init(void)
	 */
	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.
+26 −28
Original line number Diff line number Diff line
@@ -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
@@ -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:
@@ -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.
+5 −2
Original line number Diff line number Diff line
@@ -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);
}

/*
Loading