2019-05-27 08:55:05 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2005-10-19 23:56:38 -07:00
|
|
|
* Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
|
2005-04-16 15:20:36 -07:00
|
|
|
* Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup code for the SWARM board
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/mm.h>
|
2018-10-30 15:09:49 -07:00
|
|
|
#include <linux/memblock.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
2023-10-24 07:44:02 +02:00
|
|
|
#include <linux/console.h>
|
2006-07-10 04:44:13 -07:00
|
|
|
#include <linux/screen_info.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <linux/initrd.h>
|
|
|
|
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/bootinfo.h>
|
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/reboot.h>
|
|
|
|
#include <asm/time.h>
|
|
|
|
#include <asm/traps.h>
|
|
|
|
#include <asm/sibyte/sb1250.h>
|
2023-03-15 14:55:09 +01:00
|
|
|
#ifdef CONFIG_SIBYTE_BCM1x80
|
2005-10-19 23:56:38 -07:00
|
|
|
#include <asm/sibyte/bcm1480_regs.h>
|
|
|
|
#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/sibyte/sb1250_regs.h>
|
2005-10-19 23:56:38 -07:00
|
|
|
#else
|
2006-11-30 13:45:32 +00:00
|
|
|
#error invalid SiByte board configuration
|
2005-10-19 23:56:38 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/sibyte/sb1250_genbus.h>
|
|
|
|
#include <asm/sibyte/board.h>
|
|
|
|
|
2023-03-15 14:55:09 +01:00
|
|
|
#ifdef CONFIG_SIBYTE_BCM1x80
|
2005-10-19 23:56:38 -07:00
|
|
|
extern void bcm1480_setup(void);
|
|
|
|
#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
|
2005-04-16 15:20:36 -07:00
|
|
|
extern void sb1250_setup(void);
|
2005-10-19 23:56:38 -07:00
|
|
|
#else
|
2006-11-30 13:45:32 +00:00
|
|
|
#error invalid SiByte board configuration
|
2005-10-19 23:56:38 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
extern int xicor_probe(void);
|
2018-05-07 17:28:28 +08:00
|
|
|
extern int xicor_set_time(time64_t);
|
2018-05-07 17:28:27 +08:00
|
|
|
extern time64_t xicor_get_time(void);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
extern int m41t81_probe(void);
|
2018-05-07 17:28:28 +08:00
|
|
|
extern int m41t81_set_time(time64_t);
|
2018-05-07 17:28:27 +08:00
|
|
|
extern time64_t m41t81_get_time(void);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
const char *get_system_type(void)
|
|
|
|
{
|
|
|
|
return "SiByte " SIBYTE_BOARD_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
int swarm_be_handler(struct pt_regs *regs, int is_fixup)
|
|
|
|
{
|
|
|
|
if (!is_fixup && (regs->cp0_cause & 4)) {
|
|
|
|
/* Data bus error - print PA */
|
2005-10-01 13:14:58 +01:00
|
|
|
printk("DBE physical address: %010Lx\n",
|
2005-04-16 15:20:36 -07:00
|
|
|
__read_64bit_c0_register($26, 1));
|
|
|
|
}
|
2014-10-21 14:12:49 +02:00
|
|
|
return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2007-10-11 23:46:08 +01:00
|
|
|
enum swarm_rtc_type {
|
|
|
|
RTC_NONE,
|
|
|
|
RTC_XICOR,
|
2010-11-02 19:38:53 +00:00
|
|
|
RTC_M41T81,
|
2007-10-11 23:46:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum swarm_rtc_type swarm_rtc_type;
|
|
|
|
|
2018-05-07 17:28:27 +08:00
|
|
|
void read_persistent_clock64(struct timespec64 *ts)
|
2007-10-11 23:46:08 +01:00
|
|
|
{
|
2018-05-07 17:28:27 +08:00
|
|
|
time64_t sec;
|
2009-08-14 15:47:31 +02:00
|
|
|
|
2007-10-11 23:46:08 +01:00
|
|
|
switch (swarm_rtc_type) {
|
|
|
|
case RTC_XICOR:
|
2009-08-14 15:47:31 +02:00
|
|
|
sec = xicor_get_time();
|
|
|
|
break;
|
2007-10-11 23:46:08 +01:00
|
|
|
|
2010-11-02 19:38:53 +00:00
|
|
|
case RTC_M41T81:
|
2009-08-14 15:47:31 +02:00
|
|
|
sec = m41t81_get_time();
|
|
|
|
break;
|
2007-10-11 23:46:08 +01:00
|
|
|
|
|
|
|
case RTC_NONE:
|
|
|
|
default:
|
2018-05-07 17:28:27 +08:00
|
|
|
sec = mktime64(2000, 1, 1, 0, 0, 0);
|
2009-08-14 15:47:31 +02:00
|
|
|
break;
|
2007-10-11 23:46:08 +01:00
|
|
|
}
|
2009-08-14 15:47:31 +02:00
|
|
|
ts->tv_sec = sec;
|
2009-09-23 13:35:09 -07:00
|
|
|
ts->tv_nsec = 0;
|
2007-10-11 23:46:08 +01:00
|
|
|
}
|
|
|
|
|
2018-05-07 17:28:28 +08:00
|
|
|
int update_persistent_clock64(struct timespec64 now)
|
2007-10-11 23:46:08 +01:00
|
|
|
{
|
2018-05-07 17:28:28 +08:00
|
|
|
time64_t sec = now.tv_sec;
|
|
|
|
|
2007-10-11 23:46:08 +01:00
|
|
|
switch (swarm_rtc_type) {
|
|
|
|
case RTC_XICOR:
|
|
|
|
return xicor_set_time(sec);
|
|
|
|
|
2010-11-02 19:38:53 +00:00
|
|
|
case RTC_M41T81:
|
2007-10-11 23:46:08 +01:00
|
|
|
return m41t81_set_time(sec);
|
|
|
|
|
|
|
|
case RTC_NONE:
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-09 23:18:42 +02:00
|
|
|
#ifdef CONFIG_VGA_CONSOLE
|
|
|
|
static struct screen_info vgacon_screen_info = {
|
|
|
|
.orig_video_page = 52,
|
|
|
|
.orig_video_mode = 3,
|
|
|
|
.orig_video_cols = 80,
|
|
|
|
.flags = 12,
|
|
|
|
.orig_video_ega_bx = 3,
|
|
|
|
.orig_video_lines = 25,
|
|
|
|
.orig_video_isVGA = 0x22,
|
|
|
|
.orig_video_points = 16,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2006-06-18 01:32:22 +01:00
|
|
|
void __init plat_mem_setup(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2023-03-15 14:55:09 +01:00
|
|
|
#ifdef CONFIG_SIBYTE_BCM1x80
|
2005-10-19 23:56:38 -07:00
|
|
|
bcm1480_setup();
|
|
|
|
#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
|
2005-04-16 15:20:36 -07:00
|
|
|
sb1250_setup();
|
2005-10-19 23:56:38 -07:00
|
|
|
#else
|
2006-11-30 13:45:32 +00:00
|
|
|
#error invalid SiByte board configuration
|
2005-10-19 23:56:38 -07:00
|
|
|
#endif
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2021-11-05 10:30:47 -07:00
|
|
|
mips_set_be_handler(swarm_be_handler);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-10-11 23:46:08 +01:00
|
|
|
if (xicor_probe())
|
|
|
|
swarm_rtc_type = RTC_XICOR;
|
|
|
|
if (m41t81_probe())
|
2010-11-02 19:38:53 +00:00
|
|
|
swarm_rtc_type = RTC_M41T81;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2023-10-09 23:18:38 +02:00
|
|
|
#ifdef CONFIG_VGA_CONSOLE
|
2023-10-09 23:18:42 +02:00
|
|
|
vgacon_register_screen(&vgacon_screen_info);
|
2005-04-16 15:20:36 -07:00
|
|
|
/* XXXKW for CFE, get lines/cols from environment */
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef LEDS_PHYS
|
|
|
|
|
|
|
|
void setleds(char *str)
|
|
|
|
{
|
2007-03-24 14:26:13 +00:00
|
|
|
void *reg;
|
2005-04-16 15:20:36 -07:00
|
|
|
int i;
|
2007-03-24 14:26:13 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
for (i = 0; i < 4; i++) {
|
2007-03-24 14:26:13 +00:00
|
|
|
reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);
|
|
|
|
|
|
|
|
if (!str[i])
|
|
|
|
writeb(' ', reg);
|
|
|
|
else
|
|
|
|
writeb(str[i], reg);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
2007-03-24 14:26:13 +00:00
|
|
|
|
|
|
|
#endif /* LEDS_PHYS */
|