Path: blob/master/arch/arm/mach-ixp2000/include/mach/platform.h
10820 views
/*1* arch/arm/mach-ixp2000/include/mach/platform.h2*3* Various bits of code used by platform-level code.4*5* Author: Deepak Saxena <[email protected]>6*7* Copyright 2004 (c) MontaVista Software, Inc.8*9* This file is licensed under the terms of the GNU General Public10* License version 2. This program is licensed "as is" without any11* warranty of any kind, whether express or implied.12*/131415#ifndef __ASSEMBLY__1617static inline unsigned long ixp2000_reg_read(volatile void *reg)18{19return *((volatile unsigned long *)reg);20}2122static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)23{24*((volatile unsigned long *)reg) = val;25}2627/*28* On the IXP2400, we can't use XCB=000 due to chip bugs. We use29* XCB=101 instead, but that makes all I/O accesses bufferable. This30* is not a problem in general, but we do have to be slightly more31* careful because I/O writes are no longer automatically flushed out32* of the write buffer.33*34* In cases where we want to make sure that a write has been flushed35* out of the write buffer before we proceed, for example when masking36* a device interrupt before re-enabling IRQs in CPSR, we can use this37* function, ixp2000_reg_wrb, which performs a write, a readback, and38* issues a dummy instruction dependent on the value of the readback39* (mov rX, rX) to make sure that the readback has completed before we40* continue.41*/42static inline void ixp2000_reg_wrb(volatile void *reg, unsigned long val)43{44unsigned long dummy;4546*((volatile unsigned long *)reg) = val;4748dummy = *((volatile unsigned long *)reg);49__asm__ __volatile__("mov %0, %0" : "+r" (dummy));50}5152/*53* Boards may multiplex different devices on the 2nd channel of54* the slowport interface that each need different configuration55* settings. For example, the IXDP2400 uses channel 2 on the interface56* to access the CPLD, the switch fabric card, and the media card. Each57* one needs a different mode so drivers must save/restore the mode58* before and after each operation.59*60* acquire_slowport(&your_config);61* ...62* do slowport operations63* ...64* release_slowport();65*66* Note that while you have the slowport, you are holding a spinlock,67* so your code should be written as if you explicitly acquired a lock.68*69* The configuration only affects device 2 on the slowport, so the70* MTD map driver does not acquire/release the slowport.71*/72struct slowport_cfg {73unsigned long CCR; /* Clock divide */74unsigned long WTC; /* Write Timing Control */75unsigned long RTC; /* Read Timing Control */76unsigned long PCR; /* Protocol Control Register */77unsigned long ADC; /* Address/Data Width Control */78};798081void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);82void ixp2000_release_slowport(struct slowport_cfg *);8384/*85* IXP2400 A0/A1 and IXP2800 A0/A1/A2 have broken slowport that requires86* tweaking of addresses in the MTD driver.87*/88static inline unsigned ixp2000_has_broken_slowport(void)89{90unsigned long id = *IXP2000_PRODUCT_ID;91unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK |92IXP2000_MIN_PROD_TYPE_MASK);93return (((id_prod ==94/* fixed in IXP2400-B0 */95(IXP2000_MAJ_PROD_TYPE_IXP2000 |96IXP2000_MIN_PROD_TYPE_IXP2400)) &&97((id & IXP2000_MAJ_REV_MASK) == 0)) ||98((id_prod ==99/* fixed in IXP2800-B0 */100(IXP2000_MAJ_PROD_TYPE_IXP2000 |101IXP2000_MIN_PROD_TYPE_IXP2800)) &&102((id & IXP2000_MAJ_REV_MASK) == 0)) ||103((id_prod ==104/* fixed in IXP2850-B0 */105(IXP2000_MAJ_PROD_TYPE_IXP2000 |106IXP2000_MIN_PROD_TYPE_IXP2850)) &&107((id & IXP2000_MAJ_REV_MASK) == 0)));108}109110static inline unsigned int ixp2000_has_flash(void)111{112return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));113}114115static inline unsigned int ixp2000_is_pcimaster(void)116{117return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));118}119120void ixp2000_map_io(void);121void ixp2000_uart_init(void);122void ixp2000_init_irq(void);123void ixp2000_init_time(unsigned long);124unsigned long ixp2000_gettimeoffset(void);125126struct pci_sys_data;127128u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);129void ixp2000_pci_preinit(void);130int ixp2000_pci_setup(int, struct pci_sys_data*);131struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);132int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);133int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);134135/*136* Several of the IXP2000 systems have banked flash so we need to extend the137* flash_platform_data structure with some private pointers138*/139struct ixp2000_flash_data {140struct flash_platform_data *platform_data;141int nr_banks;142unsigned long (*bank_setup)(unsigned long);143};144145struct ixp2000_i2c_pins {146unsigned long sda_pin;147unsigned long scl_pin;148};149150151#endif /* !__ASSEMBLY__ */152153154