18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * BRIEF MODULE DESCRIPTION
48c2ecf20Sopenharmony_ci *	MyCable XXS1500 board support
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright 2003, 2008 MontaVista Software Inc.
78c2ecf20Sopenharmony_ci * Author: MontaVista Software, Inc. <source@mvista.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/kernel.h>
118c2ecf20Sopenharmony_ci#include <linux/init.h>
128c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
138c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
148c2ecf20Sopenharmony_ci#include <linux/gpio.h>
158c2ecf20Sopenharmony_ci#include <linux/delay.h>
168c2ecf20Sopenharmony_ci#include <linux/pm.h>
178c2ecf20Sopenharmony_ci#include <asm/bootinfo.h>
188c2ecf20Sopenharmony_ci#include <asm/reboot.h>
198c2ecf20Sopenharmony_ci#include <asm/setup.h>
208c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/au1000.h>
218c2ecf20Sopenharmony_ci#include <asm/mach-au1x00/gpio-au1000.h>
228c2ecf20Sopenharmony_ci#include <prom.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciconst char *get_system_type(void)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	return "XXS1500";
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_civoid prom_putchar(char c)
308c2ecf20Sopenharmony_ci{
318c2ecf20Sopenharmony_ci	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
328c2ecf20Sopenharmony_ci}
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_cistatic void xxs1500_reset(char *c)
358c2ecf20Sopenharmony_ci{
368c2ecf20Sopenharmony_ci	/* Jump to the reset vector */
378c2ecf20Sopenharmony_ci	__asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000));
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistatic void xxs1500_power_off(void)
418c2ecf20Sopenharmony_ci{
428c2ecf20Sopenharmony_ci	while (1)
438c2ecf20Sopenharmony_ci		asm volatile (
448c2ecf20Sopenharmony_ci		"	.set	mips32					\n"
458c2ecf20Sopenharmony_ci		"	wait						\n"
468c2ecf20Sopenharmony_ci		"	.set	mips0					\n");
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_civoid __init board_setup(void)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	u32 pin_func;
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	pm_power_off = xxs1500_power_off;
548c2ecf20Sopenharmony_ci	_machine_halt = xxs1500_power_off;
558c2ecf20Sopenharmony_ci	_machine_restart = xxs1500_reset;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	alchemy_gpio1_input_enable();
588c2ecf20Sopenharmony_ci	alchemy_gpio2_enable();
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	/* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
618c2ecf20Sopenharmony_ci	pin_func  = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3;
628c2ecf20Sopenharmony_ci	pin_func |= SYS_PF_UR3;
638c2ecf20Sopenharmony_ci	alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC);
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	/* Enable UART */
668c2ecf20Sopenharmony_ci	alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
678c2ecf20Sopenharmony_ci	/* Enable DTR (MCR bit 0) = USB power up */
688c2ecf20Sopenharmony_ci	__raw_writel(1, (void __iomem *)KSEG1ADDR(AU1000_UART3_PHYS_ADDR + 0x18));
698c2ecf20Sopenharmony_ci	wmb();
708c2ecf20Sopenharmony_ci}
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/******************************************************************************/
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic struct resource xxs1500_pcmcia_res[] = {
758c2ecf20Sopenharmony_ci	{
768c2ecf20Sopenharmony_ci		.name	= "pcmcia-io",
778c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
788c2ecf20Sopenharmony_ci		.start	= AU1000_PCMCIA_IO_PHYS_ADDR,
798c2ecf20Sopenharmony_ci		.end	= AU1000_PCMCIA_IO_PHYS_ADDR + 0x000400000 - 1,
808c2ecf20Sopenharmony_ci	},
818c2ecf20Sopenharmony_ci	{
828c2ecf20Sopenharmony_ci		.name	= "pcmcia-attr",
838c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
848c2ecf20Sopenharmony_ci		.start	= AU1000_PCMCIA_ATTR_PHYS_ADDR,
858c2ecf20Sopenharmony_ci		.end	= AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
868c2ecf20Sopenharmony_ci	},
878c2ecf20Sopenharmony_ci	{
888c2ecf20Sopenharmony_ci		.name	= "pcmcia-mem",
898c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
908c2ecf20Sopenharmony_ci		.start	= AU1000_PCMCIA_MEM_PHYS_ADDR,
918c2ecf20Sopenharmony_ci		.end	= AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
928c2ecf20Sopenharmony_ci	},
938c2ecf20Sopenharmony_ci};
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cistatic struct platform_device xxs1500_pcmcia_dev = {
968c2ecf20Sopenharmony_ci	.name		= "xxs1500_pcmcia",
978c2ecf20Sopenharmony_ci	.id		= -1,
988c2ecf20Sopenharmony_ci	.num_resources	= ARRAY_SIZE(xxs1500_pcmcia_res),
998c2ecf20Sopenharmony_ci	.resource	= xxs1500_pcmcia_res,
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cistatic struct platform_device *xxs1500_devs[] __initdata = {
1038c2ecf20Sopenharmony_ci	&xxs1500_pcmcia_dev,
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cistatic int __init xxs1500_dev_init(void)
1078c2ecf20Sopenharmony_ci{
1088c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_HIGH);
1098c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO201_INT, IRQ_TYPE_LEVEL_LOW);
1108c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO202_INT, IRQ_TYPE_LEVEL_LOW);
1118c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO203_INT, IRQ_TYPE_LEVEL_LOW);
1128c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
1138c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO207_INT, IRQ_TYPE_LEVEL_LOW);
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO0_INT, IRQ_TYPE_LEVEL_LOW);
1168c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO1_INT, IRQ_TYPE_LEVEL_LOW);
1178c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO2_INT, IRQ_TYPE_LEVEL_LOW);
1188c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO3_INT, IRQ_TYPE_LEVEL_LOW);
1198c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO4_INT, IRQ_TYPE_LEVEL_LOW); /* CF irq */
1208c2ecf20Sopenharmony_ci	irq_set_irq_type(AU1500_GPIO5_INT, IRQ_TYPE_LEVEL_LOW);
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	return platform_add_devices(xxs1500_devs,
1238c2ecf20Sopenharmony_ci				    ARRAY_SIZE(xxs1500_devs));
1248c2ecf20Sopenharmony_ci}
1258c2ecf20Sopenharmony_cidevice_initcall(xxs1500_dev_init);
126