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

Commit edb6310a authored by Daniel Laird's avatar Daniel Laird Committed by Ralf Baechle
Browse files

MIPS: Add support for NXP PNX833x (STB222/5) into linux kernel



The following patch add support for the NXP PNX833x SOC.  More
specifically it adds support for the STB222/5 variant. It fixes
the vectored interrupt issue.

Signed-off-by: default avatardaniel.j.laird <daniel.j.laird@nxp.com>
Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 537fa37c
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -261,6 +261,19 @@ config MACH_VR41XX
	select SYS_HAS_CPU_VR41XX
	select GENERIC_HARDIRQS_NO__DO_IRQ

config NXP_STB220
	bool "NXP STB220 board"
	select SOC_PNX833X
	help
	 Support for NXP Semiconductors STB220 Development Board.

config NXP_STB225
	bool "NXP 225 board"
	select SOC_PNX833X
	select SOC_PNX8335
	help
	 Support for NXP Semiconductors STB225 Development Board.

config PNX8550_JBS
	bool "NXP PNX8550 based JBS board"
	select PNX8550
@@ -849,6 +862,24 @@ config MIPS_RM9122
	bool
	select SERIAL_RM9000

config SOC_PNX833X
	bool
	select CEVT_R4K
	select CSRC_R4K
	select IRQ_CPU
	select DMA_NONCOHERENT
	select SYS_HAS_CPU_MIPS32_R2
	select SYS_SUPPORTS_32BIT_KERNEL
	select SYS_SUPPORTS_LITTLE_ENDIAN
	select SYS_SUPPORTS_BIG_ENDIAN
	select GENERIC_HARDIRQS_NO__DO_IRQ
	select GENERIC_GPIO
	select CPU_MIPSR2_IRQ_VI

config SOC_PNX8335
	bool
	select SOC_PNX833X

config PNX8550
	bool
	select SOC_PNX8550
+8 −0
Original line number Diff line number Diff line
@@ -381,6 +381,14 @@ load-$(CONFIG_CASIO_E55) += 0xffffffff80004000
#
load-$(CONFIG_TANBAC_TB022X)	+= 0xffffffff80000000

# NXP STB225
core-$(CONFIG_SOC_PNX833X)		+= arch/mips/nxp/pnx833x/common/
cflags-$(CONFIG_SOC_PNX833X)	+= -Iarch/mips/include/asm/mach-pnx833x
libs-$(CONFIG_NXP_STB220)		+= arch/mips/nxp/pnx833x/stb22x/
load-$(CONFIG_NXP_STB220)		+= 0xffffffff80001000
libs-$(CONFIG_NXP_STB225)		+= arch/mips/nxp/pnx833x/stb22x/
load-$(CONFIG_NXP_STB225)		+= 0xffffffff80001000

#
# Common NXP PNX8550
#
+1149 −0

File added.

Preview size limit exceeded, changes collapsed.

+172 −0
Original line number Diff line number Diff line
/*
 *  gpio.h: GPIO Support for PNX833X.
 *
 *  Copyright 2008 NXP Semiconductors
 *	  Chris Steel <chris.steel@nxp.com>
 *    Daniel Laird <daniel.j.laird@nxp.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#ifndef __ASM_MIPS_MACH_PNX833X_GPIO_H
#define __ASM_MIPS_MACH_PNX833X_GPIO_H

/* BIG FAT WARNING: races danger!
   No protections exist here. Current users are only early init code,
   when locking is not needed because no cuncurency yet exists there,
   and GPIO IRQ dispatcher, which does locking.
   However, if many uses will ever happen, proper locking will be needed
   - including locking between different uses
*/

#include "pnx833x.h"

#define SET_REG_BIT(reg, bit)		do { (reg |= (1 << (bit))); } while (0)
#define CLEAR_REG_BIT(reg, bit)		do { (reg &= ~(1 << (bit))); } while (0)

