Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
Browse files Browse the repository at this point in the history
* master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6:
  [SPARC]: Add iomap interfaces.
  [OPENPROM]: Rewrite driver to use in-kernel device tree.
  [OPENPROMFS]: Rewrite using in-kernel device tree and seq_file.
  [SPARC]: Add unique device_node IDs and a ".node" property.
  [SPARC]: Add of_set_property() interface.
  [SPARC64]: Export auxio_register to modules.
  [SPARC64]: Add missing interfaces to dma-mapping.h
  [SPARC64]: Export _PAGE_IE to modules.
  [SPARC64]: Allow floppy driver to build modular.
  [SPARC]: Export x_bus_type to modules.
  [RIOWATCHDOG]: Fix the build.
  [CPWATCHDOG]: Fix the build.
  [PARPORT] sunbpp: Fix typo.
  [MTD] sun_uflash: Port to new EBUS device layer.
  • Loading branch information
Linus Torvalds committed Jun 26, 2006
2 parents 61a46dc + 749805d commit 8871e73
Show file tree
Hide file tree
Showing 20 changed files with 1,053 additions and 1,363 deletions.
2 changes: 2 additions & 0 deletions arch/sparc/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ struct bus_type ebus_bus_type = {
.suspend = of_device_suspend,
.resume = of_device_resume,
};
EXPORT_SYMBOL(ebus_bus_type);
#endif

#ifdef CONFIG_SBUS
Expand All @@ -149,6 +150,7 @@ struct bus_type sbus_bus_type = {
.suspend = of_device_suspend,
.resume = of_device_resume,
};
EXPORT_SYMBOL(sbus_bus_type);
#endif

static int __init of_bus_driver_init(void)
Expand Down
106 changes: 88 additions & 18 deletions arch/sparc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@

static struct device_node *allnodes;

/* use when traversing tree through the allnext, child, sibling,
* or parent members of struct device_node.
*/
static DEFINE_RWLOCK(devtree_lock);

int of_device_is_compatible(struct device_node *device, const char *compat)
{
const char* cp;
Expand Down Expand Up @@ -185,6 +190,54 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
}
EXPORT_SYMBOL(of_getintprop_default);

int of_set_property(struct device_node *dp, const char *name, void *val, int len)
{
struct property **prevp;
void *new_val;
int err;

new_val = kmalloc(len, GFP_KERNEL);
if (!new_val)
return -ENOMEM;

memcpy(new_val, val, len);

err = -ENODEV;

write_lock(&devtree_lock);
prevp = &dp->properties;
while (*prevp) {
struct property *prop = *prevp;

if (!strcmp(prop->name, name)) {
void *old_val = prop->value;
int ret;

ret = prom_setprop(dp->node, name, val, len);
err = -EINVAL;
if (ret >= 0) {
prop->value = new_val;
prop->length = len;

if (OF_IS_DYNAMIC(prop))
kfree(old_val);

OF_MARK_DYNAMIC(prop);

err = 0;
}
break;
}
prevp = &(*prevp)->next;
}
write_unlock(&devtree_lock);

/* XXX Upate procfs if necessary... */

return err;
}
EXPORT_SYMBOL(of_set_property);

static unsigned int prom_early_allocated;

static void * __init prom_early_alloc(unsigned long size)
Expand Down Expand Up @@ -354,7 +407,9 @@ static char * __init build_full_name(struct device_node *dp)
return n;
}

static struct property * __init build_one_prop(phandle node, char *prev)
static unsigned int unique_id;

static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
{
static struct property *tmp = NULL;
struct property *p;
Expand All @@ -364,25 +419,34 @@ static struct property * __init build_one_prop(phandle node, char *prev)
p = tmp;
memset(p, 0, sizeof(*p) + 32);
tmp = NULL;
} else
} else {
p = prom_early_alloc(sizeof(struct property) + 32);
p->unique_id = unique_id++;
}

