1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-04-21 12:27:27 +03:00

[adm5120] experimental support for 2.6.27

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12863 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg
2008-10-05 11:07:49 +00:00
parent 7bab42f05f
commit b06573b702
115 changed files with 1602 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
obj-y += rb-1xx.o
obj-${CONFIG_ADM5120_MACH_RB_11X} += rb-11x.o
obj-${CONFIG_ADM5120_MACH_RB_133} += rb-133.o
obj-${CONFIG_ADM5120_MACH_RB_133C} += rb-133c.o
obj-${CONFIG_ADM5120_MACH_RB_150} += rb-150.o
obj-${CONFIG_ADM5120_MACH_RB_153} += rb-153.o
obj-${CONFIG_ADM5120_MACH_RB_192} += rb-192.o

View File

@@ -0,0 +1,35 @@
/*
* Mikrotik RouterBOARD 111/112 support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
static struct gpio_led rb11x_gpio_leds[] __initdata = {
GPIO_LED_STD(ADM5120_GPIO_PIN3, "user", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L1, "lan_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L0, "lan_lnkact", NULL),
};
static u8 rb11x_vlans[6] __initdata = {
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void __init rb11x_setup(void)
{
rb1xx_generic_setup();
rb1xx_add_device_nand();
adm5120_add_device_switch(1, rb11x_vlans);
adm5120_add_device_gpio(0);
adm5120_add_device_gpio_leds(ARRAY_SIZE(rb11x_gpio_leds),
rb11x_gpio_leds);
}
ADM5120_BOARD(MACH_ADM5120_RB_11X, "Mikrotik RouterBOARD 111/112", rb11x_setup);

View File

@@ -0,0 +1,40 @@
/*
* Mikrotik RouterBOARD 133 support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
static struct gpio_led rb133_gpio_leds[] __initdata = {
GPIO_LED_STD(ADM5120_GPIO_PIN6, "power", NULL),
GPIO_LED_STD(ADM5120_GPIO_PIN5, "user", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L1, "lan1_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L0, "lan1_lnkact", NULL),
GPIO_LED_INV(ADM5120_GPIO_P1L1, "lan2_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P1L0, "lan2_lnkact", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L1, "lan3_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L0, "lan3_lnkact", NULL),
};
static u8 rb133_vlans[6] __initdata = {
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void __init rb133_setup(void)
{
rb1xx_generic_setup();
rb1xx_add_device_nand();
adm5120_add_device_switch(3, rb133_vlans);
adm5120_add_device_gpio(0);
adm5120_add_device_gpio_leds(ARRAY_SIZE(rb133_gpio_leds),
rb133_gpio_leds);
}
ADM5120_BOARD(MACH_ADM5120_RB_133, "Mikrotik RouterBOARD 133", rb133_setup);

View File

@@ -0,0 +1,36 @@
/*
* Mikrotik RouterBOARD 133C support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
static struct gpio_led rb133c_gpio_leds[] __initdata = {
GPIO_LED_STD(ADM5120_GPIO_PIN6, "power", NULL),
GPIO_LED_STD(ADM5120_GPIO_PIN5, "user", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L1, "lan1_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L0, "lan1_lnkact", NULL),
};
static u8 rb133c_vlans[6] __initdata = {
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void __init rb133c_setup(void)
{
rb1xx_generic_setup();
rb1xx_add_device_nand();
adm5120_add_device_switch(1, rb133c_vlans);
adm5120_add_device_gpio(0);
adm5120_add_device_gpio_leds(ARRAY_SIZE(rb133c_gpio_leds),
rb133c_gpio_leds);
}
ADM5120_BOARD(MACH_ADM5120_RB_133C, "Mikrotik RouterBOARD 133C", rb133c_setup);

View File

@@ -0,0 +1,136 @@
/*
* Mikrotik RouterBOARD 150 support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
#define RB150_NAND_BASE 0x1FC80000
#define RB150_NAND_SIZE 1
#define RB150_GPIO_NAND_READY ADM5120_GPIO_PIN0
#define RB150_GPIO_NAND_NCE ADM5120_GPIO_PIN1
#define RB150_GPIO_NAND_CLE ADM5120_GPIO_P2L2
#define RB150_GPIO_NAND_ALE ADM5120_GPIO_P3L2
#define RB150_GPIO_RESET_BUTTON ADM5120_GPIO_PIN1 /* FIXME */
#define RB150_GPIO_DEV_MASK ( 1 << RB150_GPIO_NAND_READY \
| 1 << RB150_GPIO_NAND_NCE \
| 1 << RB150_GPIO_NAND_CLE \
| 1 << RB150_GPIO_NAND_ALE)
#define RB150_NAND_DELAY 100
#define RB150_NAND_WRITE(v) \
writeb((v), (void __iomem *)KSEG1ADDR(RB150_NAND_BASE))
static struct resource rb150_nand_resources[] __initdata = {
[0] = {
.start = RB150_NAND_BASE,
.end = RB150_NAND_BASE + RB150_NAND_SIZE-1,
.flags = IORESOURCE_MEM,
},
};
static struct gpio_led rb150_gpio_leds[] __initdata = {
GPIO_LED_STD(ADM5120_GPIO_P0L2, "user", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L1, "lan1_led1", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L0, "lan1_led2", NULL),
GPIO_LED_INV(ADM5120_GPIO_P1L1, "lan5_led1", NULL),
GPIO_LED_INV(ADM5120_GPIO_P1L0, "lan5_led2", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L1, "lan4_led1", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L0, "lan4_led2", NULL),
GPIO_LED_INV(ADM5120_GPIO_P3L1, "lan3_led1", NULL),
GPIO_LED_INV(ADM5120_GPIO_P3L0, "lan3_led2", NULL),
GPIO_LED_INV(ADM5120_GPIO_P4L1, "lan2_led1", NULL),
GPIO_LED_INV(ADM5120_GPIO_P4L0, "lan2_led2", NULL),
};
static u8 rb150_vlans[6] __initdata = {
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
};
static int rb150_nand_dev_ready(struct mtd_info *mtd)
{
return gpio_get_value(RB150_GPIO_NAND_READY);
}
static void rb150_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
unsigned int ctrl)
{
if (ctrl & NAND_CTRL_CHANGE) {
gpio_set_value(RB150_GPIO_NAND_CLE, (ctrl & NAND_CLE) ? 1 : 0);
gpio_set_value(RB150_GPIO_NAND_ALE, (ctrl & NAND_ALE) ? 1 : 0);
gpio_set_value(RB150_GPIO_NAND_NCE, (ctrl & NAND_NCE) ? 0 : 1);
}
udelay(RB150_NAND_DELAY);
if (cmd != NAND_CMD_NONE)
RB150_NAND_WRITE(cmd);
}
static void __init rb150_add_device_nand(void)
{
struct platform_device *pdev;
int err;
/* setup GPIO pins for NAND flash chip */
gpio_request(RB150_GPIO_NAND_READY, "nand-ready");
gpio_direction_input(RB150_GPIO_NAND_READY);
gpio_request(RB150_GPIO_NAND_NCE, "nand-nce");
gpio_direction_output(RB150_GPIO_NAND_NCE, 1);
gpio_request(RB150_GPIO_NAND_CLE, "nand-cle");
gpio_direction_output(RB150_GPIO_NAND_CLE, 0);
gpio_request(RB150_GPIO_NAND_ALE, "nand-ale");
gpio_direction_output(RB150_GPIO_NAND_ALE, 0);
pdev = platform_device_alloc("gen_nand", -1);
if (!pdev)
goto err_out;
err = platform_device_add_resources(pdev, rb150_nand_resources,
ARRAY_SIZE(rb150_nand_resources));
if (err)
goto err_put;
rb1xx_nand_data.ctrl.cmd_ctrl = rb150_nand_cmd_ctrl;
rb1xx_nand_data.ctrl.dev_ready = rb150_nand_dev_ready;
err = platform_device_add_data(pdev, &rb1xx_nand_data,
sizeof(rb1xx_nand_data));
if (err)
goto err_put;
err = platform_device_add(pdev);
if (err)
goto err_put;
return;
err_put:
platform_device_put(pdev);
err_out:
return;
}
static void __init rb150_setup(void)
{
rb1xx_gpio_buttons[0].gpio = RB150_GPIO_RESET_BUTTON;
rb1xx_generic_setup();
rb150_add_device_nand();
adm5120_add_device_gpio(RB150_GPIO_DEV_MASK);
adm5120_add_device_gpio_leds(ARRAY_SIZE(rb150_gpio_leds),
rb150_gpio_leds);
adm5120_add_device_switch(5, rb150_vlans);
}
ADM5120_BOARD(MACH_ADM5120_RB_150, "Mikrotik RouterBOARD 150", rb150_setup);

