Linux Audio

Check our new training course

Embedded Linux training

Mar 31-Apr 8, 2025
Register
Loading...
v3.5.6
 
  1/*
  2 * BRIEF MODULE DESCRIPTION
  3 *	MyCable XXS1500 board support
  4 *
  5 * Copyright 2003, 2008 MontaVista Software Inc.
  6 * Author: MontaVista Software, Inc. <source@mvista.com>
  7 *
  8 * This program is free software; you can redistribute it and/or modify
  9 * it under the terms of the GNU General Public License as published by
 10 * the Free Software Foundation; either version 2 of the License, or
 11 * (at your option) any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 * GNU General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU General Public License
 19 * along with this program; if not, write to the Free Software
 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 21 */
 22
 23#include <linux/kernel.h>
 24#include <linux/init.h>
 25#include <linux/interrupt.h>
 26#include <linux/platform_device.h>
 27#include <linux/gpio.h>
 28#include <linux/delay.h>
 29#include <linux/pm.h>
 30#include <asm/bootinfo.h>
 31#include <asm/reboot.h>
 
 32#include <asm/mach-au1x00/au1000.h>
 33#include <prom.h>
 34
 35const char *get_system_type(void)
 36{
 37	return "XXS1500";
 38}
 39
 40void __init prom_init(void)
 41{
 42	unsigned char *memsize_str;
 43	unsigned long memsize;
 44
 45	prom_argc = fw_arg0;
 46	prom_argv = (char **)fw_arg1;
 47	prom_envp = (char **)fw_arg2;
 48
 49	prom_init_cmdline();
 50
 51	memsize_str = prom_getenv("memsize");
 52	if (!memsize_str || strict_strtoul(memsize_str, 0, &memsize))
 53		memsize = 0x04000000;
 54
 55	add_memory_region(0, memsize, BOOT_MEM_RAM);
 56}
 57
 58void prom_putchar(unsigned char c)
 59{
 60	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
 61}
 62
 63static void xxs1500_reset(char *c)
 64{
 65	/* Jump to the reset vector */
 66	__asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000));
 67}
 68
 69static void xxs1500_power_off(void)
 70{
 71	while (1)
 72		asm volatile (
 73		"	.set	mips32					\n"
 74		"	wait						\n"
 75		"	.set	mips0					\n");
 76}
 77
 78void __init board_setup(void)
 79{
 80	u32 pin_func;
 81
 82	pm_power_off = xxs1500_power_off;
 83	_machine_halt = xxs1500_power_off;
 84	_machine_restart = xxs1500_reset;
 85
 86	alchemy_gpio1_input_enable();
 87	alchemy_gpio2_enable();
 88
 89	/* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
 90	pin_func  = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3;
 91	pin_func |= SYS_PF_UR3;
 92	au_writel(pin_func, SYS_PINFUNC);
 93
 94	/* Enable UART */
 95	alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
 96	/* Enable DTR (MCR bit 0) = USB power up */
 97	__raw_writel(1, (void __iomem *)KSEG1ADDR(AU1000_UART3_PHYS_ADDR + 0x18));
 98	wmb();
 99}