p->name = (char *) (p + 1);
if (prev == NULL) {
prom_firstprop(node, p->name);
if (special_name) {
p->length = special_len;
p->value = prom_early_alloc(special_len);
memcpy(p->value, special_val, special_len);
} else {
prom_nextprop(node, prev, p->name);
}
if (strlen(p->name) == 0) {
tmp = p;
return NULL;
}
p->length = prom_getproplen(node, p->name);
if (p->length <= 0) {
p->length = 0;
} else {
p->value = prom_early_alloc(p->length);
len = prom_getproperty(node, p->name, p->value, p->length);
if (prev == NULL) {
prom_firstprop(node, p->name);
} else {
prom_nextprop(node, prev, p->name);
}
if (strlen(p->name) == 0) {
tmp = p;
return NULL;
}
p->length = prom_getproplen(node, p->name);
if (p->length <= 0) {
p->length = 0;
} else {
p->value = prom_early_alloc(p->length + 1);
prom_getproperty(node, p->name, p->value, p->length);
((unsigned char *)p->value)[p->length] = '\0';
}
}
return p;
}
Expand All @@ -391,9 +455,14 @@ static struct property * __init build_prop_list(phandle node)
{
struct property *head, *tail;

head = tail = build_one_prop(node, NULL);
head = tail = build_one_prop(node, NULL,
".node", &node, sizeof(node));

tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
tail = tail->next;
while(tail) {
tail->next = build_one_prop(node, tail->name);
tail->next = build_one_prop(node, tail->name,
NULL, NULL, 0);
tail = tail->next;
}

Expand Down Expand Up @@ -422,6 +491,7 @@ static struct device_node * __init create_node(phandle node)
return NULL;

dp = prom_early_alloc(sizeof(*dp));
dp->unique_id = unique_id++;

kref_init(&dp->kref);

Expand Down
2 changes: 2 additions & 0 deletions arch/sparc/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ lib-y := mul.o rem.o sdiv.o udiv.o umul.o urem.o ashrdi3.o memcpy.o memset.o \
strncpy_from_user.o divdi3.o udivdi3.o strlen_user.o \
copy_user.o locks.o atomic.o atomic32.o bitops.o \
lshrdi3.o ashldi3.o rwsem.o muldi3.o bitext.o

obj-y += iomap.o
48 changes: 48 additions & 0 deletions arch/sparc/lib/iomap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Implement the sparc iomap interfaces
*/
#include <linux/pci.h>
#include <linux/module.h>
#include <asm/io.h>

/* Create a virtual mapping cookie for an IO port range */
void __iomem *ioport_map(unsigned long port, unsigned int nr)
{
return (void __iomem *) (unsigned long) port;
}

void ioport_unmap(void __iomem *addr)
{
/* Nothing to do */
}
EXPORT_SYMBOL(ioport_map);
EXPORT_SYMBOL(ioport_unmap);

/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
{
unsigned long start = pci_resource_start(dev, bar);
unsigned long len = pci_resource_len(dev, bar);
unsigned long flags = pci_resource_flags(dev, bar);

if (!len || !start)
return NULL;
if (maxlen && len > maxlen)
len = maxlen;
if (flags & IORESOURCE_IO)
return ioport_map(start, len);
if (flags & IORESOURCE_MEM) {
if (flags & IORESOURCE_CACHEABLE)
return ioremap(start, len);
return ioremap_nocache(start, len);
}
/* What? */
return NULL;
}

void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
{
/* nothing to do */
}
EXPORT_SYMBOL(pci_iomap);
EXPORT_SYMBOL(pci_iounmap);
3 changes: 2 additions & 1 deletion arch/sparc64/kernel/auxio.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/ioport.h>
Expand All @@ -16,8 +17,8 @@
#include <asm/ebus.h>
#include <asm/auxio.h>

/* This cannot be static, as it is referenced in irq.c */
void __iomem *auxio_register = NULL;
EXPORT_SYMBOL(auxio_register);

enum auxio_type {
AUXIO_TYPE_NODEV,
Expand Down
61 changes: 0 additions & 61 deletions arch/sparc64/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,67 +563,6 @@ void handler_irq(int irq, struct pt_regs *regs)
irq_exit();
}

#ifdef CONFIG_BLK_DEV_FD
extern irqreturn_t floppy_interrupt(int, void *, struct pt_regs *);

/* XXX No easy way to include asm/floppy.h XXX */
extern unsigned char *pdma_vaddr;
extern unsigned long pdma_size;
extern volatile int doing_pdma;
extern unsigned long fdc_status;

irqreturn_t sparc_floppy_irq(int irq, void *dev_cookie, struct pt_regs *regs)
{
if (likely(doing_pdma)) {
void __iomem *stat = (void __iomem *) fdc_status;
unsigned char *vaddr = pdma_vaddr;
unsigned long size = pdma_size;
u8 val;

while (size) {
val = readb(stat);
if (unlikely(!(val & 0x80))) {
pdma_vaddr = vaddr;
pdma_size = size;
return IRQ_HANDLED;
}
if (unlikely(!(val & 0x20))) {
pdma_vaddr = vaddr;
pdma_size = size;
doing_pdma = 0;
goto main_interrupt;
}
if (val & 0x40) {
/* read */
*vaddr++ = readb(stat + 1);
} else {
unsigned char data = *vaddr++;

/* write */
writeb(data, stat + 1);
}
size--;
}

pdma_vaddr = vaddr;
pdma_size = size;

/* Send Terminal Count pulse to floppy controller. */
val = readb(auxio_register);
val |= AUXIO_AUX1_FTCNT;
writeb(val, auxio_register);
val &= ~AUXIO_AUX1_FTCNT;
writeb(val, auxio_register);

doing_pdma = 0;
}

main_interrupt:
return floppy_interrupt(irq, dev_cookie, regs);
}
EXPORT_SYMBOL(sparc_floppy_irq);
#endif

struct sun5_timer {
u64 count0;
u64 limit0;
Expand Down
3 changes: 3 additions & 0 deletions arch/sparc64/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ struct bus_type isa_bus_type = {
.suspend = of_device_suspend,
.resume = of_device_resume,
};
EXPORT_SYMBOL(isa_bus_type);

struct bus_type ebus_bus_type = {
.name = "ebus",
Expand All @@ -147,6 +148,7 @@ struct bus_type ebus_bus_type = {
.suspend = of_device_suspend,
.resume = of_device_resume,
};
EXPORT_SYMBOL(ebus_bus_type);
#endif

#ifdef CONFIG_SBUS
Expand All @@ -158,6 +160,7 @@ struct bus_type sbus_bus_type = {
.suspend = of_device_suspend,
.resume = of_device_resume,
};
EXPORT_SYMBOL(sbus_bus_type);
#endif

static int __init of_bus_driver_init(void)
Expand Down
Loading

0 comments on commit 8871e73

Please sign in to comment.