30 #include <linux/slab.h>
31 #include <linux/types.h>
32 #include <linux/kernel.h>
33 #include <linux/pci.h>
35 #include <linux/string.h>
36 #include <linux/export.h>
46 static struct device root = {
47 .init_name =
"parisc",
50 static inline int check_dev(
struct device *
dev)
68 static int descend_children(
struct device * dev,
void *
data)
72 if (recurse_data->
fn(dev, recurse_data->
obj))
88 static int for_each_padev(
int (*
fn)(
struct device *,
void *),
void *
data)
124 static int parisc_driver_probe(
struct device *dev)
130 rc = pa_drv->
probe(pa_dev);
138 static int parisc_driver_remove(
struct device *dev)
157 if(driver->
drv.name) {
159 "BUG: skipping previously registered driver %s\n",
164 if (!driver->
probe) {
166 "BUG: driver %s has no probe routine\n",
177 driver->
drv.name = driver->
name;
189 static int match_and_count(
struct device * dev,
void *
data)
194 if (check_dev(dev)) {
195 if (match_device(m->
driver, pdev))
215 for_each_padev(match_and_count, &m);
238 static int find_device(
struct device * dev,
void *
data)
243 if (check_dev(dev)) {
244 if (pdev->
hpa.start == d->
hpa) {
259 ret = for_each_padev(find_device, &d);
275 while (dev != &root) {
277 if (candidate->
id.hw_type == type)
286 static inline int is_pci_dev(
struct device *dev)
291 static inline int is_pci_dev(
struct device *dev)
309 if (is_pci_dev(dev)) {
316 while (dev != &root) {
317 if (is_pci_dev(dev)) {
327 static char *print_hwpath(
struct hardware_path *path,
char *output)
330 for (i = 0; i < 6; i++) {
331 if (path->
bc[i] == -1)
333 output +=
sprintf(output,
"%u/", (
unsigned char) path->
bc[i]);
335 output +=
sprintf(output,
"%u", (
unsigned char) path->
mod);
352 get_node_path(dev->
dev.parent, &path);
354 return print_hwpath(&path, output);
358 #if defined(CONFIG_PCI) || defined(CONFIG_ISA)
370 get_node_path(&pdev->
dev, path);
388 return print_hwpath(&path, output);
401 get_node_path(padev->
dev.parent, &path);
403 for (i = 0; i < 6; i++) {
404 if (path.
bc[i] == -1)
406 output +=
sprintf(output,
"%u:", (
unsigned char) path.
bc[i]);
421 dev->
dev.parent = parent;
443 static int match_by_id(
struct device * dev,
void *
data)
477 struct device *parent = &root;
478 for (i = 0; i < 6; i++) {
479 if (modpath->
bc[i] == -1)
481 parent = &alloc_tree_node(parent, modpath->
bc[i])->dev;
483 return alloc_tree_node(parent, modpath->
mod);
496 if (find_device_by_addr(hpa) !=
NULL)
503 dev = create_parisc_device(mod_path);
506 "IODC data for second device: "
507 "%02x%02x%02x%02x%02x%02x\n"
508 "Rearranging GSC cards sometimes helps\n",
509 parisc_pathname(dev), iodc_data[0], iodc_data[1],
510 iodc_data[3], iodc_data[4], iodc_data[5], iodc_data[6]);
514 dev->
id.hw_type = iodc_data[3] & 0x1f;
515 dev->
id.hversion = (iodc_data[0] << 4) | ((iodc_data[1] & 0xf0) >> 4);
516 dev->
id.hversion_rev = iodc_data[1] & 0x0f;
517 dev->
id.sversion = ((iodc_data[4] & 0x0f) << 16) |
518 (iodc_data[5] << 8) | iodc_data[6];
519 dev->
hpa.name = parisc_pathname(dev);
525 if (hpa == 0xf4000000 || hpa == 0xf8000000) {
526 dev->
hpa.end = hpa + 0x03ffffff;
527 }
else if (hpa == 0xf6000000 || hpa == 0xfa000000) {
528 dev->
hpa.end = hpa + 0x01ffffff;
530 dev->
hpa.end = hpa + 0xfff;
542 printk(
"Unable to claim HPA %lx for device %s\n",
558 return sprintf(buf,
"parisc:t%02Xhv%04Xrev%02Xsv%08X\n",
578 make_modalias(dev, modalias);
585 #define pa_dev_attr(name, field, format_string) \
586 static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \
588 struct parisc_device *padev = to_parisc_device(dev); \
589 return sprintf(buf, format_string, padev->field); \
592 #define pa_dev_attr_id(field, format) pa_dev_attr(field, id.field, format)
602 return make_modalias(dev, buf);
617 .match = parisc_generic_match,
618 .uevent = parisc_uevent,
619 .dev_attrs = parisc_device_attrs,
620 .probe = parisc_driver_probe,
621 .remove = parisc_driver_remove,
650 static int match_pci_device(
struct device *dev,
int index,
659 return ((modpath->
bc[5] ==
PCI_SLOT(devfn)) &&
664 return (modpath->
bc[index] ==
id);
675 static int match_parisc_device(
struct device *dev,
int index,
679 char id = (index == 6) ? modpath->
mod : modpath->
bc[index];
690 static int check_parent(
struct device * dev,
void *
data)
694 if (check_dev(dev)) {
695 if (dev->
bus == &parisc_bus_type) {
698 }
else if (is_pci_dev(dev)) {
748 struct device *parent = &root;
749 for (i = 0; i < 6; i++) {
750 if (modpath->
bc[i] == -1)
752 parent = parse_tree_node(parent, i, modpath);
756 if (is_pci_dev(parent))
759 return parse_tree_node(parent, 6, modpath);
771 if (dev->
bus == &parisc_bus_type) {
773 get_node_path(dev->
parent, path);
775 }
else if (is_pci_dev(dev)) {
776 get_node_path(dev, path);
781 #define BC_PORT_MASK 0x8
782 #define BC_LOWER_PORT 0x8
784 #define BUS_CONVERTER(dev) \
785 ((dev->id.hw_type == HPHW_IOA) || (dev->id.hw_type == HPHW_BCPORT))
787 #define IS_LOWER_PORT(dev) \
788 ((gsc_readl(dev->hpa.start + offsetof(struct bc_module, io_status)) \
789 & BC_PORT_MASK) == BC_LOWER_PORT)
791 #define MAX_NATIVE_DEVICES 64
792 #define NATIVE_DEVICE_OFFSET 0x1000
794 #define FLEX_MASK F_EXTEND(0xfffc0000)
795 #define IO_IO_LOW offsetof(struct bc_module, io_io_low)
796 #define IO_IO_HIGH offsetof(struct bc_module, io_io_high)
797 #define READ_IO_IO_LOW(dev) (unsigned long)(signed int)gsc_readl(dev->hpa.start + IO_IO_LOW)
798 #define READ_IO_IO_HIGH(dev) (unsigned long)(signed int)gsc_readl(dev->hpa.start + IO_IO_HIGH)
800 static void walk_native_bus(
unsigned long io_io_low,
unsigned long io_io_high,
805 unsigned long io_io_low, io_io_high;
818 walk_native_bus(io_io_low, io_io_high, &dev->
dev);
833 static void walk_native_bus(
unsigned long io_io_low,
unsigned long io_io_high,
836 int i, devices_found = 0;
837 unsigned long hpa = io_io_low;
840 get_node_path(parent, &path);
846 dev = find_device_by_addr(hpa);
858 }
while(!devices_found && hpa < io_io_high);
861 #define CENTRAL_BUS_ADDR F_EXTEND(0xfff80000)
883 ++count, dev->
name, (
void*) dev->
hpa.start, hw_path, dev->
id.hw_type,
884 dev->
id.hversion_rev, dev->
id.hversion, dev->
id.sversion);
888 printk(
", additional addresses: ");
901 panic(
"Could not register PA-RISC bus type\n");
903 panic(
"Could not register PA-RISC root device\n");
908 static int print_one_device(
struct device * dev,
void *
data)
913 print_parisc_device(pdev);
922 for_each_padev(print_one_device,
NULL);