From: Richard Cochran <richardcochran@gmail.com>
To: Mugunthan V N <mugunthanvnm@ti.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH 1/6] drivers: net: ethernet: cpsw: add support for CPSW register offset changes in different IP version
Date: Thu, 18 Oct 2012 04:45:23 +0200 [thread overview]
Message-ID: <20121018024523.GA2867@netboy.at.omicron.at> (raw)
In-Reply-To: <1350427518-7230-2-git-send-email-mugunthanvnm@ti.com>
On Wed, Oct 17, 2012 at 04:15:13AM +0530, Mugunthan V N wrote:
>
> +#define CPSW_VERSION_1 0x19010a
> +#define CPSW_VERSION_2 0x19010c
Are you sure about these codes? What about 0x19010b?
I could not find them documented anywhere.
> +#define cpsw_slave_reg(priv, slave, reg) \
> + ((slave)->regs + (priv)->slave_reg_ofs[(reg)])
> +
> #define CPSW_MAJOR_VERSION(reg) (reg >> 8 & 0x7)
> #define CPSW_MINOR_VERSION(reg) (reg & 0xff)
> #define CPSW_RTL_VERSION(reg) ((reg >> 11) & 0x1f)
> @@ -117,6 +122,48 @@ do { \
> disable_irq_nosync(priv->irqs_table[i]); \
> } while (0);
>
> +enum CPSW_SLAVE_REG_OFS {
> + MAX_BLKS,
> + BLK_CNT,
> + FLOW_THRESH,
> + PORT_VLAN,
> + TX_PRI_MAP,
> + TS_CTL,
> + TS_SEQ_LTYPE,
> + TS_VLAN,
> + SA_LO,
> + SA_HI,
> + PORT_CONTROL,
> + TS_SEQ_MTYPE,
> + TS_CONTROL,
> +};
> +
> +static const u32 slave_reg_map_ip_v1[] = {
> + [MAX_BLKS] = 0x00,
> + [BLK_CNT] = 0x04,
> + [FLOW_THRESH] = 0x08,
> + [PORT_VLAN] = 0x0c,
> + [TX_PRI_MAP] = 0x10,
> + [TS_CTL] = 0x14,
> + [TS_SEQ_LTYPE] = 0x18,
> + [TS_VLAN] = 0x1c,
> + [SA_LO] = 0x20,
> + [SA_HI] = 0x24,
> +};
> +
> +static const u32 slave_reg_map_ip_v2[] = {
> + [PORT_CONTROL] = 0x00,
> + [TS_CONTROL] = 0x04,
You don't make use of this register in your driver, so what is the
point?
> + [MAX_BLKS] = 0x08,
> + [BLK_CNT] = 0x0c,
> + [FLOW_THRESH] = 0x10,
> + [PORT_VLAN] = 0x14,
> + [TX_PRI_MAP] = 0x18,
> + [TS_SEQ_MTYPE] = 0x1c,
> + [SA_LO] = 0x20,
> + [SA_HI] = 0x24,
> +};
> +
This is wasting memory with unused static stables. There is a better
way to handle this issue.
> static int debug_level;
> module_param(debug_level, int, 0);
> MODULE_PARM_DESC(debug_level, "cpsw debug level (NETIF_MSG bits)");
> @@ -146,19 +193,13 @@ struct cpsw_regs {
> u32 soft_reset;
> u32 stat_port_en;
> u32 ptype;
> -};
> -
> -struct cpsw_slave_regs {
> - u32 max_blks;
> - u32 blk_cnt;
> - u32 flow_thresh;
> - u32 port_vlan;
> - u32 tx_pri_map;
> - u32 ts_ctl;
> - u32 ts_seq_ltype;
> - u32 ts_vlan;
> - u32 sa_lo;
> - u32 sa_hi;
> + u32 soft_idle;
> + u32 thru_rate;
> + u32 gap_thresh;
> + u32 tx_start_wds;
> + u32 flow_control;
> + u32 vlan_ltype;
> + u32 ts_ltype;
> };
>
> struct cpsw_host_regs {
> @@ -185,7 +226,7 @@ struct cpsw_sliver_regs {
> };
>
> struct cpsw_slave {
> - struct cpsw_slave_regs __iomem *regs;
> + void __iomem *regs;
> struct cpsw_sliver_regs __iomem *sliver;
> int slave_num;
> u32 mac_control;
> @@ -215,6 +256,8 @@ struct cpsw_priv {
> struct cpdma_ctlr *dma;
> struct cpdma_chan *txch, *rxch;
> struct cpsw_ale *ale;
> + u32 cpsw_version;
> + u32 *slave_reg_ofs;
> /* snapshot of IRQ numbers */
> u32 irqs_table[4];
> u32 num_irqs;
> @@ -359,8 +402,8 @@ static inline void soft_reset(const char *module, void __iomem *reg)
> static void cpsw_set_slave_mac(struct cpsw_slave *slave,
> struct cpsw_priv *priv)
> {
> - __raw_writel(mac_hi(priv->mac_addr), &slave->regs->sa_hi);
> - __raw_writel(mac_lo(priv->mac_addr), &slave->regs->sa_lo);
> + writel(mac_hi(priv->mac_addr), cpsw_slave_reg(priv, slave, SA_HI));
> + writel(mac_lo(priv->mac_addr), cpsw_slave_reg(priv, slave, SA_LO));
> }
>
> static void _cpsw_adjust_link(struct cpsw_slave *slave,
> @@ -445,8 +488,8 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
> soft_reset(name, &slave->sliver->soft_reset);
>
> /* setup priority mapping */
> - __raw_writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map);
> - __raw_writel(TX_PRIORITY_MAPPING, &slave->regs->tx_pri_map);
> + writel(RX_PRIORITY_MAPPING, &slave->sliver->rx_pri_map);
> + writel(TX_PRIORITY_MAPPING, cpsw_slave_reg(priv, slave, TX_PRI_MAP));
>
> /* setup max packet size, and mac address */
> __raw_writel(priv->rx_packet_max, &slave->sliver->rx_maxlen);
> @@ -505,7 +548,12 @@ static int cpsw_ndo_open(struct net_device *ndev)
>
> pm_runtime_get_sync(&priv->pdev->dev);
>
> - reg = __raw_readl(&priv->regs->id_ver);
> + reg = readl(&priv->regs->id_ver);
> + priv->cpsw_version = reg;
> + if (reg == CPSW_VERSION_1)
> + priv->slave_reg_ofs = (u32 *)slave_reg_map_ip_v1;
> + else
> + priv->slave_reg_ofs = (u32 *)slave_reg_map_ip_v2;
You didn't provide a way to even use this code, like a dts for a
non-am335x board with the older version.
I think it would be better to start off supporting one version and
have that fully working, and then add the older version, but *really*
add it so that it is actually working.
Thanks,
Richard
next prev parent reply other threads:[~2012-10-18 2:45 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-16 22:45 [PATCH 0/6] Add CPTS PTP driver support Mugunthan V N
2012-10-16 22:45 ` [PATCH 1/6] drivers: net: ethernet: cpsw: add support for CPSW register offset changes in different IP version Mugunthan V N
2012-10-18 2:45 ` Richard Cochran [this message]
2012-10-22 10:39 ` N, Mugunthan V
2012-10-22 11:23 ` Richard Cochran
2012-10-22 12:19 ` N, Mugunthan V
2012-10-22 12:25 ` Richard Cochran
2012-10-16 22:45 ` [PATCH 2/6] drivers: net: ethernet: davinci_cpdma: add clear api for statistics interrupt Mugunthan V N
2012-10-18 2:48 ` Richard Cochran
2012-10-22 10:42 ` N, Mugunthan V
2012-10-22 11:31 ` Richard Cochran
2012-10-16 22:45 ` [PATCH 3/6] drivers: net: ethernet: cpsw: add multicast address to ALE table Mugunthan V N
2012-10-18 2:49 ` Richard Cochran
2012-10-21 11:26 ` Richard Cochran
2012-10-22 10:46 ` N, Mugunthan V
2012-10-16 22:45 ` [PATCH 4/6] ptp: add api to get ptp seq id and event type from skb Mugunthan V N
2012-10-16 23:10 ` Ben Hutchings
2012-10-17 13:48 ` N, Mugunthan V
2012-10-18 2:55 ` Richard Cochran
2012-10-22 10:46 ` N, Mugunthan V
2012-10-22 11:36 ` Richard Cochran
2012-10-22 12:32 ` N, Mugunthan V
2012-10-22 12:37 ` Richard Cochran
2012-10-16 22:45 ` [PATCH 5/6] drivers: net: ethernet: cpts: implement cpts hardware clock Mugunthan V N
2012-10-20 13:43 ` Richard Cochran
2012-10-22 10:55 ` N, Mugunthan V
2012-10-22 11:41 ` Richard Cochran
2012-10-22 11:44 ` Richard Cochran
2012-10-22 12:38 ` N, Mugunthan V
2012-10-22 11:46 ` Richard Cochran
2012-10-22 12:42 ` N, Mugunthan V
2012-10-16 22:45 ` [PATCH 6/6] drivers: net: ethernet: cpsw: implement timestamping capabilities in cpsw Mugunthan V N
2012-10-21 18:11 ` Richard Cochran
2012-10-21 18:46 ` [PATCH 0/6] Add CPTS PTP driver support Richard Cochran
2012-10-22 10:51 ` N, Mugunthan V
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=20121018024523.GA2867@netboy.at.omicron.at \
--to=richardcochran@gmail.com \
--cc=davem@davemloft.net \
--cc=mugunthanvnm@ti.com \
--cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.