aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sh/cchips/voyagergx/consistent.c15
-rw-r--r--arch/sh/cchips/voyagergx/irq.c7
-rw-r--r--arch/sh/kernel/cpu/Makefile2
-rw-r--r--arch/sh/kernel/cpu/bus.c197
-rw-r--r--include/asm-sh/bus-sh.h66
5 files changed, 12 insertions, 275 deletions
diff --git a/arch/sh/cchips/voyagergx/consistent.c b/arch/sh/cchips/voyagergx/consistent.c
index 3d9a02c093a3..07e8b9c5a531 100644
--- a/arch/sh/cchips/voyagergx/consistent.c
+++ b/arch/sh/cchips/voyagergx/consistent.c
@@ -15,7 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/bus-sh.h> 18
19 19
20struct voya_alloc_entry { 20struct voya_alloc_entry {
21 struct list_head list; 21 struct list_head list;
@@ -30,12 +30,13 @@ static LIST_HEAD(voya_alloc_list);
30#define OHCI_HCCA_SIZE 0x100 30#define OHCI_HCCA_SIZE 0x100
31#define OHCI_SRAM_SIZE 0x10000 31#define OHCI_SRAM_SIZE 0x10000
32 32
33#define VOYAGER_OHCI_NAME "voyager-ohci"
34
33void *voyagergx_consistent_alloc(struct device *dev, size_t size, 35void *voyagergx_consistent_alloc(struct device *dev, size_t size,
34 dma_addr_t *handle, gfp_t flag) 36 dma_addr_t *handle, gfp_t flag)
35{ 37{
36 struct list_head *list = &voya_alloc_list; 38 struct list_head *list = &voya_alloc_list;
37 struct voya_alloc_entry *entry; 39 struct voya_alloc_entry *entry;
38 struct sh_dev *shdev = to_sh_dev(dev);
39 unsigned long start, end; 40 unsigned long start, end;
40 unsigned long flags; 41 unsigned long flags;
41 42
@@ -46,9 +47,7 @@ void *voyagergx_consistent_alloc(struct device *dev, size_t size,
46 * 47 *
47 * Everything else goes through consistent_alloc(). 48 * Everything else goes through consistent_alloc().
48 */ 49 */
49 if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] || 50 if (!dev || strcmp(dev->driver->name, VOYAGER_OHCI_NAME))
50 (dev->bus == &sh_bus_types[SH_BUS_VIRT] &&
51 shdev->dev_id != SH_DEV_ID_USB_OHCI))
52 return NULL; 51 return NULL;
53 52
54 start = OHCI_SRAM_START + OHCI_HCCA_SIZE; 53 start = OHCI_SRAM_START + OHCI_HCCA_SIZE;
@@ -98,12 +97,9 @@ int voyagergx_consistent_free(struct device *dev, size_t size,
98 void *vaddr, dma_addr_t handle) 97 void *vaddr, dma_addr_t handle)
99{ 98{
100 struct voya_alloc_entry *entry; 99 struct voya_alloc_entry *entry;
101 struct sh_dev *shdev = to_sh_dev(dev);
102 unsigned long flags; 100 unsigned long flags;
103 101
104 if (!dev || dev->bus != &sh_bus_types[SH_BUS_VIRT] || 102 if (!dev || strcmp(dev->driver->name, VOYAGER_OHCI_NAME))
105 (dev->bus == &sh_bus_types[SH_BUS_VIRT] &&
106 shdev->dev_id != SH_DEV_ID_USB_OHCI))
107 return -EINVAL; 103 return -EINVAL;
108 104
109 spin_lock_irqsave(&voya_list_lock, flags); 105 spin_lock_irqsave(&voya_list_lock, flags);
@@ -123,4 +119,3 @@ int voyagergx_consistent_free(struct device *dev, size_t size,
123 119
124EXPORT_SYMBOL(voyagergx_consistent_alloc); 120EXPORT_SYMBOL(voyagergx_consistent_alloc);
125EXPORT_SYMBOL(voyagergx_consistent_free); 121EXPORT_SYMBOL(voyagergx_consistent_free);
126
diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c
index 1b6ac523b458..2ee330b3c38f 100644
--- a/arch/sh/cchips/voyagergx/irq.c
+++ b/arch/sh/cchips/voyagergx/irq.c
@@ -163,7 +163,12 @@ int voyagergx_irq_demux(int irq)
163 return irq; 163 return irq;
164} 164}
165 165
166static struct irqaction irq0 = { voyagergx_interrupt, SA_INTERRUPT, 0, "VOYAGERGX", NULL, NULL}; 166static struct irqaction irq0 = {
167 .name = "voyagergx",
168 .handler = voyagergx_interrupt,
169 .flags = SA_INTERRUPT,
170 .mask = CPU_MASK_NONE,
171};
167 172
168void __init setup_voyagergx_irq(void) 173void __init setup_voyagergx_irq(void)
169{ 174{
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index 5bfc33bec5d0..59d5b748752f 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/SuperH CPU-specifc backends. 2# Makefile for the Linux/SuperH CPU-specifc backends.
3# 3#
4 4
5obj-y += irq/ init.o bus.o clock.o 5obj-y += irq/ init.o clock.o
6 6
7obj-$(CONFIG_CPU_SH2) += sh2/ 7obj-$(CONFIG_CPU_SH2) += sh2/
8obj-$(CONFIG_CPU_SH3) += sh3/ 8obj-$(CONFIG_CPU_SH3) += sh3/
diff --git a/arch/sh/kernel/cpu/bus.c b/arch/sh/kernel/cpu/bus.c
deleted file mode 100644
index fc6c4bd40c65..000000000000
--- a/arch/sh/kernel/cpu/bus.c
+++ /dev/null
@@ -1,197 +0,0 @@
1/*
2 * arch/sh/kernel/cpu/bus.c
3 *
4 * Virtual bus for SuperH.
5 *
6 * Copyright (C) 2004 Paul Mundt
7 *
8 * Shamelessly cloned from arch/arm/mach-omap/bus.c, which was written
9 * by:
10 *
11 * Copyright (C) 2003 - 2004 Nokia Corporation
12 * Written by Tony Lindgren <tony@atomide.com>
13 * Portions of code based on sa1111.c.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 */
20#include <linux/kernel.h>
21#include <linux/device.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <asm/bus-sh.h>
25
26static int sh_bus_match(struct device *dev, struct device_driver *drv)
27{
28 struct sh_driver *shdrv = to_sh_driver(drv);
29 struct sh_dev *shdev = to_sh_dev(dev);
30
31 return shdev->dev_id == shdrv->dev_id;
32}
33
34static int sh_bus_suspend(struct device *dev, pm_message_t state)
35{
36 struct sh_dev *shdev = to_sh_dev(dev);
37 struct sh_driver *shdrv = to_sh_driver(dev->driver);
38
39 if (shdrv && shdrv->suspend)
40 return shdrv->suspend(shdev, state);
41
42 return 0;
43}
44
45static int sh_bus_resume(struct device *dev)
46{
47 struct sh_dev *shdev = to_sh_dev(dev);
48 struct sh_driver *shdrv = to_sh_driver(dev->driver);
49
50 if (shdrv && shdrv->resume)
51 return shdrv->resume(shdev);
52
53 return 0;
54}
55
56static int sh_device_probe(struct device *dev)
57{
58 struct sh_dev *shdev = to_sh_dev(dev);
59 struct sh_driver *shdrv = to_sh_driver(dev->driver);
60
61 if (shdrv && shdrv->probe)
62 return shdrv->probe(shdev);
63
64 return -ENODEV;
65}
66
67static int sh_device_remove(struct device *dev)
68{
69 struct sh_dev *shdev = to_sh_dev(dev);
70 struct sh_driver *shdrv = to_sh_driver(dev->driver);
71
72 if (shdrv && shdrv->remove)
73 return shdrv->remove(shdev);
74
75 return 0;
76}
77
78static struct device sh_bus_devices[SH_NR_BUSES] = {
79 {
80 .bus_id = SH_BUS_NAME_VIRT,
81 },
82};
83
84struct bus_type sh_bus_types[SH_NR_BUSES] = {
85 {
86 .name = SH_BUS_NAME_VIRT,
87 .match = sh_bus_match,
88 .probe = sh_bus_probe,
89 .remove = sh_bus_remove,
90 .suspend = sh_bus_suspend,
91 .resume = sh_bus_resume,
92 },
93};
94
95int sh_device_register(struct sh_dev *dev)
96{
97 if (!dev)
98 return -EINVAL;
99
100 if (dev->bus_id < 0 || dev->bus_id >= SH_NR_BUSES) {
101 printk(KERN_ERR "%s: bus_id invalid: %s bus: %d\n",
102 __FUNCTION__, dev->name, dev->bus_id);
103 return -EINVAL;
104 }
105
106 dev->dev.parent = &sh_bus_devices[dev->bus_id];
107 dev->dev.bus = &sh_bus_types[dev->bus_id];
108
109 /* This is needed for USB OHCI to work */
110 if (dev->dma_mask)
111 dev->dev.dma_mask = dev->dma_mask;
112 if (dev->coherent_dma_mask)
113 dev->dev.coherent_dma_mask = dev->coherent_dma_mask;
114
115 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%s%u",
116 dev->name, dev->dev_id);
117
118 printk(KERN_INFO "Registering SH device '%s'. Parent at %s\n",
119 dev->dev.bus_id, dev->dev.parent->bus_id);
120
121 return device_register(&dev->dev);
122}
123
124void sh_device_unregister(struct sh_dev *dev)
125{
126 device_unregister(&dev->dev);
127}
128
129int sh_driver_register(struct sh_driver *drv)
130{
131 if (!drv)
132 return -EINVAL;
133
134 if (drv->bus_id < 0 || drv->bus_id >= SH_NR_BUSES) {
135 printk(KERN_ERR "%s: bus_id invalid: bus: %d device %d\n",
136 __FUNCTION__, drv->bus_id, drv->dev_id);
137 return -EINVAL;
138 }
139
140 drv->drv.bus = &sh_bus_types[drv->bus_id];
141
142 return driver_register(&drv->drv);
143}
144
145void sh_driver_unregister(struct sh_driver *drv)
146{
147 driver_unregister(&drv->drv);
148}
149
150static int __init sh_bus_init(void)
151{
152 int i, ret = 0;
153
154 for (i = 0; i < SH_NR_BUSES; i++) {
155 ret = device_register(&sh_bus_devices[i]);
156 if (ret != 0) {
157 printk(KERN_ERR "Unable to register bus device %s\n",
158 sh_bus_devices[i].bus_id);
159 continue;
160 }
161
162 ret = bus_register(&sh_bus_types[i]);
163 if (ret != 0) {
164 printk(KERN_ERR "Unable to register bus %s\n",
165 sh_bus_types[i].name);
166 device_unregister(&sh_bus_devices[i]);
167 }
168 }
169
170 printk(KERN_INFO "SH Virtual Bus initialized\n");
171
172 return ret;
173}
174
175static void __exit sh_bus_exit(void)
176{
177 int i;
178
179 for (i = 0; i < SH_NR_BUSES; i++) {
180 bus_unregister(&sh_bus_types[i]);
181 device_unregister(&sh_bus_devices[i]);
182 }
183}
184
185module_init(sh_bus_init);
186module_exit(sh_bus_exit);
187
188MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
189MODULE_DESCRIPTION("SH Virtual Bus");
190MODULE_LICENSE("GPL");
191
192EXPORT_SYMBOL(sh_bus_types);
193EXPORT_SYMBOL(sh_device_register);
194EXPORT_SYMBOL(sh_device_unregister);
195EXPORT_SYMBOL(sh_driver_register);
196EXPORT_SYMBOL(sh_driver_unregister);
197
diff --git a/include/asm-sh/bus-sh.h b/include/asm-sh/bus-sh.h
deleted file mode 100644
index e42d63b65cb5..000000000000
--- a/include/asm-sh/bus-sh.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * include/asm-sh/bus-sh.h
3 *
4 * Copyright (C) 2004 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_SH_BUS_SH_H
11#define __ASM_SH_BUS_SH_H
12
13extern struct bus_type sh_bus_types[];
14
15struct sh_dev {
16 struct device dev;
17 char *name;
18 unsigned int dev_id;
19 unsigned int bus_id;
20 struct resource res;
21 void *mapbase;
22 unsigned int irq[6];
23 u64 *dma_mask;
24 u64 coherent_dma_mask;
25};
26
27#define to_sh_dev(d) container_of((d), struct sh_dev, dev)
28
29#define sh_get_drvdata(d) dev_get_drvdata(&(d)->dev)
30#define sh_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
31
32struct sh_driver {
33 struct device_driver drv;
34 unsigned int dev_id;
35 unsigned int bus_id;
36 int (*probe)(struct sh_dev *);
37 int (*remove)(struct sh_dev *);
38 int (*suspend)(struct sh_dev *, pm_message_t);
39 int (*resume)(struct sh_dev *);
40};
41
42#define to_sh_driver(d) container_of((d), struct sh_driver, drv)
43#define sh_name(d) ((d)->dev.driver->name)
44
45/*
46 * Device ID numbers for bus types
47 */
48enum {
49 SH_DEV_ID_USB_OHCI,
50};
51
52#define SH_NR_BUSES 1
53#define SH_BUS_NAME_VIRT "shbus"
54
55enum {
56 SH_BUS_VIRT,
57};
58
59/* arch/sh/kernel/cpu/bus.c */
60extern int sh_device_register(struct sh_dev *dev);
61extern void sh_device_unregister(struct sh_dev *dev);
62extern int sh_driver_register(struct sh_driver *drv);
63extern void sh_driver_unregister(struct sh_driver *drv);
64
65#endif /* __ASM_SH_BUS_SH_H */
66