Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / asm-arm / arch-ixp2000 / platform.h
blob509e44d528d82c7a7de604b0da7743b88f91d0e2
1 /*
2 * include/asm-arm/arch-ixp2000/platform.h
4 * Various bits of code used by platform-level code.
6 * Author: Deepak Saxena <dsaxena@plexity.net>
8 * Copyright 2004 (c) MontaVista Software, Inc.
9 *
10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any
12 * warranty of any kind, whether express or implied.
16 #ifndef __ASSEMBLY__
19 * The IXP2400 B0 silicon contains an erratum (#66) that causes writes
20 * to on-chip I/O register to not complete fully. What this means is
21 * that if you have a write to on-chip I/O followed by a back-to-back
22 * read or write, the first write will happen twice. OR...if it's
23 * not a back-to-back transaction, the read or write will generate
24 * incorrect data.
26 * The official work around for this is to set the on-chip I/O regions
27 * as XCB=101 and then force a read-back from the register.
30 #if defined(CONFIG_ARCH_ENP2611) || defined(CONFIG_ARCH_IXDP2400) || defined(CONFIG_ARCH_IXDP2401)
32 #include <asm/system.h> /* Pickup local_irq_ functions */
34 static inline void ixp2000_reg_write(volatile unsigned long *reg, unsigned long val)
36 volatile unsigned long dummy;
37 unsigned long flags;
39 local_irq_save(flags);
40 *reg = val;
41 barrier();
42 dummy = *reg;
43 local_irq_restore(flags);
45 #else
46 #define ixp2000_reg_write(reg, val) (*reg = val)
47 #endif /* IXDP2400 || IXDP2401 */
50 * Boards may multiplex different devices on the 2nd channel of
51 * the slowport interface that each need different configuration
52 * settings. For example, the IXDP2400 uses channel 2 on the interface
53 * to access the CPLD, the switch fabric card, and the media card. Each
54 * one needs a different mode so drivers must save/restore the mode
55 * before and after each operation.
57 * acquire_slowport(&your_config);
58 * ...
59 * do slowport operations
60 * ...
61 * release_slowport();
63 * Note that while you have the slowport, you are holding a spinlock,
64 * so your code should be written as if you explicitly acquired a lock.
66 * The configuration only affects device 2 on the slowport, so the
67 * MTD map driver does not acquire/release the slowport.
69 struct slowport_cfg {
70 unsigned long CCR; /* Clock divide */
71 unsigned long WTC; /* Write Timing Control */
72 unsigned long RTC; /* Read Timing Control */
73 unsigned long PCR; /* Protocol Control Register */
74 unsigned long ADC; /* Address/Data Width Control */
78 void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
79 void ixp2000_release_slowport(struct slowport_cfg *);
82 * IXP2400 A0/A1 and IXP2800 A0/A1/A2 have broken slowport that requires
83 * tweaking of addresses in the MTD driver.
85 static inline unsigned ixp2000_has_broken_slowport(void)
87 unsigned long id = *IXP2000_PROD_ID;
88 unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK |
89 IXP2000_MIN_PROD_TYPE_MASK);
90 return (((id_prod ==
91 /* fixed in IXP2400-B0 */
92 (IXP2000_MAJ_PROD_TYPE_IXP2000 |
93 IXP2000_MIN_PROD_TYPE_IXP2400)) &&
94 ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
95 ((id_prod ==
96 /* fixed in IXP2800-B0 */
97 (IXP2000_MAJ_PROD_TYPE_IXP2000 |
98 IXP2000_MIN_PROD_TYPE_IXP2800)) &&
99 ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
100 ((id_prod ==
101 /* fixed in IXP2850-B0 */
102 (IXP2000_MAJ_PROD_TYPE_IXP2000 |
103 IXP2000_MIN_PROD_TYPE_IXP2850)) &&
104 ((id & IXP2000_MAJ_REV_MASK) == 0)));
107 static inline unsigned int ixp2000_has_flash(void)
109 return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
112 static inline unsigned int ixp2000_is_pcimaster(void)
114 return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
117 void ixp2000_map_io(void);
118 void ixp2000_init_irq(void);
119 void ixp2000_init_time(unsigned long);
120 unsigned long ixp2000_gettimeoffset(void);
122 struct pci_sys_data;
124 void ixp2000_pci_preinit(void);
125 int ixp2000_pci_setup(int, struct pci_sys_data*);
126 struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
127 int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
128 int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
131 * Several of the IXP2000 systems have banked flash so we need to extend the
132 * flash_platform_data structure with some private pointers
134 struct ixp2000_flash_data {
135 struct flash_platform_data *platform_data;
136 int nr_banks;
137 unsigned long (*bank_setup)(unsigned long);
141 * GPIO helper functions
143 #define GPIO_IN 0
144 #define GPIO_OUT 1
146 extern void gpio_line_config(int line, int style);
148 static inline int gpio_line_get(int line)
150 return (((*IXP2000_GPIO_PLR) >> line) & 1);
153 static inline void gpio_line_set(int line, int value)
155 if (value)
156 ixp2000_reg_write(IXP2000_GPIO_POSR, (1 << line));
157 else
158 ixp2000_reg_write(IXP2000_GPIO_POCR, (1 << line));
161 struct ixp2000_i2c_pins {
162 unsigned long sda_pin;
163 unsigned long scl_pin;
166 #endif /* !__ASSEMBLY__ */