linux-old/arch/arm/mach-sa1100/badge4.c
<<
>>
Prefs
   1/*
   2 * linux/arch/arm/mach-sa1100/badge4.c
   3 *
   4 * BadgePAD 4 specific initialization
   5 *
   6 *   Tim Connors <connors@hpl.hp.com>
   7 *   Christopher Hoover <ch@hpl.hp.com>
   8 *
   9 * Copyright (C) 2002 Hewlett-Packard Company
  10 *
  11 * This program is free software; you can redistribute it and/or modify
  12 * it under the terms of the GNU General Public License version 2 as
  13 * published by the Free Software Foundation.
  14 *
  15 */
  16
  17#include <linux/module.h>
  18#include <linux/init.h>
  19#include <linux/kernel.h>
  20#include <linux/delay.h>
  21#include <linux/tty.h>
  22#include <linux/errno.h>
  23
  24#include <asm/hardware.h>
  25#include <asm/setup.h>
  26#include <asm/arch/irqs.h>
  27
  28#include <asm/mach/arch.h>
  29#include <asm/mach/map.h>
  30#include <asm/hardware/sa1111.h>
  31#include <asm/mach/serial_sa1100.h>
  32
  33#include "generic.h"
  34#include "sa1111.h"
  35
  36static int __init badge4_sa1111_init(void)
  37{
  38        int ret;
  39
  40        /*
  41         * Ensure that the memory bus request/grant signals are setup,
  42         * and the grant is held in its inactive state
  43         */
  44        sa1110_mb_disable();
  45
  46        /*
  47         * Probe for SA1111.
  48         */
  49        ret = sa1111_probe(BADGE4_SA1111_BASE);
  50        if (ret < 0)
  51                return ret;
  52
  53        /*
  54         * We found it.  Wake the chip up.
  55         */
  56        sa1111_wake();
  57
  58        /*
  59         * The SDRAM configuration of the SA1110 and the SA1111 must
  60         * match.  This is very important to ensure that SA1111 accesses
  61         * don't corrupt the SDRAM.  Note that this ungates the SA1111's
  62         * MBGNT signal, so we must have called sa1110_mb_disable()
  63         * beforehand.
  64         */
  65        sa1111_configure_smc(1,
  66                             FExtr(MDCNFG, MDCNFG_SA1110_DRAC0),
  67                             FExtr(MDCNFG, MDCNFG_SA1110_TDL0));
  68
  69        /*
  70         * We only need to turn on DCLK whenever we want to use the
  71         * DMA.  It can otherwise be held firmly in the off position.
  72         */
  73        SKPCR |= SKPCR_DCLKEN;
  74
  75        /*
  76         * Enable the SA1110 memory bus request and grant signals.
  77         */
  78        sa1110_mb_enable();
  79
  80        set_GPIO_IRQ_edge(BADGE4_GPIO_INT_1111, GPIO_RISING_EDGE);
  81        sa1111_init_irq(BADGE4_IRQ_GPIO_SA1111);
  82
  83        return 0;
  84}
  85
  86static int __init badge4_init(void)
  87{
  88        int ret;
  89
  90        if (!machine_is_badge4())
  91                return -ENODEV;
  92
  93        ret = badge4_sa1111_init();
  94        if (ret < 0)
  95                printk(KERN_ERR __FUNCTION__
  96                       ": SA-1111 initialization failed (%d)\n", ret);
  97
  98        /* N.B, according to rmk this is the singular place that GPDR
  99           should be set */
 100
 101        /* Video expansion */
 102        GPCR  = (BADGE4_GPIO_INT_VID | BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
 103                 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 | BADGE4_GPIO_LGP6 |
 104                 BADGE4_GPIO_LGP7 | BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
 105                 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
 106                 BADGE4_GPIO_GPC_VID);
 107        GPDR |= (BADGE4_GPIO_INT_VID | BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
 108                 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 | BADGE4_GPIO_LGP6 |
 109                 BADGE4_GPIO_LGP7 | BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
 110                 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
 111                 BADGE4_GPIO_GPC_VID);
 112
 113        /* SDRAM SPD i2c */
 114        GPCR  = (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
 115        GPDR |= (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
 116
 117        /* uart */
 118        GPCR  = (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
 119        GPDR |= (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
 120
 121        /* drives CPLD muxsel0 input */
 122        GPCR  = BADGE4_GPIO_MUXSEL0;
 123        GPDR |= BADGE4_GPIO_MUXSEL0;
 124
 125        /* test points */
 126        GPCR  = (BADGE4_GPIO_TESTPT_J7 | BADGE4_GPIO_TESTPT_J6 |
 127                 BADGE4_GPIO_TESTPT_J5);
 128        GPDR |= (BADGE4_GPIO_TESTPT_J7 | BADGE4_GPIO_TESTPT_J6 |
 129                 BADGE4_GPIO_TESTPT_J5);
 130
 131        /* drives CPLD sdram type inputs; this shouldn't be needed;
 132           bootloader left it this way. */
 133        GPDR |= (BADGE4_GPIO_SDTYP0 | BADGE4_GPIO_SDTYP1);
 134
 135        /* 5V supply rail. */
 136        GPCR  = BADGE4_GPIO_PCMEN5V;            /* initially off */
 137        GPDR |= BADGE4_GPIO_PCMEN5V;
 138
 139        /* drives SA1111 reset pin; this shouldn't be needed;
 140           bootloader left it this way. */
 141        GPSR  = BADGE4_GPIO_SA1111_NRST;
 142        GPDR |= BADGE4_GPIO_SA1111_NRST;
 143
 144        return 0;
 145}
 146
 147__initcall(badge4_init);
 148
 149
 150static unsigned badge4_5V_bitmap = 0;
 151
 152void badge4_set_5V(unsigned subsystem, int on)
 153{
 154        unsigned long flags;
 155        unsigned old_5V_bitmap;
 156
 157        local_irq_save(flags);
 158
 159        old_5V_bitmap = badge4_5V_bitmap;
 160
 161        if (on) {
 162                badge4_5V_bitmap |= subsystem;
 163        } else {
 164                badge4_5V_bitmap &= ~subsystem;
 165        }
 166
 167        /* detect on->off and off->on transitions */
 168        if ((!old_5V_bitmap) && (badge4_5V_bitmap)) {
 169                /* was off, now on */
 170                printk(KERN_INFO __FUNCTION__ ": enabling 5V supply rail\n");
 171                GPSR = BADGE4_GPIO_PCMEN5V;
 172        } else if ((old_5V_bitmap) && (!badge4_5V_bitmap)) {
 173                /* was on, now off */
 174                printk(KERN_INFO __FUNCTION__ ": disabling 5V supply rail\n");
 175                GPCR = BADGE4_GPIO_PCMEN5V;
 176        }
 177
 178        local_irq_restore(flags);
 179}
 180EXPORT_SYMBOL(badge4_set_5V);
 181
 182
 183static void __init
 184fixup_badge4(struct machine_desc *desc, struct param_struct *params,
 185            char **cmdline, struct meminfo *mi)
 186{
 187        /* nothing needed here */
 188}
 189
 190static struct map_desc badge4_io_desc[] __initdata = {
 191  /*  virtual    physical    length      domain   r w c b                  */
 192  {0xe8000000, 0x00000000, 0x02000000, DOMAIN_IO, 0,1,0,0},/* Flash bank 0 */
 193  {0xf1000000, 0x08000000, 0x00100000, DOMAIN_IO, 0,1,0,0},/* SRAM  bank 1 */
 194  {0xf2000000, 0x10000000, 0x00100000, DOMAIN_IO, 0,1,0,0},/* SRAM  bank 2 */
 195  {0xf4000000, 0x48000000, 0x00100000, DOMAIN_IO, 0,1,0,0},/* SA-1111      */
 196  LAST_DESC
 197};
 198
 199static void __init badge4_map_io(void)
 200{
 201        sa1100_map_io();
 202        iotable_init(badge4_io_desc);
 203
 204        sa1100_register_uart(0, 3);
 205        sa1100_register_uart(1, 1);
 206}
 207
 208MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
 209        BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
 210        BOOT_PARAMS(0xc0000100)
 211        FIXUP(fixup_badge4)
 212        MAPIO(badge4_map_io)
 213        INITIRQ(sa1100_init_irq)
 214MACHINE_END
 215
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.