Release 4.11 drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c
/*******************************************************************************
This is the driver for the MAC 10/100 on-chip Ethernet controller
currently tested on all the ST boards based on STb7109 and stx7200 SoCs.
DWC Ether MAC 10/100 Universal version 4.0 has been used for developing
this code.
This only implements the mac core functions for this chip.
Copyright (C) 2007-2009 STMicroelectronics Ltd
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/
#include <linux/crc32.h>
#include <asm/io.h>
#include "dwmac100.h"
static void dwmac100_core_init(struct mac_device_info *hw, int mtu)
{
void __iomem *ioaddr = hw->pcsr;
u32 value = readl(ioaddr + MAC_CONTROL);
writel((value | MAC_CORE_INIT), ioaddr + MAC_CONTROL);
#ifdef STMMAC_VLAN_TAG_USED
writel(ETH_P_8021Q, ioaddr + MAC_VLAN1);
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 45 | 75.00% | 2 | 50.00% |
Vince Bridgers | 15 | 25.00% | 2 | 50.00% |
Total | 60 | 100.00% | 4 | 100.00% |
static void dwmac100_dump_mac_regs(struct mac_device_info *hw, u32 *reg_space)
{
void __iomem *ioaddr = hw->pcsr;
reg_space[MAC_CONTROL / 4] = readl(ioaddr + MAC_CONTROL);
reg_space[MAC_ADDR_HIGH / 4] = readl(ioaddr + MAC_ADDR_HIGH);
reg_space[MAC_ADDR_LOW / 4] = readl(ioaddr + MAC_ADDR_LOW);
reg_space[MAC_HASH_HIGH / 4] = readl(ioaddr + MAC_HASH_HIGH);
reg_space[MAC_HASH_LOW / 4] = readl(ioaddr + MAC_HASH_LOW);
reg_space[MAC_FLOW_CTRL / 4] = readl(ioaddr + MAC_FLOW_CTRL);
reg_space[MAC_VLAN1 / 4] = readl(ioaddr + MAC_VLAN1);
reg_space[MAC_VLAN2 / 4] = readl(ioaddr + MAC_VLAN2);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 73 | 53.68% | 2 | 50.00% |
Corentin Labbe | 52 | 38.24% | 1 | 25.00% |
Vince Bridgers | 11 | 8.09% | 1 | 25.00% |
Total | 136 | 100.00% | 4 | 100.00% |
static int dwmac100_rx_ipc_enable(struct mac_device_info *hw)
{
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Deepak Sikri | 11 | 78.57% | 1 | 50.00% |
Vince Bridgers | 3 | 21.43% | 1 | 50.00% |
Total | 14 | 100.00% | 2 | 100.00% |
static int dwmac100_irq_status(struct mac_device_info *hw,
struct stmmac_extra_stats *x)
{
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 16 | 84.21% | 4 | 80.00% |
Vince Bridgers | 3 | 15.79% | 1 | 20.00% |
Total | 19 | 100.00% | 5 | 100.00% |
static void dwmac100_set_umac_addr(struct mac_device_info *hw,
unsigned char *addr,
unsigned int reg_n)
{
void __iomem *ioaddr = hw->pcsr;
stmmac_set_mac_addr(ioaddr, addr, MAC_ADDR_HIGH, MAC_ADDR_LOW);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 28 | 70.00% | 2 | 66.67% |
Vince Bridgers | 12 | 30.00% | 1 | 33.33% |
Total | 40 | 100.00% | 3 | 100.00% |
static void dwmac100_get_umac_addr(struct mac_device_info *hw,
unsigned char *addr,
unsigned int reg_n)
{
void __iomem *ioaddr = hw->pcsr;
stmmac_get_mac_addr(ioaddr, addr, MAC_ADDR_HIGH, MAC_ADDR_LOW);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 28 | 70.00% | 2 | 66.67% |
Vince Bridgers | 12 | 30.00% | 1 | 33.33% |
Total | 40 | 100.00% | 3 | 100.00% |
static void dwmac100_set_filter(struct mac_device_info *hw,
struct net_device *dev)
{
void __iomem *ioaddr = (void __iomem *)dev->base_addr;
u32 value = readl(ioaddr + MAC_CONTROL);
if (dev->flags & IFF_PROMISC) {
value |= MAC_CONTROL_PR;
value &= ~(MAC_CONTROL_PM | MAC_CONTROL_IF | MAC_CONTROL_HO |
MAC_CONTROL_HP);
} else if ((netdev_mc_count(dev) > HASH_TABLE_SIZE)
|| (dev->flags & IFF_ALLMULTI)) {
value |= MAC_CONTROL_PM;
value &= ~(MAC_CONTROL_PR | MAC_CONTROL_IF | MAC_CONTROL_HO);
writel(0xffffffff, ioaddr + MAC_HASH_HIGH);
writel(0xffffffff, ioaddr + MAC_HASH_LOW);
} else if (netdev_mc_empty(dev)) { /* no multicast */
value &= ~(MAC_CONTROL_PM | MAC_CONTROL_PR | MAC_CONTROL_IF |
MAC_CONTROL_HO | MAC_CONTROL_HP);
} else {
u32 mc_filter[2];
struct netdev_hw_addr *ha;
/* Perfect filter mode for physical address and Hash
* filter for multicast
*/
value |= MAC_CONTROL_HP;
value &= ~(MAC_CONTROL_PM | MAC_CONTROL_PR |
MAC_CONTROL_IF | MAC_CONTROL_HO);
memset(mc_filter, 0, sizeof(mc_filter));
netdev_for_each_mc_addr(ha, dev) {
/* The upper 6 bits of the calculated CRC are used to
* index the contens of the hash table
*/
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
/* The most significant bit determines the register to
* use (H/L) while the other 5 bits determine the bit
* within the register.
*/
mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
}
writel(mc_filter[0], ioaddr + MAC_HASH_LOW);
writel(mc_filter[1], ioaddr + MAC_HASH_HIGH);
}
writel(value, ioaddr + MAC_CONTROL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 259 | 98.11% | 3 | 75.00% |
Vince Bridgers | 5 | 1.89% | 1 | 25.00% |
Total | 264 | 100.00% | 4 | 100.00% |
static void dwmac100_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
unsigned int fc, unsigned int pause_time)
{
void __iomem *ioaddr = hw->pcsr;
unsigned int flow = MAC_FLOW_CTRL_ENABLE;
if (duplex)
flow |= (pause_time << MAC_FLOW_CTRL_PT_SHIFT);
writel(flow, ioaddr + MAC_FLOW_CTRL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 47 | 79.66% | 2 | 66.67% |
Vince Bridgers | 12 | 20.34% | 1 | 33.33% |
Total | 59 | 100.00% | 3 | 100.00% |
/* No PMT module supported on ST boards with this Eth chip. */
static void dwmac100_pmt(struct mac_device_info *hw, unsigned long mode)
{
return;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 13 | 81.25% | 2 | 66.67% |
Vince Bridgers | 3 | 18.75% | 1 | 33.33% |
Total | 16 | 100.00% | 3 | 100.00% |
static const struct stmmac_ops dwmac100_ops = {
.core_init = dwmac100_core_init,
.rx_ipc = dwmac100_rx_ipc_enable,
.dump_regs = dwmac100_dump_mac_regs,
.host_irq_status = dwmac100_irq_status,
.set_filter = dwmac100_set_filter,
.flow_ctrl = dwmac100_flow_ctrl,
.pmt = dwmac100_pmt,
.set_umac_addr = dwmac100_set_umac_addr,
.get_umac_addr = dwmac100_get_umac_addr,
};
struct mac_device_info *dwmac100_setup(void __iomem *ioaddr, int *synopsys_id)
{
struct mac_device_info *mac;
mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL);
if (!mac)
return NULL;
pr_info("\tDWMAC100\n");
mac->pcsr = ioaddr;
mac->mac = &dwmac100_ops;
mac->dma = &dwmac100_dma_ops;
mac->link.port = MAC_CONTROL_PS;
mac->link.duplex = MAC_CONTROL_F;
mac->link.speed = 0;
mac->mii.addr = MAC_MII_ADDR;
mac->mii.data = MAC_MII_DATA;
mac->mii.addr_shift = 11;
mac->mii.addr_mask = 0x0000F800;
mac->mii.reg_shift = 6;
mac->mii.reg_mask = 0x000007C0;
mac->mii.clk_csr_shift = 2;
mac->mii.clk_csr_mask = GENMASK(5, 2);
/* Synopsys Id is not available on old chips */
*synopsys_id = 0;
return mac;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 96 | 56.47% | 3 | 37.50% |
Corentin Labbe | 47 | 27.65% | 1 | 12.50% |
Dan Carpenter | 8 | 4.71% | 1 | 12.50% |
Alexandre Torgue | 7 | 4.12% | 1 | 12.50% |
Vince Bridgers | 6 | 3.53% | 1 | 12.50% |
Joao Pinto | 6 | 3.53% | 1 | 12.50% |
Total | 170 | 100.00% | 8 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Giuseppe Cavallaro | 661 | 74.94% | 7 | 36.84% |
Corentin Labbe | 100 | 11.34% | 3 | 15.79% |
Vince Bridgers | 82 | 9.30% | 3 | 15.79% |
Deepak Sikri | 13 | 1.47% | 1 | 5.26% |
Dan Carpenter | 8 | 0.91% | 1 | 5.26% |
Alexandre Torgue | 7 | 0.79% | 1 | 5.26% |
Joao Pinto | 6 | 0.68% | 1 | 5.26% |
Alexey Dobriyan | 3 | 0.34% | 1 | 5.26% |
Stephen Hemminger | 2 | 0.23% | 1 | 5.26% |
Total | 882 | 100.00% | 19 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.