/* * linux/arch/arm/mach-davinci/io.c * * DaVinci I/O mapping code * * Copyright (C) 2005-2006 Texas Instruments * * 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. */
/* * The machine specific code may provide the extra mapping besides the * default mapping provided here. */ staticstruct map_desc davinci_io_desc[] __initdata ={ { .virtual= IO_VIRT,// 0xe1000000
/* Normally devicemaps_init() would flush caches and tlb after * mdesc->map_io(), but we must also do it here because of the CPU * revision check below. */ flush_tlb_all(); flush_cache_all();
// 初始化各服用功能引脚(与GPIO引脚复用)
davinci_mux_init();
// 注册模块时钟,以便使用模块时申请
davinci_clk_init(); }
io.h
/* * linux/include/asm-arm/arch-davinci/io.h * * Copyright (C) 2006 Texas Instruments. * * 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. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * */
/* DM646X need to map 0x02000000-0x02400000 to 0x0e1400000-0x0e1800000*/ /* This is put in the generic section so IRAM is mapped the same between DaVinci and DM646X - Note that this will leave a hole for DaVinci */ #define DM646X_IO_PHYS 0x02000000 #define DM646X_IO_VIRT (IO_VIRT + IO_SIZE) #define DM646X_IO_SIZE SZ_4M
#define DAVINCI_IRAM_VIRT (DM646X_IO_VIRT + DM646X_IO_SIZE) /* after 4M of IO space */ #define DAVINCI_IRAM_SIZE SZ_16K
/* * DM644X specific mappings */ /* DaVinci IRAM mapping */ #define DAVINCI_IRAM_BASE 0x00008000 /* ARM Internal RAM (Data) */
/* * We don't actually have real ISA nor PCI buses, but there is so many * drivers out there that might just work if we fake them... */ #define PCIO_BASE 0 #define __io(a)((void __iomem *)(PCIO_BASE +(a))) #define __mem_pci(a)(a) #define __mem_isa(a)(a)
#ifndef __ASSEMBLER__
/* * Functions to access the DaVinci IO region * * NOTE: - Use davinci_read/write[bwl] for physical register addresses * - Use __raw_read/write[bwl]() for virtual register addresses * - Use IO_ADDRESS(phys_addr) to convert registers to virtual addresses * - DO NOT use hardcoded virtual addresses to allow changing the * IO address space again if needed 所有的指针强制类型转换中都加了volatile修饰符,防止IO地址被cache */ #define davinci_readb(a)(*(volatileunsignedchar*)IO_ADDRESS(a)) #define davinci_readw(a)(*(volatileunsignedshort*)IO_ADDRESS(a)) #define davinci_readl(a)(*(volatileunsignedint*)IO_ADDRESS(a))