This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-arm / arch-ixp2000 / platform.h
1 /*
2  * include/asm-arh/arch-ixp2000/platform.h
3  *
4  * Various bits of code used by platform-level code.
5  *
6  * Author: Deepak Saxena <dsaxena@plexity.net>
7  *
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.
13  */
14
15
16 #ifndef __ASSEMBLY__
17
18 /*
19  * The IXP2400 B0 silicon contains an errata that causes writes to 
20  * 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 happend twice. OR...if it's
23  * not a back-to-back trasaction, the read or write will generate 
24  * incorrect data.
25  *
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.
28  *
29  */
30 #if defined(CONFIG_ARCH_ENP2611) || defined(CONFIG_ARCH_IXDP2400) || defined(CONFIG_ARCH_IXDP2401)
31
32 #include <asm/system.h>         /* Pickup local_irq_ functions */
33
34 static inline void ixp2000_reg_write(volatile unsigned long *reg, unsigned long val)
35 {
36         volatile unsigned long dummy;
37         unsigned long flags;
38
39         local_irq_save(flags);
40         *reg = val;
41         barrier();
42         dummy = *reg;
43         local_irq_restore(flags);
44 }
45 #else
46 #define ixp2000_reg_write(reg, val) (*reg = val)
47 #endif  /* IXDP2400 || IXDP2401 */
48
49 /*
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 te media card.  Each 
54  * one needs a different mode so drivers must save/restore the mode 
55  * before and after each operation.  
56  *
57  * acquire_slowport(&your_config);
58  * ...
59  * do slowport operations
60  * ...
61  * release_slowport();
62  *
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.
65  *
66  * The configuration only affects device 2 on the slowport, so the
67  * MTD map driver does not acquire/release the slowport.  
68  */
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 */
75 };
76
77
78 void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
79 void ixp2000_release_slowport(struct slowport_cfg *);
80
81 /*
82  * IXP2400 A0/A1 and  IXP2800 A0/A1/A2 have broken slowport that requires
83  * tweaking of addresses in the MTD driver.
84  */
85 static inline unsigned ixp2000_has_broken_slowport(void)
86 {
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)));
105 }
106
107 static inline unsigned int ixp2000_has_flash(void)
108 {
109         return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
110 }
111
112 static inline unsigned int ixp2000_is_pcimaster(void)
113 {
114         return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
115 }
116
117 void ixp2000_map_io(void);
118 void ixp2000_init_irq(void);
119 void ixp2000_init_time(unsigned long);
120
121 struct pci_sys_data;
122
123 void ixp2000_pci_preinit(void);
124 int ixp2000_pci_setup(int, struct pci_sys_data*);
125 struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
126 int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
127 int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
128
129 /*
130  * Several of the IXP2000 systems have banked flash so we need to extend the
131  * flash_platform_data structure with some private pointers
132  */
133 struct ixp2000_flash_data {
134         struct flash_platform_data *platform_data;
135         int nr_banks;
136         unsigned long (*bank_setup)(unsigned long);
137 };
138
139 /*
140  * GPIO helper functions
141  */
142 #define GPIO_IN         0
143 #define GPIO_OUT        1
144
145 extern void gpio_line_config(int line, int style);
146
147 static inline int gpio_line_get(int line)
148 {
149         return (((*IXP2000_GPIO_PLR) >> line) & 1);
150 }
151
152 static inline void gpio_line_set(int line, int value)
153 {
154         if (value) 
155                 ixp2000_reg_write(IXP2000_GPIO_POSR, (1 << line));
156         else 
157                 ixp2000_reg_write(IXP2000_GPIO_POCR, (1 << line));
158 }
159
160 struct ixp2000_i2c_pins {
161         unsigned long sda_pin;
162         unsigned long scl_pin;
163 };
164
165 #endif /*  !__ASSEMBLY__ */