Path: blob/master/arch/arm/mach-imx/mach-mx21ads.c
10817 views
/*1* Copyright (C) 2000 Deep Blue Solutions Ltd2* Copyright (C) 2002 Shane Nay ([email protected])3* Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*/1516#include <linux/platform_device.h>17#include <linux/mtd/mtd.h>18#include <linux/mtd/physmap.h>19#include <linux/gpio.h>20#include <mach/common.h>21#include <mach/hardware.h>22#include <asm/mach-types.h>23#include <asm/mach/arch.h>24#include <asm/mach/time.h>25#include <asm/mach/map.h>26#include <mach/iomux-mx21.h>2728#include "devices-imx21.h"2930/*31* Memory-mapped I/O on MX21ADS base board32*/33#define MX21ADS_MMIO_BASE_ADDR 0xf500000034#define MX21ADS_MMIO_SIZE SZ_16M3536#define MX21ADS_REG_ADDR(offset) (void __force __iomem *) \37(MX21ADS_MMIO_BASE_ADDR + (offset))3839#define MX21ADS_CS8900A_IRQ IRQ_GPIOE(11)40#define MX21ADS_CS8900A_IOBASE_REG MX21ADS_REG_ADDR(0x000000)41#define MX21ADS_ST16C255_IOBASE_REG MX21ADS_REG_ADDR(0x200000)42#define MX21ADS_VERSION_REG MX21ADS_REG_ADDR(0x400000)43#define MX21ADS_IO_REG MX21ADS_REG_ADDR(0x800000)4445/* MX21ADS_IO_REG bit definitions */46#define MX21ADS_IO_SD_WP 0x0001 /* read */47#define MX21ADS_IO_TP6 0x0001 /* write */48#define MX21ADS_IO_SW_SEL 0x0002 /* read */49#define MX21ADS_IO_TP7 0x0002 /* write */50#define MX21ADS_IO_RESET_E_UART 0x000451#define MX21ADS_IO_RESET_BASE 0x000852#define MX21ADS_IO_CSI_CTL2 0x001053#define MX21ADS_IO_CSI_CTL1 0x002054#define MX21ADS_IO_CSI_CTL0 0x004055#define MX21ADS_IO_UART1_EN 0x008056#define MX21ADS_IO_UART4_EN 0x010057#define MX21ADS_IO_LCDON 0x020058#define MX21ADS_IO_IRDA_EN 0x040059#define MX21ADS_IO_IRDA_FIR_SEL 0x080060#define MX21ADS_IO_IRDA_MD0_B 0x100061#define MX21ADS_IO_IRDA_MD1 0x200062#define MX21ADS_IO_LED4_ON 0x400063#define MX21ADS_IO_LED3_ON 0x80006465static const int mx21ads_pins[] __initconst = {6667/* CS8900A */68(GPIO_PORTE | GPIO_GPIO | GPIO_IN | 11),6970/* UART1 */71PE12_PF_UART1_TXD,72PE13_PF_UART1_RXD,73PE14_PF_UART1_CTS,74PE15_PF_UART1_RTS,7576/* UART3 (IrDA) - only TXD and RXD */77PE8_PF_UART3_TXD,78PE9_PF_UART3_RXD,7980/* UART4 */81PB26_AF_UART4_RTS,82PB28_AF_UART4_TXD,83PB29_AF_UART4_CTS,84PB31_AF_UART4_RXD,8586/* LCDC */87PA5_PF_LSCLK,88PA6_PF_LD0,89PA7_PF_LD1,90PA8_PF_LD2,91PA9_PF_LD3,92PA10_PF_LD4,93PA11_PF_LD5,94PA12_PF_LD6,95PA13_PF_LD7,96PA14_PF_LD8,97PA15_PF_LD9,98PA16_PF_LD10,99PA17_PF_LD11,100PA18_PF_LD12,101PA19_PF_LD13,102PA20_PF_LD14,103PA21_PF_LD15,104PA22_PF_LD16,105PA24_PF_REV, /* Sharp panel dedicated signal */106PA25_PF_CLS, /* Sharp panel dedicated signal */107PA26_PF_PS, /* Sharp panel dedicated signal */108PA27_PF_SPL_SPR, /* Sharp panel dedicated signal */109PA28_PF_HSYNC,110PA29_PF_VSYNC,111PA30_PF_CONTRAST,112PA31_PF_OE_ACD,113114/* MMC/SDHC */115PE18_PF_SD1_D0,116PE19_PF_SD1_D1,117PE20_PF_SD1_D2,118PE21_PF_SD1_D3,119PE22_PF_SD1_CMD,120PE23_PF_SD1_CLK,121122/* NFC */123PF0_PF_NRFB,124PF1_PF_NFCE,125PF2_PF_NFWP,126PF3_PF_NFCLE,127PF4_PF_NFALE,128PF5_PF_NFRE,129PF6_PF_NFWE,130PF7_PF_NFIO0,131PF8_PF_NFIO1,132PF9_PF_NFIO2,133PF10_PF_NFIO3,134PF11_PF_NFIO4,135PF12_PF_NFIO5,136PF13_PF_NFIO6,137PF14_PF_NFIO7,138};139140/* ADS's NOR flash: 2x AM29BDS128HE9VKI on 32-bit bus */141static struct physmap_flash_data mx21ads_flash_data = {142.width = 4,143};144145static struct resource mx21ads_flash_resource = {146.start = MX21_CS0_BASE_ADDR,147.end = MX21_CS0_BASE_ADDR + 0x02000000 - 1,148.flags = IORESOURCE_MEM,149};150151static struct platform_device mx21ads_nor_mtd_device = {152.name = "physmap-flash",153.id = 0,154.dev = {155.platform_data = &mx21ads_flash_data,156},157.num_resources = 1,158.resource = &mx21ads_flash_resource,159};160161static const struct imxuart_platform_data uart_pdata_rts __initconst = {162.flags = IMXUART_HAVE_RTSCTS,163};164165static const struct imxuart_platform_data uart_pdata_norts __initconst = {166};167168static int mx21ads_fb_init(struct platform_device *pdev)169{170u16 tmp;171172tmp = __raw_readw(MX21ADS_IO_REG);173tmp |= MX21ADS_IO_LCDON;174__raw_writew(tmp, MX21ADS_IO_REG);175return 0;176}177178static void mx21ads_fb_exit(struct platform_device *pdev)179{180u16 tmp;181182tmp = __raw_readw(MX21ADS_IO_REG);183tmp &= ~MX21ADS_IO_LCDON;184__raw_writew(tmp, MX21ADS_IO_REG);185}186187/*188* Connected is a portrait Sharp-QVGA display189* of type: LQ035Q7DB02190*/191static struct imx_fb_videomode mx21ads_modes[] = {192{193.mode = {194.name = "Sharp-LQ035Q7",195.refresh = 60,196.xres = 240,197.yres = 320,198.pixclock = 188679, /* in ps (5.3MHz) */199.hsync_len = 2,200.left_margin = 6,201.right_margin = 16,202.vsync_len = 1,203.upper_margin = 8,204.lower_margin = 10,205},206.pcr = 0xfb108bc7,207.bpp = 16,208},209};210211static const struct imx_fb_platform_data mx21ads_fb_data __initconst = {212.mode = mx21ads_modes,213.num_modes = ARRAY_SIZE(mx21ads_modes),214215.pwmr = 0x00a903ff,216.lscr1 = 0x00120300,217.dmacr = 0x00020008,218219.init = mx21ads_fb_init,220.exit = mx21ads_fb_exit,221};222223static int mx21ads_sdhc_get_ro(struct device *dev)224{225return (__raw_readw(MX21ADS_IO_REG) & MX21ADS_IO_SD_WP) ? 1 : 0;226}227228static int mx21ads_sdhc_init(struct device *dev, irq_handler_t detect_irq,229void *data)230{231return request_irq(IRQ_GPIOD(25), detect_irq,232IRQF_TRIGGER_FALLING, "mmc-detect", data);233}234235static void mx21ads_sdhc_exit(struct device *dev, void *data)236{237free_irq(IRQ_GPIOD(25), data);238}239240static const struct imxmmc_platform_data mx21ads_sdhc_pdata __initconst = {241.ocr_avail = MMC_VDD_29_30 | MMC_VDD_30_31, /* 3.0V */242.get_ro = mx21ads_sdhc_get_ro,243.init = mx21ads_sdhc_init,244.exit = mx21ads_sdhc_exit,245};246247static const struct mxc_nand_platform_data248mx21ads_nand_board_info __initconst = {249.width = 1,250.hw_ecc = 1,251};252253static struct map_desc mx21ads_io_desc[] __initdata = {254/*255* Memory-mapped I/O on MX21ADS Base board:256* - CS8900A Ethernet controller257* - ST16C2552CJ UART258* - CPU and Base board version259* - Base board I/O register260*/261{262.virtual = MX21ADS_MMIO_BASE_ADDR,263.pfn = __phys_to_pfn(MX21_CS1_BASE_ADDR),264.length = MX21ADS_MMIO_SIZE,265.type = MT_DEVICE,266},267};268269static void __init mx21ads_map_io(void)270{271mx21_map_io();272iotable_init(mx21ads_io_desc, ARRAY_SIZE(mx21ads_io_desc));273}274275static struct platform_device *platform_devices[] __initdata = {276&mx21ads_nor_mtd_device,277};278279static void __init mx21ads_board_init(void)280{281mxc_gpio_setup_multiple_pins(mx21ads_pins, ARRAY_SIZE(mx21ads_pins),282"mx21ads");283284imx21_add_imx_uart0(&uart_pdata_rts);285imx21_add_imx_uart2(&uart_pdata_norts);286imx21_add_imx_uart3(&uart_pdata_rts);287imx21_add_imx_fb(&mx21ads_fb_data);288imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);289imx21_add_mxc_nand(&mx21ads_nand_board_info);290291platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));292}293294static void __init mx21ads_timer_init(void)295{296mx21_clocks_init(32768, 26000000);297}298299static struct sys_timer mx21ads_timer = {300.init = mx21ads_timer_init,301};302303MACHINE_START(MX21ADS, "Freescale i.MX21ADS")304/* maintainer: Freescale Semiconductor, Inc. */305.boot_params = MX21_PHYS_OFFSET + 0x100,306.map_io = mx21ads_map_io,307.init_early = imx21_init_early,308.init_irq = mx21_init_irq,309.timer = &mx21ads_timer,310.init_machine = mx21ads_board_init,311MACHINE_END312313314