- UID
- 1029342
- 性别
- 男
|
Davinci DM6446 Linux 内核分析——board-evm.c
*
* linux/arch/arm/mach-davinci/board-evm.c
*
* TI DaVinci EVM board
*
* Copyright (C) 2006 Texas Instruments.
*
*----------------------------------------------------------------------------
*
* This program is free software; you can redistribute it and/ormodify
* it under the terms of the GNU General Public License as publishedby
* the Free Software Foundation; either version 2 of the License,or
* (at your option) any later version.
*
* This program is distributed in the hope that it will beuseful,
* but WITHOUT ANY WARRANTY; without even the implied warrantyof
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Seethe
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General PublicLicense
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------------
*
*/
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/major.h>
#include <linux/root_dev.h>
#include <linux/dma-mapping.h>
#include <linux/mtd/mtd.h>
#include<linux/mtd/partitions.h>
#include <linux/serial.h>
#include <linux/usb_musb.h>
#include <linux/mtd/nand.h>
#include <linux/serial_8250.h>
#include <linux/davinci_mmc.h>
#include <linux/nand_davinci.h>
#include <asm/setup.h>
#include <asm/io.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/flash.h>
#include <asm/arch/irqs.h>
#include <asm/arch/hardware.h>
#include <asm/arch/edma.h>
#include <linux/kgdb.h>
#include <asm/arch/cpu.h>
#include <asm/arch/mux.h>
#include "clock.h"
#define DAVINCI_UART_CLK 27000000 // 串口时钟,与输入的晶振频率相同
static struct plat_serial8250_port serial_platform_data[] = {
{
.membase = (char *)IO_ADDRESS(DAVINCI_UART0_BASE), //串口0寄存器开始处的虚拟地址是IO_ADDRESS(0x01C20000)
.mapbase = (unsigned long)DAVINCI_UART0_BASE, //串口0寄存器开始处的实地址是0x01C20000
.irq = IRQ_UARTINT0, // 串口0的中断号是40
.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
.iotype = UPIO_MEM32,
.regshift = 2,
.uartclk = DAVINCI_UART_CLK, // 串口时钟频率是27MHz
},
{
.flags = 0,
},
};
static struct platform_device serial_device = {
.name = "serial8250", //这个名字很重要,与对应驱动中的机构体device_driver中的.name相同,其被驱动模块用来查找设备
.id = 0, // 实例名后缀为0
.dev = {
.platform_data = serial_platform_data, // 设备的私有数据或资源
},
};
static struct musb_hdrc_platform_data usb_data[] = {
{
#if defined(CONFIG_USB_MUSB_OTG)
.mode = MUSB_OTG, // OTG类型的usb模块,既可以作usb设备也可以作主机usb使用
#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
.mode = MUSB_PERIPHERAL,
#elif defined(CONFIG_USB_MUSB_HOST) // usb设备
.mode = MUSB_HOST, // 主机usb,类似于电脑的usb功能
#endif
.set_vbus = NULL,
.power = 255,
.potpgt = 4,
.multipoint = 1, // 1个收发端口
},
};
static struct resource usb_resources[] = {
{
.start = DAVINCI_USB_OTG_BASE, //USB_OTG寄存器起始处的实地址是0x01C20000
.end = DAVINCI_USB_OTG_BASE + 0x5ff, //USB_OTG寄存器末尾处的实地址是0x01C20000
.flags = IORESOURCE_MEM, // 标识为IO地址资源
},
{
.start = IRQ_USBINT, // USB_OTG中断号是12
.flags = IORESOURCE_IRQ, // 标识为中断资源
},
};
static u64 usb_dmamask = DMA_32BIT_MASK;
static struct platform_device usb_dev = {
.name = "musb_hdrc", // 与对应驱动中的名字相同,用于绑定驱动
.id = -1, // -1表示只有一个实例,无数字后缀
.dev = {
.platform_data = usb_data, // USB的私有数据
.dma_mask = &usb_dmamask, // 32位的dma
.coherent_dma_mask = DMA_32BIT_MASK,
},
.resource = usb_resources, // USB的硬件资源
.num_resources = ARRAY_SIZE(usb_resources),
};
int cpu_type(void)
{
return MACH_TYPE_DAVINCI_EVM;
}
extern void davinci_serial_init(struct platform_device*pdev);
#if defined (CONFIG_MTD_NAND_DAVINCI) ||defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
static struct mtd_partition nand_partitions[] = {
{
.name = "bootloader", // bootloader,一般使用u-boot
.offset = 0, // 从mtd分区开始地址的偏移量是0
.size = SZ_256K, // 分区大小是256K
.mask_flags = 0, // 只读
},
{
.name = "params", // 存放bootloader的参数
.offset = MTDPART_OFS_APPEND, // 从上一分区(bootloader分区)开始
.size = SZ_128K,
.mask_flags = MTD_WRITEABLE, // 可写
},
{
.name = "kernel", // 存放内核
.offset = MTDPART_OFS_APPEND,
.size = SZ_4M,
.mask_flags = 0,
},
{
.name = "filesystem", // 存放文件系统
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL, // 整个分区的剩余存储空间
.mask_flags = 0,
}
};
static struct nand_davinci_platform_data nand_data = {
.options = 0,
.eccmode = NAND_ECC_HW3_512, // 校验模式
.cle_mask = 0x10,
.ale_mask = 0x08,
.bbt_td = NULL,
.bbt_md = NULL,
.parts = nand_partitions, // 分区信息
.nr_parts = ARRAY_SIZE(nand_partitions),
}; |
|