aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/pci/pci-sh7751.c
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-03-11 02:41:51 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-04-16 03:00:12 -0400
commitb8b47bfbe4eb1ae0e6891e49c86a5f4fb00413be (patch)
treeea54e39235d29b7f96fd24611ff507dfdaa1d178 /arch/sh/drivers/pci/pci-sh7751.c
parent3ee8da87ba6151ec91b2b8bbd27633bb248ea0d5 (diff)
sh: pass along struct pci_channel
These patches rework the pci code for the sh architecture. Currently each board implements some kind of ioport to address mapping. Some boards use generic_io_base others try passing addresses as io ports. This is the first set of patches that try to unify the pci code as much as possible to avoid duplicated code. This will in the end lead to fewer lines board specific code and more generic code. This patch makes sure a struct pci_channel pointer is passed along to various pci functions such as pci_read_reg(), pci_write_reg(), pci_fixup_pcic(), sh7751_pcic_init() and sh7780_pcic_init(). Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/drivers/pci/pci-sh7751.c')
-rw-r--r--arch/sh/drivers/pci/pci-sh7751.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/arch/sh/drivers/pci/pci-sh7751.c b/arch/sh/drivers/pci/pci-sh7751.c
index 3065eb184f01..9c2c01490d62 100644
--- a/arch/sh/drivers/pci/pci-sh7751.c
+++ b/arch/sh/drivers/pci/pci-sh7751.c
@@ -40,21 +40,22 @@ static int __init sh7751_pci_init(void)
40 pr_debug("PCI: Starting intialization.\n"); 40 pr_debug("PCI: Starting intialization.\n");
41 41
42 /* check for SH7751/SH7751R hardware */ 42 /* check for SH7751/SH7751R hardware */
43 id = pci_read_reg(SH7751_PCICONF0); 43 id = pci_read_reg(NULL, SH7751_PCICONF0);
44 if (id != ((SH7751_DEVICE_ID << 16) | SH7751_VENDOR_ID) && 44 if (id != ((SH7751_DEVICE_ID << 16) | SH7751_VENDOR_ID) &&
45 id != ((SH7751R_DEVICE_ID << 16) | SH7751_VENDOR_ID)) { 45 id != ((SH7751R_DEVICE_ID << 16) | SH7751_VENDOR_ID)) {
46 pr_debug("PCI: This is not an SH7751(R) (%x)\n", id); 46 pr_debug("PCI: This is not an SH7751(R) (%x)\n", id);
47 return -ENODEV; 47 return -ENODEV;
48 } 48 }
49 49
50 if ((ret = sh4_pci_check_direct()) != 0) 50 if ((ret = sh4_pci_check_direct(NULL)) != 0)
51 return ret; 51 return ret;
52 52
53 return pcibios_init_platform(); 53 return pcibios_init_platform();
54} 54}
55subsys_initcall(sh7751_pci_init); 55subsys_initcall(sh7751_pci_init);
56 56
57static int __init __area_sdram_check(unsigned int area) 57static int __init __area_sdram_check(struct pci_channel *chan,
58 unsigned int area)
58{ 59{
59 u32 word; 60 u32 word;
60 61
@@ -65,7 +66,7 @@ static int __init __area_sdram_check(unsigned int area)
65 area, word); 66 area, word);
66 return 0; 67 return 0;
67 } 68 }
68 pci_write_reg(word, SH4_PCIBCR1); 69 pci_write_reg(chan, word, SH4_PCIBCR1);
69 70
70 word = (u16)ctrl_inw(SH7751_BCR2); 71 word = (u16)ctrl_inw(SH7751_BCR2);
71 /* check BCR2 for 32bit SDRAM interface*/ 72 /* check BCR2 for 32bit SDRAM interface*/
@@ -74,12 +75,13 @@ static int __init __area_sdram_check(unsigned int area)
74 area, word); 75 area, word);
75 return 0; 76 return 0;
76 } 77 }
77 pci_write_reg(word, SH4_PCIBCR2); 78 pci_write_reg(chan, word, SH4_PCIBCR2);
78 79
79 return 1; 80 return 1;
80} 81}
81 82
82int __init sh7751_pcic_init(struct sh4_pci_address_map *map) 83int __init sh7751_pcic_init(struct pci_channel *chan,
84 struct sh4_pci_address_map *map)
83{ 85{
84 u32 reg; 86 u32 reg;
85 u32 word; 87 u32 word;
@@ -90,10 +92,10 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
90 ctrl_outl(reg, SH7751_BCR1); 92 ctrl_outl(reg, SH7751_BCR1);
91 93
92 /* Turn the clocks back on (not done in reset)*/ 94 /* Turn the clocks back on (not done in reset)*/
93 pci_write_reg(0, SH4_PCICLKR); 95 pci_write_reg(chan, 0, SH4_PCICLKR);
94 /* Clear Powerdown IRQ's (not done in reset) */ 96 /* Clear Powerdown IRQ's (not done in reset) */
95 word = SH4_PCIPINT_D3 | SH4_PCIPINT_D0; 97 word = SH4_PCIPINT_D3 | SH4_PCIPINT_D0;
96 pci_write_reg(word, SH4_PCIPINT); 98 pci_write_reg(chan, word, SH4_PCIPINT);
97 99
98 /* 100 /*
99 * This code is unused for some boards as it is done in the 101 * This code is unused for some boards as it is done in the
@@ -103,11 +105,11 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
103 if (!(map->flags & SH4_PCIC_NO_RESET)) { 105 if (!(map->flags & SH4_PCIC_NO_RESET)) {
104 /* toggle PCI reset pin */ 106 /* toggle PCI reset pin */
105 word = SH4_PCICR_PREFIX | SH4_PCICR_PRST; 107 word = SH4_PCICR_PREFIX | SH4_PCICR_PRST;
106 pci_write_reg(word, SH4_PCICR); 108 pci_write_reg(chan, word, SH4_PCICR);
107 /* Wait for a long time... not 1 sec. but long enough */ 109 /* Wait for a long time... not 1 sec. but long enough */
108 mdelay(100); 110 mdelay(100);
109 word = SH4_PCICR_PREFIX; 111 word = SH4_PCICR_PREFIX;
110 pci_write_reg(word, SH4_PCICR); 112 pci_write_reg(chan, word, SH4_PCICR);
111 } 113 }
112 114
113 /* set the command/status bits to: 115 /* set the command/status bits to:
@@ -116,11 +118,11 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
116 */ 118 */
117 word = SH7751_PCICONF1_WCC | SH7751_PCICONF1_PER | 119 word = SH7751_PCICONF1_WCC | SH7751_PCICONF1_PER |
118 SH7751_PCICONF1_BUM | SH7751_PCICONF1_MES; 120 SH7751_PCICONF1_BUM | SH7751_PCICONF1_MES;
119 pci_write_reg(word, SH7751_PCICONF1); 121 pci_write_reg(chan, word, SH7751_PCICONF1);
120 122
121 /* define this host as the host bridge */ 123 /* define this host as the host bridge */
122 word = PCI_BASE_CLASS_BRIDGE << 24; 124 word = PCI_BASE_CLASS_BRIDGE << 24;
123 pci_write_reg(word, SH7751_PCICONF2); 125 pci_write_reg(chan, word, SH7751_PCICONF2);
124 126
125 /* Set IO and Mem windows to local address 127 /* Set IO and Mem windows to local address
126 * Make PCI and local address the same for easy 1 to 1 mapping 128 * Make PCI and local address the same for easy 1 to 1 mapping
@@ -128,24 +130,24 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
128 * Window1 = map->window1.size @ cached area base = SDRAM 130 * Window1 = map->window1.size @ cached area base = SDRAM
129 */ 131 */
130 word = map->window0.size - 1; 132 word = map->window0.size - 1;
131 pci_write_reg(word, SH4_PCILSR0); 133 pci_write_reg(chan, word, SH4_PCILSR0);
132 word = map->window1.size - 1; 134 word = map->window1.size - 1;
133 pci_write_reg(word, SH4_PCILSR1); 135 pci_write_reg(chan, word, SH4_PCILSR1);
134 /* Set the values on window 0 PCI config registers */ 136 /* Set the values on window 0 PCI config registers */
135 word = P2SEGADDR(map->window0.base); 137 word = P2SEGADDR(map->window0.base);
136 pci_write_reg(word, SH4_PCILAR0); 138 pci_write_reg(chan, word, SH4_PCILAR0);
137 pci_write_reg(word, SH7751_PCICONF5); 139 pci_write_reg(chan, word, SH7751_PCICONF5);
138 /* Set the values on window 1 PCI config registers */ 140 /* Set the values on window 1 PCI config registers */
139 word = PHYSADDR(map->window1.base); 141 word = PHYSADDR(map->window1.base);
140 pci_write_reg(word, SH4_PCILAR1); 142 pci_write_reg(chan, word, SH4_PCILAR1);
141 pci_write_reg(word, SH7751_PCICONF6); 143 pci_write_reg(chan, word, SH7751_PCICONF6);
142 144
143 /* Set the local 16MB PCI memory space window to 145 /* Set the local 16MB PCI memory space window to
144 * the lowest PCI mapped address 146 * the lowest PCI mapped address
145 */ 147 */
146 word = PCIBIOS_MIN_MEM & SH4_PCIMBR_MASK; 148 word = PCIBIOS_MIN_MEM & SH4_PCIMBR_MASK;
147 pr_debug("PCI: Setting upper bits of Memory window to 0x%x\n", word); 149 pr_debug("PCI: Setting upper bits of Memory window to 0x%x\n", word);
148 pci_write_reg(word , SH4_PCIMBR); 150 pci_write_reg(chan, word , SH4_PCIMBR);
149 151
150 /* Map IO space into PCI IO window 152 /* Map IO space into PCI IO window
151 * The IO window is 64K-PCIBIOS_MIN_IO in size 153 * The IO window is 64K-PCIBIOS_MIN_IO in size
@@ -160,19 +162,19 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
160 * correctly */ 162 * correctly */
161 word = PCIBIOS_MIN_IO & SH4_PCIIOBR_MASK; 163 word = PCIBIOS_MIN_IO & SH4_PCIIOBR_MASK;
162 pr_debug("PCI: Setting upper bits of IO window to 0x%x\n", word); 164 pr_debug("PCI: Setting upper bits of IO window to 0x%x\n", word);
163 pci_write_reg(word, SH4_PCIIOBR); 165 pci_write_reg(chan, word, SH4_PCIIOBR);
164 166
165 /* Set PCI WCRx, BCRx's, copy from BSC locations */ 167 /* Set PCI WCRx, BCRx's, copy from BSC locations */
166 168
167 /* check BCR for SDRAM in specified area */ 169 /* check BCR for SDRAM in specified area */
168 switch (map->window0.base) { 170 switch (map->window0.base) {
169 case SH7751_CS0_BASE_ADDR: word = __area_sdram_check(0); break; 171 case SH7751_CS0_BASE_ADDR: word = __area_sdram_check(chan, 0); break;
170 case SH7751_CS1_BASE_ADDR: word = __area_sdram_check(1); break; 172 case SH7751_CS1_BASE_ADDR: word = __area_sdram_check(chan, 1); break;
171 case SH7751_CS2_BASE_ADDR: word = __area_sdram_check(2); break; 173 case SH7751_CS2_BASE_ADDR: word = __area_sdram_check(chan, 2); break;
172 case SH7751_CS3_BASE_ADDR: word = __area_sdram_check(3); break; 174 case SH7751_CS3_BASE_ADDR: word = __area_sdram_check(chan, 3); break;
173 case SH7751_CS4_BASE_ADDR: word = __area_sdram_check(4); break; 175 case SH7751_CS4_BASE_ADDR: word = __area_sdram_check(chan, 4); break;
174 case SH7751_CS5_BASE_ADDR: word = __area_sdram_check(5); break; 176 case SH7751_CS5_BASE_ADDR: word = __area_sdram_check(chan, 5); break;
175 case SH7751_CS6_BASE_ADDR: word = __area_sdram_check(6); break; 177 case SH7751_CS6_BASE_ADDR: word = __area_sdram_check(chan, 6); break;
176 } 178 }
177 179
178 if (!word) 180 if (!word)
@@ -180,25 +182,25 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
180 182
181 /* configure the wait control registers */ 183 /* configure the wait control registers */
182 word = ctrl_inl(SH7751_WCR1); 184 word = ctrl_inl(SH7751_WCR1);
183 pci_write_reg(word, SH4_PCIWCR1); 185 pci_write_reg(chan, word, SH4_PCIWCR1);
184 word = ctrl_inl(SH7751_WCR2); 186 word = ctrl_inl(SH7751_WCR2);
185 pci_write_reg(word, SH4_PCIWCR2); 187 pci_write_reg(chan, word, SH4_PCIWCR2);
186 word = ctrl_inl(SH7751_WCR3); 188 word = ctrl_inl(SH7751_WCR3);
187 pci_write_reg(word, SH4_PCIWCR3); 189 pci_write_reg(chan, word, SH4_PCIWCR3);
188 word = ctrl_inl(SH7751_MCR); 190 word = ctrl_inl(SH7751_MCR);
189 pci_write_reg(word, SH4_PCIMCR); 191 pci_write_reg(chan, word, SH4_PCIMCR);
190 192
191 /* NOTE: I'm ignoring the PCI error IRQs for now.. 193 /* NOTE: I'm ignoring the PCI error IRQs for now..
192 * TODO: add support for the internal error interrupts and 194 * TODO: add support for the internal error interrupts and
193 * DMA interrupts... 195 * DMA interrupts...
194 */ 196 */
195 197
196 pci_fixup_pcic(); 198 pci_fixup_pcic(chan);
197 199
198 /* SH7751 init done, set central function init complete */ 200 /* SH7751 init done, set central function init complete */
199 /* use round robin mode to stop a device starving/overruning */ 201 /* use round robin mode to stop a device starving/overruning */
200 word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_ARBM; 202 word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_ARBM;
201 pci_write_reg(word, SH4_PCICR); 203 pci_write_reg(chan, word, SH4_PCICR);
202 204
203 return 1; 205 return 1;
204} 206}