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

Commit 724ce5ee authored by Uwe Kleine-König's avatar Uwe Kleine-König
Browse files

ns9xxx: prepare for adding support for Digi ns921x processors



The hardware team changed some things that were taken as being common to
all ns9xxx processors up to now.

This patch addresses:

- irqs: s/IRQ_/IRQ_NS9360_/

- system module registers: some registers are still general, their
  definition lives now in include/asm-arm/arch-ns9xxx/regs-sys-common.h.
  The ns9360 specific ones are in .../regs-sys-ns9360.h
  As a result ns9360_systemclock cannot be static inline any more as its
  definition needs regs-sys-ns9360.h.  This becomes a real problem when
  adding support for ns9215 as this will need regs-sys-ns9215.h and
  including both files will not work.  For the same reason
  ns9360_reset() is now non-inline and gpio functions live in their own
  file.

- register mapping: s/ns9xxx_map_io/ns9360_map_io/

- timer registers:  move time.c to time-ns9360.c;
  s/ns9xxx_timer/ns9360_timer/

Signed-off-by: default avatarUwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
parent 3a581349
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
obj-y := irq.o time.o generic.o gpio.o
obj-y := irq.o generic.o gpio.o


obj-$(CONFIG_MACH_CC9P9360DEV) += mach-cc9p9360dev.o
obj-$(CONFIG_MACH_CC9P9360DEV) += mach-cc9p9360dev.o
obj-$(CONFIG_MACH_CC9P9360JS) += mach-cc9p9360js.o
obj-$(CONFIG_MACH_CC9P9360JS) += mach-cc9p9360js.o


obj-$(CONFIG_PROCESSOR_NS9360) += gpio-ns9360.o processor-ns9360.o time-ns9360.o

obj-$(CONFIG_BOARD_A9M9750DEV) += board-a9m9750dev.o
obj-$(CONFIG_BOARD_A9M9750DEV) += board-a9m9750dev.o
obj-$(CONFIG_BOARD_JSCC9P9360) += board-jscc9p9360.o
obj-$(CONFIG_BOARD_JSCC9P9360) += board-jscc9p9360.o


+6 −5
Original line number Original line Diff line number Diff line
@@ -14,7 +14,8 @@
#include <asm/gpio.h>
#include <asm/gpio.h>


#include <asm/arch-ns9xxx/board.h>
#include <asm/arch-ns9xxx/board.h>
#include <asm/arch-ns9xxx/regs-sys.h>
#include <asm/arch-ns9xxx/processor-ns9360.h>
#include <asm/arch-ns9xxx/regs-sys-ns9360.h>
#include <asm/arch-ns9xxx/regs-mem.h>
#include <asm/arch-ns9xxx/regs-mem.h>
#include <asm/arch-ns9xxx/regs-bbu.h>
#include <asm/arch-ns9xxx/regs-bbu.h>
#include <asm/arch-ns9xxx/regs-board-a9m9750dev.h>
#include <asm/arch-ns9xxx/regs-board-a9m9750dev.h>
@@ -103,9 +104,9 @@ void __init board_a9m9750dev_init_irq(void)
	int i;
	int i;


	if (gpio_request(11, "board a9m9750dev extirq2") == 0)
	if (gpio_request(11, "board a9m9750dev extirq2") == 0)
		ns9xxx_gpio_configure(11, 0, 1);
		ns9360_gpio_configure(11, 0, 1);
	else
	else
		printk(KERN_ERR "%s: cannot get gpio 11 for IRQ_EXT2\n",
		printk(KERN_ERR "%s: cannot get gpio 11 for IRQ_NS9XXX_EXT2\n",
				__func__);
				__func__);


	for (i = FPGA_IRQ(0); i <= FPGA_IRQ(7); ++i) {
	for (i = FPGA_IRQ(0); i <= FPGA_IRQ(7); ++i) {
@@ -114,13 +115,13 @@ void __init board_a9m9750dev_init_irq(void)
		set_irq_flags(i, IRQF_VALID);
		set_irq_flags(i, IRQF_VALID);
	}
	}


	/* IRQ_EXT2: level sensitive + active low */
	/* IRQ_NS9XXX_EXT2: level sensitive + active low */
	eic = __raw_readl(SYS_EIC(2));
	eic = __raw_readl(SYS_EIC(2));
	REGSET(eic, SYS_EIC, PLTY, AL);
	REGSET(eic, SYS_EIC, PLTY, AL);
	REGSET(eic, SYS_EIC, LVEDG, LEVEL);
	REGSET(eic, SYS_EIC, LVEDG, LEVEL);
	__raw_writel(eic, SYS_EIC(2));
	__raw_writel(eic, SYS_EIC(2));


	set_irq_chained_handler(IRQ_EXT2,
	set_irq_chained_handler(IRQ_NS9XXX_EXT2,
			a9m9750dev_fpga_demux_handler);
			a9m9750dev_fpga_demux_handler);
}
}


