From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/8] net: ethernet driver: Fujitsu OGMA
Date: Mon, 14 Jul 2014 15:50:52 +0200 [thread overview]
Message-ID: <18609483.Jzi9Hxcq2r@wuerfel> (raw)
In-Reply-To: <1405233107-4762-1-git-send-email-mollie.wu@linaro.org>
On Sunday 13 July 2014 14:31:47 Mollie Wu wrote:
> +
> +Example:
> + eth0: f_taiki {
> + compatible = "fujitsu,ogma";
> + reg = <0 0x31600000 0x10000>, <0 0x31618000 0x4000>, <0 0x3161c000 0x4000>;
> + interrupts = <0 163 0x4>;
> + clocks = <&clk_alw_0_8>;
> + phy-mode = "rgmii";
> + max-speed = <1000>;
> + max-frame-size = <9000>;
> + local-mac-address = [ a4 17 31 00 00 ed ];
> + phy-handle = <ðphy0>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + ethphy0: ethernet-phy at 1 {
> + device_type = "ethernet-phy";
> + compatible = "ethernet-phy-ieee802.3-c22";
> + reg = <1>;
> + };
> + };
The name of the device should be "ethernet" rather than "f_taiki".
For the compatible string, it would be good to have a version number included.
If you cannot find out the version of the ogma hardware, add the identifier for
the soc it is used in, e.g.
compatible = "fujitsu,mb86s73-ogma", "fujitsu,ogma";
The driver only needs to match the generic string, but it's better
to be prepared for the case where we have to support slightly different
variants.
> +static inline void ogma_writel(struct ogma_priv *priv, u32 reg_addr, u32 val)
> +{
> + writel(val, priv->ioaddr + (reg_addr << 2));
> +}
> +
> +static inline u32 ogma_readl(struct ogma_priv *priv, u32 reg_addr)
> +{
> + return readl(priv->ioaddr + (reg_addr << 2));
> +}
for best performance, it may be better to use readl_relaxed() by default
and only use the nonrelaxed accesses in the cases where you have to
synchronize with DMA transfers.
> +
> +#define TIMEOUT_SPINS_MAC 1000000
> +
> +static u32 ogma_clk_type(u32 freq)
> +{
> + if (freq < 35 * OGMA_CLK_MHZ)
> + return OGMA_GMAC_GAR_REG_CR_25_35_MHZ;
> + if (freq < 60 * OGMA_CLK_MHZ)
> + return OGMA_GMAC_GAR_REG_CR_35_60_MHZ;
> + if (freq < 100 * OGMA_CLK_MHZ)
> + return OGMA_GMAC_GAR_REG_CR_60_100_MHZ;
> + if (freq < 150 * OGMA_CLK_MHZ)
> + return OGMA_GMAC_GAR_REG_CR_100_150_MHZ;
> + if (freq < 250 * OGMA_CLK_MHZ)
> + return OGMA_GMAC_GAR_REG_CR_150_250_MHZ;
> +
> + return OGMA_GMAC_GAR_REG_CR_250_300_MHZ;
> +}
> +
> +static int ogma_wait_while_busy(struct ogma_priv *priv, u32 addr, u32 mask)
> +{
> + u32 timeout = TIMEOUT_SPINS_MAC;
> +
> + while (--timeout && ogma_readl(priv, addr) & mask)
> + ;
> + if (!timeout) {
> + netdev_WARN(priv->net_device, "%s: timeout\n", __func__);
> + return -ETIMEDOUT;
> + }
> +
> + return 0;
> +}
The callers of this function seem to all be from non-atomic context, so it
would be good to occasionally msleep() here, either after each try, or
after initially spinning for as long as it takes to succeed most of the
time.
> +
> +static void ogma_napi_tx_processing(struct napi_struct *napi_p)
> +{
> + struct ogma_priv *priv = container_of(napi_p, struct ogma_priv, napi);
> +
> + ogma_ring_irq_clr(priv, OGMA_RING_TX, OGMA_IRQ_EMPTY);
> + ogma_clean_tx_desc_ring(priv);
> +
> + if (netif_queue_stopped(priv->net_device) &&
> + ogma_get_tx_avail_num(priv) >= OGMA_NETDEV_TX_PKT_SCAT_NUM_MAX)
> + netif_wake_queue(priv->net_device);
> +}
You should probably call netdev_tx_completed_queue() here and
netdev_tx_sent_queue() when sending the frame. See http://lwn.net/Articles/454390/
for a description of the API.
Arnd
next prev parent reply other threads:[~2014-07-14 13:50 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <message-id-of-cover-letter>
2014-07-13 6:28 ` [PATCH 1/8] ARM: Add platform support for Fujitsu MB86S7X SoCs Mollie Wu
2014-07-14 13:33 ` Arnd Bergmann
2014-07-15 17:37 ` Jassi Brar
2014-07-15 20:09 ` Arnd Bergmann
2014-07-17 13:32 ` Jassi Brar
2014-07-17 13:48 ` Arnd Bergmann
2014-07-17 16:54 ` Jassi Brar
2014-07-17 17:12 ` Arnd Bergmann
2014-07-15 15:11 ` Rob Herring
2014-07-15 16:11 ` Nicolas Pitre
2014-07-15 18:03 ` Jassi Brar
2014-07-16 5:52 ` Andy Green
2014-07-15 17:05 ` Nicolas Pitre
2014-07-15 18:16 ` Jassi Brar
2014-07-13 6:29 ` [PATCH 2/8] mmc: sdhci: host: add new f_sdh30 Mollie Wu
2014-07-14 14:04 ` Arnd Bergmann
2014-07-16 9:35 ` Vincent.Yang
2014-07-16 10:10 ` Arnd Bergmann
2014-07-16 11:07 ` Vincent.Yang
2014-07-13 6:30 ` [PATCH 3/8] mmc: core: add manual resume capability Mollie Wu
2014-07-13 6:30 ` [PATCH 4/8] clk: Add clock driver for mb86s7x Mollie Wu
2014-07-14 14:08 ` Arnd Bergmann
2014-07-16 7:09 ` Jassi Brar
2014-07-13 6:31 ` [PATCH 5/8] pinctrl: add driver for MB86S7x Mollie Wu
2014-07-22 16:11 ` Linus Walleij
2014-07-24 18:04 ` Jassi Brar
2014-08-08 12:42 ` Linus Walleij
2014-08-22 7:46 ` Jassi Brar
2014-08-27 16:58 ` Jassi Brar
2014-09-03 9:17 ` Linus Walleij
2014-07-13 6:31 ` [PATCH 6/8] net: ethernet driver: Fujitsu OGMA Mollie Wu
2014-07-14 9:06 ` Tobias Klauser
2014-07-14 10:36 ` Andy Green
2014-07-14 13:50 ` Arnd Bergmann [this message]
2014-07-13 6:32 ` [PATCH 7/8] mailbox: f_mhu: add driver for Fujitsu MHU controller Mollie Wu
2014-07-16 17:37 ` Sudeep Holla
2014-07-17 6:25 ` Jassi Brar
2014-07-17 10:31 ` Sudeep Holla
2014-07-17 12:56 ` Jassi Brar
2014-07-17 15:09 ` Sudeep Holla
2014-07-17 17:07 ` Jassi Brar
2014-07-17 18:51 ` Sudeep Holla
2014-07-18 9:06 ` Jassi Brar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18609483.Jzi9Hxcq2r@wuerfel \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox