Commit 00c06ed7 authored by David S. Miller's avatar David S. Miller

Merge branch 'fman-next' of git://git.freescale.com/ppc/upstream/linux

Madalin Bucur says:

====================
fsl/fman: cleanup and small fixes

This series contains fixes for the DPAA FMan driver.
Adding myself as maintainer of the driver.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4c1fad64 2fbfadb5
...@@ -5005,6 +5005,13 @@ F: drivers/net/ethernet/freescale/fec_ptp.c ...@@ -5005,6 +5005,13 @@ F: drivers/net/ethernet/freescale/fec_ptp.c
F: drivers/net/ethernet/freescale/fec.h F: drivers/net/ethernet/freescale/fec.h
F: Documentation/devicetree/bindings/net/fsl-fec.txt F: Documentation/devicetree/bindings/net/fsl-fec.txt
FREESCALE QORIQ DPAA FMAN DRIVER
M: Madalin Bucur <madalin.bucur@nxp.com>
L: netdev@vger.kernel.org
S: Maintained
F: drivers/net/ethernet/freescale/fman
F: Documentation/devicetree/bindings/powerpc/fsl/fman.txt
FREESCALE QUICC ENGINE LIBRARY FREESCALE QUICC ENGINE LIBRARY
L: linuxppc-dev@lists.ozlabs.org L: linuxppc-dev@lists.ozlabs.org
S: Orphan S: Orphan
......
subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman
obj-y += fsl_fman.o fsl_fman_mac.o fsl_mac.o obj-$(CONFIG_FSL_FMAN) += fsl_fman.o
obj-$(CONFIG_FSL_FMAN) += fsl_fman_port.o
obj-$(CONFIG_FSL_FMAN) += fsl_mac.o
fsl_fman-objs := fman_muram.o fman.o fman_sp.o fman_port.o fsl_fman-objs := fman_muram.o fman.o fman_sp.o
fsl_fman_mac-objs := fman_dtsec.o fman_memac.o fman_tgec.o fsl_fman_port-objs := fman_port.o
fsl_mac-objs += mac.o fsl_mac-objs:= mac.o fman_dtsec.o fman_memac.o fman_tgec.o
...@@ -618,7 +618,7 @@ struct fman { ...@@ -618,7 +618,7 @@ struct fman {
unsigned long cam_offset; unsigned long cam_offset;
size_t cam_size; size_t cam_size;
/* Fifo in MURAM */ /* Fifo in MURAM */
int fifo_offset; unsigned long fifo_offset;
size_t fifo_size; size_t fifo_size;
u32 liodn_base[64]; u32 liodn_base[64];
...@@ -2036,7 +2036,7 @@ static int fman_init(struct fman *fman) ...@@ -2036,7 +2036,7 @@ static int fman_init(struct fman *fman)
/* allocate MURAM for FIFO according to total size */ /* allocate MURAM for FIFO according to total size */
fman->fifo_offset = fman_muram_alloc(fman->muram, fman->fifo_offset = fman_muram_alloc(fman->muram,
fman->state->total_fifo_size); fman->state->total_fifo_size);
if (IS_ERR_VALUE(fman->cam_offset)) { if (IS_ERR_VALUE(fman->fifo_offset)) {
free_init_resources(fman); free_init_resources(fman);
dev_err(fman->dev, "%s: MURAM alloc for BMI FIFO failed\n", dev_err(fman->dev, "%s: MURAM alloc for BMI FIFO failed\n",
__func__); __func__);
...@@ -2115,6 +2115,7 @@ void fman_register_intr(struct fman *fman, enum fman_event_modules module, ...@@ -2115,6 +2115,7 @@ void fman_register_intr(struct fman *fman, enum fman_event_modules module,
fman->intr_mng[event].isr_cb = isr_cb; fman->intr_mng[event].isr_cb = isr_cb;
fman->intr_mng[event].src_handle = src_arg; fman->intr_mng[event].src_handle = src_arg;
} }
EXPORT_SYMBOL(fman_register_intr);
/** /**
* fman_unregister_intr * fman_unregister_intr
...@@ -2138,6 +2139,7 @@ void fman_unregister_intr(struct fman *fman, enum fman_event_modules module, ...@@ -2138,6 +2139,7 @@ void fman_unregister_intr(struct fman *fman, enum fman_event_modules module,
fman->intr_mng[event].isr_cb = NULL; fman->intr_mng[event].isr_cb = NULL;
fman->intr_mng[event].src_handle = NULL; fman->intr_mng[event].src_handle = NULL;
} }
EXPORT_SYMBOL(fman_unregister_intr);
/** /**
* fman_set_port_params * fman_set_port_params
...@@ -2241,6 +2243,7 @@ int fman_set_port_params(struct fman *fman, ...@@ -2241,6 +2243,7 @@ int fman_set_port_params(struct fman *fman,
spin_unlock_irqrestore(&fman->spinlock, flags); spin_unlock_irqrestore(&fman->spinlock, flags);
return err; return err;
} }
EXPORT_SYMBOL(fman_set_port_params);
/** /**
* fman_reset_mac * fman_reset_mac
...@@ -2310,6 +2313,7 @@ int fman_reset_mac(struct fman *fman, u8 mac_id) ...@@ -2310,6 +2313,7 @@ int fman_reset_mac(struct fman *fman, u8 mac_id)
return 0; return 0;
} }
EXPORT_SYMBOL(fman_reset_mac);
/** /**
* fman_set_mac_max_frame * fman_set_mac_max_frame
...@@ -2327,8 +2331,7 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl) ...@@ -2327,8 +2331,7 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl)
* or equal to the port's max * or equal to the port's max
*/ */
if ((!fman->state->port_mfl[mac_id]) || if ((!fman->state->port_mfl[mac_id]) ||
(fman->state->port_mfl[mac_id] && (mfl <= fman->state->port_mfl[mac_id])) {
(mfl <= fman->state->port_mfl[mac_id]))) {
fman->state->mac_mfl[mac_id] = mfl; fman->state->mac_mfl[mac_id] = mfl;
} else { } else {
dev_warn(fman->dev, "%s: MAC max_frame_length is larger than Port max_frame_length\n", dev_warn(fman->dev, "%s: MAC max_frame_length is larger than Port max_frame_length\n",
...@@ -2337,6 +2340,7 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl) ...@@ -2337,6 +2340,7 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl)
} }
return 0; return 0;
} }
EXPORT_SYMBOL(fman_set_mac_max_frame);
/** /**
* fman_get_clock_freq * fman_get_clock_freq
...@@ -2363,6 +2367,7 @@ u32 fman_get_bmi_max_fifo_size(struct fman *fman) ...@@ -2363,6 +2367,7 @@ u32 fman_get_bmi_max_fifo_size(struct fman *fman)
{ {
return fman->state->bmi_max_fifo_size; return fman->state->bmi_max_fifo_size;
} }
EXPORT_SYMBOL(fman_get_bmi_max_fifo_size);
/** /**
* fman_get_revision * fman_get_revision
...@@ -2384,6 +2389,7 @@ void fman_get_revision(struct fman *fman, struct fman_rev_info *rev_info) ...@@ -2384,6 +2389,7 @@ void fman_get_revision(struct fman *fman, struct fman_rev_info *rev_info)
FPM_REV1_MAJOR_SHIFT); FPM_REV1_MAJOR_SHIFT);
rev_info->minor = tmp & FPM_REV1_MINOR_MASK; rev_info->minor = tmp & FPM_REV1_MINOR_MASK;
} }
EXPORT_SYMBOL(fman_get_revision);
/** /**
* fman_get_qman_channel_id * fman_get_qman_channel_id
...@@ -2419,6 +2425,7 @@ u32 fman_get_qman_channel_id(struct fman *fman, u32 port_id) ...@@ -2419,6 +2425,7 @@ u32 fman_get_qman_channel_id(struct fman *fman, u32 port_id)
return fman->state->qman_channel_base + i; return fman->state->qman_channel_base + i;
} }
EXPORT_SYMBOL(fman_get_qman_channel_id);
/** /**
* fman_get_mem_region * fman_get_mem_region
...@@ -2432,6 +2439,7 @@ struct resource *fman_get_mem_region(struct fman *fman) ...@@ -2432,6 +2439,7 @@ struct resource *fman_get_mem_region(struct fman *fman)
{ {
return fman->state->res; return fman->state->res;
} }
EXPORT_SYMBOL(fman_get_mem_region);
/* Bootargs defines */ /* Bootargs defines */
/* Extra headroom for RX buffers - Default, min and max */ /* Extra headroom for RX buffers - Default, min and max */
...@@ -2453,7 +2461,7 @@ struct resource *fman_get_mem_region(struct fman *fman) ...@@ -2453,7 +2461,7 @@ struct resource *fman_get_mem_region(struct fman *fman)
* particular forwarding scenarios that add extra headers to the * particular forwarding scenarios that add extra headers to the
* forwarded frame. * forwarded frame.
*/ */
int fsl_fm_rx_extra_headroom = FSL_FM_RX_EXTRA_HEADROOM; static int fsl_fm_rx_extra_headroom = FSL_FM_RX_EXTRA_HEADROOM;
module_param(fsl_fm_rx_extra_headroom, int, 0); module_param(fsl_fm_rx_extra_headroom, int, 0);
MODULE_PARM_DESC(fsl_fm_rx_extra_headroom, "Extra headroom for Rx buffers"); MODULE_PARM_DESC(fsl_fm_rx_extra_headroom, "Extra headroom for Rx buffers");
...@@ -2466,7 +2474,7 @@ MODULE_PARM_DESC(fsl_fm_rx_extra_headroom, "Extra headroom for Rx buffers"); ...@@ -2466,7 +2474,7 @@ MODULE_PARM_DESC(fsl_fm_rx_extra_headroom, "Extra headroom for Rx buffers");
* Could be overridden once, at boot-time, via the * Could be overridden once, at boot-time, via the
* fm_set_max_frm() callback. * fm_set_max_frm() callback.
*/ */
int fsl_fm_max_frm = FSL_FM_MAX_FRAME_SIZE; static int fsl_fm_max_frm = FSL_FM_MAX_FRAME_SIZE;
module_param(fsl_fm_max_frm, int, 0); module_param(fsl_fm_max_frm, int, 0);
MODULE_PARM_DESC(fsl_fm_max_frm, "Maximum frame size, across all interfaces"); MODULE_PARM_DESC(fsl_fm_max_frm, "Maximum frame size, across all interfaces");
...@@ -2538,6 +2546,7 @@ struct fman *fman_bind(struct device *fm_dev) ...@@ -2538,6 +2546,7 @@ struct fman *fman_bind(struct device *fm_dev)
{ {
return (struct fman *)(dev_get_drvdata(get_device(fm_dev))); return (struct fman *)(dev_get_drvdata(get_device(fm_dev)));
} }
EXPORT_SYMBOL(fman_bind);
static irqreturn_t fman_err_irq(int irq, void *handle) static irqreturn_t fman_err_irq(int irq, void *handle)
{ {
...@@ -2727,8 +2736,8 @@ static struct fman *read_dts_node(struct platform_device *of_dev) ...@@ -2727,8 +2736,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;
...@@ -2740,16 +2749,13 @@ static struct fman *read_dts_node(struct platform_device *of_dev) ...@@ -2740,16 +2749,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);
...@@ -2796,18 +2802,15 @@ static struct fman *read_dts_node(struct platform_device *of_dev) ...@@ -2796,18 +2802,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);
...@@ -2858,7 +2861,7 @@ static struct fman *read_dts_node(struct platform_device *of_dev) ...@@ -2858,7 +2861,7 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
fman->dts_params.base_addr = fman->dts_params.base_addr =
devm_ioremap(&of_dev->dev, phys_base_addr, mem_size); devm_ioremap(&of_dev->dev, phys_base_addr, mem_size);
if (fman->dts_params.base_addr == 0) { if (!fman->dts_params.base_addr) {
dev_err(&of_dev->dev, "%s: devm_ioremap() failed\n", __func__); dev_err(&of_dev->dev, "%s: devm_ioremap() failed\n", __func__);
goto fman_free; goto fman_free;
} }
...@@ -2930,7 +2933,7 @@ static const struct of_device_id fman_match[] = { ...@@ -2930,7 +2933,7 @@ static const struct of_device_id fman_match[] = {
{} {}
}; };
MODULE_DEVICE_TABLE(of, fm_match); MODULE_DEVICE_TABLE(of, fman_match);
static struct platform_driver fman_driver = { static struct platform_driver fman_driver = {
.driver = { .driver = {
...@@ -2940,4 +2943,25 @@ static struct platform_driver fman_driver = { ...@@ -2940,4 +2943,25 @@ static struct platform_driver fman_driver = {
.probe = fman_probe, .probe = fman_probe,
}; };
builtin_platform_driver(fman_driver); static int __init fman_load(void)
{
int err;
pr_debug("FSL DPAA FMan driver\n");
err = platform_driver_register(&fman_driver);
if (err < 0)
pr_err("Error, platform_driver_register() = %d\n", err);
return err;
}
module_init(fman_load);
static void __exit fman_unload(void)
{
platform_driver_unregister(&fman_driver);
}
module_exit(fman_unload);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("Freescale DPAA Frame Manager driver");
...@@ -191,10 +191,6 @@ struct fman_mac_params { ...@@ -191,10 +191,6 @@ struct fman_mac_params {
u16 max_speed; u16 max_speed;
/* A handle to the FM object this port related to */ /* A handle to the FM object this port related to */
void *fm; void *fm;
/* MDIO exceptions interrupt source - not valid for all
* MACs; MUST be set to 0 for MACs that don't have
* mdio-irq, or for polling
*/
void *dev_id; /* device cookie used by the exception cbs */ void *dev_id; /* device cookie used by the exception cbs */
fman_mac_exception_cb *event_cb; /* MDIO Events Callback Routine */ fman_mac_exception_cb *event_cb; /* MDIO Events Callback Routine */
fman_mac_exception_cb *exception_cb;/* Exception Callback Routine */ fman_mac_exception_cb *exception_cb;/* Exception Callback Routine */
......
...@@ -507,6 +507,9 @@ static void setup_sgmii_internal_phy(struct fman_mac *memac, ...@@ -507,6 +507,9 @@ static void setup_sgmii_internal_phy(struct fman_mac *memac,
{ {
u16 tmp_reg16; u16 tmp_reg16;
if (WARN_ON(!memac->pcsphy))
return;
/* SGMII mode */ /* SGMII mode */
tmp_reg16 = IF_MODE_SGMII_EN; tmp_reg16 = IF_MODE_SGMII_EN;
if (!fixed_link) if (!fixed_link)
...@@ -1151,7 +1154,8 @@ struct fman_mac *memac_config(struct fman_mac_params *params) ...@@ -1151,7 +1154,8 @@ struct fman_mac *memac_config(struct fman_mac_params *params)
/* Save FMan revision */ /* Save FMan revision */
fman_get_revision(memac->fm, &memac->fm_rev_info); fman_get_revision(memac->fm, &memac->fm_rev_info);
if (memac->phy_if == PHY_INTERFACE_MODE_SGMII) { if (memac->phy_if == PHY_INTERFACE_MODE_SGMII ||
memac->phy_if == PHY_INTERFACE_MODE_QSGMII) {
if (!params->internal_phy_node) { if (!params->internal_phy_node) {
pr_err("PCS PHY node is not available\n"); pr_err("PCS PHY node is not available\n");
memac_free(memac); memac_free(memac);
......
...@@ -150,7 +150,8 @@ unsigned long fman_muram_alloc(struct muram_info *muram, size_t size) ...@@ -150,7 +150,8 @@ unsigned long fman_muram_alloc(struct muram_info *muram, size_t size)
* *
* Free an allocated memory from FM-MURAM partition. * Free an allocated memory from FM-MURAM partition.
*/ */
void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, size_t size) void fman_muram_free_mem(struct muram_info *muram, unsigned long offset,
size_t size)
{ {
unsigned long addr = fman_muram_offset_to_vbase(muram, offset); unsigned long addr = fman_muram_offset_to_vbase(muram, offset);
......
...@@ -46,6 +46,7 @@ unsigned long fman_muram_offset_to_vbase(struct muram_info *muram, ...@@ -46,6 +46,7 @@ unsigned long fman_muram_offset_to_vbase(struct muram_info *muram,
unsigned long fman_muram_alloc(struct muram_info *muram, size_t size); unsigned long fman_muram_alloc(struct muram_info *muram, size_t size);
void fman_muram_free_mem(struct muram_info *muram, unsigned long offset, size_t size); void fman_muram_free_mem(struct muram_info *muram, unsigned long offset,
size_t size);
#endif /* __FM_MURAM_EXT */ #endif /* __FM_MURAM_EXT */
...@@ -1477,7 +1477,8 @@ EXPORT_SYMBOL(fman_port_cfg_buf_prefix_content); ...@@ -1477,7 +1477,8 @@ EXPORT_SYMBOL(fman_port_cfg_buf_prefix_content);
*/ */
int fman_port_disable(struct fman_port *port) int fman_port_disable(struct fman_port *port)
{ {
u32 __iomem *bmi_cfg_reg, *bmi_status_reg, tmp; u32 __iomem *bmi_cfg_reg, *bmi_status_reg;
u32 tmp;
bool rx_port, failure = false; bool rx_port, failure = false;
int count; int count;
...@@ -1553,7 +1554,8 @@ EXPORT_SYMBOL(fman_port_disable); ...@@ -1553,7 +1554,8 @@ EXPORT_SYMBOL(fman_port_disable);
*/ */
int fman_port_enable(struct fman_port *port) int fman_port_enable(struct fman_port *port)
{ {
u32 __iomem *bmi_cfg_reg, tmp; u32 __iomem *bmi_cfg_reg;
u32 tmp;
bool rx_port; bool rx_port;
if (!is_init_done(port->cfg)) if (!is_init_done(port->cfg))
...@@ -1623,7 +1625,7 @@ static int fman_port_probe(struct platform_device *of_dev) ...@@ -1623,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;
...@@ -1652,28 +1654,20 @@ static int fman_port_probe(struct platform_device *of_dev) ...@@ -1652,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")) {
...@@ -1686,9 +1680,7 @@ static int fman_port_probe(struct platform_device *of_dev) ...@@ -1686,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")) {
...@@ -1743,7 +1735,7 @@ static int fman_port_probe(struct platform_device *of_dev) ...@@ -1743,7 +1735,7 @@ static int fman_port_probe(struct platform_device *of_dev)
port->dts_params.base_addr = devm_ioremap(port->dev, res.start, port->dts_params.base_addr = devm_ioremap(port->dev, res.start,
resource_size(&res)); resource_size(&res));
if (port->dts_params.base_addr == 0) if (!port->dts_params.base_addr)
dev_err(port->dev, "%s: devm_ioremap() failed\n", __func__); dev_err(port->dev, "%s: devm_ioremap() failed\n", __func__);
dev_set_drvdata(&of_dev->dev, port); dev_set_drvdata(&of_dev->dev, port);
...@@ -1775,4 +1767,25 @@ static struct platform_driver fman_port_driver = { ...@@ -1775,4 +1767,25 @@ static struct platform_driver fman_port_driver = {
.probe = fman_port_probe, .probe = fman_port_probe,
}; };
builtin_platform_driver(fman_port_driver); static int __init fman_port_load(void)
{
int err;
pr_debug("FSL DPAA FMan driver\n");
err = platform_driver_register(&fman_port_driver);
if (err < 0)
pr_err("Error, platform_driver_register() = %d\n", err);
return err;
}
module_init(fman_port_load);
static void __exit fman_port_unload(void)
{
platform_driver_unregister(&fman_port_driver);
}
module_exit(fman_port_unload);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DESCRIPTION("Freescale DPAA Frame Manager Port driver");
...@@ -80,6 +80,7 @@ void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools ...@@ -80,6 +80,7 @@ void fman_sp_set_buf_pools_in_asc_order_of_buf_sizes(struct fman_ext_pools
} }
} }
} }
EXPORT_SYMBOL(fman_sp_set_buf_pools_in_asc_order_of_buf_sizes);
int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy * int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy *
int_context_data_copy, int_context_data_copy,
...@@ -164,3 +165,5 @@ int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy * ...@@ -164,3 +165,5 @@ int fman_sp_build_buffer_struct(struct fman_sp_int_context_data_copy *
return 0; return 0;
} }
EXPORT_SYMBOL(fman_sp_build_buffer_struct);
...@@ -469,9 +469,9 @@ static void adjust_link_memac(struct net_device *net_dev) ...@@ -469,9 +469,9 @@ static void adjust_link_memac(struct net_device *net_dev)
/* Initializes driver's PHY state, and attaches to the PHY. /* Initializes driver's PHY state, and attaches to the PHY.
* Returns 0 on success. * Returns 0 on success.
*/ */
static int init_phy(struct net_device *net_dev, static struct phy_device *init_phy(struct net_device *net_dev,
struct mac_device *mac_dev, struct mac_device *mac_dev,
void (*adj_lnk)(struct net_device *)) void (*adj_lnk)(struct net_device *))
{ {
struct phy_device *phy_dev; struct phy_device *phy_dev;
struct mac_priv_s *priv = mac_dev->priv; struct mac_priv_s *priv = mac_dev->priv;
...@@ -480,7 +480,7 @@ static int init_phy(struct net_device *net_dev, ...@@ -480,7 +480,7 @@ static int init_phy(struct net_device *net_dev,
priv->phy_if); priv->phy_if);
if (!phy_dev) { if (!phy_dev) {
netdev_err(net_dev, "Could not connect to PHY\n"); netdev_err(net_dev, "Could not connect to PHY\n");
return -ENODEV; return NULL;
} }
/* Remove any features not supported by the controller */ /* Remove any features not supported by the controller */
...@@ -493,23 +493,23 @@ static int init_phy(struct net_device *net_dev, ...@@ -493,23 +493,23 @@ static int init_phy(struct net_device *net_dev,
mac_dev->phy_dev = phy_dev; mac_dev->phy_dev = phy_dev;
return 0; return phy_dev;
} }
static int dtsec_init_phy(struct net_device *net_dev, static struct phy_device *dtsec_init_phy(struct net_device *net_dev,
struct mac_device *mac_dev) struct mac_device *mac_dev)
{ {
return init_phy(net_dev, mac_dev, &adjust_link_dtsec); return init_phy(net_dev, mac_dev, &adjust_link_dtsec);
} }
static int tgec_init_phy(struct net_device *net_dev, static struct phy_device *tgec_init_phy(struct net_device *net_dev,
struct mac_device *mac_dev) struct mac_device *mac_dev)
{ {
return init_phy(net_dev, mac_dev, adjust_link_void); return init_phy(net_dev, mac_dev, adjust_link_void);
} }
static int memac_init_phy(struct net_device *net_dev, static struct phy_device *memac_init_phy(struct net_device *net_dev,
struct mac_device *mac_dev) struct mac_device *mac_dev)
{ {
return init_phy(net_dev, mac_dev, &adjust_link_memac); return init_phy(net_dev, mac_dev, &adjust_link_memac);
} }
...@@ -583,31 +583,6 @@ static void setup_memac(struct mac_device *mac_dev) ...@@ -583,31 +583,6 @@ static void setup_memac(struct mac_device *mac_dev)
static DEFINE_MUTEX(eth_lock); static DEFINE_MUTEX(eth_lock);
static const char phy_str[][11] = {
[PHY_INTERFACE_MODE_MII] = "mii",
[PHY_INTERFACE_MODE_GMII] = "gmii",
[PHY_INTERFACE_MODE_SGMII] = "sgmii",
[PHY_INTERFACE_MODE_TBI] = "tbi",
[PHY_INTERFACE_MODE_RMII] = "rmii",
[PHY_INTERFACE_MODE_RGMII] = "rgmii",
[PHY_INTERFACE_MODE_RGMII_ID] = "rgmii-id",
[PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
[PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
[PHY_INTERFACE_MODE_RTBI] = "rtbi",
[PHY_INTERFACE_MODE_XGMII] = "xgmii"
};
static phy_interface_t __pure __attribute__((nonnull)) str2phy(const char *str)
{
int i;
for (i = 0; i < ARRAY_SIZE(phy_str); i++)
if (strcmp(str, phy_str[i]) == 0)
return (phy_interface_t)i;
return PHY_INTERFACE_MODE_MII;
}
static const u16 phy2speed[] = { static const u16 phy2speed[] = {
[PHY_INTERFACE_MODE_MII] = SPEED_100, [PHY_INTERFACE_MODE_MII] = SPEED_100,
[PHY_INTERFACE_MODE_GMII] = SPEED_1000, [PHY_INTERFACE_MODE_GMII] = SPEED_1000,
...@@ -678,7 +653,7 @@ MODULE_DEVICE_TABLE(of, mac_match); ...@@ -678,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;
...@@ -686,9 +661,9 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -686,9 +661,9 @@ 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 char *char_prop; u32 val;
const u32 *u32_prop;
u8 fman_id; u8 fman_id;
int phy_if;
dev = &_of_dev->dev; dev = &_of_dev->dev;
mac_node = dev->of_node; mac_node = dev->of_node;
...@@ -749,16 +724,15 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -749,16 +724,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) {
...@@ -805,15 +779,14 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -805,15 +779,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);
...@@ -870,16 +843,14 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -870,16 +843,14 @@ static int mac_probe(struct platform_device *_of_dev)
} }
/* Get the PHY connection type */ /* Get the PHY connection type */
char_prop = (const char *)of_get_property(mac_node, phy_if = of_get_phy_mode(mac_node);
"phy-connection-type", NULL); if (phy_if < 0) {
if (!char_prop) {
dev_warn(dev, dev_warn(dev,
"of_get_property(%s, phy-connection-type) failed. Defaulting to MII\n", "of_get_phy_mode() for %s failed. Defaulting to SGMII\n",
mac_node->full_name); mac_node->full_name);
priv->phy_if = PHY_INTERFACE_MODE_MII; phy_if = PHY_INTERFACE_MODE_SGMII;
} else {
priv->phy_if = str2phy(char_prop);
} }
priv->phy_if = phy_if;
priv->speed = phy2speed[priv->phy_if]; priv->speed = phy2speed[priv->phy_if];
priv->max_speed = priv->speed; priv->max_speed = priv->speed;
......
...@@ -58,7 +58,8 @@ struct mac_device { ...@@ -58,7 +58,8 @@ struct mac_device {
bool tx_pause_active; bool tx_pause_active;
bool promisc; bool promisc;
int (*init_phy)(struct net_device *net_dev, struct mac_device *mac_dev); struct phy_device *(*init_phy)(struct net_device *net_dev,
struct mac_device *mac_dev);
int (*init)(struct mac_device *mac_dev); int (*init)(struct mac_device *mac_dev);
int (*start)(struct mac_device *mac_dev); int (*start)(struct mac_device *mac_dev);
int (*stop)(struct mac_device *mac_dev); int (*stop)(struct mac_device *mac_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment