⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 at91sam9261_devices.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * arch/arm/mach-at91/at91sam9261_devices.c * *  Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> *  Copyright (C) 2005 David Brownell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */#include <asm/mach/arch.h>#include <asm/mach/map.h>#include <linux/platform_device.h>#include <linux/i2c-gpio.h>#include <linux/fb.h>#include <video/atmel_lcdc.h>#include <asm/arch/board.h>#include <asm/arch/gpio.h>#include <asm/arch/at91sam9261.h>#include <asm/arch/at91sam9261_matrix.h>#include <asm/arch/at91sam926x_mc.h>#include "generic.h"/* -------------------------------------------------------------------- *  USB Host * -------------------------------------------------------------------- */#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)static u64 ohci_dmamask = 0xffffffffUL;static struct at91_usbh_data usbh_data;static struct resource usbh_resources[] = {	[0] = {		.start	= AT91SAM9261_UHP_BASE,		.end	= AT91SAM9261_UHP_BASE + SZ_1M - 1,		.flags	= IORESOURCE_MEM,	},	[1] = {		.start	= AT91SAM9261_ID_UHP,		.end	= AT91SAM9261_ID_UHP,		.flags	= IORESOURCE_IRQ,	},};static struct platform_device at91sam9261_usbh_device = {	.name		= "at91_ohci",	.id		= -1,	.dev		= {				.dma_mask		= &ohci_dmamask,				.coherent_dma_mask	= 0xffffffff,				.platform_data		= &usbh_data,	},	.resource	= usbh_resources,	.num_resources	= ARRAY_SIZE(usbh_resources),};void __init at91_add_device_usbh(struct at91_usbh_data *data){	if (!data)		return;	usbh_data = *data;	platform_device_register(&at91sam9261_usbh_device);}#elsevoid __init at91_add_device_usbh(struct at91_usbh_data *data) {}#endif/* -------------------------------------------------------------------- *  USB Device (Gadget) * -------------------------------------------------------------------- */#ifdef CONFIG_USB_GADGET_AT91static struct at91_udc_data udc_data;static struct resource udc_resources[] = {	[0] = {		.start	= AT91SAM9261_BASE_UDP,		.end	= AT91SAM9261_BASE_UDP + SZ_16K - 1,		.flags	= IORESOURCE_MEM,	},	[1] = {		.start	= AT91SAM9261_ID_UDP,		.end	= AT91SAM9261_ID_UDP,		.flags	= IORESOURCE_IRQ,	},};static struct platform_device at91sam9261_udc_device = {	.name		= "at91_udc",	.id		= -1,	.dev		= {				.platform_data		= &udc_data,	},	.resource	= udc_resources,	.num_resources	= ARRAY_SIZE(udc_resources),};void __init at91_add_device_udc(struct at91_udc_data *data){	unsigned long x;	if (!data)		return;	if (data->vbus_pin) {		at91_set_gpio_input(data->vbus_pin, 0);		at91_set_deglitch(data->vbus_pin, 1);	}	/* Pullup pin is handled internally */	x = at91_sys_read(AT91_MATRIX_USBPUCR);	at91_sys_write(AT91_MATRIX_USBPUCR, x | AT91_MATRIX_USBPUCR_PUON);	udc_data = *data;	platform_device_register(&at91sam9261_udc_device);}#elsevoid __init at91_add_device_udc(struct at91_udc_data *data) {}#endif/* -------------------------------------------------------------------- *  MMC / SD * -------------------------------------------------------------------- */#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)static u64 mmc_dmamask = 0xffffffffUL;static struct at91_mmc_data mmc_data;static struct resource mmc_resources[] = {	[0] = {		.start	= AT91SAM9261_BASE_MCI,		.end	= AT91SAM9261_BASE_MCI + SZ_16K - 1,		.flags	= IORESOURCE_MEM,	},	[1] = {		.start	= AT91SAM9261_ID_MCI,		.end	= AT91SAM9261_ID_MCI,		.flags	= IORESOURCE_IRQ,	},};static struct platform_device at91sam9261_mmc_device = {	.name		= "at91_mci",	.id		= -1,	.dev		= {				.dma_mask		= &mmc_dmamask,				.coherent_dma_mask	= 0xffffffff,				.platform_data		= &mmc_data,	},	.resource	= mmc_resources,	.num_resources	= ARRAY_SIZE(mmc_resources),};void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data){	if (!data)		return;	/* input/irq */	if (data->det_pin) {		at91_set_gpio_input(data->det_pin, 1);		at91_set_deglitch(data->det_pin, 1);	}	if (data->wp_pin)		at91_set_gpio_input(data->wp_pin, 1);	if (data->vcc_pin)		at91_set_gpio_output(data->vcc_pin, 0);	/* CLK */	at91_set_B_periph(AT91_PIN_PA2, 0);	/* CMD */	at91_set_B_periph(AT91_PIN_PA1, 1);	/* DAT0, maybe DAT1..DAT3 */	at91_set_B_periph(AT91_PIN_PA0, 1);	if (data->wire4) {		at91_set_B_periph(AT91_PIN_PA4, 1);		at91_set_B_periph(AT91_PIN_PA5, 1);		at91_set_B_periph(AT91_PIN_PA6, 1);	}	mmc_data = *data;	platform_device_register(&at91sam9261_mmc_device);}#elsevoid __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}#endif/* -------------------------------------------------------------------- *  NAND / SmartMedia * -------------------------------------------------------------------- */#if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)static struct at91_nand_data nand_data;#define NAND_BASE	AT91_CHIPSELECT_3static struct resource nand_resources[] = {	{		.start	= NAND_BASE,		.end	= NAND_BASE + SZ_256M - 1,		.flags	= IORESOURCE_MEM,	}};static struct platform_device at91_nand_device = {	.name		= "at91_nand",	.id		= -1,	.dev		= {				.platform_data	= &nand_data,	},	.resource	= nand_resources,	.num_resources	= ARRAY_SIZE(nand_resources),};void __init at91_add_device_nand(struct at91_nand_data *data){	unsigned long csa, mode;	if (!data)		return;	csa = at91_sys_read(AT91_MATRIX_EBICSA);	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC);	/* set the bus interface characteristics */	at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)			| AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));	at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5)			| AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5));	at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));	if (data->bus_width_16)		mode = AT91_SMC_DBW_16;	else		mode = AT91_SMC_DBW_8;	at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1));	/* enable pin */	if (data->enable_pin)		at91_set_gpio_output(data->enable_pin, 1);	/* ready/busy pin */	if (data->rdy_pin)		at91_set_gpio_input(data->rdy_pin, 1);	/* card detect pin */	if (data->det_pin)		at91_set_gpio_input(data->det_pin, 1);	at91_set_A_periph(AT91_PIN_PC0, 0);		/* NANDOE */	at91_set_A_periph(AT91_PIN_PC1, 0);		/* NANDWE */	nand_data = *data;	platform_device_register(&at91_nand_device);}#elsevoid __init at91_add_device_nand(struct at91_nand_data *data) {}#endif/* -------------------------------------------------------------------- *  TWI (i2c) * -------------------------------------------------------------------- *//* * Prefer the GPIO code since the TWI controller isn't robust * (gets overruns and underruns under load) and can only issue * repeated STARTs in one scenario (the driver doesn't yet handle them). */#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)static struct i2c_gpio_platform_data pdata = {	.sda_pin		= AT91_PIN_PA7,	.sda_is_open_drain	= 1,	.scl_pin		= AT91_PIN_PA8,	.scl_is_open_drain	= 1,	.udelay			= 2,		/* ~100 kHz */};static struct platform_device at91sam9261_twi_device = {	.name			= "i2c-gpio",	.id			= -1,	.dev.platform_data	= &pdata,};void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices){	at91_set_GPIO_periph(AT91_PIN_PA7, 1);		/* TWD (SDA) */	at91_set_multi_drive(AT91_PIN_PA7, 1);	at91_set_GPIO_periph(AT91_PIN_PA8, 1);		/* TWCK (SCL) */	at91_set_multi_drive(AT91_PIN_PA8, 1);	i2c_register_board_info(0, devices, nr_devices);	platform_device_register(&at91sam9261_twi_device);}#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)static struct resource twi_resources[] = {	[0] = {		.start	= AT91SAM9261_BASE_TWI,		.end	= AT91SAM9261_BASE_TWI + SZ_16K - 1,		.flags	= IORESOURCE_MEM,	},	[1] = {		.start	= AT91SAM9261_ID_TWI,		.end	= AT91SAM9261_ID_TWI,		.flags	= IORESOURCE_IRQ,	},};static struct platform_device at91sam9261_twi_device = {	.name		= "at91_i2c",	.id		= -1,	.resource	= twi_resources,	.num_resources	= ARRAY_SIZE(twi_resources),};void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices){	/* pins used for TWI interface */	at91_set_A_periph(AT91_PIN_PA7, 0);		/* TWD */	at91_set_multi_drive(AT91_PIN_PA7, 1);	at91_set_A_periph(AT91_PIN_PA8, 0);		/* TWCK */	at91_set_multi_drive(AT91_PIN_PA8, 1);	i2c_register_board_info(0, devices, nr_devices);	platform_device_register(&at91sam9261_twi_device);}#elsevoid __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}#endif/* -------------------------------------------------------------------- *  SPI * -------------------------------------------------------------------- */#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)static u64 spi_dmamask = 0xffffffffUL;static struct resource spi0_resources[] = {	[0] = {		.start	= AT91SAM9261_BASE_SPI0,		.end	= AT91SAM9261_BASE_SPI0 + SZ_16K - 1,		.flags	= IORESOURCE_MEM,	},	[1] = {		.start	= AT91SAM9261_ID_SPI0,		.end	= AT91SAM9261_ID_SPI0,		.flags	= IORESOURCE_IRQ,	},};static struct platform_device at91sam9261_spi0_device = {	.name		= "atmel_spi",	.id		= 0,	.dev		= {				.dma_mask		= &spi_dmamask,				.coherent_dma_mask	= 0xffffffff,	},	.resource	= spi0_resources,	.num_resources	= ARRAY_SIZE(spi0_resources),};static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };static struct resource spi1_resources[] = {	[0] = {		.start	= AT91SAM9261_BASE_SPI1,		.end	= AT91SAM9261_BASE_SPI1 + SZ_16K - 1,		.flags	= IORESOURCE_MEM,	},	[1] = {

⌨️ 快捷键说明

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