码迷,mamicode.com
首页 > 其他好文 > 详细

at91sam9260ek的板级、irq初始化-小试牛刀

时间:2015-06-09 17:30:04      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:at91sam9260ek   linux   

话不多说,先上代码。

//code path:arch/arm/mach-at91/board-sam9260ek.c
MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
	/* Maintainer: Atmel */
	.phys_io	= AT91_BASE_SYS,
	.io_pg_offst	= (AT91_VA_BASE_SYS >> 18) & 0xfffc,
	.boot_params	= AT91_SDRAM_BASE + 0x100,
	.timer		= &at91sam926x_timer,
	.map_io		= ek_map_io,//初始化时钟和7个usart
	.init_irq	= ek_init_irq,<span style="white-space:pre">	</span>//macro for interrput definition 各个中断号的优先级定义
	.init_machine	= ek_board_init, //including USB PCI NAND Serial.etc initialization.各个外设初始化
MACHINE_END

该结构体的定义,在arch.h定义

#define MACHINE_START(_type,_name)			static const struct machine_desc __mach_desc_##_type	 __used							 __attribute__((__section__(".arch.info.init"))) = {		.nr		= MACH_TYPE_##_type,			.name		= _name,

#define MACHINE_END				};

首先,分析板级初始化的具体步骤:

//platform device register
static void __init ek_board_init(void)
{
	/* Serial */
	at91_add_device_serial(); //9260平台串口设备初始化注册platform device register,还有设备驱动注册driver register,具体在atmel_serial.c
	/* USB Host */
	at91_add_device_usbh(&ek_usbh_data);//
	/* USB Device */
	at91_add_device_udc(&ek_udc_data);//
	/* SPI */
	//at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
	/* NAND */
	ek_add_device_nand();//nand初始化,定义nand的分区状态,位宽,以及定义nand驱动连接的建立时间、维持时间等,设置nand的总线片选地址范围信息
	/* Ethernet */
	at91_add_device_eth(&ek_macb_data);//以太网驱动,设置各个外设管脚功能,具体见下
	/* MMC */
	//at91_add_device_mmc(0, &ek_mmc_data);
	/* I2C */
	//at91_add_device_i2c(NULL, 0);
	/* Compact Flash */
	//at91_add_device_cf(&ek_cf_data);
	/* SSC (to AT73C213) */
	//at73c213_set_clk(&at73c213_data);
	//at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
	/* LEDs */
	//at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
	/* Push Buttons */
	//ek_add_device_buttons();
	/* shutdown controller, wakeup button (5 msec low) */
	at91_sys_write(AT91_SHDW_MR, 0);//给shutdown模式寄存器写0,shutdown主要是用在待机唤醒等需求
}
//Ethernet的初始化
void __init at91_add_device_eth(struct at91_eth_data *data)
{
	if (!data)
		return;

	if (data->phy_irq_pin) {
		at91_set_gpio_input(data->phy_irq_pin, 0);
		at91_set_deglitch(data->phy_irq_pin, 1);
	}

	/* Pins used for MII and RMII */
	at91_set_A_periph(AT91_PIN_PA19, 0);	/* ETXCK_EREFCK */
	at91_set_A_periph(AT91_PIN_PA17, 0);	/* ERXDV */
	at91_set_A_periph(AT91_PIN_PA14, 0);	/* ERX0 */
	at91_set_A_periph(AT91_PIN_PA15, 0);	/* ERX1 */
	at91_set_A_periph(AT91_PIN_PA18, 0);	/* ERXER */
	at91_set_A_periph(AT91_PIN_PA16, 0);	/* ETXEN */
	at91_set_A_periph(AT91_PIN_PA12, 0);	/* ETX0 */
	at91_set_A_periph(AT91_PIN_PA13, 0);	/* ETX1 */
	at91_set_A_periph(AT91_PIN_PA21, 0);	/* EMDIO */
	at91_set_A_periph(AT91_PIN_PA20, 0);	/* EMDC */

	if (!data->is_rmii) {
		at91_set_B_periph(AT91_PIN_PA28, 0);	/* ECRS */
		at91_set_B_periph(AT91_PIN_PA29, 0);	/* ECOL */
		at91_set_B_periph(AT91_PIN_PA25, 0);	/* ERX2 */
		at91_set_B_periph(AT91_PIN_PA26, 0);	/* ERX3 */
		at91_set_B_periph(AT91_PIN_PA27, 0);	/* ERXCK */
		at91_set_B_periph(AT91_PIN_PA23, 0);	/* ETX2 */
		at91_set_B_periph(AT91_PIN_PA24, 0);	/* ETX3 */
		at91_set_B_periph(AT91_PIN_PA22, 0);	/* ETXER */
	}

	eth_data = *data;
	platform_device_register(&at91sam9260_eth_device); //设备注册最后都会调用此函数
}





at91sam9260ek的板级、irq初始化-小试牛刀

标签:at91sam9260ek   linux   

原文地址:http://blog.csdn.net/linglongqiongge/article/details/46426805

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!