blob: 52ded516ea5caed2d85aff56000d2985af06daf8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/asm-arm/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 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.
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
34static 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 the 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 */
69struct 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
78void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
79void 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 */
85static 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
107static inline unsigned int ixp2000_has_flash(void)
108{
109 return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
110}
111
112static inline unsigned int ixp2000_is_pcimaster(void)
113{
114 return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
115}
116
117void ixp2000_map_io(void);
118void ixp2000_init_irq(void);
119void ixp2000_init_time(unsigned long);
120unsigned long ixp2000_gettimeoffset(void);
121
122struct pci_sys_data;
123
Lennert Buytenhek8443b162005-04-29 21:58:15 +0100124u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125void ixp2000_pci_preinit(void);
126int ixp2000_pci_setup(int, struct pci_sys_data*);
127struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
128int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
129int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
130
131/*
132 * Several of the IXP2000 systems have banked flash so we need to extend the
133 * flash_platform_data structure with some private pointers
134 */
135struct ixp2000_flash_data {
136 struct flash_platform_data *platform_data;
137 int nr_banks;
138 unsigned long (*bank_setup)(unsigned long);
139};
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141struct ixp2000_i2c_pins {
142 unsigned long sda_pin;
143 unsigned long scl_pin;
144};
145
Lennert Buytenhekc4982882005-06-24 20:54:35 +0100146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147#endif /* !__ASSEMBLY__ */