Commit 38e27180 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Linus Torvalds

[PATCH] ppc64: clean up existence-check of legacy ISAdevices

My previous patch exposed the internals of the ppc_md.  data structure
to drivers, which wasn't nice, this new patch cleans that up.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 74de2f94
......@@ -534,25 +534,12 @@ EXPORT_SYMBOL(pcibios_remove_root_bus);
static void __init pSeries_request_regions(void)
{
struct device_node *i8042;
request_region(0x20,0x20,"pic1");
request_region(0xa0,0x20,"pic2");
request_region(0x00,0x20,"dma1");
request_region(0x40,0x20,"timer");
request_region(0x80,0x10,"dma page reg");
request_region(0xc0,0x20,"dma2");
#define I8042_DATA_REG 0x60
/*
* Some machines have an unterminated i8042 so check the device
* tree and reserve the region if it does not appear. Later on
* the i8042 code will try and reserve this region and fail.
*/
if (!(i8042 = of_find_node_by_type(NULL, "8042")))
request_region(I8042_DATA_REG, 16, "reserved (no i8042)");
of_node_put(i8042);
}
void __init pSeries_final_fixup(void)
......
......@@ -534,6 +534,31 @@ static void __init pSeries_calibrate_decr(void)
setup_default_decr();
}
static int pSeries_check_legacy_ioport(unsigned int baseport)
{
struct device_node *np;
#define I8042_DATA_REG 0x60
#define FDC_BASE 0x3f0
switch(baseport) {
case I8042_DATA_REG:
np = of_find_node_by_type(NULL, "8042");
if (np == NULL)
return -ENODEV;
of_node_put(np);
break;
case FDC_BASE:
np = of_find_node_by_type(NULL, "fdc");
if (np == NULL)
return -ENODEV;
of_node_put(np);
break;
}
return 0;
}
/*
* Called very early, MMU is off, device-tree isn't unflattened
*/
......@@ -568,4 +593,5 @@ struct machdep_calls __initdata pSeries_md = {
.set_rtc_time = pSeries_set_rtc_time,
.calibrate_decr = pSeries_calibrate_decr,
.progress = pSeries_progress,
.check_legacy_ioport = pSeries_check_legacy_ioport,
};
......@@ -395,6 +395,15 @@ static void __init pmac_progress(char *s, unsigned short hex)
#endif /* CONFIG_BOOTX_TEXT */
}
/*
* pmac has no legacy IO, anything calling this function has to
* fail or bad things will happen
*/
static int pmac_check_legacy_ioport(unsigned int baseport)
{
return -ENODEV;
}
static int __init pmac_declare_of_platform_devices(void)
{
struct device_node *np;
......@@ -449,4 +458,5 @@ struct machdep_calls __initdata pmac_md = {
.calibrate_decr = pmac_calibrate_decr,
.feature_call = pmac_do_feature_call,
.progress = pmac_progress,
.check_legacy_ioport = pmac_check_legacy_ioport
};
......@@ -1288,6 +1288,14 @@ struct old_serial_port *get_legacy_serial_ports(unsigned int *count)
#endif /* CONFIG_PPC_ISERIES */
EXPORT_SYMBOL(get_legacy_serial_ports);
int check_legacy_ioport(unsigned long base_port)
{
if (ppc_md.check_legacy_ioport == NULL)
return 0;
return ppc_md.check_legacy_ioport(base_port);
}
EXPORT_SYMBOL(check_legacy_ioport);
#ifdef CONFIG_XMON
static int __init early_xmon(char *p)
{
......
......@@ -4286,6 +4286,13 @@ int __init floppy_init(void)
}
use_virtual_dma = can_use_virtual_dma & 1;
#if defined(CONFIG_PPC64)
if (check_legacy_ioport(FDC1)) {
del_timer(&fd_timeout);
err = -ENODEV;
goto out_unreg_region;
}
#endif
fdc_state[0].address = FDC1;
if (fdc_state[0].address == -1) {
del_timer(&fd_timeout);
......
......@@ -35,6 +35,7 @@
# define I8042_AUX_IRQ 12
#endif
/*
* Register numbers.
*/
......@@ -96,7 +97,7 @@ static inline int i8042_platform_init(void)
* On ix86 platforms touching the i8042 data register region can do really
* bad things. Because of this the region is always reserved on ix86 boxes.
*/
#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__) && !defined(__mips__)
#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__) && !defined(__mips__) && !defined (CONFIG_PPC64)
if (!request_region(I8042_DATA_REG, 16, "i8042"))
return -1;
#endif
......@@ -110,12 +111,18 @@ static inline int i8042_platform_init(void)
i8042_noloop = 1;
#endif
#if defined(CONFIG_PPC64)
if (check_legacy_ioport(I8042_DATA_REG))
return -1;
if (!request_region(I8042_DATA_REG, 16, "i8042"))
return -1;
#endif
return 0;
}
static inline void i8042_platform_exit(void)
{
#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__)
#if !defined(__i386__) && !defined(__sh__) && !defined(__alpha__) && !defined(__x86_64__) && !defined(CONFIG_PPC64)
release_region(I8042_DATA_REG, 16);
#endif
}
......
......@@ -11,6 +11,7 @@
#define __ASM_PPC64_FLOPPY_H
#include <linux/config.h>
#include <asm/machdep.h>
#define fd_inb(port) inb_p(port)
#define fd_outb(value,port) outb_p(value,port)
......
#ifndef _PPC64_IO_H
#ifndef _PPC64_IO_H
#define _PPC64_IO_H
/*
......@@ -436,6 +436,10 @@ static inline int check_signature(const volatile void __iomem * io_addr,
#define dma_cache_wback(_start,_size) do { } while (0)
#define dma_cache_wback_inv(_start,_size) do { } while (0)
/* Check of existence of legacy devices */
extern int check_legacy_ioport(unsigned long base_port);
#endif /* __KERNEL__ */
#endif /* _PPC64_IO_H */
......@@ -114,6 +114,9 @@ struct machdep_calls {
*/
long (*feature_call)(unsigned int feature, ...);
/* Check availability of legacy devices like i8042 */
int (*check_legacy_ioport)(unsigned int baseport);
};
extern struct machdep_calls ppc_md;
......
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