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