View File

@@ -0,0 +1,74 @@
/*
* Mikrotik RouterBOARD 153 support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
#define RB153_GPIO_DEV_MASK ( 1 << ADM5120_GPIO_PIN0 \
| 1 << ADM5120_GPIO_PIN3 \
| 1 << ADM5120_GPIO_PIN4 )
static struct resource rb153_cf_resources[] __initdata = {
{
.name = "cf_membase",
.start = ADM5120_EXTIO1_BASE,
.end = ADM5120_EXTIO1_BASE + ADM5120_EXTIO1_SIZE-1 ,
.flags = IORESOURCE_MEM
}, {
.name = "cf_irq",
.start = ADM5120_IRQ_GPIO4,
.end = ADM5120_IRQ_GPIO4,
.flags = IORESOURCE_IRQ
}
};
static struct gpio_led rb153_gpio_leds[] __initdata = {
GPIO_LED_STD(ADM5120_GPIO_PIN5, "user", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L1, "lan1_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P0L0, "lan1_lnkact", NULL),
GPIO_LED_INV(ADM5120_GPIO_P1L1, "lan5_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P1L0, "lan5_lnkact", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L1, "lan4_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P2L0, "lan4_lnkact", NULL),
GPIO_LED_INV(ADM5120_GPIO_P3L1, "lan3_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P3L0, "lan3_lnkact", NULL),
GPIO_LED_INV(ADM5120_GPIO_P4L1, "lan2_speed", NULL),
GPIO_LED_INV(ADM5120_GPIO_P4L0, "lan2_lnkact", NULL),
};
static u8 rb153_vlans[6] __initdata = {
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void __init rb153_add_device_cf(void)
{
/* enable CSX1:INTX1 on GPIO[3:4] for the CF slot */
adm5120_gpio_csx1_enable();
/* enable the wait state pin GPIO[0] for external I/O control */
adm5120_gpio_ew_enable();
platform_device_register_simple("pata-rb153-cf", -1,
rb153_cf_resources, ARRAY_SIZE(rb153_cf_resources));
}
static void __init rb153_setup(void)
{
rb1xx_generic_setup();
rb1xx_add_device_nand();
rb153_add_device_cf();
adm5120_add_device_gpio(RB153_GPIO_DEV_MASK);
adm5120_add_device_gpio_leds(ARRAY_SIZE(rb153_gpio_leds),
rb153_gpio_leds);
adm5120_add_device_switch(5, rb153_vlans);
}
ADM5120_BOARD(MACH_ADM5120_RB_153, "Mikrotik RouterBOARD 153", rb153_setup);

