Skip to contentSkip to conversation

add TI AR7 support

PATCH In review Florian Fainelli 2 participants 3 messages Jun 1, 2009 – Jun 4, 2009 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 8/10 add TI AR7 support

This patch adds support for the TI AR7 System-on-Chip. Supported versions are TNED7100, 7200 and 7300.

---

arch/mips/ar7/Makefile new file +10 -0
new file mode 100644
index 0000000..7435e44
@@ -0,0 +1,10 @@
+
+obj-y := \
+	prom.o \
+	setup.o \
+	memory.o \
+	irq.o \
+	time.o \
+	platform.o \
+	gpio.o \
+	clock.o
arch/mips/ar7/clock.c new file +447 -0

447 lines not on this page · raw message

arch/mips/ar7/gpio.c new file +48 -0

48 lines not on this page · raw message

arch/mips/ar7/irq.c new file +184 -0

184 lines not on this page · raw message

arch/mips/ar7/memory.c new file +74 -0

74 lines not on this page · raw message

arch/mips/ar7/platform.c new file +543 -0

543 lines not on this page · raw message

arch/mips/ar7/prom.c new file +330 -0

330 lines not on this page · raw message

arch/mips/ar7/setup.c new file +107 -0

107 lines not on this page · raw message

arch/mips/ar7/time.c new file +28 -0
new file mode 100644
index 0000000..5f17489
@@ -0,0 +1,28 @@
+/*
+ * Carsten Langgaard, [email protected]
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope 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.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Setting up the clock on the MIPS boards.
+ */
+
+#include <linux/version.h>
+#include <asm/time.h>
+#include <asm/mach-ar7/ar7.h>
+
+void __init plat_time_init(void)
+{
+	mips_hpt_frequency = ar7_cpu_freq() / 2;
+}
arch/mips/include/asm/mach-ar7/ar7.h new file +170 -0

170 lines not on this page · raw message

arch/mips/include/asm/mach-ar7/gpio.h new file +110 -0

110 lines not on this page · raw message

arch/mips/include/asm/mach-ar7/irq.h new file +16 -0
new file mode 100644
index 0000000..39e9757
@@ -0,0 +1,16 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Shamelessly copied from asm-mips/mach-emma2rh/
+ * Copyright (C) 2003 by Ralf Baechle
+ */
+#ifndef __ASM_AR7_IRQ_H
+#define __ASM_AR7_IRQ_H
+
+#define NR_IRQS	256
+
+#include_next <irq.h>
+
+#endif /* __ASM_AR7_IRQ_H */
arch/mips/include/asm/mach-ar7/prom.h new file +26 -0
new file mode 100644
index 0000000..55f5939
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2006, 2007 Florian Fainelli <[email protected]>
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __PROM_H__
+#define __PROM_H__
+
+extern char *prom_getenv(const char *name);
+extern void prom_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
+extern void prom_meminit(void);
+
+#endif /* __PROM_H__ */
arch/mips/include/asm/mach-ar7/spaces.h new file +32 -0
new file mode 100644
index 0000000..f4d1237
@@ -0,0 +1,32 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
+ * Copyright (C) 2000, 2002  Maciej W. Rozycki
+ * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
+ */
+#ifndef _ASM_AR7_SPACES_H
+#define _ASM_AR7_SPACES_H
+
+#define CAC_BASE		0x80000000
+#define IO_BASE			0xa0000000
+#define UNCAC_BASE		0xa0000000
+#define MAP_BASE		0xc0000000
+
+/*
+ * This handles the memory map.
+ * We handle pages at KSEG0 for kernels with 32 bit address space.
+ */
+#define PAGE_OFFSET		0x94000000UL
+#define PHYS_OFFSET		0x14000000UL
+
+/*
+ * Memory above this physical address will be considered highmem.
+ */
+#ifndef HIGHMEM_START
+#define HIGHMEM_START		0x40000000UL
+#endif
+
+#endif /* __ASM_AR7_SPACES_H */
arch/mips/include/asm/mach-ar7/war.h new file +25 -0
new file mode 100644
index 0000000..f4862b5
@@ -0,0 +1,25 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <[email protected]>
+ */
+#ifndef __ASM_MIPS_MACH_AR7_WAR_H
+#define __ASM_MIPS_MACH_AR7_WAR_H
+
+#define R4600_V1_INDEX_ICACHEOP_WAR	0
+#define R4600_V1_HIT_CACHEOP_WAR	0
+#define R4600_V2_HIT_CACHEOP_WAR	0
+#define R5432_CP0_INTERRUPT_WAR		0
+#define BCM1250_M3_WAR			0
+#define SIBYTE_1956_WAR			0
+#define MIPS4K_ICACHE_REFILL_WAR	0
+#define MIPS_CACHE_SYNC_WAR		0
+#define TX49XX_ICACHE_INDEX_INV_WAR	0
+#define RM9000_CDEX_SMP_WAR		0
+#define ICACHE_REFILLS_WORKAROUND_WAR	0
+#define R10000_LLSC_WAR			0
+#define MIPS34K_MISSED_ITLB_WAR		0
+
+#endif /* __ASM_MIPS_MACH_AR7_WAR_H */
#1 lore raw
Quoted 1 line · Florian Fainelli

