From: Florian Fainelli <f.fainelli@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH RFC v2 23/32] net: dsa: bcm_sf2: make it a real platform driver
Date: Thu, 3 Mar 2016 10:33:03 -0800 [thread overview]
Message-ID: <56D8835F.4040607@gmail.com> (raw)
In-Reply-To: <1456677700-23027-24-git-send-email-andrew@lunn.ch>
On 28/02/16 08:41, Andrew Lunn wrote:
> From: Florian Fainelli <f.fainelli@gmail.com>
>
> The Broadcom Starfighter 2 switch driver should be a proper platform
> driver, now that the DSA code has been updated to allow that, register
> a switch device, feed it with the proper configuration data coming
> from Device Tree and register our switch device with DSA.
>
> The bulk of the changes consist in moving what bcm_sf2_sw_setup() did
> into the component slave bind function.
>
> This change does not however prevent the old DSA binding from working.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
[snip]
> + /* All the interesting properties are at the parent device_node
> + * level
> + */
> + dn = ds->pd->of_node->parent;
This is no longer true with the binding you are proposing, but see more
below.
> + bcm_sf2_identify_ports(priv, ds->pd->of_node);
> +
> + priv->irq0 = irq_of_parse_and_map(dn, 0);
> + priv->irq1 = irq_of_parse_and_map(dn, 1);
> +
> + base = &priv->core;
> + for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
> + *base = of_iomap(dn, i);
> + if (!base) {
> + pr_err("unable to find register: %s\n", reg_names[i]);
> + ret = -ENOMEM;
> + goto out_unmap;
> + }
> + base++;
> + }
> +
> + ret = bcm_sf2_sw_rst(priv);
> + if (ret) {
> + pr_err("unable to software reset switch: %d\n", ret);
> + goto out_unmap;
> + }
> +
> + /* Disable all interrupts and request them */
> + bcm_sf2_intr_disable(priv);
> +
> + ret = request_irq(priv->irq0, bcm_sf2_switch_0_isr, 0,
> + "switch_0", priv);
> + if (ret < 0) {
> + pr_err("failed to request switch_0 IRQ\n");
> + goto out_unmap;
> + }
> +
> + ret = request_irq(priv->irq1, bcm_sf2_switch_1_isr, 0,
> + "switch_1", priv);
> + if (ret < 0) {
> + pr_err("failed to request switch_1 IRQ\n");
> + goto out_free_irq0;
> + }
> +
> + /* Reset the MIB counters */
> + reg = core_readl(priv, CORE_GMNCFGCFG);
> + reg |= RST_MIB_CNT;
> + core_writel(priv, reg, CORE_GMNCFGCFG);
> + reg &= ~RST_MIB_CNT;
> + core_writel(priv, reg, CORE_GMNCFGCFG);
> +
> + /* Get the maximum number of ports for this switch */
> + priv->hw_params.num_ports = core_readl(priv, CORE_IMP0_PRT_ID) + 1;
> + if (priv->hw_params.num_ports > DSA_MAX_PORTS)
> + priv->hw_params.num_ports = DSA_MAX_PORTS;
> +
> + /* Assume a single GPHY setup if we can't read that property */
> + if (of_property_read_u32(dn, "brcm,num-gphy",
> + &priv->hw_params.num_gphy))
> + priv->hw_params.num_gphy = 1;
> +
> + /* Include the pseudo-PHY address and the broadcast PHY address to
> + * divert reads towards our workaround. This is only required for
> + * 7445D0, since 7445E0 disconnects the internal switch pseudo-PHY such
> + * that we can use the regular SWITCH_MDIO master controller instead.
> + *
> + * By default, DSA initializes ds->phys_mii_mask to ds->phys_port_mask
> + * to have a 1:1 mapping between Port address and PHY address in order
> + * to utilize the slave_mii_bus instance to read from Port PHYs. This is
> + * not what we want here, so we initialize phys_mii_mask 0 to always
> + * utilize the "master" MDIO bus backed by the "mdio-unimac" driver.
> + */
> + if (of_machine_is_compatible("brcm,bcm7445d0"))
> + ds->phys_mii_mask |= ((1 << BRCM_PSEUDO_PHY_ADDR) | (1 << 0));
> + else
> + ds->phys_mii_mask = 0;
> +
> + rev = reg_readl(priv, REG_SWITCH_REVISION);
> + priv->hw_params.top_rev = (rev >> SWITCH_TOP_REV_SHIFT) &
> + SWITCH_TOP_REV_MASK;
> + priv->hw_params.core_rev = (rev & SF2_REV_MASK);
> +
> + rev = reg_readl(priv, REG_PHY_REVISION);
> + priv->hw_params.gphy_rev = rev & PHY_REVISION_MASK;
> +
> + pr_info("Starfighter 2 top: %x.%02x, core: %x.%02x base: 0x%p, IRQs: %d, %d\n",
> + priv->hw_params.top_rev >> 8, priv->hw_params.top_rev & 0xff,
> + priv->hw_params.core_rev >> 8, priv->hw_params.core_rev & 0xff,
> + priv->core, priv->irq0, priv->irq1);
> +
> + platform_set_drvdata(pdev, ds);
> +
> + return dsa_switch_register(dst, ds, dn, "Starfighter 2");
> +
> +out_free_irq0:
> + free_irq(priv->irq0, priv);
> +out_unmap:
> + base = &priv->core;
> + for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
> + if (*base)
> + iounmap(*base);
> + base++;
> + }
> + return ret;
> +}
> +
> +static void bcm_sf2_sw_unbind(struct device *dev,
> + struct device *master, void *data)
> +{
> + struct dsa_switch *ds = dev_get_drvdata(dev);
> + struct bcm_sf2_priv *priv = ds_to_priv(ds);
> +
> + /* Disable all ports and interrupts */
> + priv->wol_ports_mask = 0;
> + bcm_sf2_sw_suspend(ds);
> + dsa_switch_unregister(ds);
> +}
> +
> +static const struct component_ops bcm_sf2_component_ops = {
> + .bind = bcm_sf2_sw_bind,
> + .unbind = bcm_sf2_sw_unbind,
> +};
> +
> +static int bcm_sf2_sw_remove(struct platform_device *pdev)
> +{
> + component_del(&pdev->dev, &bcm_sf2_component_ops);
>
> return 0;
> }
> -module_init(bcm_sf2_init);
>
> -static void __exit bcm_sf2_exit(void)
> +static int bcm_sf2_sw_probe(struct platform_device *pdev)
> {
> - unregister_switch_driver(&bcm_sf2_switch_driver);
> + return component_add(&pdev->dev, &bcm_sf2_component_ops);
> }
> -module_exit(bcm_sf2_exit);
> +
> +static const struct of_device_id bcm_sf2_of_match[] = {
> + { .compatible = "brcm,brcm-sf2" },
As I mentioned before, this is a no go for the SF2 platforms out there
which are using the old DSA binding (incorrectly maybe, but using it)
and whose bootloader cannot be changed, but I still have a fundamental
problem with how this is approached here, my initial attempts at making
the SF2 driver a real platform driver was to take the
brcm,bcm7445-switch-v4.0 compatible string as match here, and call
dsa_of_probe() to get the old binding to populate the dsa_platform_data
structure on our behalf, and not require the "dsa" platform device to be
there at all, just some piece of code to be resident in the kernel that
exposes dsa_switch_register().
So, not really the same direction we are taking here, and as I will
reply shortly in the cover letter, the need for the special "dsa"
platform device is only an artifact now, and to catch older setups, it
does not need to exist.
--
Florian
next prev parent reply other threads:[~2016-03-03 18:34 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-28 16:41 [PATCH RFC v2 00/32] Make DSA switches linux devices Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 01/32] net: dsa: Move platform data allocation for OF Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 02/32] dsa: Rename mv88e6123_61_65 to mv88e6123 to be consistent Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 03/32] dsa: Make setup and finish more symmetrical Andrew Lunn
2016-03-11 23:54 ` Florian Fainelli
2016-02-28 16:41 ` [PATCH RFC v2 04/32] net: dsa: Pass the dsa device to the switch drivers Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 05/32] net: dsa: Have the switch driver allocate there own private memory Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 06/32] net: dsa: Remove allocation of driver " Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 07/32] net: dsa: Keep the mii bus and address in the private structure Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 08/32] net: dsa: dsa.c: Refactor to increase symmetry Andrew Lunn
2016-03-11 23:54 ` Florian Fainelli
2016-02-28 16:41 ` [PATCH RFC v2 09/32] driver: component: Add support for empty match table Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 10/32] net: dsa: Add basic support for component master support Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 11/32] net: dsa: Keep a reference to the switch device for component matching Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 12/32] net: dsa: Add slave component matches based on a phandle to the slave Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 13/32] net: dsa: Make dsa,mii-bus optional Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 14/32] net: dsa: Add register/unregister functions for switch drivers Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 15/32] net: dsa: Rename DSA probe function Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 16/32] dsa: mv88e6xxx: Use bus in mv88e6xxx_lookup_name() Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 17/32] dsa: mv88e6xxx: Add shared code for binding/unbinding a switch driver Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 18/32] dsa: mv88e6xxx: Prepare for turning this into a library module Andrew Lunn
2016-02-29 2:40 ` Vivien Didelot
2016-02-29 14:53 ` Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 19/32] dsa: mv88e6xxx: Add macro for registering the drivers Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 20/32] dsa: Add mdio device support to Marvell switches Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 21/32] net: mdio: Add mdiodev_{read|write} helpers Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 22/32] net: dsa: Better integrate the drivers with mdio device Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 23/32] net: dsa: bcm_sf2: make it a real platform driver Andrew Lunn
2016-03-03 18:33 ` Florian Fainelli [this message]
2016-03-03 19:12 ` Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 24/32] net: dsa: Add some debug prints for error cases Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 25/32] net: dsa: Setup the switches after all have been probed Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 26/32] net: dsa: Only setup platform switches, not device switches Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 27/32] net: dsa: If a switch fails to probe, defer probing Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 28/32] Documentation: DSA: Describe how probe of DSA and switches work Andrew Lunn
2016-02-29 11:42 ` Sergei Shtylyov
2016-02-28 16:41 ` [PATCH RFC v2 29/32] dsa: slave: Don't reference NULL pointer during phy_disconnect Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 30/32] dsa: Destroy fixed link phys after the phy has been disconnected Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 31/32] dsa: dsa: Fix freeing of fixed-phys from user ports Andrew Lunn
2016-02-28 16:41 ` [PATCH RFC v2 32/32] phy: fixed: Fix removal of phys Andrew Lunn
2016-03-03 18:49 ` [PATCH RFC v2 00/32] Make DSA switches linux devices Florian Fainelli
2016-03-03 20:27 ` Andrew Lunn
2016-03-11 23:41 ` Florian Fainelli
2016-03-12 17:08 ` Andrew Lunn
2016-03-13 7:26 ` Vivien Didelot
2016-03-14 19:36 ` Florian Fainelli
2016-03-14 20:51 ` Andrew Lunn
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=56D8835F.4040607@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.com \
/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;
as well as URLs for NNTP newsgroup(s).