/* Initialize GPIO to a known state */
static inline void pnx833x_gpio_init(void)
{
	PNX833X_PIO_DIR = 0;
	PNX833X_PIO_DIR2 = 0;
	PNX833X_PIO_SEL = 0;
	PNX833X_PIO_SEL2 = 0;
	PNX833X_PIO_INT_EDGE = 0;
	PNX833X_PIO_INT_HI = 0;
	PNX833X_PIO_INT_LO = 0;

	/* clear any GPIO interrupt requests */
	PNX833X_PIO_INT_CLEAR = 0xffff;
	PNX833X_PIO_INT_CLEAR = 0;
	PNX833X_PIO_INT_ENABLE = 0;
}

/* Select GPIO direction for a pin */
static inline void pnx833x_gpio_select_input(unsigned int pin)
{
	if (pin < 32)
		CLEAR_REG_BIT(PNX833X_PIO_DIR, pin);
	else
		CLEAR_REG_BIT(PNX833X_PIO_DIR2, pin & 31);
}
static inline void pnx833x_gpio_select_output(unsigned int pin)
{
	if (pin < 32)
		SET_REG_BIT(PNX833X_PIO_DIR, pin);
	else
		SET_REG_BIT(PNX833X_PIO_DIR2, pin & 31);
}

/* Select GPIO or alternate function for a pin */
static inline void pnx833x_gpio_select_function_io(unsigned int pin)
{
	if (pin < 32)
		CLEAR_REG_BIT(PNX833X_PIO_SEL, pin);
	else
		CLEAR_REG_BIT(PNX833X_PIO_SEL2, pin & 31);
}
static inline void pnx833x_gpio_select_function_alt(unsigned int pin)
{
	if (pin < 32)
		SET_REG_BIT(PNX833X_PIO_SEL, pin);
	else
		SET_REG_BIT(PNX833X_PIO_SEL2, pin & 31);
}

/* Read GPIO pin */
static inline int pnx833x_gpio_read(unsigned int pin)
{
	if (pin < 32)
		return (PNX833X_PIO_IN >> pin) & 1;
	else
		return (PNX833X_PIO_IN2 >> (pin & 31)) & 1;
}

/* Write GPIO pin */
static inline void pnx833x_gpio_write(unsigned int val, unsigned int pin)
{
	if (pin < 32) {
		if (val)
			SET_REG_BIT(PNX833X_PIO_OUT, pin);
		else
			CLEAR_REG_BIT(PNX833X_PIO_OUT, pin);
	} else {
		if (val)
			SET_REG_BIT(PNX833X_PIO_OUT2, pin & 31);
		else
			CLEAR_REG_BIT(PNX833X_PIO_OUT2, pin & 31);
	}
}

/* Configure GPIO interrupt */
#define GPIO_INT_NONE		0
#define GPIO_INT_LEVEL_LOW	1
#define GPIO_INT_LEVEL_HIGH	2
#define GPIO_INT_EDGE_RISING	3
#define GPIO_INT_EDGE_FALLING	4
#define GPIO_INT_EDGE_BOTH	5
static inline void pnx833x_gpio_setup_irq(int when, unsigned int pin)
{
	switch (when) {
	case GPIO_INT_LEVEL_LOW:
		CLEAR_REG_BIT(PNX833X_PIO_INT_EDGE, pin);
		CLEAR_REG_BIT(PNX833X_PIO_INT_HI, pin);
		SET_REG_BIT(PNX833X_PIO_INT_LO, pin);
		break;
	case GPIO_INT_LEVEL_HIGH:
		CLEAR_REG_BIT(PNX833X_PIO_INT_EDGE, pin);
		SET_REG_BIT(PNX833X_PIO_INT_HI, pin);
		CLEAR_REG_BIT(PNX833X_PIO_INT_LO, pin);
		break;
	case GPIO_INT_EDGE_RISING:
		SET_REG_BIT(PNX833X_PIO_INT_EDGE, pin);
		SET_REG_BIT(PNX833X_PIO_INT_HI, pin);
		CLEAR_REG_BIT(PNX833X_PIO_INT_LO, pin);
		break;
	case GPIO_INT_EDGE_FALLING:
		SET_REG_BIT(PNX833X_PIO_INT_EDGE, pin);
		CLEAR_REG_BIT(PNX833X_PIO_INT_HI, pin);
		SET_REG_BIT(PNX833X_PIO_INT_LO, pin);
		break;
	case GPIO_INT_EDGE_BOTH:
		SET_REG_BIT(PNX833X_PIO_INT_EDGE, pin);
		SET_REG_BIT(PNX833X_PIO_INT_HI, pin);
		SET_REG_BIT(PNX833X_PIO_INT_LO, pin);
		break;
	default:
		CLEAR_REG_BIT(PNX833X_PIO_INT_EDGE, pin);
		CLEAR_REG_BIT(PNX833X_PIO_INT_HI, pin);
		CLEAR_REG_BIT(PNX833X_PIO_INT_LO, pin);
		break;
	}
}

