Commit cc5d0189 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Paul Mackerras

[PATCH] powerpc: Remove device_node addrs/n_addr

The pre-parsed addrs/n_addrs fields in struct device_node are finally
gone. Remove the dodgy heuristics that did that parsing at boot and
remove the fields themselves since we now have a good replacement with
the new OF parsing code. This patch also fixes a bunch of drivers to use
the new code instead, so that at least pmac32, pseries, iseries and g5
defconfigs build.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 9cf84d7c
...@@ -211,8 +211,6 @@ int __init btext_find_display(int allow_nonstdout) ...@@ -211,8 +211,6 @@ int __init btext_find_display(int allow_nonstdout)
struct device_node *np = NULL; struct device_node *np = NULL;
int rc = -ENODEV; int rc = -ENODEV;
printk("trying to initialize btext ...\n");
name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
if (name != NULL) { if (name != NULL) {
np = of_find_node_by_path(name); np = of_find_node_by_path(name);
......
...@@ -896,6 +896,25 @@ static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node, ...@@ -896,6 +896,25 @@ static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
unsigned long phb_io_base_phys, unsigned long phb_io_base_phys,
void __iomem * phb_io_base_virt) void __iomem * phb_io_base_virt)
{ {
/* Remove these asap */
struct pci_address {
u32 a_hi;
u32 a_mid;
u32 a_lo;
};
struct isa_address {
u32 a_hi;
u32 a_lo;
};
struct isa_range {
struct isa_address isa_addr;
struct pci_address pci_addr;
unsigned int size;
};
struct isa_range *range; struct isa_range *range;
unsigned long pci_addr; unsigned long pci_addr;
unsigned int isa_addr; unsigned int isa_addr;
...@@ -1330,8 +1349,9 @@ unsigned int pci_address_to_pio(phys_addr_t address) ...@@ -1330,8 +1349,9 @@ unsigned int pci_address_to_pio(phys_addr_t address)
list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
if (address >= hose->io_base_phys && if (address >= hose->io_base_phys &&
address < (hose->io_base_phys + hose->pci_io_size)) address < (hose->io_base_phys + hose->pci_io_size))
return (unsigned int)hose->io_base_virt + return (unsigned int)
(address - hose->io_base_phys); ((unsigned long)hose->io_base_virt +
(address - hose->io_base_phys));
} }
return (unsigned int)-1; return (unsigned int)-1;
} }
......
This diff is collapsed.
...@@ -558,7 +558,8 @@ unsigned long prom_memparse(const char *ptr, const char **retptr) ...@@ -558,7 +558,8 @@ unsigned long prom_memparse(const char *ptr, const char **retptr)
static void __init early_cmdline_parse(void) static void __init early_cmdline_parse(void)
{ {
struct prom_t *_prom = &RELOC(prom); struct prom_t *_prom = &RELOC(prom);
char *opt, *p; const char *opt;
char *p;
int l = 0; int l = 0;
RELOC(prom_cmd_line[0]) = 0; RELOC(prom_cmd_line[0]) = 0;
......
...@@ -188,39 +188,19 @@ int is_python(struct device_node *dev) ...@@ -188,39 +188,19 @@ int is_python(struct device_node *dev)
return 0; return 0;
} }
static int get_phb_reg_prop(struct device_node *dev, static void python_countermeasures(struct device_node *dev)
unsigned int addr_size_words,
struct reg_property64 *reg)
{ {
unsigned int *ui_ptr = NULL, len; struct resource registers;
/* Found a PHB, now figure out where his registers are mapped. */
ui_ptr = (unsigned int *)get_property(dev, "reg", &len);
if (ui_ptr == NULL)
return 1;
if (addr_size_words == 1) {
reg->address = ((struct reg_property32 *)ui_ptr)->address;
reg->size = ((struct reg_property32 *)ui_ptr)->size;
} else {
*reg = *((struct reg_property64 *)ui_ptr);
}
return 0;
}
static void python_countermeasures(struct device_node *dev,
unsigned int addr_size_words)
{
struct reg_property64 reg_struct;
void __iomem *chip_regs; void __iomem *chip_regs;
volatile u32 val; volatile u32 val;
if (get_phb_reg_prop(dev, addr_size_words, &reg_struct)) if (of_address_to_resource(dev, 0, &registers)) {
printk(KERN_ERR "Can't get address for Python workarounds !\n");
return; return;
}
/* Python's register file is 1 MB in size. */ /* Python's register file is 1 MB in size. */
chip_regs = ioremap(reg_struct.address & ~(0xfffffUL), 0x100000); chip_regs = ioremap(registers.start & ~(0xfffffUL), 0x100000);
/* /*
* Firmware doesn't always clear this bit which is critical * Firmware doesn't always clear this bit which is critical
...@@ -301,11 +281,10 @@ static int phb_set_bus_ranges(struct device_node *dev, ...@@ -301,11 +281,10 @@ static int phb_set_bus_ranges(struct device_node *dev,
} }
static int __devinit setup_phb(struct device_node *dev, static int __devinit setup_phb(struct device_node *dev,
struct pci_controller *phb, struct pci_controller *phb)
unsigned int addr_size_words)
{ {
if (is_python(dev)) if (is_python(dev))
python_countermeasures(dev, addr_size_words); python_countermeasures(dev);
if (phb_set_bus_ranges(dev, phb)) if (phb_set_bus_ranges(dev, phb))
return 1; return 1;
...@@ -320,8 +299,8 @@ unsigned long __init find_and_init_phbs(void) ...@@ -320,8 +299,8 @@ unsigned long __init find_and_init_phbs(void)
{ {
struct device_node *node; struct device_node *node;
struct pci_controller *phb; struct pci_controller *phb;
unsigned int root_size_cells = 0;
unsigned int index; unsigned int index;
unsigned int root_size_cells = 0;
unsigned int *opprop = NULL; unsigned int *opprop = NULL;
struct device_node *root = of_find_node_by_path("/"); struct device_node *root = of_find_node_by_path("/");
...@@ -343,10 +322,11 @@ unsigned long __init find_and_init_phbs(void) ...@@ -343,10 +322,11 @@ unsigned long __init find_and_init_phbs(void)
phb = pcibios_alloc_controller(node); phb = pcibios_alloc_controller(node);
if (!phb) if (!phb)
continue; continue;
setup_phb(node, phb, root_size_cells); setup_phb(node, phb);
pci_process_bridge_OF_ranges(phb, node, 0); pci_process_bridge_OF_ranges(phb, node, 0);
pci_setup_phb_io(phb, index == 0); pci_setup_phb_io(phb, index == 0);
#ifdef CONFIG_PPC_PSERIES #ifdef CONFIG_PPC_PSERIES
/* XXX This code need serious fixing ... --BenH */
if (ppc64_interrupt_controller == IC_OPEN_PIC && pSeries_mpic) { if (ppc64_interrupt_controller == IC_OPEN_PIC && pSeries_mpic) {
int addr = root_size_cells * (index + 2) - 1; int addr = root_size_cells * (index + 2) - 1;
mpic_assign_isu(pSeries_mpic, index, opprop[addr]); mpic_assign_isu(pSeries_mpic, index, opprop[addr]);
...@@ -381,22 +361,17 @@ unsigned long __init find_and_init_phbs(void) ...@@ -381,22 +361,17 @@ unsigned long __init find_and_init_phbs(void)
struct pci_controller * __devinit init_phb_dynamic(struct device_node *dn) struct pci_controller * __devinit init_phb_dynamic(struct device_node *dn)
{ {
struct device_node *root = of_find_node_by_path("/");
unsigned int root_size_cells = 0;
struct pci_controller *phb; struct pci_controller *phb;
int primary; int primary;
root_size_cells = prom_n_size_cells(root);
primary = list_empty(&hose_list); primary = list_empty(&hose_list);
phb = pcibios_alloc_controller(dn); phb = pcibios_alloc_controller(dn);
if (!phb) if (!phb)
return NULL; return NULL;
setup_phb(dn, phb, root_size_cells); setup_phb(dn, phb);
pci_process_bridge_OF_ranges(phb, dn, primary); pci_process_bridge_OF_ranges(phb, dn, primary);
pci_setup_phb_io_dynamic(phb, primary); pci_setup_phb_io_dynamic(phb, primary);
of_node_put(root);
pci_devs_phb_init_dynamic(phb); pci_devs_phb_init_dynamic(phb);
scan_phb(phb); scan_phb(phb);
......
...@@ -432,7 +432,8 @@ static int __init parse_numa_properties(void) ...@@ -432,7 +432,8 @@ static int __init parse_numa_properties(void)
if (!memcell_buf || len <= 0) if (!memcell_buf || len <= 0)
continue; continue;
ranges = memory->n_addrs; /* ranges in cell */
ranges = (len >> 2) / (n_mem_addr_cells + n_mem_size_cells);
new_range: new_range:
/* these are order-sensitive, and modify the buffer pointer */ /* these are order-sensitive, and modify the buffer pointer */
start = read_n_cells(n_mem_addr_cells, &memcell_buf); start = read_n_cells(n_mem_addr_cells, &memcell_buf);
...@@ -779,7 +780,8 @@ int hot_add_scn_to_nid(unsigned long scn_addr) ...@@ -779,7 +780,8 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
if (!memcell_buf || len <= 0) if (!memcell_buf || len <= 0)
continue; continue;
ranges = memory->n_addrs; /* ranges in cell */ /* ranges in cell */
ranges = (len >> 2) / (n_mem_addr_cells + n_mem_size_cells);
ha_new_range: ha_new_range:
start = read_n_cells(n_mem_addr_cells, &memcell_buf); start = read_n_cells(n_mem_addr_cells, &memcell_buf);
size = read_n_cells(n_mem_size_cells, &memcell_buf); size = read_n_cells(n_mem_size_cells, &memcell_buf);
......
...@@ -1445,20 +1445,55 @@ static long g5_i2s_enable(struct device_node *node, long param, long value) ...@@ -1445,20 +1445,55 @@ static long g5_i2s_enable(struct device_node *node, long param, long value)
/* Very crude implementation for now */ /* Very crude implementation for now */
struct macio_chip *macio = &macio_chips[0]; struct macio_chip *macio = &macio_chips[0];
unsigned long flags; unsigned long flags;
int cell;
if (value == 0) u32 fcrs[3][3] = {
return 0; /* don't disable yet */ { 0,
K2_FCR1_I2S0_CELL_ENABLE |
K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE,
KL3_I2S0_CLK18_ENABLE
},
{ KL0_SCC_A_INTF_ENABLE,
K2_FCR1_I2S1_CELL_ENABLE |
K2_FCR1_I2S1_CLK_ENABLE_BIT | K2_FCR1_I2S1_ENABLE,
KL3_I2S1_CLK18_ENABLE
},
{ KL0_SCC_B_INTF_ENABLE,
SH_FCR1_I2S2_CELL_ENABLE |
SH_FCR1_I2S2_CLK_ENABLE_BIT | SH_FCR1_I2S2_ENABLE,
SH_FCR3_I2S2_CLK18_ENABLE
},
};
if (macio->type != macio_keylargo2 /* && macio->type != macio_shasta*/)
return -ENODEV;
if (strncmp(node->name, "i2s-", 4))
return -ENODEV;
cell = node->name[4] - 'a';
switch(cell) {
case 0:
case 1:
break;
#if 0
case 2:
if (macio->type == macio_shasta)
break;
#endif
default:
return -ENODEV;
}
LOCK(flags); LOCK(flags);
MACIO_BIS(KEYLARGO_FCR3, KL3_CLK45_ENABLE | KL3_CLK49_ENABLE | if (value) {
KL3_I2S0_CLK18_ENABLE); MACIO_BIC(KEYLARGO_FCR0, fcrs[cell][0]);
udelay(10); MACIO_BIS(KEYLARGO_FCR1, fcrs[cell][1]);
MACIO_BIS(KEYLARGO_FCR1, K2_FCR1_I2S0_CELL_ENABLE | MACIO_BIS(KEYLARGO_FCR3, fcrs[cell][2]);
K2_FCR1_I2S0_CLK_ENABLE_BIT | K2_FCR1_I2S0_ENABLE); } else {
MACIO_BIC(KEYLARGO_FCR3, fcrs[cell][2]);
MACIO_BIC(KEYLARGO_FCR1, fcrs[cell][1]);
MACIO_BIS(KEYLARGO_FCR0, fcrs[cell][0]);
}
udelay(10); udelay(10);
MACIO_BIC(KEYLARGO_FCR1, K2_FCR1_I2S0_RESET);
UNLOCK(flags); UNLOCK(flags);
udelay(10);
return 0; return 0;
} }
...@@ -2960,26 +2995,6 @@ pmac_feature_init(void) ...@@ -2960,26 +2995,6 @@ pmac_feature_init(void)
set_initial_features(); set_initial_features();
} }
int __init pmac_feature_late_init(void)
{
#if 0
struct device_node *np;
/* Request some resources late */
if (uninorth_node)
request_OF_resource(uninorth_node, 0, NULL);
np = find_devices("hammerhead");
if (np)
request_OF_resource(np, 0, NULL);
np = find_devices("interrupt-controller");
if (np)
request_OF_resource(np, 0, NULL);
#endif
return 0;
}
device_initcall(pmac_feature_late_init);
#if 0 #if 0
static void dump_HT_speeds(char *name, u32 cfg, u32 frq) static void dump_HT_speeds(char *name, u32 cfg, u32 frq)
{ {
......
...@@ -514,7 +514,7 @@ static void core99_nvram_sync(void) ...@@ -514,7 +514,7 @@ static void core99_nvram_sync(void)
#endif #endif
} }
static int __init core99_nvram_setup(struct device_node *dp) static int __init core99_nvram_setup(struct device_node *dp, unsigned long addr)
{ {
int i; int i;
u32 gen_bank0, gen_bank1; u32 gen_bank0, gen_bank1;
...@@ -528,7 +528,7 @@ static int __init core99_nvram_setup(struct device_node *dp) ...@@ -528,7 +528,7 @@ static int __init core99_nvram_setup(struct device_node *dp)
printk(KERN_ERR "nvram: can't allocate ram image\n"); printk(KERN_ERR "nvram: can't allocate ram image\n");
return -ENOMEM; return -ENOMEM;
} }
nvram_data = ioremap(dp->addrs[0].address, NVRAM_SIZE*2); nvram_data = ioremap(addr, NVRAM_SIZE*2);
nvram_naddrs = 1; /* Make sure we get the correct case */ nvram_naddrs = 1; /* Make sure we get the correct case */
DBG("nvram: Checking bank 0...\n"); DBG("nvram: Checking bank 0...\n");
...@@ -570,34 +570,48 @@ static int __init core99_nvram_setup(struct device_node *dp) ...@@ -570,34 +570,48 @@ static int __init core99_nvram_setup(struct device_node *dp)
int __init pmac_nvram_init(void) int __init pmac_nvram_init(void)
{ {
struct device_node *dp; struct device_node *dp;
struct resource r1, r2;
unsigned int s1 = 0, s2 = 0;
int err = 0; int err = 0;
nvram_naddrs = 0; nvram_naddrs = 0;
dp = find_devices("nvram"); dp = of_find_node_by_name(NULL, "nvram");
if (dp == NULL) { if (dp == NULL) {
printk(KERN_ERR "Can't find NVRAM device\n"); printk(KERN_ERR "Can't find NVRAM device\n");
return -ENODEV; return -ENODEV;
} }
nvram_naddrs = dp->n_addrs;
/* Try to obtain an address */
if (of_address_to_resource(dp, 0, &r1) == 0) {
nvram_naddrs = 1;
s1 = (r1.end - r1.start) + 1;
if (of_address_to_resource(dp, 1, &r2) == 0) {
nvram_naddrs = 2;
s2 = (r2.end - r2.start) + 1;
}
}
is_core_99 = device_is_compatible(dp, "nvram,flash"); is_core_99 = device_is_compatible(dp, "nvram,flash");
if (is_core_99) if (is_core_99) {
err = core99_nvram_setup(dp); err = core99_nvram_setup(dp, r1.start);
goto bail;
}
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC32
else if (_machine == _MACH_chrp && nvram_naddrs == 1) { if (_machine == _MACH_chrp && nvram_naddrs == 1) {
nvram_data = ioremap(dp->addrs[0].address + isa_mem_base, nvram_data = ioremap(r1.start, s1);
dp->addrs[0].size);
nvram_mult = 1; nvram_mult = 1;
ppc_md.nvram_read_val = direct_nvram_read_byte; ppc_md.nvram_read_val = direct_nvram_read_byte;
ppc_md.nvram_write_val = direct_nvram_write_byte; ppc_md.nvram_write_val = direct_nvram_write_byte;
} else if (nvram_naddrs == 1) { } else if (nvram_naddrs == 1) {
nvram_data = ioremap(dp->addrs[0].address, dp->addrs[0].size); nvram_data = ioremap(r1.start, s1);
nvram_mult = (dp->addrs[0].size + NVRAM_SIZE - 1) / NVRAM_SIZE; nvram_mult = (s1 + NVRAM_SIZE - 1) / NVRAM_SIZE;
ppc_md.nvram_read_val = direct_nvram_read_byte; ppc_md.nvram_read_val = direct_nvram_read_byte;
ppc_md.nvram_write_val = direct_nvram_write_byte; ppc_md.nvram_write_val = direct_nvram_write_byte;
} else if (nvram_naddrs == 2) { } else if (nvram_naddrs == 2) {
nvram_addr = ioremap(dp->addrs[0].address, dp->addrs[0].size); nvram_addr = ioremap(r1.start, s1);
nvram_data = ioremap(dp->addrs[1].address, dp->addrs[1].size); nvram_data = ioremap(r2.start, s2);
ppc_md.nvram_read_val = indirect_nvram_read_byte; ppc_md.nvram_read_val = indirect_nvram_read_byte;
ppc_md.nvram_write_val = indirect_nvram_write_byte; ppc_md.nvram_write_val = indirect_nvram_write_byte;
} else if (nvram_naddrs == 0 && sys_ctrler == SYS_CTRLER_PMU) { } else if (nvram_naddrs == 0 && sys_ctrler == SYS_CTRLER_PMU) {
...@@ -606,13 +620,15 @@ int __init pmac_nvram_init(void) ...@@ -606,13 +620,15 @@ int __init pmac_nvram_init(void)
ppc_md.nvram_read_val = pmu_nvram_read_byte; ppc_md.nvram_read_val = pmu_nvram_read_byte;
ppc_md.nvram_write_val = pmu_nvram_write_byte; ppc_md.nvram_write_val = pmu_nvram_write_byte;
#endif /* CONFIG_ADB_PMU */ #endif /* CONFIG_ADB_PMU */
} } else {
#endif
else {
printk(KERN_ERR "Incompatible type of NVRAM\n"); printk(KERN_ERR "Incompatible type of NVRAM\n");
return -ENXIO; err = -ENXIO;
} }
lookup_partitions(); #endif /* CONFIG_PPC32 */
bail:
of_node_put(dp);
if (err == 0)
lookup_partitions();
return err; return err;
} }
......
...@@ -285,15 +285,13 @@ static struct pci_ops chaos_pci_ops = ...@@ -285,15 +285,13 @@ static struct pci_ops chaos_pci_ops =
}; };
static void __init setup_chaos(struct pci_controller *hose, static void __init setup_chaos(struct pci_controller *hose,
struct reg_property *addr) struct resource *addr)
{ {
/* assume a `chaos' bridge */ /* assume a `chaos' bridge */
hose->ops = &chaos_pci_ops; hose->ops = &chaos_pci_ops;
hose->cfg_addr = ioremap(addr->address + 0x800000, 0x1000); hose->cfg_addr = ioremap(addr->start + 0x800000, 0x1000);
hose->cfg_data = ioremap(addr->address + 0xc00000, 0x1000); hose->cfg_data = ioremap(addr->start + 0xc00000, 0x1000);
} }
#else
#define setup_chaos(hose, addr)
#endif /* CONFIG_PPC32 */ #endif /* CONFIG_PPC32 */
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
...@@ -356,9 +354,11 @@ static unsigned long u3_ht_cfg_access(struct pci_controller* hose, ...@@ -356,9 +354,11 @@ static unsigned long u3_ht_cfg_access(struct pci_controller* hose,
/* For now, we don't self probe U3 HT bridge */ /* For now, we don't self probe U3 HT bridge */
if (PCI_SLOT(devfn) == 0) if (PCI_SLOT(devfn) == 0)
return 0; return 0;
return ((unsigned long)hose->cfg_data) + U3_HT_CFA0(devfn, offset); return ((unsigned long)hose->cfg_data) +
U3_HT_CFA0(devfn, offset);
} else } else
return ((unsigned long)hose->cfg_data) + U3_HT_CFA1(bus, devfn, offset); return ((unsigned long)hose->cfg_data) +
U3_HT_CFA1(bus, devfn, offset);
} }
static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
...@@ -532,7 +532,8 @@ static void __init init_p2pbridge(void) ...@@ -532,7 +532,8 @@ static void __init init_p2pbridge(void)
} }
if (early_read_config_word(hose, bus, devfn, if (early_read_config_word(hose, bus, devfn,
PCI_BRIDGE_CONTROL, &val) < 0) { PCI_BRIDGE_CONTROL, &val) < 0) {
printk(KERN_ERR "init_p2pbridge: couldn't read bridge control\n"); printk(KERN_ERR "init_p2pbridge: couldn't read bridge"
" control\n");
return; return;
} }
val &= ~PCI_BRIDGE_CTL_MASTER_ABORT; val &= ~PCI_BRIDGE_CTL_MASTER_ABORT;
...@@ -576,36 +577,38 @@ static void __init fixup_nec_usb2(void) ...@@ -576,36 +577,38 @@ static void __init fixup_nec_usb2(void)
continue; continue;
early_read_config_dword(hose, bus, devfn, 0xe4, &data); early_read_config_dword(hose, bus, devfn, 0xe4, &data);
if (data & 1UL) { if (data & 1UL) {
printk("Found NEC PD720100A USB2 chip with disabled EHCI, fixing up...\n"); printk("Found NEC PD720100A USB2 chip with disabled"
" EHCI, fixing up...\n");
data &= ~1UL; data &= ~1UL;
early_write_config_dword(hose, bus, devfn, 0xe4, data); early_write_config_dword(hose, bus, devfn, 0xe4, data);
early_write_config_byte(hose, bus, devfn | 2, PCI_INTERRUPT_LINE, early_write_config_byte(hose, bus,
devfn | 2, PCI_INTERRUPT_LINE,
nec->intrs[0].line); nec->intrs[0].line);
} }
} }
} }
static void __init setup_bandit(struct pci_controller *hose, static void __init setup_bandit(struct pci_controller *hose,
struct reg_property *addr) struct resource *addr)
{ {
hose->ops = &macrisc_pci_ops; hose->ops = &macrisc_pci_ops;
hose->cfg_addr = ioremap(addr->address + 0x800000, 0x1000); hose->cfg_addr = ioremap(addr->start + 0x800000, 0x1000);
hose->cfg_data = ioremap(addr->address + 0xc00000, 0x1000); hose->cfg_data = ioremap(addr->start + 0xc00000, 0x1000);
init_bandit(hose); init_bandit(hose);
} }
static int __init setup_uninorth(struct pci_controller *hose, static int __init setup_uninorth(struct pci_controller *hose,
struct reg_property *addr) struct resource *addr)
{ {
pci_assign_all_buses = 1; pci_assign_all_buses = 1;
has_uninorth = 1; has_uninorth = 1;
hose->ops = &macrisc_pci_ops; hose->ops = &macrisc_pci_ops;
hose->cfg_addr = ioremap(addr->address + 0x800000, 0x1000); hose->cfg_addr = ioremap(addr->start + 0x800000, 0x1000);
hose->cfg_data = ioremap(addr->address + 0xc00000, 0x1000); hose->cfg_data = ioremap(addr->start + 0xc00000, 0x1000);
/* We "know" that the bridge at f2000000 has the PCI slots. */ /* We "know" that the bridge at f2000000 has the PCI slots. */
return addr->address == 0xf2000000; return addr->start == 0xf2000000;
} }
#endif #endif /* CONFIG_PPC32 */
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
static void __init setup_u3_agp(struct pci_controller* hose) static void __init setup_u3_agp(struct pci_controller* hose)
...@@ -722,7 +725,7 @@ static void __init setup_u3_ht(struct pci_controller* hose) ...@@ -722,7 +725,7 @@ static void __init setup_u3_ht(struct pci_controller* hose)
hose->mem_resources[cur-1].end = res->start - 1; hose->mem_resources[cur-1].end = res->start - 1;
} }
} }
#endif #endif /* CONFIG_PPC64 */
/* /*
* We assume that if we have a G3 powermac, we have one bridge called * We assume that if we have a G3 powermac, we have one bridge called
...@@ -733,24 +736,17 @@ static int __init add_bridge(struct device_node *dev) ...@@ -733,24 +736,17 @@ static int __init add_bridge(struct device_node *dev)
{ {
int len; int len;
struct pci_controller *hose; struct pci_controller *hose;
#ifdef CONFIG_PPC32 struct resource rsrc;
struct reg_property *addr;
#endif
char *disp_name; char *disp_name;
int *bus_range; int *bus_range;
int primary = 1; int primary = 1, has_address = 0;
DBG("Adding PCI host bridge %s\n", dev->full_name); DBG("Adding PCI host bridge %s\n", dev->full_name);
#ifdef CONFIG_PPC32 /* Fetch host bridge registers address */
/* XXX fix this */ has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
addr = (struct reg_property *) get_property(dev, "reg", &len);
if (addr == NULL || len < sizeof(*addr)) { /* Get bus range if any */
printk(KERN_WARNING "Can't use %s: no address\n",
dev->full_name);
return -ENODEV;
}
#endif
bus_range = (int *) get_property(dev, "bus-range", &len); bus_range = (int *) get_property(dev, "bus-range", &len);
if (bus_range == NULL || len < 2 * sizeof(int)) { if (bus_range == NULL || len < 2 * sizeof(int)) {
printk(KERN_WARNING "Can't get bus-range for %s, assume" printk(KERN_WARNING "Can't get bus-range for %s, assume"
...@@ -770,6 +766,8 @@ static int __init add_bridge(struct device_node *dev) ...@@ -770,6 +766,8 @@ static int __init add_bridge(struct device_node *dev)
hose->last_busno = bus_range ? bus_range[1] : 0xff; hose->last_busno = bus_range ? bus_range[1] : 0xff;
disp_name = NULL; disp_name = NULL;
/* 64 bits only bridges */
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
if (device_is_compatible(dev, "u3-agp")) { if (device_is_compatible(dev, "u3-agp")) {
setup_u3_agp(hose); setup_u3_agp(hose);
...@@ -782,25 +780,30 @@ static int __init add_bridge(struct device_node *dev) ...@@ -782,25 +780,30 @@ static int __init add_bridge(struct device_node *dev)
} }
printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n", printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
disp_name, hose->first_busno, hose->last_busno); disp_name, hose->first_busno, hose->last_busno);
#else #endif /* CONFIG_PPC64 */
/* 32 bits only bridges */
#ifdef CONFIG_PPC32
if (device_is_compatible(dev, "uni-north")) { if (device_is_compatible(dev, "uni-north")) {
primary = setup_uninorth(hose, addr); primary = setup_uninorth(hose, &rsrc);
disp_name = "UniNorth"; disp_name = "UniNorth";
} else if (strcmp(dev->name, "pci") == 0) { } else if (strcmp(dev->name, "pci") == 0) {
/* XXX assume this is a mpc106 (grackle) */ /* XXX assume this is a mpc106 (grackle) */
setup_grackle(hose); setup_grackle(hose);
disp_name = "Grackle (MPC106)"; disp_name = "Grackle (MPC106)";
} else if (strcmp(dev->name, "bandit") == 0) { } else if (strcmp(dev->name, "bandit") == 0) {
setup_bandit(hose, addr); setup_bandit(hose, &rsrc);
disp_name = "Bandit"; disp_name = "Bandit";
} else if (strcmp(dev->name, "chaos") == 0) { } else if (strcmp(dev->name, "chaos") == 0) {
setup_chaos(hose, addr); setup_chaos(hose, &rsrc);
disp_name = "Chaos"; disp_name = "Chaos";
primary = 0; primary = 0;
} }
printk(KERN_INFO "Found %s PCI host bridge at 0x%08lx. Firmware bus number: %d->%d\n", printk(KERN_INFO "Found %s PCI host bridge at 0x%08lx. "
disp_name, addr->address, hose->first_busno, hose->last_busno); "Firmware bus number: %d->%d\n",
#endif disp_name, rsrc.start, hose->first_busno, hose->last_busno);
#endif /* CONFIG_PPC32 */
DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n", DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
hose, hose->cfg_addr, hose->cfg_data); hose, hose->cfg_addr, hose->cfg_data);
...@@ -814,8 +817,7 @@ static int __init add_bridge(struct device_node *dev) ...@@ -814,8 +817,7 @@ static int __init add_bridge(struct device_node *dev)
return 0; return 0;
} }
static void __init static void __init pcibios_fixup_OF_interrupts(void)
pcibios_fixup_OF_interrupts(void)
{ {
struct pci_dev* dev = NULL; struct pci_dev* dev = NULL;
...@@ -835,8 +837,7 @@ pcibios_fixup_OF_interrupts(void) ...@@ -835,8 +837,7 @@ pcibios_fixup_OF_interrupts(void)
} }
} }
void __init void __init pmac_pcibios_fixup(void)
pmac_pcibios_fixup(void)
{ {
/* Fixup interrupts according to OF tree */ /* Fixup interrupts according to OF tree */
pcibios_fixup_OF_interrupts(); pcibios_fixup_OF_interrupts();
......
This diff is collapsed.
...@@ -42,10 +42,6 @@ extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, ...@@ -42,10 +42,6 @@ extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,
unsigned long data_port, unsigned long ctrl_port, int *irq); unsigned long data_port, unsigned long ctrl_port, int *irq);
extern int pmac_nvram_init(void); extern int pmac_nvram_init(void);
extern void pmac_pic_init(void);
extern struct hw_interrupt_type pmac_pic;
void pmac_pic_init(void);
int pmac_get_irq(struct pt_regs *regs);
#endif /* __PMAC_H__ */ #endif /* __PMAC_H__ */
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
#include <asm/iommu.h> #include <asm/iommu.h>
#include <asm/smu.h> #include <asm/smu.h>
#include <asm/pmc.h> #include <asm/pmc.h>
#include <asm/mpic.h>
#include <asm/lmb.h> #include <asm/lmb.h>
#include <asm/udbg.h> #include <asm/udbg.h>
...@@ -751,7 +750,7 @@ struct machdep_calls __initdata pmac_md = { ...@@ -751,7 +750,7 @@ struct machdep_calls __initdata pmac_md = {
.init_early = pmac_init_early, .init_early = pmac_init_early,
.show_cpuinfo = pmac_show_cpuinfo, .show_cpuinfo = pmac_show_cpuinfo,
.init_IRQ = pmac_pic_init, .init_IRQ = pmac_pic_init,
.get_irq = mpic_get_irq, /* changed later */ .get_irq = NULL, /* changed later */
.pcibios_fixup = pmac_pcibios_fixup, .pcibios_fixup = pmac_pcibios_fixup,
.restart = pmac_restart, .restart = pmac_restart,
.power_off = pmac_power_off, .power_off = pmac_power_off,
......
...@@ -258,15 +258,20 @@ int __init via_calibrate_decr(void) ...@@ -258,15 +258,20 @@ int __init via_calibrate_decr(void)
volatile unsigned char __iomem *via; volatile unsigned char __iomem *via;
int count = VIA_TIMER_FREQ_6 / 100; int count = VIA_TIMER_FREQ_6 / 100;
unsigned int dstart, dend; unsigned int dstart, dend;
struct resource rsrc;
vias = find_devices("via-cuda"); vias = of_find_node_by_name(NULL, "via-cuda");
if (vias == 0) if (vias == 0)
vias = find_devices("via-pmu"); vias = of_find_node_by_name(NULL, "via-pmu");
if (vias == 0) if (vias == 0)
vias = find_devices("via"); vias = of_find_node_by_name(NULL, "via");
if (vias == 0 || vias->n_addrs == 0) if (vias == 0 || of_address_to_resource(vias, 0, &rsrc))
return 0; return 0;
via = ioremap(vias->addrs[0].address, vias->addrs[0].size); via = ioremap(rsrc.start, rsrc.end - rsrc.start + 1);
if (via == NULL) {
printk(KERN_ERR "Failed to map VIA for timer calibration !\n");
return 0;
}
/* set timer 1 for continuous interrupts */ /* set timer 1 for continuous interrupts */
out_8(&via[ACR], (via[ACR] & ~T1MODE) | T1MODE_CONT); out_8(&via[ACR], (via[ACR] & ~T1MODE) | T1MODE_CONT);
......
...@@ -1083,23 +1083,33 @@ static int swim3_add_device(struct device_node *swim) ...@@ -1083,23 +1083,33 @@ static int swim3_add_device(struct device_node *swim)
{ {
struct device_node *mediabay; struct device_node *mediabay;
struct floppy_state *fs = &floppy_states[floppy_count]; struct floppy_state *fs = &floppy_states[floppy_count];
struct resource res_reg, res_dma;
if (swim->n_addrs < 2) if (of_address_to_resource(swim, 0, &res_reg) ||
{ of_address_to_resource(swim, 1, &res_dma)) {
printk(KERN_INFO "swim3: expecting 2 addrs (n_addrs:%d, n_intrs:%d)\n", printk(KERN_ERR "swim3: Can't get addresses\n");
swim->n_addrs, swim->n_intrs);
return -EINVAL; return -EINVAL;
} }
if (request_mem_region(res_reg.start, res_reg.end - res_reg.start + 1,
if (swim->n_intrs < 2) " (reg)") == NULL) {
{ printk(KERN_ERR "swim3: Can't request register space\n");
printk(KERN_INFO "swim3: expecting 2 intrs (n_addrs:%d, n_intrs:%d)\n", return -EINVAL;
swim->n_addrs, swim->n_intrs); }
if (request_mem_region(res_dma.start, res_dma.end - res_dma.start + 1,
" (dma)") == NULL) {
release_mem_region(res_reg.start,
res_reg.end - res_reg.start + 1);
printk(KERN_ERR "swim3: Can't request DMA space\n");
return -EINVAL; return -EINVAL;
} }
if (!request_OF_resource(swim, 0, NULL)) { if (swim->n_intrs < 2) {
printk(KERN_INFO "swim3: can't request IO resource !\n"); printk(KERN_INFO "swim3: expecting 2 intrs (n_intrs:%d)\n",
swim->n_intrs);
release_mem_region(res_reg.start,
res_reg.end - res_reg.start + 1);
release_mem_region(res_dma.start,
res_dma.end - res_dma.start + 1);
return -EINVAL; return -EINVAL;
} }
...@@ -1110,10 +1120,8 @@ static int swim3_add_device(struct device_node *swim) ...@@ -1110,10 +1120,8 @@ static int swim3_add_device(struct device_node *swim)
memset(fs, 0, sizeof(*fs)); memset(fs, 0, sizeof(*fs));
spin_lock_init(&fs->lock); spin_lock_init(&fs->lock);
fs->state = idle; fs->state = idle;
fs->swim3 = (struct swim3 __iomem *) fs->swim3 = (struct swim3 __iomem *)ioremap(res_reg.start, 0x200);
ioremap(swim->addrs[0].address, 0x200); fs->dma = (struct dbdma_regs __iomem *)ioremap(res_dma.start, 0x200);
fs->dma = (struct dbdma_regs __iomem *)
ioremap(swim->addrs[1].address, 0x200);
fs->swim3_intr = swim->intrs[0].line; fs->swim3_intr = swim->intrs[0].line;
fs->dma_intr = swim->intrs[1].line; fs->dma_intr = swim->intrs[1].line;
fs->cur_cyl = -1; fs->cur_cyl = -1;
......
...@@ -1271,7 +1271,7 @@ static int ...@@ -1271,7 +1271,7 @@ static int
pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
{ {
struct device_node *np = pmif->node; struct device_node *np = pmif->node;
int *bidp, i; int *bidp;
pmif->cable_80 = 0; pmif->cable_80 = 0;
pmif->broken_dma = pmif->broken_dma_warn = 0; pmif->broken_dma = pmif->broken_dma_warn = 0;
...@@ -1430,7 +1430,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) ...@@ -1430,7 +1430,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
pmif = &pmac_ide[i]; pmif = &pmac_ide[i];
hwif = &ide_hwifs[i]; hwif = &ide_hwifs[i];
if (mdev->ofdev.node->n_addrs == 0) { if (macio_resource_count(mdev) == 0) {
printk(KERN_WARNING "ide%d: no address for %s\n", printk(KERN_WARNING "ide%d: no address for %s\n",
i, mdev->ofdev.node->full_name); i, mdev->ofdev.node->full_name);
return -ENXIO; return -ENXIO;
......
...@@ -256,42 +256,42 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res, ...@@ -256,42 +256,42 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res,
{ {
if (res->flags & IORESOURCE_MEM) { if (res->flags & IORESOURCE_MEM) {
/* Grand Central has too large resource 0 on some machines */ /* Grand Central has too large resource 0 on some machines */
if (index == 0 && !strcmp(np->name, "gc")) { if (index == 0 && !strcmp(np->name, "gc"))
np->addrs[0].size = 0x20000;
res->end = res->start + 0x1ffff; res->end = res->start + 0x1ffff;
}
/* Airport has bogus resource 2 */ /* Airport has bogus resource 2 */
if (index >= 2 && !strcmp(np->name, "radio")) if (index >= 2 && !strcmp(np->name, "radio"))
return 1; return 1;
#ifndef CONFIG_PPC64
/* DBDMAs may have bogus sizes */ /* DBDMAs may have bogus sizes */
if ((res->start & 0x0001f000) == 0x00008000) { if ((res->start & 0x0001f000) == 0x00008000)
np->addrs[index].size = 0x100;
res->end = res->start + 0xff; res->end = res->start + 0xff;
} #endif /* CONFIG_PPC64 */
/* ESCC parent eats child resources. We could have added a /* ESCC parent eats child resources. We could have added a
* level of hierarchy, but I don't really feel the need * level of hierarchy, but I don't really feel the need
* for it * for it
*/ */
if (!strcmp(np->name, "escc")) if (!strcmp(np->name, "escc"))
return 1; return 1;
/* ESCC has bogus resources >= 3 */ /* ESCC has bogus resources >= 3 */
if (index >= 3 && !(strcmp(np->name, "ch-a") && if (index >= 3 && !(strcmp(np->name, "ch-a") &&
strcmp(np->name, "ch-b"))) strcmp(np->name, "ch-b")))
return 1; return 1;
/* Media bay has too many resources, keep only first one */ /* Media bay has too many resources, keep only first one */
if (index > 0 && !strcmp(np->name, "media-bay")) if (index > 0 && !strcmp(np->name, "media-bay"))
return 1; return 1;
/* Some older IDE resources have bogus sizes */ /* Some older IDE resources have bogus sizes */
if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") && if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") &&
strcmp(np->type, "ide") && strcmp(np->type, "ata"))) { strcmp(np->type, "ide") && strcmp(np->type, "ata"))) {
if (index == 0 && np->addrs[0].size > 0x1000) { if (index == 0 && (res->end - res->start) > 0xfff)
np->addrs[0].size = 0x1000;
res->end = res->start + 0xfff; res->end = res->start + 0xfff;
} if (index == 1 && (res->end - res->start) > 0xff)
if (index == 1 && np->addrs[1].size > 0x100) {
np->addrs[1].size = 0x100;
res->end = res->start + 0xff; res->end = res->start + 0xff;
}
} }
} }
return 0; return 0;
...@@ -349,7 +349,7 @@ static void macio_setup_resources(struct macio_dev *dev, ...@@ -349,7 +349,7 @@ static void macio_setup_resources(struct macio_dev *dev,
/* Currently, we consider failure as harmless, this may /* Currently, we consider failure as harmless, this may
* change in the future, once I've found all the device * change in the future, once I've found all the device
* tree bugs in older machines & worked around them * tree bugs in older machines & worked around them
l */ */
if (insert_resource(parent_res, res)) { if (insert_resource(parent_res, res)) {
printk(KERN_WARNING "Can't request resource " printk(KERN_WARNING "Can't request resource "
"%d for MacIO device %s\n", "%d for MacIO device %s\n",
......
...@@ -647,6 +647,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de ...@@ -647,6 +647,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de
struct media_bay_info* bay; struct media_bay_info* bay;
u32 __iomem *regbase; u32 __iomem *regbase;
struct device_node *ofnode; struct device_node *ofnode;
unsigned long base;
int i; int i;
ofnode = mdev->ofdev.node; ofnode = mdev->ofdev.node;
...@@ -656,10 +657,11 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de ...@@ -656,10 +657,11 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de
if (macio_request_resources(mdev, "media-bay")) if (macio_request_resources(mdev, "media-bay"))
return -EBUSY; return -EBUSY;
/* Media bay registers are located at the beginning of the /* Media bay registers are located at the beginning of the
* mac-io chip, we get the parent address for now (hrm...) * mac-io chip, for now, we trick and align down the first
* resource passed in
*/ */
regbase = (u32 __iomem *) base = macio_resource_start(mdev, 0) & 0xffff0000u;
ioremap(ofnode->parent->addrs[0].address, 0x100); regbase = (u32 __iomem *)ioremap(base, 0x100);
if (regbase == NULL) { if (regbase == NULL) {
macio_release_resources(mdev); macio_release_resources(mdev);
return -ENOMEM; return -ENOMEM;
......
...@@ -193,10 +193,6 @@ static int __init via_cuda_start(void) ...@@ -193,10 +193,6 @@ static int __init via_cuda_start(void)
if (via == NULL) if (via == NULL)
return -ENODEV; return -ENODEV;
#ifdef CONFIG_PPC
request_OF_resource(vias, 0, NULL);
#endif
if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) {
printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ);
return -EAGAIN; return -EAGAIN;
......
...@@ -298,7 +298,7 @@ static struct backlight_controller pmu_backlight_controller = { ...@@ -298,7 +298,7 @@ static struct backlight_controller pmu_backlight_controller = {
int __init find_via_pmu(void) int __init find_via_pmu(void)
{ {
phys_addr_t taddr; u64 taddr;
u32 *reg; u32 *reg;
if (via != 0) if (via != 0)
...@@ -337,7 +337,7 @@ int __init find_via_pmu(void) ...@@ -337,7 +337,7 @@ int __init find_via_pmu(void)
else if (device_is_compatible(vias->parent, "Keylargo") else if (device_is_compatible(vias->parent, "Keylargo")
|| device_is_compatible(vias->parent, "K2-Keylargo")) { || device_is_compatible(vias->parent, "K2-Keylargo")) {
struct device_node *gpiop; struct device_node *gpiop;
phys_addr_t gaddr = 0; u64 gaddr = OF_BAD_ADDR;
pmu_kind = PMU_KEYLARGO_BASED; pmu_kind = PMU_KEYLARGO_BASED;
pmu_has_adb = (find_type_devices("adb") != NULL); pmu_has_adb = (find_type_devices("adb") != NULL);
...@@ -352,7 +352,7 @@ int __init find_via_pmu(void) ...@@ -352,7 +352,7 @@ int __init find_via_pmu(void)
reg = (u32 *)get_property(gpiop, "reg", NULL); reg = (u32 *)get_property(gpiop, "reg", NULL);
if (reg) if (reg)
gaddr = of_translate_address(gpiop, reg); gaddr = of_translate_address(gpiop, reg);
if (gaddr != 0) if (gaddr != OF_BAD_ADDR)
gpio_reg = ioremap(gaddr, 0x10); gpio_reg = ioremap(gaddr, 0x10);
} }
if (gpio_reg == NULL) if (gpio_reg == NULL)
...@@ -479,9 +479,6 @@ static int __init via_pmu_dev_init(void) ...@@ -479,9 +479,6 @@ static int __init via_pmu_dev_init(void)
if (vias == NULL) if (vias == NULL)
return -ENODEV; return -ENODEV;
#ifndef CONFIG_PPC64
request_OF_resource(vias, 0, NULL);
#endif
#ifdef CONFIG_PMAC_BACKLIGHT #ifdef CONFIG_PMAC_BACKLIGHT
/* Enable backlight */ /* Enable backlight */
register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); register_backlight_controller(&pmu_backlight_controller, NULL, "pmu");
......
...@@ -432,11 +432,12 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat ...@@ -432,11 +432,12 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
struct Scsi_Host *host; struct Scsi_Host *host;
void *dma_cmd_space; void *dma_cmd_space;
unsigned char *clkprop; unsigned char *clkprop;
int proplen; int proplen, rc = -ENODEV;
if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) { if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
printk(KERN_ERR "mac53c94: expected 2 addrs and intrs (got %d/%d)\n", printk(KERN_ERR "mac53c94: expected 2 addrs and intrs"
node->n_addrs, node->n_intrs); " (got %d/%d)\n",
macio_resource_count(mdev), macio_irq_count(mdev));
return -ENODEV; return -ENODEV;
} }
...@@ -448,6 +449,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat ...@@ -448,6 +449,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
host = scsi_host_alloc(&mac53c94_template, sizeof(struct fsc_state)); host = scsi_host_alloc(&mac53c94_template, sizeof(struct fsc_state));
if (host == NULL) { if (host == NULL) {
printk(KERN_ERR "mac53c94: couldn't register host"); printk(KERN_ERR "mac53c94: couldn't register host");
rc = -ENOMEM;
goto out_release; goto out_release;
} }
...@@ -486,6 +488,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat ...@@ -486,6 +488,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
if (dma_cmd_space == 0) { if (dma_cmd_space == 0) {
printk(KERN_ERR "mac53c94: couldn't allocate dma " printk(KERN_ERR "mac53c94: couldn't allocate dma "
"command space for %s\n", node->full_name); "command space for %s\n", node->full_name);
rc = -ENOMEM;
goto out_free; goto out_free;
} }
state->dma_cmds = (struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space); state->dma_cmds = (struct dbdma_cmd *)DBDMA_ALIGN(dma_cmd_space);
...@@ -495,18 +498,21 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat ...@@ -495,18 +498,21 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
mac53c94_init(state); mac53c94_init(state);
if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94", state)) { if (request_irq(state->intr, do_mac53c94_interrupt, 0, "53C94",state)) {
printk(KERN_ERR "mac53C94: can't get irq %d for %s\n", printk(KERN_ERR "mac53C94: can't get irq %d for %s\n",
state->intr, node->full_name); state->intr, node->full_name);
goto out_free_dma; goto out_free_dma;
} }
/* XXX FIXME: handle failure */ rc = scsi_add_host(host, &mdev->ofdev.dev);
scsi_add_host(host, &mdev->ofdev.dev); if (rc != 0)
scsi_scan_host(host); goto out_release_irq;
scsi_scan_host(host);
return 0; return 0;
out_release_irq:
free_irq(state->intr, state);
out_free_dma: out_free_dma:
kfree(state->dma_cmd_space); kfree(state->dma_cmd_space);
out_free: out_free:
...@@ -518,7 +524,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat ...@@ -518,7 +524,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
out_release: out_release:
macio_release_resources(mdev); macio_release_resources(mdev);
return -ENODEV; return rc;
} }
static int mac53c94_remove(struct macio_dev *mdev) static int mac53c94_remove(struct macio_dev *mdev)
......
...@@ -1869,7 +1869,8 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) ...@@ -1869,7 +1869,8 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) { if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
printk(KERN_ERR "mesh: expected 2 addrs and 2 intrs" printk(KERN_ERR "mesh: expected 2 addrs and 2 intrs"
" (got %d,%d)\n", mesh->n_addrs, mesh->n_intrs); " (got %d,%d)\n", macio_resource_count(mdev),
macio_irq_count(mdev));
return -ENODEV; return -ENODEV;
} }
......
...@@ -1431,11 +1431,14 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) ...@@ -1431,11 +1431,14 @@ static int __init pmz_init_port(struct uart_pmac_port *uap)
char name[1]; char name[1];
} *slots; } *slots;
int len; int len;
struct resource r_ports, r_rxdma, r_txdma;
/* /*
* Request & map chip registers * Request & map chip registers
*/ */
uap->port.mapbase = np->addrs[0].address; if (of_address_to_resource(np, 0, &r_ports))
return -ENODEV;
uap->port.mapbase = r_ports.start;
uap->port.membase = ioremap(uap->port.mapbase, 0x1000); uap->port.membase = ioremap(uap->port.mapbase, 0x1000);
uap->control_reg = uap->port.membase; uap->control_reg = uap->port.membase;
...@@ -1445,16 +1448,20 @@ static int __init pmz_init_port(struct uart_pmac_port *uap) ...@@ -1445,16 +1448,20 @@ static int __init pmz_init_port(struct uart_pmac_port *uap)
* Request & map DBDMA registers * Request & map DBDMA registers
*/ */
#ifdef HAS_DBDMA #ifdef HAS_DBDMA
if (np->n_addrs >= 3 && np->n_intrs >= 3) if (of_address_to_resource(np, 1, &r_txdma) == 0 &&
of_address_to_resource(np, 2, &r_rxdma) == 0)
uap->flags |= PMACZILOG_FLAG_HAS_DMA; uap->flags |= PMACZILOG_FLAG_HAS_DMA;
#else
memset(&r_txdma, 0, sizeof(struct resource));
memset(&r_rxdma, 0, sizeof(struct resource));
#endif #endif
if (ZS_HAS_DMA(uap)) { if (ZS_HAS_DMA(uap)) {
uap->tx_dma_regs = ioremap(np->addrs[np->n_addrs - 2].address, 0x1000); uap->tx_dma_regs = ioremap(r_txdma.start, 0x100);
if (uap->tx_dma_regs == NULL) { if (uap->tx_dma_regs == NULL) {
uap->flags &= ~PMACZILOG_FLAG_HAS_DMA; uap->flags &= ~PMACZILOG_FLAG_HAS_DMA;
goto no_dma; goto no_dma;
} }
uap->rx_dma_regs = ioremap(np->addrs[np->n_addrs - 1].address, 0x1000); uap->rx_dma_regs = ioremap(r_rxdma.start, 0x100);
if (uap->rx_dma_regs == NULL) { if (uap->rx_dma_regs == NULL) {
iounmap(uap->tx_dma_regs); iounmap(uap->tx_dma_regs);
uap->tx_dma_regs = NULL; uap->tx_dma_regs = NULL;
......
...@@ -133,12 +133,6 @@ static int controlfb_mmap(struct fb_info *info, struct file *file, ...@@ -133,12 +133,6 @@ static int controlfb_mmap(struct fb_info *info, struct file *file,
static int controlfb_set_par (struct fb_info *info); static int controlfb_set_par (struct fb_info *info);
static int controlfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info); static int controlfb_check_var (struct fb_var_screeninfo *var, struct fb_info *info);
/*
* inititialization
*/
int control_init(void);
void control_setup(char *);
/******************** Prototypes for internal functions **********************/ /******************** Prototypes for internal functions **********************/
static void set_control_clock(unsigned char *params); static void set_control_clock(unsigned char *params);
...@@ -550,9 +544,46 @@ static void control_set_hardware(struct fb_info_control *p, struct fb_par_contro ...@@ -550,9 +544,46 @@ static void control_set_hardware(struct fb_info_control *p, struct fb_par_contro
/* /*
* Called from fbmem.c for probing & initializing * Parse user speficied options (`video=controlfb:')
*/ */
int __init control_init(void) static void __init control_setup(char *options)
{
char *this_opt;
if (!options || !*options)
return;
while ((this_opt = strsep(&options, ",")) != NULL) {
if (!strncmp(this_opt, "vmode:", 6)) {
int vmode = simple_strtoul(this_opt+6, NULL, 0);
if (vmode > 0 && vmode <= VMODE_MAX &&
control_mac_modes[vmode - 1].m[1] >= 0)
default_vmode = vmode;
} else if (!strncmp(this_opt, "cmode:", 6)) {
int depth = simple_strtoul(this_opt+6, NULL, 0);
switch (depth) {
case CMODE_8:
case CMODE_16:
case CMODE_32:
default_cmode = depth;
break;
case 8:
default_cmode = CMODE_8;
break;
case 15:
case 16:
default_cmode = CMODE_16;
break;
case 24:
case 32:
default_cmode = CMODE_32;
break;
}
}
}
}
static int __init control_init(void)
{ {
struct device_node *dp; struct device_node *dp;
char *option = NULL; char *option = NULL;
...@@ -651,15 +682,16 @@ static void __init find_vram_size(struct fb_info_control *p) ...@@ -651,15 +682,16 @@ static void __init find_vram_size(struct fb_info_control *p)
static int __init control_of_init(struct device_node *dp) static int __init control_of_init(struct device_node *dp)
{ {
struct fb_info_control *p; struct fb_info_control *p;
unsigned long addr; struct resource fb_res, reg_res;
int i;
if (control_fb) { if (control_fb) {
printk(KERN_ERR "controlfb: only one control is supported\n"); printk(KERN_ERR "controlfb: only one control is supported\n");
return -ENXIO; return -ENXIO;
} }
if(dp->n_addrs != 2) {
printk(KERN_ERR "expecting 2 address for control (got %d)", dp->n_addrs); if (of_pci_address_to_resource(dp, 2, &fb_res) ||
of_pci_address_to_resource(dp, 1, &reg_res)) {
printk(KERN_ERR "can't get 2 addresses for control\n");
return -ENXIO; return -ENXIO;
} }
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kmalloc(sizeof(*p), GFP_KERNEL);
...@@ -669,18 +701,12 @@ static int __init control_of_init(struct device_node *dp) ...@@ -669,18 +701,12 @@ static int __init control_of_init(struct device_node *dp)
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
/* Map in frame buffer and registers */ /* Map in frame buffer and registers */
for (i = 0; i < dp->n_addrs; ++i) { p->fb_orig_base = fb_res.start;
addr = dp->addrs[i].address; p->fb_orig_size = fb_res.end - fb_res.start + 1;
if (dp->addrs[i].size >= 0x800000) { /* use the big-endian aperture (??) */
p->fb_orig_base = addr; p->frame_buffer_phys = fb_res.start + 0x800000;
p->fb_orig_size = dp->addrs[i].size; p->control_regs_phys = reg_res.start;
/* use the big-endian aperture (??) */ p->control_regs_size = reg_res.end - reg_res.start + 1;
p->frame_buffer_phys = addr + 0x800000;
} else {
p->control_regs_phys = addr;
p->control_regs_size = dp->addrs[i].size;
}
}
if (!p->fb_orig_base || if (!p->fb_orig_base ||
!request_mem_region(p->fb_orig_base,p->fb_orig_size,"controlfb")) { !request_mem_region(p->fb_orig_base,p->fb_orig_size,"controlfb")) {
...@@ -1059,43 +1085,3 @@ static void control_cleanup(void) ...@@ -1059,43 +1085,3 @@ static void control_cleanup(void)
} }
/*
* Parse user speficied options (`video=controlfb:')
*/
void __init control_setup(char *options)
{
char *this_opt;
if (!options || !*options)
return;
while ((this_opt = strsep(&options, ",")) != NULL) {
if (!strncmp(this_opt, "vmode:", 6)) {
int vmode = simple_strtoul(this_opt+6, NULL, 0);
if (vmode > 0 && vmode <= VMODE_MAX &&
control_mac_modes[vmode - 1].m[1] >= 0)
default_vmode = vmode;
} else if (!strncmp(this_opt, "cmode:", 6)) {
int depth = simple_strtoul(this_opt+6, NULL, 0);
switch (depth) {
case CMODE_8:
case CMODE_16:
case CMODE_32:
default_cmode = depth;
break;
case 8:
default_cmode = CMODE_8;
break;
case 15:
case 16:
default_cmode = CMODE_16;
break;
case 24:
case 32:
default_cmode = CMODE_32;
break;
}
}
}
}
...@@ -223,6 +223,7 @@ static int offb_blank(int blank, struct fb_info *info) ...@@ -223,6 +223,7 @@ static int offb_blank(int blank, struct fb_info *info)
int __init offb_init(void) int __init offb_init(void)
{ {
struct device_node *dp = NULL, *boot_disp = NULL; struct device_node *dp = NULL, *boot_disp = NULL;
#if defined(CONFIG_BOOTX_TEXT) && defined(CONFIG_PPC32) #if defined(CONFIG_BOOTX_TEXT) && defined(CONFIG_PPC32)
struct device_node *macos_display = NULL; struct device_node *macos_display = NULL;
#endif #endif
...@@ -234,60 +235,54 @@ int __init offb_init(void) ...@@ -234,60 +235,54 @@ int __init offb_init(void)
if (boot_infos != 0) { if (boot_infos != 0) {
unsigned long addr = unsigned long addr =
(unsigned long) boot_infos->dispDeviceBase; (unsigned long) boot_infos->dispDeviceBase;
u32 *addrp;
u64 daddr, dsize;
unsigned int flags;
/* find the device node corresponding to the macos display */ /* find the device node corresponding to the macos display */
while ((dp = of_find_node_by_type(dp, "display"))) { while ((dp = of_find_node_by_type(dp, "display"))) {
int i; int i;
/*
* Grrr... It looks like the MacOS ATI driver
* munges the assigned-addresses property (but
* the AAPL,address value is OK).
*/
if (strncmp(dp->name, "ATY,", 4) == 0
&& dp->n_addrs == 1) {
unsigned int *ap =
(unsigned int *) get_property(dp,
"AAPL,address",
NULL);
if (ap != NULL) {
dp->addrs[0].address = *ap;
dp->addrs[0].size = 0x01000000;
}
}
/* /*
* The LTPro on the Lombard powerbook has no addresses * Look for an AAPL,address property first.
* on the display nodes, they are on their parent.
*/ */
if (dp->n_addrs == 0 unsigned int na;
&& device_is_compatible(dp, "ATY,264LTPro")) { unsigned int *ap =
int na; (unsigned int *)get_property(dp, "AAPL,address",
unsigned int *ap = (unsigned int *) &na);
get_property(dp, "AAPL,address", &na); if (ap != 0) {
if (ap != 0) for (na /= sizeof(unsigned int); na > 0;
for (na /= sizeof(unsigned int); --na, ++ap)
na > 0; --na, ++ap) if (*ap <= addr &&
if (*ap <= addr addr < *ap + 0x1000000) {
&& addr < macos_display = dp;
*ap + 0x1000000) goto foundit;
goto foundit; }
} }
/* /*
* See if the display address is in one of the address * See if the display address is in one of the address
* ranges for this display. * ranges for this display.
*/ */
for (i = 0; i < dp->n_addrs; ++i) { i = 0;
if (dp->addrs[i].address <= addr for (;;) {
&& addr < addrp = of_get_address(dp, i++, &dsize, &flags);
dp->addrs[i].address + if (addrp == NULL)
dp->addrs[i].size)
break; break;
if (!(flags & IORESOURCE_MEM))
continue;
daddr = of_translate_address(dp, addrp);
if (daddr == OF_BAD_ADDR)
continue;
if (daddr <= addr && addr < (daddr + dsize)) {
macos_display = dp;
goto foundit;
}
} }
if (i < dp->n_addrs) { foundit:
foundit: if (macos_display) {
printk(KERN_INFO "MacOS display is %s\n", printk(KERN_INFO "MacOS display is %s\n",
dp->full_name); dp->full_name);
macos_display = dp;
break; break;
} }
} }
...@@ -326,8 +321,10 @@ static void __init offb_init_nodriver(struct device_node *dp) ...@@ -326,8 +321,10 @@ static void __init offb_init_nodriver(struct device_node *dp)
int *pp, i; int *pp, i;
unsigned int len; unsigned int len;
int width = 640, height = 480, depth = 8, pitch; int width = 640, height = 480, depth = 8, pitch;
unsigned int rsize, *up; unsigned int flags, rsize, *up;
unsigned long address = 0; u64 address = OF_BAD_ADDR;
u32 *addrp;
u64 asize;
if ((pp = (int *) get_property(dp, "depth", &len)) != NULL if ((pp = (int *) get_property(dp, "depth", &len)) != NULL
&& len == sizeof(int)) && len == sizeof(int))
...@@ -363,7 +360,7 @@ static void __init offb_init_nodriver(struct device_node *dp) ...@@ -363,7 +360,7 @@ static void __init offb_init_nodriver(struct device_node *dp)
break; break;
} }
if (pdev) { if (pdev) {
for (i = 0; i < 6 && address == 0; i++) { for (i = 0; i < 6 && address == OF_BAD_ADDR; i++) {
if ((pci_resource_flags(pdev, i) & if ((pci_resource_flags(pdev, i) &
IORESOURCE_MEM) && IORESOURCE_MEM) &&
(pci_resource_len(pdev, i) >= rsize)) (pci_resource_len(pdev, i) >= rsize))
...@@ -374,27 +371,33 @@ static void __init offb_init_nodriver(struct device_node *dp) ...@@ -374,27 +371,33 @@ static void __init offb_init_nodriver(struct device_node *dp)
} }
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
if (address == 0 && /* This one is dodgy, we may drop it ... */
(up = (unsigned *) get_property(dp, "address", &len)) != NULL && if (address == OF_BAD_ADDR &&
len == sizeof(unsigned)) (up = (unsigned *) get_property(dp, "address", &len)) != NULL &&
address = (u_long) * up; len == sizeof(unsigned int))
if (address == 0) { address = (u64) * up;
for (i = 0; i < dp->n_addrs; ++i)
if (dp->addrs[i].size >= if (address == OF_BAD_ADDR) {
pitch * height * depth / 8) for (i = 0; (addrp = of_get_address(dp, i, &asize, &flags))
break; != NULL; i++) {
if (i >= dp->n_addrs) { if (!(flags & IORESOURCE_MEM))
continue;
if (asize >= pitch * height * depth / 8)
break;
}
if (addrp == NULL) {
printk(KERN_ERR printk(KERN_ERR
"no framebuffer address found for %s\n", "no framebuffer address found for %s\n",
dp->full_name); dp->full_name);
return; return;
} }
address = of_translate_address(dp, addrp);
address = (u_long) dp->addrs[i].address; if (address == OF_BAD_ADDR) {
printk(KERN_ERR
#ifdef CONFIG_PPC64 "can't translate framebuffer address for %s\n",
address += ((struct pci_dn *)dp->data)->phb->pci_mem_offset; dp->full_name);
#endif return;
}
/* kludge for valkyrie */ /* kludge for valkyrie */
if (strcmp(dp->name, "valkyrie") == 0) if (strcmp(dp->name, "valkyrie") == 0)
...@@ -459,7 +462,9 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -459,7 +462,9 @@ static void __init offb_init_fb(const char *name, const char *full_name,
par->cmap_type = cmap_unknown; par->cmap_type = cmap_unknown;
if (depth == 8) { if (depth == 8) {
/* XXX kludge for ati */
/* Palette hacks disabled for now */
#if 0
if (dp && !strncmp(name, "ATY,Rage128", 11)) { if (dp && !strncmp(name, "ATY,Rage128", 11)) {
unsigned long regbase = dp->addrs[2].address; unsigned long regbase = dp->addrs[2].address;
par->cmap_adr = ioremap(regbase, 0x1FFF); par->cmap_adr = ioremap(regbase, 0x1FFF);
...@@ -490,6 +495,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -490,6 +495,7 @@ static void __init offb_init_fb(const char *name, const char *full_name,
par->cmap_adr = ioremap(regbase + 0x6000, 0x1000); par->cmap_adr = ioremap(regbase + 0x6000, 0x1000);
par->cmap_type = cmap_gxt2000; par->cmap_type = cmap_gxt2000;
} }
#endif
fix->visual = par->cmap_adr ? FB_VISUAL_PSEUDOCOLOR fix->visual = par->cmap_adr ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_STATIC_PSEUDOCOLOR; : FB_VISUAL_STATIC_PSEUDOCOLOR;
} else } else
......
...@@ -69,6 +69,8 @@ struct fb_info_platinum { ...@@ -69,6 +69,8 @@ struct fb_info_platinum {
unsigned long total_vram; unsigned long total_vram;
int clktype; int clktype;
int dactype; int dactype;
struct resource rsrc_fb, rsrc_reg;
}; };
/* /*
...@@ -97,9 +99,6 @@ static int platinum_var_to_par(struct fb_var_screeninfo *var, ...@@ -97,9 +99,6 @@ static int platinum_var_to_par(struct fb_var_screeninfo *var,
* Interface used by the world * Interface used by the world
*/ */
int platinumfb_init(void);
int platinumfb_setup(char*);
static struct fb_ops platinumfb_ops = { static struct fb_ops platinumfb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_check_var = platinumfb_check_var, .fb_check_var = platinumfb_check_var,
...@@ -485,7 +484,7 @@ static int platinum_var_to_par(struct fb_var_screeninfo *var, ...@@ -485,7 +484,7 @@ static int platinum_var_to_par(struct fb_var_screeninfo *var,
/* /*
* Parse user speficied options (`video=platinumfb:') * Parse user speficied options (`video=platinumfb:')
*/ */
int __init platinumfb_setup(char *options) static int __init platinumfb_setup(char *options)
{ {
char *this_opt; char *this_opt;
...@@ -526,19 +525,15 @@ int __init platinumfb_setup(char *options) ...@@ -526,19 +525,15 @@ int __init platinumfb_setup(char *options)
#define invalidate_cache(addr) #define invalidate_cache(addr)
#endif #endif
static int __devinit platinumfb_probe(struct of_device* odev, const struct of_device_id *match) static int __devinit platinumfb_probe(struct of_device* odev,
const struct of_device_id *match)
{ {
struct device_node *dp = odev->node; struct device_node *dp = odev->node;
struct fb_info *info; struct fb_info *info;
struct fb_info_platinum *pinfo; struct fb_info_platinum *pinfo;
unsigned long addr, size;
volatile __u8 *fbuffer; volatile __u8 *fbuffer;
int i, bank0, bank1, bank2, bank3, rc; int bank0, bank1, bank2, bank3, rc;
if (dp->n_addrs != 2) {
printk(KERN_ERR "expecting 2 address for platinum (got %d)", dp->n_addrs);
return -ENXIO;
}
printk(KERN_INFO "platinumfb: Found Apple Platinum video hardware\n"); printk(KERN_INFO "platinumfb: Found Apple Platinum video hardware\n");
info = framebuffer_alloc(sizeof(*pinfo), &odev->dev); info = framebuffer_alloc(sizeof(*pinfo), &odev->dev);
...@@ -546,26 +541,39 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_de ...@@ -546,26 +541,39 @@ static int __devinit platinumfb_probe(struct of_device* odev, const struct of_de
return -ENOMEM; return -ENOMEM;
pinfo = info->par; pinfo = info->par;
/* Map in frame buffer and registers */ if (of_address_to_resource(dp, 0, &pinfo->rsrc_reg) ||
for (i = 0; i < dp->n_addrs; ++i) { of_address_to_resource(dp, 1, &pinfo->rsrc_fb)) {
addr = dp->addrs[i].address; printk(KERN_ERR "platinumfb: Can't get resources\n");
size = dp->addrs[i].size; framebuffer_release(info);
/* Let's assume we can request either all or nothing */ return -ENXIO;
if (!request_mem_region(addr, size, "platinumfb")) {
framebuffer_release(info);
return -ENXIO;
}
if (size >= 0x400000) {
/* frame buffer - map only 4MB */
pinfo->frame_buffer_phys = addr;
pinfo->frame_buffer = __ioremap(addr, 0x400000, _PAGE_WRITETHRU);
pinfo->base_frame_buffer = pinfo->frame_buffer;
} else {
/* registers */
pinfo->platinum_regs_phys = addr;
pinfo->platinum_regs = ioremap(addr, size);
}
} }
if (!request_mem_region(pinfo->rsrc_reg.start,
pinfo->rsrc_reg.start -
pinfo->rsrc_reg.end + 1,
"platinumfb registers")) {
framebuffer_release(info);
return -ENXIO;
}
if (!request_mem_region(pinfo->rsrc_fb.start,
pinfo->rsrc_fb.start
- pinfo->rsrc_fb.end + 1,
"platinumfb framebuffer")) {
release_mem_region(pinfo->rsrc_reg.start,
pinfo->rsrc_reg.end -
pinfo->rsrc_reg.start + 1);
framebuffer_release(info);
return -ENXIO;
}
/* frame buffer - map only 4MB */
pinfo->frame_buffer_phys = pinfo->rsrc_fb.start;
pinfo->frame_buffer = __ioremap(pinfo->rsrc_fb.start, 0x400000,
_PAGE_WRITETHRU);
pinfo->base_frame_buffer = pinfo->frame_buffer;
/* registers */
pinfo->platinum_regs_phys = pinfo->rsrc_reg.start;
pinfo->platinum_regs = ioremap(pinfo->rsrc_reg.start, 0x1000);
pinfo->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */ pinfo->cmap_regs_phys = 0xf301b000; /* XXX not in prom? */
request_mem_region(pinfo->cmap_regs_phys, 0x1000, "platinumfb cmap"); request_mem_region(pinfo->cmap_regs_phys, 0x1000, "platinumfb cmap");
...@@ -628,18 +636,16 @@ static int __devexit platinumfb_remove(struct of_device* odev) ...@@ -628,18 +636,16 @@ static int __devexit platinumfb_remove(struct of_device* odev)
{ {
struct fb_info *info = dev_get_drvdata(&odev->dev); struct fb_info *info = dev_get_drvdata(&odev->dev);
struct fb_info_platinum *pinfo = info->par; struct fb_info_platinum *pinfo = info->par;
struct device_node *dp = odev->node;
unsigned long addr, size;
int i;
unregister_framebuffer (info); unregister_framebuffer (info);
/* Unmap frame buffer and registers */ /* Unmap frame buffer and registers */
for (i = 0; i < dp->n_addrs; ++i) { release_mem_region(pinfo->rsrc_fb.start,
addr = dp->addrs[i].address; pinfo->rsrc_fb.end -
size = dp->addrs[i].size; pinfo->rsrc_fb.start + 1);
release_mem_region(addr, size); release_mem_region(pinfo->rsrc_reg.start,
} pinfo->rsrc_reg.end -
pinfo->rsrc_reg.start + 1);
iounmap(pinfo->frame_buffer); iounmap(pinfo->frame_buffer);
iounmap(pinfo->platinum_regs); iounmap(pinfo->platinum_regs);
release_mem_region(pinfo->cmap_regs_phys, 0x1000); release_mem_region(pinfo->cmap_regs_phys, 0x1000);
...@@ -666,7 +672,7 @@ static struct of_platform_driver platinum_driver = ...@@ -666,7 +672,7 @@ static struct of_platform_driver platinum_driver =
.remove = platinumfb_remove, .remove = platinumfb_remove,
}; };
int __init platinumfb_init(void) static int __init platinumfb_init(void)
{ {
#ifndef MODULE #ifndef MODULE
char *option = NULL; char *option = NULL;
...@@ -680,7 +686,7 @@ int __init platinumfb_init(void) ...@@ -680,7 +686,7 @@ int __init platinumfb_init(void)
return 0; return 0;
} }
void __exit platinumfb_exit(void) static void __exit platinumfb_exit(void)
{ {
of_unregister_driver(&platinum_driver); of_unregister_driver(&platinum_driver);
} }
......
...@@ -342,19 +342,19 @@ int __init valkyriefb_init(void) ...@@ -342,19 +342,19 @@ int __init valkyriefb_init(void)
#else /* ppc (!CONFIG_MAC) */ #else /* ppc (!CONFIG_MAC) */
{ {
struct device_node *dp; struct device_node *dp;
struct resource r;
dp = find_devices("valkyrie"); dp = of_find_node_by_name(NULL, "valkyrie");
if (dp == 0) if (dp == 0)
return 0; return 0;
if (dp->n_addrs != 1) { if (of_address_to_resource(dp, 0, &r)) {
printk(KERN_ERR "expecting 1 address for valkyrie (got %d)\n", printk(KERN_ERR "can't find address for valkyrie\n");
dp->n_addrs);
return 0; return 0;
} }
frame_buffer_phys = dp->addrs[0].address; frame_buffer_phys = r.start;
cmap_regs_phys = dp->addrs[0].address+0x304000; cmap_regs_phys = r.start + 0x304000;
flags = _PAGE_WRITETHRU; flags = _PAGE_WRITETHRU;
} }
#endif /* ppc (!CONFIG_MAC) */ #endif /* ppc (!CONFIG_MAC) */
......
...@@ -232,10 +232,12 @@ ...@@ -232,10 +232,12 @@
#define K2_FCR1_I2S0_RESET 0x00000800 #define K2_FCR1_I2S0_RESET 0x00000800
#define K2_FCR1_I2S0_CLK_ENABLE_BIT 0x00001000 #define K2_FCR1_I2S0_CLK_ENABLE_BIT 0x00001000
#define K2_FCR1_I2S0_ENABLE 0x00002000 #define K2_FCR1_I2S0_ENABLE 0x00002000
#define K2_FCR1_PCI1_CLK_ENABLE 0x00004000 #define K2_FCR1_PCI1_CLK_ENABLE 0x00004000
#define K2_FCR1_FW_CLK_ENABLE 0x00008000 #define K2_FCR1_FW_CLK_ENABLE 0x00008000
#define K2_FCR1_FW_RESET_N 0x00010000 #define K2_FCR1_FW_RESET_N 0x00010000
#define K2_FCR1_I2S1_CELL_ENABLE 0x00020000
#define K2_FCR1_I2S1_CLK_ENABLE_BIT 0x00080000
#define K2_FCR1_I2S1_ENABLE 0x00100000
#define K2_FCR1_GMAC_CLK_ENABLE 0x00400000 #define K2_FCR1_GMAC_CLK_ENABLE 0x00400000
#define K2_FCR1_GMAC_POWER_DOWN 0x00800000 #define K2_FCR1_GMAC_POWER_DOWN 0x00800000
#define K2_FCR1_GMAC_RESET_N 0x01000000 #define K2_FCR1_GMAC_RESET_N 0x01000000
...@@ -246,3 +248,9 @@ ...@@ -246,3 +248,9 @@
#define K2_FCR1_UATA_RESET_N 0x40000000 #define K2_FCR1_UATA_RESET_N 0x40000000
#define K2_FCR1_UATA_CHOOSE_CLK66 0x80000000 #define K2_FCR1_UATA_CHOOSE_CLK66 0x80000000
/* Shasta definitions */
#define SH_FCR1_I2S2_CELL_ENABLE 0x00000010
#define SH_FCR1_I2S2_CLK_ENABLE_BIT 0x00000040
#define SH_FCR1_I2S2_ENABLE 0x00000080
#define SH_FCR3_I2S2_CLK18_ENABLE 0x00008000
...@@ -65,49 +65,11 @@ struct boot_param_header ...@@ -65,49 +65,11 @@ struct boot_param_header
typedef u32 phandle; typedef u32 phandle;
typedef u32 ihandle; typedef u32 ihandle;
struct address_range {
unsigned long space;
unsigned long address;
unsigned long size;
};
struct interrupt_info { struct interrupt_info {
int line; int line;
int sense; /* +ve/-ve logic, edge or level, etc. */ int sense; /* +ve/-ve logic, edge or level, etc. */
}; };
struct pci_address {
u32 a_hi;
u32 a_mid;
u32 a_lo;
};
struct isa_address {
u32 a_hi;
u32 a_lo;
};
struct isa_range {
struct isa_address isa_addr;
struct pci_address pci_addr;
unsigned int size;
};
struct reg_property {
unsigned long address;
unsigned long size;
};
struct reg_property32 {
unsigned int address;
unsigned int size;
};
struct reg_property64 {
u64 address;
u64 size;
};
struct property { struct property {
char *name; char *name;
int length; int length;
...@@ -120,8 +82,6 @@ struct device_node { ...@@ -120,8 +82,6 @@ struct device_node {
char *type; char *type;
phandle node; phandle node;
phandle linux_phandle; phandle linux_phandle;
int n_addrs;
struct address_range *addrs;
int n_intrs; int n_intrs;
struct interrupt_info *intrs; struct interrupt_info *intrs;
char *full_name; char *full_name;
......
...@@ -125,6 +125,7 @@ static int awacs_rate_index; ...@@ -125,6 +125,7 @@ static int awacs_rate_index;
static int awacs_subframe; static int awacs_subframe;
static struct device_node* awacs_node; static struct device_node* awacs_node;
static struct device_node* i2s_node; static struct device_node* i2s_node;
static struct resource awacs_rsrc[3];
static char awacs_name[64]; static char awacs_name[64];
static int awacs_revision; static int awacs_revision;
...@@ -667,9 +668,12 @@ static void PMacIrqCleanup(void) ...@@ -667,9 +668,12 @@ static void PMacIrqCleanup(void)
iounmap(awacs_txdma); iounmap(awacs_txdma);
iounmap(awacs_rxdma); iounmap(awacs_rxdma);
release_OF_resource(awacs_node, 0); release_mem_region(awacs_rsrc[0].start,
release_OF_resource(awacs_node, 1); awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
release_OF_resource(awacs_node, 2); release_mem_region(awacs_rsrc[1].start,
awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
release_mem_region(awacs_rsrc[2].start,
awacs_rsrc[2].end - awacs_rsrc[2].start + 1);
kfree(awacs_tx_cmd_space); kfree(awacs_tx_cmd_space);
kfree(awacs_rx_cmd_space); kfree(awacs_rx_cmd_space);
...@@ -2863,46 +2867,58 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n"); ...@@ -2863,46 +2867,58 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
* other info if necessary (early AWACS we want to read chip ids) * other info if necessary (early AWACS we want to read chip ids)
*/ */
if (io->n_addrs < 3 || io->n_intrs < 3) { if (of_get_address(io, 2, NULL, NULL) == NULL || io->n_intrs < 3) {
/* OK - maybe we need to use the 'awacs' node (on earlier /* OK - maybe we need to use the 'awacs' node (on earlier
* machines). * machines).
*/ */
if (awacs_node) { if (awacs_node) {
io = awacs_node ; io = awacs_node ;
if (io->n_addrs < 3 || io->n_intrs < 3) { if (of_get_address(io, 2, NULL, NULL) == NULL ||
printk("dmasound_pmac: can't use %s" io->n_intrs < 3) {
" (%d addrs, %d intrs)\n", printk("dmasound_pmac: can't use %s\n",
io->full_name, io->n_addrs, io->n_intrs); io->full_name);
return -ENODEV; return -ENODEV;
} }
} else { } else
printk("dmasound_pmac: can't use %s (%d addrs, %d intrs)\n", printk("dmasound_pmac: can't use %s\n", io->full_name);
io->full_name, io->n_addrs, io->n_intrs);
}
} }
if (!request_OF_resource(io, 0, NULL)) { if (of_address_to_resource(io, 0, &awacs_rsrc[0]) ||
request_mem_region(awacs_rsrc[0].start,
awacs_rsrc[0].end - awacs_rsrc[0].start + 1,
" (IO)") == NULL) {
printk(KERN_ERR "dmasound: can't request IO resource !\n"); printk(KERN_ERR "dmasound: can't request IO resource !\n");
return -ENODEV; return -ENODEV;
} }
if (!request_OF_resource(io, 1, " (tx dma)")) { if (of_address_to_resource(io, 1, &awacs_rsrc[1]) ||
release_OF_resource(io, 0); request_mem_region(awacs_rsrc[1].start,
printk(KERN_ERR "dmasound: can't request TX DMA resource !\n"); awacs_rsrc[1].end - awacs_rsrc[1].start + 1,
" (tx dma)") == NULL) {
release_mem_region(awacs_rsrc[0].start,
awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n");
return -ENODEV; return -ENODEV;
} }
if (of_address_to_resource(io, 2, &awacs_rsrc[2]) ||
if (!request_OF_resource(io, 2, " (rx dma)")) { request_mem_region(awacs_rsrc[2].start,
release_OF_resource(io, 0); awacs_rsrc[2].end - awacs_rsrc[2].start + 1,
release_OF_resource(io, 1); " (rx dma)") == NULL) {
printk(KERN_ERR "dmasound: can't request RX DMA resource !\n"); release_mem_region(awacs_rsrc[0].start,
awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
release_mem_region(awacs_rsrc[1].start,
awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n");
return -ENODEV; return -ENODEV;
} }
awacs_beep_dev = input_allocate_device(); awacs_beep_dev = input_allocate_device();
if (!awacs_beep_dev) { if (!awacs_beep_dev) {
release_OF_resource(io, 0); release_mem_region(awacs_rsrc[0].start,
release_OF_resource(io, 1); awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
release_OF_resource(io, 2); release_mem_region(awacs_rsrc[1].start,
awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
release_mem_region(awacs_rsrc[2].start,
awacs_rsrc[2].end - awacs_rsrc[2].start + 1);
printk(KERN_ERR "dmasound: can't allocate input device !\n"); printk(KERN_ERR "dmasound: can't allocate input device !\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -2916,11 +2932,11 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n"); ...@@ -2916,11 +2932,11 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
/* all OF versions I've seen use this value */ /* all OF versions I've seen use this value */
if (i2s_node) if (i2s_node)
i2s = ioremap(io->addrs[0].address, 0x1000); i2s = ioremap(awacs_rsrc[0].start, 0x1000);
else else
awacs = ioremap(io->addrs[0].address, 0x1000); awacs = ioremap(awacs_rsrc[0].start, 0x1000);
awacs_txdma = ioremap(io->addrs[1].address, 0x100); awacs_txdma = ioremap(awacs_rsrc[1].start, 0x100);
awacs_rxdma = ioremap(io->addrs[2].address, 0x100); awacs_rxdma = ioremap(awacs_rsrc[2].start, 0x100);
/* first of all make sure that the chip is powered up....*/ /* first of all make sure that the chip is powered up....*/
pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1); pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, io, 0, 1);
...@@ -3083,9 +3099,10 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev); ...@@ -3083,9 +3099,10 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
struct device_node* mio; struct device_node* mio;
macio_base = NULL; macio_base = NULL;
for (mio = io->parent; mio; mio = mio->parent) { for (mio = io->parent; mio; mio = mio->parent) {
if (strcmp(mio->name, "mac-io") == 0 if (strcmp(mio->name, "mac-io") == 0) {
&& mio->n_addrs > 0) { struct resource r;
macio_base = ioremap(mio->addrs[0].address, 0x40); if (of_address_to_resource(mio, 0, &r) == 0)
macio_base = ioremap(r.start, 0x40);
break; break;
} }
} }
......
...@@ -803,21 +803,17 @@ static int snd_pmac_free(struct snd_pmac *chip) ...@@ -803,21 +803,17 @@ static int snd_pmac_free(struct snd_pmac *chip)
iounmap(chip->playback.dma); iounmap(chip->playback.dma);
if (chip->capture.dma) if (chip->capture.dma)
iounmap(chip->capture.dma); iounmap(chip->capture.dma);
#ifndef CONFIG_PPC64
if (chip->node) { if (chip->node) {
int i; int i;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (chip->of_requested & (1 << i)) { if (chip->requested & (1 << i))
if (chip->is_k2) release_mem_region(chip->rsrc[i].start,
release_OF_resource(chip->node->parent, chip->rsrc[i].end -
i); chip->rsrc[i].start + 1);
else
release_OF_resource(chip->node, i);
}
} }
} }
#endif /* CONFIG_PPC64 */
if (chip->pdev) if (chip->pdev)
pci_dev_put(chip->pdev); pci_dev_put(chip->pdev);
kfree(chip); kfree(chip);
...@@ -991,6 +987,11 @@ static int __init snd_pmac_detect(struct snd_pmac *chip) ...@@ -991,6 +987,11 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
chip->can_byte_swap = 0; /* FIXME: check this */ chip->can_byte_swap = 0; /* FIXME: check this */
chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */
break; break;
default:
printk(KERN_ERR "snd: Unknown layout ID 0x%x\n",
layout_id);
return -ENODEV;
} }
} }
prop = (unsigned int *)get_property(sound, "device-id", NULL); prop = (unsigned int *)get_property(sound, "device-id", NULL);
...@@ -1175,46 +1176,69 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) ...@@ -1175,46 +1176,69 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
} }
np = chip->node; np = chip->node;
chip->requested = 0;
if (chip->is_k2) { if (chip->is_k2) {
if (np->parent->n_addrs < 2 || np->n_intrs < 3) { static char *rnames[] = {
"Sound Control", "Sound DMA" };
if (np->n_intrs < 3) {
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i ++) {
#ifndef CONFIG_PPC64 if (of_address_to_resource(np->parent, i,
static char *name[2] = { "- Control", "- DMA" }; &chip->rsrc[i])) {
if (! request_OF_resource(np->parent, i, name[i])) { printk(KERN_ERR "snd: can't translate rsrc "
snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i); " %d (%s)\n", i, rnames[i]);
err = -ENODEV;
goto __error;
}
if (request_mem_region(chip->rsrc[i].start,
chip->rsrc[i].end -
chip->rsrc[i].start + 1,
rnames[i]) == NULL) {
printk(KERN_ERR "snd: can't request rsrc "
" %d (%s: 0x%08lx:%08lx)\n",
i, rnames[i], chip->rsrc[i].start,
chip->rsrc[i].end);
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
chip->of_requested |= (1 << i); chip->requested |= (1 << i);
#endif /* CONFIG_PPC64 */
ctrl_addr = np->parent->addrs[0].address;
txdma_addr = np->parent->addrs[1].address;
rxdma_addr = txdma_addr + 0x100;
} }
ctrl_addr = chip->rsrc[0].start;
txdma_addr = chip->rsrc[1].start;
rxdma_addr = txdma_addr + 0x100;
} else { } else {
if (np->n_addrs < 3 || np->n_intrs < 3) { static char *rnames[] = {
"Sound Control", "Sound Tx DMA", "Sound Rx DMA" };
if (np->n_intrs < 3) {
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
for (i = 0; i < 3; i ++) {
for (i = 0; i < 3; i++) { if (of_address_to_resource(np->parent, i,
#ifndef CONFIG_PPC64 &chip->rsrc[i])) {
static char *name[3] = { "- Control", "- Tx DMA", "- Rx DMA" }; printk(KERN_ERR "snd: can't translate rsrc "
if (! request_OF_resource(np, i, name[i])) { " %d (%s)\n", i, rnames[i]);
snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i); err = -ENODEV;
goto __error;
}
if (request_mem_region(chip->rsrc[i].start,
chip->rsrc[i].end -
chip->rsrc[i].start + 1,
rnames[i]) == NULL) {
printk(KERN_ERR "snd: can't request rsrc "
" %d (%s: 0x%08lx:%08lx)\n",
i, rnames[i], chip->rsrc[i].start,
chip->rsrc[i].end);
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
chip->of_requested |= (1 << i); chip->requested |= (1 << i);
#endif /* CONFIG_PPC64 */
ctrl_addr = np->addrs[0].address;
txdma_addr = np->addrs[1].address;
rxdma_addr = np->addrs[2].address;
} }
ctrl_addr = chip->rsrc[0].start;
txdma_addr = chip->rsrc[1].start;
rxdma_addr = chip->rsrc[2].start;
} }
chip->awacs = ioremap(ctrl_addr, 0x1000); chip->awacs = ioremap(ctrl_addr, 0x1000);
...@@ -1266,9 +1290,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) ...@@ -1266,9 +1290,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
} else if (chip->is_pbook_G3) { } else if (chip->is_pbook_G3) {
struct device_node* mio; struct device_node* mio;
for (mio = chip->node->parent; mio; mio = mio->parent) { for (mio = chip->node->parent; mio; mio = mio->parent) {
if (strcmp(mio->name, "mac-io") == 0 if (strcmp(mio->name, "mac-io") == 0) {
&& mio->n_addrs > 0) { struct resource r;
chip->macio_base = ioremap(mio->addrs[0].address, 0x40); if (of_address_to_resource(mio, 0, &r) == 0)
chip->macio_base =
ioremap(r.start, 0x40);
break; break;
} }
} }
......
...@@ -113,7 +113,8 @@ struct snd_pmac { ...@@ -113,7 +113,8 @@ struct snd_pmac {
unsigned int initialized : 1; unsigned int initialized : 1;
unsigned int feature_is_set : 1; unsigned int feature_is_set : 1;
unsigned int of_requested; unsigned int requested;
struct resource rsrc[3];
int num_freqs; int num_freqs;
int *freq_table; int *freq_table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment