blob: 6e5b6a955abec4c62cf9e26975fb4ca35810dc2c [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
Lennert Buytenhekecbea7a2005-10-29 16:28:27 +010018static inline unsigned long ixp2000_reg_read(volatile void *reg)
19{
20 return *((volatile unsigned long *)reg);
21}
22
Lennert Buytenhek917afce2005-09-15 13:00:25 +010023static inline void ixp2000_reg_write(volatile void *reg, unsigned long val)
24{
25 *((volatile unsigned long *)reg) = val;
26}
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28/*
29 * Boards may multiplex different devices on the 2nd channel of
30 * the slowport interface that each need different configuration
31 * settings. For example, the IXDP2400 uses channel 2 on the interface
32 * to access the CPLD, the switch fabric card, and the media card. Each
33 * one needs a different mode so drivers must save/restore the mode
34 * before and after each operation.
35 *
36 * acquire_slowport(&your_config);
37 * ...
38 * do slowport operations
39 * ...
40 * release_slowport();
41 *
42 * Note that while you have the slowport, you are holding a spinlock,
43 * so your code should be written as if you explicitly acquired a lock.
44 *
45 * The configuration only affects device 2 on the slowport, so the
46 * MTD map driver does not acquire/release the slowport.
47 */
48struct slowport_cfg {
49 unsigned long CCR; /* Clock divide */
50 unsigned long WTC; /* Write Timing Control */
51 unsigned long RTC; /* Read Timing Control */
52 unsigned long PCR; /* Protocol Control Register */
53 unsigned long ADC; /* Address/Data Width Control */
54};
55
56
57void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *);
58void ixp2000_release_slowport(struct slowport_cfg *);
59
60/*
61 * IXP2400 A0/A1 and IXP2800 A0/A1/A2 have broken slowport that requires
62 * tweaking of addresses in the MTD driver.
63 */
64static inline unsigned ixp2000_has_broken_slowport(void)
65{
Lennert Buytenhek44449bb2005-09-15 13:00:52 +010066 unsigned long id = *IXP2000_PRODUCT_ID;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK |
68 IXP2000_MIN_PROD_TYPE_MASK);
69 return (((id_prod ==
70 /* fixed in IXP2400-B0 */
71 (IXP2000_MAJ_PROD_TYPE_IXP2000 |
72 IXP2000_MIN_PROD_TYPE_IXP2400)) &&
73 ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
74 ((id_prod ==
75 /* fixed in IXP2800-B0 */
76 (IXP2000_MAJ_PROD_TYPE_IXP2000 |
77 IXP2000_MIN_PROD_TYPE_IXP2800)) &&
78 ((id & IXP2000_MAJ_REV_MASK) == 0)) ||
79 ((id_prod ==
80 /* fixed in IXP2850-B0 */
81 (IXP2000_MAJ_PROD_TYPE_IXP2000 |
82 IXP2000_MIN_PROD_TYPE_IXP2850)) &&
83 ((id & IXP2000_MAJ_REV_MASK) == 0)));
84}
85
86static inline unsigned int ixp2000_has_flash(void)
87{
88 return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM));
89}
90
91static inline unsigned int ixp2000_is_pcimaster(void)
92{
93 return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST));
94}
95
96void ixp2000_map_io(void);
Lennert Buytenhek28187f22005-07-10 19:44:53 +010097void ixp2000_uart_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098void ixp2000_init_irq(void);
99void ixp2000_init_time(unsigned long);
100unsigned long ixp2000_gettimeoffset(void);
101
102struct pci_sys_data;
103
Lennert Buytenhek8443b162005-04-29 21:58:15 +0100104u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105void ixp2000_pci_preinit(void);
106int ixp2000_pci_setup(int, struct pci_sys_data*);
107struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*);
108int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *);
109int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32);
110
111/*
112 * Several of the IXP2000 systems have banked flash so we need to extend the
113 * flash_platform_data structure with some private pointers
114 */
115struct ixp2000_flash_data {
116 struct flash_platform_data *platform_data;
117 int nr_banks;
118 unsigned long (*bank_setup)(unsigned long);
119};
120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121struct ixp2000_i2c_pins {
122 unsigned long sda_pin;
123 unsigned long scl_pin;
124};
125
Lennert Buytenhekc4982882005-06-24 20:54:35 +0100126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127#endif /* !__ASSEMBLY__ */