2 * (C) Copyright 2004 Nick Barker <nick.barker9@btinternet.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <device/device.h>
25 #include <device/pci.h>
26 #include <device/pci_ops.h>
27 #include <device/pci_ids.h>
28 #include <console/console.h>
32 static void udelay(int i){
42 dev0 = dev_find_device(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, 0);
43 dev0 = dev_find_device(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, dev0);
46 for(i = 0; i < 256; i += 16) {
47 printk_debug("0x%x: ", i);
48 for(j = 0; j < 16; j++) {
49 printk_debug("%02x ", pci_read_config8(dev0, i+j));
53 printk_debug("Card32\n");
54 for(i = 0 ; i < 256 ; i+=16){
55 printk_debug("0x%x: ",i);
56 for(j = 0 ; j < 16 ; j++){
57 printk_debug(" %02x",*(unsigned char *)(0x80000000+i+j));
61 printk_debug("Card16\n");
62 for(i = 0; i < 256; i += 16) {
63 printk_debug("0x%x: ", i);
64 for(j = 0; j < 16; j++) {
65 printk_debug("%02x ", *(unsigned char *)(0x80000800+ i+j));
69 printk_debug("CF Config\n");
70 for(i = 0 ; i < 256 ; i+=16){
71 printk_debug("0x%x: ",i);
72 for(j=0 ; j < 16 ; j++){
73 printk_debug("%02x ",*(unsigned char *)(0x81000200 + i + j));
80 static void rl5c476_init(device_t dev)
82 //unsigned char enables;
86 #error "FIXME implement carbus bridge support"
87 #error "FIXME this code is close to a but the conversion needs more work"
88 /* cardbus controller function 1 for CF Socket */
89 printk_debug("rl5c476 init\n");
91 /* setup pci header manually because 'pci_device.c' doesn't know how to handle
92 * pci to cardbus bridges - (header type 2 I think)
96 /* initialize function zero - pcmcia socket so it behaves itself */
97 /* FIXME - statically put control memory at 0xe0000000 for now
98 * one day the pci_device allocator might do this */
99 pci_write_config32(dev,0x10,0xe0000000);
100 pci_write_config8(dev,0x0d,0x20);
101 pci_write_config8(dev,0x19,0x02);
102 pci_write_config8(dev,0x1a,0x02);
103 pci_write_config8(dev,0x1b,0x20);
104 //pci_write_config8(dev,0x3c,0);
105 pci_write_config8(dev,0x82,0x00a0);
106 pci_write_config16(dev,0x04,0x07);
109 /* get second function - i.e. compact flash socket */
110 dev = dev_find_device(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, dev);
113 /* FIXME - control structure statically declared at 0xe0008000 for now */
114 pci_write_config32(dev,0x10,0xe0008000);
115 pci_write_config8(dev,0x0d,0x20);
116 pci_write_config8(dev,0x19,0x03);
117 pci_write_config8(dev,0x1a,0x03);
118 pci_write_config8(dev,0x1b,0x20);
120 //pci_write_config8(dev,0x3c,0x0);
121 pci_write_config16(dev,0x3e,0x0780);
122 pci_write_config16(dev,0x82,0x00a0);
124 pci_write_config16(dev,0x04,0x07);
127 /* pick up where 16 bit card control structure is */
128 pc16 = (pc16reg_t *)(0xe0008800);
130 /* disable memory and io windows and turn off socket power */
133 /* disable irq lines */
136 /* disable memory and I/O windows */
139 /* reset card, configure for I/O and set IRQ line */
143 // set io window 0 for 1e8 - 1ef
150 // add io offset of 8 so that CF card will decode 0x1e8 as 0x1f0 i.e. the first byte of
151 // a 16 byte aligned, 16 byte window etc
155 // set io window 1 for 3ed - 3ee
166 // FIXME statically declare CF config window at 0xe1000000
175 // set I/O width for Auto Data width
179 // enable I/O window 0 and 1
185 // apply power and enable outputs
189 // delay could be optimised, but this works
195 cptr = (unsigned char *)(0xe1000200);
196 printk_debug("CF Config = %x\n",*cptr);
198 // FIX Me 16 bit CF always have first config byte at 0x200 into Config structure,
199 // but CF+ May Not according to spec - should locate through reading tuple data,
200 // but this will do for now !!!
203 // set CF to decode 16 IO bytes on any 16 byte boundary - rely on the io
204 // windows of the bridge set up above to map those bytes into the
205 // addresses for ide controller 3 (0x1e8 - 0x1ef and 0x3ed - 0x3ee)
211 static struct device_operations ricoh_rl5c476_ops = {
212 .read_resources = pci_bus_read_resources,
213 .set_resources = pci_dev_set_resources,
214 .enable_resources = pci_bus_enable_resources,
215 .inti = rl5c476_init,
216 .scan_bus = pci_scan_bridge,
219 static struct pci_driver ricoh_rl5c476_driver __pci_driver = {
220 .ops = &ricoh_rl5c476_ops,
221 .vendor = PCI_VENDOR_ID_RICOH,
222 .device = PCI_DEVICE_ID_RICOH_RL5C476,
225 struct chip_operations southbridge_ricoh_rl5c476_control = {
226 CHIP_NAME("RICOH RL5C476")
227 .enable = southbridge_init,