100
101/******************************************************************************/
102
103static struct resource xxs1500_pcmcia_res[] = {
104	{
105		.name	= "pcmcia-io",
106		.flags	= IORESOURCE_MEM,
107		.start	= AU1000_PCMCIA_IO_PHYS_ADDR,
108		.end	= AU1000_PCMCIA_IO_PHYS_ADDR + 0x000400000 - 1,
109	},
110	{
111		.name	= "pcmcia-attr",
112		.flags	= IORESOURCE_MEM,
113		.start	= AU1000_PCMCIA_ATTR_PHYS_ADDR,
114		.end	= AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
115	},
116	{
117		.name	= "pcmcia-mem",
118		.flags	= IORESOURCE_MEM,
119		.start	= AU1000_PCMCIA_MEM_PHYS_ADDR,
120		.end	= AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
121	},
122};
123
124static struct platform_device xxs1500_pcmcia_dev = {
125	.name		= "xxs1500_pcmcia",
126	.id		= -1,
127	.num_resources	= ARRAY_SIZE(xxs1500_pcmcia_res),
128	.resource	= xxs1500_pcmcia_res,
129};
130
131static struct platform_device *xxs1500_devs[] __initdata = {
132	&xxs1500_pcmcia_dev,
133};
134
135static int __init xxs1500_dev_init(void)
136{
137	irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_HIGH);
138	irq_set_irq_type(AU1500_GPIO201_INT, IRQ_TYPE_LEVEL_LOW);
139	irq_set_irq_type(AU1500_GPIO202_INT, IRQ_TYPE_LEVEL_LOW);
140	irq_set_irq_type(AU1500_GPIO203_INT, IRQ_TYPE_LEVEL_LOW);
141	irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
142	irq_set_irq_type(AU1500_GPIO207_INT, IRQ_TYPE_LEVEL_LOW);
143
144	irq_set_irq_type(AU1500_GPIO0_INT, IRQ_TYPE_LEVEL_LOW);
145	irq_set_irq_type(AU1500_GPIO1_INT, IRQ_TYPE_LEVEL_LOW);
146	irq_set_irq_type(AU1500_GPIO2_INT, IRQ_TYPE_LEVEL_LOW);
147	irq_set_irq_type(AU1500_GPIO3_INT, IRQ_TYPE_LEVEL_LOW);
148	irq_set_irq_type(AU1500_GPIO4_INT, IRQ_TYPE_LEVEL_LOW); /* CF irq */
149	irq_set_irq_type(AU1500_GPIO5_INT, IRQ_TYPE_LEVEL_LOW);
150
151	return platform_add_devices(xxs1500_devs,
152				    ARRAY_SIZE(xxs1500_devs));
153}
154device_initcall(xxs1500_dev_init);
v5.4
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * BRIEF MODULE DESCRIPTION
  4 *	MyCable XXS1500 board support
  5 *
  6 * Copyright 2003, 2008 MontaVista Software Inc.
  7 * Author: MontaVista Software, Inc. <source@mvista.com>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  8 */
  9
 10#include <linux/kernel.h>
 11#include <linux/init.h>
 12#include <linux/interrupt.h>
 13#include <linux/platform_device.h>
 14#include <linux/gpio.h>
 15#include <linux/delay.h>
 16#include <linux/pm.h>
 17#include <asm/bootinfo.h>
 18#include <asm/reboot.h>
 19#include <asm/setup.h>
 20#include <asm/mach-au1x00/au1000.h>
 21#include <prom.h>
 22
 23const char *get_system_type(void)
 24{
 25	return "XXS1500";
 26}
 27
 28void __init prom_init(void)
 29{
 30	unsigned char *memsize_str;
 31	unsigned long memsize;
 32
 33	prom_argc = fw_arg0;
 34	prom_argv = (char **)fw_arg1;
 35	prom_envp = (char **)fw_arg2;
 36
 37	prom_init_cmdline();
 38
 39	memsize_str = prom_getenv("memsize");
 40	if (!memsize_str || kstrtoul(memsize_str, 0, &memsize))
 41		memsize = 0x04000000;
 42
 43	add_memory_region(0, memsize, BOOT_MEM_RAM);
 44}
 45
 46void prom_putchar(char c)
 47{
 48	alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
 49}
 50
 51static void xxs1500_reset(char *c)
 52{
 53	/* Jump to the reset vector */
 54	__asm__ __volatile__("jr\t%0" : : "r"(0xbfc00000));
 55}
 56
 57static void xxs1500_power_off(void)
 58{
 59	while (1)
 60		asm volatile (
 61		"	.set	mips32					\n"
 62		"	wait						\n"
 63		"	.set	mips0					\n");
 64}
 65
 66void __init board_setup(void)
 67{
 68	u32 pin_func;
 69
 70	pm_power_off = xxs1500_power_off;
 71	_machine_halt = xxs1500_power_off;
 72	_machine_restart = xxs1500_reset;
 73
 74	alchemy_gpio1_input_enable();
 75	alchemy_gpio2_enable();
 76
 77	/* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
 78	pin_func  = alchemy_rdsys(AU1000_SYS_PINFUNC) & ~SYS_PF_UR3;
 79	pin_func |= SYS_PF_UR3;
 80	alchemy_wrsys(pin_func, AU1000_SYS_PINFUNC);
 81
 82	/* Enable UART */
 83	alchemy_uart_enable(AU1000_UART3_PHYS_ADDR);
 84	/* Enable DTR (MCR bit 0) = USB power up */
 85	__raw_writel(1, (void __iomem *)KSEG1ADDR(AU1000_UART3_PHYS_ADDR + 0x18));
 86	wmb();
 87}
 88
 89/******************************************************************************/
 90
 91static struct resource xxs1500_pcmcia_res[] = {
 92	{
 93		.name	= "pcmcia-io",
 94		.flags	= IORESOURCE_MEM,
 95		.start	= AU1000_PCMCIA_IO_PHYS_ADDR,
 96		.end	= AU1000_PCMCIA_IO_PHYS_ADDR + 0x000400000 - 1,
 97	},
 98	{
 99		.name	= "pcmcia-attr",
100		.flags	= IORESOURCE_MEM,
101		.start	= AU1000_PCMCIA_ATTR_PHYS_ADDR,
102		.end	= AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
103	},
104	{
105		.name	= "pcmcia-mem",
106		.flags	= IORESOURCE_MEM,
107		.start	= AU1000_PCMCIA_MEM_PHYS_ADDR,
108		.end	= AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
109	},
110};
111
112static struct platform_device xxs1500_pcmcia_dev = {
113	.name		= "xxs1500_pcmcia",
114	.id		= -1,
115	.num_resources	= ARRAY_SIZE(xxs1500_pcmcia_res),
116	.resource	= xxs1500_pcmcia_res,
117};
118
119static struct platform_device *xxs1500_devs[] __initdata = {
120	&xxs1500_pcmcia_dev,
121};
122
123static int __init xxs1500_dev_init(void)
124{
125	irq_set_irq_type(AU1500_GPIO204_INT, IRQ_TYPE_LEVEL_HIGH);
126	irq_set_irq_type(AU1500_GPIO201_INT, IRQ_TYPE_LEVEL_LOW);
127	irq_set_irq_type(AU1500_GPIO202_INT, IRQ_TYPE_LEVEL_LOW);
128	irq_set_irq_type(AU1500_GPIO203_INT, IRQ_TYPE_LEVEL_LOW);
129	irq_set_irq_type(AU1500_GPIO205_INT, IRQ_TYPE_LEVEL_LOW);
130	irq_set_irq_type(AU1500_GPIO207_INT, IRQ_TYPE_LEVEL_LOW);
131
132	irq_set_irq_type(AU1500_GPIO0_INT, IRQ_TYPE_LEVEL_LOW);
133	irq_set_irq_type(AU1500_GPIO1_INT, IRQ_TYPE_LEVEL_LOW);
134	irq_set_irq_type(AU1500_GPIO2_INT, IRQ_TYPE_LEVEL_LOW);
135	irq_set_irq_type(AU1500_GPIO3_INT, IRQ_TYPE_LEVEL_LOW);
136	irq_set_irq_type(AU1500_GPIO4_INT, IRQ_TYPE_LEVEL_LOW); /* CF irq */
137	irq_set_irq_type(AU1500_GPIO5_INT, IRQ_TYPE_LEVEL_LOW);
138
139	return platform_add_devices(xxs1500_devs,
140				    ARRAY_SIZE(xxs1500_devs));
141}
142device_initcall(xxs1500_dev_init);