linux/arch/arm/mach-iop32x/n2100.c
<<
>>
Prefs
   1/*
   2 * arch/arm/mach-iop32x/n2100.c
   3 *
   4 * Board support code for the Thecus N2100 platform.
   5 *
   6 * Author: Rory Bolt <rorybolt@pacbell.net>
   7 * Copyright (C) 2002 Rory Bolt
   8 * Copyright 2003 (c) MontaVista, Software, Inc.
   9 * Copyright (C) 2004 Intel Corp.
  10 *
  11 * This program is free software; you can redistribute it and/or modify it
  12 * under the terms of the GNU General Public License as published by the
  13 * Free Software Foundation; either version 2 of the License, or (at your
  14 * option) any later version.
  15 */
  16
  17#include <linux/mm.h>
  18#include <linux/init.h>
  19#include <linux/f75375s.h>
  20#include <linux/leds-pca9532.h>
  21#include <linux/delay.h>
  22#include <linux/kernel.h>
  23#include <linux/pci.h>
  24#include <linux/pm.h>
  25#include <linux/string.h>
  26#include <linux/serial_core.h>
  27#include <linux/serial_8250.h>
  28#include <linux/mtd/physmap.h>
  29#include <linux/i2c.h>
  30#include <linux/platform_device.h>
  31#include <linux/reboot.h>
  32#include <linux/io.h>
  33#include <mach/hardware.h>
  34#include <asm/irq.h>
  35#include <asm/mach/arch.h>
  36#include <asm/mach/map.h>
  37#include <asm/mach/pci.h>
  38#include <asm/mach/time.h>
  39#include <asm/mach-types.h>
  40#include <asm/page.h>
  41#include <asm/pgtable.h>
  42#include <mach/time.h>
  43
  44/*
  45 * N2100 timer tick configuration.
  46 */
  47static void __init n2100_timer_init(void)
  48{
  49        /* 33.000 MHz crystal.  */
  50        iop_init_time(198000000);
  51}
  52
  53
  54/*
  55 * N2100 I/O.
  56 */
  57static struct map_desc n2100_io_desc[] __initdata = {
  58        {       /* on-board devices */
  59                .virtual        = N2100_UART,
  60                .pfn            = __phys_to_pfn(N2100_UART),
  61                .length         = 0x00100000,
  62                .type           = MT_DEVICE
  63        },
  64};
  65
  66void __init n2100_map_io(void)
  67{
  68        iop3xx_map_io();
  69        iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc));
  70}
  71
  72
  73/*
  74 * N2100 PCI.
  75 */
  76static int __init
  77n2100_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  78{
  79        int irq;
  80
  81        if (PCI_SLOT(dev->devfn) == 1) {
  82                /* RTL8110SB #1 */
  83                irq = IRQ_IOP32X_XINT0;
  84        } else if (PCI_SLOT(dev->devfn) == 2) {
  85                /* RTL8110SB #2 */
  86                irq = IRQ_IOP32X_XINT3;
  87        } else if (PCI_SLOT(dev->devfn) == 3) {
  88                /* Sil3512 */
  89                irq = IRQ_IOP32X_XINT2;
  90        } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
  91                /* VT6212 INTA */
  92                irq = IRQ_IOP32X_XINT1;
  93        } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
  94                /* VT6212 INTB */
  95                irq = IRQ_IOP32X_XINT0;
  96        } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
  97                /* VT6212 INTC */
  98                irq = IRQ_IOP32X_XINT2;
  99        } else if (PCI_SLOT(dev->devfn) == 5) {
 100                /* Mini-PCI slot */
 101                irq = IRQ_IOP32X_XINT3;
 102        } else {
 103                printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
 104                        "device PCI:%d:%d:%d\n", dev->bus->number,
 105                        PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
 106                irq = -1;
 107        }
 108
 109        return irq;
 110}
 111
 112static struct hw_pci n2100_pci __initdata = {
 113        .nr_controllers = 1,
 114        .ops            = &iop3xx_ops,
 115        .setup          = iop3xx_pci_setup,
 116        .preinit        = iop3xx_pci_preinit,
 117        .map_irq        = n2100_pci_map_irq,
 118};
 119
 120/*
 121 * Both r8169 chips on the n2100 exhibit PCI parity problems.  Set
 122 * the ->broken_parity_status flag for both ports so that the r8169
 123 * driver knows it should ignore error interrupts.
 124 */
 125static void n2100_fixup_r8169(struct pci_dev *dev)
 126{
 127        if (dev->bus->number == 0 &&
 128            (dev->devfn == PCI_DEVFN(1, 0) ||
 129             dev->devfn == PCI_DEVFN(2, 0)))
 130                dev->broken_parity_status = 1;
 131}
 132DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
 133
 134static int __init n2100_pci_init(void)
 135{
 136        if (machine_is_n2100())
 137                pci_common_init(&n2100_pci);
 138
 139        return 0;
 140}
 141
 142subsys_initcall(n2100_pci_init);
 143
 144
 145/*
 146 * N2100 machine initialisation.
 147 */
 148static struct physmap_flash_data n2100_flash_data = {
 149        .width          = 2,
 150};
 151
 152static struct resource n2100_flash_resource = {
 153        .start          = 0xf0000000,
 154        .end            = 0xf0ffffff,
 155        .flags          = IORESOURCE_MEM,
 156};
 157
 158static struct platform_device n2100_flash_device = {
 159        .name           = "physmap-flash",
 160        .id             = 0,
 161        .dev            = {
 162                .platform_data  = &n2100_flash_data,
 163        },
 164        .num_resources  = 1,
 165        .resource       = &n2100_flash_resource,
 166};
 167
 168
 169static struct plat_serial8250_port n2100_serial_port[] = {
 170        {
 171                .mapbase        = N2100_UART,
 172                .membase        = (char *)N2100_UART,
 173                .irq            = 0,
 174                .flags          = UPF_SKIP_TEST | UPF_AUTO_IRQ | UPF_SHARE_IRQ,
 175                .iotype         = UPIO_MEM,
 176                .regshift       = 0,
 177                .uartclk        = 1843200,
 178        },
 179        { },
 180};
 181
 182static struct resource n2100_uart_resource = {
 183        .start          = N2100_UART,
 184        .end            = N2100_UART + 7,
 185        .flags          = IORESOURCE_MEM,
 186};
 187
 188static struct platform_device n2100_serial_device = {
 189        .name           = "serial8250",
 190        .id             = PLAT8250_DEV_PLATFORM,
 191        .dev            = {
 192                .platform_data          = n2100_serial_port,
 193        },
 194        .num_resources  = 1,
 195        .resource       = &n2100_uart_resource,
 196};
 197
 198static struct f75375s_platform_data n2100_f75375s = {
 199        .pwm            = { 255, 255 },
 200        .pwm_enable = { 0, 0 },
 201};
 202
 203static struct pca9532_platform_data n2100_leds = {
 204        .leds = {
 205        {       .name = "n2100:red:satafail0",
 206                .state = PCA9532_OFF,
 207                .type = PCA9532_TYPE_LED,
 208        },
 209        {       .name = "n2100:red:satafail1",
 210                .state = PCA9532_OFF,
 211                .type = PCA9532_TYPE_LED,
 212        },
 213        {       .name = "n2100:blue:usb",
 214                .state = PCA9532_OFF,
 215                .type = PCA9532_TYPE_LED,
 216        },
 217        {       .type = PCA9532_TYPE_NONE },
 218
 219        {       .type = PCA9532_TYPE_NONE },
 220        {       .type = PCA9532_TYPE_NONE },
 221        {       .type = PCA9532_TYPE_NONE },
 222        {       .name = "n2100:red:usb",
 223                .state = PCA9532_OFF,
 224                .type = PCA9532_TYPE_LED,
 225        },
 226
 227        {       .type = PCA9532_TYPE_NONE }, /* power OFF gpio */
 228        {       .type = PCA9532_TYPE_NONE }, /* reset gpio */
 229        {       .type = PCA9532_TYPE_NONE },
 230        {       .type = PCA9532_TYPE_NONE },
 231
 232        {       .type = PCA9532_TYPE_NONE },
 233        {       .name = "n2100:orange:system",
 234                .state = PCA9532_OFF,
 235                .type = PCA9532_TYPE_LED,
 236        },
 237        {       .name = "n2100:red:system",
 238                .state = PCA9532_OFF,
 239                .type = PCA9532_TYPE_LED,
 240        },
 241        {       .name = "N2100 beeper"  ,
 242                .state =  PCA9532_OFF,
 243                .type = PCA9532_TYPE_N2100_BEEP,
 244        },
 245        },
 246        .psc = { 0, 0 },
 247        .pwm = { 0, 0 },
 248};
 249
 250static struct i2c_board_info __initdata n2100_i2c_devices[] = {
 251        {
 252                I2C_BOARD_INFO("rs5c372b", 0x32),
 253        },
 254        {
 255                I2C_BOARD_INFO("f75375", 0x2e),
 256                .platform_data = &n2100_f75375s,
 257        },
 258        {
 259                I2C_BOARD_INFO("pca9532", 0x60),
 260                .platform_data = &n2100_leds,
 261        },
 262};
 263
 264/*
 265 * Pull PCA9532 GPIO #8 low to power off the machine.
 266 */
 267static void n2100_power_off(void)
 268{
 269        local_irq_disable();
 270
 271        /* Start condition, I2C address of PCA9532, write transaction.  */
 272        *IOP3XX_IDBR0 = 0xc0;
 273        *IOP3XX_ICR0 = 0xe9;
 274        mdelay(1);
 275
 276        /* Write address 0x08.  */
 277        *IOP3XX_IDBR0 = 0x08;
 278        *IOP3XX_ICR0 = 0xe8;
 279        mdelay(1);
 280
 281        /* Write data 0x01, stop condition.  */
 282        *IOP3XX_IDBR0 = 0x01;
 283        *IOP3XX_ICR0 = 0xea;
 284
 285        while (1)
 286                ;
 287}
 288
 289static void n2100_restart(char mode, const char *cmd)
 290{
 291        gpio_line_set(N2100_HARDWARE_RESET, GPIO_LOW);
 292        gpio_line_config(N2100_HARDWARE_RESET, GPIO_OUT);
 293        while (1)
 294                ;
 295}
 296
 297
 298static struct timer_list power_button_poll_timer;
 299
 300static void power_button_poll(unsigned long dummy)
 301{
 302        if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
 303                ctrl_alt_del();
 304                return;
 305        }
 306
 307        power_button_poll_timer.expires = jiffies + (HZ / 10);
 308        add_timer(&power_button_poll_timer);
 309}
 310
 311
 312static void __init n2100_init_machine(void)
 313{
 314        platform_device_register(&iop3xx_i2c0_device);
 315        platform_device_register(&n2100_flash_device);
 316        platform_device_register(&n2100_serial_device);
 317        platform_device_register(&iop3xx_dma_0_channel);
 318        platform_device_register(&iop3xx_dma_1_channel);
 319
 320        i2c_register_board_info(0, n2100_i2c_devices,
 321                ARRAY_SIZE(n2100_i2c_devices));
 322
 323        pm_power_off = n2100_power_off;
 324
 325        init_timer(&power_button_poll_timer);
 326        power_button_poll_timer.function = power_button_poll;
 327        power_button_poll_timer.expires = jiffies + (HZ / 10);
 328        add_timer(&power_button_poll_timer);
 329}
 330
 331MACHINE_START(N2100, "Thecus N2100")
 332        /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
 333        .atag_offset    = 0x100,
 334        .map_io         = n2100_map_io,
 335        .init_irq       = iop32x_init_irq,
 336        .init_time      = n2100_timer_init,
 337        .init_machine   = n2100_init_machine,
 338        .restart        = n2100_restart,
 339MACHINE_END
 340