View File

@@ -0,0 +1,27 @@
/*
* Mikrotik RouterBOARD 192 support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
static u8 rb192_vlans[6] __initdata = {
0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
};
static void __init rb192_setup(void)
{
rb1xx_generic_setup();
rb1xx_add_device_nand();
adm5120_add_device_gpio(0);
adm5120_add_device_switch(6, rb192_vlans);
}
ADM5120_BOARD(MACH_ADM5120_RB_192, "Mikrotik RouterBOARD 192", rb192_setup);

View File

@@ -0,0 +1,152 @@
/*
* Mikrotik RouterBOARD 1xx series support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* NAND initialization code was based on a driver for Linux 2.6.19+ which
* was derived from the driver for Linux 2.4.xx published by Mikrotik for
* their RouterBoard 1xx and 5xx series boards.
* Copyright (C) 2007 David Goodenough <david.goodenough@linkchoose.co.uk>
* Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
*
* 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.
*
*/
#include "rb-1xx.h"
#define RB1XX_NAND_CHIP_DELAY 25
static struct adm5120_pci_irq rb1xx_pci_irqs[] __initdata = {
PCIIRQ(1, 0, 1, ADM5120_IRQ_PCI0),
PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI1),
PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI2)
};
#ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition rb1xx_nor_parts[] = {
{
.name = "booter",
.offset = 0,
.size = 64*1024,
.mask_flags = MTD_WRITEABLE,
} , {
.name = "firmware",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
}
};
static struct mtd_partition rb1xx_nand_parts[] = {
{
.name = "kernel",
.offset = 0,
.size = 4 * 1024 * 1024,
} , {
.name = "rootfs",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL
}
};
#endif /* CONFIG_MTD_PARTITIONS */
/*
* We need to use the OLD Yaffs-1 OOB layout, otherwise the RB bootloader
* will not be able to find the kernel that we load. So set the oobinfo
* when creating the partitions
*/
static struct nand_ecclayout rb1xx_nand_ecclayout = {
.eccbytes = 6,
.eccpos = { 8, 9, 10, 13, 14, 15 },
.oobavail = 9,
.oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
};
/*--------------------------------------------------------------------------*/
static int rb1xx_nand_fixup(struct mtd_info *mtd)
{
struct nand_chip *chip = mtd->priv;
if (mtd->writesize == 512)
chip->ecc.layout = &rb1xx_nand_ecclayout;
return 0;
}
struct platform_nand_data rb1xx_nand_data __initdata = {
.chip = {
.nr_chips = 1,
#ifdef CONFIG_MTD_PARTITIONS
.nr_partitions = ARRAY_SIZE(rb1xx_nand_parts),
.partitions = rb1xx_nand_parts,
#endif /* CONFIG_MTD_PARTITIONS */
.chip_delay = RB1XX_NAND_CHIP_DELAY,
.options = NAND_NO_AUTOINCR,
.chip_fixup = rb1xx_nand_fixup,
},
};
struct gpio_button rb1xx_gpio_buttons[] __initdata = {
{
.desc = "reset_button",
.type = EV_KEY,
.code = BTN_0,
.threshold = 5,
.gpio = ADM5120_GPIO_PIN7,
}
};
static void __init rb1xx_mac_setup(void)
{
if (rb_hs.mac_base != NULL && is_valid_ether_addr(rb_hs.mac_base)) {
adm5120_setup_eth_macs(rb_hs.mac_base);
} else {
u8 mac[ETH_ALEN];
random_ether_addr(mac);
adm5120_setup_eth_macs(mac);
}
}
void __init rb1xx_add_device_flash(void)
{
/* setup data for flash0 device */
#ifdef CONFIG_MTD_PARTITIONS
adm5120_flash0_data.nr_parts = ARRAY_SIZE(rb1xx_nor_parts);
adm5120_flash0_data.parts = rb1xx_nor_parts;
#endif /* CONFIG_MTD_PARTITIONS */
adm5120_flash0_data.window_size = 128*1024;
adm5120_add_device_flash(0);
}
void __init rb1xx_add_device_nand(void)
{
/* enable NAND flash interface */
adm5120_nand_enable();
/* initialize NAND chip */
adm5120_nand_set_spn(1);
adm5120_nand_set_wpn(0);
adm5120_add_device_nand(&rb1xx_nand_data);
}
void __init rb1xx_generic_setup(void)
{
if (adm5120_package_bga())
adm5120_pci_set_irq_map(ARRAY_SIZE(rb1xx_pci_irqs),
rb1xx_pci_irqs);
adm5120_add_device_uart(0);
adm5120_add_device_uart(1);
adm5120_add_device_gpio_buttons(ARRAY_SIZE(rb1xx_gpio_buttons),
rb1xx_gpio_buttons);
rb1xx_add_device_flash();
rb1xx_mac_setup();
}

View File

@@ -0,0 +1,34 @@
/*
* Mikrotik RouterBOARD 1xx series support
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/etherdevice.h>
#include <asm/bootinfo.h>
#include <asm/mach-adm5120/adm5120_defs.h>
#include <asm/mach-adm5120/adm5120_nand.h>
#include <asm/mach-adm5120/adm5120_board.h>
#include <asm/mach-adm5120/adm5120_platform.h>
#include <asm/mach-adm5120/adm5120_info.h>
#include <prom/routerboot.h>
extern struct platform_nand_data rb1xx_nand_data __initdata;
extern struct gpio_button rb1xx_gpio_buttons[] __initdata;
extern void rb1xx_add_device_flash(void) __init;
extern void rb1xx_add_device_nand(void) __init;
extern void rb1xx_generic_setup(void) __init;