📄 at91sam9rl_devices.c
字号:
/* * Copyright (C) 2007 Atmel Corporation * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. */#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/at91sam9rl.h>#include <asm/arch/at91sam9rl_matrix.h>#include <asm/arch/at91sam926x_mc.h>#include "generic.h"/* -------------------------------------------------------------------- * 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 = AT91SAM9RL_BASE_MCI, .end = AT91SAM9RL_BASE_MCI + SZ_16K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = AT91SAM9RL_ID_MCI, .end = AT91SAM9RL_ID_MCI, .flags = IORESOURCE_IRQ, },};static struct platform_device at91sam9rl_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_A_periph(AT91_PIN_PA2, 0); /* CMD */ at91_set_A_periph(AT91_PIN_PA1, 1); /* DAT0, maybe DAT1..DAT3 */ at91_set_A_periph(AT91_PIN_PA0, 1); if (data->wire4) { at91_set_A_periph(AT91_PIN_PA3, 1); at91_set_A_periph(AT91_PIN_PA4, 1); at91_set_A_periph(AT91_PIN_PA5, 1); } mmc_data = *data; platform_device_register(&at91sam9rl_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; if (!data) return; csa = at91_sys_read(AT91_MATRIX_EBICSA); at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); /* 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)); at91_sys_write(AT91_SMC_MODE(3), AT91_SMC_DBW_8 | 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_PB4, 0); /* NANDOE */ at91_set_A_periph(AT91_PIN_PB5, 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_PA23, .sda_is_open_drain = 1, .scl_pin = AT91_PIN_PA24, .scl_is_open_drain = 1, .udelay = 2, /* ~100 kHz */};static struct platform_device at91sam9rl_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_PA23, 1); /* TWD (SDA) */ at91_set_multi_drive(AT91_PIN_PA23, 1); at91_set_GPIO_periph(AT91_PIN_PA24, 1); /* TWCK (SCL) */ at91_set_multi_drive(AT91_PIN_PA24, 1); i2c_register_board_info(0, devices, nr_devices); platform_device_register(&at91sam9rl_twi_device);}#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)static struct resource twi_resources[] = { [0] = { .start = AT91SAM9RL_BASE_TWI0, .end = AT91SAM9RL_BASE_TWI0 + SZ_16K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = AT91SAM9RL_ID_TWI0, .end = AT91SAM9RL_ID_TWI0, .flags = IORESOURCE_IRQ, },};static struct platform_device at91sam9rl_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_PA23, 0); /* TWD */ at91_set_multi_drive(AT91_PIN_PA23, 1); at91_set_A_periph(AT91_PIN_PA24, 0); /* TWCK */ at91_set_multi_drive(AT91_PIN_PA24, 1); i2c_register_board_info(0, devices, nr_devices); platform_device_register(&at91sam9rl_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 spi_resources[] = { [0] = { .start = AT91SAM9RL_BASE_SPI, .end = AT91SAM9RL_BASE_SPI + SZ_16K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = AT91SAM9RL_ID_SPI, .end = AT91SAM9RL_ID_SPI, .flags = IORESOURCE_IRQ, },};static struct platform_device at91sam9rl_spi_device = { .name = "atmel_spi", .id = 0, .dev = { .dma_mask = &spi_dmamask, .coherent_dma_mask = 0xffffffff, }, .resource = spi_resources, .num_resources = ARRAY_SIZE(spi_resources),};static const unsigned spi_standard_cs[4] = { AT91_PIN_PA28, AT91_PIN_PB7, AT91_PIN_PD8, AT91_PIN_PD9 };void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices){ int i; unsigned long cs_pin; at91_set_A_periph(AT91_PIN_PA25, 0); /* MISO */ at91_set_A_periph(AT91_PIN_PA26, 0); /* MOSI */ at91_set_A_periph(AT91_PIN_PA27, 0); /* SPCK */ /* Enable SPI chip-selects */ for (i = 0; i < nr_devices; i++) { if (devices[i].controller_data) cs_pin = (unsigned long) devices[i].controller_data; else cs_pin = spi_standard_cs[devices[i].chip_select]; /* enable chip-select pin */ at91_set_gpio_output(cs_pin, 1); /* pass chip-select pin to driver */ devices[i].controller_data = (void *) cs_pin; } spi_register_board_info(devices, nr_devices); platform_device_register(&at91sam9rl_spi_device);}#elsevoid __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}#endif/* -------------------------------------------------------------------- * LCD Controller * -------------------------------------------------------------------- */#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)static u64 lcdc_dmamask = 0xffffffffUL;static struct atmel_lcdfb_info lcdc_data;static struct resource lcdc_resources[] = { [0] = { .start = AT91SAM9RL_LCDC_BASE, .end = AT91SAM9RL_LCDC_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = AT91SAM9RL_ID_LCDC, .end = AT91SAM9RL_ID_LCDC, .flags = IORESOURCE_IRQ, },#if defined(CONFIG_FB_INTSRAM) [2] = { .start = AT91SAM9RL_SRAM_BASE, .end = AT91SAM9RL_SRAM_BASE + AT91SAM9RL_SRAM_SIZE - 1, .flags = IORESOURCE_MEM,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -