Path: blob/master/arch/arm/mach-imx/mach-kzm_arm11_01.c
10817 views
/*1* KZM-ARM11-01 support2* Copyright (C) 2009 Yoichi Yuasa <[email protected]>3*4* based on code for MX31ADS,5* Copyright (C) 2000 Deep Blue Solutions Ltd6* Copyright (C) 2002 Shane Nay ([email protected])7* Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License as published by11* the Free Software Foundation; either version 2 of the License, or12* (at your option) any later version.13*14* This program is distributed in the hope that it will be useful,15* but WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17* GNU General Public License for more details.18*/1920#include <linux/gpio.h>21#include <linux/init.h>22#include <linux/platform_device.h>23#include <linux/serial_8250.h>24#include <linux/smsc911x.h>25#include <linux/types.h>2627#include <asm/irq.h>28#include <asm/mach-types.h>29#include <asm/memory.h>30#include <asm/setup.h>31#include <asm/mach/arch.h>32#include <asm/mach/irq.h>33#include <asm/mach/map.h>34#include <asm/mach/time.h>3536#include <mach/clock.h>37#include <mach/common.h>38#include <mach/iomux-mx3.h>3940#include "devices-imx31.h"4142#define KZM_ARM11_IO_ADDRESS(x) (IOMEM( \43IMX_IO_P2V_MODULE(x, MX31_CS4) ?: \44IMX_IO_P2V_MODULE(x, MX31_CS5)) ?: \45MX31_IO_ADDRESS(x))4647/*48* KZM-ARM11-01 Board Control Registers on FPGA49*/50#define KZM_ARM11_CTL1 (MX31_CS4_BASE_ADDR + 0x1000)51#define KZM_ARM11_CTL2 (MX31_CS4_BASE_ADDR + 0x1001)52#define KZM_ARM11_RSW1 (MX31_CS4_BASE_ADDR + 0x1002)53#define KZM_ARM11_BACK_LIGHT (MX31_CS4_BASE_ADDR + 0x1004)54#define KZM_ARM11_FPGA_REV (MX31_CS4_BASE_ADDR + 0x1008)55#define KZM_ARM11_7SEG_LED (MX31_CS4_BASE_ADDR + 0x1010)56#define KZM_ARM11_LEDS (MX31_CS4_BASE_ADDR + 0x1020)57#define KZM_ARM11_DIPSW2 (MX31_CS4_BASE_ADDR + 0x1003)5859/*60* External UART for touch panel on FPGA61*/62#define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050)6364#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)65/*66* KZM-ARM11-01 has an external UART on FPGA67*/68static struct plat_serial8250_port serial_platform_data[] = {69{70.membase = KZM_ARM11_IO_ADDRESS(KZM_ARM11_16550),71.mapbase = KZM_ARM11_16550,72.irq = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),73.irqflags = IRQ_TYPE_EDGE_RISING,74.uartclk = 14745600,75.regshift = 0,76.iotype = UPIO_MEM,77.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |78UPF_BUGGY_UART,79},80{},81};8283static struct resource serial8250_resources[] = {84{85.start = KZM_ARM11_16550,86.end = KZM_ARM11_16550 + 0x10,87.flags = IORESOURCE_MEM,88},89{90.start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),91.end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_1),92.flags = IORESOURCE_IRQ,93},94};9596static struct platform_device serial_device = {97.name = "serial8250",98.id = PLAT8250_DEV_PLATFORM,99.dev = {100.platform_data = serial_platform_data,101},102.num_resources = ARRAY_SIZE(serial8250_resources),103.resource = serial8250_resources,104};105106static int __init kzm_init_ext_uart(void)107{108u8 tmp;109110/*111* GPIO 1-1: external UART interrupt line112*/113mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));114gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");115gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));116117/*118* Unmask UART interrupt119*/120tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));121tmp |= 0x2;122__raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));123124return platform_device_register(&serial_device);125}126#else127static inline int kzm_init_ext_uart(void)128{129return 0;130}131#endif132133/*134* SMSC LAN9118135*/136#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)137static struct smsc911x_platform_config kzm_smsc9118_config = {138.phy_interface = PHY_INTERFACE_MODE_MII,139.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,140.irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,141.flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,142};143144static struct resource kzm_smsc9118_resources[] = {145{146.start = MX31_CS5_BASE_ADDR,147.end = MX31_CS5_BASE_ADDR + SZ_128K - 1,148.flags = IORESOURCE_MEM,149},150{151.start = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2),152.end = IOMUX_TO_IRQ(MX31_PIN_GPIO1_2),153.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,154},155};156157static struct platform_device kzm_smsc9118_device = {158.name = "smsc911x",159.id = -1,160.num_resources = ARRAY_SIZE(kzm_smsc9118_resources),161.resource = kzm_smsc9118_resources,162.dev = {163.platform_data = &kzm_smsc9118_config,164},165};166167static int __init kzm_init_smsc9118(void)168{169/*170* GPIO 1-2: SMSC9118 interrupt line171*/172mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));173gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");174gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));175176return platform_device_register(&kzm_smsc9118_device);177}178#else179static inline int kzm_init_smsc9118(void)180{181return 0;182}183#endif184185#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)186static const struct imxuart_platform_data uart_pdata __initconst = {187.flags = IMXUART_HAVE_RTSCTS,188};189190static void __init kzm_init_imx_uart(void)191{192imx31_add_imx_uart0(&uart_pdata);193imx31_add_imx_uart1(&uart_pdata);194}195#else196static inline void kzm_init_imx_uart(void)197{198}199#endif200201static int kzm_pins[] __initdata = {202MX31_PIN_CTS1__CTS1,203MX31_PIN_RTS1__RTS1,204MX31_PIN_TXD1__TXD1,205MX31_PIN_RXD1__RXD1,206MX31_PIN_DCD_DCE1__DCD_DCE1,207MX31_PIN_RI_DCE1__RI_DCE1,208MX31_PIN_DSR_DCE1__DSR_DCE1,209MX31_PIN_DTR_DCE1__DTR_DCE1,210MX31_PIN_CTS2__CTS2,211MX31_PIN_RTS2__RTS2,212MX31_PIN_TXD2__TXD2,213MX31_PIN_RXD2__RXD2,214MX31_PIN_DCD_DTE1__DCD_DTE2,215MX31_PIN_RI_DTE1__RI_DTE2,216MX31_PIN_DSR_DTE1__DSR_DTE2,217MX31_PIN_DTR_DTE1__DTR_DTE2,218};219220/*221* Board specific initialization.222*/223static void __init kzm_board_init(void)224{225mxc_iomux_setup_multiple_pins(kzm_pins,226ARRAY_SIZE(kzm_pins), "kzm");227kzm_init_ext_uart();228kzm_init_smsc9118();229kzm_init_imx_uart();230231pr_info("Clock input source is 26MHz\n");232}233234/*235* This structure defines static mappings for the kzm-arm11-01 board.236*/237static struct map_desc kzm_io_desc[] __initdata = {238{239.virtual = MX31_CS4_BASE_ADDR_VIRT,240.pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),241.length = MX31_CS4_SIZE,242.type = MT_DEVICE243},244{245.virtual = MX31_CS5_BASE_ADDR_VIRT,246.pfn = __phys_to_pfn(MX31_CS5_BASE_ADDR),247.length = MX31_CS5_SIZE,248.type = MT_DEVICE249},250};251252/*253* Set up static virtual mappings.254*/255static void __init kzm_map_io(void)256{257mx31_map_io();258iotable_init(kzm_io_desc, ARRAY_SIZE(kzm_io_desc));259}260261static void __init kzm_timer_init(void)262{263mx31_clocks_init(26000000);264}265266static struct sys_timer kzm_timer = {267.init = kzm_timer_init,268};269270MACHINE_START(KZM_ARM11_01, "Kyoto Microcomputer Co., Ltd. KZM-ARM11-01")271.boot_params = MX3x_PHYS_OFFSET + 0x100,272.map_io = kzm_map_io,273.init_early = imx31_init_early,274.init_irq = mx31_init_irq,275.timer = &kzm_timer,276.init_machine = kzm_board_init,277MACHINE_END278279280