blob: 87d396e28db2f8c1dc359918e970f33c98a66777 [file] [log] [blame]
Heiko J Schickd7a30102005-11-16 08:56:43 +01001/*
2 * IBM PowerPC eBus Infrastructure Support.
3 *
4 * Copyright (c) 2005 IBM Corporation
Joachim Fenkes6bccf752007-03-09 19:00:32 +01005 * Joachim Fenkes <fenkes@de.ibm.com>
Heiko J Schickd7a30102005-11-16 08:56:43 +01006 * Heiko J Schick <schickhj@de.ibm.com>
Joachim Fenkesa8308802007-03-09 18:56:46 +01007 *
Heiko J Schickd7a30102005-11-16 08:56:43 +01008 * All rights reserved.
9 *
Joachim Fenkesa8308802007-03-09 18:56:46 +010010 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
11 * BSD.
Heiko J Schickd7a30102005-11-16 08:56:43 +010012 *
13 * OpenIB BSD License
14 *
Joachim Fenkesa8308802007-03-09 18:56:46 +010015 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
Heiko J Schickd7a30102005-11-16 08:56:43 +010017 *
Joachim Fenkesa8308802007-03-09 18:56:46 +010018 * Redistributions of source code must retain the above copyright notice, this
19 * list of conditions and the following disclaimer.
Heiko J Schickd7a30102005-11-16 08:56:43 +010020 *
Joachim Fenkesa8308802007-03-09 18:56:46 +010021 * Redistributions in binary form must reproduce the above copyright notice,
22 * this list of conditions and the following disclaimer in the documentation
Heiko J Schickd7a30102005-11-16 08:56:43 +010023 * and/or other materials
Joachim Fenkesa8308802007-03-09 18:56:46 +010024 * provided with the distribution.
Heiko J Schickd7a30102005-11-16 08:56:43 +010025 *
Joachim Fenkesa8308802007-03-09 18:56:46 +010026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Heiko J Schickd7a30102005-11-16 08:56:43 +010032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
33 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
Joachim Fenkesa8308802007-03-09 18:56:46 +010034 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Heiko J Schickd7a30102005-11-16 08:56:43 +010036 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _ASM_EBUS_H
40#define _ASM_EBUS_H
Arnd Bergmann88ced032005-12-16 22:43:46 +010041#ifdef __KERNEL__
Heiko J Schickd7a30102005-11-16 08:56:43 +010042
43#include <linux/device.h>
44#include <linux/interrupt.h>
45#include <linux/mod_devicetable.h>
46#include <asm/of_device.h>
47
Heiko J Schickd7a30102005-11-16 08:56:43 +010048extern struct bus_type ibmebus_bus_type;
49
Joachim Fenkesa8308802007-03-09 18:56:46 +010050struct ibmebus_dev {
Heiko J Schickd7a30102005-11-16 08:56:43 +010051 struct of_device ofdev;
52};
53
Joachim Fenkesa8308802007-03-09 18:56:46 +010054struct ibmebus_driver {
Heiko J Schickd7a30102005-11-16 08:56:43 +010055 char *name;
56 struct of_device_id *id_table;
57 int (*probe) (struct ibmebus_dev *dev, const struct of_device_id *id);
58 int (*remove) (struct ibmebus_dev *dev);
59 struct device_driver driver;
60};
61
62int ibmebus_register_driver(struct ibmebus_driver *drv);
63void ibmebus_unregister_driver(struct ibmebus_driver *drv);
64
65int ibmebus_request_irq(struct ibmebus_dev *dev,
Joachim Fenkesa8308802007-03-09 18:56:46 +010066 u32 ist,
David Howells40220c12006-10-09 12:19:47 +010067 irq_handler_t handler,
Heiko J Schickd7a30102005-11-16 08:56:43 +010068 unsigned long irq_flags, const char * devname,
69 void *dev_id);
70void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id);
71
72static inline struct ibmebus_driver *to_ibmebus_driver(struct device_driver *drv)
73{
74 return container_of(drv, struct ibmebus_driver, driver);
75}
76
77static inline struct ibmebus_dev *to_ibmebus_dev(struct device *dev)
78{
79 return container_of(dev, struct ibmebus_dev, ofdev.dev);
80}
81
82
Arnd Bergmann88ced032005-12-16 22:43:46 +010083#endif /* __KERNEL__ */
Heiko J Schickd7a30102005-11-16 08:56:43 +010084#endif /* _ASM_IBMEBUS_H */