Path: blob/master/arch/arm/mach-orion5x/db88f5281-setup.c
10817 views
/*1* arch/arm/mach-orion5x/db88f5281-setup.c2*3* Marvell Orion-2 Development Board Setup4*5* Maintainer: Tzachi Perelstein <[email protected]>6*7* This file is licensed under the terms of the GNU General Public8* License version 2. This program is licensed "as is" without any9* warranty of any kind, whether express or implied.10*/1112#include <linux/kernel.h>13#include <linux/init.h>14#include <linux/platform_device.h>15#include <linux/pci.h>16#include <linux/irq.h>17#include <linux/mtd/physmap.h>18#include <linux/mtd/nand.h>19#include <linux/timer.h>20#include <linux/mv643xx_eth.h>21#include <linux/i2c.h>22#include <asm/mach-types.h>23#include <asm/gpio.h>24#include <asm/mach/arch.h>25#include <asm/mach/pci.h>26#include <mach/orion5x.h>27#include <plat/orion_nand.h>28#include "common.h"29#include "mpp.h"3031/*****************************************************************************32* DB-88F5281 on board devices33****************************************************************************/3435/*36* 512K NOR flash Device bus boot chip select37*/3839#define DB88F5281_NOR_BOOT_BASE 0xf400000040#define DB88F5281_NOR_BOOT_SIZE SZ_512K4142/*43* 7-Segment on Device bus chip select 044*/4546#define DB88F5281_7SEG_BASE 0xfa00000047#define DB88F5281_7SEG_SIZE SZ_1K4849/*50* 32M NOR flash on Device bus chip select 151*/5253#define DB88F5281_NOR_BASE 0xfc00000054#define DB88F5281_NOR_SIZE SZ_32M5556/*57* 32M NAND flash on Device bus chip select 258*/5960#define DB88F5281_NAND_BASE 0xfa80000061#define DB88F5281_NAND_SIZE SZ_1K6263/*64* PCI65*/6667#define DB88F5281_PCI_SLOT0_OFFS 768#define DB88F5281_PCI_SLOT0_IRQ_PIN 1269#define DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN 137071/*****************************************************************************72* 512M NOR Flash on Device bus Boot CS73****************************************************************************/7475static struct physmap_flash_data db88f5281_boot_flash_data = {76.width = 1, /* 8 bit bus width */77};7879static struct resource db88f5281_boot_flash_resource = {80.flags = IORESOURCE_MEM,81.start = DB88F5281_NOR_BOOT_BASE,82.end = DB88F5281_NOR_BOOT_BASE + DB88F5281_NOR_BOOT_SIZE - 1,83};8485static struct platform_device db88f5281_boot_flash = {86.name = "physmap-flash",87.id = 0,88.dev = {89.platform_data = &db88f5281_boot_flash_data,90},91.num_resources = 1,92.resource = &db88f5281_boot_flash_resource,93};9495/*****************************************************************************96* 32M NOR Flash on Device bus CS197****************************************************************************/9899static struct physmap_flash_data db88f5281_nor_flash_data = {100.width = 4, /* 32 bit bus width */101};102103static struct resource db88f5281_nor_flash_resource = {104.flags = IORESOURCE_MEM,105.start = DB88F5281_NOR_BASE,106.end = DB88F5281_NOR_BASE + DB88F5281_NOR_SIZE - 1,107};108109static struct platform_device db88f5281_nor_flash = {110.name = "physmap-flash",111.id = 1,112.dev = {113.platform_data = &db88f5281_nor_flash_data,114},115.num_resources = 1,116.resource = &db88f5281_nor_flash_resource,117};118119/*****************************************************************************120* 32M NAND Flash on Device bus CS2121****************************************************************************/122123static struct mtd_partition db88f5281_nand_parts[] = {124{125.name = "kernel",126.offset = 0,127.size = SZ_2M,128}, {129.name = "root",130.offset = SZ_2M,131.size = (SZ_16M - SZ_2M),132}, {133.name = "user",134.offset = SZ_16M,135.size = SZ_8M,136}, {137.name = "recovery",138.offset = (SZ_16M + SZ_8M),139.size = SZ_8M,140},141};142143static struct resource db88f5281_nand_resource = {144.flags = IORESOURCE_MEM,145.start = DB88F5281_NAND_BASE,146.end = DB88F5281_NAND_BASE + DB88F5281_NAND_SIZE - 1,147};148149static struct orion_nand_data db88f5281_nand_data = {150.parts = db88f5281_nand_parts,151.nr_parts = ARRAY_SIZE(db88f5281_nand_parts),152.cle = 0,153.ale = 1,154.width = 8,155};156157static struct platform_device db88f5281_nand_flash = {158.name = "orion_nand",159.id = -1,160.dev = {161.platform_data = &db88f5281_nand_data,162},163.resource = &db88f5281_nand_resource,164.num_resources = 1,165};166167/*****************************************************************************168* 7-Segment on Device bus CS0169* Dummy counter every 2 sec170****************************************************************************/171172static void __iomem *db88f5281_7seg;173static struct timer_list db88f5281_timer;174175static void db88f5281_7seg_event(unsigned long data)176{177static int count = 0;178writel(0, db88f5281_7seg + (count << 4));179count = (count + 1) & 7;180mod_timer(&db88f5281_timer, jiffies + 2 * HZ);181}182183static int __init db88f5281_7seg_init(void)184{185if (machine_is_db88f5281()) {186db88f5281_7seg = ioremap(DB88F5281_7SEG_BASE,187DB88F5281_7SEG_SIZE);188if (!db88f5281_7seg) {189printk(KERN_ERR "Failed to ioremap db88f5281_7seg\n");190return -EIO;191}192setup_timer(&db88f5281_timer, db88f5281_7seg_event, 0);193mod_timer(&db88f5281_timer, jiffies + 2 * HZ);194}195196return 0;197}198199__initcall(db88f5281_7seg_init);200201/*****************************************************************************202* PCI203****************************************************************************/204205void __init db88f5281_pci_preinit(void)206{207int pin;208209/*210* Configure PCI GPIO IRQ pins211*/212pin = DB88F5281_PCI_SLOT0_IRQ_PIN;213if (gpio_request(pin, "PCI Int1") == 0) {214if (gpio_direction_input(pin) == 0) {215irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);216} else {217printk(KERN_ERR "db88f5281_pci_preinit faield to "218"set_irq_type pin %d\n", pin);219gpio_free(pin);220}221} else {222printk(KERN_ERR "db88f5281_pci_preinit failed to gpio_request %d\n", pin);223}224225pin = DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN;226if (gpio_request(pin, "PCI Int2") == 0) {227if (gpio_direction_input(pin) == 0) {228irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);229} else {230printk(KERN_ERR "db88f5281_pci_preinit faield "231"to set_irq_type pin %d\n", pin);232gpio_free(pin);233}234} else {235printk(KERN_ERR "db88f5281_pci_preinit failed to gpio_request %d\n", pin);236}237}238239static int __init db88f5281_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)240{241int irq;242243/*244* Check for devices with hard-wired IRQs.245*/246irq = orion5x_pci_map_irq(dev, slot, pin);247if (irq != -1)248return irq;249250/*251* PCI IRQs are connected via GPIOs.252*/253switch (slot - DB88F5281_PCI_SLOT0_OFFS) {254case 0:255return gpio_to_irq(DB88F5281_PCI_SLOT0_IRQ_PIN);256case 1:257case 2:258return gpio_to_irq(DB88F5281_PCI_SLOT1_SLOT2_IRQ_PIN);259default:260return -1;261}262}263264static struct hw_pci db88f5281_pci __initdata = {265.nr_controllers = 2,266.preinit = db88f5281_pci_preinit,267.swizzle = pci_std_swizzle,268.setup = orion5x_pci_sys_setup,269.scan = orion5x_pci_sys_scan_bus,270.map_irq = db88f5281_pci_map_irq,271};272273static int __init db88f5281_pci_init(void)274{275if (machine_is_db88f5281())276pci_common_init(&db88f5281_pci);277278return 0;279}280281subsys_initcall(db88f5281_pci_init);282283/*****************************************************************************284* Ethernet285****************************************************************************/286static struct mv643xx_eth_platform_data db88f5281_eth_data = {287.phy_addr = MV643XX_ETH_PHY_ADDR(8),288};289290/*****************************************************************************291* RTC DS1339 on I2C bus292****************************************************************************/293static struct i2c_board_info __initdata db88f5281_i2c_rtc = {294I2C_BOARD_INFO("ds1339", 0x68),295};296297/*****************************************************************************298* General Setup299****************************************************************************/300static unsigned int db88f5281_mpp_modes[] __initdata = {301MPP0_GPIO, /* USB Over Current */302MPP1_GPIO, /* USB Vbat input */303MPP2_PCI_ARB, /* PCI_REQn[2] */304MPP3_PCI_ARB, /* PCI_GNTn[2] */305MPP4_PCI_ARB, /* PCI_REQn[3] */306MPP5_PCI_ARB, /* PCI_GNTn[3] */307MPP6_GPIO, /* JP0, CON17.2 */308MPP7_GPIO, /* JP1, CON17.1 */309MPP8_GPIO, /* JP2, CON11.2 */310MPP9_GPIO, /* JP3, CON11.3 */311MPP10_GPIO, /* RTC int */312MPP11_GPIO, /* Baud Rate Generator */313MPP12_GPIO, /* PCI int 1 */314MPP13_GPIO, /* PCI int 2 */315MPP14_NAND, /* NAND_REn[2] */316MPP15_NAND, /* NAND_WEn[2] */317MPP16_UART, /* UART1_RX */318MPP17_UART, /* UART1_TX */319MPP18_UART, /* UART1_CTSn */320MPP19_UART, /* UART1_RTSn */3210,322};323324static void __init db88f5281_init(void)325{326/*327* Basic Orion setup. Need to be called early.328*/329orion5x_init();330331orion5x_mpp_conf(db88f5281_mpp_modes);332writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */333334/*335* Configure peripherals.336*/337orion5x_ehci0_init();338orion5x_eth_init(&db88f5281_eth_data);339orion5x_i2c_init();340orion5x_uart0_init();341orion5x_uart1_init();342343orion5x_setup_dev_boot_win(DB88F5281_NOR_BOOT_BASE,344DB88F5281_NOR_BOOT_SIZE);345platform_device_register(&db88f5281_boot_flash);346347orion5x_setup_dev0_win(DB88F5281_7SEG_BASE, DB88F5281_7SEG_SIZE);348349orion5x_setup_dev1_win(DB88F5281_NOR_BASE, DB88F5281_NOR_SIZE);350platform_device_register(&db88f5281_nor_flash);351352orion5x_setup_dev2_win(DB88F5281_NAND_BASE, DB88F5281_NAND_SIZE);353platform_device_register(&db88f5281_nand_flash);354355i2c_register_board_info(0, &db88f5281_i2c_rtc, 1);356}357358MACHINE_START(DB88F5281, "Marvell Orion-2 Development Board")359/* Maintainer: Tzachi Perelstein <[email protected]> */360.boot_params = 0x00000100,361.init_machine = db88f5281_init,362.map_io = orion5x_map_io,363.init_early = orion5x_init_early,364.init_irq = orion5x_init_irq,365.timer = &orion5x_timer,366MACHINE_END367368369