diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-01 16:05:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-01 16:05:40 -0500 |
commit | 13dda80e48439b446d0bc9bab34b91484bc8f533 (patch) | |
tree | e8037122d65fe2a5dd8f633a7648b2597640a2ce /drivers | |
parent | 379e3a820da171cb1d97e8dccd736a69cebfb7c0 (diff) | |
parent | 5f19daa16ffca55db5b0253eba2bd0f71ee7f7f4 (diff) |
Merge branch 'davinci-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci
* 'davinci-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci: (40 commits)
DaVinci DM365: Adding support for SPI EEPROM
DaVinci DM365: Adding DM365 SPI support
DaVinci DM355: Modifications to DM355 SPI support
DaVinci: SPI: Adding header file for SPI support.
davinci: dm646x: CDCE clocks: davinci_clk converted to clk_lookup
davinci: clkdev cleanup: remove clk_lookup wrapper, use clkdev_add_table()
DaVinci: DM365: Voice codec support for the DM365 SoC
davinci: clock: let clk->set_rate function sleep
Add SDA and SCL pin numbers to i2c platform data
davinci: da8xx/omap-l1xx: Add EDMA platform data for da850/omap-l138
davinci: build list of unused EDMA events dynamically
davinci: Fix edma_alloc_channel api for EDMA_CHANNEL_ANY case
davinci: Keep count of channel controllers on a platform
davinci: Correct return value of edma_alloc_channel api
davinci: add CDCE949 support on DM6467 EVM
davinci: add support for CDCE949 clock synthesizer
davinci: da850/omap-l138 EVM: register for suspend support
davinci: da850/omap-l138: add support for SoC suspend
davinci: add power management support
DaVinci: DM365: Changing default queue for DM365.
...
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/Kconfig | 2 | ||||
-rw-r--r-- | drivers/net/davinci_emac.c | 55 |
2 files changed, 37 insertions, 20 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index dd9a09c72dff..18300625b05b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -920,7 +920,7 @@ config NET_NETX | |||
920 | 920 | ||
921 | config TI_DAVINCI_EMAC | 921 | config TI_DAVINCI_EMAC |
922 | tristate "TI DaVinci EMAC Support" | 922 | tristate "TI DaVinci EMAC Support" |
923 | depends on ARM && ARCH_DAVINCI | 923 | depends on ARM && ( ARCH_DAVINCI || ARCH_OMAP3 ) |
924 | select PHYLIB | 924 | select PHYLIB |
925 | help | 925 | help |
926 | This driver supports TI's DaVinci Ethernet . | 926 | This driver supports TI's DaVinci Ethernet . |
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 33c4fe26178c..1605bc225b0c 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c | |||
@@ -62,12 +62,11 @@ | |||
62 | #include <linux/bitops.h> | 62 | #include <linux/bitops.h> |
63 | #include <linux/io.h> | 63 | #include <linux/io.h> |
64 | #include <linux/uaccess.h> | 64 | #include <linux/uaccess.h> |
65 | #include <linux/davinci_emac.h> | ||
65 | 66 | ||
66 | #include <asm/irq.h> | 67 | #include <asm/irq.h> |
67 | #include <asm/page.h> | 68 | #include <asm/page.h> |
68 | 69 | ||
69 | #include <mach/emac.h> | ||
70 | |||
71 | static int debug_level; | 70 | static int debug_level; |
72 | module_param(debug_level, int, 0); | 71 | module_param(debug_level, int, 0); |
73 | MODULE_PARM_DESC(debug_level, "DaVinci EMAC debug level (NETIF_MSG bits)"); | 72 | MODULE_PARM_DESC(debug_level, "DaVinci EMAC debug level (NETIF_MSG bits)"); |
@@ -465,6 +464,7 @@ struct emac_priv { | |||
465 | void __iomem *ctrl_base; | 464 | void __iomem *ctrl_base; |
466 | void __iomem *emac_ctrl_ram; | 465 | void __iomem *emac_ctrl_ram; |
467 | u32 ctrl_ram_size; | 466 | u32 ctrl_ram_size; |
467 | u32 hw_ram_addr; | ||
468 | struct emac_txch *txch[EMAC_DEF_MAX_TX_CH]; | 468 | struct emac_txch *txch[EMAC_DEF_MAX_TX_CH]; |
469 | struct emac_rxch *rxch[EMAC_DEF_MAX_RX_CH]; | 469 | struct emac_rxch *rxch[EMAC_DEF_MAX_RX_CH]; |
470 | u32 link; /* 1=link on, 0=link off */ | 470 | u32 link; /* 1=link on, 0=link off */ |
@@ -488,6 +488,9 @@ struct emac_priv { | |||
488 | struct mii_bus *mii_bus; | 488 | struct mii_bus *mii_bus; |
489 | struct phy_device *phydev; | 489 | struct phy_device *phydev; |
490 | spinlock_t lock; | 490 | spinlock_t lock; |
491 | /*platform specific members*/ | ||
492 | void (*int_enable) (void); | ||
493 | void (*int_disable) (void); | ||
491 | }; | 494 | }; |
492 | 495 | ||
493 | /* clock frequency for EMAC */ | 496 | /* clock frequency for EMAC */ |
@@ -495,11 +498,9 @@ static struct clk *emac_clk; | |||
495 | static unsigned long emac_bus_frequency; | 498 | static unsigned long emac_bus_frequency; |
496 | static unsigned long mdio_max_freq; | 499 | static unsigned long mdio_max_freq; |
497 | 500 | ||
498 | /* EMAC internal utility function */ | 501 | #define emac_virt_to_phys(addr, priv) \ |
499 | static inline u32 emac_virt_to_phys(void __iomem *addr) | 502 | (((u32 __force)(addr) - (u32 __force)(priv->emac_ctrl_ram)) \ |
500 | { | 503 | + priv->hw_ram_addr) |
501 | return (u32 __force) io_v2p(addr); | ||
502 | } | ||
503 | 504 | ||
504 | /* Cache macros - Packet buffers would be from skb pool which is cached */ | 505 | /* Cache macros - Packet buffers would be from skb pool which is cached */ |
505 | #define EMAC_VIRT_NOCACHE(addr) (addr) | 506 | #define EMAC_VIRT_NOCACHE(addr) (addr) |
@@ -1002,6 +1003,8 @@ static void emac_int_disable(struct emac_priv *priv) | |||
1002 | emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0x0); | 1003 | emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0x0); |
1003 | emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0x0); | 1004 | emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0x0); |
1004 | /* NOTE: Rx Threshold and Misc interrupts are not disabled */ | 1005 | /* NOTE: Rx Threshold and Misc interrupts are not disabled */ |
1006 | if (priv->int_disable) | ||
1007 | priv->int_disable(); | ||
1005 | 1008 | ||
1006 | local_irq_restore(flags); | 1009 | local_irq_restore(flags); |
1007 | 1010 | ||
@@ -1021,6 +1024,9 @@ static void emac_int_disable(struct emac_priv *priv) | |||
1021 | static void emac_int_enable(struct emac_priv *priv) | 1024 | static void emac_int_enable(struct emac_priv *priv) |
1022 | { | 1025 | { |
1023 | if (priv->version == EMAC_VERSION_2) { | 1026 | if (priv->version == EMAC_VERSION_2) { |
1027 | if (priv->int_enable) | ||
1028 | priv->int_enable(); | ||
1029 | |||
1024 | emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0xff); | 1030 | emac_ctrl_write(EMAC_DM646X_CMRXINTEN, 0xff); |
1025 | emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0xff); | 1031 | emac_ctrl_write(EMAC_DM646X_CMTXINTEN, 0xff); |
1026 | 1032 | ||
@@ -1302,7 +1308,7 @@ static int emac_tx_bdproc(struct emac_priv *priv, u32 ch, u32 budget) | |||
1302 | curr_bd = txch->active_queue_head; | 1308 | curr_bd = txch->active_queue_head; |
1303 | if (NULL == curr_bd) { | 1309 | if (NULL == curr_bd) { |
1304 | emac_write(EMAC_TXCP(ch), | 1310 | emac_write(EMAC_TXCP(ch), |
1305 | emac_virt_to_phys(txch->last_hw_bdprocessed)); | 1311 | emac_virt_to_phys(txch->last_hw_bdprocessed, priv)); |
1306 | txch->no_active_pkts++; | 1312 | txch->no_active_pkts++; |
1307 | spin_unlock_irqrestore(&priv->tx_lock, flags); | 1313 | spin_unlock_irqrestore(&priv->tx_lock, flags); |
1308 | return 0; | 1314 | return 0; |
@@ -1312,7 +1318,7 @@ static int emac_tx_bdproc(struct emac_priv *priv, u32 ch, u32 budget) | |||
1312 | while ((curr_bd) && | 1318 | while ((curr_bd) && |
1313 | ((frame_status & EMAC_CPPI_OWNERSHIP_BIT) == 0) && | 1319 | ((frame_status & EMAC_CPPI_OWNERSHIP_BIT) == 0) && |
1314 | (pkts_processed < budget)) { | 1320 | (pkts_processed < budget)) { |
1315 | emac_write(EMAC_TXCP(ch), emac_virt_to_phys(curr_bd)); | 1321 | emac_write(EMAC_TXCP(ch), emac_virt_to_phys(curr_bd, priv)); |
1316 | txch->active_queue_head = curr_bd->next; | 1322 | txch->active_queue_head = curr_bd->next; |
1317 | if (frame_status & EMAC_CPPI_EOQ_BIT) { | 1323 | if (frame_status & EMAC_CPPI_EOQ_BIT) { |
1318 | if (curr_bd->next) { /* misqueued packet */ | 1324 | if (curr_bd->next) { /* misqueued packet */ |
@@ -1399,7 +1405,7 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, u32 ch) | |||
1399 | txch->active_queue_tail = curr_bd; | 1405 | txch->active_queue_tail = curr_bd; |
1400 | if (1 != txch->queue_active) { | 1406 | if (1 != txch->queue_active) { |
1401 | emac_write(EMAC_TXHDP(ch), | 1407 | emac_write(EMAC_TXHDP(ch), |
1402 | emac_virt_to_phys(curr_bd)); | 1408 | emac_virt_to_phys(curr_bd, priv)); |
1403 | txch->queue_active = 1; | 1409 | txch->queue_active = 1; |
1404 | } | 1410 | } |
1405 | ++txch->queue_reinit; | 1411 | ++txch->queue_reinit; |
@@ -1411,10 +1417,11 @@ static int emac_send(struct emac_priv *priv, struct emac_netpktobj *pkt, u32 ch) | |||
1411 | tail_bd->next = curr_bd; | 1417 | tail_bd->next = curr_bd; |
1412 | txch->active_queue_tail = curr_bd; | 1418 | txch->active_queue_tail = curr_bd; |
1413 | tail_bd = EMAC_VIRT_NOCACHE(tail_bd); | 1419 | tail_bd = EMAC_VIRT_NOCACHE(tail_bd); |
1414 | tail_bd->h_next = (int)emac_virt_to_phys(curr_bd); | 1420 | tail_bd->h_next = (int)emac_virt_to_phys(curr_bd, priv); |
1415 | frame_status = tail_bd->mode; | 1421 | frame_status = tail_bd->mode; |
1416 | if (frame_status & EMAC_CPPI_EOQ_BIT) { | 1422 | if (frame_status & EMAC_CPPI_EOQ_BIT) { |
1417 | emac_write(EMAC_TXHDP(ch), emac_virt_to_phys(curr_bd)); | 1423 | emac_write(EMAC_TXHDP(ch), |
1424 | emac_virt_to_phys(curr_bd, priv)); | ||
1418 | frame_status &= ~(EMAC_CPPI_EOQ_BIT); | 1425 | frame_status &= ~(EMAC_CPPI_EOQ_BIT); |
1419 | tail_bd->mode = frame_status; | 1426 | tail_bd->mode = frame_status; |
1420 | ++txch->end_of_queue_add; | 1427 | ++txch->end_of_queue_add; |
@@ -1604,7 +1611,8 @@ static int emac_init_rxch(struct emac_priv *priv, u32 ch, char *param) | |||
1604 | } | 1611 | } |
1605 | 1612 | ||
1606 | /* populate the hardware descriptor */ | 1613 | /* populate the hardware descriptor */ |
1607 | curr_bd->h_next = emac_virt_to_phys(rxch->active_queue_head); | 1614 | curr_bd->h_next = emac_virt_to_phys(rxch->active_queue_head, |
1615 | priv); | ||
1608 | /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */ | 1616 | /* FIXME buff_ptr = dma_map_single(... data_ptr ...) */ |
1609 | curr_bd->buff_ptr = virt_to_phys(curr_bd->data_ptr); | 1617 | curr_bd->buff_ptr = virt_to_phys(curr_bd->data_ptr); |
1610 | curr_bd->off_b_len = rxch->buf_size; | 1618 | curr_bd->off_b_len = rxch->buf_size; |
@@ -1879,7 +1887,7 @@ static void emac_addbd_to_rx_queue(struct emac_priv *priv, u32 ch, | |||
1879 | rxch->active_queue_tail = curr_bd; | 1887 | rxch->active_queue_tail = curr_bd; |
1880 | if (0 != rxch->queue_active) { | 1888 | if (0 != rxch->queue_active) { |
1881 | emac_write(EMAC_RXHDP(ch), | 1889 | emac_write(EMAC_RXHDP(ch), |
1882 | emac_virt_to_phys(rxch->active_queue_head)); | 1890 | emac_virt_to_phys(rxch->active_queue_head, priv)); |
1883 | rxch->queue_active = 1; | 1891 | rxch->queue_active = 1; |
1884 | } | 1892 | } |
1885 | } else { | 1893 | } else { |
@@ -1890,11 +1898,11 @@ static void emac_addbd_to_rx_queue(struct emac_priv *priv, u32 ch, | |||
1890 | rxch->active_queue_tail = curr_bd; | 1898 | rxch->active_queue_tail = curr_bd; |
1891 | tail_bd->next = curr_bd; | 1899 | tail_bd->next = curr_bd; |
1892 | tail_bd = EMAC_VIRT_NOCACHE(tail_bd); | 1900 | tail_bd = EMAC_VIRT_NOCACHE(tail_bd); |
1893 | tail_bd->h_next = emac_virt_to_phys(curr_bd); | 1901 | tail_bd->h_next = emac_virt_to_phys(curr_bd, priv); |
1894 | frame_status = tail_bd->mode; | 1902 | frame_status = tail_bd->mode; |
1895 | if (frame_status & EMAC_CPPI_EOQ_BIT) { | 1903 | if (frame_status & EMAC_CPPI_EOQ_BIT) { |
1896 | emac_write(EMAC_RXHDP(ch), | 1904 | emac_write(EMAC_RXHDP(ch), |
1897 | emac_virt_to_phys(curr_bd)); | 1905 | emac_virt_to_phys(curr_bd, priv)); |
1898 | frame_status &= ~(EMAC_CPPI_EOQ_BIT); | 1906 | frame_status &= ~(EMAC_CPPI_EOQ_BIT); |
1899 | tail_bd->mode = frame_status; | 1907 | tail_bd->mode = frame_status; |
1900 | ++rxch->end_of_queue_add; | 1908 | ++rxch->end_of_queue_add; |
@@ -1987,7 +1995,7 @@ static int emac_rx_bdproc(struct emac_priv *priv, u32 ch, u32 budget) | |||
1987 | curr_pkt->num_bufs = 1; | 1995 | curr_pkt->num_bufs = 1; |
1988 | curr_pkt->pkt_length = | 1996 | curr_pkt->pkt_length = |
1989 | (frame_status & EMAC_RX_BD_PKT_LENGTH_MASK); | 1997 | (frame_status & EMAC_RX_BD_PKT_LENGTH_MASK); |
1990 | emac_write(EMAC_RXCP(ch), emac_virt_to_phys(curr_bd)); | 1998 | emac_write(EMAC_RXCP(ch), emac_virt_to_phys(curr_bd, priv)); |
1991 | ++rxch->processed_bd; | 1999 | ++rxch->processed_bd; |
1992 | last_bd = curr_bd; | 2000 | last_bd = curr_bd; |
1993 | curr_bd = last_bd->next; | 2001 | curr_bd = last_bd->next; |
@@ -1998,7 +2006,7 @@ static int emac_rx_bdproc(struct emac_priv *priv, u32 ch, u32 budget) | |||
1998 | if (curr_bd) { | 2006 | if (curr_bd) { |
1999 | ++rxch->mis_queued_packets; | 2007 | ++rxch->mis_queued_packets; |
2000 | emac_write(EMAC_RXHDP(ch), | 2008 | emac_write(EMAC_RXHDP(ch), |
2001 | emac_virt_to_phys(curr_bd)); | 2009 | emac_virt_to_phys(curr_bd, priv)); |
2002 | } else { | 2010 | } else { |
2003 | ++rxch->end_of_queue; | 2011 | ++rxch->end_of_queue; |
2004 | rxch->queue_active = 0; | 2012 | rxch->queue_active = 0; |
@@ -2099,7 +2107,7 @@ static int emac_hw_enable(struct emac_priv *priv) | |||
2099 | emac_write(EMAC_RXINTMASKSET, BIT(ch)); | 2107 | emac_write(EMAC_RXINTMASKSET, BIT(ch)); |
2100 | rxch->queue_active = 1; | 2108 | rxch->queue_active = 1; |
2101 | emac_write(EMAC_RXHDP(ch), | 2109 | emac_write(EMAC_RXHDP(ch), |
2102 | emac_virt_to_phys(rxch->active_queue_head)); | 2110 | emac_virt_to_phys(rxch->active_queue_head, priv)); |
2103 | } | 2111 | } |
2104 | 2112 | ||
2105 | /* Enable MII */ | 2113 | /* Enable MII */ |
@@ -2660,6 +2668,9 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev) | |||
2660 | priv->phy_mask = pdata->phy_mask; | 2668 | priv->phy_mask = pdata->phy_mask; |
2661 | priv->rmii_en = pdata->rmii_en; | 2669 | priv->rmii_en = pdata->rmii_en; |
2662 | priv->version = pdata->version; | 2670 | priv->version = pdata->version; |
2671 | priv->int_enable = pdata->interrupt_enable; | ||
2672 | priv->int_disable = pdata->interrupt_disable; | ||
2673 | |||
2663 | emac_dev = &ndev->dev; | 2674 | emac_dev = &ndev->dev; |
2664 | /* Get EMAC platform data */ | 2675 | /* Get EMAC platform data */ |
2665 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2676 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -2692,6 +2703,12 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev) | |||
2692 | priv->ctrl_ram_size = pdata->ctrl_ram_size; | 2703 | priv->ctrl_ram_size = pdata->ctrl_ram_size; |
2693 | priv->emac_ctrl_ram = priv->remap_addr + pdata->ctrl_ram_offset; | 2704 | priv->emac_ctrl_ram = priv->remap_addr + pdata->ctrl_ram_offset; |
2694 | 2705 | ||
2706 | if (pdata->hw_ram_addr) | ||
2707 | priv->hw_ram_addr = pdata->hw_ram_addr; | ||
2708 | else | ||
2709 | priv->hw_ram_addr = (u32 __force)res->start + | ||
2710 | pdata->ctrl_ram_offset; | ||
2711 | |||
2695 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 2712 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
2696 | if (!res) { | 2713 | if (!res) { |
2697 | dev_err(emac_dev, "DaVinci EMAC: Error getting irq res\n"); | 2714 | dev_err(emac_dev, "DaVinci EMAC: Error getting irq res\n"); |