| 1 |
|
| 2 |
|
| 3 |
#include <device/device.h> |
| 4 |
#include <device/pci.h> |
| 5 |
#include <device/pci_ops.h> |
| 6 |
#include <device/pci_ids.h> |
| 7 |
#include <console/console.h> |
| 8 |
#include <device/cardbus.h> |
| 9 |
#include <delay.h> |
| 10 |
#include "rl5c476.h" |
| 11 |
#include "chip.h" |
| 12 |
|
| 13 |
static int enable_cf_boot = 0; |
| 14 |
static unsigned int cf_base; |
| 15 |
|
| 16 |
static void rl5c476_init(struct device *dev) |
| 17 |
{ |
| 18 |
pc16reg_t *pc16; |
| 19 |
unsigned char *base; |
| 20 |
|
| 21 |
|
| 22 |
printk(BIOS_DEBUG, "Ricoh RL5c476: Initializing.\n"); |
| 23 |
|
| 24 |
printk(BIOS_DEBUG, "CF Base = %0x\n",cf_base); |
| 25 |
|
| 26 |
|
| 27 |
pci_write_config16(dev,0x82,0x00a0); |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
if (!enable_cf_boot) { |
| 32 |
printk(BIOS_DEBUG, "CF boot not enabled.\n"); |
| 33 |
return; |
| 34 |
} |
| 35 |
|
| 36 |
if (PCI_FUNC(dev->path.pci.devfn) != 1) { |
| 37 |
|
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
pci_write_config16(dev,0x3e,0x0780); |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
base = (unsigned char *)pci_read_config32(dev,0x10); |
| 48 |
pc16 = (pc16reg_t *)(base + 0x800); |
| 49 |
|
| 50 |
|
| 51 |
pc16->pwctrl = 0; |
| 52 |
|
| 53 |
|
| 54 |
pc16->igctrl = 0; |
| 55 |
|
| 56 |
|
| 57 |
pc16->awinen = 0; |
| 58 |
|
| 59 |
|
| 60 |
pc16->igctrl = 0x69; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
pc16->iostl0 = 0xe0; |
| 83 |
pc16->iosth0 = 1; |
| 84 |
|
| 85 |
pc16->iospl0 = 0xef; |
| 86 |
pc16->iosph0 = 1; |
| 87 |
|
| 88 |
pc16->ioffl0 = 0; |
| 89 |
pc16->ioffh0 = 0; |
| 90 |
|
| 91 |
|
| 92 |
pc16->iostl1 = 0; |
| 93 |
pc16->iosth1 = 0; |
| 94 |
|
| 95 |
pc16->iospl1 = 0; |
| 96 |
pc16->iosph1 = 0; |
| 97 |
|
| 98 |
pc16->ioffl1 = 0x0; |
| 99 |
pc16->ioffh1 = 0; |
| 100 |
|
| 101 |
|
| 102 |
pc16->smpga0 = cf_base>>24; |
| 103 |
pc16->smsth0 = (cf_base>>20)&0x0f; |
| 104 |
pc16->smstl0 = (cf_base>>12)&0xff; |
| 105 |
pc16->smsph0 = ((cf_base>>20)&0x0f) | 0x80; |
| 106 |
pc16->smspl0 = (cf_base>>12)&0xff; |
| 107 |
pc16->moffl0 = 0; |
| 108 |
pc16->moffh0 = 0x40; |
| 109 |
|
| 110 |
|
| 111 |
pc16->ioctrl = 0x22; |
| 112 |
|
| 113 |
|
| 114 |
pc16->awinen = 0xc1; |
| 115 |
|
| 116 |
pc16->miscc1 = 1; |
| 117 |
|
| 118 |
|
| 119 |
pc16->pwctrl = 0xb0; |
| 120 |
|
| 121 |
|
| 122 |
udelay(100000); |
| 123 |
|
| 124 |
pc16->igctrl = 0x69; |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
unsigned char *cptr; |
| 132 |
cptr = (unsigned char *)(cf_base + 0x200); |
| 133 |
printk(BIOS_DEBUG, "CF Config = %x\n",*cptr); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
*cptr = 0x41; |
| 141 |
} |
| 142 |
|
| 143 |
static void rl5c476_read_resources(struct device *dev) |
| 144 |
{ |
| 145 |
struct resource *resource; |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
if (enable_cf_boot && (PCI_FUNC(dev->path.pci.devfn) == 1)) { |
| 151 |
|
| 152 |
resource = new_resource(dev, 1); |
| 153 |
resource->flags |= IORESOURCE_MEM; |
| 154 |
resource->size = 0x1000; |
| 155 |
resource->align = resource->gran = 12; |
| 156 |
resource->limit= 0xffff0000; |
| 157 |
} |
| 158 |
cardbus_read_resources(dev); |
| 159 |
} |
| 160 |
|
| 161 |
static void rl5c476_set_resources(struct device *dev) |
| 162 |
{ |
| 163 |
struct resource *resource; |
| 164 |
printk(BIOS_DEBUG, "%s In set resources\n",dev_path(dev)); |
| 165 |
if (enable_cf_boot && (PCI_FUNC(dev->path.pci.devfn) == 1)) { |
| 166 |
resource = find_resource(dev,1); |
| 167 |
if (!(resource->flags & IORESOURCE_STORED)) { |
| 168 |
resource->flags |= IORESOURCE_STORED; |
| 169 |
printk(BIOS_DEBUG, "%s 1 ==> %llx\n", dev_path(dev), resource->base); |
| 170 |
cf_base = resource->base; |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
pci_dev_set_resources(dev); |
| 175 |
} |
| 176 |
|
| 177 |
static void rl5c476_set_subsystem(struct device *dev, unsigned int vendor, |
| 178 |
unsigned int device) |
| 179 |
{ |
| 180 |
u16 miscreg = pci_read_config16(dev, 0x82); |
| 181 |
|
| 182 |
pci_write_config16(dev, 0x82, miscreg | 0x40); |
| 183 |
|
| 184 |
pci_dev_set_subsystem(dev, vendor, device); |
| 185 |
|
| 186 |
|
| 187 |
pci_write_config16(dev, 0x82, miscreg); |
| 188 |
} |
| 189 |
|
| 190 |
static struct pci_operations rl5c476_pci_ops = { |
| 191 |
.set_subsystem = rl5c476_set_subsystem, |
| 192 |
}; |
| 193 |
|
| 194 |
static struct device_operations ricoh_rl5c476_ops = { |
| 195 |
.read_resources = rl5c476_read_resources, |
| 196 |
.set_resources = rl5c476_set_resources, |
| 197 |
.enable_resources = cardbus_enable_resources, |
| 198 |
.init = rl5c476_init, |
| 199 |
.scan_bus = pci_scan_bridge, |
| 200 |
.ops_pci = &rl5c476_pci_ops, |
| 201 |
}; |
| 202 |
|
| 203 |
static const struct pci_driver ricoh_rl5c476_driver __pci_driver = { |
| 204 |
.ops = &ricoh_rl5c476_ops, |
| 205 |
.vendor = PCI_VID_RICOH, |
| 206 |
.device = PCI_DID_RICOH_RL5C476, |
| 207 |
}; |
| 208 |
|
| 209 |
static void southbridge_init(struct device *dev) |
| 210 |
{ |
| 211 |
struct southbridge_ricoh_rl5c476_config *conf = dev->chip_info; |
| 212 |
enable_cf_boot = conf->enable_cf; |
| 213 |
} |
| 214 |
|
| 215 |
struct chip_operations southbridge_ricoh_rl5c476_ops = { |
| 216 |
.name = "Ricoh RL5C476 CardBus Controller", |
| 217 |
.enable_dev = southbridge_init, |
| 218 |
}; |