+1 −26
Original line number Original line Diff line number Diff line
/*
/*
 * arch/arm/mach-ns9xxx/generic.c
 * arch/arm/mach-ns9xxx/generic.c
 *
 *
 * Copyright (C) 2006 by Digi International Inc.
 * Copyright (C) 2006,2007 by Digi International Inc.
 * All rights reserved.
 * All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify it
 * This program is free software; you can redistribute it and/or modify it
@@ -11,34 +11,9 @@
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/init.h>
#include <asm/memory.h>
#include <asm/memory.h>
#include <asm/page.h>
#include <asm/mach-types.h>
#include <asm/mach/map.h>
#include <asm/arch-ns9xxx/regs-sys.h>
#include <asm/arch-ns9xxx/regs-mem.h>
#include <asm/arch-ns9xxx/board.h>


#include "generic.h"
#include "generic.h"


static struct map_desc standard_io_desc[] __initdata = {
	{ /* BBus */
		.virtual = io_p2v(0x90000000),
		.pfn = __phys_to_pfn(0x90000000),
		.length = 0x00700000,
		.type = MT_DEVICE,
	}, { /* AHB */
		.virtual = io_p2v(0xa0100000),
		.pfn = __phys_to_pfn(0xa0100000),
		.length = 0x00900000,
		.type = MT_DEVICE,
	},
};

void __init ns9xxx_map_io(void)
{
	iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
}

void __init ns9xxx_init_machine(void)
void __init ns9xxx_init_machine(void)
{
{
}
}
+1 −4
Original line number Original line Diff line number Diff line
/*
/*
 * arch/arm/mach-ns9xxx/generic.h
 * arch/arm/mach-ns9xxx/generic.h
 *
 *
 * Copyright (C) 2006 by Digi International Inc.
 * Copyright (C) 2006,2007 by Digi International Inc.
 * All rights reserved.
 * All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify it
 * This program is free software; you can redistribute it and/or modify it
@@ -13,7 +13,4 @@
#include <linux/init.h>
#include <linux/init.h>


void __init ns9xxx_init_irq(void);
void __init ns9xxx_init_irq(void);
void __init ns9xxx_map_io(void);
void __init ns9xxx_init_machine(void);
void __init ns9xxx_init_machine(void);

extern struct sys_timer ns9xxx_timer;
+118 −0
Original line number Original line Diff line number Diff line
/*
 * arch/arm/mach-ns9xxx/gpio-ns9360.c
 *
 * Copyright (C) 2006,2007 by Digi International Inc.
 * All rights reserved.
 *
 * 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/bug.h>
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>

#include <asm/arch-ns9xxx/regs-bbu.h>
#include <asm/arch-ns9xxx/processor-ns9360.h>

#include "gpio-ns9360.h"

static inline int ns9360_valid_gpio(unsigned gpio)
{
	return gpio <= 72;
}

static inline void __iomem *ns9360_gpio_get_gconfaddr(unsigned gpio)
{
	if (gpio < 56)
		return BBU_GCONFb1(gpio / 8);
	else
		/*
		 * this could be optimised away on
		 * ns9750 only builds, but it isn't ...
		 */
		return BBU_GCONFb2((gpio - 56) / 8);
}

static inline void __iomem *ns9360_gpio_get_gctrladdr(unsigned gpio)
{
	if (gpio < 32)
		return BBU_GCTRL1;
	else if (gpio < 64)
		return BBU_GCTRL2;
	else
		/* this could be optimised away on ns9750 only builds */
		return BBU_GCTRL3;
}

static inline void __iomem *ns9360_gpio_get_gstataddr(unsigned gpio)
{
	if (gpio < 32)
		return BBU_GSTAT1;
	else if (gpio < 64)
		return BBU_GSTAT2;
	else
		/* this could be optimised away on ns9750 only builds */
		return BBU_GSTAT3;
}

/*
 * each gpio can serve for 4 different purposes [0..3].  These are called
 * "functions" and passed in the parameter func.  Functions 0-2 are always some
 * special things, function 3 is GPIO.  If func == 3 dir specifies input or
 * output, and with inv you can enable an inverter (independent of func).
 */
int __ns9360_gpio_configure(unsigned gpio, int dir, int inv, int func)
{
	void __iomem *conf = ns9360_gpio_get_gconfaddr(gpio);
	u32 confval;

	confval = __raw_readl(conf);
	REGSETIM_IDX(confval, BBU_GCONFx, DIR, gpio & 7, dir);
	REGSETIM_IDX(confval, BBU_GCONFx, INV, gpio & 7, inv);
	REGSETIM_IDX(confval, BBU_GCONFx, FUNC, gpio & 7, func);
	__raw_writel(confval, conf);

	return 0;
}

int ns9360_gpio_configure(unsigned gpio, int inv, int func)
{
	if (likely(ns9360_valid_gpio(gpio))) {
		if (func == 3) {
			printk(KERN_WARNING "use gpio_direction_input "
					"or gpio_direction_output\n");
			return -EINVAL;
		} else
			return __ns9360_gpio_configure(gpio, 0, inv, func);
	} else
		return -EINVAL;
}
EXPORT_SYMBOL(ns9360_gpio_configure);

int ns9360_gpio_get_value(unsigned gpio)
{
	void __iomem *stat = ns9360_gpio_get_gstataddr(gpio);
	int ret;

	ret = 1 & (__raw_readl(stat) >> (gpio & 31));

	return ret;
}

void ns9360_gpio_set_value(unsigned gpio, int value)
{
	void __iomem *ctrl = ns9360_gpio_get_gctrladdr(gpio);
	u32 ctrlval;

	ctrlval = __raw_readl(ctrl);

	if (value)
		ctrlval |= 1 << (gpio & 31);
	else
		ctrlval &= ~(1 << (gpio & 31));

	__raw_writel(ctrlval, ctrl);
}
Loading