--- a/arch/mips/bcm63xx/boards/Kconfig +++ b/arch/mips/bcm63xx/boards/Kconfig @@ -8,4 +8,10 @@ config BOARD_BCM963XX select SSB help +config BOARD_LIVEBOX + bool "Inventel Livebox(es) boards" + select SSB + help + Inventel Livebox boards using the RedBoot bootloader. + endchoice --- a/arch/mips/bcm63xx/boards/Makefile +++ b/arch/mips/bcm63xx/boards/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_BOARD_BCM963XX) += board_bcm963xx.o +obj-$(CONFIG_BOARD_LIVEBOX) += board_livebox.o EXTRA_CFLAGS += -Werror --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h @@ -58,7 +58,7 @@ struct gpio_led leds[8]; /* Reset button */ - struct gpio_button reset_buttons[1]; + struct gpio_button reset_buttons[4]; }; #endif /* ! BOARD_BCM963XX_H_ */ --- a/drivers/mtd/maps/bcm963xx-flash.c +++ b/drivers/mtd/maps/bcm963xx-flash.c @@ -202,7 +202,7 @@ printk(KERN_INFO PFX "assuming RedBoot bootloader\n"); if (bcm963xx_mtd_info->size > 0x00400000) { printk(KERN_INFO PFX "Support for extended flash memory size : 0x%lx ; ONLY 64MBIT SUPPORT\n", bcm963xx_mtd_info->size); - bcm963xx_map.virt = (u32)(EXTENDED_SIZE); + bcm963xx_map.virt = (u32)(bcm963xx_map.phys + 0xA0000000); } #ifdef CONFIG_MTD_REDBOOT_PARTS --- /dev/null +++ b/arch/mips/bcm63xx/boards/board_livebox.c @@ -0,0 +1,359 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2008 Florian Fainelli + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PFX "board_livebox: " + +static unsigned int mac_addr_used = 0; +static struct board_info board; + +/* + * known 6348 boards + */ +#ifdef CONFIG_BCM63XX_CPU_6348 +static struct board_info __initdata board_livebox = { + .name = "Livebox", + .expected_cpu_id = 0x6348, + + .has_enet0 = 1, + .has_enet1 = 1, + .has_pci = 1, + + .enet0 = { + .has_phy = 1, + .use_internal_phy = 1, + }, + + .enet1 = { + .has_phy = 1, + .phy_id = 31, + }, + + .has_ohci0 = 1, + .has_udc0 = 1, + .has_pccard = 1, /*the pccard (PCMCIA) connector can be soldered if not present*/ + + .has_dsp = 0, /*TODO some Liveboxes have dsp*/ + .dsp = { + .gpio_rst = 6, /*FIXME eth1 shares gpio6 with dsp*/ + .gpio_int = 35, + .cs = 2, + .ext_irq = 2, + }, + + .leds = { + { + .name = "adsl-fail", + .gpio = 0, + .active_low = 0, + .default_trigger = "default-on", + }, + { + .name = "adsl", + .gpio = 1, + .active_low = 0, + }, + { + .name = "traffic", + .gpio = 2, + .active_low = 0, + }, + { + .name = "phone", + .gpio = 3, + .active_low = 0, + }, + { + .name = "wifi", + .gpio = 4, + .active_low = 0, + }, + }, + + .reset_buttons = { + { + .desc = "BTN_1", + .gpio = 36, + .active_low = 1, + .type = EV_KEY, + .code = BTN_1, + .threshold = 3, + }, + { + .desc = "BTN_2", + .gpio = 7, + .active_low = 1, + .type = EV_KEY, + .code = BTN_2, + .threshold = 3, + }, + + }, +}; +#endif + +/* + * all boards + */ +static const struct board_info __initdata *bcm963xx_boards[] = { +#ifdef CONFIG_BCM63XX_CPU_6348 + &board_livebox +#endif +}; + +#define MIPS_BASE 0xff400000 +#define RAC_CR0 0x00 /*offset*/ +#define RAC_C_INV (1 << 4) +#define RAC_PF_I (1 << 2) +#define RAC_I (1 << 0) +#define RAC_CR1 0x04 /*offset*/ +#define RAC_UPB_SHFT 16 +#define RAC_LWB_SHFT 0 + +static void __cpuinit set_cpuregs(void) +{ + volatile unsigned int *cr0, *cr1; + cr0 = (volatile unsigned int *)(MIPS_BASE + RAC_CR0); + cr1 = (volatile unsigned int *)(MIPS_BASE + RAC_CR1); + + printk("board_livebox: setting cpu registers...\n"); + + *cr0 = RAC_I | RAC_PF_I | RAC_C_INV ; + *cr1 = (0x200 << RAC_UPB_SHFT); + printk("RAC changed: RAC_CR0 = 0x%0x, RAC_CR1 = 0x%0x\n", (int)*cr0, (int)*cr1); + + /*REGISTER 16, SELECT 0*/ + write_c0_config(0x80008083); + /*REGISTER 22, SELECT 0*/ + write_c0_diag(0xEF880000); + /*REGISTER 22, SELECT 5*/ + write_c0_diag5(0x30); +} + +/* + * early init callback + */ +void __init board_prom_init(void) +{ + u32 val; + + set_cpuregs(); + + /* read base address of boot chip select (0) */ + val = bcm_mpi_readl(MPI_CSBASE_REG(0)); + val &= MPI_CSBASE_BASE_MASK; + + /* assume board is a Livebox */ + memcpy(&board, bcm963xx_boards[0], sizeof(board)); + + /* setup pin multiplexing depending on board enabled device, + * this has to be done this early since PCI init is done + * inside arch_initcall */ + val = 0; + + if (board.has_pci) { + bcm63xx_pci_enabled = 1; + if (BCMCPU_IS_6348()) + val |= GPIO_MODE_6348_G2_PCI; + } + + if (board.has_pccard) { + if (BCMCPU_IS_6348()) + val |= GPIO_MODE_6348_G1_MII_PCCARD; + } + + if (board.has_enet0 && !board.enet0.use_internal_phy) { + if (BCMCPU_IS_6348()) + val |= GPIO_MODE_6348_G3_EXT_MII | + GPIO_MODE_6348_G0_EXT_MII; + } + + if (board.has_enet1 && !board.enet1.use_internal_phy) { + if (BCMCPU_IS_6348()) + val |= GPIO_MODE_6348_G3_EXT_MII | + GPIO_MODE_6348_G0_EXT_MII; + printk(KERN_INFO PFX "resetting gpio6 for eth1...\n"); + gpio_request(6, "dsp_eth_rst"); + gpio_direction_output(6, 0); + gpio_set_value(6, 1); + } + + bcm_gpio_writel(val, GPIO_MODE_REG); +} + +/* + * second stage init callback, good time to panic if we couldn't + * identify on which board we're running since early printk is working + */ +void __init board_setup(void) +{ + if (!board.name[0]) + panic("unable to detect bcm963xx board"); + printk(KERN_INFO PFX "board name: %s\n", board.name); + + /* make sure we're running on expected cpu */ + if (bcm63xx_get_cpu_id() != board.expected_cpu_id) + panic("unexpected CPU for bcm963xx board"); +} + +/* + * return board name for /proc/cpuinfo + */ +const char *board_get_name(void) +{ + return board.name; +} + +/* + * register & return a new board mac address + */ + +static int board_get_mac_address(u8 *mac) +{ + u8 default_mac[ETH_ALEN] = {0x00, 0x07, 0x3A, 0x00, 0x00, 0x00}; + u8 *p; + int count; + + memcpy(mac, default_mac, ETH_ALEN); + + p = mac + ETH_ALEN - 1; + count = mac_addr_used; + + while (count--) { + do { + (*p)++; + if (*p != 0) + break; + p--; + } while (p != mac); + } + + if (p == mac) { + printk(KERN_ERR PFX "unable to fetch mac address\n"); + return -ENODEV; + } + mac_addr_used++; + + return 0; +} + +static struct resource mtd_resources[] = { + { + .start = 0, /* filled at runtime */ + .end = 0, /* filled at runtime */ + .flags = IORESOURCE_MEM, + } +}; + +static struct platform_device mtd_dev = { + .name = "bcm963xx-flash", + .resource = mtd_resources, + .num_resources = ARRAY_SIZE(mtd_resources), +}; + +static struct resource gpiodev_resource = { + .start = 0xFFFFFFFF, +}; + +static struct gpio_led_platform_data bcm63xx_led_data; + +static struct platform_device bcm63xx_gpio_leds = { + .name = "leds-gpio", + .id = 0, + .dev.platform_data = &bcm63xx_led_data, +}; + +static struct gpio_buttons_platform_data bcm63xx_gpio_buttons_data = { + .poll_interval = 20, +}; + +static struct platform_device bcm63xx_gpio_buttons_device = { + .name = "gpio-buttons", + .id = 0, + .dev.platform_data = &bcm63xx_gpio_buttons_data, +}; + +/* + * third stage init callback, register all board devices. + */ +int __init board_register_devices(void) +{ + u32 val; + int led_count = 0; + + if (board.has_pccard) + bcm63xx_pcmcia_register(); + + if (board.has_enet0 && + !board_get_mac_address(board.enet0.mac_addr)) + bcm63xx_enet_register(0, &board.enet0); + + if (board.has_enet1 && + !board_get_mac_address(board.enet1.mac_addr)) + bcm63xx_enet_register(1, &board.enet1); + + if (board.has_ohci0) + bcm63xx_ohci_register(); + + if (board.has_dsp) + bcm63xx_dsp_register(&board.dsp); + + if (board.has_udc0) + bcm63xx_udc_register(); + + /* read base address of boot chip select (0) */ + val = bcm_mpi_readl(MPI_CSBASE_REG(0)); + val &= MPI_CSBASE_BASE_MASK; + printk(KERN_NOTICE "detected mtd start address 0x%08lx --> 0x1e400000...\n", (long unsigned int)val); + mtd_resources[0].start = 0x1e400000; + mtd_resources[0].end = 0x1EBFFFFF; + + platform_device_register(&mtd_dev); + + platform_device_register_simple("GPIODEV", 0, &gpiodev_resource, 1); + + /* count number of LEDs defined by this device */ + while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name) + led_count++; + + bcm63xx_led_data.num_leds = led_count; + bcm63xx_led_data.leds = board.leds; + + platform_device_register(&bcm63xx_gpio_leds); + + if (board.reset_buttons) { + bcm63xx_gpio_buttons_data.nbuttons = ARRAY_SIZE(board.reset_buttons); + bcm63xx_gpio_buttons_data.buttons = board.reset_buttons; + + platform_device_register(&bcm63xx_gpio_buttons_device); + } + + + return 0; +} +