From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6] Marvell MV88E61XX Switch Driver support
Date: Wed, 22 Apr 2009 22:30:23 -0700 [thread overview]
Message-ID: <49EFFCEF.5000005@gmail.com> (raw)
In-Reply-To: <1240403013-24534-1-git-send-email-prafulla@marvell.com>
Hi Prafulla,
So close...
Prafulla Wadaskar wrote:
<snip>
> +/* Chip Address mode
> + * The Switch support two modes of operation
> + * 1. single chip mode and
> + * 2. Multi-chip mode
> + * Refer section 9.2 &9.3 in chip datasheet-02 for more details
> + *
> + * By default single chip mode is configured
> + * multichip mode operation can be configured in board header
> + */
> +#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
> +#define mv88e61xx_wr_phy miiphy_write
> +#define mv88e61xx_rd_phy miiphy_read
> +#else
> +
> +static int mv88e61xx_busychk_multic(u32 devaddr)
> +{
> + u32 reg = 0;
> + u32 timeout = MV88E61XX_PHY_TIMEOUT;
> +
> + /* Poll till SMIBusy bit is clear */
> + do {
> + miiphy_read(name, devaddr, 0x0, ®);
> + if (timeout-- == 0) {
> + printf("SMI busy timeout\n");
> + return -1;
> + }
> + } while (reg & BIT15);
> + return 0;
> +}
> +
> +static void mv88e61xx_wr_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 data)
> +{
> + u16 reg;
> + u32 mii_dev_addr;
> +
> + /* command to read PHY dev address */
> + if (!miiphy_read(name, 0xEE, 0xEE, &mii_dev_addr)) {
> + printf("Error..could not read PHY dev address\n");
> + return;
> + }
> + mv88e61xx_busychk_multic(mii_dev_addr);
> + /* Write data to Switch indirect data register */
> + miiphy_write(name, mii_dev_addr, 0x1, data);
> + /* Write command to Switch indirect command register (write) */
> + miiphy_write(name, mii_dev_addr, 0x0,
> + reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
> +}
> +
> +static void mv88e61xx_rd_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 * data)
> +{
> + u16 reg;
> + u32 mii_dev_addr;
> +
> + /* command to read PHY dev address */
> + if (!miiphy_read(name, 0xEE, 0xEE, &mii_dev_addr)) {
> + printf("Error..could not read PHY dev address\n");
> + return;
> + }
> + mv88e61xx_busychk_multic(mii_dev_addr);
> + /* Write command to Switch indirect command register (read) */
> + miiphy_write(name, mii_dev_addr, 0x0,
> + reg_ofs | (phy_adr << 5) | BIT10 | BIT12 | BIT15);
> + mv88e61xx_busychk_multic(mii_dev_addr);
> + /* Read data from Switch indirect data register */
> + miiphy_read(name, mii_dev_addr, 0x1, (u16 *) & data);
> +}
> +#endif /* CONFIG_MV88E61XX_MULTICHIP_ADRMODE */
> +
>
I apologize for not being more clear here. Please don't put non-trivial
functions in header files. What I was hoping you'd do was put something
like this in the header file:
static void mv88e61xx_wr_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 data);
static void mv88e61xx_rd_phy(char *name, u32 phy_adr, u32 reg_ofs, u16 * data);
/* Helpful comment here */
#ifndef CONFIG_MV88E61XX_MULTICHIP_ADRMODE
#define WRITE_PHY miiphy_write
#define READ_PHY miiphy_read
#else
#define WRITE_PHY mv88e61xx_wr_phy
#define READ_PHY mv88e61xx_rd_phy
#endif
and then use these macros throughout. You'll agree that it's much easier
to follow.
> +#endif /* _MV88E61XX_H */
> diff --git a/include/netdev.h b/include/netdev.h
> index 2794ddd..e6832de 100644
> --- a/include/netdev.h
> +++ b/include/netdev.h
> @@ -59,6 +59,7 @@ int mpc512x_fec_initialize(bd_t *bis);
> int mpc5xxx_fec_initialize(bd_t *bis);
> int mpc8220_fec_initialize(bd_t *bis);
> int mpc82xx_scc_enet_initialize(bd_t *bis);
> +int mv88e61xx_switch_initialize(struct mv88e61xx_config *swconfig);
> int natsemi_initialize(bd_t *bis);
> int npe_initialize(bd_t *bis);
> int ns8382x_initialize(bd_t *bis);
>
Apart from that, it looks really good. Thanks for all the hard work.
regards,
Ben
next prev parent reply other threads:[~2009-04-23 5:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-15 13:24 [U-Boot] [PATCH v4] Marvell MV88E61XX Switch Driver support Prafulla Wadaskar
2009-04-17 7:36 ` Jean-Christophe PLAGNIOL-VILLARD
2009-04-18 6:44 ` Prafulla Wadaskar
2009-04-19 6:11 ` [U-Boot] [PATCH v5] " Prafulla Wadaskar
2009-04-20 3:48 ` Ben Warren
2009-04-22 7:11 ` Prafulla Wadaskar
2009-04-22 12:23 ` [U-Boot] [PATCH v6] " Prafulla Wadaskar
2009-04-23 5:30 ` Ben Warren [this message]
2009-04-23 12:29 ` Detlev Zundel
2009-04-23 13:54 ` Prafulla Wadaskar
2013-01-25 6:44 ` Kenny
2009-04-23 14:04 ` Prafulla Wadaskar
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=49EFFCEF.5000005@gmail.com \
--to=biggerbadderben@gmail.com \
--cc=u-boot@lists.denx.de \
/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