/* Enable/disable GPIO interrupt */
static inline void pnx833x_gpio_enable_irq(unsigned int pin)
{
	SET_REG_BIT(PNX833X_PIO_INT_ENABLE, pin);
}
static inline void pnx833x_gpio_disable_irq(unsigned int pin)
{
	CLEAR_REG_BIT(PNX833X_PIO_INT_ENABLE, pin);
}

/* Clear GPIO interrupt request */
static inline void pnx833x_gpio_clear_irq(unsigned int pin)
{
	SET_REG_BIT(PNX833X_PIO_INT_CLEAR, pin);
	CLEAR_REG_BIT(PNX833X_PIO_INT_CLEAR, pin);
}

#endif
+126 −0
Original line number Diff line number Diff line

/*
 *  irq.h: IRQ mappings for PNX833X.
 *
 *  Copyright 2008 NXP Semiconductors
 *	  Chris Steel <chris.steel@nxp.com>
 *    Daniel Laird <daniel.j.laird@nxp.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __ASM_MIPS_MACH_PNX833X_IRQ_MAPPING_H
#define __ASM_MIPS_MACH_PNX833X_IRQ_MAPPING_H
/*
 * The "IRQ numbers" are completely virtual.
 *
 * In PNX8330/1, we have 48 interrupt lines, numbered from 1 to 48.
 * Let's use numbers 1..48 for PIC interrupts, number 0 for timer interrupt,
 * numbers 49..64 for (virtual) GPIO interrupts.
 *
 * In PNX8335, we have 57 interrupt lines, numbered from 1 to 57,
 * connected to PIC, which uses core hardware interrupt 2, and also
 * a timer interrupt through hardware interrupt 5.
 * Let's use numbers 1..64 for PIC interrupts, number 0 for timer interrupt,
 * numbers 65..80 for (virtual) GPIO interrupts.
 *
 */
#include <irq.h>

#define PNX833X_TIMER_IRQ				(MIPS_CPU_IRQ_BASE + 7)

