aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sh_eth.h
diff options
context:
space:
mode:
authorYoshihiro Shimoda <shimoda.yoshihiro@renesas.com>2009-05-24 19:54:21 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-26 01:49:55 -0400
commit380af9e390ec81e74a2fd7fad948a8b12eeec7da (patch)
tree28123090740fe01bfcae1787993b40c9e588756a /drivers/net/sh_eth.h
parent862df49750e7ca9369c04d8d8105b3cc5d976e0d (diff)
net: sh_eth: CPU dependency code collect to "struct sh_eth_cpu_data"
This improves readability by collecting CPU dependency code. Signed-off-by: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sh_eth.h')
-rw-r--r--drivers/net/sh_eth.h226
1 files changed, 119 insertions, 107 deletions
diff --git a/drivers/net/sh_eth.h b/drivers/net/sh_eth.h
index 1537e13e623d..eec6c4a7fbe7 100644
--- a/drivers/net/sh_eth.h
+++ b/drivers/net/sh_eth.h
@@ -2,7 +2,7 @@
2 * SuperH Ethernet device driver 2 * SuperH Ethernet device driver
3 * 3 *
4 * Copyright (C) 2006-2008 Nobuhiro Iwamatsu 4 * Copyright (C) 2006-2008 Nobuhiro Iwamatsu
5 * Copyright (C) 2008 Renesas Solutions Corp. 5 * Copyright (C) 2008-2009 Renesas Solutions Corp.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License, 8 * under the terms and conditions of the GNU General Public License,
@@ -39,12 +39,10 @@
39#define ETHERSMALL 60 39#define ETHERSMALL 60
40#define PKT_BUF_SZ 1538 40#define PKT_BUF_SZ 1538
41 41
42#ifdef CONFIG_CPU_SUBTYPE_SH7763 42#if defined(CONFIG_CPU_SUBTYPE_SH7763)
43
44#define SH7763_SKB_ALIGN 32
45/* Chip Base Address */ 43/* Chip Base Address */
46# define SH_TSU_ADDR 0xFEE01800 44# define SH_TSU_ADDR 0xFEE01800
47# define ARSTR SH_TSU_ADDR 45# define ARSTR SH_TSU_ADDR
48 46
49/* Chip Registers */ 47/* Chip Registers */
50/* E-DMAC */ 48/* E-DMAC */
@@ -143,8 +141,8 @@
143# define FWNLCR1 0xB0 141# define FWNLCR1 0xB0
144# define FWALCR1 0x40 142# define FWALCR1 0x40
145 143
146#else /* CONFIG_CPU_SUBTYPE_SH7763 */ 144#else /* #elif defined(CONFIG_CPU_SUBTYPE_SH7763) */
147# define RX_OFFSET 2 /* skb offset */ 145/* This section is SH3 or SH2 */
148#ifndef CONFIG_CPU_SUBTYPE_SH7619 146#ifndef CONFIG_CPU_SUBTYPE_SH7619
149/* Chip base address */ 147/* Chip base address */
150# define SH_TSU_ADDR 0xA7000804 148# define SH_TSU_ADDR 0xA7000804
@@ -243,6 +241,30 @@
243 241
244#endif /* CONFIG_CPU_SUBTYPE_SH7763 */ 242#endif /* CONFIG_CPU_SUBTYPE_SH7763 */
245 243
244/* There are avoid compile error... */
245#if !defined(BCULR)
246#define BCULR 0x0fc
247#endif
248#if !defined(TRIMD)
249#define TRIMD 0x0fc
250#endif
251#if !defined(APR)
252#define APR 0x0fc
253#endif
254#if !defined(MPR)
255#define MPR 0x0fc
256#endif
257#if !defined(TPAUSER)
258#define TPAUSER 0x0fc
259#endif
260
261/* Driver's parameters */
262#if defined(CONFIG_CPU_SH4)
263#define SH4_SKB_RX_ALIGN 32
264#else
265#define SH2_SH3_SKB_RX_ALIGN 2
266#endif
267
246/* 268/*
247 * Register's bits 269 * Register's bits
248 */ 270 */
@@ -261,11 +283,10 @@ enum GECMR_BIT {
261 283
262/* EDMR */ 284/* EDMR */
263enum DMAC_M_BIT { 285enum DMAC_M_BIT {
286 EDMR_EL = 0x40, /* Litte endian */
264 EDMR_DL1 = 0x20, EDMR_DL0 = 0x10, 287 EDMR_DL1 = 0x20, EDMR_DL0 = 0x10,
265#ifdef CONFIG_CPU_SUBTYPE_SH7763 288#ifdef CONFIG_CPU_SUBTYPE_SH7763
266 EDMR_SRST = 0x03, 289 EDMR_SRST = 0x03,
267 EMDR_DESC_R = 0x30, /* Descriptor reserve size */
268 EDMR_EL = 0x40, /* Litte endian */
269#else /* CONFIG_CPU_SUBTYPE_SH7763 */ 290#else /* CONFIG_CPU_SUBTYPE_SH7763 */
270 EDMR_SRST = 0x01, 291 EDMR_SRST = 0x01,
271#endif 292#endif
@@ -307,47 +328,43 @@ enum PHY_STATUS_BIT { PHY_ST_LINK = 0x01, };
307 328
308/* EESR */ 329/* EESR */
309enum EESR_BIT { 330enum EESR_BIT {
310#ifndef CONFIG_CPU_SUBTYPE_SH7763 331 EESR_TWB1 = 0x80000000,
311 EESR_TWB = 0x40000000, 332 EESR_TWB = 0x40000000, /* same as TWB0 */
312#else 333 EESR_TC1 = 0x20000000,
313 EESR_TWB = 0xC0000000, 334 EESR_TUC = 0x10000000,
314 EESR_TC1 = 0x20000000, 335 EESR_ROC = 0x08000000,
315 EESR_TUC = 0x10000000, 336 EESR_TABT = 0x04000000,
316 EESR_ROC = 0x80000000, 337 EESR_RABT = 0x02000000,
317#endif 338 EESR_RFRMER = 0x01000000, /* same as RFCOF */
318 EESR_TABT = 0x04000000, 339 EESR_ADE = 0x00800000,
319 EESR_RABT = 0x02000000, EESR_RFRMER = 0x01000000, 340 EESR_ECI = 0x00400000,
320#ifndef CONFIG_CPU_SUBTYPE_SH7763 341 EESR_FTC = 0x00200000, /* same as TC or TC0 */
321 EESR_ADE = 0x00800000, 342 EESR_TDE = 0x00100000,
322#endif 343 EESR_TFE = 0x00080000, /* same as TFUF */
323 EESR_ECI = 0x00400000, 344 EESR_FRC = 0x00040000, /* same as FR */
324 EESR_FTC = 0x00200000, EESR_TDE = 0x00100000, 345 EESR_RDE = 0x00020000,
325 EESR_TFE = 0x00080000, EESR_FRC = 0x00040000, 346 EESR_RFE = 0x00010000,
326 EESR_RDE = 0x00020000, EESR_RFE = 0x00010000, 347 EESR_CND = 0x00000800,
327#ifndef CONFIG_CPU_SUBTYPE_SH7763 348 EESR_DLC = 0x00000400,
328 EESR_CND = 0x00000800, 349 EESR_CD = 0x00000200,
329#endif 350 EESR_RTO = 0x00000100,
330 EESR_DLC = 0x00000400, 351 EESR_RMAF = 0x00000080,
331 EESR_CD = 0x00000200, EESR_RTO = 0x00000100, 352 EESR_CEEF = 0x00000040,
332 EESR_RMAF = 0x00000080, EESR_CEEF = 0x00000040, 353 EESR_CELF = 0x00000020,
333 EESR_CELF = 0x00000020, EESR_RRF = 0x00000010, 354 EESR_RRF = 0x00000010,
334 EESR_RTLF = 0x00000008, EESR_RTSF = 0x00000004, 355 EESR_RTLF = 0x00000008,
335 EESR_PRE = 0x00000002, EESR_CERF = 0x00000001, 356 EESR_RTSF = 0x00000004,
336}; 357 EESR_PRE = 0x00000002,
337 358 EESR_CERF = 0x00000001,
338 359};
339#ifdef CONFIG_CPU_SUBTYPE_SH7763 360
340# define TX_CHECK (EESR_TC1 | EESR_FTC) 361#define DEFAULT_TX_CHECK (EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | \
341# define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \ 362 EESR_RTO)
342 | EESR_RFRMER | EESR_TFE | EESR_TDE | EESR_ECI) 363#define DEFAULT_EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | \
343# define TX_ERROR_CEHCK (EESR_TWB | EESR_TABT | EESR_TDE | EESR_TFE) 364 EESR_RDE | EESR_RFRMER | EESR_ADE | \
344 365 EESR_TFE | EESR_TDE | EESR_ECI)
345#else 366#define DEFAULT_TX_ERROR_CHECK (EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | \
346# define TX_CHECK (EESR_FTC | EESR_CND | EESR_DLC | EESR_CD | EESR_RTO) 367 EESR_TFE)
347# define EESR_ERR_CHECK (EESR_TWB | EESR_TABT | EESR_RABT | EESR_RDE \
348 | EESR_RFRMER | EESR_ADE | EESR_TFE | EESR_TDE | EESR_ECI)
349# define TX_ERROR_CEHCK (EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE)
350#endif
351 368
352/* EESIPR */ 369/* EESIPR */
353enum DMAC_IM_BIT { 370enum DMAC_IM_BIT {
@@ -386,12 +403,8 @@ enum FCFTR_BIT {
386 FCFTR_RFF0 = 0x00010000, FCFTR_RFD2 = 0x00000004, 403 FCFTR_RFF0 = 0x00010000, FCFTR_RFD2 = 0x00000004,
387 FCFTR_RFD1 = 0x00000002, FCFTR_RFD0 = 0x00000001, 404 FCFTR_RFD1 = 0x00000002, FCFTR_RFD0 = 0x00000001,
388}; 405};
389#define FIFO_F_D_RFF (FCFTR_RFF2|FCFTR_RFF1|FCFTR_RFF0) 406#define DEFAULT_FIFO_F_D_RFF (FCFTR_RFF2 | FCFTR_RFF1 | FCFTR_RFF0)
390#ifndef CONFIG_CPU_SUBTYPE_SH7619 407#define DEFAULT_FIFO_F_D_RFD (FCFTR_RFD2 | FCFTR_RFD1 | FCFTR_RFD0)
391#define FIFO_F_D_RFD (FCFTR_RFD2|FCFTR_RFD1|FCFTR_RFD0)
392#else
393#define FIFO_F_D_RFD (FCFTR_RFD0)
394#endif
395 408
396/* Transfer descriptor bit */ 409/* Transfer descriptor bit */
397enum TD_STS_BIT { 410enum TD_STS_BIT {
@@ -404,60 +417,38 @@ enum TD_STS_BIT {
404#define TD_TFP (TD_TFP1|TD_TFP0) 417#define TD_TFP (TD_TFP1|TD_TFP0)
405 418
406/* RMCR */ 419/* RMCR */
407enum RECV_RST_BIT { RMCR_RST = 0x01, }; 420#define DEFAULT_RMCR_VALUE 0x00000000
421
408/* ECMR */ 422/* ECMR */
409enum FELIC_MODE_BIT { 423enum FELIC_MODE_BIT {
410#ifdef CONFIG_CPU_SUBTYPE_SH7763
411 ECMR_TRCCM = 0x04000000, ECMR_RCSC = 0x00800000, 424 ECMR_TRCCM = 0x04000000, ECMR_RCSC = 0x00800000,
412 ECMR_DPAD = 0x00200000, ECMR_RZPF = 0x00100000, 425 ECMR_DPAD = 0x00200000, ECMR_RZPF = 0x00100000,
413#endif
414 ECMR_ZPF = 0x00080000, ECMR_PFR = 0x00040000, ECMR_RXF = 0x00020000, 426 ECMR_ZPF = 0x00080000, ECMR_PFR = 0x00040000, ECMR_RXF = 0x00020000,
415 ECMR_TXF = 0x00010000, ECMR_MCT = 0x00002000, ECMR_PRCEF = 0x00001000, 427 ECMR_TXF = 0x00010000, ECMR_MCT = 0x00002000, ECMR_PRCEF = 0x00001000,
416 ECMR_PMDE = 0x00000200, ECMR_RE = 0x00000040, ECMR_TE = 0x00000020, 428 ECMR_PMDE = 0x00000200, ECMR_RE = 0x00000040, ECMR_TE = 0x00000020,
417 ECMR_ILB = 0x00000008, ECMR_ELB = 0x00000004, ECMR_DM = 0x00000002, 429 ECMR_ILB = 0x00000008, ECMR_ELB = 0x00000004,
418 ECMR_PRM = 0x00000001, 430 ECMR_DM = 0x00000002, ECMR_PRM = 0x00000001,
419}; 431};
420 432
421#ifdef CONFIG_CPU_SUBTYPE_SH7763
422#define ECMR_CHG_DM (ECMR_TRCCM | ECMR_RZPF | ECMR_ZPF |\
423 ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT)
424#elif CONFIG_CPU_SUBTYPE_SH7619
425#define ECMR_CHG_DM (ECMR_ZPF | ECMR_PFR | ECMR_RXF | ECMR_TXF)
426#else
427#define ECMR_CHG_DM (ECMR_ZPF | ECMR_PFR | ECMR_RXF | ECMR_TXF | ECMR_MCT)
428#endif
429
430/* ECSR */ 433/* ECSR */
431enum ECSR_STATUS_BIT { 434enum ECSR_STATUS_BIT {
432#ifndef CONFIG_CPU_SUBTYPE_SH7763
433 ECSR_BRCRX = 0x20, ECSR_PSRTO = 0x10, 435 ECSR_BRCRX = 0x20, ECSR_PSRTO = 0x10,
434#endif
435 ECSR_LCHNG = 0x04, 436 ECSR_LCHNG = 0x04,
436 ECSR_MPD = 0x02, ECSR_ICD = 0x01, 437 ECSR_MPD = 0x02, ECSR_ICD = 0x01,
437}; 438};
438 439
439#ifdef CONFIG_CPU_SUBTYPE_SH7763 440#define DEFAULT_ECSR_INIT (ECSR_BRCRX | ECSR_PSRTO | ECSR_LCHNG | \
440# define ECSR_INIT (ECSR_ICD | ECSIPR_MPDIP) 441 ECSR_ICD | ECSIPR_MPDIP)
441#else
442# define ECSR_INIT (ECSR_BRCRX | ECSR_PSRTO | \
443 ECSR_LCHNG | ECSR_ICD | ECSIPR_MPDIP)
444#endif
445 442
446/* ECSIPR */ 443/* ECSIPR */
447enum ECSIPR_STATUS_MASK_BIT { 444enum ECSIPR_STATUS_MASK_BIT {
448#ifndef CONFIG_CPU_SUBTYPE_SH7763
449 ECSIPR_BRCRXIP = 0x20, ECSIPR_PSRTOIP = 0x10, 445 ECSIPR_BRCRXIP = 0x20, ECSIPR_PSRTOIP = 0x10,
450#endif
451 ECSIPR_LCHNGIP = 0x04, 446 ECSIPR_LCHNGIP = 0x04,
452 ECSIPR_MPDIP = 0x02, ECSIPR_ICDIP = 0x01, 447 ECSIPR_MPDIP = 0x02, ECSIPR_ICDIP = 0x01,
453}; 448};
454 449
455#ifdef CONFIG_CPU_SUBTYPE_SH7763 450#define DEFAULT_ECSIPR_INIT (ECSIPR_BRCRXIP | ECSIPR_PSRTOIP | \
456# define ECSIPR_INIT (ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP) 451 ECSIPR_LCHNGIP | ECSIPR_ICDIP | ECSIPR_MPDIP)
457#else
458# define ECSIPR_INIT (ECSIPR_BRCRXIP | ECSIPR_PSRTOIP | ECSIPR_LCHNGIP | \
459 ECSIPR_ICDIP | ECSIPR_MPDIP)
460#endif
461 452
462/* APR */ 453/* APR */
463enum APR_BIT { 454enum APR_BIT {
@@ -483,23 +474,12 @@ enum RPADIR_BIT {
483 RPADIR_PADR = 0x0003f, 474 RPADIR_PADR = 0x0003f,
484}; 475};
485 476
486#if defined(CONFIG_CPU_SUBTYPE_SH7763)
487# define RPADIR_INIT (0x00)
488#else
489# define RPADIR_INIT (RPADIR_PADS1)
490#endif
491
492/* RFLR */ 477/* RFLR */
493#define RFLR_VALUE 0x1000 478#define RFLR_VALUE 0x1000
494 479
495/* FDR */ 480/* FDR */
496enum FIFO_SIZE_BIT { 481#define DEFAULT_FDR_INIT 0x00000707
497#ifndef CONFIG_CPU_SUBTYPE_SH7619 482
498 FIFO_SIZE_T = 0x00000700, FIFO_SIZE_R = 0x00000007,
499#else
500 FIFO_SIZE_T = 0x00000100, FIFO_SIZE_R = 0x00000001,
501#endif
502};
503enum phy_offsets { 483enum phy_offsets {
504 PHY_CTRL = 0, PHY_STAT = 1, PHY_IDT1 = 2, PHY_IDT2 = 3, 484 PHY_CTRL = 0, PHY_STAT = 1, PHY_IDT1 = 2, PHY_IDT2 = 3,
505 PHY_ANA = 4, PHY_ANL = 5, PHY_ANE = 6, 485 PHY_ANA = 4, PHY_ANL = 5, PHY_ANE = 6,
@@ -633,7 +613,43 @@ struct sh_eth_rxdesc {
633 u32 pad0; /* padding data */ 613 u32 pad0; /* padding data */
634} __attribute__((aligned(2), packed)); 614} __attribute__((aligned(2), packed));
635 615
616/* This structure is used by each CPU dependency handling. */
617struct sh_eth_cpu_data {
618 /* optional functions */
619 void (*chip_reset)(struct net_device *ndev);
620 void (*set_duplex)(struct net_device *ndev);
621 void (*set_rate)(struct net_device *ndev);
622
623 /* mandatory initialize value */
624 unsigned long eesipr_value;
625
626 /* optional initialize value */
627 unsigned long ecsr_value;
628 unsigned long ecsipr_value;
629 unsigned long fdr_value;
630 unsigned long fcftr_value;
631 unsigned long rpadir_value;
632 unsigned long rmcr_value;
633
634 /* interrupt checking mask */
635 unsigned long tx_check;
636 unsigned long eesr_err_check;
637 unsigned long tx_error_check;
638
639 /* hardware features */
640 unsigned no_psr:1; /* EtherC DO NOT have PSR */
641 unsigned apr:1; /* EtherC have APR */
642 unsigned mpr:1; /* EtherC have MPR */
643 unsigned tpauser:1; /* EtherC have TPAUSER */
644 unsigned bculr:1; /* EtherC have BCULR */
645 unsigned hw_swap:1; /* E-DMAC have DE bit in EDMR */
646 unsigned rpadir:1; /* E-DMAC have RPADIR */
647 unsigned no_trimd:1; /* E-DMAC DO NOT have TRIMD */
648 unsigned no_ade:1; /* E-DMAC DO NOT have ADE bit in EESR */
649};
650
636struct sh_eth_private { 651struct sh_eth_private {
652 struct sh_eth_cpu_data *cd;
637 dma_addr_t rx_desc_dma; 653 dma_addr_t rx_desc_dma;
638 dma_addr_t tx_desc_dma; 654 dma_addr_t tx_desc_dma;
639 struct sh_eth_rxdesc *rx_ring; 655 struct sh_eth_rxdesc *rx_ring;
@@ -661,11 +677,7 @@ struct sh_eth_private {
661 struct net_device_stats tsu_stats; /* TSU forward status */ 677 struct net_device_stats tsu_stats; /* TSU forward status */
662}; 678};
663 679
664#ifdef CONFIG_CPU_SUBTYPE_SH7763 680static inline void sh_eth_soft_swap(char *src, int len)
665/* SH7763 has endian control register */
666#define swaps(x, y)
667#else
668static void swaps(char *src, int len)
669{ 681{
670#ifdef __LITTLE_ENDIAN__ 682#ifdef __LITTLE_ENDIAN__
671 u32 *p = (u32 *)src; 683 u32 *p = (u32 *)src;
@@ -676,5 +688,5 @@ static void swaps(char *src, int len)
676 *p = swab32(*p); 688 *p = swab32(*p);
677#endif 689#endif
678} 690}
679#endif /* CONFIG_CPU_SUBTYPE_SH7763 */ 691
680#endif 692#endif /* #ifndef __SH_ETH_H__ */