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
nexedi
linux
Commits
29f7ac7e
Commit
29f7ac7e
authored
Jun 24, 2006
by
David S. Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MTD] sun_uflash: Port to new EBUS device layer.
Signed-off-by:
David S. Miller
<
davem@davemloft.net
>
parent
fcc18e83
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
100 deletions
+95
-100
drivers/mtd/maps/sun_uflash.c
drivers/mtd/maps/sun_uflash.c
+95
-100
No files found.
drivers/mtd/maps/sun_uflash.c
View file @
29f7ac7e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <linux/ioport.h>
#include <linux/ioport.h>
#include <asm/ebus.h>
#include <asm/ebus.h>
#include <asm/oplib.h>
#include <asm/oplib.h>
#include <asm/prom.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/io.h>
...
@@ -30,146 +31,140 @@
...
@@ -30,146 +31,140 @@
#define UFLASH_WINDOW_SIZE 0x200000
#define UFLASH_WINDOW_SIZE 0x200000
#define UFLASH_BUSWIDTH 1
/* EBus is 8-bit */
#define UFLASH_BUSWIDTH 1
/* EBus is 8-bit */
MODULE_AUTHOR
MODULE_AUTHOR
(
"Eric Brower <ebrower@usa.net>"
);
(
"Eric Brower <ebrower@usa.net>"
);
MODULE_DESCRIPTION
(
"User-programmable flash device on Sun Microsystems boardsets"
);
MODULE_DESCRIPTION
MODULE_SUPPORTED_DEVICE
(
"userflash"
);
(
"User-programmable flash device on Sun Microsystems boardsets"
);
MODULE_LICENSE
(
"GPL"
);
MODULE_SUPPORTED_DEVICE
MODULE_VERSION
(
"2.0"
);
(
"userflash"
);
MODULE_LICENSE
(
"GPL"
);
static
LIST_HEAD
(
device_list
);
static
LIST_HEAD
(
device_list
);
struct
uflash_dev
{
struct
uflash_dev
{
char
*
name
;
/* device name */
char
*
name
;
/* device name */
struct
map_info
map
;
/* mtd map info */
struct
map_info
map
;
/* mtd map info */
struct
mtd_info
*
mtd
;
/* mtd info */
struct
mtd_info
*
mtd
;
/* mtd info */
struct
list_head
list
;
};
};
struct
map_info
uflash_map_templ
=
{
struct
map_info
uflash_map_templ
=
{
.
name
=
"SUNW,???-????"
,
.
name
=
"SUNW,???-????"
,
.
size
=
UFLASH_WINDOW_SIZE
,
.
size
=
UFLASH_WINDOW_SIZE
,
.
bankwidth
=
UFLASH_BUSWIDTH
,
.
bankwidth
=
UFLASH_BUSWIDTH
,
};
};
int
uflash_devinit
(
struct
linux_ebus_device
*
edev
)
int
uflash_devinit
(
struct
linux_ebus_device
*
edev
,
struct
device_node
*
dp
)
{
{
int
iTmp
,
nregs
;
struct
uflash_dev
*
up
;
struct
linux_prom_registers
regs
[
2
];
struct
resource
*
res
;
struct
uflash_dev
*
pdev
;
iTmp
=
prom_getproperty
(
edev
->
prom_node
,
"reg"
,
(
void
*
)
regs
,
sizeof
(
regs
));
if
((
iTmp
%
sizeof
(
regs
[
0
]))
!=
0
)
{
printk
(
"%s: Strange reg property size %d
\n
"
,
UFLASH_DEVNAME
,
iTmp
);
return
-
ENODEV
;
}
nregs
=
iTmp
/
sizeof
(
regs
[
0
])
;
res
=
&
edev
->
resource
[
0
]
;
if
(
nreg
s
!=
1
)
{
if
(
edev
->
num_addr
s
!=
1
)
{
/* Non-CFI userflash device-- once I find one we
/* Non-CFI userflash device-- once I find one we
* can work on supporting it.
* can work on supporting it.
*/
*/
printk
(
"%s: unsupported device at 0x%lx (%d regs): "
\
printk
(
"%s: unsupported device at 0x%lx (%d regs): "
\
"email ebrower@usa.net
\n
"
,
"email ebrower@usa.net
\n
"
,
UFLASH_DEVNAME
,
edev
->
resource
[
0
].
start
,
nregs
);
dp
->
full_name
,
res
->
start
,
edev
->
num_addrs
);
return
-
ENODEV
;
return
-
ENODEV
;
}
}
if
(
0
==
(
pdev
=
kmalloc
(
sizeof
(
struct
uflash_dev
),
GFP_KERNEL
)))
{
up
=
kzalloc
(
sizeof
(
struct
uflash_dev
),
GFP_KERNEL
);
printk
(
"%s: unable to kmalloc new device
\n
"
,
UFLASH_DEVNAME
);
if
(
!
up
)
return
(
-
ENOMEM
);
return
-
ENOMEM
;
}
/* copy defaults and tweak parameters */
/* copy defaults and tweak parameters */
memcpy
(
&
pdev
->
map
,
&
uflash_map_templ
,
sizeof
(
uflash_map_templ
));
memcpy
(
&
up
->
map
,
&
uflash_map_templ
,
sizeof
(
uflash_map_templ
));
pdev
->
map
.
size
=
regs
[
0
].
reg_size
;
up
->
map
.
size
=
(
res
->
end
-
res
->
start
)
+
1UL
;
iTmp
=
prom_getproplen
(
edev
->
prom_node
,
"model"
);
up
->
name
=
of_get_property
(
dp
,
"model"
,
NULL
);
pdev
->
name
=
kmalloc
(
iTmp
,
GFP_KERNEL
);
if
(
up
->
name
&&
0
<
strlen
(
up
->
name
))
prom_getstring
(
edev
->
prom_node
,
"model"
,
pdev
->
name
,
iTmp
);
up
->
map
.
name
=
up
->
name
;
if
(
0
!=
pdev
->
name
&&
0
<
strlen
(
pdev
->
name
))
{
pdev
->
map
.
name
=
pdev
->
name
;
up
->
map
.
phys
=
res
->
start
;
}
pdev
->
map
.
phys
=
edev
->
resource
[
0
].
start
;
up
->
map
.
virt
=
ioremap_nocache
(
res
->
start
,
up
->
map
.
size
);
pdev
->
map
.
virt
=
ioremap_nocache
(
edev
->
resource
[
0
].
start
,
pdev
->
map
.
size
);
if
(
!
up
->
map
.
virt
)
{
if
(
0
==
pdev
->
map
.
virt
)
{
printk
(
"%s: Failed to map device.
\n
"
,
dp
->
full_name
);
printk
(
"%s: failed to map device
\n
"
,
__FUNCTION__
);
kfree
(
up
);
kfree
(
pdev
->
name
);
kfree
(
pdev
);
return
-
EINVAL
;
return
(
-
1
);
}
}
simple_map_init
(
&
pdev
->
map
);
simple_map_init
(
&
up
->
map
);
/* MTD registration */
/* MTD registration */
pdev
->
mtd
=
do_map_probe
(
"cfi_probe"
,
&
pdev
->
map
);
up
->
mtd
=
do_map_probe
(
"cfi_probe"
,
&
up
->
map
);
if
(
0
==
pdev
->
mtd
)
{
if
(
!
up
->
mtd
)
{
iounmap
(
pdev
->
map
.
virt
);
iounmap
(
up
->
map
.
virt
);
kfree
(
pdev
->
name
);
kfree
(
up
);
kfree
(
pdev
);
return
(
-
ENXIO
)
;
return
-
ENXIO
;
}
}
list_add
(
&
pdev
->
list
,
&
device_list
)
;
up
->
mtd
->
owner
=
THIS_MODULE
;
pdev
->
mtd
->
owner
=
THIS_MODULE
;
add_mtd_device
(
up
->
mtd
)
;
add_mtd_device
(
pdev
->
mtd
);
dev_set_drvdata
(
&
edev
->
ofdev
.
dev
,
up
);
return
(
0
);
return
0
;
}
}
static
int
__
init
uflash_init
(
void
)
static
int
__
devinit
uflash_probe
(
struct
of_device
*
dev
,
const
struct
of_device_id
*
match
)
{
{
struct
linux_ebus
*
ebus
=
NULL
;
struct
linux_ebus_device
*
edev
=
to_ebus_device
(
&
dev
->
dev
);
struct
linux_ebus_device
*
edev
=
NULL
;
struct
device_node
*
dp
=
dev
->
node
;
for_each_ebus
(
ebus
)
{
for_each_ebusdev
(
edev
,
ebus
)
{
if
(
!
strcmp
(
edev
->
prom_name
,
UFLASH_OBPNAME
))
{
if
(
0
>
prom_getproplen
(
edev
->
prom_node
,
"user"
))
{
DEBUG
(
2
,
"%s: ignoring device at 0x%lx
\n
"
,
UFLASH_DEVNAME
,
edev
->
resource
[
0
].
start
);
}
else
{
uflash_devinit
(
edev
);
}
}
}
}
if
(
list_empty
(
&
device_list
))
{
if
(
of_find_property
(
dp
,
"user"
,
NULL
))
printk
(
"%s: unable to locate device
\n
"
,
UFLASH_DEVNAME
);
return
-
ENODEV
;
return
-
ENODEV
;
}
return
(
0
);
return
uflash_devinit
(
edev
,
dp
);
}
}
static
void
__exit
uflash_cleanup
(
void
)
static
int
__devexit
uflash_remove
(
struct
of_device
*
dev
)
{
{
struct
list_head
*
udevlist
;
struct
uflash_dev
*
up
=
dev_get_drvdata
(
&
dev
->
dev
);
struct
uflash_dev
*
udev
;
if
(
up
->
mtd
)
{
list_for_each
(
udevlist
,
&
device_list
)
{
del_mtd_device
(
up
->
mtd
);
udev
=
list_entry
(
udevlist
,
struct
uflash_dev
,
list
);
map_destroy
(
up
->
mtd
);
DEBUG
(
2
,
"%s: removing device %s
\n
"
,
UFLASH_DEVNAME
,
udev
->
name
);
if
(
0
!=
udev
->
mtd
)
{
del_mtd_device
(
udev
->
mtd
);
map_destroy
(
udev
->
mtd
);
}
if
(
0
!=
udev
->
map
.
virt
)
{
iounmap
(
udev
->
map
.
virt
);
udev
->
map
.
virt
=
NULL
;
}
kfree
(
udev
->
name
);
kfree
(
udev
);
}
}
if
(
up
->
map
.
virt
)
{
iounmap
(
up
->
map
.
virt
);
up
->
map
.
virt
=
NULL
;
}
kfree
(
up
);
return
0
;
}
static
struct
of_device_id
uflash_match
[]
=
{
{
.
name
=
UFLASH_OBPNAME
,
},
{},
};
MODULE_DEVICE_TABLE
(
of
,
uflash_match
);
static
struct
of_platform_driver
uflash_driver
=
{
.
name
=
UFLASH_DEVNAME
,
.
match_table
=
uflash_match
,
.
probe
=
uflash_probe
,
.
remove
=
__devexit_p
(
uflash_remove
),
};
static
int
__init
uflash_init
(
void
)
{
return
of_register_driver
(
&
uflash_driver
,
&
ebus_bus_type
);
}
static
void
__exit
uflash_exit
(
void
)
{
of_unregister_driver
(
&
uflash_driver
);
}
}
module_init
(
uflash_init
);
module_init
(
uflash_init
);
module_exit
(
uflash_
cleanup
);
module_exit
(
uflash_
exit
);
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