Lines Matching refs:pdata
139 static void xgbe_default_config(struct xgbe_prv_data *pdata) in xgbe_default_config() argument
143 pdata->pblx8 = DMA_PBL_X8_ENABLE; in xgbe_default_config()
144 pdata->tx_sf_mode = MTL_TSF_ENABLE; in xgbe_default_config()
145 pdata->tx_threshold = MTL_TX_THRESHOLD_64; in xgbe_default_config()
146 pdata->tx_pbl = DMA_PBL_16; in xgbe_default_config()
147 pdata->tx_osp_mode = DMA_OSP_ENABLE; in xgbe_default_config()
148 pdata->rx_sf_mode = MTL_RSF_DISABLE; in xgbe_default_config()
149 pdata->rx_threshold = MTL_RX_THRESHOLD_64; in xgbe_default_config()
150 pdata->rx_pbl = DMA_PBL_16; in xgbe_default_config()
151 pdata->pause_autoneg = 1; in xgbe_default_config()
152 pdata->tx_pause = 1; in xgbe_default_config()
153 pdata->rx_pause = 1; in xgbe_default_config()
154 pdata->phy_speed = SPEED_UNKNOWN; in xgbe_default_config()
155 pdata->power_down = 0; in xgbe_default_config()
156 pdata->default_autoneg = AUTONEG_ENABLE; in xgbe_default_config()
157 pdata->default_speed = SPEED_10000; in xgbe_default_config()
162 static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata) in xgbe_init_all_fptrs() argument
164 xgbe_init_function_ptrs_dev(&pdata->hw_if); in xgbe_init_all_fptrs()
165 xgbe_init_function_ptrs_desc(&pdata->desc_if); in xgbe_init_all_fptrs()
169 static int xgbe_acpi_support(struct xgbe_prv_data *pdata) in xgbe_acpi_support() argument
171 struct acpi_device *adev = pdata->adev; in xgbe_acpi_support()
172 struct device *dev = pdata->dev; in xgbe_acpi_support()
187 pdata->sysclk_rate = property; in xgbe_acpi_support()
196 pdata->ptpclk_rate = property; in xgbe_acpi_support()
214 pdata->coherent = !!cca; in xgbe_acpi_support()
219 static int xgbe_acpi_support(struct xgbe_prv_data *pdata) in xgbe_acpi_support() argument
226 static int xgbe_of_support(struct xgbe_prv_data *pdata) in xgbe_of_support() argument
228 struct device *dev = pdata->dev; in xgbe_of_support()
231 pdata->sysclk = devm_clk_get(dev, XGBE_DMA_CLOCK); in xgbe_of_support()
232 if (IS_ERR(pdata->sysclk)) { in xgbe_of_support()
234 return PTR_ERR(pdata->sysclk); in xgbe_of_support()
236 pdata->sysclk_rate = clk_get_rate(pdata->sysclk); in xgbe_of_support()
239 pdata->ptpclk = devm_clk_get(dev, XGBE_PTP_CLOCK); in xgbe_of_support()
240 if (IS_ERR(pdata->ptpclk)) { in xgbe_of_support()
242 return PTR_ERR(pdata->ptpclk); in xgbe_of_support()
244 pdata->ptpclk_rate = clk_get_rate(pdata->ptpclk); in xgbe_of_support()
247 pdata->coherent = of_dma_is_coherent(dev->of_node); in xgbe_of_support()
252 static int xgbe_of_support(struct xgbe_prv_data *pdata) in xgbe_of_support() argument
260 struct xgbe_prv_data *pdata; in xgbe_probe() local
280 pdata = netdev_priv(netdev); in xgbe_probe()
281 pdata->netdev = netdev; in xgbe_probe()
282 pdata->pdev = pdev; in xgbe_probe()
283 pdata->adev = ACPI_COMPANION(dev); in xgbe_probe()
284 pdata->dev = dev; in xgbe_probe()
287 spin_lock_init(&pdata->lock); in xgbe_probe()
288 mutex_init(&pdata->xpcs_mutex); in xgbe_probe()
289 mutex_init(&pdata->rss_mutex); in xgbe_probe()
290 spin_lock_init(&pdata->tstamp_lock); in xgbe_probe()
293 pdata->use_acpi = (!pdata->adev || acpi_disabled) ? 0 : 1; in xgbe_probe()
297 pdata->tx_desc_count = XGBE_TX_DESC_CNT; in xgbe_probe()
298 if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) { in xgbe_probe()
300 pdata->tx_desc_count); in xgbe_probe()
305 pdata->rx_desc_count = XGBE_RX_DESC_CNT; in xgbe_probe()
306 if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) { in xgbe_probe()
308 pdata->rx_desc_count); in xgbe_probe()
315 pdata->xgmac_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
316 if (IS_ERR(pdata->xgmac_regs)) { in xgbe_probe()
318 ret = PTR_ERR(pdata->xgmac_regs); in xgbe_probe()
321 DBGPR(" xgmac_regs = %p\n", pdata->xgmac_regs); in xgbe_probe()
324 pdata->xpcs_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
325 if (IS_ERR(pdata->xpcs_regs)) { in xgbe_probe()
327 ret = PTR_ERR(pdata->xpcs_regs); in xgbe_probe()
330 DBGPR(" xpcs_regs = %p\n", pdata->xpcs_regs); in xgbe_probe()
334 pdata->mac_addr, in xgbe_probe()
335 sizeof(pdata->mac_addr)); in xgbe_probe()
336 if (ret || !is_valid_ether_addr(pdata->mac_addr)) { in xgbe_probe()
352 pdata->phy_mode = PHY_INTERFACE_MODE_XGMII; in xgbe_probe()
356 pdata->per_channel_irq = 1; in xgbe_probe()
359 if (pdata->use_acpi) in xgbe_probe()
360 ret = xgbe_acpi_support(pdata); in xgbe_probe()
362 ret = xgbe_of_support(pdata); in xgbe_probe()
367 if (pdata->coherent) { in xgbe_probe()
368 pdata->axdomain = XGBE_DMA_OS_AXDOMAIN; in xgbe_probe()
369 pdata->arcache = XGBE_DMA_OS_ARCACHE; in xgbe_probe()
370 pdata->awcache = XGBE_DMA_OS_AWCACHE; in xgbe_probe()
372 pdata->axdomain = XGBE_DMA_SYS_AXDOMAIN; in xgbe_probe()
373 pdata->arcache = XGBE_DMA_SYS_ARCACHE; in xgbe_probe()
374 pdata->awcache = XGBE_DMA_SYS_AWCACHE; in xgbe_probe()
383 pdata->dev_irq = ret; in xgbe_probe()
385 netdev->irq = pdata->dev_irq; in xgbe_probe()
386 netdev->base_addr = (unsigned long)pdata->xgmac_regs; in xgbe_probe()
387 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len); in xgbe_probe()
390 xgbe_init_all_fptrs(pdata); in xgbe_probe()
391 hw_if = &pdata->hw_if; in xgbe_probe()
392 desc_if = &pdata->desc_if; in xgbe_probe()
395 hw_if->exit(pdata); in xgbe_probe()
398 xgbe_get_all_hw_features(pdata); in xgbe_probe()
401 xgbe_default_config(pdata); in xgbe_probe()
407 DMA_BIT_MASK(pdata->hw_feat.dma_width)); in xgbe_probe()
420 pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(), in xgbe_probe()
421 pdata->hw_feat.tx_ch_cnt); in xgbe_probe()
422 pdata->tx_q_count = pdata->tx_ring_count; in xgbe_probe()
423 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count); in xgbe_probe()
429 pdata->rx_ring_count = min_t(unsigned int, in xgbe_probe()
431 pdata->hw_feat.rx_ch_cnt); in xgbe_probe()
432 pdata->rx_q_count = pdata->hw_feat.rx_q_cnt; in xgbe_probe()
433 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count); in xgbe_probe()
440 netdev_rss_key_fill(pdata->rss_key, sizeof(pdata->rss_key)); in xgbe_probe()
443 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH, in xgbe_probe()
444 i % pdata->rx_ring_count); in xgbe_probe()
446 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, IP2TE, 1); in xgbe_probe()
447 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, TCP4TE, 1); in xgbe_probe()
448 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1); in xgbe_probe()
451 pdata->mii_bus_id = kasprintf(GFP_KERNEL, "%s", pdev->name); in xgbe_probe()
452 if (!pdata->mii_bus_id) { in xgbe_probe()
457 ret = xgbe_mdio_register(pdata); in xgbe_probe()
480 if (pdata->hw_feat.rss) in xgbe_probe()
490 pdata->netdev_features = netdev->features; in xgbe_probe()
497 xgbe_init_rx_coalesce(pdata); in xgbe_probe()
498 xgbe_init_tx_coalesce(pdata); in xgbe_probe()
507 xgbe_ptp_register(pdata); in xgbe_probe()
509 xgbe_debugfs_init(pdata); in xgbe_probe()
518 xgbe_mdio_unregister(pdata); in xgbe_probe()
521 kfree(pdata->mii_bus_id); in xgbe_probe()
535 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_remove() local
539 xgbe_debugfs_exit(pdata); in xgbe_remove()
541 xgbe_ptp_unregister(pdata); in xgbe_remove()
545 xgbe_mdio_unregister(pdata); in xgbe_remove()
547 kfree(pdata->mii_bus_id); in xgbe_remove()