Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * BRIEF MODULE DESCRIPTION
0004  *  MyCable XXS1500 board support
0005  *
0006  * Copyright 2003, 2008 MontaVista Software Inc.
0007  * Author: MontaVista Software, Inc. <source@mvista.com>
0008  */
0009 
0010 #include <linux/kernel.h>
0011 #include <linux/init.h>
0012 #include <linux/interrupt.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/gpio.h>
0015 #include <linux/delay.h>
0016 #include <linux/pm.h>
0017 #include <asm/bootinfo.h>
0018 #include <asm/reboot.h>
0019 #include <asm/setup.h>
0020 #include <asm/mach-au1x00/au1000.h>
0021 #include <asm/mach-au1x00/gpio-au1000.h>
0022 #include <prom.h>
0023 
0024 const char *get_system_type(void)
0025 {
0026     return "XXS1500";
0027 }
0028 
0029 void prom_putchar(char c)
0030 {
0031     alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
0032 }
0033 
0034 static void xxs1500_reset(char *c)
0035 {
0036     /* Jump to the reset vector */
0037     __asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000));
0038 }
0039 
0040 static void xxs1500_power_off(void)
0041 {
0042     while (1)
0043         asm volatile (
0044         "   .set    mips32                  \n"
0045         "   wait                        \n"
0046         "   .set    mips0                   \n");
0047 }
0048 
0049 void __init board_setup(void)
0050 {
0051     u32 pin_func;
0052 
0053     pm_power_off = xxs1500_power_off;
0054     _machine_halt = xxs1500_power_off;
0055     _machine_restart = xxs1500_reset;
0056 
0057     alchemy_gpio1_input_enable();
0058     alchemy_gpio2_enable();
0059 
0060     /* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
0061     pin_func  = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3;
0062     pin_func |= SYS_PF_UR3;
0063     alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC);
0064 
0065     /* Enable UART */
0066     alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
0067     /* Enable DTR (MCR bit 0) = USB power up */
0068     __raw_writel(1, (void __iomem *)KSEG1ADDR(AU1000_UART3_PHYS_ADDR + 0x18));
0069     wmb();
0070 }
0071 
0072 /******************************************************************************/
0073 
0074 static struct resource xxs1500_pcmcia_res[] = {
0075     {
0076         .name   = "pcmcia-io",
0077         .flags  = IORESOURCE_MEM,
0078         .start  = AU1000_PCMCIA_IO_PHYS_ADDR,
0079         .end    = AU1000_PCMCIA_IO_PHYS_ADDR + 0x000400000 - 1,
0080     },
0081     {
0082         .name   = "pcmcia-attr",
0083         .flags  = IORESOURCE_MEM,
0084         .start  = AU1000_PCMCIA_ATTR_PHYS_ADDR,
0085         .end    = AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
0086     },
0087     {
0088         .name   = "pcmcia-mem",
0089         .flags  = IORESOURCE_MEM,
0090         .start  = AU1000_PCMCIA_MEM_PHYS_ADDR,
0091         .end    = AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
0092     },
0093 };
0094 
0095 static struct platform_device xxs1500_pcmcia_dev = {
0096     .name       = "xxs1500_pcmcia",
0097     .id     = -1,
0098     .num_resources  = ARRAY_SIZE(xxs1500_pcmcia_res),
0099     .resource   = xxs1500_pcmcia_res,
0100 };
0101 
0102 static struct platform_device *xxs1500_devs[] __initdata = {
0103     &xxs1500_pcmcia_dev,
0104 };
0105 
0106 static int __init xxs1500_dev_init(void)
0107 {
0108     irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_HIGH);
0109     irq_set_irq_type(AU1500_GPIO201_INT, IRQ_TYPE_LEVEL_LOW);
0110     irq_set_irq_type(AU1500_GPIO202_INT, IRQ_TYPE_LEVEL_LOW);
0111     irq_set_irq_type(AU1500_GPIO203_INT, IRQ_TYPE_LEVEL_LOW);
0112     irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
0113     irq_set_irq_type(AU1500_GPIO207_INT, IRQ_TYPE_LEVEL_LOW);
0114 
0115     irq_set_irq_type(AU1500_GPIO0_INT, IRQ_TYPE_LEVEL_LOW);
0116     irq_set_irq_type(AU1500_GPIO1_INT, IRQ_TYPE_LEVEL_LOW);
0117     irq_set_irq_type(AU1500_GPIO2_INT, IRQ_TYPE_LEVEL_LOW);
0118     irq_set_irq_type(AU1500_GPIO3_INT, IRQ_TYPE_LEVEL_LOW);
0119     irq_set_irq_type(AU1500_GPIO4_INT, IRQ_TYPE_LEVEL_LOW); /* CF irq */
0120     irq_set_irq_type(AU1500_GPIO5_INT, IRQ_TYPE_LEVEL_LOW);
0121 
0122     return platform_add_devices(xxs1500_devs,
0123                     ARRAY_SIZE(xxs1500_devs));
0124 }
0125 device_initcall(xxs1500_dev_init);