scb9328.c

来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 198 行

C
198
字号
/* * linux/arch/arm/mach-imx/scb9328.c * * Copyright (c) 2004 Sascha Hauer <saschahauer@web.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */#include <linux/device.h>#include <linux/init.h>#include <asm/system.h>#include <asm/hardware.h>#include <asm/irq.h>#include <asm/pgtable.h>#include <asm/page.h>#include <asm/mach/map.h>#include <asm/mach-types.h>#include <asm/mach/arch.h>#include <linux/interrupt.h>#include "generic.h"#include <asm/serial.h>#define TYPE_NONE     0#define TYPE_EVK9328  1#define TYPE_EVK9328L 2static int eval_board_type = TYPE_NONE;int scb9328_eval_board(void){	return eval_board_type;}static u8 imx_led_shadow = 0;/* On the evk9328l eval board we have 4 leds and 4 buttons connected * PB21 - PB24 -> led0 - led4 * PB25 - PB27 -> Ta0 - Ta3 * PA15        -> TA4 */void scb9328_ledon(int x){	switch(scb9328_eval_board()) {	case TYPE_EVK9328:		imx_led_shadow |= (x);		*((volatile u8 *)(IMX_CS3_VIRT)) = imx_led_shadow;		break;	case TYPE_EVK9328L:		DR(1) |= (x<<21);		break;	default:		break;	}}void scb9328_ledoff(int x){	switch(scb9328_eval_board()) {	case TYPE_EVK9328:		imx_led_shadow &= ~(x);		*((volatile u8 *)(IMX_CS3_VIRT)) = imx_led_shadow;		break;	case TYPE_EVK9328L:		DR(1) &= ~(x<<21);		break;	default:		break;	}}int scb9328_get_buttons(void){	u8 buttons = 0;	switch(scb9328_eval_board()) {	case TYPE_EVK9328:		buttons =  *((volatile u8 *)(IMX_CS3_VIRT));		printk("%d evk9328", buttons);		break;	case TYPE_EVK9328L:		buttons  = (SSR(1) >> 25) & 0x7;      /* bits 0-2 */		buttons |= ((SSR(0) >> 15) & 1) << 3; /* bit 3 */		buttons  = ~buttons & 0xf;            /* buttons are inverted */		printk("%d evk9328l", buttons);		break;	default:		break;	}	return buttons;}void evk9328_init_leds(void){	if( scb9328_eval_board() == TYPE_EVK9328L ) {		GIUS(1) |= (0xf << 21);		DDIR(1) |= (0xf << 21);		OCR2(1) |= (0xff) << ((21 - 16)*2);		scb9328_ledoff(0xf);		GIUS(1) |= (0x7 << 25);		DDIR(1) &= ~(0x7 << 25);		ICONFA2(1) &= ~(0x3f << 18);		GIUS(0) |= (1<<15);		DDIR(0) &= ~(1<<15);		ICONFA2(0) &= ~(0x3);	}}EXPORT_SYMBOL(scb9328_ledon);EXPORT_SYMBOL(scb9328_ledoff);EXPORT_SYMBOL(scb9328_get_buttons);static struct resource dm9000x_resources[] = {	[0] = {		.start	= SCB9328_ETH_VIRT,		.end	= (SCB9328_ETH_VIRT + 4),		.flags	= IORESOURCE_MEM,	},	[1] = {		.start	= (SCB9328_ETH_IRQ),		.end	= (SCB9328_ETH_IRQ),		.flags	= IORESOURCE_IRQ,	},};static struct platform_device dm9000x_device = {	.name		= "dmfe",	.id		= 0,	.num_resources	= ARRAY_SIZE(dm9000x_resources),	.resource	= dm9000x_resources,};static struct platform_device *devices[] __initdata = {	&dm9000x_device,};static int __init scb9328_init(void){	evk9328_init_leds();	UFCR(IMX_UART1_BASE) = 0xa81;	UFCR(IMX_UART2_BASE) = 0xa81;	return platform_add_devices(devices, ARRAY_SIZE(devices));}subsys_initcall(scb9328_init);static int __init scb9328_set_board_type(char *str){	if(strncmp( str+1, "evk9328", 8 ) == 0) {		printk("evk9328 eval board found\n");		eval_board_type = TYPE_EVK9328;	}	if(strncmp( str+1, "evk9328l", 8 ) == 0) {		printk("evk9328l eval board found\n");		eval_board_type = TYPE_EVK9328L;	}	return 0;}__setup("eval_board",scb9328_set_board_type);static struct map_desc scb9328_io_desc[] __initdata = {	/* virtual     physical    length      type */	{IMX_CS0_VIRT, IMX_CS0_PHYS, IMX_CS0_SIZE, MT_DEVICE},	{IMX_CS1_VIRT, IMX_CS1_PHYS, IMX_CS1_SIZE, MT_DEVICE},	{IMX_CS2_VIRT, IMX_CS2_PHYS, IMX_CS2_SIZE, MT_DEVICE},	{IMX_CS3_VIRT, IMX_CS3_PHYS, IMX_CS3_SIZE, MT_DEVICE},	{IMX_CS5_VIRT, IMX_CS5_PHYS, IMX_CS5_SIZE, MT_DEVICE},};static void __init scb9328_init_irq(void){	imx_init_irq();	set_irq_type(SCB9328_UART1_IRQ,__IRQT_LOWLVL);}void __initscb9328_map_io(void){	imx_map_io();	iotable_init(scb9328_io_desc, ARRAY_SIZE(scb9328_io_desc));}MACHINE_START(SCB9328, "Synertronixx scb9328")    MAINTAINER("Sascha Hauer")    BOOT_MEM(0x08000000, 0x00200000, 0xe0200000)    BOOT_PARAMS(0x08000100)    MAPIO(scb9328_map_io)    INITIRQ(scb9328_init_irq)    INITTIME(imx_init_time)MACHINE_END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?