| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 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 Buytenhek | ecbea7a | 2005-10-29 16:28:27 +0100 | [diff] [blame] | 18 | static inline unsigned long ixp2000_reg_read(volatile void *reg) | 
 | 19 | { | 
 | 20 | 	return *((volatile unsigned long *)reg); | 
 | 21 | } | 
 | 22 |  | 
| Lennert Buytenhek | 917afce | 2005-09-15 13:00:25 +0100 | [diff] [blame] | 23 | static inline void ixp2000_reg_write(volatile void *reg, unsigned long val) | 
 | 24 | { | 
 | 25 | 	*((volatile unsigned long *)reg) = val; | 
 | 26 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 |  | 
 | 28 | /* | 
| Lennert Buytenhek | b4a1f67 | 2005-10-29 16:28:28 +0100 | [diff] [blame] | 29 |  * On the IXP2400, we can't use XCB=000 due to chip bugs.  We use | 
 | 30 |  * XCB=101 instead, but that makes all I/O accesses bufferable.  This | 
 | 31 |  * is not a problem in general, but we do have to be slightly more | 
 | 32 |  * careful because I/O writes are no longer automatically flushed out | 
 | 33 |  * of the write buffer. | 
 | 34 |  * | 
 | 35 |  * In cases where we want to make sure that a write has been flushed | 
 | 36 |  * out of the write buffer before we proceed, for example when masking | 
 | 37 |  * a device interrupt before re-enabling IRQs in CPSR, we can use this | 
 | 38 |  * function, ixp2000_reg_wrb, which performs a write, a readback, and | 
 | 39 |  * issues a dummy instruction dependent on the value of the readback | 
 | 40 |  * (mov rX, rX) to make sure that the readback has completed before we | 
 | 41 |  * continue. | 
 | 42 |  */ | 
 | 43 | static inline void ixp2000_reg_wrb(volatile void *reg, unsigned long val) | 
 | 44 | { | 
 | 45 | 	unsigned long dummy; | 
 | 46 |  | 
 | 47 | 	*((volatile unsigned long *)reg) = val; | 
 | 48 |  | 
 | 49 | 	dummy = *((volatile unsigned long *)reg); | 
 | 50 | 	__asm__ __volatile__("mov %0, %0" : "+r" (dummy)); | 
 | 51 | } | 
 | 52 |  | 
 | 53 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 |  * Boards may multiplex different devices on the 2nd channel of  | 
 | 55 |  * the slowport interface that each need different configuration  | 
 | 56 |  * settings.  For example, the IXDP2400 uses channel 2 on the interface  | 
 | 57 |  * to access the CPLD, the switch fabric card, and the media card.  Each | 
 | 58 |  * one needs a different mode so drivers must save/restore the mode  | 
 | 59 |  * before and after each operation.   | 
 | 60 |  * | 
 | 61 |  * acquire_slowport(&your_config); | 
 | 62 |  * ... | 
 | 63 |  * do slowport operations | 
 | 64 |  * ... | 
 | 65 |  * release_slowport(); | 
 | 66 |  * | 
 | 67 |  * Note that while you have the slowport, you are holding a spinlock, | 
 | 68 |  * so your code should be written as if you explicitly acquired a lock. | 
 | 69 |  * | 
 | 70 |  * The configuration only affects device 2 on the slowport, so the | 
 | 71 |  * MTD map driver does not acquire/release the slowport.   | 
 | 72 |  */ | 
 | 73 | struct slowport_cfg { | 
 | 74 | 	unsigned long CCR;	/* Clock divide */ | 
 | 75 | 	unsigned long WTC;	/* Write Timing Control */ | 
 | 76 | 	unsigned long RTC;	/* Read Timing Control */ | 
 | 77 | 	unsigned long PCR;	/* Protocol Control Register */ | 
 | 78 | 	unsigned long ADC;	/* Address/Data Width Control */ | 
 | 79 | }; | 
 | 80 |  | 
 | 81 |  | 
 | 82 | void ixp2000_acquire_slowport(struct slowport_cfg *, struct slowport_cfg *); | 
 | 83 | void ixp2000_release_slowport(struct slowport_cfg *); | 
 | 84 |  | 
 | 85 | /* | 
 | 86 |  * IXP2400 A0/A1 and  IXP2800 A0/A1/A2 have broken slowport that requires | 
 | 87 |  * tweaking of addresses in the MTD driver. | 
 | 88 |  */ | 
 | 89 | static inline unsigned ixp2000_has_broken_slowport(void) | 
 | 90 | { | 
| Lennert Buytenhek | 44449bb | 2005-09-15 13:00:52 +0100 | [diff] [blame] | 91 | 	unsigned long id = *IXP2000_PRODUCT_ID; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | 	unsigned long id_prod = id & (IXP2000_MAJ_PROD_TYPE_MASK | | 
 | 93 | 				      IXP2000_MIN_PROD_TYPE_MASK); | 
 | 94 | 	return (((id_prod == | 
 | 95 | 		  /* fixed in IXP2400-B0 */ | 
 | 96 | 		  (IXP2000_MAJ_PROD_TYPE_IXP2000 | | 
 | 97 | 		   IXP2000_MIN_PROD_TYPE_IXP2400)) && | 
 | 98 | 		 ((id & IXP2000_MAJ_REV_MASK) == 0)) || | 
 | 99 | 		((id_prod == | 
 | 100 | 		  /* fixed in IXP2800-B0 */ | 
 | 101 | 		  (IXP2000_MAJ_PROD_TYPE_IXP2000 | | 
 | 102 | 		   IXP2000_MIN_PROD_TYPE_IXP2800)) && | 
 | 103 | 		 ((id & IXP2000_MAJ_REV_MASK) == 0)) || | 
 | 104 | 		((id_prod == | 
 | 105 | 		  /* fixed in IXP2850-B0 */ | 
 | 106 | 		  (IXP2000_MAJ_PROD_TYPE_IXP2000 | | 
 | 107 | 		   IXP2000_MIN_PROD_TYPE_IXP2850)) && | 
 | 108 | 		 ((id & IXP2000_MAJ_REV_MASK) == 0))); | 
 | 109 | } | 
 | 110 |  | 
 | 111 | static inline unsigned int ixp2000_has_flash(void) | 
 | 112 | { | 
 | 113 | 	return ((*IXP2000_STRAP_OPTIONS) & (CFG_BOOT_PROM)); | 
 | 114 | } | 
 | 115 |  | 
 | 116 | static inline unsigned int ixp2000_is_pcimaster(void) | 
 | 117 | { | 
 | 118 | 	return ((*IXP2000_STRAP_OPTIONS) & (CFG_PCI_BOOT_HOST)); | 
 | 119 | } | 
 | 120 |  | 
 | 121 | void ixp2000_map_io(void); | 
| Lennert Buytenhek | 28187f2 | 2005-07-10 19:44:53 +0100 | [diff] [blame] | 122 | void ixp2000_uart_init(void); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | void ixp2000_init_irq(void); | 
 | 124 | void ixp2000_init_time(unsigned long); | 
 | 125 | unsigned long ixp2000_gettimeoffset(void); | 
 | 126 |  | 
 | 127 | struct pci_sys_data; | 
 | 128 |  | 
| Lennert Buytenhek | 8443b16 | 2005-04-29 21:58:15 +0100 | [diff] [blame] | 129 | u32 *ixp2000_pci_config_addr(unsigned int bus, unsigned int devfn, int where); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | void ixp2000_pci_preinit(void); | 
 | 131 | int ixp2000_pci_setup(int, struct pci_sys_data*); | 
 | 132 | struct pci_bus* ixp2000_pci_scan_bus(int, struct pci_sys_data*); | 
 | 133 | int ixp2000_pci_read_config(struct pci_bus*, unsigned int, int, int, u32 *); | 
 | 134 | int ixp2000_pci_write_config(struct pci_bus*, unsigned int, int, int, u32); | 
 | 135 |  | 
 | 136 | /* | 
 | 137 |  * Several of the IXP2000 systems have banked flash so we need to extend the | 
 | 138 |  * flash_platform_data structure with some private pointers | 
 | 139 |  */ | 
 | 140 | struct ixp2000_flash_data { | 
 | 141 | 	struct flash_platform_data *platform_data; | 
 | 142 | 	int nr_banks; | 
 | 143 | 	unsigned long (*bank_setup)(unsigned long); | 
 | 144 | }; | 
 | 145 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | struct ixp2000_i2c_pins { | 
 | 147 | 	unsigned long sda_pin; | 
 | 148 | 	unsigned long scl_pin; | 
 | 149 | }; | 
 | 150 |  | 
| Lennert Buytenhek | c498288 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 151 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | #endif /*  !__ASSEMBLY__ */ |