aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGiuseppe CAVALLARO <peppe.cavallaro@st.com>2012-04-18 15:48:21 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-19 20:08:59 -0400
commit0f1f88a875bd6c6725501183fabeb99a70c35757 (patch)
tree9ac6a5af22c32206d0e23320f497f4e04fb41d7e /drivers
parent4bfcbd7abce2d9b56f10d455ffeab00584cd8045 (diff)
stmmac: verify the dma_cfg platform fields
Recently the dma parameters that can be passed from the platform have been moved from the plat_stmmacenet_data to the stmmac_dma_cfg. In case of this new structure is not well allocated the driver can fails. This is an example how this field is managed in ST platforms static struct stmmac_dma_cfg gmac_dma_setting = { .pbl = 32, }; static struct plat_stmmacenet_data stih415_ethernet_platform_data[] = { { .dma_cfg = &gmac_dma_setting, .has_gmac = 1, [snip] This patch so verifies that the dma_cfg passed from the platform. In case of it is NULL there is no reason that the driver has to fail and some default values can be passed. These are ok for all the Synopsys chips and could impact on performances, only. Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> cc: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/common.h1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c23
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c7
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
4 files changed, 25 insertions, 7 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 9e42b5d32cff..f5dedcbf4651 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -147,6 +147,7 @@ struct stmmac_extra_stats {
147#define DMA_HW_FEAT_FLEXIPPSEN 0x04000000 /* Flexible PPS Output */ 147#define DMA_HW_FEAT_FLEXIPPSEN 0x04000000 /* Flexible PPS Output */
148#define DMA_HW_FEAT_SAVLANINS 0x08000000 /* Source Addr or VLAN Insertion */ 148#define DMA_HW_FEAT_SAVLANINS 0x08000000 /* Source Addr or VLAN Insertion */
149#define DMA_HW_FEAT_ACTPHYIF 0x70000000 /* Active/selected PHY interface */ 149#define DMA_HW_FEAT_ACTPHYIF 0x70000000 /* Active/selected PHY interface */
150#define DEFAULT_DMA_PBL 8
150 151
151enum rx_frame_status { /* IPC status */ 152enum rx_frame_status { /* IPC status */
152 good_frame = 0, 153 good_frame = 0,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9ecd6cf9815a..efc42e1f9b4a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -919,6 +919,24 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv)
919 priv->dev->dev_addr); 919 priv->dev->dev_addr);
920} 920}
921 921
922static int stmmac_init_dma_engine(struct stmmac_priv *priv)
923{
924 int pbl = DEFAULT_DMA_PBL, fixed_burst = 0, burst_len = 0;
925
926 /* Some DMA parameters can be passed from the platform;
927 * in case of these are not passed we keep a default
928 * (good for all the chips) and init the DMA! */
929 if (priv->plat->dma_cfg) {
930 pbl = priv->plat->dma_cfg->pbl;
931 fixed_burst = priv->plat->dma_cfg->fixed_burst;
932 burst_len = priv->plat->dma_cfg->burst_len;
933 }
934
935 return priv->hw->dma->init(priv->ioaddr, pbl, fixed_burst,
936 burst_len, priv->dma_tx_phy,
937 priv->dma_rx_phy);
938}
939
922/** 940/**
923 * stmmac_open - open entry point of the driver 941 * stmmac_open - open entry point of the driver
924 * @dev : pointer to the device structure. 942 * @dev : pointer to the device structure.
@@ -967,10 +985,7 @@ static int stmmac_open(struct net_device *dev)
967 init_dma_desc_rings(dev); 985 init_dma_desc_rings(dev);
968 986
969 /* DMA initialization and SW reset */ 987 /* DMA initialization and SW reset */
970 ret = priv->hw->dma->init(priv->ioaddr, priv->plat->dma_cfg->pbl, 988 ret = stmmac_init_dma_engine(priv);
971 priv->plat->dma_cfg->fixed_burst,
972 priv->plat->dma_cfg->burst_len,
973 priv->dma_tx_phy, priv->dma_rx_phy);
974 if (ret < 0) { 989 if (ret < 0) {
975 pr_err("%s: DMA initialization failed\n", __func__); 990 pr_err("%s: DMA initialization failed\n", __func__);
976 goto open_error; 991 goto open_error;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 65e0f98520d6..58fab5303e9c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -28,6 +28,7 @@
28 28
29struct plat_stmmacenet_data plat_dat; 29struct plat_stmmacenet_data plat_dat;
30struct stmmac_mdio_bus_data mdio_data; 30struct stmmac_mdio_bus_data mdio_data;
31struct stmmac_dma_cfg dma_cfg;
31 32
32static void stmmac_default_data(void) 33static void stmmac_default_data(void)
33{ 34{
@@ -35,8 +36,6 @@ static void stmmac_default_data(void)
35 plat_dat.bus_id = 1; 36 plat_dat.bus_id = 1;
36 plat_dat.phy_addr = 0; 37 plat_dat.phy_addr = 0;
37 plat_dat.interface = PHY_INTERFACE_MODE_GMII; 38 plat_dat.interface = PHY_INTERFACE_MODE_GMII;
38 plat_dat.dma_cfg->pbl = 32;
39 plat_dat.dma_cfg->burst_len = DMA_AXI_BLEN_256;
40 plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ 39 plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
41 plat_dat.has_gmac = 1; 40 plat_dat.has_gmac = 1;
42 plat_dat.force_sf_dma_mode = 1; 41 plat_dat.force_sf_dma_mode = 1;
@@ -45,6 +44,10 @@ static void stmmac_default_data(void)
45 mdio_data.phy_reset = NULL; 44 mdio_data.phy_reset = NULL;
46 mdio_data.phy_mask = 0; 45 mdio_data.phy_mask = 0;
47 plat_dat.mdio_bus_data = &mdio_data; 46 plat_dat.mdio_bus_data = &mdio_data;
47
48 dma_cfg.pbl = 32;
49 dma_cfg.burst_len = DMA_AXI_BLEN_256;
50 plat_dat.dma_cfg = &dma_cfg;
48} 51}
49 52
50/** 53/**
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index ba30d38a6caf..3dd8f0803808 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -50,7 +50,6 @@ static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
50 * once needed on other platforms. 50 * once needed on other platforms.
51 */ 51 */
52 if (of_device_is_compatible(np, "st,spear600-gmac")) { 52 if (of_device_is_compatible(np, "st,spear600-gmac")) {
53 plat->dma_cfg->pbl = 8;
54 plat->has_gmac = 1; 53 plat->has_gmac = 1;
55 plat->pmt = 1; 54 plat->pmt = 1;
56 } 55 }