Path: blob/master/arch/arm/mach-footbridge/common.c
10817 views
/*1* linux/arch/arm/mach-footbridge/common.c2*3* Copyright (C) 1998-2000 Russell King, Dave Gilbert.4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License version 2 as7* published by the Free Software Foundation.8*/9#include <linux/module.h>10#include <linux/types.h>11#include <linux/mm.h>12#include <linux/ioport.h>13#include <linux/list.h>14#include <linux/init.h>15#include <linux/io.h>16#include <linux/spinlock.h>1718#include <asm/pgtable.h>19#include <asm/page.h>20#include <asm/irq.h>21#include <asm/mach-types.h>22#include <asm/setup.h>23#include <asm/hardware/dec21285.h>2425#include <asm/mach/irq.h>26#include <asm/mach/map.h>2728#include "common.h"2930unsigned int mem_fclk_21285 = 50000000;3132EXPORT_SYMBOL(mem_fclk_21285);3334static int __init early_fclk(char *arg)35{36mem_fclk_21285 = simple_strtoul(arg, NULL, 0);37return 0;38}3940early_param("mem_fclk_21285", early_fclk);4142static int __init parse_tag_memclk(const struct tag *tag)43{44mem_fclk_21285 = tag->u.memclk.fmemclk;45return 0;46}4748__tagtable(ATAG_MEMCLK, parse_tag_memclk);4950/*51* Footbridge IRQ translation table52* Converts from our IRQ numbers into FootBridge masks53*/54static const int fb_irq_mask[] = {55IRQ_MASK_UART_RX, /* 0 */56IRQ_MASK_UART_TX, /* 1 */57IRQ_MASK_TIMER1, /* 2 */58IRQ_MASK_TIMER2, /* 3 */59IRQ_MASK_TIMER3, /* 4 */60IRQ_MASK_IN0, /* 5 */61IRQ_MASK_IN1, /* 6 */62IRQ_MASK_IN2, /* 7 */63IRQ_MASK_IN3, /* 8 */64IRQ_MASK_DOORBELLHOST, /* 9 */65IRQ_MASK_DMA1, /* 10 */66IRQ_MASK_DMA2, /* 11 */67IRQ_MASK_PCI, /* 12 */68IRQ_MASK_SDRAMPARITY, /* 13 */69IRQ_MASK_I2OINPOST, /* 14 */70IRQ_MASK_PCI_ABORT, /* 15 */71IRQ_MASK_PCI_SERR, /* 16 */72IRQ_MASK_DISCARD_TIMER, /* 17 */73IRQ_MASK_PCI_DPERR, /* 18 */74IRQ_MASK_PCI_PERR, /* 19 */75};7677static void fb_mask_irq(struct irq_data *d)78{79*CSR_IRQ_DISABLE = fb_irq_mask[_DC21285_INR(d->irq)];80}8182static void fb_unmask_irq(struct irq_data *d)83{84*CSR_IRQ_ENABLE = fb_irq_mask[_DC21285_INR(d->irq)];85}8687static struct irq_chip fb_chip = {88.irq_ack = fb_mask_irq,89.irq_mask = fb_mask_irq,90.irq_unmask = fb_unmask_irq,91};9293static void __init __fb_init_irq(void)94{95unsigned int irq;9697/*98* setup DC21285 IRQs99*/100*CSR_IRQ_DISABLE = -1;101*CSR_FIQ_DISABLE = -1;102103for (irq = _DC21285_IRQ(0); irq < _DC21285_IRQ(20); irq++) {104irq_set_chip_and_handler(irq, &fb_chip, handle_level_irq);105set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);106}107}108109void __init footbridge_init_irq(void)110{111__fb_init_irq();112113if (!footbridge_cfn_mode())114return;115116if (machine_is_ebsa285())117/* The following is dependent on which slot118* you plug the Southbridge card into. We119* currently assume that you plug it into120* the right-hand most slot.121*/122isa_init_irq(IRQ_PCI);123124if (machine_is_cats())125isa_init_irq(IRQ_IN2);126127if (machine_is_netwinder())128isa_init_irq(IRQ_IN3);129}130131/*132* Common mapping for all systems. Note that the outbound write flush is133* commented out since there is a "No Fix" problem with it. Not mapping134* it means that we have extra bullet protection on our feet.135*/136static struct map_desc fb_common_io_desc[] __initdata = {137{138.virtual = ARMCSR_BASE,139.pfn = __phys_to_pfn(DC21285_ARMCSR_BASE),140.length = ARMCSR_SIZE,141.type = MT_DEVICE,142}, {143.virtual = XBUS_BASE,144.pfn = __phys_to_pfn(0x40000000),145.length = XBUS_SIZE,146.type = MT_DEVICE,147}148};149150/*151* The mapping when the footbridge is in host mode. We don't map any of152* this when we are in add-in mode.153*/154static struct map_desc ebsa285_host_io_desc[] __initdata = {155#if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST)156{157.virtual = PCIMEM_BASE,158.pfn = __phys_to_pfn(DC21285_PCI_MEM),159.length = PCIMEM_SIZE,160.type = MT_DEVICE,161}, {162.virtual = PCICFG0_BASE,163.pfn = __phys_to_pfn(DC21285_PCI_TYPE_0_CONFIG),164.length = PCICFG0_SIZE,165.type = MT_DEVICE,166}, {167.virtual = PCICFG1_BASE,168.pfn = __phys_to_pfn(DC21285_PCI_TYPE_1_CONFIG),169.length = PCICFG1_SIZE,170.type = MT_DEVICE,171}, {172.virtual = PCIIACK_BASE,173.pfn = __phys_to_pfn(DC21285_PCI_IACK),174.length = PCIIACK_SIZE,175.type = MT_DEVICE,176}, {177.virtual = PCIO_BASE,178.pfn = __phys_to_pfn(DC21285_PCI_IO),179.length = PCIO_SIZE,180.type = MT_DEVICE,181},182#endif183};184185void __init footbridge_map_io(void)186{187/*188* Set up the common mapping first; we need this to189* determine whether we're in host mode or not.190*/191iotable_init(fb_common_io_desc, ARRAY_SIZE(fb_common_io_desc));192193/*194* Now, work out what we've got to map in addition on this195* platform.196*/197if (footbridge_cfn_mode())198iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc));199}200201#ifdef CONFIG_FOOTBRIDGE_ADDIN202203static inline unsigned long fb_bus_sdram_offset(void)204{205return *CSR_PCISDRAMBASE & 0xfffffff0;206}207208/*209* These two functions convert virtual addresses to PCI addresses and PCI210* addresses to virtual addresses. Note that it is only legal to use these211* on memory obtained via get_zeroed_page or kmalloc.212*/213unsigned long __virt_to_bus(unsigned long res)214{215WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);216217return res + (fb_bus_sdram_offset() - PAGE_OFFSET);218}219EXPORT_SYMBOL(__virt_to_bus);220221unsigned long __bus_to_virt(unsigned long res)222{223res = res - (fb_bus_sdram_offset() - PAGE_OFFSET);224225WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);226227return res;228}229EXPORT_SYMBOL(__bus_to_virt);230231unsigned long __pfn_to_bus(unsigned long pfn)232{233return __pfn_to_phys(pfn) + (fb_bus_sdram_offset() - PHYS_OFFSET);234}235EXPORT_SYMBOL(__pfn_to_bus);236237unsigned long __bus_to_pfn(unsigned long bus)238{239return __phys_to_pfn(bus - (fb_bus_sdram_offset() - PHYS_OFFSET));240}241EXPORT_SYMBOL(__bus_to_pfn);242243#endif244245246