Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
63a79fa5
Commit
63a79fa5
authored
Aug 24, 2003
by
Benjamin Herrenschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update OF platform & macio driver cores to adapt to device
model changes. Fix refcounting
parent
394edd85
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
216 additions
and
121 deletions
+216
-121
arch/ppc/syslib/of_device.c
arch/ppc/syslib/of_device.c
+70
-45
drivers/macintosh/macio_asic.c
drivers/macintosh/macio_asic.c
+135
-72
include/asm-ppc/macio.h
include/asm-ppc/macio.h
+5
-2
include/asm-ppc/of_device.h
include/asm-ppc/of_device.h
+6
-2
No files found.
arch/ppc/syslib/of_device.c
View file @
63a79fa5
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
* Used by a driver to check whether an of_device present in the
* Used by a driver to check whether an of_device present in the
* system is in its list of supported devices.
* system is in its list of supported devices.
*/
*/
const
struct
of_match
*
const
struct
of_match
*
of_match_device
(
const
struct
of_match
*
matches
,
of_match_device
(
const
struct
of_match
*
matches
,
const
struct
of_device
*
dev
)
const
struct
of_device
*
dev
)
{
{
if
(
!
dev
->
node
)
if
(
!
dev
->
node
)
return
NULL
;
return
NULL
;
...
@@ -38,8 +38,7 @@ of_match_device(const struct of_match *matches, const struct of_device *dev)
...
@@ -38,8 +38,7 @@ of_match_device(const struct of_match *matches, const struct of_device *dev)
return
NULL
;
return
NULL
;
}
}
static
int
static
int
of_platform_bus_match
(
struct
device
*
dev
,
struct
device_driver
*
drv
)
of_platform_bus_match
(
struct
device
*
dev
,
struct
device_driver
*
drv
)
{
{
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_platform_driver
*
of_drv
=
to_of_platform_driver
(
drv
);
struct
of_platform_driver
*
of_drv
=
to_of_platform_driver
(
drv
);
...
@@ -51,21 +50,27 @@ of_platform_bus_match(struct device *dev, struct device_driver *drv)
...
@@ -51,21 +50,27 @@ of_platform_bus_match(struct device *dev, struct device_driver *drv)
return
of_match_device
(
matches
,
of_dev
)
!=
NULL
;
return
of_match_device
(
matches
,
of_dev
)
!=
NULL
;
}
}
struct
bus_type
of_platform_bus_type
=
{
struct
of_device
*
of_dev_get
(
struct
of_device
*
dev
)
name:
"of_platform"
,
{
match:
of_platform_bus_match
,
struct
device
*
tmp
;
};
if
(
!
dev
)
return
NULL
;
tmp
=
get_device
(
&
dev
->
dev
);
if
(
tmp
)
return
to_of_device
(
tmp
);
else
return
NULL
;
}
static
int
__init
void
of_dev_put
(
struct
of_device
*
dev
)
of_bus_driver_init
(
void
)
{
{
return
bus_register
(
&
of_platform_bus_type
);
if
(
dev
)
put_device
(
&
dev
->
dev
);
}
}
postcore_initcall
(
of_bus_driver_init
);
static
int
static
int
of_device_probe
(
struct
device
*
dev
)
of_device_probe
(
struct
device
*
dev
)
{
{
int
error
=
-
ENODEV
;
int
error
=
-
ENODEV
;
struct
of_platform_driver
*
drv
;
struct
of_platform_driver
*
drv
;
...
@@ -78,22 +83,18 @@ of_device_probe(struct device *dev)
...
@@ -78,22 +83,18 @@ of_device_probe(struct device *dev)
if
(
!
drv
->
probe
)
if
(
!
drv
->
probe
)
return
error
;
return
error
;
/* if (!try_module_get(driver->owner)) {
of_dev_get
(
of_dev
);
printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
return error;
}
*/
match
=
of_match_device
(
drv
->
match_table
,
of_dev
);
match
=
of_match_device
(
drv
->
match_table
,
of_dev
);
if
(
match
)
if
(
match
)
error
=
drv
->
probe
(
of_dev
,
match
);
error
=
drv
->
probe
(
of_dev
,
match
);
/*
if
(
error
)
module_put(driver->owner
);
of_dev_put
(
of_dev
);
*/
return
error
;
return
error
;
}
}
static
int
static
int
of_device_remove
(
struct
device
*
dev
)
of_device_remove
(
struct
device
*
dev
)
{
{
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_platform_driver
*
drv
=
to_of_platform_driver
(
of_dev
->
dev
.
driver
);
struct
of_platform_driver
*
drv
=
to_of_platform_driver
(
of_dev
->
dev
.
driver
);
...
@@ -103,32 +104,43 @@ of_device_remove(struct device *dev)
...
@@ -103,32 +104,43 @@ of_device_remove(struct device *dev)
return
0
;
return
0
;
}
}
static
int
static
int
of_device_suspend
(
struct
device
*
dev
,
u32
state
)
of_device_suspend
(
struct
device
*
dev
,
u32
state
,
u32
level
)
{
{
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_platform_driver
*
drv
=
to_of_platform_driver
(
of_dev
->
dev
.
driver
);
struct
of_platform_driver
*
drv
=
to_of_platform_driver
(
of_dev
->
dev
.
driver
);
int
error
=
0
;
int
error
=
0
;
if
(
drv
&&
drv
->
suspend
)
if
(
drv
&&
drv
->
suspend
)
error
=
drv
->
suspend
(
of_dev
,
state
,
level
);
error
=
drv
->
suspend
(
of_dev
,
state
);
return
error
;
return
error
;
}
}
static
int
static
int
of_device_resume
(
struct
device
*
dev
)
of_device_resume
(
struct
device
*
dev
,
u32
level
)
{
{
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_device
*
of_dev
=
to_of_device
(
dev
);
struct
of_platform_driver
*
drv
=
to_of_platform_driver
(
of_dev
->
dev
.
driver
);
struct
of_platform_driver
*
drv
=
to_of_platform_driver
(
of_dev
->
dev
.
driver
);
int
error
=
0
;
int
error
=
0
;
if
(
drv
&&
drv
->
resume
)
if
(
drv
&&
drv
->
resume
)
error
=
drv
->
resume
(
of_dev
,
level
);
error
=
drv
->
resume
(
of_dev
);
return
error
;
return
error
;
}
}
int
struct
bus_type
of_platform_bus_type
=
{
of_register_driver
(
struct
of_platform_driver
*
drv
)
name:
"of_platform"
,
match:
of_platform_bus_match
,
suspend:
of_device_suspend
,
resume:
of_device_resume
,
};
static
int
__init
of_bus_driver_init
(
void
)
{
return
bus_register
(
&
of_platform_bus_type
);
}
postcore_initcall
(
of_bus_driver_init
);
int
of_register_driver
(
struct
of_platform_driver
*
drv
)
{
{
int
count
=
0
;
int
count
=
0
;
...
@@ -136,8 +148,6 @@ of_register_driver(struct of_platform_driver *drv)
...
@@ -136,8 +148,6 @@ of_register_driver(struct of_platform_driver *drv)
drv
->
driver
.
name
=
drv
->
name
;
drv
->
driver
.
name
=
drv
->
name
;
drv
->
driver
.
bus
=
&
of_platform_bus_type
;
drv
->
driver
.
bus
=
&
of_platform_bus_type
;
drv
->
driver
.
probe
=
of_device_probe
;
drv
->
driver
.
probe
=
of_device_probe
;
drv
->
driver
.
resume
=
of_device_resume
;
drv
->
driver
.
suspend
=
of_device_suspend
;
drv
->
driver
.
remove
=
of_device_remove
;
drv
->
driver
.
remove
=
of_device_remove
;
/* register with core */
/* register with core */
...
@@ -145,15 +155,13 @@ of_register_driver(struct of_platform_driver *drv)
...
@@ -145,15 +155,13 @@ of_register_driver(struct of_platform_driver *drv)
return
count
?
count
:
1
;
return
count
?
count
:
1
;
}
}
void
void
of_unregister_driver
(
struct
of_platform_driver
*
drv
)
of_unregister_driver
(
struct
of_platform_driver
*
drv
)
{
{
driver_unregister
(
&
drv
->
driver
);
driver_unregister
(
&
drv
->
driver
);
}
}
static
ssize_t
static
ssize_t
dev_show_devspec
(
struct
device
*
dev
,
char
*
buf
)
dev_show_devspec
(
struct
device
*
dev
,
char
*
buf
)
{
{
struct
of_device
*
ofdev
;
struct
of_device
*
ofdev
;
...
@@ -163,8 +171,22 @@ dev_show_devspec(struct device *dev, char *buf)
...
@@ -163,8 +171,22 @@ dev_show_devspec(struct device *dev, char *buf)
static
DEVICE_ATTR
(
devspec
,
S_IRUGO
,
dev_show_devspec
,
NULL
);
static
DEVICE_ATTR
(
devspec
,
S_IRUGO
,
dev_show_devspec
,
NULL
);
int
/**
of_device_register
(
struct
of_device
*
ofdev
)
* of_release_dev - free an of device structure when all users of it are finished.
* @dev: device that's been disconnected
*
* Will be called only by the device core when all users of this of device are
* done.
*/
void
of_release_dev
(
struct
device
*
dev
)
{
struct
of_device
*
ofdev
;
ofdev
=
to_of_device
(
dev
);
kfree
(
ofdev
);
}
int
of_device_register
(
struct
of_device
*
ofdev
)
{
{
int
rc
;
int
rc
;
struct
of_device
**
odprop
;
struct
of_device
**
odprop
;
...
@@ -197,21 +219,20 @@ of_device_register(struct of_device *ofdev)
...
@@ -197,21 +219,20 @@ of_device_register(struct of_device *ofdev)
return
0
;
return
0
;
}
}
void
void
of_device_unregister
(
struct
of_device
*
ofdev
)
of_device_unregister
(
struct
of_device
*
ofdev
)
{
{
struct
of_device
**
odprop
;
struct
of_device
**
odprop
;
device_remove_file
(
&
ofdev
->
dev
,
&
dev_attr_devspec
);
device_remove_file
(
&
ofdev
->
dev
,
&
dev_attr_devspec
);
device_unregister
(
&
ofdev
->
dev
);
odprop
=
(
struct
of_device
**
)
get_property
(
ofdev
->
node
,
"linux,device"
,
NULL
);
odprop
=
(
struct
of_device
**
)
get_property
(
ofdev
->
node
,
"linux,device"
,
NULL
);
if
(
odprop
)
if
(
odprop
)
*
odprop
=
NULL
;
*
odprop
=
NULL
;
device_unregister
(
&
ofdev
->
dev
);
}
}
struct
of_device
*
struct
of_device
*
of_platform_device_create
(
struct
device_node
*
np
,
const
char
*
bus_id
)
of_platform_device_create
(
struct
device_node
*
np
,
const
char
*
bus_id
)
{
{
struct
of_device
*
dev
;
struct
of_device
*
dev
;
u32
*
reg
;
u32
*
reg
;
...
@@ -226,6 +247,7 @@ of_platform_device_create(struct device_node *np, const char *bus_id)
...
@@ -226,6 +247,7 @@ of_platform_device_create(struct device_node *np, const char *bus_id)
dev
->
dev
.
dma_mask
=
&
dev
->
dma_mask
;
dev
->
dev
.
dma_mask
=
&
dev
->
dma_mask
;
dev
->
dev
.
parent
=
NULL
;
dev
->
dev
.
parent
=
NULL
;
dev
->
dev
.
bus
=
&
of_platform_bus_type
;
dev
->
dev
.
bus
=
&
of_platform_bus_type
;
dev
->
dev
.
release
=
of_release_dev
;
reg
=
(
u32
*
)
get_property
(
np
,
"reg"
,
NULL
);
reg
=
(
u32
*
)
get_property
(
np
,
"reg"
,
NULL
);
strlcpy
(
dev
->
dev
.
bus_id
,
bus_id
,
BUS_ID_SIZE
);
strlcpy
(
dev
->
dev
.
bus_id
,
bus_id
,
BUS_ID_SIZE
);
...
@@ -244,4 +266,7 @@ EXPORT_SYMBOL(of_register_driver);
...
@@ -244,4 +266,7 @@ EXPORT_SYMBOL(of_register_driver);
EXPORT_SYMBOL
(
of_unregister_driver
);
EXPORT_SYMBOL
(
of_unregister_driver
);
EXPORT_SYMBOL
(
of_device_register
);
EXPORT_SYMBOL
(
of_device_register
);
EXPORT_SYMBOL
(
of_device_unregister
);
EXPORT_SYMBOL
(
of_device_unregister
);
EXPORT_SYMBOL
(
of_dev_get
);
EXPORT_SYMBOL
(
of_dev_put
);
EXPORT_SYMBOL
(
of_platform_device_create
);
EXPORT_SYMBOL
(
of_platform_device_create
);
EXPORT_SYMBOL
(
of_release_dev
);
drivers/macintosh/macio_asic.c
View file @
63a79fa5
...
@@ -23,6 +23,8 @@
...
@@ -23,6 +23,8 @@
#include <asm/prom.h>
#include <asm/prom.h>
#include <asm/pci-bridge.h>
#include <asm/pci-bridge.h>
static
struct
macio_chip
*
macio_on_hold
;
static
int
static
int
macio_bus_match
(
struct
device
*
dev
,
struct
device_driver
*
drv
)
macio_bus_match
(
struct
device
*
dev
,
struct
device_driver
*
drv
)
{
{
...
@@ -36,21 +38,27 @@ macio_bus_match(struct device *dev, struct device_driver *drv)
...
@@ -36,21 +38,27 @@ macio_bus_match(struct device *dev, struct device_driver *drv)
return
of_match_device
(
matches
,
&
macio_dev
->
ofdev
)
!=
NULL
;
return
of_match_device
(
matches
,
&
macio_dev
->
ofdev
)
!=
NULL
;
}
}
struct
bus_type
macio_bus_type
=
{
struct
macio_dev
*
macio_dev_get
(
struct
macio_dev
*
dev
)
name:
"macio"
,
{
match:
macio_bus_match
,
struct
device
*
tmp
;
};
static
int
__init
if
(
!
dev
)
macio_bus_driver_init
(
void
)
return
NULL
;
tmp
=
get_device
(
&
dev
->
ofdev
.
dev
);
if
(
tmp
)
return
to_macio_device
(
tmp
);
else
return
NULL
;
}
void
macio_dev_put
(
struct
macio_dev
*
dev
)
{
{
return
bus_register
(
&
macio_bus_type
);
if
(
dev
)
put_device
(
&
dev
->
ofdev
.
dev
);
}
}
postcore_initcall
(
macio_bus_driver_init
);
static
int
static
int
macio_device_probe
(
struct
device
*
dev
)
macio_device_probe
(
struct
device
*
dev
)
{
{
int
error
=
-
ENODEV
;
int
error
=
-
ENODEV
;
struct
macio_driver
*
drv
;
struct
macio_driver
*
drv
;
...
@@ -63,55 +71,89 @@ macio_device_probe(struct device *dev)
...
@@ -63,55 +71,89 @@ macio_device_probe(struct device *dev)
if
(
!
drv
->
probe
)
if
(
!
drv
->
probe
)
return
error
;
return
error
;
/* if (!try_module_get(driver->owner)) {
macio_dev_get
(
macio_dev
);
printk(KERN_ERR "Can't get a module reference for %s\n", driver->name);
return error;
}
*/
match
=
of_match_device
(
drv
->
match_table
,
&
macio_dev
->
ofdev
);
match
=
of_match_device
(
drv
->
match_table
,
&
macio_dev
->
ofdev
);
if
(
match
)
if
(
match
)
error
=
drv
->
probe
(
macio_dev
,
match
);
error
=
drv
->
probe
(
macio_dev
,
match
);
/*
if
(
error
)
module_put(driver->owner
);
macio_dev_put
(
macio_dev
);
*/
return
error
;
return
error
;
}
}
static
int
static
int
macio_device_remove
(
struct
device
*
dev
)
macio_device_remove
(
struct
device
*
dev
)
{
{
struct
macio_dev
*
macio_dev
=
to_macio_device
(
dev
);
struct
macio_dev
*
macio_dev
=
to_macio_device
(
dev
);
struct
macio_driver
*
drv
=
to_macio_driver
(
macio_dev
->
ofdev
.
dev
.
driver
);
struct
macio_driver
*
drv
=
to_macio_driver
(
macio_dev
->
ofdev
.
dev
.
driver
);
if
(
drv
&&
drv
->
remove
)
if
(
drv
&&
drv
->
remove
)
drv
->
remove
(
macio_dev
);
drv
->
remove
(
macio_dev
);
macio_dev_put
(
macio_dev
);
return
0
;
return
0
;
}
}
static
int
static
int
macio_device_suspend
(
struct
device
*
dev
,
u32
state
)
macio_device_suspend
(
struct
device
*
dev
,
u32
state
,
u32
level
)
{
{
struct
macio_dev
*
macio_dev
=
to_macio_device
(
dev
);
struct
macio_dev
*
macio_dev
=
to_macio_device
(
dev
);
struct
macio_driver
*
drv
=
to_macio_driver
(
macio_dev
->
ofdev
.
dev
.
driver
)
;
struct
macio_driver
*
drv
;
int
error
=
0
;
int
error
=
0
;
if
(
drv
&&
drv
->
suspend
)
if
(
macio_dev
->
ofdev
.
dev
.
driver
==
NULL
)
error
=
drv
->
suspend
(
macio_dev
,
state
,
level
);
return
0
;
drv
=
to_macio_driver
(
macio_dev
->
ofdev
.
dev
.
driver
);
if
(
drv
->
suspend
)
error
=
drv
->
suspend
(
macio_dev
,
state
);
return
error
;
return
error
;
}
}
static
int
static
int
macio_device_resume
(
struct
device
*
dev
)
macio_device_resume
(
struct
device
*
dev
,
u32
level
)
{
{
struct
macio_dev
*
macio_dev
=
to_macio_device
(
dev
);
struct
macio_dev
*
macio_dev
=
to_macio_device
(
dev
);
struct
macio_driver
*
drv
=
to_macio_driver
(
macio_dev
->
ofdev
.
dev
.
driver
)
;
struct
macio_driver
*
drv
;
int
error
=
0
;
int
error
=
0
;
if
(
drv
&&
drv
->
resume
)
if
(
macio_dev
->
ofdev
.
dev
.
driver
==
NULL
)
error
=
drv
->
resume
(
macio_dev
,
level
);
return
0
;
drv
=
to_macio_driver
(
macio_dev
->
ofdev
.
dev
.
driver
);
if
(
drv
->
resume
)
error
=
drv
->
resume
(
macio_dev
);
return
error
;
return
error
;
}
}
struct
bus_type
macio_bus_type
=
{
name:
"macio"
,
match:
macio_bus_match
,
suspend:
macio_device_suspend
,
resume:
macio_device_resume
,
};
static
int
__init
macio_bus_driver_init
(
void
)
{
return
bus_register
(
&
macio_bus_type
);
}
postcore_initcall
(
macio_bus_driver_init
);
/**
* macio_release_dev - free a macio device structure when all users of it are finished.
* @dev: device that's been disconnected
*
* Will be called only by the device core when all users of this macio device are
* done. This currently means never as we don't hot remove any macio device yet,
* though that will happen with mediabay based devices in a later implementation.
*/
static
void
macio_release_dev
(
struct
device
*
dev
)
{
struct
macio_dev
*
mdev
;
mdev
=
to_macio_device
(
dev
);
kfree
(
mdev
);
}
/**
/**
* macio_add_one_device - Add one device from OF node to the device tree
* macio_add_one_device - Add one device from OF node to the device tree
* @chip: pointer to the macio_chip holding the device
* @chip: pointer to the macio_chip holding the device
...
@@ -121,13 +163,15 @@ macio_device_resume(struct device * dev, u32 level)
...
@@ -121,13 +163,15 @@ macio_device_resume(struct device * dev, u32 level)
* When media-bay is changed to hotswap drivers, this function will
* When media-bay is changed to hotswap drivers, this function will
* be exposed to the bay driver some way...
* be exposed to the bay driver some way...
*/
*/
static
struct
macio_dev
*
static
struct
macio_dev
*
macio_add_one_device
(
struct
macio_chip
*
chip
,
struct
device
*
parent
,
macio_add_one_device
(
struct
macio_chip
*
chip
,
struct
device
*
parent
,
struct
device_node
*
np
,
struct
macio_dev
*
in_bay
)
struct
device_node
*
np
,
struct
macio_dev
*
in_bay
)
{
{
struct
macio_dev
*
dev
;
struct
macio_dev
*
dev
;
u32
*
reg
;
u32
*
reg
;
if
(
np
==
NULL
)
return
NULL
;
dev
=
kmalloc
(
sizeof
(
*
dev
),
GFP_KERNEL
);
dev
=
kmalloc
(
sizeof
(
*
dev
),
GFP_KERNEL
);
if
(
!
dev
)
if
(
!
dev
)
return
NULL
;
return
NULL
;
...
@@ -140,6 +184,7 @@ macio_add_one_device(struct macio_chip *chip, struct device *parent,
...
@@ -140,6 +184,7 @@ macio_add_one_device(struct macio_chip *chip, struct device *parent,
dev
->
ofdev
.
dev
.
dma_mask
=
&
dev
->
ofdev
.
dma_mask
;
dev
->
ofdev
.
dev
.
dma_mask
=
&
dev
->
ofdev
.
dma_mask
;
dev
->
ofdev
.
dev
.
parent
=
parent
;
dev
->
ofdev
.
dev
.
parent
=
parent
;
dev
->
ofdev
.
dev
.
bus
=
&
macio_bus_type
;
dev
->
ofdev
.
dev
.
bus
=
&
macio_bus_type
;
dev
->
ofdev
.
dev
.
release
=
macio_release_dev
;
/* MacIO itself has a different reg, we use it's PCI base */
/* MacIO itself has a different reg, we use it's PCI base */
if
(
np
==
chip
->
of_node
)
{
if
(
np
==
chip
->
of_node
)
{
...
@@ -164,8 +209,7 @@ macio_add_one_device(struct macio_chip *chip, struct device *parent,
...
@@ -164,8 +209,7 @@ macio_add_one_device(struct macio_chip *chip, struct device *parent,
return
dev
;
return
dev
;
}
}
static
int
static
int
macio_skip_device
(
struct
device_node
*
np
)
macio_skip_device
(
struct
device_node
*
np
)
{
{
if
(
strncmp
(
np
->
name
,
"battery"
,
7
)
==
0
)
if
(
strncmp
(
np
->
name
,
"battery"
,
7
)
==
0
)
return
1
;
return
1
;
...
@@ -185,10 +229,9 @@ macio_skip_device(struct device_node *np)
...
@@ -185,10 +229,9 @@ macio_skip_device(struct device_node *np)
* For now, childs of media-bay are added now as well. This will
* For now, childs of media-bay are added now as well. This will
* change rsn though.
* change rsn though.
*/
*/
static
void
static
void
macio_pci_add_devices
(
struct
macio_chip
*
chip
)
macio_pci_add_devices
(
struct
macio_chip
*
chip
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
,
*
pnode
;
struct
macio_dev
*
rdev
,
*
mdev
,
*
mbdev
=
NULL
,
*
sdev
=
NULL
;
struct
macio_dev
*
rdev
,
*
mdev
,
*
mbdev
=
NULL
,
*
sdev
=
NULL
;
struct
device
*
parent
=
NULL
;
struct
device
*
parent
=
NULL
;
...
@@ -197,15 +240,22 @@ macio_pci_add_devices(struct macio_chip *chip)
...
@@ -197,15 +240,22 @@ macio_pci_add_devices(struct macio_chip *chip)
if
(
chip
->
lbus
.
pdev
)
if
(
chip
->
lbus
.
pdev
)
parent
=
&
chip
->
lbus
.
pdev
->
dev
;
parent
=
&
chip
->
lbus
.
pdev
->
dev
;
#endif
#endif
rdev
=
macio_add_one_device
(
chip
,
parent
,
chip
->
of_node
,
NULL
);
pnode
=
of_node_get
(
chip
->
of_node
);
if
(
pnode
==
NULL
)
return
;
rdev
=
macio_add_one_device
(
chip
,
parent
,
pnode
,
NULL
);
if
(
rdev
==
NULL
)
if
(
rdev
==
NULL
)
return
;
return
;
/* First scan 1st level */
/* First scan 1st level */
for
(
np
=
chip
->
of_node
->
child
;
np
!=
NULL
;
np
=
np
->
sibling
)
{
for
(
np
=
NULL
;
(
np
=
of_get_next_child
(
pnode
,
np
))
!=
NULL
;
)
{
if
(
!
macio_skip_device
(
np
))
{
if
(
!
macio_skip_device
(
np
))
{
of_node_get
(
np
);
mdev
=
macio_add_one_device
(
chip
,
&
rdev
->
ofdev
.
dev
,
np
,
NULL
);
mdev
=
macio_add_one_device
(
chip
,
&
rdev
->
ofdev
.
dev
,
np
,
NULL
);
if
(
strncmp
(
np
->
name
,
"media-bay"
,
9
)
==
0
)
if
(
mdev
==
NULL
)
of_node_put
(
np
);
else
if
(
strncmp
(
np
->
name
,
"media-bay"
,
9
)
==
0
)
mbdev
=
mdev
;
mbdev
=
mdev
;
else
if
(
strncmp
(
np
->
name
,
"escc"
,
4
)
==
0
)
else
if
(
strncmp
(
np
->
name
,
"escc"
,
4
)
==
0
)
sdev
=
mdev
;
sdev
=
mdev
;
...
@@ -213,16 +263,20 @@ macio_pci_add_devices(struct macio_chip *chip)
...
@@ -213,16 +263,20 @@ macio_pci_add_devices(struct macio_chip *chip)
}
}
/* Add media bay devices if any */
/* Add media bay devices if any */
if
(
mbdev
)
{
if
(
mbdev
)
for
(
np
=
mbdev
->
ofdev
.
node
->
child
;
np
!=
NULL
;
np
=
np
->
sibling
)
for
(
np
=
NULL
;
(
np
=
of_get_next_child
(
mbdev
->
ofdev
.
node
,
np
))
!=
NULL
;)
if
(
!
macio_skip_device
(
np
))
if
(
!
macio_skip_device
(
np
))
{
macio_add_one_device
(
chip
,
&
mbdev
->
ofdev
.
dev
,
np
,
mbdev
);
of_node_get
(
np
);
if
(
macio_add_one_device
(
chip
,
&
mbdev
->
ofdev
.
dev
,
np
,
mbdev
)
==
NULL
)
of_node_put
(
np
);
}
}
/* Add serial ports if any */
/* Add serial ports if any */
if
(
sdev
)
{
if
(
sdev
)
for
(
np
=
sdev
->
ofdev
.
node
->
child
;
np
!=
NULL
;
np
=
np
->
sibling
)
for
(
np
=
NULL
;
(
np
=
of_get_next_child
(
sdev
->
ofdev
.
node
,
np
))
!=
NULL
;)
if
(
!
macio_skip_device
(
np
))
if
(
!
macio_skip_device
(
np
))
{
macio_add_one_device
(
chip
,
&
sdev
->
ofdev
.
dev
,
np
,
NULL
);
of_node_get
(
np
);
if
(
macio_add_one_device
(
chip
,
&
sdev
->
ofdev
.
dev
,
np
,
NULL
)
==
NULL
)
of_node_put
(
np
);
}
}
}
}
...
@@ -231,8 +285,7 @@ macio_pci_add_devices(struct macio_chip *chip)
...
@@ -231,8 +285,7 @@ macio_pci_add_devices(struct macio_chip *chip)
* macio_register_driver - Registers a new MacIO device driver
* macio_register_driver - Registers a new MacIO device driver
* @drv: pointer to the driver definition structure
* @drv: pointer to the driver definition structure
*/
*/
int
int
macio_register_driver
(
struct
macio_driver
*
drv
)
macio_register_driver
(
struct
macio_driver
*
drv
)
{
{
int
count
=
0
;
int
count
=
0
;
...
@@ -240,8 +293,6 @@ macio_register_driver(struct macio_driver *drv)
...
@@ -240,8 +293,6 @@ macio_register_driver(struct macio_driver *drv)
drv
->
driver
.
name
=
drv
->
name
;
drv
->
driver
.
name
=
drv
->
name
;
drv
->
driver
.
bus
=
&
macio_bus_type
;
drv
->
driver
.
bus
=
&
macio_bus_type
;
drv
->
driver
.
probe
=
macio_device_probe
;
drv
->
driver
.
probe
=
macio_device_probe
;
drv
->
driver
.
resume
=
macio_device_resume
;
drv
->
driver
.
suspend
=
macio_device_suspend
;
drv
->
driver
.
remove
=
macio_device_remove
;
drv
->
driver
.
remove
=
macio_device_remove
;
/* register with core */
/* register with core */
...
@@ -253,16 +304,14 @@ macio_register_driver(struct macio_driver *drv)
...
@@ -253,16 +304,14 @@ macio_register_driver(struct macio_driver *drv)
* macio_unregister_driver - Unregisters a new MacIO device driver
* macio_unregister_driver - Unregisters a new MacIO device driver
* @drv: pointer to the driver definition structure
* @drv: pointer to the driver definition structure
*/
*/
void
void
macio_unregister_driver
(
struct
macio_driver
*
drv
)
macio_unregister_driver
(
struct
macio_driver
*
drv
)
{
{
driver_unregister
(
&
drv
->
driver
);
driver_unregister
(
&
drv
->
driver
);
}
}
#ifdef CONFIG_PCI
#ifdef CONFIG_PCI
static
int
__devinit
static
int
__devinit
macio_pci_probe
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
macio_pci_probe
(
struct
pci_dev
*
pdev
,
const
struct
pci_device_id
*
ent
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
struct
macio_chip
*
chip
;
struct
macio_chip
*
chip
;
...
@@ -270,19 +319,27 @@ macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
...
@@ -270,19 +319,27 @@ macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if
(
ent
->
vendor
!=
PCI_VENDOR_ID_APPLE
)
if
(
ent
->
vendor
!=
PCI_VENDOR_ID_APPLE
)
return
-
ENODEV
;
return
-
ENODEV
;
/* Note regarding refcounting: We assume pci_device_to_OF_node() is ported
* to new OF APIs and returns a node with refcount incremented. This isn't
* the case today, but on the other hand ppc32 doesn't do refcounting. This
* will have to be fixed when going to ppc64. --BenH.
*/
np
=
pci_device_to_OF_node
(
pdev
);
np
=
pci_device_to_OF_node
(
pdev
);
if
(
np
==
NULL
)
if
(
np
==
NULL
)
return
-
ENODEV
;
return
-
ENODEV
;
/* We also assume that pmac_feature will have done a get() on nodes stored
* in the macio chips array
*/
chip
=
macio_find
(
np
,
macio_unknown
);
chip
=
macio_find
(
np
,
macio_unknown
);
of_node_put
(
np
);
if
(
chip
==
NULL
)
if
(
chip
==
NULL
)
return
-
ENODEV
;
return
-
ENODEV
;
/* XXX Need locking */
/* XXX Need locking
???
*/
if
(
chip
->
lbus
.
pdev
==
NULL
)
{
if
(
chip
->
lbus
.
pdev
==
NULL
)
{
chip
->
lbus
.
pdev
=
pdev
;
chip
->
lbus
.
pdev
=
pdev
;
chip
->
lbus
.
chip
=
chip
;
chip
->
lbus
.
chip
=
chip
;
// INIT_LIST_HEAD(&chip->lbus.devices);
pci_set_drvdata
(
pdev
,
&
chip
->
lbus
);
pci_set_drvdata
(
pdev
,
&
chip
->
lbus
);
pci_set_master
(
pdev
);
pci_set_master
(
pdev
);
}
}
...
@@ -290,13 +347,28 @@ macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
...
@@ -290,13 +347,28 @@ macio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
printk
(
KERN_INFO
"MacIO PCI driver attached to %s chipset
\n
"
,
printk
(
KERN_INFO
"MacIO PCI driver attached to %s chipset
\n
"
,
chip
->
name
);
chip
->
name
);
/*
* HACK ALERT: The WallStreet PowerBook and some OHare based machines
* have 2 macio ASICs. I must probe the "main" one first or IDE ordering
* will be incorrect. So I put on "hold" the second one since it seem to
* appear first on PCI
*/
if
(
chip
->
type
==
macio_gatwick
||
chip
->
type
==
macio_ohareII
)
if
(
macio_chips
[
0
].
lbus
.
pdev
==
NULL
)
{
macio_on_hold
=
chip
;
return
0
;
}
macio_pci_add_devices
(
chip
);
macio_pci_add_devices
(
chip
);
if
(
macio_on_hold
&&
macio_chips
[
0
].
lbus
.
pdev
!=
NULL
)
{
macio_pci_add_devices
(
macio_on_hold
);
macio_on_hold
=
NULL
;
}
return
0
;
return
0
;
}
}
static
void
__devexit
static
void
__devexit
macio_pci_remove
(
struct
pci_dev
*
pdev
)
macio_pci_remove
(
struct
pci_dev
*
pdev
)
{
{
panic
(
"removing of macio-asic not supported !
\n
"
);
panic
(
"removing of macio-asic not supported !
\n
"
);
}
}
...
@@ -326,8 +398,7 @@ static struct pci_driver macio_pci_driver = {
...
@@ -326,8 +398,7 @@ static struct pci_driver macio_pci_driver = {
#endif
/* CONFIG_PCI */
#endif
/* CONFIG_PCI */
static
int
__init
static
int
__init
macio_module_init
(
void
)
macio_module_init
(
void
)
{
{
#ifdef CONFIG_PCI
#ifdef CONFIG_PCI
int
rc
;
int
rc
;
...
@@ -339,17 +410,9 @@ macio_module_init (void)
...
@@ -339,17 +410,9 @@ macio_module_init (void)
return
0
;
return
0
;
}
}
/*
static void __exit
macio_module_cleanup (void)
{
#ifdef CONFIG_PCI
pci_unregister_driver(&macio_pci_driver);
#endif
}
module_exit(macio_module_cleanup);
*/
module_init
(
macio_module_init
);
module_init
(
macio_module_init
);
EXPORT_SYMBOL
(
macio_register_driver
);
EXPORT_SYMBOL
(
macio_register_driver
);
EXPORT_SYMBOL
(
macio_unregister_driver
);
EXPORT_SYMBOL
(
macio_unregister_driver
);
EXPORT_SYMBOL
(
macio_dev_get
);
EXPORT_SYMBOL
(
macio_dev_put
);
include/asm-ppc/macio.h
View file @
63a79fa5
...
@@ -42,6 +42,9 @@ struct macio_dev
...
@@ -42,6 +42,9 @@ struct macio_dev
#define to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
#define to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
#define of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
#define of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
extern
struct
macio_dev
*
macio_dev_get
(
struct
macio_dev
*
dev
);
extern
void
macio_dev_put
(
struct
macio_dev
*
dev
);
/*
/*
* A driver for a mac-io chip based device
* A driver for a mac-io chip based device
*/
*/
...
@@ -54,8 +57,8 @@ struct macio_driver
...
@@ -54,8 +57,8 @@ struct macio_driver
int
(
*
probe
)(
struct
macio_dev
*
dev
,
const
struct
of_match
*
match
);
int
(
*
probe
)(
struct
macio_dev
*
dev
,
const
struct
of_match
*
match
);
int
(
*
remove
)(
struct
macio_dev
*
dev
);
int
(
*
remove
)(
struct
macio_dev
*
dev
);
int
(
*
suspend
)(
struct
macio_dev
*
dev
,
u32
state
,
u32
level
);
int
(
*
suspend
)(
struct
macio_dev
*
dev
,
u32
state
);
int
(
*
resume
)(
struct
macio_dev
*
dev
,
u32
level
);
int
(
*
resume
)(
struct
macio_dev
*
dev
);
int
(
*
shutdown
)(
struct
macio_dev
*
dev
);
int
(
*
shutdown
)(
struct
macio_dev
*
dev
);
struct
device_driver
driver
;
struct
device_driver
driver
;
...
...
include/asm-ppc/of_device.h
View file @
63a79fa5
...
@@ -39,6 +39,9 @@ struct of_match
...
@@ -39,6 +39,9 @@ struct of_match
extern
const
struct
of_match
*
of_match_device
(
extern
const
struct
of_match
*
of_match_device
(
const
struct
of_match
*
matches
,
const
struct
of_device
*
dev
);
const
struct
of_match
*
matches
,
const
struct
of_device
*
dev
);
extern
struct
of_device
*
of_dev_get
(
struct
of_device
*
dev
);
extern
void
of_dev_put
(
struct
of_device
*
dev
);
/*
/*
* An of_platform_driver driver is attached to a basic of_device on
* An of_platform_driver driver is attached to a basic of_device on
* the "platform bus" (of_platform_bus_type)
* the "platform bus" (of_platform_bus_type)
...
@@ -52,8 +55,8 @@ struct of_platform_driver
...
@@ -52,8 +55,8 @@ struct of_platform_driver
int
(
*
probe
)(
struct
of_device
*
dev
,
const
struct
of_match
*
match
);
int
(
*
probe
)(
struct
of_device
*
dev
,
const
struct
of_match
*
match
);
int
(
*
remove
)(
struct
of_device
*
dev
);
int
(
*
remove
)(
struct
of_device
*
dev
);
int
(
*
suspend
)(
struct
of_device
*
dev
,
u32
state
,
u32
level
);
int
(
*
suspend
)(
struct
of_device
*
dev
,
u32
state
);
int
(
*
resume
)(
struct
of_device
*
dev
,
u32
level
);
int
(
*
resume
)(
struct
of_device
*
dev
);
int
(
*
shutdown
)(
struct
of_device
*
dev
);
int
(
*
shutdown
)(
struct
of_device
*
dev
);
struct
device_driver
driver
;
struct
device_driver
driver
;
...
@@ -65,6 +68,7 @@ extern void of_unregister_driver(struct of_platform_driver *drv);
...
@@ -65,6 +68,7 @@ extern void of_unregister_driver(struct of_platform_driver *drv);
extern
int
of_device_register
(
struct
of_device
*
ofdev
);
extern
int
of_device_register
(
struct
of_device
*
ofdev
);
extern
void
of_device_unregister
(
struct
of_device
*
ofdev
);
extern
void
of_device_unregister
(
struct
of_device
*
ofdev
);
extern
struct
of_device
*
of_platform_device_create
(
struct
device_node
*
np
,
const
char
*
bus_id
);
extern
struct
of_device
*
of_platform_device_create
(
struct
device_node
*
np
,
const
char
*
bus_id
);
extern
void
of_release_dev
(
struct
device
*
dev
);
#endif
/* __OF_DEVICE_H__ */
#endif
/* __OF_DEVICE_H__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment