Path: blob/master/arch/arm/mach-nomadik/board-nhk8815.c
10817 views
/*1* linux/arch/arm/mach-nomadik/board-8815nhk.c2*3* Copyright (C) STMicroelectronics4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2, as7* published by the Free Software Foundation.8*9* NHK15 board specifc driver definition10*/11#include <linux/types.h>12#include <linux/kernel.h>13#include <linux/init.h>14#include <linux/platform_device.h>15#include <linux/amba/bus.h>16#include <linux/interrupt.h>17#include <linux/gpio.h>18#include <linux/mtd/mtd.h>19#include <linux/mtd/nand.h>20#include <linux/mtd/onenand.h>21#include <linux/mtd/partitions.h>22#include <linux/io.h>23#include <asm/sizes.h>24#include <asm/mach-types.h>25#include <asm/mach/arch.h>26#include <asm/mach/irq.h>27#include <asm/mach/flash.h>2829#include <plat/mtu.h>3031#include <mach/setup.h>32#include <mach/nand.h>33#include <mach/fsmc.h>3435/* Initial value for SRC control register: all timers use MXTAL/8 source */36#define SRC_CR_INIT_MASK 0x00007fff37#define SRC_CR_INIT_VAL 0x2aaa80003839/* These addresses span 16MB, so use three individual pages */40static struct resource nhk8815_nand_resources[] = {41{42.name = "nand_addr",43.start = NAND_IO_ADDR,44.end = NAND_IO_ADDR + 0xfff,45.flags = IORESOURCE_MEM,46}, {47.name = "nand_cmd",48.start = NAND_IO_CMD,49.end = NAND_IO_CMD + 0xfff,50.flags = IORESOURCE_MEM,51}, {52.name = "nand_data",53.start = NAND_IO_DATA,54.end = NAND_IO_DATA + 0xfff,55.flags = IORESOURCE_MEM,56}57};5859static int nhk8815_nand_init(void)60{61/* FSMC setup for nand chip select (8-bit nand in 8815NHK) */62writel(0x0000000E, FSMC_PCR(0));63writel(0x000D0A00, FSMC_PMEM(0));64writel(0x00100A00, FSMC_PATT(0));6566/* enable access to the chip select area */67writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));6869return 0;70}7172/*73* These partitions are the same as those used in the 2.6.20 release74* shipped by the vendor; the first two partitions are mandated75* by the boot ROM, and the bootloader area is somehow oversized...76*/77static struct mtd_partition nhk8815_partitions[] = {78{79.name = "X-Loader(NAND)",80.offset = 0,81.size = SZ_256K,82}, {83.name = "MemInit(NAND)",84.offset = MTDPART_OFS_APPEND,85.size = SZ_256K,86}, {87.name = "BootLoader(NAND)",88.offset = MTDPART_OFS_APPEND,89.size = SZ_2M,90}, {91.name = "Kernel zImage(NAND)",92.offset = MTDPART_OFS_APPEND,93.size = 3 * SZ_1M,94}, {95.name = "Root Filesystem(NAND)",96.offset = MTDPART_OFS_APPEND,97.size = 22 * SZ_1M,98}, {99.name = "User Filesystem(NAND)",100.offset = MTDPART_OFS_APPEND,101.size = MTDPART_SIZ_FULL,102}103};104105static struct nomadik_nand_platform_data nhk8815_nand_data = {106.parts = nhk8815_partitions,107.nparts = ARRAY_SIZE(nhk8815_partitions),108.options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \109| NAND_NO_READRDY | NAND_NO_AUTOINCR,110.init = nhk8815_nand_init,111};112113static struct platform_device nhk8815_nand_device = {114.name = "nomadik_nand",115.dev = {116.platform_data = &nhk8815_nand_data,117},118.resource = nhk8815_nand_resources,119.num_resources = ARRAY_SIZE(nhk8815_nand_resources),120};121122/* These are the partitions for the OneNand device, different from above */123static struct mtd_partition nhk8815_onenand_partitions[] = {124{125.name = "X-Loader(OneNAND)",126.offset = 0,127.size = SZ_256K,128}, {129.name = "MemInit(OneNAND)",130.offset = MTDPART_OFS_APPEND,131.size = SZ_256K,132}, {133.name = "BootLoader(OneNAND)",134.offset = MTDPART_OFS_APPEND,135.size = SZ_2M-SZ_256K,136}, {137.name = "SysImage(OneNAND)",138.offset = MTDPART_OFS_APPEND,139.size = 4 * SZ_1M,140}, {141.name = "Root Filesystem(OneNAND)",142.offset = MTDPART_OFS_APPEND,143.size = 22 * SZ_1M,144}, {145.name = "User Filesystem(OneNAND)",146.offset = MTDPART_OFS_APPEND,147.size = MTDPART_SIZ_FULL,148}149};150151static struct onenand_platform_data nhk8815_onenand_data = {152.parts = nhk8815_onenand_partitions,153.nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),154};155156static struct resource nhk8815_onenand_resource[] = {157{158.start = 0x30000000,159.end = 0x30000000 + SZ_128K - 1,160.flags = IORESOURCE_MEM,161},162};163164static struct platform_device nhk8815_onenand_device = {165.name = "onenand-flash",166.id = -1,167.dev = {168.platform_data = &nhk8815_onenand_data,169},170.resource = nhk8815_onenand_resource,171.num_resources = ARRAY_SIZE(nhk8815_onenand_resource),172};173174static void __init nhk8815_onenand_init(void)175{176#ifdef CONFIG_MTD_ONENAND177/* Set up SMCS0 for OneNand */178writel(0x000030db, FSMC_BCR(0));179writel(0x02100551, FSMC_BTR(0));180#endif181}182183#define __MEM_4K_RESOURCE(x) \184.res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}185186static struct amba_device uart0_device = {187.dev = { .init_name = "uart0" },188__MEM_4K_RESOURCE(NOMADIK_UART0_BASE),189.irq = {IRQ_UART0, NO_IRQ},190};191192static struct amba_device uart1_device = {193.dev = { .init_name = "uart1" },194__MEM_4K_RESOURCE(NOMADIK_UART1_BASE),195.irq = {IRQ_UART1, NO_IRQ},196};197198static struct amba_device *amba_devs[] __initdata = {199&uart0_device,200&uart1_device,201};202203static struct resource nhk8815_eth_resources[] = {204{205.name = "smc91x-regs",206.start = 0x34000000 + 0x300,207.end = 0x34000000 + SZ_64K - 1,208.flags = IORESOURCE_MEM,209}, {210.start = NOMADIK_GPIO_TO_IRQ(115),211.end = NOMADIK_GPIO_TO_IRQ(115),212.flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,213}214};215216static struct platform_device nhk8815_eth_device = {217.name = "smc91x",218.resource = nhk8815_eth_resources,219.num_resources = ARRAY_SIZE(nhk8815_eth_resources),220};221222static int __init nhk8815_eth_init(void)223{224int gpio_nr = 115; /* hardwired in the board */225int err;226227err = gpio_request(gpio_nr, "eth_irq");228if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);229if (!err) err = gpio_direction_input(gpio_nr);230if (err)231pr_err("Error %i in %s\n", err, __func__);232return err;233}234device_initcall(nhk8815_eth_init);235236static struct platform_device *nhk8815_platform_devices[] __initdata = {237&nhk8815_nand_device,238&nhk8815_onenand_device,239&nhk8815_eth_device,240/* will add more devices */241};242243static void __init nomadik_timer_init(void)244{245u32 src_cr;246247/* Configure timer sources in "system reset controller" ctrl reg */248src_cr = readl(io_p2v(NOMADIK_SRC_BASE));249src_cr &= SRC_CR_INIT_MASK;250src_cr |= SRC_CR_INIT_VAL;251writel(src_cr, io_p2v(NOMADIK_SRC_BASE));252253/* Save global pointer to mtu, used by platform timer code */254mtu_base = io_p2v(NOMADIK_MTU0_BASE);255256nmdk_timer_init();257}258259static struct sys_timer nomadik_timer = {260.init = nomadik_timer_init,261};262263static void __init nhk8815_platform_init(void)264{265int i;266267cpu8815_platform_init();268nhk8815_onenand_init();269platform_add_devices(nhk8815_platform_devices,270ARRAY_SIZE(nhk8815_platform_devices));271272for (i = 0; i < ARRAY_SIZE(amba_devs); i++)273amba_device_register(amba_devs[i], &iomem_resource);274}275276MACHINE_START(NOMADIK, "NHK8815")277/* Maintainer: ST MicroElectronics */278.boot_params = 0x100,279.map_io = cpu8815_map_io,280.init_irq = cpu8815_init_irq,281.timer = &nomadik_timer,282.init_machine = nhk8815_platform_init,283MACHINE_END284285286