Commit 15f8e733 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'pcmcia-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux

Pull pcmcia updates from Dominik Brodowski:
 "This is a series co-developed by Simon Geis and Lukas Panzer to clean
  up the i82092 PCMCIA device driver"

* 'pcmcia-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux:
  PCMCIA/i82092: remove #if 0 block
  PCMCIA/i82092: delete enter/leave macro
  PCMCIA/i82092: include <linux/io.h> instead of <asm/io.h>
  PCMCIA/i82092: shorten the lines with over 80 characters
  PCMCIA/i82092: move assignment out of if condition
  PCMCIA/i82092: change code indentation
  PCMCIA/i82092: insert blank line after declarations
  PCMCIA/i82092: remove braces around single statement blocks
  PCMCIA/i82092: add/remove spaces to improve readability
  PCMCIA/i82092: use dev_<level> instead of printk
parents 94f2630b 71705c61
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <pcmcia/ss.h> #include <pcmcia/ss.h>
#include <asm/io.h> #include <linux/io.h>
#include "i82092aa.h" #include "i82092aa.h"
#include "i82365.h" #include "i82365.h"
...@@ -53,10 +53,12 @@ static struct pccard_operations i82092aa_operations = { ...@@ -53,10 +53,12 @@ static struct pccard_operations i82092aa_operations = {
struct socket_info { struct socket_info {
int number; int number;
int card_state; /* 0 = no socket, int card_state;
1 = empty socket, /* 0 = no socket,
2 = card but not initialized, * 1 = empty socket,
3 = operational card */ * 2 = card but not initialized,
* 3 = operational card
*/
unsigned int io_base; /* base io address of the socket */ unsigned int io_base; /* base io address of the socket */
struct pcmcia_socket socket; struct pcmcia_socket socket;
...@@ -68,18 +70,20 @@ static struct socket_info sockets[MAX_SOCKETS]; ...@@ -68,18 +70,20 @@ static struct socket_info sockets[MAX_SOCKETS];
static int socket_count; /* shortcut */ static int socket_count; /* shortcut */
static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) static int i82092aa_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id)
{ {
unsigned char configbyte; unsigned char configbyte;
int i, ret; int i, ret;
enter("i82092aa_pci_probe"); ret = pci_enable_device(dev);
if (ret)
if ((ret = pci_enable_device(dev)))
return ret; return ret;
pci_read_config_byte(dev, 0x40, &configbyte); /* PCI Configuration Control */ /* PCI Configuration Control */
switch(configbyte&6) { pci_read_config_byte(dev, 0x40, &configbyte);
switch (configbyte&6) {
case 0: case 0:
socket_count = 2; socket_count = 2;
break; break;
...@@ -92,18 +96,20 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i ...@@ -92,18 +96,20 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
break; break;
default: default:
printk(KERN_ERR "i82092aa: Oops, you did something we didn't think of.\n"); dev_err(&dev->dev,
"Oops, you did something we didn't think of.\n");
ret = -EIO; ret = -EIO;
goto err_out_disable; goto err_out_disable;
} }
printk(KERN_INFO "i82092aa: configured as a %d socket device.\n", socket_count); dev_info(&dev->dev, "configured as a %d socket device.\n",
socket_count);
if (!request_region(pci_resource_start(dev, 0), 2, "i82092aa")) { if (!request_region(pci_resource_start(dev, 0), 2, "i82092aa")) {
ret = -EBUSY; ret = -EBUSY;
goto err_out_disable; goto err_out_disable;
} }
for (i = 0;i<socket_count;i++) { for (i = 0; i < socket_count; i++) {
sockets[i].card_state = 1; /* 1 = present but empty */ sockets[i].card_state = 1; /* 1 = present but empty */
sockets[i].io_base = pci_resource_start(dev, 0); sockets[i].io_base = pci_resource_start(dev, 0);
sockets[i].socket.features |= SS_CAP_PCCARD; sockets[i].socket.features |= SS_CAP_PCCARD;
...@@ -117,42 +123,46 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i ...@@ -117,42 +123,46 @@ static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
if (card_present(i)) { if (card_present(i)) {
sockets[i].card_state = 3; sockets[i].card_state = 3;
dev_dbg(&dev->dev, "i82092aa: slot %i is occupied\n", i); dev_dbg(&dev->dev, "slot %i is occupied\n", i);
} else { } else {
dev_dbg(&dev->dev, "i82092aa: slot %i is vacant\n", i); dev_dbg(&dev->dev, "slot %i is vacant\n", i);
} }
} }
/* Now, specifiy that all interrupts are to be done as PCI interrupts */ /* Now, specifiy that all interrupts are to be done as PCI interrupts
configbyte = 0xFF; /* bitmask, one bit per event, 1 = PCI interrupt, 0 = ISA interrupt */ * bitmask, one bit per event, 1 = PCI interrupt, 0 = ISA interrupt
pci_write_config_byte(dev, 0x50, configbyte); /* PCI Interrupt Routing Register */ */
configbyte = 0xFF;
/* PCI Interrupt Routing Register */
pci_write_config_byte(dev, 0x50, configbyte);
/* Register the interrupt handler */ /* Register the interrupt handler */
dev_dbg(&dev->dev, "Requesting interrupt %i\n", dev->irq); dev_dbg(&dev->dev, "Requesting interrupt %i\n", dev->irq);
if ((ret = request_irq(dev->irq, i82092aa_interrupt, IRQF_SHARED, "i82092aa", i82092aa_interrupt))) { ret = request_irq(dev->irq, i82092aa_interrupt, IRQF_SHARED,
printk(KERN_ERR "i82092aa: Failed to register IRQ %d, aborting\n", dev->irq); "i82092aa", i82092aa_interrupt);
if (ret) {
dev_err(&dev->dev, "Failed to register IRQ %d, aborting\n",
dev->irq);
goto err_out_free_res; goto err_out_free_res;
} }
for (i = 0; i<socket_count; i++) { for (i = 0; i < socket_count; i++) {
sockets[i].socket.dev.parent = &dev->dev; sockets[i].socket.dev.parent = &dev->dev;
sockets[i].socket.ops = &i82092aa_operations; sockets[i].socket.ops = &i82092aa_operations;
sockets[i].socket.resource_ops = &pccard_nonstatic_ops; sockets[i].socket.resource_ops = &pccard_nonstatic_ops;
ret = pcmcia_register_socket(&sockets[i].socket); ret = pcmcia_register_socket(&sockets[i].socket);
if (ret) { if (ret)
goto err_out_free_sockets; goto err_out_free_sockets;
} }
}
leave("i82092aa_pci_probe");
return 0; return 0;
err_out_free_sockets: err_out_free_sockets:
if (i) { if (i) {
for (i--;i>=0;i--) { for (i--; i >= 0; i--)
pcmcia_unregister_socket(&sockets[i].socket); pcmcia_unregister_socket(&sockets[i].socket);
} }
}
free_irq(dev->irq, i82092aa_interrupt); free_irq(dev->irq, i82092aa_interrupt);
err_out_free_res: err_out_free_res:
release_region(pci_resource_start(dev, 0), 2); release_region(pci_resource_start(dev, 0), 2);
...@@ -165,14 +175,10 @@ static void i82092aa_pci_remove(struct pci_dev *dev) ...@@ -165,14 +175,10 @@ static void i82092aa_pci_remove(struct pci_dev *dev)
{ {
int i; int i;
enter("i82092aa_pci_remove");
free_irq(dev->irq, i82092aa_interrupt); free_irq(dev->irq, i82092aa_interrupt);
for (i = 0; i < socket_count; i++) for (i = 0; i < socket_count; i++)
pcmcia_unregister_socket(&sockets[i].socket); pcmcia_unregister_socket(&sockets[i].socket);
leave("i82092aa_pci_remove");
} }
static DEFINE_SPINLOCK(port_lock); static DEFINE_SPINLOCK(port_lock);
...@@ -184,44 +190,27 @@ static unsigned char indirect_read(int socket, unsigned short reg) ...@@ -184,44 +190,27 @@ static unsigned char indirect_read(int socket, unsigned short reg)
unsigned short int port; unsigned short int port;
unsigned char val; unsigned char val;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&port_lock,flags);
spin_lock_irqsave(&port_lock, flags);
reg += socket * 0x40; reg += socket * 0x40;
port = sockets[socket].io_base; port = sockets[socket].io_base;
outb(reg,port); outb(reg, port);
val = inb(port+1); val = inb(port+1);
spin_unlock_irqrestore(&port_lock,flags); spin_unlock_irqrestore(&port_lock, flags);
return val; return val;
} }
#if 0
static unsigned short indirect_read16(int socket, unsigned short reg)
{
unsigned short int port;
unsigned short tmp;
unsigned long flags;
spin_lock_irqsave(&port_lock,flags);
reg = reg + socket * 0x40;
port = sockets[socket].io_base;
outb(reg,port);
tmp = inb(port+1);
reg++;
outb(reg,port);
tmp = tmp | (inb(port+1)<<8);
spin_unlock_irqrestore(&port_lock,flags);
return tmp;
}
#endif
static void indirect_write(int socket, unsigned short reg, unsigned char value) static void indirect_write(int socket, unsigned short reg, unsigned char value)
{ {
unsigned short int port; unsigned short int port;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&port_lock,flags);
spin_lock_irqsave(&port_lock, flags);
reg = reg + socket * 0x40; reg = reg + socket * 0x40;
port = sockets[socket].io_base; port = sockets[socket].io_base;
outb(reg,port); outb(reg, port);
outb(value,port+1); outb(value, port+1);
spin_unlock_irqrestore(&port_lock,flags); spin_unlock_irqrestore(&port_lock, flags);
} }
static void indirect_setbit(int socket, unsigned short reg, unsigned char mask) static void indirect_setbit(int socket, unsigned short reg, unsigned char mask)
...@@ -229,53 +218,58 @@ static void indirect_setbit(int socket, unsigned short reg, unsigned char mask) ...@@ -229,53 +218,58 @@ static void indirect_setbit(int socket, unsigned short reg, unsigned char mask)
unsigned short int port; unsigned short int port;
unsigned char val; unsigned char val;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&port_lock,flags);
spin_lock_irqsave(&port_lock, flags);
reg = reg + socket * 0x40; reg = reg + socket * 0x40;
port = sockets[socket].io_base; port = sockets[socket].io_base;
outb(reg,port); outb(reg, port);
val = inb(port+1); val = inb(port+1);
val |= mask; val |= mask;
outb(reg,port); outb(reg, port);
outb(val,port+1); outb(val, port+1);
spin_unlock_irqrestore(&port_lock,flags); spin_unlock_irqrestore(&port_lock, flags);
} }
static void indirect_resetbit(int socket, unsigned short reg, unsigned char mask) static void indirect_resetbit(int socket,
unsigned short reg, unsigned char mask)
{ {
unsigned short int port; unsigned short int port;
unsigned char val; unsigned char val;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&port_lock,flags);
spin_lock_irqsave(&port_lock, flags);
reg = reg + socket * 0x40; reg = reg + socket * 0x40;
port = sockets[socket].io_base; port = sockets[socket].io_base;
outb(reg,port); outb(reg, port);
val = inb(port+1); val = inb(port+1);
val &= ~mask; val &= ~mask;
outb(reg,port); outb(reg, port);
outb(val,port+1); outb(val, port+1);
spin_unlock_irqrestore(&port_lock,flags); spin_unlock_irqrestore(&port_lock, flags);
} }
static void indirect_write16(int socket, unsigned short reg, unsigned short value) static void indirect_write16(int socket,
unsigned short reg, unsigned short value)
{ {
unsigned short int port; unsigned short int port;
unsigned char val; unsigned char val;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&port_lock,flags);
spin_lock_irqsave(&port_lock, flags);
reg = reg + socket * 0x40; reg = reg + socket * 0x40;
port = sockets[socket].io_base; port = sockets[socket].io_base;
outb(reg,port); outb(reg, port);
val = value & 255; val = value & 255;
outb(val,port+1); outb(val, port+1);
reg++; reg++;
outb(reg,port); outb(reg, port);
val = value>>8; val = value>>8;
outb(val,port+1); outb(val, port+1);
spin_unlock_irqrestore(&port_lock,flags); spin_unlock_irqrestore(&port_lock, flags);
} }
/* simple helper functions */ /* simple helper functions */
...@@ -284,7 +278,7 @@ static int cycle_time = 120; ...@@ -284,7 +278,7 @@ static int cycle_time = 120;
static int to_cycles(int ns) static int to_cycles(int ns)
{ {
if (cycle_time!=0) if (cycle_time != 0)
return ns/cycle_time; return ns/cycle_time;
else else
return 0; return 0;
...@@ -299,58 +293,61 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev) ...@@ -299,58 +293,61 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev)
int loopcount = 0; int loopcount = 0;
int handled = 0; int handled = 0;
unsigned int events, active=0; unsigned int events, active = 0;
/* enter("i82092aa_interrupt");*/
while (1) { while (1) {
loopcount++; loopcount++;
if (loopcount>20) { if (loopcount > 20) {
printk(KERN_ERR "i82092aa: infinite eventloop in interrupt \n"); pr_err("i82092aa: infinite eventloop in interrupt\n");
break; break;
} }
active = 0; active = 0;
for (i=0;i<socket_count;i++) { for (i = 0; i < socket_count; i++) {
int csc; int csc;
if (sockets[i].card_state==0) /* Inactive socket, should not happen */
/* Inactive socket, should not happen */
if (sockets[i].card_state == 0)
continue; continue;
csc = indirect_read(i,I365_CSC); /* card status change register */ /* card status change register */
csc = indirect_read(i, I365_CSC);
if (csc==0) /* no events on this socket */ if (csc == 0) /* no events on this socket */
continue; continue;
handled = 1; handled = 1;
events = 0; events = 0;
if (csc & I365_CSC_DETECT) { if (csc & I365_CSC_DETECT) {
events |= SS_DETECT; events |= SS_DETECT;
printk("Card detected in socket %i!\n",i); dev_info(&sockets[i].dev->dev,
"Card detected in socket %i!\n", i);
} }
if (indirect_read(i,I365_INTCTL) & I365_PC_IOCARD) { if (indirect_read(i, I365_INTCTL) & I365_PC_IOCARD) {
/* For IO/CARDS, bit 0 means "read the card" */ /* For IO/CARDS, bit 0 means "read the card" */
events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0; if (csc & I365_CSC_STSCHG)
events |= SS_STSCHG;
} else { } else {
/* Check for battery/ready events */ /* Check for battery/ready events */
events |= (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0; if (csc & I365_CSC_BVD1)
events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0; events |= SS_BATDEAD;
events |= (csc & I365_CSC_READY) ? SS_READY : 0; if (csc & I365_CSC_BVD2)
events |= SS_BATWARN;
if (csc & I365_CSC_READY)
events |= SS_READY;
} }
if (events) { if (events)
pcmcia_parse_events(&sockets[i].socket, events); pcmcia_parse_events(&sockets[i].socket, events);
}
active |= events; active |= events;
} }
if (active==0) /* no more events to handle */ if (active == 0) /* no more events to handle */
break; break;
} }
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
/* leave("i82092aa_interrupt");*/
} }
...@@ -360,39 +357,29 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev) ...@@ -360,39 +357,29 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev)
static int card_present(int socketno) static int card_present(int socketno)
{ {
unsigned int val; unsigned int val;
enter("card_present");
if ((socketno<0) || (socketno >= MAX_SOCKETS)) if ((socketno < 0) || (socketno >= MAX_SOCKETS))
return 0; return 0;
if (sockets[socketno].io_base == 0) if (sockets[socketno].io_base == 0)
return 0; return 0;
val = indirect_read(socketno, 1); /* Interface status register */ val = indirect_read(socketno, 1); /* Interface status register */
if ((val&12)==12) { if ((val&12) == 12)
leave("card_present 1");
return 1; return 1;
}
leave("card_present 0");
return 0; return 0;
} }
static void set_bridge_state(int sock) static void set_bridge_state(int sock)
{ {
enter("set_bridge_state"); indirect_write(sock, I365_GBLCTL, 0x00);
indirect_write(sock, I365_GBLCTL,0x00); indirect_write(sock, I365_GENCTL, 0x00);
indirect_write(sock, I365_GENCTL,0x00);
indirect_setbit(sock, I365_INTCTL,0x08); indirect_setbit(sock, I365_INTCTL, 0x08);
leave("set_bridge_state");
} }
static int i82092aa_init(struct pcmcia_socket *sock) static int i82092aa_init(struct pcmcia_socket *sock)
{ {
int i; int i;
...@@ -400,8 +387,6 @@ static int i82092aa_init(struct pcmcia_socket *sock) ...@@ -400,8 +387,6 @@ static int i82092aa_init(struct pcmcia_socket *sock)
pccard_io_map io = { 0, 0, 0, 0, 1 }; pccard_io_map io = { 0, 0, 0, 0, 1 };
pccard_mem_map mem = { .res = &res, }; pccard_mem_map mem = { .res = &res, };
enter("i82092aa_init");
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
io.map = i; io.map = i;
i82092aa_set_io_map(sock, &io); i82092aa_set_io_map(sock, &io);
...@@ -411,23 +396,22 @@ static int i82092aa_init(struct pcmcia_socket *sock) ...@@ -411,23 +396,22 @@ static int i82092aa_init(struct pcmcia_socket *sock)
i82092aa_set_mem_map(sock, &mem); i82092aa_set_mem_map(sock, &mem);
} }
leave("i82092aa_init");
return 0; return 0;
} }
static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value) static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
{ {
unsigned int sock = container_of(socket, struct socket_info, socket)->number; unsigned int sock = container_of(socket,
struct socket_info, socket)->number;
unsigned int status; unsigned int status;
enter("i82092aa_get_status"); /* Interface Status Register */
status = indirect_read(sock, I365_STATUS);
status = indirect_read(sock,I365_STATUS); /* Interface Status Register */
*value = 0; *value = 0;
if ((status & I365_CS_DETECT) == I365_CS_DETECT) { if ((status & I365_CS_DETECT) == I365_CS_DETECT)
*value |= SS_DETECT; *value |= SS_DETECT;
}
/* IO cards have a different meaning of bits 0,1 */ /* IO cards have a different meaning of bits 0,1 */
/* Also notice the inverse-logic on the bits */ /* Also notice the inverse-logic on the bits */
...@@ -451,18 +435,18 @@ static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value) ...@@ -451,18 +435,18 @@ static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
if (status & I365_CS_POWERON) if (status & I365_CS_POWERON)
(*value) |= SS_POWERON; /* power is applied to the card */ (*value) |= SS_POWERON; /* power is applied to the card */
leave("i82092aa_get_status");
return 0; return 0;
} }
static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state) static int i82092aa_set_socket(struct pcmcia_socket *socket,
socket_state_t *state)
{ {
unsigned int sock = container_of(socket, struct socket_info, socket)->number; struct socket_info *sock_info = container_of(socket, struct socket_info,
socket);
unsigned int sock = sock_info->number;
unsigned char reg; unsigned char reg;
enter("i82092aa_set_socket");
/* First, set the global controller options */ /* First, set the global controller options */
set_bridge_state(sock); set_bridge_state(sock);
...@@ -470,23 +454,26 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta ...@@ -470,23 +454,26 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
/* Values for the IGENC register */ /* Values for the IGENC register */
reg = 0; reg = 0;
if (!(state->flags & SS_RESET)) /* The reset bit has "inverse" logic */
/* The reset bit has "inverse" logic */
if (!(state->flags & SS_RESET))
reg = reg | I365_PC_RESET; reg = reg | I365_PC_RESET;
if (state->flags & SS_IOCARD) if (state->flags & SS_IOCARD)
reg = reg | I365_PC_IOCARD; reg = reg | I365_PC_IOCARD;
indirect_write(sock,I365_INTCTL,reg); /* IGENC, Interrupt and General Control Register */ /* IGENC, Interrupt and General Control Register */
indirect_write(sock, I365_INTCTL, reg);
/* Power registers */ /* Power registers */
reg = I365_PWR_NORESET; /* default: disable resetdrv on resume */ reg = I365_PWR_NORESET; /* default: disable resetdrv on resume */
if (state->flags & SS_PWR_AUTO) { if (state->flags & SS_PWR_AUTO) {
printk("Auto power\n"); dev_info(&sock_info->dev->dev, "Auto power\n");
reg |= I365_PWR_AUTO; /* automatic power mngmnt */ reg |= I365_PWR_AUTO; /* automatic power mngmnt */
} }
if (state->flags & SS_OUTPUT_ENA) { if (state->flags & SS_OUTPUT_ENA) {
printk("Power Enabled \n"); dev_info(&sock_info->dev->dev, "Power Enabled\n");
reg |= I365_PWR_OUT; /* enable power */ reg |= I365_PWR_OUT; /* enable power */
} }
...@@ -494,43 +481,47 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta ...@@ -494,43 +481,47 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
case 0: case 0:
break; break;
case 50: case 50:
printk("setting voltage to Vcc to 5V on socket %i\n",sock); dev_info(&sock_info->dev->dev,
"setting voltage to Vcc to 5V on socket %i\n",
sock);
reg |= I365_VCC_5V; reg |= I365_VCC_5V;
break; break;
default: default:
printk("i82092aa: i82092aa_set_socket called with invalid VCC power value: %i ", state->Vcc); dev_err(&sock_info->dev->dev,
leave("i82092aa_set_socket"); "%s called with invalid VCC power value: %i",
__func__, state->Vcc);
return -EINVAL; return -EINVAL;
} }
switch (state->Vpp) { switch (state->Vpp) {
case 0: case 0:
printk("not setting Vpp on socket %i\n",sock); dev_info(&sock_info->dev->dev,
"not setting Vpp on socket %i\n", sock);
break; break;
case 50: case 50:
printk("setting Vpp to 5.0 for socket %i\n",sock); dev_info(&sock_info->dev->dev,
"setting Vpp to 5.0 for socket %i\n", sock);
reg |= I365_VPP1_5V | I365_VPP2_5V; reg |= I365_VPP1_5V | I365_VPP2_5V;
break; break;
case 120: case 120:
printk("setting Vpp to 12.0\n"); dev_info(&sock_info->dev->dev, "setting Vpp to 12.0\n");
reg |= I365_VPP1_12V | I365_VPP2_12V; reg |= I365_VPP1_12V | I365_VPP2_12V;
break; break;
default: default:
printk("i82092aa: i82092aa_set_socket called with invalid VPP power value: %i ", state->Vcc); dev_err(&sock_info->dev->dev,
leave("i82092aa_set_socket"); "%s called with invalid VPP power value: %i",
__func__, state->Vcc);
return -EINVAL; return -EINVAL;
} }
if (reg != indirect_read(sock,I365_POWER)) /* only write if changed */ if (reg != indirect_read(sock, I365_POWER)) /* only write if changed */
indirect_write(sock,I365_POWER,reg); indirect_write(sock, I365_POWER, reg);
/* Enable specific interrupt events */ /* Enable specific interrupt events */
reg = 0x00; reg = 0x00;
if (state->csc_mask & SS_DETECT) { if (state->csc_mask & SS_DETECT)
reg |= I365_CSC_DETECT; reg |= I365_CSC_DETECT;
}
if (state->flags & SS_IOCARD) { if (state->flags & SS_IOCARD) {
if (state->csc_mask & SS_STSCHG) if (state->csc_mask & SS_STSCHG)
reg |= I365_CSC_STSCHG; reg |= I365_CSC_STSCHG;
...@@ -544,83 +535,76 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta ...@@ -544,83 +535,76 @@ static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *sta
} }
/* now write the value and clear the (probably bogus) pending stuff by doing a dummy read*/ /* now write the value and clear the (probably bogus) pending stuff
* by doing a dummy read
*/
indirect_write(sock,I365_CSCINT,reg); indirect_write(sock, I365_CSCINT, reg);
(void)indirect_read(sock,I365_CSC); (void)indirect_read(sock, I365_CSC);
leave("i82092aa_set_socket");
return 0; return 0;
} }
static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_map *io) static int i82092aa_set_io_map(struct pcmcia_socket *socket,
struct pccard_io_map *io)
{ {
unsigned int sock = container_of(socket, struct socket_info, socket)->number; struct socket_info *sock_info = container_of(socket, struct socket_info,
socket);
unsigned int sock = sock_info->number;
unsigned char map, ioctl; unsigned char map, ioctl;
enter("i82092aa_set_io_map");
map = io->map; map = io->map;
/* Check error conditions */ /* Check error conditions */
if (map > 1) { if (map > 1)
leave("i82092aa_set_io_map with invalid map");
return -EINVAL; return -EINVAL;
}
if ((io->start > 0xffff) || (io->stop > 0xffff) || (io->stop < io->start)){ if ((io->start > 0xffff) || (io->stop > 0xffff)
leave("i82092aa_set_io_map with invalid io"); || (io->stop < io->start))
return -EINVAL; return -EINVAL;
}
/* Turn off the window before changing anything */ /* Turn off the window before changing anything */
if (indirect_read(sock, I365_ADDRWIN) & I365_ENA_IO(map)) if (indirect_read(sock, I365_ADDRWIN) & I365_ENA_IO(map))
indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_IO(map)); indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_IO(map));
/* printk("set_io_map: Setting range to %x - %x \n",io->start,io->stop); */
/* write the new values */ /* write the new values */
indirect_write16(sock,I365_IO(map)+I365_W_START,io->start); indirect_write16(sock, I365_IO(map)+I365_W_START, io->start);
indirect_write16(sock,I365_IO(map)+I365_W_STOP,io->stop); indirect_write16(sock, I365_IO(map)+I365_W_STOP, io->stop);
ioctl = indirect_read(sock,I365_IOCTL) & ~I365_IOCTL_MASK(map); ioctl = indirect_read(sock, I365_IOCTL) & ~I365_IOCTL_MASK(map);
if (io->flags & (MAP_16BIT|MAP_AUTOSZ)) if (io->flags & (MAP_16BIT|MAP_AUTOSZ))
ioctl |= I365_IOCTL_16BIT(map); ioctl |= I365_IOCTL_16BIT(map);
indirect_write(sock,I365_IOCTL,ioctl); indirect_write(sock, I365_IOCTL, ioctl);
/* Turn the window back on if needed */ /* Turn the window back on if needed */
if (io->flags & MAP_ACTIVE) if (io->flags & MAP_ACTIVE)
indirect_setbit(sock,I365_ADDRWIN,I365_ENA_IO(map)); indirect_setbit(sock, I365_ADDRWIN, I365_ENA_IO(map));
leave("i82092aa_set_io_map");
return 0; return 0;
} }
static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_map *mem) static int i82092aa_set_mem_map(struct pcmcia_socket *socket,
struct pccard_mem_map *mem)
{ {
struct socket_info *sock_info = container_of(socket, struct socket_info, socket); struct socket_info *sock_info = container_of(socket, struct socket_info,
socket);
unsigned int sock = sock_info->number; unsigned int sock = sock_info->number;
struct pci_bus_region region; struct pci_bus_region region;
unsigned short base, i; unsigned short base, i;
unsigned char map; unsigned char map;
enter("i82092aa_set_mem_map");
pcibios_resource_to_bus(sock_info->dev->bus, &region, mem->res); pcibios_resource_to_bus(sock_info->dev->bus, &region, mem->res);
map = mem->map; map = mem->map;
if (map > 4) { if (map > 4)
leave("i82092aa_set_mem_map: invalid map");
return -EINVAL; return -EINVAL;
}
if ( (mem->card_start > 0x3ffffff) || (region.start > region.end) || if ((mem->card_start > 0x3ffffff) || (region.start > region.end) ||
(mem->speed > 1000) ) { (mem->speed > 1000)) {
leave("i82092aa_set_mem_map: invalid address / speed"); dev_err(&sock_info->dev->dev,
printk("invalid mem map for socket %i: %llx to %llx with a " "invalid mem map for socket %i: %llx to %llx with a start of %x\n",
"start of %x\n",
sock, sock,
(unsigned long long)region.start, (unsigned long long)region.start,
(unsigned long long)region.end, (unsigned long long)region.end,
...@@ -632,9 +616,6 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_ ...@@ -632,9 +616,6 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
if (indirect_read(sock, I365_ADDRWIN) & I365_ENA_MEM(map)) if (indirect_read(sock, I365_ADDRWIN) & I365_ENA_MEM(map))
indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_MEM(map)); indirect_resetbit(sock, I365_ADDRWIN, I365_ENA_MEM(map));
/* printk("set_mem_map: Setting map %i range to %x - %x on socket %i, speed is %i, active = %i \n",map, region.start,region.end,sock,mem->speed,mem->flags & MAP_ACTIVE); */
/* write the start address */ /* write the start address */
base = I365_MEM(map); base = I365_MEM(map);
i = (region.start >> 12) & 0x0fff; i = (region.start >> 12) & 0x0fff;
...@@ -642,11 +623,11 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_ ...@@ -642,11 +623,11 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
i |= I365_MEM_16BIT; i |= I365_MEM_16BIT;
if (mem->flags & MAP_0WS) if (mem->flags & MAP_0WS)
i |= I365_MEM_0WS; i |= I365_MEM_0WS;
indirect_write16(sock,base+I365_W_START,i); indirect_write16(sock, base+I365_W_START, i);
/* write the stop address */ /* write the stop address */
i= (region.end >> 12) & 0x0fff; i = (region.end >> 12) & 0x0fff;
switch (to_cycles(mem->speed)) { switch (to_cycles(mem->speed)) {
case 0: case 0:
break; break;
...@@ -661,26 +642,21 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_ ...@@ -661,26 +642,21 @@ static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_
break; break;
} }
indirect_write16(sock,base+I365_W_STOP,i); indirect_write16(sock, base+I365_W_STOP, i);
/* card start */ /* card start */
i = ((mem->card_start - region.start) >> 12) & 0x3fff; i = ((mem->card_start - region.start) >> 12) & 0x3fff;
if (mem->flags & MAP_WRPROT) if (mem->flags & MAP_WRPROT)
i |= I365_MEM_WRPROT; i |= I365_MEM_WRPROT;
if (mem->flags & MAP_ATTRIB) { if (mem->flags & MAP_ATTRIB)
/* printk("requesting attribute memory for socket %i\n",sock);*/
i |= I365_MEM_REG; i |= I365_MEM_REG;
} else { indirect_write16(sock, base+I365_W_OFF, i);
/* printk("requesting normal memory for socket %i\n",sock);*/
}
indirect_write16(sock,base+I365_W_OFF,i);
/* Enable the window if necessary */ /* Enable the window if necessary */
if (mem->flags & MAP_ACTIVE) if (mem->flags & MAP_ACTIVE)
indirect_setbit(sock, I365_ADDRWIN, I365_ENA_MEM(map)); indirect_setbit(sock, I365_ADDRWIN, I365_ENA_MEM(map));
leave("i82092aa_set_mem_map");
return 0; return 0;
} }
...@@ -691,11 +667,9 @@ static int i82092aa_module_init(void) ...@@ -691,11 +667,9 @@ static int i82092aa_module_init(void)
static void i82092aa_module_exit(void) static void i82092aa_module_exit(void)
{ {
enter("i82092aa_module_exit");
pci_unregister_driver(&i82092aa_pci_driver); pci_unregister_driver(&i82092aa_pci_driver);
if (sockets[0].io_base>0) if (sockets[0].io_base > 0)
release_region(sockets[0].io_base, 2); release_region(sockets[0].io_base, 2);
leave("i82092aa_module_exit");
} }
module_init(i82092aa_module_init); module_init(i82092aa_module_init);
......
...@@ -4,17 +4,6 @@ ...@@ -4,17 +4,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
/* Debuging defines */
#ifdef NOTRACE
#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
#define leave(x) printk("Leave: %s, %s line %i\n",x,__FILE__,__LINE__)
#else
#define enter(x) do {} while (0)
#define leave(x) do {} while (0)
#endif
/* prototypes */ /* prototypes */
static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *id); static int i82092aa_pci_probe(struct pci_dev *dev, const struct pci_device_id *id);
......
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