Lines Matching refs:pdata

184 static void xgbe_default_config(struct xgbe_prv_data *pdata)  in xgbe_default_config()  argument
188 pdata->pblx8 = DMA_PBL_X8_ENABLE; in xgbe_default_config()
189 pdata->tx_sf_mode = MTL_TSF_ENABLE; in xgbe_default_config()
190 pdata->tx_threshold = MTL_TX_THRESHOLD_64; in xgbe_default_config()
191 pdata->tx_pbl = DMA_PBL_16; in xgbe_default_config()
192 pdata->tx_osp_mode = DMA_OSP_ENABLE; in xgbe_default_config()
193 pdata->rx_sf_mode = MTL_RSF_DISABLE; in xgbe_default_config()
194 pdata->rx_threshold = MTL_RX_THRESHOLD_64; in xgbe_default_config()
195 pdata->rx_pbl = DMA_PBL_16; in xgbe_default_config()
196 pdata->pause_autoneg = 1; in xgbe_default_config()
197 pdata->tx_pause = 1; in xgbe_default_config()
198 pdata->rx_pause = 1; in xgbe_default_config()
199 pdata->phy_speed = SPEED_UNKNOWN; in xgbe_default_config()
200 pdata->power_down = 0; in xgbe_default_config()
205 static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata) in xgbe_init_all_fptrs() argument
207 xgbe_init_function_ptrs_dev(&pdata->hw_if); in xgbe_init_all_fptrs()
208 xgbe_init_function_ptrs_phy(&pdata->phy_if); in xgbe_init_all_fptrs()
209 xgbe_init_function_ptrs_desc(&pdata->desc_if); in xgbe_init_all_fptrs()
213 static int xgbe_acpi_support(struct xgbe_prv_data *pdata) in xgbe_acpi_support() argument
215 struct device *dev = pdata->dev; in xgbe_acpi_support()
226 pdata->sysclk_rate = property; in xgbe_acpi_support()
235 pdata->ptpclk_rate = property; in xgbe_acpi_support()
240 static int xgbe_acpi_support(struct xgbe_prv_data *pdata) in xgbe_acpi_support() argument
247 static int xgbe_of_support(struct xgbe_prv_data *pdata) in xgbe_of_support() argument
249 struct device *dev = pdata->dev; in xgbe_of_support()
252 pdata->sysclk = devm_clk_get(dev, XGBE_DMA_CLOCK); in xgbe_of_support()
253 if (IS_ERR(pdata->sysclk)) { in xgbe_of_support()
255 return PTR_ERR(pdata->sysclk); in xgbe_of_support()
257 pdata->sysclk_rate = clk_get_rate(pdata->sysclk); in xgbe_of_support()
260 pdata->ptpclk = devm_clk_get(dev, XGBE_PTP_CLOCK); in xgbe_of_support()
261 if (IS_ERR(pdata->ptpclk)) { in xgbe_of_support()
263 return PTR_ERR(pdata->ptpclk); in xgbe_of_support()
265 pdata->ptpclk_rate = clk_get_rate(pdata->ptpclk); in xgbe_of_support()
270 static struct platform_device *xgbe_of_get_phy_pdev(struct xgbe_prv_data *pdata) in xgbe_of_get_phy_pdev() argument
272 struct device *dev = pdata->dev; in xgbe_of_get_phy_pdev()
289 phy_pdev = pdata->pdev; in xgbe_of_get_phy_pdev()
295 static int xgbe_of_support(struct xgbe_prv_data *pdata) in xgbe_of_support() argument
300 static struct platform_device *xgbe_of_get_phy_pdev(struct xgbe_prv_data *pdata) in xgbe_of_get_phy_pdev() argument
322 static struct platform_device *xgbe_get_phy_pdev(struct xgbe_prv_data *pdata) in xgbe_get_phy_pdev() argument
326 if (pdata->use_acpi) { in xgbe_get_phy_pdev()
327 get_device(pdata->dev); in xgbe_get_phy_pdev()
328 phy_pdev = pdata->pdev; in xgbe_get_phy_pdev()
330 phy_pdev = xgbe_of_get_phy_pdev(pdata); in xgbe_get_phy_pdev()
338 struct xgbe_prv_data *pdata; in xgbe_probe() local
358 pdata = netdev_priv(netdev); in xgbe_probe()
359 pdata->netdev = netdev; in xgbe_probe()
360 pdata->pdev = pdev; in xgbe_probe()
361 pdata->adev = ACPI_COMPANION(dev); in xgbe_probe()
362 pdata->dev = dev; in xgbe_probe()
365 spin_lock_init(&pdata->lock); in xgbe_probe()
366 mutex_init(&pdata->xpcs_mutex); in xgbe_probe()
367 mutex_init(&pdata->rss_mutex); in xgbe_probe()
368 spin_lock_init(&pdata->tstamp_lock); in xgbe_probe()
370 pdata->msg_enable = netif_msg_init(debug, default_msg_level); in xgbe_probe()
372 set_bit(XGBE_DOWN, &pdata->dev_state); in xgbe_probe()
375 pdata->use_acpi = dev->of_node ? 0 : 1; in xgbe_probe()
377 phy_pdev = xgbe_get_phy_pdev(pdata); in xgbe_probe()
402 pdata->tx_desc_count = XGBE_TX_DESC_CNT; in xgbe_probe()
403 if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) { in xgbe_probe()
405 pdata->tx_desc_count); in xgbe_probe()
410 pdata->rx_desc_count = XGBE_RX_DESC_CNT; in xgbe_probe()
411 if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) { in xgbe_probe()
413 pdata->rx_desc_count); in xgbe_probe()
420 pdata->xgmac_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
421 if (IS_ERR(pdata->xgmac_regs)) { in xgbe_probe()
423 ret = PTR_ERR(pdata->xgmac_regs); in xgbe_probe()
426 if (netif_msg_probe(pdata)) in xgbe_probe()
427 dev_dbg(dev, "xgmac_regs = %p\n", pdata->xgmac_regs); in xgbe_probe()
430 pdata->xpcs_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
431 if (IS_ERR(pdata->xpcs_regs)) { in xgbe_probe()
433 ret = PTR_ERR(pdata->xpcs_regs); in xgbe_probe()
436 if (netif_msg_probe(pdata)) in xgbe_probe()
437 dev_dbg(dev, "xpcs_regs = %p\n", pdata->xpcs_regs); in xgbe_probe()
440 pdata->rxtx_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
441 if (IS_ERR(pdata->rxtx_regs)) { in xgbe_probe()
443 ret = PTR_ERR(pdata->rxtx_regs); in xgbe_probe()
446 if (netif_msg_probe(pdata)) in xgbe_probe()
447 dev_dbg(dev, "rxtx_regs = %p\n", pdata->rxtx_regs); in xgbe_probe()
450 pdata->sir0_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
451 if (IS_ERR(pdata->sir0_regs)) { in xgbe_probe()
453 ret = PTR_ERR(pdata->sir0_regs); in xgbe_probe()
456 if (netif_msg_probe(pdata)) in xgbe_probe()
457 dev_dbg(dev, "sir0_regs = %p\n", pdata->sir0_regs); in xgbe_probe()
460 pdata->sir1_regs = devm_ioremap_resource(dev, res); in xgbe_probe()
461 if (IS_ERR(pdata->sir1_regs)) { in xgbe_probe()
463 ret = PTR_ERR(pdata->sir1_regs); in xgbe_probe()
466 if (netif_msg_probe(pdata)) in xgbe_probe()
467 dev_dbg(dev, "sir1_regs = %p\n", pdata->sir1_regs); in xgbe_probe()
471 pdata->mac_addr, in xgbe_probe()
472 sizeof(pdata->mac_addr)); in xgbe_probe()
473 if (ret || !is_valid_ether_addr(pdata->mac_addr)) { in xgbe_probe()
489 pdata->phy_mode = PHY_INTERFACE_MODE_XGMII; in xgbe_probe()
493 pdata->per_channel_irq = 1; in xgbe_probe()
497 &pdata->speed_set); in xgbe_probe()
503 switch (pdata->speed_set) { in xgbe_probe()
517 pdata->serdes_blwc, in xgbe_probe()
525 memcpy(pdata->serdes_blwc, xgbe_serdes_blwc, in xgbe_probe()
526 sizeof(pdata->serdes_blwc)); in xgbe_probe()
532 pdata->serdes_cdr_rate, in xgbe_probe()
540 memcpy(pdata->serdes_cdr_rate, xgbe_serdes_cdr_rate, in xgbe_probe()
541 sizeof(pdata->serdes_cdr_rate)); in xgbe_probe()
547 pdata->serdes_pq_skew, in xgbe_probe()
555 memcpy(pdata->serdes_pq_skew, xgbe_serdes_pq_skew, in xgbe_probe()
556 sizeof(pdata->serdes_pq_skew)); in xgbe_probe()
562 pdata->serdes_tx_amp, in xgbe_probe()
570 memcpy(pdata->serdes_tx_amp, xgbe_serdes_tx_amp, in xgbe_probe()
571 sizeof(pdata->serdes_tx_amp)); in xgbe_probe()
577 pdata->serdes_dfe_tap_cfg, in xgbe_probe()
585 memcpy(pdata->serdes_dfe_tap_cfg, xgbe_serdes_dfe_tap_cfg, in xgbe_probe()
586 sizeof(pdata->serdes_dfe_tap_cfg)); in xgbe_probe()
592 pdata->serdes_dfe_tap_ena, in xgbe_probe()
600 memcpy(pdata->serdes_dfe_tap_ena, xgbe_serdes_dfe_tap_ena, in xgbe_probe()
601 sizeof(pdata->serdes_dfe_tap_ena)); in xgbe_probe()
605 if (pdata->use_acpi) in xgbe_probe()
606 ret = xgbe_acpi_support(pdata); in xgbe_probe()
608 ret = xgbe_of_support(pdata); in xgbe_probe()
618 pdata->coherent = (attr == DEV_DMA_COHERENT); in xgbe_probe()
619 if (pdata->coherent) { in xgbe_probe()
620 pdata->axdomain = XGBE_DMA_OS_AXDOMAIN; in xgbe_probe()
621 pdata->arcache = XGBE_DMA_OS_ARCACHE; in xgbe_probe()
622 pdata->awcache = XGBE_DMA_OS_AWCACHE; in xgbe_probe()
624 pdata->axdomain = XGBE_DMA_SYS_AXDOMAIN; in xgbe_probe()
625 pdata->arcache = XGBE_DMA_SYS_ARCACHE; in xgbe_probe()
626 pdata->awcache = XGBE_DMA_SYS_AWCACHE; in xgbe_probe()
635 pdata->dev_irq = ret; in xgbe_probe()
643 pdata->an_irq = ret; in xgbe_probe()
645 netdev->irq = pdata->dev_irq; in xgbe_probe()
646 netdev->base_addr = (unsigned long)pdata->xgmac_regs; in xgbe_probe()
647 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len); in xgbe_probe()
650 xgbe_init_all_fptrs(pdata); in xgbe_probe()
653 pdata->hw_if.exit(pdata); in xgbe_probe()
656 xgbe_get_all_hw_features(pdata); in xgbe_probe()
659 xgbe_default_config(pdata); in xgbe_probe()
663 DMA_BIT_MASK(pdata->hw_feat.dma_width)); in xgbe_probe()
676 pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(), in xgbe_probe()
677 pdata->hw_feat.tx_ch_cnt); in xgbe_probe()
678 pdata->tx_q_count = pdata->tx_ring_count; in xgbe_probe()
679 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count); in xgbe_probe()
685 pdata->rx_ring_count = min_t(unsigned int, in xgbe_probe()
687 pdata->hw_feat.rx_ch_cnt); in xgbe_probe()
688 pdata->rx_q_count = pdata->hw_feat.rx_q_cnt; in xgbe_probe()
689 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_ring_count); in xgbe_probe()
696 netdev_rss_key_fill(pdata->rss_key, sizeof(pdata->rss_key)); in xgbe_probe()
699 XGMAC_SET_BITS(pdata->rss_table[i], MAC_RSSDR, DMCH, in xgbe_probe()
700 i % pdata->rx_ring_count); in xgbe_probe()
702 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, IP2TE, 1); in xgbe_probe()
703 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, TCP4TE, 1); in xgbe_probe()
704 XGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1); in xgbe_probe()
707 pdata->phy_if.phy_init(pdata); in xgbe_probe()
728 if (pdata->hw_feat.rss) in xgbe_probe()
738 pdata->netdev_features = netdev->features; in xgbe_probe()
745 xgbe_init_rx_coalesce(pdata); in xgbe_probe()
746 xgbe_init_tx_coalesce(pdata); in xgbe_probe()
756 snprintf(pdata->an_name, sizeof(pdata->an_name) - 1, "%s-pcs", in xgbe_probe()
760 pdata->dev_workqueue = in xgbe_probe()
762 if (!pdata->dev_workqueue) { in xgbe_probe()
768 pdata->an_workqueue = in xgbe_probe()
769 create_singlethread_workqueue(pdata->an_name); in xgbe_probe()
770 if (!pdata->an_workqueue) { in xgbe_probe()
776 xgbe_ptp_register(pdata); in xgbe_probe()
778 xgbe_debugfs_init(pdata); in xgbe_probe()
789 destroy_workqueue(pdata->dev_workqueue); in xgbe_probe()
809 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_remove() local
813 xgbe_debugfs_exit(pdata); in xgbe_remove()
815 xgbe_ptp_unregister(pdata); in xgbe_remove()
817 flush_workqueue(pdata->an_workqueue); in xgbe_remove()
818 destroy_workqueue(pdata->an_workqueue); in xgbe_remove()
820 flush_workqueue(pdata->dev_workqueue); in xgbe_remove()
821 destroy_workqueue(pdata->dev_workqueue); in xgbe_remove()
836 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_suspend() local
844 pdata->lpm_ctrl = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL1); in xgbe_suspend()
845 pdata->lpm_ctrl |= MDIO_CTRL1_LPOWER; in xgbe_suspend()
846 XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl); in xgbe_suspend()
856 struct xgbe_prv_data *pdata = netdev_priv(netdev); in xgbe_resume() local
861 pdata->lpm_ctrl &= ~MDIO_CTRL1_LPOWER; in xgbe_resume()
862 XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_CTRL1, pdata->lpm_ctrl); in xgbe_resume()