Subject: [PATCH 08/10] add TI AR7 support

This should be 7/9 I assume?

arch/mips/ar7/clock.c line 135

Quoted 1 line
arch/mips/ar7/clock.c new file +1 -0
+	if (base / (*prediv) * (*mul) / (*postdiv) != target) {

There should be a tax on excessive use of parenthesis ;-)

arch/mips/ar7/clock.c line 137

Quoted 2 lines
arch/mips/ar7/clock.c new file +2 -0
+		approximate(base, target, prediv, postdiv, mul);
+		tmp_freq = base / (*prediv) * (*mul) / (*postdiv);

More taxes!

arch/mips/ar7/clock.c line 238

Quoted 8 lines
arch/mips/ar7/clock.c new file +8 -0
+
+	writel(((prediv - 1) << PREDIV_SHIFT) | (postdiv - 1), &clock->ctrl);
+	mdelay(1);
+	writel(4, &clock->pll);
+	while (readl(&clock->pll) & PLL_STATUS)
+		;
+	writel(((mul - 1) << MUL_SHIFT) | (0xff << 3) | 0x0e, &clock->pll);
+	mdelay(75);

These calls to mdelay seem to be done very early before BogoMIPS has been calibrated?

arch/mips/ar7/clock.c line 424

Quoted 10 lines
arch/mips/ar7/clock.c new file +10 -0
+	printk(KERN_INFO "Clocks: Setting USB clock\n");
+	usb_base = ar7_bus_clock;
+	calculate(usb_base, TNETD7200_DEF_USB_CLK, &usb_prediv,
+		&usb_postdiv, &usb_mul);
+	tnetd7200_set_clock(usb_base, &clocks->usb,
+		usb_prediv, usb_postdiv, -1, usb_mul,
+		TNETD7200_DEF_USB_CLK);
+
+	#warning FIXME
+	ar7_dsp_clock = ar7_cpu_clock;

Fix it :-)

arch/mips/ar7/clock.c line 434

