Commit 030d0ba0 authored by Anton Blanchard's avatar Anton Blanchard

Merge samba.org:/scratch/anton/linux-2.5

into samba.org:/scratch/anton/tmp3
parents 5a2bfcec eb40c469
...@@ -973,7 +973,7 @@ M: scott.feldman@intel.com ...@@ -973,7 +973,7 @@ M: scott.feldman@intel.com
S: Supported S: Supported
INTERMEZZO FILE SYSTEM INTERMEZZO FILE SYSTEM
P: Chen Yang P: Cluster File Systems
M: intermezzo-devel@lists.sf.net M: intermezzo-devel@lists.sf.net
W: http://www.inter-mezzo.org/ W: http://www.inter-mezzo.org/
L: intermezzo-discuss@lists.sourceforge.net L: intermezzo-discuss@lists.sourceforge.net
......
...@@ -682,6 +682,21 @@ __initcall(balanced_irq_init); ...@@ -682,6 +682,21 @@ __initcall(balanced_irq_init);
#else /* !SMP */ #else /* !SMP */
static inline void move_irq(int irq) { } static inline void move_irq(int irq) { }
void send_IPI_self(int vector)
{
unsigned int cfg;
/*
* Wait for idle.
*/
apic_wait_icr_idle();
cfg = APIC_DM_FIXED | APIC_DEST_SELF | vector | APIC_DEST_LOGICAL;
/*
* Send the IPI. The write to APIC_ICR fires this off.
*/
apic_write_around(APIC_ICR, cfg);
}
#endif /* defined(CONFIG_SMP) */ #endif /* defined(CONFIG_SMP) */
......
...@@ -357,25 +357,23 @@ int register_busmouse(struct busmouse *ops) ...@@ -357,25 +357,23 @@ int register_busmouse(struct busmouse *ops)
{ {
unsigned int msedev = MINOR_TO_MOUSE(ops->minor); unsigned int msedev = MINOR_TO_MOUSE(ops->minor);
struct busmouse_data *mse; struct busmouse_data *mse;
int ret; int ret = -EINVAL;
if (msedev >= NR_MICE) { if (msedev >= NR_MICE) {
printk(KERN_ERR "busmouse: trying to allocate mouse on minor %d\n", printk(KERN_ERR "busmouse: trying to allocate mouse on minor %d\n",
ops->minor); ops->minor);
return -EINVAL; goto out;
} }
ret = -ENOMEM;
mse = kmalloc(sizeof(*mse), GFP_KERNEL); mse = kmalloc(sizeof(*mse), GFP_KERNEL);
if (!mse) if (!mse)
return -ENOMEM; goto out;
down(&mouse_sem); down(&mouse_sem);
ret = -EBUSY;
if (busmouse_data[msedev]) if (busmouse_data[msedev])
{ goto freemem;
up(&mouse_sem);
kfree(mse);
return -EBUSY;
}
memset(mse, 0, sizeof(*mse)); memset(mse, 0, sizeof(*mse));
...@@ -386,14 +384,22 @@ int register_busmouse(struct busmouse *ops) ...@@ -386,14 +384,22 @@ int register_busmouse(struct busmouse *ops)
mse->lock = (spinlock_t)SPIN_LOCK_UNLOCKED; mse->lock = (spinlock_t)SPIN_LOCK_UNLOCKED;
init_waitqueue_head(&mse->wait); init_waitqueue_head(&mse->wait);
busmouse_data[msedev] = mse;
ret = misc_register(&mse->miscdev); ret = misc_register(&mse->miscdev);
if (!ret)
ret = msedev; if (ret < 0)
goto freemem;
busmouse_data[msedev] = mse;
ret = msedev;
out:
up(&mouse_sem); up(&mouse_sem);
return ret; return ret;
freemem:
kfree(mse);
goto out;
} }
/** /**
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Watchdog driver for integrated watchdog in the SuperH processors. * Watchdog driver for integrated watchdog in the SuperH processors.
* *
* Copyright (C) 2001, 2002 Paul Mundt <lethal@0xd6.org> * Copyright (C) 2001, 2002, 2003 Paul Mundt <lethal@linux-sh.org>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
* *
* 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com>
* Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT
*
* 19-Apr-2002 Rob Radez <rob@osinvestor.com>
* Added expect close support, made emulated timeout runtime changeable
* general cleanups, add some ioctls
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -22,76 +26,50 @@ ...@@ -22,76 +26,50 @@
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/fs.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/watchdog.h>
#if defined(CONFIG_CPU_SH5)
#define WTCNT CPRC_BASE + 0x10
#define WTCSR CPRC_BASE + 0x18
#elif defined(CONFIG_CPU_SH4)
#define WTCNT 0xffc00008
#define WTCSR 0xffc0000c
#elif defined(CONFIG_CPU_SH3)
#define WTCNT 0xffffff84
#define WTCSR 0xffffff86
#else
#error "Can't use SuperH watchdog on this platform"
#endif
#define WTCNT_HIGH 0x5a00
#define WTCSR_HIGH 0xa500
#define WTCSR_TME 0x80
#define WTCSR_WT 0x40
#define WTCSR_RSTS 0x20
#define WTCSR_WOVF 0x10
#define WTCSR_IOVF 0x08
#define WTCSR_CKS2 0x04
#define WTCSR_CKS1 0x02
#define WTCSR_CKS0 0x01
/* /*
* CKS0-2 supports a number of clock division ratios. At the time the watchdog * Default clock division ratio is 5.25 msecs. For an additional table of
* is enabled, it defaults to a 41 usec overflow period .. we overload this to * values, consult the asm-sh/watchdog.h. Overload this at module load
* something a little more reasonable, and really can't deal with anything * time.
* lower than WTCSR_CKS_1024, else we drop back into the usec range.
* *
* Clock Division Ratio Overflow Period * In order for this to work reliably we need to have HZ set to 1000 or
* -------------------------------------------- * something quite higher than 100 (or we need a proper high-res timer
* 1/32 (initial value) 41 usecs * implementation that will deal with this properly), otherwise the 10ms
* 1/64 82 usecs * resolution of a jiffy is enough to trigger the overflow. For things like
* 1/128 164 usecs * the SH-4 and SH-5, this isn't necessarily that big of a problem, though
* 1/256 328 usecs * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely
* 1/512 656 usecs * necssary.
* 1/1024 1.31 msecs *
* 1/2048 2.62 msecs * As a result of this timing problem, the only modes that are particularly
* 1/4096 5.25 msecs * feasible are the 4096 and the 2048 divisors, which yeild 5.25 and 2.62ms
*/ * overflow periods respectively.
#define WTCSR_CKS_32 0x00 *
#define WTCSR_CKS_64 0x01 * Also, since we can't really expect userspace to be responsive enough
#define WTCSR_CKS_128 0x02 * before the overflow happens, we maintain two seperate timers .. One in
#define WTCSR_CKS_256 0x03 * the kernel for clearing out WOVF every 2ms or so (again, this depends on
#define WTCSR_CKS_512 0x04 * HZ == 1000), and another for monitoring userspace writes to the WDT device.
#define WTCSR_CKS_1024 0x05 *
#define WTCSR_CKS_2048 0x06 * As such, we currently use a configurable heartbeat interval which defaults
#define WTCSR_CKS_4096 0x07 * to 30s. In this case, the userspace daemon is only responsible for periodic
* writes to the device before the next heartbeat is scheduled. If the daemon
/* * misses its deadline, the kernel timer will allow the WDT to overflow.
* Default clock division ratio is 5.25 msecs. Overload this at module load
* time. Any value not in the msec range will default to a timeout of one
* jiffy, which exceeds the usec overflow periods.
*/ */
static int clock_division_ratio = WTCSR_CKS_4096; static int clock_division_ratio = WTCSR_CKS_4096;
#define msecs_to_jiffies(msecs) (jiffies + ((HZ * msecs + 999) / 1000)) #define msecs_to_jiffies(msecs) (jiffies + (HZ * msecs + 9999) / 10000)
#define next_ping_period(cks) msecs_to_jiffies(cks - 4) #define next_ping_period(cks) msecs_to_jiffies(cks - 4)
#define user_ping_period(cks) (next_ping_period(cks) * 10)
static unsigned long sh_is_open = 0; static unsigned long shwdt_is_open;
static struct watchdog_info sh_wdt_info; static struct watchdog_info sh_wdt_info;
static char shwdt_expect_close;
static struct timer_list timer; static struct timer_list timer;
static unsigned long next_heartbeat; static unsigned long next_heartbeat;
static int heartbeat = 30;
#ifdef CONFIG_WATCHDOG_NOWAYOUT #ifdef CONFIG_WATCHDOG_NOWAYOUT
static int nowayout = 1; static int nowayout = 1;
...@@ -99,35 +77,6 @@ static int nowayout = 1; ...@@ -99,35 +77,6 @@ static int nowayout = 1;
static int nowayout = 0; static int nowayout = 0;
#endif #endif
MODULE_PARM(nowayout,"i");
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
/**
* sh_wdt_write_cnt - Write to Counter
*
* @val: Value to write
*
* Writes the given value @val to the lower byte of the timer counter.
* The upper byte is set manually on each write.
*/
static void sh_wdt_write_cnt(__u8 val)
{
ctrl_outw(WTCNT_HIGH | (__u16)val, WTCNT);
}
/**
* sh_wdt_write_csr - Write to Control/Status Register
*
* @val: Value to write
*
* Writes the given value @val to the lower byte of the control/status
* register. The upper byte is set manually on each write.
*/
static void sh_wdt_write_csr(__u8 val)
{
ctrl_outw(WTCSR_HIGH | (__u16)val, WTCSR);
}
/** /**
* sh_wdt_start - Start the Watchdog * sh_wdt_start - Start the Watchdog
* *
...@@ -135,13 +84,44 @@ static void sh_wdt_write_csr(__u8 val) ...@@ -135,13 +84,44 @@ static void sh_wdt_write_csr(__u8 val)
*/ */
static void sh_wdt_start(void) static void sh_wdt_start(void)
{ {
timer.expires = next_ping_period(clock_division_ratio); __u8 csr;
next_heartbeat = user_ping_period(clock_division_ratio);
add_timer(&timer); mod_timer(&timer, next_ping_period(clock_division_ratio));
next_heartbeat = jiffies + (heartbeat * HZ);
csr = sh_wdt_read_csr();
csr |= WTCSR_WT | clock_division_ratio;
sh_wdt_write_csr(csr);
sh_wdt_write_csr(WTCSR_WT | WTCSR_CKS_4096);
sh_wdt_write_cnt(0); sh_wdt_write_cnt(0);
sh_wdt_write_csr((ctrl_inb(WTCSR) | WTCSR_TME));
/*
* These processors have a bit of an inconsistent initialization
* process.. starting with SH-3, RSTS was moved to WTCSR, and the
* RSTCSR register was removed.
*
* On the SH-2 however, in addition with bits being in different
* locations, we must deal with RSTCSR outright..
*/
csr = sh_wdt_read_csr();
csr |= WTCSR_TME;
csr &= ~WTCSR_RSTS;
sh_wdt_write_csr(csr);
#ifdef CONFIG_CPU_SH2
/*
* Whoever came up with the RSTCSR semantics must've been smoking
* some of the good stuff, since in addition to the WTCSR/WTCNT write
* brain-damage, it's managed to fuck things up one step further..
*
* If we need to clear the WOVF bit, the upper byte has to be 0xa5..
* but if we want to touch RSTE or RSTS, the upper byte has to be
* 0x5a..
*/
csr = sh_wdt_read_rstcsr();
csr &= ~RSTCSR_RSTS;
sh_wdt_write_rstcsr(csr);
#endif
} }
/** /**
...@@ -151,9 +131,13 @@ static void sh_wdt_start(void) ...@@ -151,9 +131,13 @@ static void sh_wdt_start(void)
*/ */
static void sh_wdt_stop(void) static void sh_wdt_stop(void)
{ {
__u8 csr;
del_timer(&timer); del_timer(&timer);
sh_wdt_write_csr((ctrl_inb(WTCSR) & ~WTCSR_TME)); csr = sh_wdt_read_csr();
csr &= ~WTCSR_TME;
sh_wdt_write_csr(csr);
} }
/** /**
...@@ -166,11 +150,15 @@ static void sh_wdt_stop(void) ...@@ -166,11 +150,15 @@ static void sh_wdt_stop(void)
static void sh_wdt_ping(unsigned long data) static void sh_wdt_ping(unsigned long data)
{ {
if (time_before(jiffies, next_heartbeat)) { if (time_before(jiffies, next_heartbeat)) {
sh_wdt_write_csr((ctrl_inb(WTCSR) & ~WTCSR_IOVF)); __u8 csr;
csr = sh_wdt_read_csr();
csr &= ~WTCSR_IOVF;
sh_wdt_write_csr(csr);
sh_wdt_write_cnt(0); sh_wdt_write_cnt(0);
timer.expires = next_ping_period(clock_division_ratio); mod_timer(&timer, next_ping_period(clock_division_ratio));
add_timer(&timer);
} }
} }
...@@ -184,21 +172,12 @@ static void sh_wdt_ping(unsigned long data) ...@@ -184,21 +172,12 @@ static void sh_wdt_ping(unsigned long data)
*/ */
static int sh_wdt_open(struct inode *inode, struct file *file) static int sh_wdt_open(struct inode *inode, struct file *file)
{ {
switch (minor(inode->i_rdev)) { if (test_and_set_bit(0, &shwdt_is_open))
case WATCHDOG_MINOR: return -EBUSY;
if (test_and_set_bit(0, &sh_is_open)) if (nowayout)
return -EBUSY; MOD_INC_USE_COUNT;
if (nowayout) { sh_wdt_start();
MOD_INC_USE_COUNT;
}
sh_wdt_start();
break;
default:
return -ENODEV;
}
return 0; return 0;
} }
...@@ -213,32 +192,19 @@ static int sh_wdt_open(struct inode *inode, struct file *file) ...@@ -213,32 +192,19 @@ static int sh_wdt_open(struct inode *inode, struct file *file)
*/ */
static int sh_wdt_close(struct inode *inode, struct file *file) static int sh_wdt_close(struct inode *inode, struct file *file)
{ {
if (minor(inode->i_rdev) == WATCHDOG_MINOR) { if (!nowayout && shwdt_expect_close == 42) {
if (!nowayout) { sh_wdt_stop();
sh_wdt_stop(); } else {
} printk(KERN_CRIT "shwdt: Unexpected close, not stopping watchdog!\n");
clear_bit(0, &sh_is_open); next_heartbeat = jiffies + (heartbeat * HZ);
} }
clear_bit(0, &shwdt_is_open);
shwdt_expect_close = 0;
return 0; return 0;
} }
/**
* sh_wdt_read - Read from Device
*
* @file: file handle of device
* @buf: buffer to write to
* @count: length of buffer
* @ppos: offset
*
* Unsupported.
*/
static ssize_t sh_wdt_read(struct file *file, char *buf,
size_t count, loff_t *ppos)
{
return -EINVAL;
}
/** /**
* sh_wdt_write - Write to Device * sh_wdt_write - Write to Device
* *
...@@ -257,11 +223,21 @@ static ssize_t sh_wdt_write(struct file *file, const char *buf, ...@@ -257,11 +223,21 @@ static ssize_t sh_wdt_write(struct file *file, const char *buf,
return -ESPIPE; return -ESPIPE;
if (count) { if (count) {
next_heartbeat = user_ping_period(clock_division_ratio); size_t i;
return 1;
shwdt_expect_close = 0;
for (i = 0; i != count; i++) {
char c;
if (get_user(c, buf + i))
return -EFAULT;
if (c == 'V')
shwdt_expect_close = 42;
}
next_heartbeat = jiffies + (heartbeat * HZ);
} }
return 0; return count;
} }
/** /**
...@@ -278,6 +254,8 @@ static ssize_t sh_wdt_write(struct file *file, const char *buf, ...@@ -278,6 +254,8 @@ static ssize_t sh_wdt_write(struct file *file, const char *buf,
static int sh_wdt_ioctl(struct inode *inode, struct file *file, static int sh_wdt_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int new_timeout;
switch (cmd) { switch (cmd) {
case WDIOC_GETSUPPORT: case WDIOC_GETSUPPORT:
if (copy_to_user((struct watchdog_info *)arg, if (copy_to_user((struct watchdog_info *)arg,
...@@ -288,17 +266,41 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file, ...@@ -288,17 +266,41 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file,
break; break;
case WDIOC_GETSTATUS: case WDIOC_GETSTATUS:
if (copy_to_user((int *)arg, case WDIOC_GETBOOTSTATUS:
&sh_is_open, return put_user(0, (int *)arg);
sizeof(int))) { case WDIOC_KEEPALIVE:
next_heartbeat = jiffies + (heartbeat * HZ);
break;
case WDIOC_SETTIMEOUT:
if (get_user(new_timeout, (int *)arg))
return -EFAULT;
if (new_timeout < 1 || new_timeout > 3600) /* arbitrary upper limit */
return -EINVAL;
heartbeat = new_timeout;
next_heartbeat = jiffies + (heartbeat * HZ);
/* Fall */
case WDIOC_GETTIMEOUT:
return put_user(heartbeat, (int *)arg);
case WDIOC_SETOPTIONS:
{
int options, retval = -EINVAL;
if (get_user(options, (int *)arg))
return -EFAULT; return -EFAULT;
if (options & WDIOS_DISABLECARD) {
sh_wdt_stop();
retval = 0;
} }
break; if (options & WDIOS_ENABLECARD) {
case WDIOC_KEEPALIVE: sh_wdt_start();
next_heartbeat = user_ping_period(clock_division_ratio); retval = 0;
}
break; return retval;
}
default: default:
return -ENOTTY; return -ENOTTY;
} }
...@@ -328,7 +330,7 @@ static int sh_wdt_notify_sys(struct notifier_block *this, ...@@ -328,7 +330,7 @@ static int sh_wdt_notify_sys(struct notifier_block *this,
static struct file_operations sh_wdt_fops = { static struct file_operations sh_wdt_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = sh_wdt_read, .llseek = no_llseek,
.write = sh_wdt_write, .write = sh_wdt_write,
.ioctl = sh_wdt_ioctl, .ioctl = sh_wdt_ioctl,
.open = sh_wdt_open, .open = sh_wdt_open,
...@@ -336,21 +338,20 @@ static struct file_operations sh_wdt_fops = { ...@@ -336,21 +338,20 @@ static struct file_operations sh_wdt_fops = {
}; };
static struct watchdog_info sh_wdt_info = { static struct watchdog_info sh_wdt_info = {
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
.firmware_version = 1, .firmware_version = 1,
.identity = "SH WDT", .identity = "SH WDT",
}; };
static struct notifier_block sh_wdt_notifier = { static struct notifier_block sh_wdt_notifier = {
.notifier_call = sh_wdt_notify_sys, .notifier_call = sh_wdt_notify_sys,
.next = NULL, .priority = 0,
.priority = 0
}; };
static struct miscdevice sh_wdt_miscdev = { static struct miscdevice sh_wdt_miscdev = {
.minor = WATCHDOG_MINOR, .minor = WATCHDOG_MINOR,
.name = "watchdog", .name = "watchdog",
.fops &sh_wdt_fops, .fops = &sh_wdt_fops,
}; };
/** /**
...@@ -366,23 +367,8 @@ static int __init sh_wdt_init(void) ...@@ -366,23 +367,8 @@ static int __init sh_wdt_init(void)
return -EINVAL; return -EINVAL;
} }
if (!request_region(WTCNT, 1, "shwdt")) {
printk(KERN_ERR "shwdt: Can't request WTCNT region\n");
misc_deregister(&sh_wdt_miscdev);
return -ENXIO;
}
if (!request_region(WTCSR, 1, "shwdt")) {
printk(KERN_ERR "shwdt: Can't request WTCSR region\n");
release_region(WTCNT, 1);
misc_deregister(&sh_wdt_miscdev);
return -ENXIO;
}
if (register_reboot_notifier(&sh_wdt_notifier)) { if (register_reboot_notifier(&sh_wdt_notifier)) {
printk(KERN_ERR "shwdt: Can't register reboot notifier\n"); printk(KERN_ERR "shwdt: Can't register reboot notifier\n");
release_region(WTCSR, 1);
release_region(WTCNT, 1);
misc_deregister(&sh_wdt_miscdev); misc_deregister(&sh_wdt_miscdev);
return -EINVAL; return -EINVAL;
} }
...@@ -403,16 +389,16 @@ static int __init sh_wdt_init(void) ...@@ -403,16 +389,16 @@ static int __init sh_wdt_init(void)
static void __exit sh_wdt_exit(void) static void __exit sh_wdt_exit(void)
{ {
unregister_reboot_notifier(&sh_wdt_notifier); unregister_reboot_notifier(&sh_wdt_notifier);
release_region(WTCSR, 1);
release_region(WTCNT, 1);
misc_deregister(&sh_wdt_miscdev); misc_deregister(&sh_wdt_miscdev);
} }
MODULE_AUTHOR("Paul Mundt <lethal@0xd6.org>"); MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
MODULE_DESCRIPTION("SuperH watchdog driver"); MODULE_DESCRIPTION("SuperH watchdog driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_PARM(clock_division_ratio, "i"); MODULE_PARM(clock_division_ratio, "i");
MODULE_PARM_DESC(clock_division_ratio, "Clock division ratio. Valid ranges are from 0x5 (1.31ms) to 0x7 (5.25ms). Defaults to 0x7."); MODULE_PARM_DESC(clock_division_ratio, "Clock division ratio. Valid ranges are from 0x5 (1.31ms) to 0x7 (5.25ms). Defaults to 0x7.");
MODULE_PARM(nowayout,"i");
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
module_init(sh_wdt_init); module_init(sh_wdt_init);
module_exit(sh_wdt_exit); module_exit(sh_wdt_exit);
......
...@@ -161,7 +161,7 @@ static int debug; ...@@ -161,7 +161,7 @@ static int debug;
* then put the packet into tx_queue, and call sppp_flush_xmit() * then put the packet into tx_queue, and call sppp_flush_xmit()
* after spinlock is released. * after spinlock is released.
*/ */
static void sppp_flush_xmit() static void sppp_flush_xmit(void)
{ {
struct sk_buff *skb; struct sk_buff *skb;
while ((skb = skb_dequeue(&tx_queue)) != NULL) while ((skb = skb_dequeue(&tx_queue)) != NULL)
......
/* /*
* $Id$ * $Id: hd64465_ss.c,v 1.7 2003/07/06 14:42:50 lethal Exp $
* *
* Device driver for the PCMCIA controller module of the * Device driver for the PCMCIA controller module of the
* Hitachi HD64465 handheld companion chip. * Hitachi HD64465 handheld companion chip.
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
* *
* by Greg Banks <gbanks@pocketpenguins.com> * by Greg Banks <gbanks@pocketpenguins.com>
* (c) 2000 PocketPenguins Inc * (c) 2000 PocketPenguins Inc
*
*/ */
#include <linux/types.h> #include <linux/types.h>
...@@ -37,28 +36,26 @@ ...@@ -37,28 +36,26 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/workqueue.h> #include <linux/interrupt.h>
#include <linux/device.h> #include <linux/device.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/hd64465.h> #include <asm/hd64465/hd64465.h>
#include <asm/hd64465/io.h>
#include <pcmcia/version.h> #include <pcmcia/version.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/cs.h> #include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
#include <pcmcia/ss.h> #include <pcmcia/ss.h>
#include <pcmcia/bulkmem.h> #include <pcmcia/bulkmem.h>
#include <pcmcia/cistpl.h>
#include "cs_internal.h" #include "cs_internal.h"
#define MODNAME "hd64465_ss" #define MODNAME "hd64465_ss"
/* #define HD64465_DEBUG 1 */ /* #define HD64465_DEBUG 1 */
#ifndef HD64465_DEBUG
#define HD64465_DEBUG 0
#endif
#if HD64465_DEBUG #if HD64465_DEBUG
#define DPRINTK(args...) printk(MODNAME ": " args) #define DPRINTK(args...) printk(MODNAME ": " args)
#else #else
...@@ -66,7 +63,8 @@ ...@@ -66,7 +63,8 @@
#endif #endif
extern int hd64465_io_debug; extern int hd64465_io_debug;
extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags);
extern void p3_iounmap(void *addr);
/*============================================================*/ /*============================================================*/
...@@ -74,37 +72,22 @@ extern int hd64465_io_debug; ...@@ -74,37 +72,22 @@ extern int hd64465_io_debug;
typedef struct hs_socket_t typedef struct hs_socket_t
{ {
unsigned int number;
u_int irq; u_int irq;
u_long mem_base; u_long mem_base;
void *io_base;
u_long mem_length; u_long mem_length;
void (*handler)(void *info, u_int events);
void *handler_info;
u_int pending_events;
u_int ctrl_base; u_int ctrl_base;
socket_state_t state; socket_state_t state;
pccard_io_map io_maps[MAX_IO_WIN]; pccard_io_map io_maps[MAX_IO_WIN];
pccard_mem_map mem_maps[MAX_WIN]; pccard_mem_map mem_maps[MAX_WIN];
struct vm_struct *io_vma; /* allocated kernel vm for mapping IO space */ struct pcmcia_socket socket;
} hs_socket_t; } hs_socket_t;
#define HS_MAX_SOCKETS 2
static hs_socket_t hs_sockets[HS_MAX_SOCKETS];
static spinlock_t hs_pending_event_lock = SPIN_LOCK_UNLOCKED;
/* Calculate socket number from ptr into hs_sockets[] */
#define hs_sockno(sp) (sp - hs_sockets)
static socket_cap_t hs_socket_cap = #define HS_MAX_SOCKETS 2
{ static hs_socket_t hs_sockets[HS_MAX_SOCKETS];
SS_CAP_PCCARD /* support 16 bit cards */
|SS_CAP_STATIC_MAP /* mappings are fixed in host memory */
,
0xffde/*0xffff*/, /* IRQs mapped in s/w so can do any, really */
HD64465_PCC_WINDOW, /* 16MB fixed window size */
0, /* no PCI support */
0, /* no CardBus support */
0 /* no bus operations needed */
};
#define hs_in(sp, r) inb((sp)->ctrl_base + (r)) #define hs_in(sp, r) inb((sp)->ctrl_base + (r))
#define hs_out(sp, v, r) outb(v, (sp)->ctrl_base + (r)) #define hs_out(sp, v, r) outb(v, (sp)->ctrl_base + (r))
...@@ -179,7 +162,7 @@ static void hs_socket_enable_ireq(hs_socket_t *sp) ...@@ -179,7 +162,7 @@ static void hs_socket_enable_ireq(hs_socket_t *sp)
{ {
unsigned short cscier; unsigned short cscier;
DPRINTK("hs_socket_enable_ireq(sock=%d)\n", hs_sockno(sp)); DPRINTK("hs_socket_enable_ireq(sock=%d)\n", sp->number);
cscier = hs_in(sp, CSCIER); cscier = hs_in(sp, CSCIER);
cscier &= ~HD64465_PCCCSCIER_PIREQE_MASK; cscier &= ~HD64465_PCCCSCIER_PIREQE_MASK;
...@@ -191,7 +174,7 @@ static void hs_socket_disable_ireq(hs_socket_t *sp) ...@@ -191,7 +174,7 @@ static void hs_socket_disable_ireq(hs_socket_t *sp)
{ {
unsigned short cscier; unsigned short cscier;
DPRINTK("hs_socket_disable_ireq(sock=%d)\n", hs_sockno(sp)); DPRINTK("hs_socket_disable_ireq(sock=%d)\n", sp->number);
cscier = hs_in(sp, CSCIER); cscier = hs_in(sp, CSCIER);
cscier &= ~HD64465_PCCCSCIER_PIREQE_MASK; cscier &= ~HD64465_PCCCSCIER_PIREQE_MASK;
...@@ -255,7 +238,7 @@ static struct hw_interrupt_type hd64465_ss_irq_type = { ...@@ -255,7 +238,7 @@ static struct hw_interrupt_type hd64465_ss_irq_type = {
*/ */
static void hs_map_irq(hs_socket_t *sp, unsigned int irq) static void hs_map_irq(hs_socket_t *sp, unsigned int irq)
{ {
DPRINTK("hs_map_irq(sock=%d irq=%d)\n", hs_sockno(sp), irq); DPRINTK("hs_map_irq(sock=%d irq=%d)\n", sp->number, irq);
if (irq >= HS_NUM_MAPPED_IRQS) if (irq >= HS_NUM_MAPPED_IRQS)
return; return;
...@@ -272,7 +255,7 @@ static void hs_map_irq(hs_socket_t *sp, unsigned int irq) ...@@ -272,7 +255,7 @@ static void hs_map_irq(hs_socket_t *sp, unsigned int irq)
*/ */
static void hs_unmap_irq(hs_socket_t *sp, unsigned int irq) static void hs_unmap_irq(hs_socket_t *sp, unsigned int irq)
{ {
DPRINTK("hs_unmap_irq(sock=%d irq=%d)\n", hs_sockno(sp), irq); DPRINTK("hs_unmap_irq(sock=%d irq=%d)\n", sp->number, irq);
if (irq >= HS_NUM_MAPPED_IRQS) if (irq >= HS_NUM_MAPPED_IRQS)
return; return;
...@@ -301,7 +284,7 @@ static int hs_set_voltages(hs_socket_t *sp, int Vcc, int Vpp) ...@@ -301,7 +284,7 @@ static int hs_set_voltages(hs_socket_t *sp, int Vcc, int Vpp)
{ {
u_int psr; u_int psr;
u_int vcci = 0; u_int vcci = 0;
u_int sock = hs_sockno(sp); u_int sock = sp->number;
DPRINTK("hs_set_voltage(%d, %d, %d)\n", sock, Vcc, Vpp); DPRINTK("hs_set_voltage(%d, %d, %d)\n", sock, Vcc, Vpp);
...@@ -359,13 +342,12 @@ static void hs_reset_socket(hs_socket_t *sp, int on) ...@@ -359,13 +342,12 @@ static void hs_reset_socket(hs_socket_t *sp, int on)
/*============================================================*/ /*============================================================*/
static int hs_init(unsigned int sock) static int hs_init(struct pcmcia_socket *s)
{ {
hs_socket_t *sp = &hs_sockets[sock]; hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
DPRINTK("hs_init(%d)\n", sock); DPRINTK("hs_init(%d)\n", sp->number);
sp->pending_events = 0;
sp->state.Vcc = 0; sp->state.Vcc = 0;
sp->state.Vpp = 0; sp->state.Vpp = 0;
hs_set_voltages(sp, 0, 0); hs_set_voltages(sp, 0, 0);
...@@ -375,9 +357,12 @@ static int hs_init(unsigned int sock) ...@@ -375,9 +357,12 @@ static int hs_init(unsigned int sock)
/*============================================================*/ /*============================================================*/
static int hs_suspend(unsigned int sock) static int hs_suspend(struct pcmcia_socket *s)
{ {
DPRINTK("hs_suspend(%d)\n", sock); #ifdef HD64465_DEBUG
hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
DPRINTK("hs_suspend(%d)\n", sp->number);
#endif
/* TODO */ /* TODO */
...@@ -386,32 +371,10 @@ static int hs_suspend(unsigned int sock) ...@@ -386,32 +371,10 @@ static int hs_suspend(unsigned int sock)
/*============================================================*/ /*============================================================*/
static int hs_register_callback(unsigned int sock,
void (*handler)(void *, unsigned int), void * info)
{
hs_socket_t *sp = &hs_sockets[sock];
DPRINTK("hs_register_callback(%d)\n", sock);
sp->handler = handler;
sp->handler_info = info;
return 0;
}
/*============================================================*/
static int hs_inquire_socket(unsigned int sock, socket_cap_t *cap) static int hs_get_status(struct pcmcia_socket *s, u_int *value)
{ {
DPRINTK("hs_inquire_socket(%d)\n", sock); hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
*cap = hs_socket_cap;
return 0;
}
/*============================================================*/
static int hs_get_status(unsigned int sock, u_int *value)
{
hs_socket_t *sp = &hs_sockets[sock];
unsigned int isr; unsigned int isr;
u_int status = 0; u_int status = 0;
...@@ -473,9 +436,9 @@ static int hs_get_status(unsigned int sock, u_int *value) ...@@ -473,9 +436,9 @@ static int hs_get_status(unsigned int sock, u_int *value)
/*============================================================*/ /*============================================================*/
static int hs_get_socket(unsigned int sock, socket_state_t *state) static int hs_get_socket(struct pcmcia_socket *s, socket_state_t *state)
{ {
hs_socket_t *sp = &hs_sockets[sock]; hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
DPRINTK("hs_get_socket(%d)\n", sock); DPRINTK("hs_get_socket(%d)\n", sock);
...@@ -485,9 +448,9 @@ static int hs_get_socket(unsigned int sock, socket_state_t *state) ...@@ -485,9 +448,9 @@ static int hs_get_socket(unsigned int sock, socket_state_t *state)
/*============================================================*/ /*============================================================*/
static int hs_set_socket(unsigned int sock, socket_state_t *state) static int hs_set_socket(struct pcmcia_socket *s, socket_state_t *state)
{ {
hs_socket_t *sp = &hs_sockets[sock]; hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
u_long flags; u_long flags;
u_int changed; u_int changed;
unsigned short cscier; unsigned short cscier;
...@@ -495,12 +458,12 @@ static int hs_set_socket(unsigned int sock, socket_state_t *state) ...@@ -495,12 +458,12 @@ static int hs_set_socket(unsigned int sock, socket_state_t *state)
DPRINTK("hs_set_socket(sock=%d, flags=%x, csc_mask=%x, Vcc=%d, Vpp=%d, io_irq=%d)\n", DPRINTK("hs_set_socket(sock=%d, flags=%x, csc_mask=%x, Vcc=%d, Vpp=%d, io_irq=%d)\n",
sock, state->flags, state->csc_mask, state->Vcc, state->Vpp, state->io_irq); sock, state->flags, state->csc_mask, state->Vcc, state->Vpp, state->io_irq);
save_and_cli(flags); /* Don't want interrupts happening here */ local_irq_save(flags); /* Don't want interrupts happening here */
if (state->Vpp != sp->state.Vpp || if (state->Vpp != sp->state.Vpp ||
state->Vcc != sp->state.Vcc) { state->Vcc != sp->state.Vcc) {
if (!hs_set_voltages(sp, state->Vcc, state->Vpp)) { if (!hs_set_voltages(sp, state->Vcc, state->Vpp)) {
restore_flags(flags); local_irq_restore(flags);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -588,7 +551,7 @@ static int hs_set_socket(unsigned int sock, socket_state_t *state) ...@@ -588,7 +551,7 @@ static int hs_set_socket(unsigned int sock, socket_state_t *state)
/* hd64465_io_debug = 0; */ /* hd64465_io_debug = 0; */
sp->state = *state; sp->state = *state;
restore_flags(flags); local_irq_restore(flags);
#if HD64465_DEBUG > 10 #if HD64465_DEBUG > 10
if (state->flags & SS_OUTPUT_ENA) if (state->flags & SS_OUTPUT_ENA)
...@@ -599,10 +562,11 @@ static int hs_set_socket(unsigned int sock, socket_state_t *state) ...@@ -599,10 +562,11 @@ static int hs_set_socket(unsigned int sock, socket_state_t *state)
/*============================================================*/ /*============================================================*/
static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io) static int hs_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
{ {
hs_socket_t *sp = &hs_sockets[sock]; hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
int map = io->map; int map = io->map;
int sock = sp->number;
struct pccard_io_map *sio; struct pccard_io_map *sio;
pgprot_t prot; pgprot_t prot;
...@@ -639,10 +603,9 @@ static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io) ...@@ -639,10 +603,9 @@ static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io)
printk(KERN_INFO MODNAME ": MAP_0WS unimplemented\n"); printk(KERN_INFO MODNAME ": MAP_0WS unimplemented\n");
if (io->flags & MAP_ACTIVE) { if (io->flags & MAP_ACTIVE) {
unsigned long pstart, psize, paddrbase, vaddrbase; unsigned long pstart, psize, paddrbase;
paddrbase = virt_to_phys((void*)(sp->mem_base + 2 * HD64465_PCC_WINDOW)); paddrbase = virt_to_phys((void*)(sp->mem_base + 2 * HD64465_PCC_WINDOW));
vaddrbase = (unsigned long)sp->io_vma->addr;
pstart = io->start & PAGE_MASK; pstart = io->start & PAGE_MASK;
psize = ((io->stop + PAGE_SIZE) & PAGE_MASK) - pstart; psize = ((io->stop + PAGE_SIZE) & PAGE_MASK) - pstart;
...@@ -653,26 +616,17 @@ static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io) ...@@ -653,26 +616,17 @@ static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io)
* page will be mapped. But the code allows for weird cards * page will be mapped. But the code allows for weird cards
* that might want IO ports > 4K. * that might want IO ports > 4K.
*/ */
DPRINTK("remap_page_range(vaddr=0x%08lx, paddr=0x%08lx, size=0x%08lxx)\n", sp->io_base = p3_ioremap(paddrbase + pstart, psize, pgprot_val(prot));
vaddrbase + pstart, paddrbase + pstart, psize);
#error This does not work. Firstly remap_page_range() uses current->mm for
#error the address space, which is wrong for kernel mappings. remap_page_range
#error also does flush_{cache,tlb}_range() which ONLY works for user mappings.
#error Next, remap_page_range() now wants to take a vm_area_struct arg.
remap_page_range(vaddrbase + pstart, paddrbase + pstart, psize, prot);
/* /*
* Change the mapping used by inb() outb() etc * Change the mapping used by inb() outb() etc
*/ */
hd64465_port_map( hd64465_port_map(io->start,
io->start,
io->stop - io->start + 1, io->stop - io->start + 1,
vaddrbase + io->start,0); (unsigned long)sp->io_base + io->start, 0);
} else { } else {
hd64465_port_unmap( hd64465_port_unmap(sio->start, sio->stop - sio->start + 1);
sio->start, p3_iounmap(sp->io_base);
sio->stop - sio->start + 1);
/* TODO: remap_page_range() to mark pages not present ? */
} }
*sio = *io; *sio = *io;
...@@ -681,9 +635,9 @@ static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io) ...@@ -681,9 +635,9 @@ static int hs_set_io_map(unsigned int sock, struct pccard_io_map *io)
/*============================================================*/ /*============================================================*/
static int hs_set_mem_map(unsigned int sock, struct pccard_mem_map *mem) static int hs_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
{ {
hs_socket_t *sp = &hs_sockets[sock]; hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
struct pccard_mem_map *smem; struct pccard_mem_map *smem;
int map = mem->map; int map = mem->map;
unsigned long paddr, size; unsigned long paddr, size;
...@@ -722,13 +676,6 @@ static int hs_set_mem_map(unsigned int sock, struct pccard_mem_map *mem) ...@@ -722,13 +676,6 @@ static int hs_set_mem_map(unsigned int sock, struct pccard_mem_map *mem)
/*============================================================*/ /*============================================================*/
static void hs_proc_setup(unsigned int sock, struct proc_dir_entry *base)
{
DPRINTK("hs_proc_setup(%d)\n", sock);
}
/*============================================================*/
/* /*
* This function is registered with the HD64465 glue code to do a * This function is registered with the HD64465 glue code to do a
* secondary demux step on the PCMCIA interrupts. It handles * secondary demux step on the PCMCIA interrupts. It handles
...@@ -756,35 +703,9 @@ static int hs_irq_demux(int irq, void *dev) ...@@ -756,35 +703,9 @@ static int hs_irq_demux(int irq, void *dev)
/* /*
* Interrupt handling routine. * Interrupt handling routine.
*
* This uses the schedule_work() technique to cause reportable events
* such as card insertion and removal to be handled in keventd's
* process context.
*/ */
static irqreturn_t hs_interrupt(int irq, void *dev, struct pt_regs *regs)
static void hs_events_bh(void *dummy)
{
hs_socket_t *sp;
u_int events;
int i;
for (i=0; i<HS_MAX_SOCKETS; i++) {
sp = &hs_sockets[i];
spin_lock_irq(&hs_pending_event_lock);
events = sp->pending_events;
sp->pending_events = 0;
spin_unlock_irq(&hs_pending_event_lock);
if (sp->handler)
sp->handler(sp->handler_info, events);
}
}
static DECLARE_WORK(hs_events_task, hs_events_bh, NULL);
static void hs_interrupt(int irq, void *dev, struct pt_regs *regs)
{ {
hs_socket_t *sp = (hs_socket_t *)dev; hs_socket_t *sp = (hs_socket_t *)dev;
u_int events = 0; u_int events = 0;
...@@ -801,7 +722,7 @@ static void hs_interrupt(int irq, void *dev, struct pt_regs *regs) ...@@ -801,7 +722,7 @@ static void hs_interrupt(int irq, void *dev, struct pt_regs *regs)
if ((hs_in(sp, ISR) & HD64465_PCCISR_PCD_MASK) != 0) { if ((hs_in(sp, ISR) & HD64465_PCCISR_PCD_MASK) != 0) {
printk(KERN_NOTICE MODNAME printk(KERN_NOTICE MODNAME
": socket %d, card not a supported card type or not inserted correctly\n", ": socket %d, card not a supported card type or not inserted correctly\n",
hs_sockno(sp)); sp->number);
/* Don't do the rest unless a card is present */ /* Don't do the rest unless a card is present */
cscr &= ~(HD64465_PCCCSCR_PCDC| cscr &= ~(HD64465_PCCCSCR_PCDC|
HD64465_PCCCSCR_PRC| HD64465_PCCCSCR_PRC|
...@@ -839,34 +760,22 @@ static void hs_interrupt(int irq, void *dev, struct pt_regs *regs) ...@@ -839,34 +760,22 @@ static void hs_interrupt(int irq, void *dev, struct pt_regs *regs)
hs_out(sp, cscr, CSCR); hs_out(sp, cscr, CSCR);
if (events) { if (events)
/* pcmcia_parse_events(&sp->socket, events);
* Arrange for events to be reported to the registered
* event handler function (from CardServices) in a process return IRQ_HANDLED;
* context (keventd) "soon".
*/
spin_lock(&hs_pending_event_lock);
sp->pending_events |= events;
spin_unlock(&hs_pending_event_lock);
schedule_work(&hs_events_task);
}
} }
/*============================================================*/ /*============================================================*/
static struct pccard_operations hs_operations = { static struct pccard_operations hs_operations = {
.owner = THIS_MODULE,
.init = hs_init, .init = hs_init,
.suspend = hs_suspend, .suspend = hs_suspend,
.register_callback = hs_register_callback,
.inquire_socket = hs_inquire_socket,
.get_status = hs_get_status, .get_status = hs_get_status,
.get_socket = hs_get_socket, .get_socket = hs_get_socket,
.set_socket = hs_set_socket, .set_socket = hs_set_socket,
.set_io_map = hs_set_io_map, .set_io_map = hs_set_io_map,
.set_mem_map = hs_set_mem_map, .set_mem_map = hs_set_mem_map,
.proc_setup = hs_proc_setup,
}; };
static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base, static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base,
...@@ -886,9 +795,6 @@ static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base, ...@@ -886,9 +795,6 @@ static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base,
for (i=0 ; i<MAX_WIN ; i++) for (i=0 ; i<MAX_WIN ; i++)
sp->mem_maps[i].map = i; sp->mem_maps[i].map = i;
if ((sp->io_vma = get_vm_area(HS_IO_MAP_SIZE, VM_IOREMAP)) == 0)
return -ENOMEM;
hd64465_register_irq_demux(sp->irq, hs_irq_demux, sp); hd64465_register_irq_demux(sp->irq, hs_irq_demux, sp);
if ((err = request_irq(sp->irq, hs_interrupt, SA_INTERRUPT, MODNAME, sp)) < 0) if ((err = request_irq(sp->irq, hs_interrupt, SA_INTERRUPT, MODNAME, sp)) < 0)
...@@ -925,9 +831,8 @@ static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base, ...@@ -925,9 +831,8 @@ static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base,
hs_reset_socket(sp, 1); hs_reset_socket(sp, 1);
printk(KERN_INFO "HD64465 PCMCIA bridge socket %d at 0x%08lx irq %d io window %ldK@0x%08lx\n", printk(KERN_INFO "HD64465 PCMCIA bridge socket %d at 0x%08lx irq %d\n",
i, sp->mem_base, sp->irq, i, sp->mem_base, sp->irq);
sp->io_vma->size>>10, (unsigned long)sp->io_vma->addr);
return 0; return 0;
} }
...@@ -935,7 +840,10 @@ static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base, ...@@ -935,7 +840,10 @@ static int hs_init_socket(hs_socket_t *sp, int irq, unsigned long mem_base,
static void hs_exit_socket(hs_socket_t *sp) static void hs_exit_socket(hs_socket_t *sp)
{ {
unsigned short cscier, gcr; unsigned short cscier, gcr;
unsigned long flags;
local_irq_save(flags);
/* turn off interrupts in hardware */ /* turn off interrupts in hardware */
cscier = hs_in(sp, CSCIER); cscier = hs_in(sp, CSCIER);
cscier = (cscier & IER_MASK) | IER_OFF; cscier = (cscier & IER_MASK) | IER_OFF;
...@@ -955,19 +863,13 @@ static void hs_exit_socket(hs_socket_t *sp) ...@@ -955,19 +863,13 @@ static void hs_exit_socket(hs_socket_t *sp)
free_irq(sp->irq, hs_interrupt); free_irq(sp->irq, hs_interrupt);
hd64465_unregister_irq_demux(sp->irq); hd64465_unregister_irq_demux(sp->irq);
} }
if (sp->io_vma != 0)
vfree(sp->io_vma->addr);
}
static struct pcmcia_socket_class_data hd64465_data = { local_irq_restore(flags);
.nsock = HS_MAX_SOCKETS, }
.ops = &hs_operations,
};
static struct device_driver hd64465_driver = { static struct device_driver hd64465_driver = {
.name = "hd64465-pcmcia", .name = "hd64465-pcmcia",
.bus = &platform_bus_type, .bus = &platform_bus_type,
.devclass = &pcmcia_socket_class,
.suspend = pcmcia_socket_dev_suspend, .suspend = pcmcia_socket_dev_suspend,
.resume = pcmcia_socket_dev_resume, .resume = pcmcia_socket_dev_resume,
}; };
...@@ -996,7 +898,8 @@ static int __init init_hs(void) ...@@ -996,7 +898,8 @@ static int __init init_hs(void)
} }
/* hd64465_io_debug = 1; */ /* hd64465_io_debug = 1; */
register_driver(&hd64465_driver); if (driver_register(&hd64465_driver))
return -EINVAL;
/* Wake both sockets out of STANDBY mode */ /* Wake both sockets out of STANDBY mode */
/* TODO: wait 15ms */ /* TODO: wait 15ms */
...@@ -1014,14 +917,22 @@ static int __init init_hs(void) ...@@ -1014,14 +917,22 @@ static int __init init_hs(void)
v |= HD64465_PCCCSCR_PSWSEL; v |= HD64465_PCCCSCR_PSWSEL;
outb(v, HD64465_REG_PCC0CSCR); outb(v, HD64465_REG_PCC0CSCR);
hs_set_voltages(&hs_sockets[0], 0, 0);
hs_set_voltages(&hs_sockets[1], 0, 0);
/* /*
* Setup hs_sockets[] structures and request system resources. * Setup hs_sockets[] structures and request system resources.
* TODO: on memory allocation failure, power down the socket * TODO: on memory allocation failure, power down the socket
* before quitting. * before quitting.
*/ */
for (i=0; i<HS_MAX_SOCKETS; i++) {
hs_set_voltages(&hs_sockets[i], 0, 0);
hs_sockets[i].socket.features |= SS_CAP_PCCARD | SS_CAP_STATIC_MAP; /* mappings are fixed in host memory */
hs_sockets[i].socket.irq_mask = 0xffde;/*0xffff*/ /* IRQs mapped in s/w so can do any, really */
hs_sockets[i].socket.map_size = HD64465_PCC_WINDOW; /* 16MB fixed window size */
hs_sockets[i].socket.owner = THIS_MODULE;
hs_sockets[i].socket.ss_entry = &hs_operations;
}
i = hs_init_socket(&hs_sockets[0], i = hs_init_socket(&hs_sockets[0],
HD64465_IRQ_PCMCIA0, HD64465_IRQ_PCMCIA0,
HD64465_PCC0_BASE, HD64465_PCC0_BASE,
...@@ -1040,27 +951,31 @@ static int __init init_hs(void) ...@@ -1040,27 +951,31 @@ static int __init init_hs(void)
} }
/* hd64465_io_debug = 0; */ /* hd64465_io_debug = 0; */
hd64465_device.dev.class_data = &hd64465_data;
platform_device_register(&hd64465_device); platform_device_register(&hd64465_device);
return 0; for (i=0; i<HS_MAX_SOCKETS; i++) {
unsigned int ret;
hs_sockets[i].socket.dev.dev = &hd64465_device.dev;
hs_sockets[i].number = i;
ret = pcmcia_register_socket(&hs_sockets[i].socket);
if (ret && i)
pcmcia_unregister_socket(&hs_sockets[0].socket);
}
return 0;
} }
static void __exit exit_hs(void) static void __exit exit_hs(void)
{ {
u_long flags;
int i; int i;
save_and_cli(flags);
/* for (i=0 ; i<HS_MAX_SOCKETS ; i++) {
* Release kernel resources pcmcia_unregister_socket(&hs_sockets[i].socket);
*/ hs_exit_socket(&hs_sockets[i]);
for (i=0 ; i<HS_MAX_SOCKETS ; i++) }
hs_exit_socket(&hs_sockets[i]);
platform_device_unregister(&hd64465_device); platform_device_unregister(&hd64465_device);
restore_flags(flags);
unregister_driver(&hd64465_driver); unregister_driver(&hd64465_driver);
} }
......
...@@ -69,7 +69,7 @@ obj-$(CONFIG_FB_SA1100) += sa1100fb.o cfbfillrect.o cfbcopyarea.o cfbi ...@@ -69,7 +69,7 @@ obj-$(CONFIG_FB_SA1100) += sa1100fb.o cfbfillrect.o cfbcopyarea.o cfbi
obj-$(CONFIG_FB_VIRTUAL) += vfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_VIRTUAL) += vfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_HIT) += hitfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_HIT) += hitfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_E1355) += epson1355fb.o obj-$(CONFIG_FB_E1355) += epson1355fb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o obj-$(CONFIG_FB_PVR2) += pvr2fb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o obj-$(CONFIG_FB_VOODOO1) += sstfb.o cfbfillrect.o cfbcopyarea.o cfbimgblt.o
obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o cfbimgblt.o cfbcopyarea.o obj-$(CONFIG_FB_FFB) += ffb.o sbuslib.o cfbimgblt.o cfbcopyarea.o
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Dreamcast. * Dreamcast.
* *
* Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org> * Copyright (c) 2001 M. R. Brown <mrbrown@0xd6.org>
* Copyright (c) 2001 Paul Mundt <lethal@chaoticdreams.org> * Copyright (c) 2001, 2002, 2003 Paul Mundt <lethal@linux-sh.org>
* *
* This file is part of the LinuxDC project (linuxdc.sourceforge.net). * This file is part of the LinuxDC project (linuxdc.sourceforge.net).
* *
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
/* /*
* This driver is mostly based on the excellent amifb and vfb sources. It uses * This driver is mostly based on the excellent amifb and vfb sources. It uses
* an odd scheme for converting hardware values to/from framebuffer values, here are * an odd scheme for converting hardware values to/from framebuffer values,
* some hacked-up formulas: * here are some hacked-up formulas:
* *
* The Dreamcast has screen offsets from each side of its four borders and the start * The Dreamcast has screen offsets from each side of its four borders and
* offsets of the display window. I used these values to calculate 'pseudo' values * the start offsets of the display window. I used these values to calculate
* (think of them as placeholders) for the fb video mode, so that when it came time * 'pseudo' values (think of them as placeholders) for the fb video mode, so
* to convert these values back into their hardware values, I could just add mode- * that when it came time to convert these values back into their hardware
* specific offsets to get the correct mode settings: * values, I could just add mode- specific offsets to get the correct mode
* settings:
* *
* left_margin = diwstart_h - borderstart_h; * left_margin = diwstart_h - borderstart_h;
* right_margin = borderstop_h - (diwstart_h + xres); * right_margin = borderstop_h - (diwstart_h + xres);
...@@ -29,9 +30,9 @@ ...@@ -29,9 +30,9 @@
* hsync_len = borderstart_h + (hsync_total - borderstop_h); * hsync_len = borderstart_h + (hsync_total - borderstop_h);
* vsync_len = borderstart_v + (vsync_total - borderstop_v); * vsync_len = borderstart_v + (vsync_total - borderstop_v);
* *
* Then, when it's time to convert back to hardware settings, the only constants * Then, when it's time to convert back to hardware settings, the only
* are the borderstart_* offsets, all other values are derived from the fb video * constants are the borderstart_* offsets, all other values are derived from
* mode: * the fb video mode:
* *
* // PAL * // PAL
* borderstart_h = 116; * borderstart_h = 116;
...@@ -57,7 +58,6 @@ ...@@ -57,7 +58,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/console.h>
#ifdef CONFIG_SH_DREAMCAST #ifdef CONFIG_SH_DREAMCAST
#include <asm/io.h> #include <asm/io.h>
...@@ -66,14 +66,9 @@ ...@@ -66,14 +66,9 @@
#endif #endif
#ifdef CONFIG_MTRR #ifdef CONFIG_MTRR
#include <asm/mtrr.h> #include <asm/mtrr.h>
#endif #endif
#include <video/fbcon.h>
#include <video/fbcon-cfb16.h>
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
#ifdef CONFIG_FB_PVR2_DEBUG #ifdef CONFIG_FB_PVR2_DEBUG
# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
#else #else
...@@ -124,16 +119,6 @@ static struct pvr2_params outputs[] __initdata = { ...@@ -124,16 +119,6 @@ static struct pvr2_params outputs[] __initdata = {
*/ */
static struct pvr2fb_par { static struct pvr2fb_par {
int xres;
int yres;
int vxres;
int vyres;
int xoffset;
int yoffset;
u_short bpp;
u_long pixclock;
u_short hsync_total; /* Clocks/line */ u_short hsync_total; /* Clocks/line */
u_short vsync_total; /* Lines/field */ u_short vsync_total; /* Lines/field */
u_short borderstart_h; u_short borderstart_h;
...@@ -144,53 +129,49 @@ static struct pvr2fb_par { ...@@ -144,53 +129,49 @@ static struct pvr2fb_par {
u_short diwstart_v; /* Vertical offset of the display field, for u_short diwstart_v; /* Vertical offset of the display field, for
interlaced modes, this is the long field */ interlaced modes, this is the long field */
u_long disp_start; /* Address of image within VRAM */ u_long disp_start; /* Address of image within VRAM */
u_long next_line; /* Modulo for next line */
u_char is_interlaced; /* Is the display interlaced? */ u_char is_interlaced; /* Is the display interlaced? */
u_char is_doublescan; /* Are scanlines output twice? (doublescan) */ u_char is_doublescan; /* Are scanlines output twice? (doublescan) */
u_char is_lowres; /* Is horizontal pixel-doubling enabled? */ u_char is_lowres; /* Is horizontal pixel-doubling enabled? */
} *currentpar;
u_long bordercolor; /* RGB888 format border color */ static struct fb_info *fb_info;
u_long vmode;
} currentpar;
static int currbpp;
static struct display disp;
static struct fb_info fb_info;
static int pvr2fb_inverse = 0; static int pvr2fb_inverse = 0;
static struct { u_short red, green, blue, alpha; } palette[256]; static struct fb_fix_screeninfo pvr2_fix __initdata = {
static union { .id = "NEC PowerVR2",
#ifdef FBCON_HAS_CFB16 .type = FB_TYPE_PACKED_PIXELS,
u16 cfb16[16]; .visual = FB_VISUAL_TRUECOLOR,
#endif .ypanstep = 1,
#ifdef FBCON_HAS_CFB24 .ywrapstep = 1,
u32 cfb24[16]; .accel = FB_ACCEL_NONE,
#endif };
#ifdef FBCON_HAS_CFB32
u32 cfb32[16];
#endif
} fbcon_cmap;
static char pvr2fb_name[16] = "NEC PowerVR2"; static struct fb_var_screeninfo pvr2_var __initdata = {
.xres = 640,
.yres = 480,
.xres_virtual = 640,
.yres_virtual = 480,
.bits_per_pixel =16,
.red = { 11, 5, 0 },
.green = { 5, 6, 0 },
.blue = { 0, 5, 0 },
.activate = FB_ACTIVATE_NOW,
.height = -1,
.width = -1,
.vmode = FB_VMODE_NONINTERLACED,
};
#define VIDEOMEMSIZE (8*1024*1024) #define VIDEOMEMSIZE (8*1024*1024)
static u_long videomemory = 0xa5000000, videomemorysize = VIDEOMEMSIZE; static u_long videomemory = 0xa5000000, videomemorysize = VIDEOMEMSIZE;
static int cable_type = -1; static int cable_type = -1;
static int video_output = -1; static int video_output = -1;
#ifdef CONFIG_MTRR static int nopan = 0;
static int enable_mtrr = 1; static int nowrap = 1;
static int mtrr_handle;
#endif
/* /*
* We do all updating, blanking, etc. during the vertical retrace period * We do all updating, blanking, etc. during the vertical retrace period
*/ */
static u_short do_vmode_full = 0; /* Change the video mode */ static u_short do_vmode_full = 0; /* Change the video mode */
static u_short do_vmode_pan = 0; /* Update the video mode */ static u_short do_vmode_pan = 0; /* Update the video mode */
static short do_blank = 0; /* (Un)Blank the screen */ static short do_blank = 0; /* (Un)Blank the screen */
...@@ -201,50 +182,15 @@ static u_short is_blanked = 0; /* Is the screen blanked? */ ...@@ -201,50 +182,15 @@ static u_short is_blanked = 0; /* Is the screen blanked? */
int pvr2fb_setup(char*); int pvr2fb_setup(char*);
static int pvr2fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info);
static int pvr2fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int pvr2fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int pvr2fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info);
static int pvr2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int pvr2fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info);
static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info); u_int transp, struct fb_info *info);
static int pvr2fb_blank(int blank, struct fb_info *info); static int pvr2fb_blank(int blank, struct fb_info *info);
/*
* Interface to the low level console driver
*/
static int pvr2fbcon_switch(int con, struct fb_info *info);
static int pvr2fbcon_updatevar(int con, struct fb_info *info);
/*
* Internal/hardware-specific routines
*/
static u_long get_line_length(int xres_virtual, int bpp); static u_long get_line_length(int xres_virtual, int bpp);
static void set_color_bitfields(struct fb_var_screeninfo *var); static void set_color_bitfields(struct fb_var_screeninfo *var);
static int pvr2_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue, static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info);
u_int *transp, struct fb_info *info); static int pvr2fb_set_par(struct fb_info *info);
static void pvr2_update_display(struct fb_info *info);
static int pvr2_encode_fix(struct fb_fix_screeninfo *fix, static void pvr2_init_display(struct fb_info *info);
struct pvr2fb_par *par);
static int pvr2_decode_var(struct fb_var_screeninfo *var,
struct pvr2fb_par *par);
static int pvr2_encode_var(struct fb_var_screeninfo *var,
struct pvr2fb_par *par);
static void pvr2_get_par(struct pvr2fb_par *par);
static void pvr2_set_var(struct fb_var_screeninfo *var);
static void pvr2_pan_var(struct fb_var_screeninfo *var);
static int pvr2_update_par(void);
static void pvr2_update_display(void);
static void pvr2_init_display(void);
static void pvr2_do_blank(void); static void pvr2_do_blank(void);
static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp); static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
static int pvr2_init_cable(void); static int pvr2_init_cable(void);
...@@ -252,19 +198,18 @@ static int pvr2_get_param(const struct pvr2_params *p, const char *s, ...@@ -252,19 +198,18 @@ static int pvr2_get_param(const struct pvr2_params *p, const char *s,
int val, int size); int val, int size);
static struct fb_ops pvr2fb_ops = { static struct fb_ops pvr2fb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_get_fix = pvr2fb_get_fix, .fb_setcolreg = pvr2fb_setcolreg,
.fb_get_var = pvr2fb_get_var, .fb_blank = pvr2fb_blank,
.fb_set_var = pvr2fb_set_var, .fb_check_var = pvr2fb_check_var,
.fb_get_cmap = pvr2fb_get_cmap, .fb_set_par = pvr2fb_set_par,
.fb_set_cmap = pvr2fb_set_cmap, .fb_fillrect = cfb_fillrect,
.fb_setcolreg = pvr2fb_setcolreg, .fb_copyarea = cfb_copyarea,
.fb_pan_display = pvr2fb_pan_display, .fb_imageblit = cfb_imageblit,
.fb_blank = pvr2fb_blank, .fb_cursor = soft_cursor,
}; };
static struct fb_videomode pvr2_modedb[] __initdata = { static struct fb_videomode pvr2_modedb[] __initdata = {
/* /*
* Broadcast video modes (PAL and NTSC). I'm unfamiliar with * Broadcast video modes (PAL and NTSC). I'm unfamiliar with
* PAL-M and PAL-N, but from what I've read both modes parallel PAL and * PAL-M and PAL-N, but from what I've read both modes parallel PAL and
...@@ -275,21 +220,16 @@ static struct fb_videomode pvr2_modedb[] __initdata = { ...@@ -275,21 +220,16 @@ static struct fb_videomode pvr2_modedb[] __initdata = {
/* 640x480 @ 60Hz interlaced (NTSC) */ /* 640x480 @ 60Hz interlaced (NTSC) */
"ntsc_640x480i", 60, 640, 480, TV_CLK, 38, 33, 0, 18, 146, 26, "ntsc_640x480i", 60, 640, 480, TV_CLK, 38, 33, 0, 18, 146, 26,
FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP FB_SYNC_BROADCAST, FB_VMODE_INTERLACED | FB_VMODE_YWRAP
}, }, {
{
/* 640x240 @ 60Hz (NTSC) */ /* 640x240 @ 60Hz (NTSC) */
/* XXX: Broken! Don't use... */ /* XXX: Broken! Don't use... */
"ntsc_640x240", 60, 640, 240, TV_CLK, 38, 33, 0, 0, 146, 22, "ntsc_640x240", 60, 640, 240, TV_CLK, 38, 33, 0, 0, 146, 22,
FB_SYNC_BROADCAST, FB_VMODE_YWRAP FB_SYNC_BROADCAST, FB_VMODE_YWRAP
}, }, {
{
/* 640x480 @ 60hz (VGA) */ /* 640x480 @ 60hz (VGA) */
"vga_640x480", 60, 640, 480, VGA_CLK, 38, 33, 0, 18, 146, 26, "vga_640x480", 60, 640, 480, VGA_CLK, 38, 33, 0, 18, 146, 26,
0, FB_VMODE_YWRAP 0, FB_VMODE_YWRAP
}, },
}; };
#define NUM_TOTAL_MODES ARRAY_SIZE(pvr2_modedb) #define NUM_TOTAL_MODES ARRAY_SIZE(pvr2_modedb)
...@@ -301,222 +241,10 @@ static struct fb_videomode pvr2_modedb[] __initdata = { ...@@ -301,222 +241,10 @@ static struct fb_videomode pvr2_modedb[] __initdata = {
static int defmode = DEFMODE_NTSC; static int defmode = DEFMODE_NTSC;
static char *mode_option __initdata = NULL; static char *mode_option __initdata = NULL;
/* Get the fixed part of the display */
static int pvr2fb_get_fix(struct fb_fix_screeninfo *fix, int con,
struct fb_info *info)
{
struct pvr2fb_par par;
if (con == -1)
pvr2_get_par(&par);
else {
int err;
if ((err = pvr2_decode_var(&fb_display[con].var, &par)))
return err;
}
return pvr2_encode_fix(fix, &par);
}
/* Get the user-defined part of the display */
static int pvr2fb_get_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
int err = 0;
if (con == -1) {
struct pvr2fb_par par;
pvr2_get_par(&par);
err = pvr2_encode_var(var, &par);
} else
*var = fb_display[con].var;
return err;
}
/* Set the user-defined part of the display */
static int pvr2fb_set_var(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
int err, activate = var->activate;
int oldxres, oldyres, oldvxres, oldvyres, oldbpp;
struct pvr2fb_par par;
struct display *display;
if (con >= 0)
display = &fb_display[con];
else
display = &disp; /* used during initialization */
/*
* FB_VMODE_CONUPDATE and FB_VMODE_SMOOTH_XPAN are equal!
* as FB_VMODE_SMOOTH_XPAN is only used internally
*/
if (var->vmode & FB_VMODE_CONUPDATE) {
var->vmode |= FB_VMODE_YWRAP;
var->xoffset = display->var.xoffset;
var->yoffset = display->var.yoffset;
}
if ((err = pvr2_decode_var(var, &par)))
return err;
pvr2_encode_var(var, &par);
/* Do memory check and bitfield set here?? */
if ((activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
oldxres = display->var.xres;
oldyres = display->var.yres;
oldvxres = display->var.xres_virtual;
oldvyres = display->var.yres_virtual;
oldbpp = display->var.bits_per_pixel;
display->var = *var;
if (oldxres != var->xres || oldyres != var->yres ||
oldvxres != var->xres_virtual || oldvyres != var->yres_virtual ||
oldbpp != var->bits_per_pixel) {
struct fb_fix_screeninfo fix;
pvr2_encode_fix(&fix, &par);
display->scrollmode = SCROLL_YREDRAW;
display->visual = fix.visual;
display->type = fix.type;
display->type_aux = fix.type_aux;
display->ypanstep = fix.ypanstep;
display->ywrapstep = fix.ywrapstep;
display->line_length = fix.line_length;
display->can_soft_blank = 1;
display->inverse = pvr2fb_inverse;
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16:
display->dispsw = &fbcon_cfb16;
display->dispsw_data = fbcon_cmap.cfb16;
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:
display->dispsw = &fbcon_cfb24;
display->dispsw_data = fbcon_cmap.cfb24;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:
display->dispsw = &fbcon_cfb32;
display->dispsw_data = fbcon_cmap.cfb32;
break;
#endif
default:
display->dispsw = &fbcon_dummy;
break;
}
if (fb_info.changevar)
(*fb_info.changevar)(con);
}
if (oldbpp != var->bits_per_pixel) {
if ((err = fb_alloc_cmap(&display->cmap, 0, 0)))
return err;
do_install_cmap(con, info);
}
if (con == info->currcon)
pvr2_set_var(&display->var);
}
return 0;
}
/*
* Pan or wrap the display.
* This call looks only at xoffset, yoffset and the FB_VMODE_YRAP flag
*/
static int pvr2fb_pan_display(struct fb_var_screeninfo *var, int con,
struct fb_info *info)
{
if (var->vmode & FB_VMODE_YWRAP) {
if (var->yoffset<0 || var->yoffset >=
fb_display[con].var.yres_virtual || var->xoffset)
return -EINVAL;
} else {
if (var->xoffset+fb_display[con].var.xres >
fb_display[con].var.xres_virtual ||
var->yoffset+fb_display[con].var.yres >
fb_display[con].var.yres_virtual)
return -EINVAL;
}
if (con == info->currcon)
pvr2_pan_var(var);
fb_display[con].var.xoffset = var->xoffset;
fb_display[con].var.yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP)
fb_display[con].var.vmode |= FB_VMODE_YWRAP;
else
fb_display[con].var.vmode &= ~FB_VMODE_YWRAP;
return 0;
}
/* Get the colormap */
static int pvr2fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
if (con == info->currcon) /* current console? */
return fb_get_cmap(cmap, kspc, pvr2_getcolreg, info);
else if (fb_display[con].cmap.len) /* non default colormap? */
fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
else
fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel),
cmap, kspc ? 0 : 2);
return 0;
}
/* Set the colormap */
static int pvr2fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
struct fb_info *info)
{
int err;
if (!fb_display[con].cmap.len) { /* no colormap allocated? */
if ((err = fb_alloc_cmap(&fb_display[con].cmap,
1<<fb_display[con].var.bits_per_pixel,
0)))
return err;
}
if (con == info->currcon) /* current console? */
return fb_set_cmap(cmap, kspc, info);
else
fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
return 0;
}
static int pvr2fbcon_switch(int con, struct fb_info *info)
{
/* Do we have to save the colormap? */
if (fb_display[info->currcon].cmap.len)
fb_get_cmap(&fb_display[info->currcon].cmap, 1, pvr2_getcolreg, info);
info->currcon = con;
pvr2_set_var(&fb_display[con].var);
/* Install new colormap */
do_install_cmap(con, info);
return 0;
}
static int pvr2fbcon_updatevar(int con, struct fb_info *info)
{
pvr2_pan_var(&fb_display[con].var);
return 0;
}
static int pvr2fb_blank(int blank, struct fb_info *info) static int pvr2fb_blank(int blank, struct fb_info *info)
{ {
do_blank = blank ? blank : -1; do_blank = blank ? blank : -1;
return 0;
} }
static inline u_long get_line_length(int xres_virtual, int bpp) static inline u_long get_line_length(int xres_virtual, int bpp)
...@@ -548,52 +276,29 @@ static void set_color_bitfields(struct fb_var_screeninfo *var) ...@@ -548,52 +276,29 @@ static void set_color_bitfields(struct fb_var_screeninfo *var)
} }
} }
static int pvr2_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
u_int *transp, struct fb_info *info)
{
if (regno > 255)
return 1;
*red = palette[regno].red;
*green = palette[regno].green;
*blue = palette[regno].blue;
*transp = 0;
return 0;
}
static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info) u_int transp, struct fb_info *info)
{ {
if (regno > 255) if (regno > 255)
return 1; return 1;
palette[regno].red = red;
palette[regno].green = green;
palette[regno].blue = blue;
if (regno < 16) { if (regno < 16) {
switch (currbpp) { switch (info->var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB16
case 16: /* RGB 565 */ case 16: /* RGB 565 */
fbcon_cmap.cfb16[regno] = (red & 0xf800) | ((u16*)(info->pseudo_palette))[regno] = (red & 0xf800) |
((green & 0xfc00) >> 5) | ((green & 0xfc00) >> 5) |
((blue & 0xf800) >> 11); ((blue & 0xf800) >> 11);
break; break;
#endif
#ifdef FBCON_HAS_CFB24
case 24: /* RGB 888 */ case 24: /* RGB 888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
fbcon_cmap.cfb24[regno] = (red << 16) | (green << 8) | blue; ((u32*)(info->pseudo_palette))[regno] = (red << 16) | (green << 8) | blue;
break; break;
#endif
#ifdef FBCON_HAS_CFB32
case 32: /* ARGB 8888 */ case 32: /* ARGB 8888 */
red >>= 8; green >>= 8; blue >>= 8; red >>= 8; green >>= 8; blue >>= 8;
fbcon_cmap.cfb32[regno] = (red << 16) | (green << 8) | blue; ((u32*)(info->pseudo_palette))[regno] = (transp << 24) |(red << 16) | (green << 8) | blue;
break; break;
#endif
default: default:
DPRINTK("Invalid bit depth %d?!?\n", currbpp); DPRINTK("Invalid bit depth %d?!?\n", info->var.bits_per_pixel);
return 1; return 1;
} }
} }
...@@ -601,85 +306,33 @@ static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, ...@@ -601,85 +306,33 @@ static int pvr2fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
return 0; return 0;
} }
static int pvr2fb_set_par(struct fb_info *info)
static int pvr2_encode_fix(struct fb_fix_screeninfo *fix,
struct pvr2fb_par *par)
{
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id, pvr2fb_name);
fix->smem_start = videomemory;
fix->smem_len = videomemorysize;
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
fix->visual = FB_VISUAL_TRUECOLOR;
if (par->vmode & FB_VMODE_YWRAP) {
fix->ywrapstep = 1;
fix->xpanstep = fix->ypanstep = 0;
} else {
fix->ywrapstep = 0;
fix->xpanstep = 1;
fix->ypanstep = 1;
}
fix->line_length = par->next_line;
return 0;
}
/*
* Create a hardware video mode using the framebuffer values. If a value needs
* to be clipped or constrained it's done here. This routine needs a bit more
* work to make sure we're doing the right tests at the right time.
*/
static int pvr2_decode_var(struct fb_var_screeninfo *var,
struct pvr2fb_par *par)
{ {
struct pvr2fb_par *par = (struct pvr2fb_par *)info->par;
struct fb_var_screeninfo *var = &info->var;
u_long line_length; u_long line_length;
u_short vtotal; u_short vtotal;
if (var->pixclock != TV_CLK && var->pixclock != VGA_CLK) {
DPRINTK("Invalid pixclock value %d\n", var->pixclock);
return -EINVAL;
}
par->pixclock = var->pixclock;
if ((par->xres = var->xres) < 320)
par->xres = 320;
if ((par->yres = var->yres) < 240)
par->yres = 240;
if ((par->vxres = var->xres_virtual) < par->xres)
par->vxres = par->xres;
if ((par->vyres = var->yres_virtual) < par->yres)
par->vyres = par->yres;
if ((par->bpp = var->bits_per_pixel) <= 16)
par->bpp = 16;
else if ((par->bpp = var->bits_per_pixel) <= 24)
par->bpp = 24;
else if ((par->bpp = var->bits_per_pixel) <= 32)
par->bpp = 32;
currbpp = par->bpp;
/* /*
* XXX: It's possible that a user could use a VGA box, change the cable * XXX: It's possible that a user could use a VGA box, change the cable
* type in hardware (i.e. switch from VGA<->composite), then change modes * type in hardware (i.e. switch from VGA<->composite), then change
* (i.e. switching to another VT). If that happens we should automagically * modes (i.e. switching to another VT). If that happens we should
* change the output format to cope, but currently I don't have a VGA box * automagically change the output format to cope, but currently I
* to make sure this works properly. * don't have a VGA box to make sure this works properly.
*/ */
cable_type = pvr2_init_cable(); cable_type = pvr2_init_cable();
if (cable_type == CT_VGA && video_output != VO_VGA) if (cable_type == CT_VGA && video_output != VO_VGA)
video_output = VO_VGA; video_output = VO_VGA;
par->vmode = var->vmode & FB_VMODE_MASK; var->vmode &= FB_VMODE_MASK;
if (par->vmode & FB_VMODE_INTERLACED && video_output != VO_VGA) if (var->vmode & FB_VMODE_INTERLACED && video_output != VO_VGA)
par->is_interlaced = 1; par->is_interlaced = 1;
/* /*
* XXX: Need to be more creative with this (i.e. allow doublecan for * XXX: Need to be more creative with this (i.e. allow doublecan for
* PAL/NTSC output). * PAL/NTSC output).
*/ */
par->is_doublescan = (par->yres < 480 && video_output == VO_VGA); if (var->vmode & FB_VMODE_DOUBLE && video_output == VO_VGA)
par->is_doublescan = 1;
par->hsync_total = var->left_margin + var->xres + var->right_margin + par->hsync_total = var->left_margin + var->xres + var->right_margin +
var->hsync_len; var->hsync_len;
...@@ -691,22 +344,12 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var, ...@@ -691,22 +344,12 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var,
if (par->is_interlaced) if (par->is_interlaced)
vtotal /= 2; vtotal /= 2;
if (vtotal > (PAL_VTOTAL + NTSC_VTOTAL)/2) { if (vtotal > (PAL_VTOTAL + NTSC_VTOTAL)/2) {
/* PAL video output */
/* XXX: Should be using a range here ... ? */
if (par->hsync_total != PAL_HTOTAL) {
DPRINTK("invalid hsync total for PAL\n");
return -EINVAL;
}
/* XXX: Check for start values here... */ /* XXX: Check for start values here... */
/* XXX: Check hardware for PAL-compatibility */ /* XXX: Check hardware for PAL-compatibility */
par->borderstart_h = 116; par->borderstart_h = 116;
par->borderstart_v = 44; par->borderstart_v = 44;
} else { } else {
/* NTSC video output */ /* NTSC video output */
if (par->hsync_total != NTSC_HTOTAL) {
DPRINTK("invalid hsync total for NTSC\n");
return -EINVAL;
}
par->borderstart_h = 126; par->borderstart_h = 126;
par->borderstart_v = 18; par->borderstart_v = 18;
} }
...@@ -714,155 +357,123 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var, ...@@ -714,155 +357,123 @@ static int pvr2_decode_var(struct fb_var_screeninfo *var,
/* VGA mode */ /* VGA mode */
/* XXX: What else needs to be checked? */ /* XXX: What else needs to be checked? */
/* /*
* XXX: We have a little freedom in VGA modes, what ranges should * XXX: We have a little freedom in VGA modes, what ranges
* be here (i.e. hsync/vsync totals, etc.)? * should be here (i.e. hsync/vsync totals, etc.)?
*/ */
par->borderstart_h = 126; par->borderstart_h = 126;
par->borderstart_v = 40; par->borderstart_v = 40;
} }
/* Calculate the remainding offsets */ /* Calculate the remainding offsets */
par->borderstop_h = par->borderstart_h + par->hsync_total -
var->hsync_len;
par->borderstop_v = par->borderstart_v + par->vsync_total -
var->vsync_len;
par->diwstart_h = par->borderstart_h + var->left_margin; par->diwstart_h = par->borderstart_h + var->left_margin;
par->diwstart_v = par->borderstart_v + var->upper_margin; par->diwstart_v = par->borderstart_v + var->upper_margin;
par->borderstop_h = par->diwstart_h + var->xres +
var->right_margin;
par->borderstop_v = par->diwstart_v + var->yres +
var->lower_margin;
if (!par->is_interlaced) if (!par->is_interlaced)
par->borderstop_v /= 2; par->borderstop_v /= 2;
if (info->var.xres < 640)
if (par->xres < 640)
par->is_lowres = 1; par->is_lowres = 1;
/* XXX: Needs testing. */
if (!((par->vmode ^ var->vmode) & FB_VMODE_YWRAP)) {
par->xoffset = var->xoffset;
par->yoffset = var->yoffset;
if (par->vmode & FB_VMODE_YWRAP) {
if (par->xoffset || par->yoffset < 0 || par->yoffset >=
par->vyres)
par->xoffset = par->yoffset = 0;
} else {
if (par->xoffset < 0 || par->xoffset > par->vxres-par->xres ||
par->yoffset < 0 || par->yoffset > par->vyres-par->yres)
par->xoffset = par->yoffset = 0;
}
} else
par->xoffset = par->yoffset = 0;
/* Check memory sizes */
line_length = get_line_length(var->xres_virtual, var->bits_per_pixel); line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
if (line_length * var->yres_virtual > videomemorysize) par->disp_start = videomemory + (line_length * var->yoffset) * line_length;
return -ENOMEM; info->fix.line_length = line_length;
par->disp_start = videomemory + (get_line_length(par->vxres, par->bpp) *
par->yoffset) * get_line_length(par->xoffset, par->bpp);
par->next_line = line_length;
return 0; return 0;
} }
static int pvr2_encode_var(struct fb_var_screeninfo *var, static int pvr2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
struct pvr2fb_par *par)
{ {
memset(var, 0, sizeof(struct fb_var_screeninfo)); u_short vtotal, hsync_total;
u_long line_length;
if (var->pixclock != TV_CLK || var->pixclock != VGA_CLK) {
DPRINTK("Invalid pixclock value %d\n", var->pixclock);
return -EINVAL;
}
var->xres = par->xres; if (var->xres < 320)
var->yres = par->yres; var->xres = 320;
var->xres_virtual = par->vxres; if (var->yres < 240)
var->yres_virtual = par->vyres; var->yres = 240;
var->xoffset = par->xoffset; if (var->xres_virtual < var->xres)
var->yoffset = par->yoffset; var->xres_virtual = var->xres;
if (var->yres_virtual < var->yres)
var->yres_virtual = var->yres;
if (var->bits_per_pixel <= 16)
var->bits_per_pixel = 16;
else if (var->bits_per_pixel <= 24)
var->bits_per_pixel = 24;
else if (var->bits_per_pixel <= 32)
var->bits_per_pixel = 32;
var->bits_per_pixel = par->bpp;
set_color_bitfields(var); set_color_bitfields(var);
var->activate = FB_ACTIVATE_NOW; if (var->vmode & FB_VMODE_YWRAP) {
var->height = -1; if (var->xoffset || var->yoffset < 0 ||
var->width = -1; var->yoffset >= var->yres_virtual) {
var->xoffset = var->yoffset = 0;
var->pixclock = par->pixclock; } else {
if (var->xoffset > var->xres_virtual - var->xres ||
var->yoffset > var->yres_virtual - var->yres ||
var->xoffset < 0 || var->yoffset < 0)
var->xoffset = var->yoffset = 0;
}
} else {
var->xoffset = var->yoffset = 0;
}
if (par->is_doublescan) /*
* XXX: Need to be more creative with this (i.e. allow doublecan for
* PAL/NTSC output).
*/
if (var->yres < 480 && video_output == VO_VGA)
var->vmode = FB_VMODE_DOUBLE; var->vmode = FB_VMODE_DOUBLE;
if (par->is_interlaced)
var->vmode |= FB_VMODE_INTERLACED;
else
var->vmode |= FB_VMODE_NONINTERLACED;
var->right_margin = par->borderstop_h - (par->diwstart_h + par->xres);
var->left_margin = par->diwstart_h - par->borderstart_h;
var->hsync_len = par->borderstart_h + (par->hsync_total - par->borderstop_h);
var->upper_margin = par->diwstart_v - par->borderstart_v;
var->lower_margin = par->borderstop_v - (par->diwstart_v + par->yres);
var->vsync_len = par->borderstart_v + (par->vsync_total - par->borderstop_v);
if (video_output != VO_VGA) if (video_output != VO_VGA)
var->sync = FB_SYNC_BROADCAST; var->sync = FB_SYNC_BROADCAST | FB_VMODE_INTERLACED;
if (par->vmode & FB_VMODE_YWRAP)
var->vmode |= FB_VMODE_YWRAP;
return 0;
}
static void pvr2_get_par(struct pvr2fb_par *par)
{
*par = currentpar;
}
/* Setup the new videomode in hardware */
static void pvr2_set_var(struct fb_var_screeninfo *var)
{
do_vmode_pan = 0;
do_vmode_full = 0;
pvr2_decode_var(var, &currentpar);
do_vmode_full = 1; hsync_total = var->left_margin + var->xres + var->right_margin +
} var->hsync_len;
vtotal = var->upper_margin + var->yres + var->lower_margin +
/* var->vsync_len;
* Pan or wrap the display
* This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag in `var'.
*/
static void pvr2_pan_var(struct fb_var_screeninfo *var)
{
struct pvr2fb_par *par = &currentpar;
par->xoffset = var->xoffset;
par->yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP)
par->vmode |= FB_VMODE_YWRAP;
else
par->vmode &= ~FB_VMODE_YWRAP;
do_vmode_pan = 0;
pvr2_update_par();
do_vmode_pan = 1;
}
static int pvr2_update_par(void)
{
struct pvr2fb_par *par = &currentpar;
u_long move;
move = get_line_length(par->xoffset, par->bpp);
if (par->yoffset) {
par->disp_start += (par->next_line * par->yoffset) + move;
} else
par->disp_start += move;
if (var->sync & FB_SYNC_BROADCAST) {
if (var->vmode & FB_VMODE_INTERLACED)
vtotal /= 2;
if (vtotal > (PAL_VTOTAL + NTSC_VTOTAL)/2) {
/* PAL video output */
/* XXX: Should be using a range here ... ? */
if (hsync_total != PAL_HTOTAL) {
DPRINTK("invalid hsync total for PAL\n");
return -EINVAL;
}
} else {
/* NTSC video output */
if (hsync_total != NTSC_HTOTAL) {
DPRINTK("invalid hsync total for NTSC\n");
return -EINVAL;
}
}
}
/* Check memory sizes */
line_length = get_line_length(var->xres_virtual, var->bits_per_pixel);
if (line_length * var->yres_virtual > videomemorysize)
return -ENOMEM;
return 0; return 0;
} }
static void pvr2_update_display(void) static void pvr2_update_display(struct fb_info *info)
{ {
struct pvr2fb_par *par = &currentpar; struct pvr2fb_par *par = (struct pvr2fb_par *) info->par;
struct fb_var_screeninfo *var = &info->var;
/* Update the start address of the display image */ /* Update the start address of the display image */
ctrl_outl(par->disp_start, DISP_DIWADDRL); ctrl_outl(par->disp_start, DISP_DIWADDRL);
ctrl_outl(par->disp_start + ctrl_outl(par->disp_start +
get_line_length(par->xoffset + par->xres, par->bpp), get_line_length(var->xoffset+var->xres, var->bits_per_pixel),
DISP_DIWADDRS); DISP_DIWADDRS);
} }
...@@ -872,11 +483,12 @@ static void pvr2_update_display(void) ...@@ -872,11 +483,12 @@ static void pvr2_update_display(void)
* registers are still undocumented. * registers are still undocumented.
*/ */
static void pvr2_init_display(void) static void pvr2_init_display(struct fb_info *info)
{ {
struct pvr2fb_par *par = &currentpar; struct pvr2fb_par *par = (struct pvr2fb_par *) info->par;
struct fb_var_screeninfo *var = &info->var;
u_short diw_height, diw_width, diw_modulo = 1; u_short diw_height, diw_width, diw_modulo = 1;
u_short bytesperpixel = par->bpp / 8; u_short bytesperpixel = var->bits_per_pixel >> 3;
/* hsync and vsync totals */ /* hsync and vsync totals */
ctrl_outl((par->vsync_total << 16) | par->hsync_total, DISP_SYNCSIZE); ctrl_outl((par->vsync_total << 16) | par->hsync_total, DISP_SYNCSIZE);
...@@ -885,16 +497,16 @@ static void pvr2_init_display(void) ...@@ -885,16 +497,16 @@ static void pvr2_init_display(void)
/* since we're "panning" within vram, we need to offset things based /* since we're "panning" within vram, we need to offset things based
* on the offset from the virtual x start to our real gfx. */ * on the offset from the virtual x start to our real gfx. */
if (video_output != VO_VGA && par->is_interlaced) if (video_output != VO_VGA && par->is_interlaced)
diw_modulo += par->next_line / 4; diw_modulo += info->fix.line_length / 4;
diw_height = (par->is_interlaced ? par->yres / 2 : par->yres); diw_height = (par->is_interlaced ? var->yres / 2 : var->yres);
diw_width = get_line_length(par->xres, par->bpp) / 4; diw_width = get_line_length(var->xres, var->bits_per_pixel) / 4;
ctrl_outl((diw_modulo << 20) | (--diw_height << 10) | --diw_width, ctrl_outl((diw_modulo << 20) | (--diw_height << 10) | --diw_width,
DISP_DIWSIZE); DISP_DIWSIZE);
/* display address, long and short fields */ /* display address, long and short fields */
ctrl_outl(par->disp_start, DISP_DIWADDRL); ctrl_outl(par->disp_start, DISP_DIWADDRL);
ctrl_outl(par->disp_start + ctrl_outl(par->disp_start +
get_line_length(par->xoffset + par->xres, par->bpp), get_line_length(var->xoffset+var->xres, var->bits_per_pixel),
DISP_DIWADDRS); DISP_DIWADDRS);
/* border horizontal, border vertical, border color */ /* border horizontal, border vertical, border color */
...@@ -919,7 +531,6 @@ static void pvr2_init_display(void) ...@@ -919,7 +531,6 @@ static void pvr2_init_display(void)
/* video enable, color sync, interlace, /* video enable, color sync, interlace,
* hsync and vsync polarity (currently unused) */ * hsync and vsync polarity (currently unused) */
ctrl_outl(0x100 | ((par->is_interlaced /*|4*/) << 4), DISP_SYNCCONF); ctrl_outl(0x100 | ((par->is_interlaced /*|4*/) << 4), DISP_SYNCCONF);
} }
/* Simulate blanking by making the border cover the entire screen */ /* Simulate blanking by making the border cover the entire screen */
...@@ -941,23 +552,20 @@ static void pvr2_do_blank(void) ...@@ -941,23 +552,20 @@ static void pvr2_do_blank(void)
static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp) static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp)
{ {
if (do_vmode_pan || do_vmode_full) struct fb_info *info = dev_id;
pvr2_update_display();
if (do_vmode_pan || do_vmode_full)
pvr2_update_display(info);
if (do_vmode_full) if (do_vmode_full)
pvr2_init_display(); pvr2_init_display(info);
if (do_vmode_pan) if (do_vmode_pan)
do_vmode_pan = 0; do_vmode_pan = 0;
if (do_vmode_full)
do_vmode_full = 0;
if (do_blank) { if (do_blank) {
pvr2_do_blank(); pvr2_do_blank();
do_blank = 0; do_blank = 0;
} }
if (do_vmode_full) {
do_vmode_full = 0;
}
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -991,94 +599,120 @@ static int pvr2_init_cable(void) ...@@ -991,94 +599,120 @@ static int pvr2_init_cable(void)
int __init pvr2fb_init(void) int __init pvr2fb_init(void)
{ {
struct fb_var_screeninfo var;
u_long modememused; u_long modememused;
int err = -EINVAL;
if (!MACH_DREAMCAST) if (!mach_is_dreamcast())
return -ENXIO; return -ENXIO;
fb_info = kmalloc(sizeof(struct fb_info) + sizeof(struct pvr2fb_par) +
sizeof(u32) * 16, GFP_KERNEL);
if (!fb_info) {
printk(KERN_ERR "Failed to allocate memory for fb_info\n");
return -ENOMEM;
}
memset(fb_info, 0, sizeof(fb_info) + sizeof(struct pvr2fb_par) + sizeof(u32) * 16);
currentpar = (struct pvr2fb_par *)(fb_info + 1);
/* Make a guess at the monitor based on the attached cable */ /* Make a guess at the monitor based on the attached cable */
if (pvr2_init_cable() == CT_VGA) { if (pvr2_init_cable() == CT_VGA) {
fb_info.monspecs.hfmin = 30000; fb_info->monspecs.hfmin = 30000;
fb_info.monspecs.hfmax = 70000; fb_info->monspecs.hfmax = 70000;
fb_info.monspecs.vfmin = 60; fb_info->monspecs.vfmin = 60;
fb_info.monspecs.vfmax = 60; fb_info->monspecs.vfmax = 60;
} } else {
else { /* Not VGA, using a TV (taken from acornfb) */ /* Not VGA, using a TV (taken from acornfb) */
fb_info.monspecs.hfmin = 15469; fb_info->monspecs.hfmin = 15469;
fb_info.monspecs.hfmax = 15781; fb_info->monspecs.hfmax = 15781;
fb_info.monspecs.vfmin = 49; fb_info->monspecs.vfmin = 49;
fb_info.monspecs.vfmax = 51; fb_info->monspecs.vfmax = 51;
} }
/* XXX: This needs to pull default video output via BIOS or other means */ /*
* XXX: This needs to pull default video output via BIOS or other means
*/
if (video_output < 0) { if (video_output < 0) {
if (cable_type == CT_VGA) if (cable_type == CT_VGA) {
video_output = VO_VGA; video_output = VO_VGA;
else } else {
video_output = VO_NTSC; video_output = VO_NTSC;
}
} }
strcpy(fb_info.modename, pvr2fb_name); pvr2_fix.smem_start = videomemory;
fb_info.changevar = NULL; pvr2_fix.smem_len = videomemorysize;
fb_info.fbops = &pvr2fb_ops;
fb_info.screen_base = (char *) videomemory; fb_info->screen_base = ioremap_nocache(pvr2_fix.smem_start,
fb_info.disp = &disp; pvr2_fix.smem_len);
fb_info.currcon = -1;
fb_info.switch_con = &pvr2fbcon_switch; if (!fb_info->screen_base) {
fb_info.updatevar = &pvr2fbcon_updatevar; printk("Failed to remap MMIO space\n");
fb_info.flags = FBINFO_FLAG_DEFAULT; err = -ENXIO;
memset(&var, 0, sizeof(var)); goto out_err;
}
memset_io((unsigned long)fb_info->screen_base, 0, pvr2_fix.smem_len);
pvr2_fix.ypanstep = nopan ? 0 : 1;
pvr2_fix.ywrapstep = nowrap ? 0 : 1;
fb_info->fbops = &pvr2fb_ops;
fb_info->fix = pvr2_fix;
fb_info->par = currentpar;
fb_info->pseudo_palette = (void *)(fb_info->par + 1);
fb_info->flags = FBINFO_FLAG_DEFAULT;
if (video_output == VO_VGA) if (video_output == VO_VGA)
defmode = DEFMODE_VGA; defmode = DEFMODE_VGA;
if (!fb_find_mode(&var, &fb_info, mode_option, pvr2_modedb, if (!mode_option)
NUM_TOTAL_MODES, &pvr2_modedb[defmode], 16)) { mode_option = "640x480@60";
return -EINVAL;
}
if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0, if (!fb_find_mode(&fb_info->var, fb_info, mode_option, pvr2_modedb,
"pvr2 VBL handler", &currentpar)) { NUM_TOTAL_MODES, &pvr2_modedb[defmode], 16))
DPRINTK("couldn't register VBL int\n"); fb_info->var = pvr2_var;
return -EBUSY;
}
#ifdef CONFIG_MTRR if (request_irq(HW_EVENT_VSYNC, pvr2fb_interrupt, 0,
if (enable_mtrr) { "pvr2 VBL handler", fb_info)) {
mtrr_handle = mtrr_add(videomemory, videomemorysize, MTRR_TYPE_WRCOMB, 1); err = -EBUSY;
printk("pvr2fb: MTRR turned on\n"); goto out_err;
} }
#endif
pvr2fb_set_var(&var, -1, &fb_info); if (register_framebuffer(fb_info) < 0)
goto reg_failed;
if (register_framebuffer(&fb_info) < 0) modememused = get_line_length(fb_info->var.xres_virtual,
return -EINVAL; fb_info->var.bits_per_pixel);
modememused *= fb_info->var.yres_virtual;
modememused = get_line_length(var.xres_virtual, var.bits_per_pixel);
modememused *= var.yres_virtual;
printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n", printk("fb%d: %s frame buffer device, using %ldk/%ldk of video memory\n",
fb_info.node, fb_info.modename, modememused>>10, fb_info->node, fb_info->fix.id, modememused>>10,
videomemorysize>>10); videomemorysize>>10);
printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n",
fb_info.node, var.xres, var.yres, var.bits_per_pixel, fb_info->node, fb_info->var.xres, fb_info->var.yres,
get_line_length(var.xres, var.bits_per_pixel), fb_info->var.bits_per_pixel,
get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel),
(char *)pvr2_get_param(cables, NULL, cable_type, 3), (char *)pvr2_get_param(cables, NULL, cable_type, 3),
(char *)pvr2_get_param(outputs, NULL, video_output, 3)); (char *)pvr2_get_param(outputs, NULL, video_output, 3));
return 0; return 0;
reg_failed:
free_irq(HW_EVENT_VSYNC, 0);
out_err:
kfree(fb_info);
return err;
} }
static void __exit pvr2fb_exit(void) static void __exit pvr2fb_exit(void)
{ {
#ifdef CONFIG_MTRR unregister_framebuffer(fb_info);
if (enable_mtrr) { free_irq(HW_EVENT_VSYNC, 0);
mtrr_del(mtrr_handle, videomemory, videomemorysize); kfree(fb_info);
printk("pvr2fb: MTRR turned off\n");
}
#endif
unregister_framebuffer(&fb_info);
} }
static int __init pvr2_get_param(const struct pvr2_params *p, const char *s, static int __init pvr2_get_param(const struct pvr2_params *p, const char *s,
...@@ -1102,7 +736,6 @@ static int __init pvr2_get_param(const struct pvr2_params *p, const char *s, ...@@ -1102,7 +736,6 @@ static int __init pvr2_get_param(const struct pvr2_params *p, const char *s,
* Parse command arguments. Supported arguments are: * Parse command arguments. Supported arguments are:
* inverse Use inverse color maps * inverse Use inverse color maps
* nomtrr Disable MTRR usage * nomtrr Disable MTRR usage
* font:<fontname> Specify console font
* cable:composite|rgb|vga Override the video cable type * cable:composite|rgb|vga Override the video cable type
* output:NTSC|PAL|VGA Override the video output format * output:NTSC|PAL|VGA Override the video output format
* *
...@@ -1117,8 +750,6 @@ int __init pvr2fb_setup(char *options) ...@@ -1117,8 +750,6 @@ int __init pvr2fb_setup(char *options)
char cable_arg[80]; char cable_arg[80];
char output_arg[80]; char output_arg[80];
fb_info.fontname[0] = '\0';
if (!options || !*options) if (!options || !*options)
return 0; return 0;
...@@ -1128,23 +759,21 @@ int __init pvr2fb_setup(char *options) ...@@ -1128,23 +759,21 @@ int __init pvr2fb_setup(char *options)
if (!strcmp(this_opt, "inverse")) { if (!strcmp(this_opt, "inverse")) {
pvr2fb_inverse = 1; pvr2fb_inverse = 1;
fb_invert_cmaps(); fb_invert_cmaps();
} else if (!strncmp(this_opt, "font:", 5)) } else if (!strncmp(this_opt, "cable:", 6)) {
strcpy(fb_info.fontname, this_opt + 5);
else if (!strncmp(this_opt, "cable:", 6))
strcpy(cable_arg, this_opt + 6); strcpy(cable_arg, this_opt + 6);
else if (!strncmp(this_opt, "output:", 7)) } else if (!strncmp(this_opt, "output:", 7)) {
strcpy(output_arg, this_opt + 7); strcpy(output_arg, this_opt + 7);
#ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nopan", 5)) {
else if (!strncmp(this_opt, "nomtrr", 6)) nopan = 1;
enable_mtrr = 0; } else if (!strncmp(this_opt, "nowrap", 6)) {
#endif nowrap = 1;
else } else {
mode_option = this_opt; mode_option = this_opt;
}
} }
if (*cable_arg) if (*cable_arg)
cable_type = pvr2_get_param(cables, cable_arg, 0, 3); cable_type = pvr2_get_param(cables, cable_arg, 0, 3);
if (*output_arg) if (*output_arg)
video_output = pvr2_get_param(outputs, output_arg, 0, 3); video_output = pvr2_get_param(outputs, output_arg, 0, 3);
......
...@@ -536,7 +536,8 @@ static ssize_t read_profile(struct file *file, char *buf, ...@@ -536,7 +536,8 @@ static ssize_t read_profile(struct file *file, char *buf,
buf++; p++; count--; read++; buf++; p++; count--; read++;
} }
pnt = (char *)prof_buffer + p - sizeof(unsigned int); pnt = (char *)prof_buffer + p - sizeof(unsigned int);
copy_to_user(buf,(void *)pnt,count); if (copy_to_user(buf,(void *)pnt,count))
return -EFAULT;
read += count; read += count;
*ppos += read; *ppos += read;
return read; return read;
......
...@@ -107,7 +107,7 @@ static inline void x86_do_profile(struct pt_regs * regs) ...@@ -107,7 +107,7 @@ static inline void x86_do_profile(struct pt_regs * regs)
atomic_inc((atomic_t *)&prof_buffer[eip]); atomic_inc((atomic_t *)&prof_buffer[eip]);
} }
#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) #if defined(CONFIG_X86_IO_APIC)
static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i)
{ {
if (IO_APIC_IRQ(i)) if (IO_APIC_IRQ(i))
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define _NAMESPACE_H_ #define _NAMESPACE_H_
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/dcache.h> #include <linux/mount.h>
#include <linux/sched.h> #include <linux/sched.h>
struct namespace { struct namespace {
...@@ -19,9 +19,9 @@ static inline void put_namespace(struct namespace *namespace) ...@@ -19,9 +19,9 @@ static inline void put_namespace(struct namespace *namespace)
{ {
if (atomic_dec_and_test(&namespace->count)) { if (atomic_dec_and_test(&namespace->count)) {
down_write(&namespace->sem); down_write(&namespace->sem);
spin_lock(&dcache_lock); spin_lock(&vfsmount_lock);
umount_tree(namespace->root); umount_tree(namespace->root);
spin_unlock(&dcache_lock); spin_unlock(&vfsmount_lock);
up_write(&namespace->sem); up_write(&namespace->sem);
kfree(namespace); kfree(namespace);
} }
......
...@@ -456,10 +456,10 @@ struct pci_bus { ...@@ -456,10 +456,10 @@ struct pci_bus {
void *sysdata; /* hook for sys-specific extension */ void *sysdata; /* hook for sys-specific extension */
struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */ struct proc_dir_entry *procdir; /* directory entry in /proc/bus/pci */
unsigned char number; /* bus number */ unsigned int number; /* bus number */
unsigned char primary; /* number of primary bridge */ unsigned int primary; /* number of primary bridge */
unsigned char secondary; /* number of secondary bridge */ unsigned int secondary; /* number of secondary bridge */
unsigned char subordinate; /* max number of subordinate buses */ unsigned int subordinate; /* max number of subordinate buses */
char name[48]; char name[48];
......
...@@ -605,6 +605,9 @@ EXPORT_SYMBOL(next_thread); ...@@ -605,6 +605,9 @@ EXPORT_SYMBOL(next_thread);
EXPORT_SYMBOL(__per_cpu_offset); EXPORT_SYMBOL(__per_cpu_offset);
#endif #endif
EXPORT_SYMBOL(set_fs_pwd);
EXPORT_SYMBOL(set_fs_root);
/* debug */ /* debug */
EXPORT_SYMBOL(dump_stack); EXPORT_SYMBOL(dump_stack);
EXPORT_SYMBOL(ptrace_notify); EXPORT_SYMBOL(ptrace_notify);
......
...@@ -668,7 +668,7 @@ static int wanrouter_device_stat(struct wan_device *wandev, ...@@ -668,7 +668,7 @@ static int wanrouter_device_stat(struct wan_device *wandev,
static int wanrouter_device_new_if(struct wan_device *wandev, static int wanrouter_device_new_if(struct wan_device *wandev,
wanif_conf_t *u_conf) wanif_conf_t *u_conf)
{ {
wanif_conf_t conf; wanif_conf_t *cnf;
struct net_device *dev = NULL; struct net_device *dev = NULL;
#ifdef CONFIG_WANPIPE_MULTPPP #ifdef CONFIG_WANPIPE_MULTPPP
struct ppp_device *pppdev=NULL; struct ppp_device *pppdev=NULL;
...@@ -678,38 +678,47 @@ static int wanrouter_device_new_if(struct wan_device *wandev, ...@@ -678,38 +678,47 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL)) if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL))
return -ENODEV; return -ENODEV;
if (copy_from_user(&conf, u_conf, sizeof(wanif_conf_t))) cnf = kmalloc(sizeof(wanif_conf_t), GFP_KERNEL);
return -EFAULT; if (!cnf)
return -ENOBUFS;
if (conf.magic != ROUTER_MAGIC) err = -EFAULT;
return -EINVAL; if (copy_from_user(cnf, u_conf, sizeof(wanif_conf_t)))
goto out;
err = -EINVAL;
if (cnf->magic != ROUTER_MAGIC)
goto out;
if (conf.config_id == WANCONFIG_MPPP) { if (cnf->config_id == WANCONFIG_MPPP) {
#ifdef CONFIG_WANPIPE_MULTPPP #ifdef CONFIG_WANPIPE_MULTPPP
pppdev = kmalloc(sizeof(struct ppp_device), GFP_KERNEL); pppdev = kmalloc(sizeof(struct ppp_device), GFP_KERNEL);
err = -ENOBUFS;
if (pppdev == NULL) if (pppdev == NULL)
return -ENOBUFS; goto out;
memset(pppdev, 0, sizeof(struct ppp_device)); memset(pppdev, 0, sizeof(struct ppp_device));
pppdev->dev = kmalloc(sizeof(struct net_device), GFP_KERNEL); pppdev->dev = kmalloc(sizeof(struct net_device), GFP_KERNEL);
if (pppdev->dev == NULL) { if (pppdev->dev == NULL) {
kfree(pppdev); kfree(pppdev);
return -ENOBUFS; err = -ENOBUFS;
goto out;
} }
memset(pppdev->dev, 0, sizeof(struct net_device)); memset(pppdev->dev, 0, sizeof(struct net_device));
err = wandev->new_if(wandev, err = wandev->new_if(wandev, (struct net_device *)pppdev, cnf);
(struct net_device *)pppdev, &conf);
dev = pppdev->dev; dev = pppdev->dev;
#else #else
printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n", printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n",
wandev->name); wandev->name);
return -EPROTONOSUPPORT; err = -EPROTONOSUPPORT;
goto out;
#endif #endif
} else { } else {
dev = kmalloc(sizeof(struct net_device), GFP_KERNEL); dev = kmalloc(sizeof(struct net_device), GFP_KERNEL);
err = -ENOBUFS;
if (dev == NULL) if (dev == NULL)
return -ENOBUFS; goto out;
memset(dev, 0, sizeof(struct net_device)); memset(dev, 0, sizeof(struct net_device));
err = wandev->new_if(wandev, dev, &conf); err = wandev->new_if(wandev, dev, cnf);
} }
if (!err) { if (!err) {
...@@ -748,7 +757,8 @@ static int wanrouter_device_new_if(struct wan_device *wandev, ...@@ -748,7 +757,8 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
++wandev->ndev; ++wandev->ndev;
unlock_adapter_irq(&wandev->lock, &smp_flags); unlock_adapter_irq(&wandev->lock, &smp_flags);
return 0; /* done !!! */ err = 0; /* done !!! */
goto out;
} }
} }
if (wandev->del_if) if (wandev->del_if)
...@@ -761,18 +771,19 @@ static int wanrouter_device_new_if(struct wan_device *wandev, ...@@ -761,18 +771,19 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
dev->priv = NULL; dev->priv = NULL;
} }
#ifdef CONFIG_WANPIPE_MULTPPP #ifdef CONFIG_WANPIPE_MULTPPP
if (conf.config_id == WANCONFIG_MPPP) if (cnf->config_id == WANCONFIG_MPPP)
kfree(pppdev); kfree(pppdev);
else else
kfree(dev); kfree(dev);
#else #else
/* Sync PPP is disabled */ /* Sync PPP is disabled */
if (conf.config_id != WANCONFIG_MPPP) if (cnf->config_id != WANCONFIG_MPPP)
kfree(dev); kfree(dev);
#endif #endif
out:
kfree(cnf);
return err; return err;
} }
......
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