Path: blob/master/arch/xtensa/platforms/xt2000/setup.c
15126 views
/*1* arch/xtensa/platforms/xt2000/setup.c2*3* Platform specific functions for the XT2000 board.4*5* Authors: Chris Zankel <[email protected]>6* Joe Taylor <[email protected]>7*8* Copyright 2001 - 2004 Tensilica Inc.9*10* This program is free software; you can redistribute it and/or modify it11* under the terms of the GNU General Public License as published by the12* Free Software Foundation; either version 2 of the License, or (at your13* option) any later version.14*15*/16#include <linux/stddef.h>17#include <linux/kernel.h>18#include <linux/init.h>19#include <linux/errno.h>20#include <linux/reboot.h>21#include <linux/kdev_t.h>22#include <linux/types.h>23#include <linux/major.h>24#include <linux/console.h>25#include <linux/delay.h>26#include <linux/stringify.h>27#include <linux/platform_device.h>28#include <linux/serial.h>29#include <linux/serial_8250.h>3031#include <asm/processor.h>32#include <asm/platform.h>33#include <asm/bootparam.h>34#include <platform/hardware.h>35#include <platform/serial.h>3637/* Assumes s points to an 8-chr string. No checking for NULL. */3839static void led_print (int f, char *s)40{41unsigned long* led_addr = (unsigned long*) (XT2000_LED_ADDR + 0xE0) + f;42int i;43for (i = f; i < 8; i++)44if ((*led_addr++ = *s++) == 0)45break;46}4748void platform_halt(void)49{50led_print (0, " HALT ");51local_irq_disable();52while (1);53}5455void platform_power_off(void)56{57led_print (0, "POWEROFF");58local_irq_disable();59while (1);60}6162void platform_restart(void)63{64/* Flush and reset the mmu, simulate a processor reset, and65* jump to the reset vector. */6667__asm__ __volatile__ ("movi a2, 15\n\t"68"wsr a2, " __stringify(ICOUNTLEVEL) "\n\t"69"movi a2, 0\n\t"70"wsr a2, " __stringify(ICOUNT) "\n\t"71"wsr a2, " __stringify(IBREAKENABLE) "\n\t"72"wsr a2, " __stringify(LCOUNT) "\n\t"73"movi a2, 0x1f\n\t"74"wsr a2, " __stringify(PS) "\n\t"75"isync\n\t"76"jx %0\n\t"77:78: "a" (XCHAL_RESET_VECTOR_VADDR)79: "a2"80);8182/* control never gets here */83}8485void __init platform_setup(char** cmdline)86{87led_print (0, "LINUX ");88}8990/* early initialization */9192extern sysmem_info_t __initdata sysmem;9394void platform_init(bp_tag_t* first)95{96/* Set default memory block if not provided by the bootloader. */9798if (sysmem.nr_banks == 0) {99sysmem.nr_banks = 1;100sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START;101sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START102+ PLATFORM_DEFAULT_MEM_SIZE;103}104}105106/* Heartbeat. Let the LED blink. */107108void platform_heartbeat(void)109{110static int i=0, t = 0;111112if (--t < 0)113{114t = 59;115led_print(7, i ? ".": " ");116i ^= 1;117}118}119120//#define RS_TABLE_SIZE 2121//#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)122123#define _SERIAL_PORT(_base,_irq) \124{ \125.mapbase = (_base), \126.membase = (void*)(_base), \127.irq = (_irq), \128.uartclk = DUART16552_XTAL_FREQ, \129.iotype = UPIO_MEM, \130.flags = UPF_BOOT_AUTOCONF, \131.regshift = 2, \132}133134static struct plat_serial8250_port xt2000_serial_data[] = {135#if XCHAL_HAVE_BE136_SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),137_SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),138#else139_SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),140_SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),141#endif142{ }143};144145static struct platform_device xt2000_serial8250_device = {146.name = "serial8250",147.id = PLAT8250_DEV_PLATFORM,148.dev = {149.platform_data = xt2000_serial_data,150},151};152153static struct resource xt2000_sonic_res[] = {154{155.start = SONIC83934_ADDR,156.end = SONIC83934_ADDR + 0xff,157.flags = IORESOURCE_MEM,158},159{160.start = SONIC83934_INTNUM,161.end = SONIC83934_INTNUM,162.flags = IORESOURCE_IRQ,163},164};165166static struct platform_device xt2000_sonic_device = {167.name = "xtsonic",168.num_resources = ARRAY_SIZE(xt2000_sonic_res),169.resource = xt2000_sonic_res,170};171172static int __init xt2000_setup_devinit(void)173{174platform_device_register(&xt2000_serial8250_device);175platform_device_register(&xt2000_sonic_device);176177return 0;178}179180device_initcall(xt2000_setup_devinit);181182183