/* Interrupts supported by PIC */
#define PNX833X_PIC_I2C0_INT			(PNX833X_PIC_IRQ_BASE +  1)
#define PNX833X_PIC_I2C1_INT			(PNX833X_PIC_IRQ_BASE +  2)
#define PNX833X_PIC_UART0_INT			(PNX833X_PIC_IRQ_BASE +  3)
#define PNX833X_PIC_UART1_INT			(PNX833X_PIC_IRQ_BASE +  4)
#define PNX833X_PIC_TS_IN0_DV_INT		(PNX833X_PIC_IRQ_BASE +  5)
#define PNX833X_PIC_TS_IN0_DMA_INT		(PNX833X_PIC_IRQ_BASE +  6)
#define PNX833X_PIC_GPIO_INT			(PNX833X_PIC_IRQ_BASE +  7)
#define PNX833X_PIC_AUDIO_DEC_INT		(PNX833X_PIC_IRQ_BASE +  8)
#define PNX833X_PIC_VIDEO_DEC_INT		(PNX833X_PIC_IRQ_BASE +  9)
#define PNX833X_PIC_CONFIG_INT			(PNX833X_PIC_IRQ_BASE + 10)
#define PNX833X_PIC_AOI_INT				(PNX833X_PIC_IRQ_BASE + 11)
#define PNX833X_PIC_SYNC_INT			(PNX833X_PIC_IRQ_BASE + 12)
#define PNX8330_PIC_SPU_INT				(PNX833X_PIC_IRQ_BASE + 13)
#define PNX8335_PIC_SATA_INT			(PNX833X_PIC_IRQ_BASE + 13)
#define PNX833X_PIC_OSD_INT				(PNX833X_PIC_IRQ_BASE + 14)
#define PNX833X_PIC_DISP1_INT			(PNX833X_PIC_IRQ_BASE + 15)
#define PNX833X_PIC_DEINTERLACER_INT	(PNX833X_PIC_IRQ_BASE + 16)
#define PNX833X_PIC_DISPLAY2_INT		(PNX833X_PIC_IRQ_BASE + 17)
#define PNX833X_PIC_VC_INT				(PNX833X_PIC_IRQ_BASE + 18)
#define PNX833X_PIC_SC_INT				(PNX833X_PIC_IRQ_BASE + 19)
#define PNX833X_PIC_IDE_INT				(PNX833X_PIC_IRQ_BASE + 20)
#define PNX833X_PIC_IDE_DMA_INT			(PNX833X_PIC_IRQ_BASE + 21)
#define PNX833X_PIC_TS_IN1_DV_INT		(PNX833X_PIC_IRQ_BASE + 22)
#define PNX833X_PIC_TS_IN1_DMA_INT		(PNX833X_PIC_IRQ_BASE + 23)
#define PNX833X_PIC_SGDX_DMA_INT		(PNX833X_PIC_IRQ_BASE + 24)
#define PNX833X_PIC_TS_OUT_INT			(PNX833X_PIC_IRQ_BASE + 25)
#define PNX833X_PIC_IR_INT				(PNX833X_PIC_IRQ_BASE + 26)
#define PNX833X_PIC_VMSP1_INT			(PNX833X_PIC_IRQ_BASE + 27)
#define PNX833X_PIC_VMSP2_INT			(PNX833X_PIC_IRQ_BASE + 28)
#define PNX833X_PIC_PIBC_INT			(PNX833X_PIC_IRQ_BASE + 29)
#define PNX833X_PIC_TS_IN0_TRD_INT		(PNX833X_PIC_IRQ_BASE + 30)
#define PNX833X_PIC_SGDX_TPD_INT		(PNX833X_PIC_IRQ_BASE + 31)
#define PNX833X_PIC_USB_INT				(PNX833X_PIC_IRQ_BASE + 32)
#define PNX833X_PIC_TS_IN1_TRD_INT		(PNX833X_PIC_IRQ_BASE + 33)
#define PNX833X_PIC_CLOCK_INT			(PNX833X_PIC_IRQ_BASE + 34)
#define PNX833X_PIC_SGDX_PARSER_INT		(PNX833X_PIC_IRQ_BASE + 35)
#define PNX833X_PIC_VMSP_DMA_INT		(PNX833X_PIC_IRQ_BASE + 36)

