2008-07-10 22:33:08 +07:00
|
|
|
/*
|
|
|
|
* linux/arch/mips/txx9/generic/setup.c
|
|
|
|
*
|
|
|
|
* Based on linux/arch/mips/txx9/rbtx4938/setup.c,
|
|
|
|
* and RBTX49xx patch from CELF patch archive.
|
|
|
|
*
|
|
|
|
* 2003-2005 (c) MontaVista Software, Inc.
|
|
|
|
* (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
2008-07-11 21:27:54 +07:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/err.h>
|
2008-07-18 23:51:52 +07:00
|
|
|
#include <linux/gpio.h>
|
2008-07-23 22:25:18 +07:00
|
|
|
#include <linux/platform_device.h>
|
2008-07-11 21:27:54 +07:00
|
|
|
#include <asm/bootinfo.h>
|
2008-07-18 23:51:52 +07:00
|
|
|
#include <asm/time.h>
|
2008-07-23 22:25:17 +07:00
|
|
|
#include <asm/reboot.h>
|
2008-07-10 22:33:08 +07:00
|
|
|
#include <asm/txx9/generic.h>
|
2008-07-23 22:25:15 +07:00
|
|
|
#include <asm/txx9/pci.h>
|
2008-07-11 21:27:54 +07:00
|
|
|
#ifdef CONFIG_CPU_TX49XX
|
|
|
|
#include <asm/txx9/tx4938.h>
|
|
|
|
#endif
|
2008-07-10 22:33:08 +07:00
|
|
|
|
|
|
|
/* EBUSC settings of TX4927, etc. */
|
|
|
|
struct resource txx9_ce_res[8];
|
|
|
|
static char txx9_ce_res_name[8][4]; /* "CEn" */
|
|
|
|
|
|
|
|
/* pcode, internal register */
|
2008-07-18 23:51:47 +07:00
|
|
|
unsigned int txx9_pcode;
|
2008-07-10 22:33:08 +07:00
|
|
|
char txx9_pcode_str[8];
|
|
|
|
static struct resource txx9_reg_res = {
|
|
|
|
.name = txx9_pcode_str,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
};
|
|
|
|
void __init
|
|
|
|
txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
|
|
|
|
sprintf(txx9_ce_res_name[i], "CE%d", i);
|
|
|
|
txx9_ce_res[i].flags = IORESOURCE_MEM;
|
|
|
|
txx9_ce_res[i].name = txx9_ce_res_name[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(txx9_pcode_str, "TX%x", pcode);
|
|
|
|
if (base) {
|
|
|
|
txx9_reg_res.start = base & 0xfffffffffULL;
|
|
|
|
txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
|
|
|
|
request_resource(&iomem_resource, &txx9_reg_res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clocks */
|
|
|
|
unsigned int txx9_master_clock;
|
|
|
|
unsigned int txx9_cpu_clock;
|
|
|
|
unsigned int txx9_gbus_clock;
|
2008-07-11 21:27:54 +07:00
|
|
|
|
2008-07-18 23:51:47 +07:00
|
|
|
int txx9_ccfg_toeon __initdata = 1;
|
2008-07-11 21:27:54 +07:00
|
|
|
|
|
|
|
/* Minimum CLK support */
|
|
|
|
|
|
|
|
struct clk *clk_get(struct device *dev, const char *id)
|
|
|
|
{
|
|
|
|
if (!strcmp(id, "spi-baseclk"))
|
2008-07-18 23:51:47 +07:00
|
|
|
return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
|
2008-07-11 21:27:54 +07:00
|
|
|
if (!strcmp(id, "imbus_clk"))
|
2008-07-18 23:51:47 +07:00
|
|
|
return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
|
2008-07-11 21:27:54 +07:00
|
|
|
return ERR_PTR(-ENOENT);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_get);
|
|
|
|
|
|
|
|
int clk_enable(struct clk *clk)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_enable);
|
|
|
|
|
|
|
|
void clk_disable(struct clk *clk)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_disable);
|
|
|
|
|
|
|
|
unsigned long clk_get_rate(struct clk *clk)
|
|
|
|
{
|
|
|
|
return (unsigned long)clk;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_get_rate);
|
|
|
|
|
|
|
|
void clk_put(struct clk *clk)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_put);
|
|
|
|
|
2008-07-17 22:43:48 +07:00
|
|
|
/* GPIO support */
|
|
|
|
|
|
|
|
#ifdef CONFIG_GENERIC_GPIO
|
|
|
|
int gpio_to_irq(unsigned gpio)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(gpio_to_irq);
|
|
|
|
|
|
|
|
int irq_to_gpio(unsigned irq)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(irq_to_gpio);
|
|
|
|
#endif
|
|
|
|
|
2008-07-11 21:27:54 +07:00
|
|
|
extern struct txx9_board_vec jmr3927_vec;
|
|
|
|
extern struct txx9_board_vec rbtx4927_vec;
|
|
|
|
extern struct txx9_board_vec rbtx4937_vec;
|
|
|
|
extern struct txx9_board_vec rbtx4938_vec;
|
|
|
|
|
|
|
|
struct txx9_board_vec *txx9_board_vec __initdata;
|
|
|
|
static char txx9_system_type[32];
|
|
|
|
|
|
|
|
void __init prom_init_cmdline(void)
|
|
|
|
{
|
|
|
|
int argc = (int)fw_arg0;
|
|
|
|
char **argv = (char **)fw_arg1;
|
|
|
|
int i; /* Always ignore the "-c" at argv[0] */
|
2008-07-18 23:51:47 +07:00
|
|
|
#ifdef CONFIG_64BIT
|
|
|
|
char *fixed_argv[32];
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
|
|
|
|
argv = fixed_argv;
|
|
|
|
#endif
|
2008-07-11 21:27:54 +07:00
|
|
|
|
|
|
|
/* ignore all built-in args if any f/w args given */
|
|
|
|
if (argc > 1)
|
|
|
|
*arcs_cmdline = '\0';
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (i != 1)
|
|
|
|
strcat(arcs_cmdline, " ");
|
|
|
|
strcat(arcs_cmdline, argv[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init prom_init(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_CPU_TX39XX
|
2008-07-13 17:51:55 +07:00
|
|
|
txx9_board_vec = &jmr3927_vec;
|
2008-07-11 21:27:54 +07:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_CPU_TX49XX
|
|
|
|
switch (TX4938_REV_PCODE()) {
|
2008-07-17 22:43:48 +07:00
|
|
|
#ifdef CONFIG_TOSHIBA_RBTX4927
|
2008-07-11 21:27:54 +07:00
|
|
|
case 0x4927:
|
2008-07-13 17:51:55 +07:00
|
|
|
txx9_board_vec = &rbtx4927_vec;
|
2008-07-11 21:27:54 +07:00
|
|
|
break;
|
|
|
|
case 0x4937:
|
2008-07-13 17:51:55 +07:00
|
|
|
txx9_board_vec = &rbtx4937_vec;
|
2008-07-11 21:27:54 +07:00
|
|
|
break;
|
2008-07-17 22:43:48 +07:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_TOSHIBA_RBTX4938
|
2008-07-11 21:27:54 +07:00
|
|
|
case 0x4938:
|
2008-07-13 17:51:55 +07:00
|
|
|
txx9_board_vec = &rbtx4938_vec;
|
2008-07-11 21:27:54 +07:00
|
|
|
break;
|
2008-07-17 22:43:48 +07:00
|
|
|
#endif
|
2008-07-11 21:27:54 +07:00
|
|
|
}
|
|
|
|
#endif
|
2008-07-13 17:51:55 +07:00
|
|
|
|
|
|
|
strcpy(txx9_system_type, txx9_board_vec->system);
|
|
|
|
|
2008-07-13 22:15:04 +07:00
|
|
|
txx9_board_vec->prom_init();
|
2008-07-11 21:27:54 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init prom_free_prom_memory(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *get_system_type(void)
|
|
|
|
{
|
|
|
|
return txx9_system_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * __init prom_getcmdline(void)
|
|
|
|
{
|
|
|
|
return &(arcs_cmdline[0]);
|
|
|
|
}
|
|
|
|
|
2008-07-23 22:25:17 +07:00
|
|
|
static void __noreturn txx9_machine_halt(void)
|
|
|
|
{
|
|
|
|
local_irq_disable();
|
|
|
|
clear_c0_status(ST0_IM);
|
|
|
|
while (1) {
|
|
|
|
if (cpu_wait) {
|
|
|
|
(*cpu_wait)();
|
|
|
|
if (cpu_has_counter) {
|
|
|
|
/*
|
|
|
|
* Clear counter interrupt while it
|
|
|
|
* breaks WAIT instruction even if
|
|
|
|
* masked.
|
|
|
|
*/
|
|
|
|
write_c0_compare(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-23 22:25:18 +07:00
|
|
|
/* Watchdog support */
|
|
|
|
void __init txx9_wdt_init(unsigned long base)
|
|
|
|
{
|
|
|
|
struct resource res = {
|
|
|
|
.start = base,
|
|
|
|
.end = base + 0x100 - 1,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
};
|
|
|
|
platform_device_register_simple("txx9wdt", -1, &res, 1);
|
|
|
|
}
|
|
|
|
|
2008-07-23 22:25:20 +07:00
|
|
|
/* SPI support */
|
|
|
|
void __init txx9_spi_init(int busid, unsigned long base, int irq)
|
|
|
|
{
|
|
|
|
struct resource res[] = {
|
|
|
|
{
|
|
|
|
.start = base,
|
|
|
|
.end = base + 0x20 - 1,
|
|
|
|
.flags = IORESOURCE_MEM,
|
|
|
|
}, {
|
|
|
|
.start = irq,
|
|
|
|
.flags = IORESOURCE_IRQ,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
platform_device_register_simple("spi_txx9", busid,
|
|
|
|
res, ARRAY_SIZE(res));
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init txx9_ethaddr_init(unsigned int id, unsigned char *ethaddr)
|
|
|
|
{
|
|
|
|
struct platform_device *pdev =
|
|
|
|
platform_device_alloc("tc35815-mac", id);
|
|
|
|
if (!pdev ||
|
|
|
|
platform_device_add_data(pdev, ethaddr, 6) ||
|
|
|
|
platform_device_add(pdev))
|
|
|
|
platform_device_put(pdev);
|
|
|
|
}
|
|
|
|
|
2008-07-11 21:27:54 +07:00
|
|
|
/* wrappers */
|
|
|
|
void __init plat_mem_setup(void)
|
|
|
|
{
|
2008-07-18 23:51:47 +07:00
|
|
|
ioport_resource.start = 0;
|
|
|
|
ioport_resource.end = ~0UL; /* no limit */
|
|
|
|
iomem_resource.start = 0;
|
|
|
|
iomem_resource.end = ~0UL; /* no limit */
|
2008-07-23 22:25:17 +07:00
|
|
|
|
|
|
|
/* fallback restart/halt routines */
|
|
|
|
_machine_restart = (void (*)(char *))txx9_machine_halt;
|
|
|
|
_machine_halt = txx9_machine_halt;
|
|
|
|
pm_power_off = txx9_machine_halt;
|
|
|
|
|
2008-07-23 22:25:15 +07:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
pcibios_plat_setup = txx9_pcibios_setup;
|
|
|
|
#endif
|
2008-07-11 21:27:54 +07:00
|
|
|
txx9_board_vec->mem_setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init arch_init_irq(void)
|
|
|
|
{
|
|
|
|
txx9_board_vec->irq_setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init plat_time_init(void)
|
|
|
|
{
|
|
|
|
txx9_board_vec->time_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init _txx9_arch_init(void)
|
|
|
|
{
|
|
|
|
if (txx9_board_vec->arch_init)
|
|
|
|
txx9_board_vec->arch_init();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
arch_initcall(_txx9_arch_init);
|
|
|
|
|
|
|
|
static int __init _txx9_device_init(void)
|
|
|
|
{
|
|
|
|
if (txx9_board_vec->device_init)
|
|
|
|
txx9_board_vec->device_init();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
device_initcall(_txx9_device_init);
|
|
|
|
|
|
|
|
int (*txx9_irq_dispatch)(int pending);
|
|
|
|
asmlinkage void plat_irq_dispatch(void)
|
|
|
|
{
|
|
|
|
int pending = read_c0_status() & read_c0_cause() & ST0_IM;
|
|
|
|
int irq = txx9_irq_dispatch(pending);
|
|
|
|
|
|
|
|
if (likely(irq >= 0))
|
|
|
|
do_IRQ(irq);
|
|
|
|
else
|
|
|
|
spurious_interrupt();
|
|
|
|
}
|
2008-07-13 21:37:56 +07:00
|
|
|
|
|
|
|
/* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
|
|
|
|
#ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
|
|
|
|
static unsigned long __swizzle_addr_none(unsigned long port)
|
|
|
|
{
|
|
|
|
return port;
|
|
|
|
}
|
|
|
|
unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
|
|
|
|
EXPORT_SYMBOL(__swizzle_addr_b);
|
|
|
|
#endif
|