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
537a3165
Commit
537a3165
authored
May 16, 2016
by
Madalin Bucur
Committed by
Madalin Bucur
Oct 04, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fsl/fman: simplify device tree reads
Signed-off-by:
Madalin Bucur
<
madalin.bucur@nxp.com
>
parent
6fa85192
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
48 deletions
+30
-48
drivers/net/ethernet/freescale/fman/fman.c
drivers/net/ethernet/freescale/fman/fman.c
+12
-18
drivers/net/ethernet/freescale/fman/fman_port.c
drivers/net/ethernet/freescale/fman/fman_port.c
+7
-17
drivers/net/ethernet/freescale/fman/mac.c
drivers/net/ethernet/freescale/fman/mac.c
+11
-13
No files found.
drivers/net/ethernet/freescale/fman/fman.c
View file @
537a3165
...
@@ -2737,8 +2737,8 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
...
@@ -2737,8 +2737,8 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
struct
fman
*
fman
;
struct
fman
*
fman
;
struct
device_node
*
fm_node
,
*
muram_node
;
struct
device_node
*
fm_node
,
*
muram_node
;
struct
resource
*
res
;
struct
resource
*
res
;
const
u32
*
u32_prop
;
u32
val
,
range
[
2
]
;
int
lenp
,
err
,
irq
;
int
err
,
irq
;
struct
clk
*
clk
;
struct
clk
*
clk
;
u32
clk_rate
;
u32
clk_rate
;
phys_addr_t
phys_base_addr
;
phys_addr_t
phys_base_addr
;
...
@@ -2750,16 +2750,13 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
...
@@ -2750,16 +2750,13 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
fm_node
=
of_node_get
(
of_dev
->
dev
.
of_node
);
fm_node
=
of_node_get
(
of_dev
->
dev
.
of_node
);
u32_prop
=
(
const
u32
*
)
of_get_property
(
fm_node
,
"cell-index"
,
&
lenp
);
err
=
of_property_read_u32
(
fm_node
,
"cell-index"
,
&
val
);
if
(
!
u32_prop
)
{
if
(
err
)
{
dev_err
(
&
of_dev
->
dev
,
"%s:
of_get_property(%s, cell-index) failed
\n
"
,
dev_err
(
&
of_dev
->
dev
,
"%s:
failed to read cell-index for %s
\n
"
,
__func__
,
fm_node
->
full_name
);
__func__
,
fm_node
->
full_name
);
goto
fman_node_put
;
goto
fman_node_put
;
}
}
if
(
WARN_ON
(
lenp
!=
sizeof
(
u32
)))
fman
->
dts_params
.
id
=
(
u8
)
val
;
goto
fman_node_put
;
fman
->
dts_params
.
id
=
(
u8
)
fdt32_to_cpu
(
u32_prop
[
0
]);
/* Get the FM interrupt */
/* Get the FM interrupt */
res
=
platform_get_resource
(
of_dev
,
IORESOURCE_IRQ
,
0
);
res
=
platform_get_resource
(
of_dev
,
IORESOURCE_IRQ
,
0
);
...
@@ -2806,18 +2803,15 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
...
@@ -2806,18 +2803,15 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
/* Rounding to MHz */
/* Rounding to MHz */
fman
->
dts_params
.
clk_freq
=
DIV_ROUND_UP
(
clk_rate
,
1000000
);
fman
->
dts_params
.
clk_freq
=
DIV_ROUND_UP
(
clk_rate
,
1000000
);
u32_prop
=
(
const
u32
*
)
of_get_property
(
fm_node
,
err
=
of_property_read_u32_array
(
fm_node
,
"fsl,qman-channel-range"
,
"fsl,qman-channel-range"
,
&
range
[
0
],
2
);
&
lenp
);
if
(
err
)
{
if
(
!
u32_prop
)
{
dev_err
(
&
of_dev
->
dev
,
"%s: failed to read fsl,qman-channel-range for %s
\n
"
,
dev_err
(
&
of_dev
->
dev
,
"%s: of_get_property(%s, fsl,qman-channel-range) failed
\n
"
,
__func__
,
fm_node
->
full_name
);
__func__
,
fm_node
->
full_name
);
goto
fman_node_put
;
goto
fman_node_put
;
}
}
if
(
WARN_ON
(
lenp
!=
sizeof
(
u32
)
*
2
))
fman
->
dts_params
.
qman_channel_base
=
range
[
0
];
goto
fman_node_put
;
fman
->
dts_params
.
num_of_qman_channels
=
range
[
1
];
fman
->
dts_params
.
qman_channel_base
=
fdt32_to_cpu
(
u32_prop
[
0
]);
fman
->
dts_params
.
num_of_qman_channels
=
fdt32_to_cpu
(
u32_prop
[
1
]);
/* Get the MURAM base address and size */
/* Get the MURAM base address and size */
muram_node
=
of_find_matching_node
(
fm_node
,
fman_muram_match
);
muram_node
=
of_find_matching_node
(
fm_node
,
fman_muram_match
);
...
...
drivers/net/ethernet/freescale/fman/fman_port.c
View file @
537a3165
...
@@ -1625,7 +1625,7 @@ static int fman_port_probe(struct platform_device *of_dev)
...
@@ -1625,7 +1625,7 @@ static int fman_port_probe(struct platform_device *of_dev)
struct
device_node
*
fm_node
,
*
port_node
;
struct
device_node
*
fm_node
,
*
port_node
;
struct
resource
res
;
struct
resource
res
;
struct
resource
*
dev_res
;
struct
resource
*
dev_res
;
const
u32
*
u32_prop
;
u32
val
;
int
err
=
0
,
lenp
;
int
err
=
0
,
lenp
;
enum
fman_port_type
port_type
;
enum
fman_port_type
port_type
;
u16
port_speed
;
u16
port_speed
;
...
@@ -1654,28 +1654,20 @@ static int fman_port_probe(struct platform_device *of_dev)
...
@@ -1654,28 +1654,20 @@ static int fman_port_probe(struct platform_device *of_dev)
goto
return_err
;
goto
return_err
;
}
}
u32_prop
=
(
const
u32
*
)
of_get_property
(
port_node
,
"cell-index"
,
&
lenp
);
err
=
of_property_read_u32
(
port_node
,
"cell-index"
,
&
val
);
if
(
!
u32_prop
)
{
if
(
err
)
{
dev_err
(
port
->
dev
,
"%s:
of_get_property(%s, cell-index)
failed
\n
"
,
dev_err
(
port
->
dev
,
"%s:
reading cell-index for %s
failed
\n
"
,
__func__
,
port_node
->
full_name
);
__func__
,
port_node
->
full_name
);
err
=
-
EINVAL
;
err
=
-
EINVAL
;
goto
return_err
;
goto
return_err
;
}
}
if
(
WARN_ON
(
lenp
!=
sizeof
(
u32
)))
{
port_id
=
(
u8
)
val
;
err
=
-
EINVAL
;
goto
return_err
;
}
port_id
=
(
u8
)
fdt32_to_cpu
(
u32_prop
[
0
]);
port
->
dts_params
.
id
=
port_id
;
port
->
dts_params
.
id
=
port_id
;
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v3-port-tx"
))
{
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v3-port-tx"
))
{
port_type
=
FMAN_PORT_TYPE_TX
;
port_type
=
FMAN_PORT_TYPE_TX
;
port_speed
=
1000
;
port_speed
=
1000
;
u32_prop
=
(
const
u32
*
)
of_get_property
(
port_node
,
if
(
of_find_property
(
port_node
,
"fsl,fman-10g-port"
,
&
lenp
))
"fsl,fman-10g-port"
,
&
lenp
);
if
(
u32_prop
)
port_speed
=
10000
;
port_speed
=
10000
;
}
else
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v2-port-tx"
))
{
}
else
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v2-port-tx"
))
{
...
@@ -1688,9 +1680,7 @@ static int fman_port_probe(struct platform_device *of_dev)
...
@@ -1688,9 +1680,7 @@ static int fman_port_probe(struct platform_device *of_dev)
}
else
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v3-port-rx"
))
{
}
else
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v3-port-rx"
))
{
port_type
=
FMAN_PORT_TYPE_RX
;
port_type
=
FMAN_PORT_TYPE_RX
;
port_speed
=
1000
;
port_speed
=
1000
;
u32_prop
=
(
const
u32
*
)
of_get_property
(
port_node
,
if
(
of_find_property
(
port_node
,
"fsl,fman-10g-port"
,
&
lenp
))
"fsl,fman-10g-port"
,
&
lenp
);
if
(
u32_prop
)
port_speed
=
10000
;
port_speed
=
10000
;
}
else
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v2-port-rx"
))
{
}
else
if
(
of_device_is_compatible
(
port_node
,
"fsl,fman-v2-port-rx"
))
{
...
...
drivers/net/ethernet/freescale/fman/mac.c
View file @
537a3165
...
@@ -653,7 +653,7 @@ MODULE_DEVICE_TABLE(of, mac_match);
...
@@ -653,7 +653,7 @@ MODULE_DEVICE_TABLE(of, mac_match);
static
int
mac_probe
(
struct
platform_device
*
_of_dev
)
static
int
mac_probe
(
struct
platform_device
*
_of_dev
)
{
{
int
err
,
i
,
lenp
,
nph
;
int
err
,
i
,
nph
;
struct
device
*
dev
;
struct
device
*
dev
;
struct
device_node
*
mac_node
,
*
dev_node
;
struct
device_node
*
mac_node
,
*
dev_node
;
struct
mac_device
*
mac_dev
;
struct
mac_device
*
mac_dev
;
...
@@ -661,7 +661,7 @@ static int mac_probe(struct platform_device *_of_dev)
...
@@ -661,7 +661,7 @@ static int mac_probe(struct platform_device *_of_dev)
struct
resource
res
;
struct
resource
res
;
struct
mac_priv_s
*
priv
;
struct
mac_priv_s
*
priv
;
const
u8
*
mac_addr
;
const
u8
*
mac_addr
;
const
u32
*
u32_prop
;
u32
val
;
u8
fman_id
;
u8
fman_id
;
dev
=
&
_of_dev
->
dev
;
dev
=
&
_of_dev
->
dev
;
...
@@ -723,16 +723,15 @@ static int mac_probe(struct platform_device *_of_dev)
...
@@ -723,16 +723,15 @@ static int mac_probe(struct platform_device *_of_dev)
}
}
/* Get the FMan cell-index */
/* Get the FMan cell-index */
u32_prop
=
of_get_property
(
dev_node
,
"cell-index"
,
&
lenp
);
err
=
of_property_read_u32
(
dev_node
,
"cell-index"
,
&
val
);
if
(
!
u32_prop
)
{
if
(
err
)
{
dev_err
(
dev
,
"
of_get_property(%s, cell-index) failed
\n
"
,
dev_err
(
dev
,
"
failed to read cell-index for %s
\n
"
,
dev_node
->
full_name
);
dev_node
->
full_name
);
err
=
-
EINVAL
;
err
=
-
EINVAL
;
goto
_return_of_node_put
;
goto
_return_of_node_put
;
}
}
WARN_ON
(
lenp
!=
sizeof
(
u32
));
/* cell-index 0 => FMan id 1 */
/* cell-index 0 => FMan id 1 */
fman_id
=
(
u8
)(
fdt32_to_cpu
(
u32_prop
[
0
])
+
1
);
fman_id
=
(
u8
)(
val
+
1
);
priv
->
fman
=
fman_bind
(
&
of_dev
->
dev
);
priv
->
fman
=
fman_bind
(
&
of_dev
->
dev
);
if
(
!
priv
->
fman
)
{
if
(
!
priv
->
fman
)
{
...
@@ -779,15 +778,14 @@ static int mac_probe(struct platform_device *_of_dev)
...
@@ -779,15 +778,14 @@ static int mac_probe(struct platform_device *_of_dev)
}
}
/* Get the cell-index */
/* Get the cell-index */
u32_prop
=
of_get_property
(
mac_node
,
"cell-index"
,
&
lenp
);
err
=
of_property_read_u32
(
mac_node
,
"cell-index"
,
&
val
);
if
(
!
u32_prop
)
{
if
(
err
)
{
dev_err
(
dev
,
"
of_get_property(%s, cell-index) failed
\n
"
,
dev_err
(
dev
,
"
failed to read cell-index for %s
\n
"
,
mac_node
->
full_name
);
mac_node
->
full_name
);
err
=
-
EINVAL
;
err
=
-
EINVAL
;
goto
_return_dev_set_drvdata
;
goto
_return_dev_set_drvdata
;
}
}
WARN_ON
(
lenp
!=
sizeof
(
u32
));
priv
->
cell_index
=
(
u8
)
val
;
priv
->
cell_index
=
(
u8
)
fdt32_to_cpu
(
u32_prop
[
0
]);
/* Get the MAC address */
/* Get the MAC address */
mac_addr
=
of_get_mac_address
(
mac_node
);
mac_addr
=
of_get_mac_address
(
mac_node
);
...
@@ -847,7 +845,7 @@ static int mac_probe(struct platform_device *_of_dev)
...
@@ -847,7 +845,7 @@ static int mac_probe(struct platform_device *_of_dev)
priv
->
phy_if
=
of_get_phy_mode
(
mac_node
);
priv
->
phy_if
=
of_get_phy_mode
(
mac_node
);
if
(
priv
->
phy_if
<
0
)
{
if
(
priv
->
phy_if
<
0
)
{
dev_warn
(
dev
,
dev_warn
(
dev
,
"of_get_p
roperty(%s, phy-connection-type)
failed. Defaulting to MII
\n
"
,
"of_get_p
hy_mode() for %s
failed. Defaulting to MII
\n
"
,
mac_node
->
full_name
);
mac_node
->
full_name
);
priv
->
phy_if
=
PHY_INTERFACE_MODE_MII
;
priv
->
phy_if
=
PHY_INTERFACE_MODE_MII
;
}
}
...
...
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