#if defined(CONFIG_SOC_PNX8335)
#define PNX8335_PIC_MIU_INT					(PNX833X_PIC_IRQ_BASE + 37)
#define PNX8335_PIC_AVCHIP_IRQ_INT			(PNX833X_PIC_IRQ_BASE + 38)
#define PNX8335_PIC_SYNC_HD_INT				(PNX833X_PIC_IRQ_BASE + 39)
#define PNX8335_PIC_DISP_HD_INT				(PNX833X_PIC_IRQ_BASE + 40)
#define PNX8335_PIC_DISP_SCALER_INT			(PNX833X_PIC_IRQ_BASE + 41)
#define PNX8335_PIC_OSD_HD1_INT				(PNX833X_PIC_IRQ_BASE + 42)
#define PNX8335_PIC_DTL_WRITER_Y_INT		(PNX833X_PIC_IRQ_BASE + 43)
#define PNX8335_PIC_DTL_WRITER_C_INT		(PNX833X_PIC_IRQ_BASE + 44)
#define PNX8335_PIC_DTL_EMULATOR_Y_IR_INT	(PNX833X_PIC_IRQ_BASE + 45)
#define PNX8335_PIC_DTL_EMULATOR_C_IR_INT	(PNX833X_PIC_IRQ_BASE + 46)
#define PNX8335_PIC_DENC_TTX_INT			(PNX833X_PIC_IRQ_BASE + 47)
#define PNX8335_PIC_MMI_SIF0_INT			(PNX833X_PIC_IRQ_BASE + 48)
#define PNX8335_PIC_MMI_SIF1_INT			(PNX833X_PIC_IRQ_BASE + 49)
#define PNX8335_PIC_MMI_CDMMU_INT			(PNX833X_PIC_IRQ_BASE + 50)
#define PNX8335_PIC_PIBCS_INT				(PNX833X_PIC_IRQ_BASE + 51)
#define PNX8335_PIC_ETHERNET_INT			(PNX833X_PIC_IRQ_BASE + 52)
#define PNX8335_PIC_VMSP1_0_INT				(PNX833X_PIC_IRQ_BASE + 53)
#define PNX8335_PIC_VMSP1_1_INT				(PNX833X_PIC_IRQ_BASE + 54)
#define PNX8335_PIC_VMSP1_DMA_INT			(PNX833X_PIC_IRQ_BASE + 55)
#define PNX8335_PIC_TDGR_DE_INT				(PNX833X_PIC_IRQ_BASE + 56)
#define PNX8335_PIC_IR1_IRQ_INT				(PNX833X_PIC_IRQ_BASE + 57)
#endif

/* GPIO interrupts */
#define PNX833X_GPIO_0_INT			(PNX833X_GPIO_IRQ_BASE +  0)
#define PNX833X_GPIO_1_INT			(PNX833X_GPIO_IRQ_BASE +  1)
#define PNX833X_GPIO_2_INT			(PNX833X_GPIO_IRQ_BASE +  2)
#define PNX833X_GPIO_3_INT			(PNX833X_GPIO_IRQ_BASE +  3)
#define PNX833X_GPIO_4_INT			(PNX833X_GPIO_IRQ_BASE +  4)
#define PNX833X_GPIO_5_INT			(PNX833X_GPIO_IRQ_BASE +  5)
#define PNX833X_GPIO_6_INT			(PNX833X_GPIO_IRQ_BASE +  6)
#define PNX833X_GPIO_7_INT			(PNX833X_GPIO_IRQ_BASE +  7)
#define PNX833X_GPIO_8_INT			(PNX833X_GPIO_IRQ_BASE +  8)
#define PNX833X_GPIO_9_INT			(PNX833X_GPIO_IRQ_BASE +  9)
#define PNX833X_GPIO_10_INT			(PNX833X_GPIO_IRQ_BASE + 10)
#define PNX833X_GPIO_11_INT			(PNX833X_GPIO_IRQ_BASE + 11)
#define PNX833X_GPIO_12_INT			(PNX833X_GPIO_IRQ_BASE + 12)
#define PNX833X_GPIO_13_INT			(PNX833X_GPIO_IRQ_BASE + 13)
#define PNX833X_GPIO_14_INT			(PNX833X_GPIO_IRQ_BASE + 14)
#define PNX833X_GPIO_15_INT			(PNX833X_GPIO_IRQ_BASE + 15)

#endif
Loading