Commit cdf0a7d1 authored by Jiri Slaby's avatar Jiri Slaby Committed by David Woodhouse

[MTD] pmc551 whitespace cleanup

Spaces were used for indent, there was more than 80 columns per line. Get
rid of that stuff.
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent e417fcfb
......@@ -105,7 +105,7 @@
static struct mtd_info *pmc551list;
static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr)
static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
{
struct mypriv *priv = mtd->priv;
u32 soff_hi, soff_lo; /* start address offset hi/lo */
......@@ -115,15 +115,17 @@ static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr)
size_t retlen;
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_erase(pos:%ld, len:%ld)\n", (long)instr->addr, (long)instr->len);
printk(KERN_DEBUG "pmc551_erase(pos:%ld, len:%ld)\n", (long)instr->addr,
(long)instr->len);
#endif
end = instr->addr + instr->len - 1;
/* Is it past the end? */
if ( end > mtd->size ) {
if (end > mtd->size) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n", (long)end, (long)mtd->size);
printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n",
(long)end, (long)mtd->size);
#endif
return -EINVAL;
}
......@@ -133,9 +135,9 @@ static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr)
eoff_lo = end & (priv->asize - 1);
soff_lo = instr->addr & (priv->asize - 1);
pmc551_point (mtd, instr->addr, instr->len, &retlen, &ptr);
pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr);
if ( soff_hi == eoff_hi || mtd->size == priv->asize) {
if (soff_hi == eoff_hi || mtd->size == priv->asize) {
/* The whole thing fits within one access, so just one shot
will do it. */
memset(ptr, 0xff, instr->len);
......@@ -144,20 +146,21 @@ static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr)
written. */
while (soff_hi != eoff_hi) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk( KERN_DEBUG "pmc551_erase() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
printk(KERN_DEBUG "pmc551_erase() soff_hi: %ld, "
"eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
#endif
memset(ptr, 0xff, priv->asize);
if (soff_hi + priv->asize >= mtd->size) {
goto out;
}
soff_hi += priv->asize;
pmc551_point (mtd,(priv->base_map0|soff_hi),
pmc551_point(mtd, (priv->base_map0 | soff_hi),
priv->asize, &retlen, &ptr);
}
memset (ptr, 0xff, eoff_lo);
memset(ptr, 0xff, eoff_lo);
}
out:
out:
instr->state = MTD_ERASE_DONE;
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_erase() done\n");
......@@ -167,8 +170,8 @@ static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr)
return 0;
}
static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf)
static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
size_t * retlen, u_char ** mtdbuf)
{
struct mypriv *priv = mtd->priv;
u32 soff_hi;
......@@ -180,7 +183,8 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *
if (from + len > mtd->size) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n", (long)from+len, (long)mtd->size);
printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n",
(long)from + len, (long)mtd->size);
#endif
return -EINVAL;
}
......@@ -189,9 +193,9 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *
soff_lo = from & (priv->asize - 1);
/* Cheap hack optimization */
if( priv->curr_map0 != from ) {
pci_write_config_dword ( priv->dev, PMC551_PCI_MEM_MAP0,
(priv->base_map0 | soff_hi) );
if (priv->curr_map0 != from) {
pci_write_config_dword(priv->dev, PMC551_PCI_MEM_MAP0,
(priv->base_map0 | soff_hi));
priv->curr_map0 = soff_hi;
}
......@@ -200,16 +204,16 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *
return 0;
}
static void pmc551_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len)
static void pmc551_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from,
size_t len)
{
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_unpoint()\n");
#endif
}
static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t * retlen, u_char * buf)
{
struct mypriv *priv = mtd->priv;
u32 soff_hi, soff_lo; /* start address offset hi/lo */
......@@ -219,7 +223,8 @@ static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *r
u_char *copyto = buf;
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n", (long)from, (long)len, (long)priv->asize);
printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n",
(long)from, (long)len, (long)priv->asize);
#endif
end = from + len - 1;
......@@ -227,7 +232,8 @@ static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *r
/* Is it past the end? */
if (end > mtd->size) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n", (long) end, (long)mtd->size);
printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n",
(long)end, (long)mtd->size);
#endif
return -EINVAL;
}
......@@ -237,7 +243,7 @@ static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *r
soff_lo = from & (priv->asize - 1);
eoff_lo = end & (priv->asize - 1);
pmc551_point (mtd, from, len, retlen, &ptr);
pmc551_point(mtd, from, len, retlen, &ptr);
if (soff_hi == eoff_hi) {
/* The whole thing fits within one access, so just one shot
......@@ -249,7 +255,8 @@ static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *r
written. */
while (soff_hi != eoff_hi) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk( KERN_DEBUG "pmc551_read() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
printk(KERN_DEBUG "pmc551_read() soff_hi: %ld, "
"eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
#endif
memcpy(copyto, ptr, priv->asize);
copyto += priv->asize;
......@@ -257,13 +264,13 @@ static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *r
goto out;
}
soff_hi += priv->asize;
pmc551_point (mtd, soff_hi, priv->asize, retlen, &ptr);
pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr);
}
memcpy(copyto, ptr, eoff_lo);
copyto += eoff_lo;
}
out:
out:
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_read() done\n");
#endif
......@@ -271,7 +278,8 @@ static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *r
return 0;
}
static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t * retlen, const u_char * buf)
{
struct mypriv *priv = mtd->priv;
u32 soff_hi, soff_lo; /* start address offset hi/lo */
......@@ -280,16 +288,18 @@ static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
u_char *ptr;
const u_char *copyfrom = buf;
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_write(pos:%ld, len:%ld) asize:%ld\n", (long)to, (long)len, (long)priv->asize);
printk(KERN_DEBUG "pmc551_write(pos:%ld, len:%ld) asize:%ld\n",
(long)to, (long)len, (long)priv->asize);
#endif
end = to + len - 1;
/* Is it past the end? or did the u32 wrap? */
if (end > mtd->size ) {
if (end > mtd->size) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, size: %ld, to: %ld)\n", (long) end, (long)mtd->size, (long)to);
printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, "
"size: %ld, to: %ld)\n", (long)end, (long)mtd->size,
(long)to);
#endif
return -EINVAL;
}
......@@ -299,7 +309,7 @@ static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
soff_lo = to & (priv->asize - 1);
eoff_lo = end & (priv->asize - 1);
pmc551_point (mtd, to, len, retlen, &ptr);
pmc551_point(mtd, to, len, retlen, &ptr);
if (soff_hi == eoff_hi) {
/* The whole thing fits within one access, so just one shot
......@@ -311,7 +321,8 @@ static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
written. */
while (soff_hi != eoff_hi) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk( KERN_DEBUG "pmc551_write() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
printk(KERN_DEBUG "pmc551_write() soff_hi: %ld, "
"eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
#endif
memcpy(ptr, copyfrom, priv->asize);
copyfrom += priv->asize;
......@@ -319,13 +330,13 @@ static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
goto out;
}
soff_hi += priv->asize;
pmc551_point (mtd, soff_hi, priv->asize, retlen, &ptr);
pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr);
}
memcpy(ptr, copyfrom, eoff_lo);
copyfrom += eoff_lo;
}
out:
out:
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_write() done\n");
#endif
......@@ -345,7 +356,7 @@ static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *re
* mechanism
* returns the size of the memory region found.
*/
static u32 fixup_pmc551 (struct pci_dev *dev)
static u32 fixup_pmc551(struct pci_dev *dev)
{
#ifdef CONFIG_MTD_PMC551_BUGFIX
u32 dram_data;
......@@ -355,7 +366,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
u8 bcmd, counter;
/* Sanity Check */
if(!dev) {
if (!dev) {
return -ENODEV;
}
......@@ -363,25 +374,25 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
* Attempt to reset the card
* FIXME: Stop Spinning registers
*/
counter=0;
counter = 0;
/* unlock registers */
pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, 0xA5 );
pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, 0xA5);
/* read in old data */
pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd );
pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd);
/* bang the reset line up and down for a few */
for(i=0;i<10;i++) {
counter=0;
for (i = 0; i < 10; i++) {
counter = 0;
bcmd &= ~0x80;
while(counter++ < 100) {
while (counter++ < 100) {
pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
}
counter=0;
counter = 0;
bcmd |= 0x80;
while(counter++ < 100) {
while (counter++ < 100) {
pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
}
}
bcmd |= (0x40|0x20);
bcmd |= (0x40 | 0x20);
pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
/*
......@@ -389,14 +400,14 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
* tweak the configurations
*/
pci_read_config_word(dev, PCI_COMMAND, &cmd);
tmp = cmd & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY);
tmp = cmd & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
pci_write_config_word(dev, PCI_COMMAND, tmp);
/*
* Disable existing aperture before probing memory size
*/
pci_read_config_dword(dev, PMC551_PCI_MEM_MAP0, &dcmd);
dtmp=(dcmd|PMC551_PCI_MEM_MAP_ENABLE|PMC551_PCI_MEM_MAP_REG_EN);
dtmp = (dcmd | PMC551_PCI_MEM_MAP_ENABLE | PMC551_PCI_MEM_MAP_REG_EN);
pci_write_config_dword(dev, PMC551_PCI_MEM_MAP0, dtmp);
/*
* Grab old BAR0 config so that we can figure out memory size
......@@ -407,13 +418,13 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
* then write all 1's to the memory space, read back the result into
* "size", and then write back all the old config.
*/
pci_read_config_dword( dev, PCI_BASE_ADDRESS_0, &cfg );
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cfg);
#ifndef CONFIG_MTD_PMC551_BUGFIX
pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, ~0 );
pci_read_config_dword( dev, PCI_BASE_ADDRESS_0, &size );
size = (size&PCI_BASE_ADDRESS_MEM_MASK);
size &= ~(size-1);
pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg );
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, ~0);
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &size);
size = (size & PCI_BASE_ADDRESS_MEM_MASK);
size &= ~(size - 1);
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, cfg);
#else
/*
* Get the size of the memory by reading all the DRAM size values
......@@ -450,28 +461,30 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
/*
* Oops .. something went wrong
*/
if( (size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) {
if ((size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) {
return -ENODEV;
}
#endif /* CONFIG_MTD_PMC551_BUGFIX */
if ((cfg&PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) {
if ((cfg & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) {
return -ENODEV;
}
/*
* Precharge Dram
*/
pci_write_config_word( dev, PMC551_SDRAM_MA, 0x0400 );
pci_write_config_word( dev, PMC551_SDRAM_CMD, 0x00bf );
pci_write_config_word(dev, PMC551_SDRAM_MA, 0x0400);
pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x00bf);
/*
* Wait until command has gone through
* FIXME: register spinning issue
*/
do { pci_read_config_word( dev, PMC551_SDRAM_CMD, &cmd );
if(counter++ > 100)break;
} while ( (PCI_COMMAND_IO) & cmd );
do {
pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
if (counter++ > 100)
break;
} while ((PCI_COMMAND_IO) & cmd);
/*
* Turn on auto refresh
......@@ -479,43 +492,47 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
* this must be held high for some duration of time, but I can find no
* documentation refrencing the reasons why.
*/
for ( i = 1; i<=8 ; i++) {
pci_write_config_word (dev, PMC551_SDRAM_CMD, 0x0df);
for (i = 1; i <= 8; i++) {
pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x0df);
/*
* Make certain command has gone through
* FIXME: register spinning issue
*/
counter=0;
do { pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
if(counter++ > 100)break;
} while ( (PCI_COMMAND_IO) & cmd );
counter = 0;
do {
pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
if (counter++ > 100)
break;
} while ((PCI_COMMAND_IO) & cmd);
}
pci_write_config_word ( dev, PMC551_SDRAM_MA, 0x0020);
pci_write_config_word ( dev, PMC551_SDRAM_CMD, 0x0ff);
pci_write_config_word(dev, PMC551_SDRAM_MA, 0x0020);
pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x0ff);
/*
* Wait until command completes
* FIXME: register spinning issue
*/
counter=0;
do { pci_read_config_word ( dev, PMC551_SDRAM_CMD, &cmd);
if(counter++ > 100)break;
} while ( (PCI_COMMAND_IO) & cmd );
counter = 0;
do {
pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
if (counter++ > 100)
break;
} while ((PCI_COMMAND_IO) & cmd);
pci_read_config_dword ( dev, PMC551_DRAM_CFG, &dcmd);
pci_read_config_dword(dev, PMC551_DRAM_CFG, &dcmd);
dcmd |= 0x02000000;
pci_write_config_dword ( dev, PMC551_DRAM_CFG, dcmd);
pci_write_config_dword(dev, PMC551_DRAM_CFG, dcmd);
/*
* Check to make certain fast back-to-back, if not
* then set it so
*/
pci_read_config_word( dev, PCI_STATUS, &cmd);
if((cmd&PCI_COMMAND_FAST_BACK) == 0) {
pci_read_config_word(dev, PCI_STATUS, &cmd);
if ((cmd & PCI_COMMAND_FAST_BACK) == 0) {
cmd |= PCI_COMMAND_FAST_BACK;
pci_write_config_word( dev, PCI_STATUS, cmd);
pci_write_config_word(dev, PCI_STATUS, cmd);
}
/*
......@@ -523,9 +540,9 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
* has a tendancy to assert DEVSEL and TRDY when a write is performed
* to the memory when memory is read-only
*/
if((cmd&PCI_STATUS_DEVSEL_MASK) != 0x0) {
if ((cmd & PCI_STATUS_DEVSEL_MASK) != 0x0) {
cmd &= ~PCI_STATUS_DEVSEL_MASK;
pci_write_config_word( dev, PCI_STATUS, cmd );
pci_write_config_word(dev, PCI_STATUS, cmd);
}
/*
* Set to be prefetchable and put everything back based on old cfg.
......@@ -540,78 +557,84 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
/*
* Turn PCI memory and I/O bus access back on
*/
pci_write_config_word( dev, PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_IO );
pci_write_config_word(dev, PCI_COMMAND,
PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
#ifdef CONFIG_MTD_PMC551_DEBUG
/*
* Some screen fun
*/
printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at 0x%llx\n",
(size<1024)?size:(size<1048576)?size>>10:size>>20,
(size<1024)?'B':(size<1048576)?'K':'M',
size, ((dcmd&(0x1<<3)) == 0)?"non-":"",
(unsigned long long)((dev->resource[0].start)&PCI_BASE_ADDRESS_MEM_MASK));
printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at "
"0x%llx\n", (size < 1024) ? size : (size < 1048576) ?
size >> 10 : size >> 20,
(size < 1024) ? 'B' : (size < 1048576) ? 'K' : 'M', size,
((dcmd & (0x1 << 3)) == 0) ? "non-" : "",
(unsigned long long)((dev->resource[0].start) &
PCI_BASE_ADDRESS_MEM_MASK));
/*
* Check to see the state of the memory
*/
pci_read_config_dword( dev, PMC551_DRAM_BLK0, &dcmd );
pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dcmd);
printk(KERN_DEBUG "pmc551: DRAM_BLK0 Flags: %s,%s\n"
"pmc551: DRAM_BLK0 Size: %d at %d\n"
"pmc551: DRAM_BLK0 Row MUX: %d, Col MUX: %d\n",
(((0x1<<1)&dcmd) == 0)?"RW":"RO",
(((0x1<<0)&dcmd) == 0)?"Off":"On",
(((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
(((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
PMC551_DRAM_BLK_GET_SIZE(dcmd),
((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) );
((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
((dcmd >> 9) & 0xF));
pci_read_config_dword( dev, PMC551_DRAM_BLK1, &dcmd );
pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dcmd);
printk(KERN_DEBUG "pmc551: DRAM_BLK1 Flags: %s,%s\n"
"pmc551: DRAM_BLK1 Size: %d at %d\n"
"pmc551: DRAM_BLK1 Row MUX: %d, Col MUX: %d\n",
(((0x1<<1)&dcmd) == 0)?"RW":"RO",
(((0x1<<0)&dcmd) == 0)?"Off":"On",
(((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
(((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
PMC551_DRAM_BLK_GET_SIZE(dcmd),
((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) );
((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
((dcmd >> 9) & 0xF));
pci_read_config_dword( dev, PMC551_DRAM_BLK2, &dcmd );
pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dcmd);
printk(KERN_DEBUG "pmc551: DRAM_BLK2 Flags: %s,%s\n"
"pmc551: DRAM_BLK2 Size: %d at %d\n"
"pmc551: DRAM_BLK2 Row MUX: %d, Col MUX: %d\n",
(((0x1<<1)&dcmd) == 0)?"RW":"RO",
(((0x1<<0)&dcmd) == 0)?"Off":"On",
(((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
(((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
PMC551_DRAM_BLK_GET_SIZE(dcmd),
((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) );
((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
((dcmd >> 9) & 0xF));
pci_read_config_dword( dev, PMC551_DRAM_BLK3, &dcmd );
pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dcmd);
printk(KERN_DEBUG "pmc551: DRAM_BLK3 Flags: %s,%s\n"
"pmc551: DRAM_BLK3 Size: %d at %d\n"
"pmc551: DRAM_BLK3 Row MUX: %d, Col MUX: %d\n",
(((0x1<<1)&dcmd) == 0)?"RW":"RO",
(((0x1<<0)&dcmd) == 0)?"Off":"On",
(((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
(((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
PMC551_DRAM_BLK_GET_SIZE(dcmd),
((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) );
((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
((dcmd >> 9) & 0xF));
pci_read_config_word( dev, PCI_COMMAND, &cmd );
printk( KERN_DEBUG "pmc551: Memory Access %s\n",
(((0x1<<1)&cmd) == 0)?"off":"on" );
printk( KERN_DEBUG "pmc551: I/O Access %s\n",
(((0x1<<0)&cmd) == 0)?"off":"on" );
pci_read_config_word( dev, PCI_STATUS, &cmd );
printk( KERN_DEBUG "pmc551: Devsel %s\n",
((PCI_STATUS_DEVSEL_MASK&cmd)==0x000)?"Fast":
((PCI_STATUS_DEVSEL_MASK&cmd)==0x200)?"Medium":
((PCI_STATUS_DEVSEL_MASK&cmd)==0x400)?"Slow":"Invalid" );
printk( KERN_DEBUG "pmc551: %sFast Back-to-Back\n",
((PCI_COMMAND_FAST_BACK&cmd) == 0)?"Not ":"" );
pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd );
printk( KERN_DEBUG "pmc551: EEPROM is under %s control\n"
pci_read_config_word(dev, PCI_COMMAND, &cmd);
printk(KERN_DEBUG "pmc551: Memory Access %s\n",
(((0x1 << 1) & cmd) == 0) ? "off" : "on");
printk(KERN_DEBUG "pmc551: I/O Access %s\n",
(((0x1 << 0) & cmd) == 0) ? "off" : "on");
pci_read_config_word(dev, PCI_STATUS, &cmd);
printk(KERN_DEBUG "pmc551: Devsel %s\n",
((PCI_STATUS_DEVSEL_MASK & cmd) == 0x000) ? "Fast" :
((PCI_STATUS_DEVSEL_MASK & cmd) == 0x200) ? "Medium" :
((PCI_STATUS_DEVSEL_MASK & cmd) == 0x400) ? "Slow" : "Invalid");
printk(KERN_DEBUG "pmc551: %sFast Back-to-Back\n",
((PCI_COMMAND_FAST_BACK & cmd) == 0) ? "Not " : "");
pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd);
printk(KERN_DEBUG "pmc551: EEPROM is under %s control\n"
"pmc551: System Control Register is %slocked to PCI access\n"
"pmc551: System Control Register is %slocked to EEPROM access\n",
(bcmd&0x1)?"software":"hardware",
(bcmd&0x20)?"":"un", (bcmd&0x40)?"":"un");
(bcmd & 0x1) ? "software" : "hardware",
(bcmd & 0x20) ? "" : "un", (bcmd & 0x40) ? "" : "un");
#endif
return size;
}
......@@ -620,7 +643,6 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
* Kernel version specific module stuffages
*/
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mark Ferrell <mferrell@mvista.com>");
MODULE_DESCRIPTION(PMC551_VERSION);
......@@ -628,11 +650,11 @@ MODULE_DESCRIPTION(PMC551_VERSION);
/*
* Stuff these outside the ifdef so as to not bust compiled in driver support
*/
static int msize=0;
static int msize = 0;
#if defined(CONFIG_MTD_PMC551_APERTURE_SIZE)
static int asize=CONFIG_MTD_PMC551_APERTURE_SIZE
static int asize = CONFIG_MTD_PMC551_APERTURE_SIZE
#else
static int asize=0;
static int asize = 0;
#endif
module_param(msize, int, 0);
......@@ -647,22 +669,24 @@ static int __init init_pmc551(void)
{
struct pci_dev *PCI_Device = NULL;
struct mypriv *priv;
int count, found=0;
int count, found = 0;
struct mtd_info *mtd;
u32 length = 0;
if(msize) {
msize = (1 << (ffs(msize) - 1))<<20;
if (msize > (1<<30)) {
printk(KERN_NOTICE "pmc551: Invalid memory size [%d]\n", msize);
if (msize) {
msize = (1 << (ffs(msize) - 1)) << 20;
if (msize > (1 << 30)) {
printk(KERN_NOTICE "pmc551: Invalid memory size [%d]\n",
msize);
return -EINVAL;
}
}
if(asize) {
asize = (1 << (ffs(asize) - 1))<<20;
if (asize > (1<<30) ) {
printk(KERN_NOTICE "pmc551: Invalid aperture size [%d]\n", asize);
if (asize) {
asize = (1 << (ffs(asize) - 1)) << 20;
if (asize > (1 << 30)) {
printk(KERN_NOTICE "pmc551: Invalid aperture size "
"[%d]\n", asize);
return -EINVAL;
}
}
......@@ -672,11 +696,11 @@ static int __init init_pmc551(void)
/*
* PCU-bus chipset probe.
*/
for( count = 0; count < MAX_MTD_DEVICES; count++ ) {
for (count = 0; count < MAX_MTD_DEVICES; count++) {
if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI,
PCI_DEVICE_ID_V3_SEMI_V370PDC,
PCI_Device ) ) == NULL) {
PCI_Device)) == NULL) {
break;
}
......@@ -691,7 +715,7 @@ static int __init init_pmc551(void)
* with the oldproc.c driver in
* some kernels (2.2.*)
*/
if((length = fixup_pmc551(PCI_Device)) <= 0) {
if ((length = fixup_pmc551(PCI_Device)) <= 0) {
printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n");
break;
}
......@@ -700,24 +724,27 @@ static int __init init_pmc551(void)
* This is needed until the driver is capable of reading the
* onboard I2C SROM to discover the "real" memory size.
*/
if(msize) {
if (msize) {
length = msize;
printk(KERN_NOTICE "pmc551: Using specified memory size 0x%x\n", length);
printk(KERN_NOTICE "pmc551: Using specified memory "
"size 0x%x\n", length);
} else {
msize = length;
}
mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
if (!mtd) {
printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n");
printk(KERN_NOTICE "pmc551: Cannot allocate new MTD "
"device.\n");
break;
}
memset(mtd, 0, sizeof(struct mtd_info));
priv = kmalloc (sizeof(struct mypriv), GFP_KERNEL);
priv = kmalloc(sizeof(struct mypriv), GFP_KERNEL);
if (!priv) {
printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n");
printk(KERN_NOTICE "pmc551: Cannot allocate new MTD "
"device.\n");
kfree(mtd);
break;
}
......@@ -725,14 +752,17 @@ static int __init init_pmc551(void)
mtd->priv = priv;
priv->dev = PCI_Device;
if(asize > length) {
printk(KERN_NOTICE "pmc551: reducing aperture size to fit %dM\n",length>>20);
if (asize > length) {
printk(KERN_NOTICE "pmc551: reducing aperture size to "
"fit %dM\n", length >> 20);
priv->asize = asize = length;
} else if (asize == 0 || asize == length) {
printk(KERN_NOTICE "pmc551: Using existing aperture size %dM\n", length>>20);
printk(KERN_NOTICE "pmc551: Using existing aperture "
"size %dM\n", length >> 20);
priv->asize = asize = length;
} else {
printk(KERN_NOTICE "pmc551: Using specified aperture size %dM\n", asize>>20);
printk(KERN_NOTICE "pmc551: Using specified aperture "
"size %dM\n", asize >> 20);
priv->asize = asize;
}
priv->start = ioremap(((PCI_Device->resource[0].start)
......@@ -745,22 +775,21 @@ static int __init init_pmc551(void)
kfree(mtd);
break;
}
#ifdef CONFIG_MTD_PMC551_DEBUG
printk( KERN_DEBUG "pmc551: setting aperture to %d\n",
ffs(priv->asize>>20)-1);
printk(KERN_DEBUG "pmc551: setting aperture to %d\n",
ffs(priv->asize >> 20) - 1);
#endif
priv->base_map0 = ( PMC551_PCI_MEM_MAP_REG_EN
priv->base_map0 = (PMC551_PCI_MEM_MAP_REG_EN
| PMC551_PCI_MEM_MAP_ENABLE
| (ffs(priv->asize>>20)-1)<<4 );
| (ffs(priv->asize >> 20) - 1) << 4);
priv->curr_map0 = priv->base_map0;
pci_write_config_dword ( priv->dev, PMC551_PCI_MEM_MAP0,
priv->curr_map0 );
pci_write_config_dword(priv->dev, PMC551_PCI_MEM_MAP0,
priv->curr_map0);
#ifdef CONFIG_MTD_PMC551_DEBUG
printk( KERN_DEBUG "pmc551: aperture set to %d\n",
(priv->base_map0 & 0xF0)>>4 );
printk(KERN_DEBUG "pmc551: aperture set to %d\n",
(priv->base_map0 & 0xF0) >> 4);
#endif
mtd->size = msize;
......@@ -777,7 +806,8 @@ static int __init init_pmc551(void)
mtd->owner = THIS_MODULE;
if (add_mtd_device(mtd)) {
printk(KERN_NOTICE "pmc551: Failed to register new device\n");
printk(KERN_NOTICE "pmc551: Failed to register new "
"device\n");
iounmap(priv->start);
kfree(mtd->priv);
kfree(mtd);
......@@ -789,13 +819,12 @@ static int __init init_pmc551(void)
printk(KERN_NOTICE "Registered pmc551 memory device.\n");
printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n",
priv->asize>>20,
priv->start,
priv->start + priv->asize);
priv->asize >> 20,
priv->start, priv->start + priv->asize);
printk(KERN_NOTICE "Total memory is %d%c\n",
(length<1024)?length:
(length<1048576)?length>>10:length>>20,
(length<1024)?'B':(length<1048576)?'K':'M');
(length < 1024) ? length :
(length < 1048576) ? length >> 10 : length >> 20,
(length < 1024) ? 'B' : (length < 1048576) ? 'K' : 'M');
priv->nextpmc551 = pmc551list;
pmc551list = mtd;
found++;
......@@ -805,7 +834,7 @@ static int __init init_pmc551(void)
if (PCI_Device)
pci_dev_put(PCI_Device);
if( !pmc551list ) {
if (!pmc551list) {
printk(KERN_NOTICE "pmc551: not detected\n");
return -ENODEV;
} else {
......@@ -819,24 +848,24 @@ static int __init init_pmc551(void)
*/
static void __exit cleanup_pmc551(void)
{
int found=0;
int found = 0;
struct mtd_info *mtd;
struct mypriv *priv;
while((mtd=pmc551list)) {
while ((mtd = pmc551list)) {
priv = mtd->priv;
pmc551list = priv->nextpmc551;
if(priv->start) {
printk (KERN_DEBUG "pmc551: unmapping %dM starting at 0x%p\n",
priv->asize>>20, priv->start);
iounmap (priv->start);
if (priv->start) {
printk(KERN_DEBUG "pmc551: unmapping %dM starting at "
"0x%p\n", priv->asize >> 20, priv->start);
iounmap(priv->start);
}
pci_dev_put(priv->dev);
kfree (mtd->priv);
del_mtd_device (mtd);
kfree (mtd);
kfree(mtd->priv);
del_mtd_device(mtd);
kfree(mtd);
found++;
}
......
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