Quoted 5 lines
arch/mips/ar7/clock.c new file +5 -0
+void __init ar7_init_clocks(void)
+{
+	switch (ar7_chip_id()) {
+	case AR7_CHIP_7100:
+#warning FIXME: Check if the new 7200 clock init works for 7100

Fix it again, Toni.

arch/mips/ar7/memory.c line 6

Quoted 12 lines
arch/mips/ar7/memory.c new file +6 -0
new file mode 100644
index 0000000..e8522a1
@@ -0,0 +1,74 @@
+/*
+ * Based on arch/mips/mm/init.c
+ * Copyright (C) 1994 - 2000 Ralf Baechle
+ * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
+ * Kevin D. Kissell, [email protected] and Carsten Langgaard, [email protected]
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.

Somehow this file has no similarity to arch/mips/mm/init.c so I think somebody else should claim the (C).

Quoted 13 lines
arch/mips/ar7/platform.c new file +10 -0
@@ -0,0 +1,543 @@
+/*
+ * Copyright (C) 2006,2007 Felix Fietkau <[email protected]>
+ * Copyright (C) 2006,2007 Eugene Konev <[email protected]>
+ *
+ * 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,

arch/mips/ar7/platform.c line 20

Quoted 10 lines
arch/mips/ar7/platform.c new file +10 -0
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/autoconf.h>

Do not include <linux/autoconf.h>.

arch/mips/ar7/platform.c line 291

Quoted 13 lines
arch/mips/ar7/platform.c new file +13 -0
+static struct platform_device vlynq_high = {
+	.id = 1,
+	.name = "vlynq",
+	.dev.platform_data = &vlynq_high_data,
+	.resource = vlynq_high_res,
+	.num_resources = ARRAY_SIZE(vlynq_high_res),
+};
+
+
+/* This is proper way to define uart ports, but they are then detected
+ * as xscale and, obviously, don't work...
+ */
+#if !defined(CONFIG_SERIAL_8250)

Can you elaborate?

Quoted 9 lines
arch/mips/ar7/platform.c new file +9 -0
+static inline unsigned char char2hex(char h)
+{
+	switch (h) {
+	case '0': case '1': case '2': case '3': case '4':
+	case '5': case '6': case '7': case '8': case '9':
+		return h - '0';
+	case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+		return h - 'A' + 10;
+	case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':

arch/mips/ar7/platform.c line 401

Quoted 10 lines
arch/mips/ar7/platform.c new file +10 -0
+		return h - 'a' + 10;
+	default:
+		return 0;
+	}
+}
+
+static void cpmac_get_mac(int instance, unsigned char *dev_addr)
+{
+	int i;
+	char name[5], default_mac[] = "00:00:00:12:34:56", *mac;

If you don't have a MAC address, either use random_ether_addr() or don't bring up the network interface at all. Multiple interfaces with the same MAC can cause chaos on a network to better avoid that.

arch/mips/ar7/platform.c line 59

Quoted 7 lines
arch/mips/ar7/platform.c new file +7 -0
+struct psp_env_chunk {
+	u8 num;
+	u8 ctrl;
+	u16 csum;
+	u8 len;
+	char data[11];
+} __attribute__ ((packed));

Afair historic versions of this code were totally polluted with __attribute__((packed)). Thanks for cleaning that.

Btw - Linux coding style: No space between __attribute__ and ((packed)).

arch/mips/ar7/platform.c line 60

Quoted 1 line
arch/mips/ar7/platform.c new file +1 -0
+#include <asm/reboot.h>

You get a false warning from checkpatch.pl here. Which probably means either we should teach checkpatch.pl to check if <linux/reboot.h> is actually including <asm/reboot.h> or rename <asm/reboot.h> to something which would also help to avoid confusion.

arch/mips/ar7/platform.c line 61

Quoted 1 line
arch/mips/ar7/platform.c new file +1 -0
+++ b/arch/mips/include/asm/mach-ar7/spaces.h

You can cut down this header file to something like:

/* Copyright blurb */
#ifndef _ASM_AR7_SPACES_H
#define _ASM_AR7_SPACES_H

/*
* This handles the memory map.
* We handle pages at KSEG0 for kernels with 32 bit address space. */
#define PAGE_OFFSET 0x94000000UL
#define PHYS_OFFSET 0x14000000UL

#include <asm/mach-generic/spaces.h>

#endif /* __ASM_AR7_SPACES_H */

Ralf

#2 lore raw

Hallo Ralf,

Le Tuesday 02 June 2009 14:51:59 Ralf Baechle, vous avez écrit :
[snip]

Quoted 11 lines

arch/mips/ar7/clock.c line 238

Quoted 8 lines
arch/mips/ar7/clock.c new file +8 -0
+
+	writel(((prediv - 1) << PREDIV_SHIFT) | (postdiv - 1), &clock->ctrl);
+	mdelay(1);
+	writel(4, &clock->pll);
+	while (readl(&clock->pll) & PLL_STATUS)
+		;
+	writel(((mul - 1) << MUL_SHIFT) | (0xff << 3) | 0x0e, &clock->pll);
+	mdelay(75);

These calls to mdelay seem to be done very early before BogoMIPS has been calibrated?

Yes, is there a prefered way than using mdelay here ?

Quoted 3 lines

Can you elaborate?

I do not think there has been AR7 devices having non-8250 compatible UARTs out there thus this code is simply useful. What is meant by the comment is that the UART will be reported by Linux as ttyS0 .... is a Xscale. But this should not happen since there are only 8250 UARTs.

Quoted 3 lines

If you don't have a MAC address, either use random_ether_addr() or don't bring up the network interface at all. Multiple interfaces with the same MAC can cause chaos on a network to better avoid that.

Thanks for spotting this.

Quoted 12 lines

arch/mips/ar7/prom.c line 94

Quoted 8 lines
arch/mips/ar7/prom.c new file +7 -0
+struct psp_env_chunk {
+	u8 num;
+	u8 ctrl;
+	u16 csum;
+	u8 len;
+	char data[11];
+} __attribute__ ((packed));

Afair historic versions of this code were totally polluted with __attribute__((packed)). Thanks for cleaning that.

Quoted 8 lines

Btw - Linux coding style: No space between __attribute__ and ((packed)).

Quoted 1 line

+#include <asm/reboot.h>

You get a false warning from checkpatch.pl here. Which probably means either we should teach checkpatch.pl to check if <linux/reboot.h> is actually including <asm/reboot.h> or rename <asm/reboot.h> to something which would also help to avoid confusion.

<linux/reboot.h> is not including <asm/reboot.h> so renaming <asm/reboot.h> sounds like a good solution.

Quoted 9 lines
Quoted 2 lines

+++ b/arch/mips/include/asm/mach-ar7/spaces.h

You can cut down this header file to something like:

/* Copyright blurb */
#ifndef _ASM_AR7_SPACES_H
#define _ASM_AR7_SPACES_H

Quoted 8 lines

/*
* This handles the memory map.
* We handle pages at KSEG0 for kernels with 32 bit address space. */
#define PAGE_OFFSET 0x94000000UL
#define PHYS_OFFSET 0x14000000UL

#include <asm/mach-generic/spaces.h>

Fixed, thanks !

Signature · 4 lines
Best regards, Florian Fainelli
Email : [email protected]
http://openwrt.org
-------------------------------