162306a36Sopenharmony_ci#ifndef _QIB_7220_H 262306a36Sopenharmony_ci#define _QIB_7220_H 362306a36Sopenharmony_ci/* 462306a36Sopenharmony_ci * Copyright (c) 2007, 2009, 2010 QLogic Corporation. All rights reserved. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This software is available to you under a choice of one of two 762306a36Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the 1062306a36Sopenharmony_ci * OpenIB.org BSD license below: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or 1362306a36Sopenharmony_ci * without modification, are permitted provided that the following 1462306a36Sopenharmony_ci * conditions are met: 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * - Redistributions of source code must retain the above 1762306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 1862306a36Sopenharmony_ci * disclaimer. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * - Redistributions in binary form must reproduce the above 2162306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 2262306a36Sopenharmony_ci * disclaimer in the documentation and/or other materials 2362306a36Sopenharmony_ci * provided with the distribution. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3262306a36Sopenharmony_ci * SOFTWARE. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* grab register-defs auto-generated by HW */ 3662306a36Sopenharmony_ci#include "qib_7220_regs.h" 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* The number of eager receive TIDs for context zero. */ 3962306a36Sopenharmony_ci#define IBA7220_KRCVEGRCNT 2048U 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define IB_7220_LT_STATE_CFGRCVFCFG 0x09 4262306a36Sopenharmony_ci#define IB_7220_LT_STATE_CFGWAITRMT 0x0a 4362306a36Sopenharmony_ci#define IB_7220_LT_STATE_TXREVLANES 0x0d 4462306a36Sopenharmony_ci#define IB_7220_LT_STATE_CFGENH 0x10 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_cistruct qib_chip_specific { 4762306a36Sopenharmony_ci u64 __iomem *cregbase; 4862306a36Sopenharmony_ci u64 *cntrs; 4962306a36Sopenharmony_ci u64 *portcntrs; 5062306a36Sopenharmony_ci spinlock_t sdepb_lock; /* serdes EPB bus */ 5162306a36Sopenharmony_ci spinlock_t rcvmod_lock; /* protect rcvctrl shadow changes */ 5262306a36Sopenharmony_ci spinlock_t gpio_lock; /* RMW of shadows/regs for ExtCtrl and GPIO */ 5362306a36Sopenharmony_ci u64 hwerrmask; 5462306a36Sopenharmony_ci u64 errormask; 5562306a36Sopenharmony_ci u64 gpio_out; /* shadow of kr_gpio_out, for rmw ops */ 5662306a36Sopenharmony_ci u64 gpio_mask; /* shadow the gpio mask register */ 5762306a36Sopenharmony_ci u64 extctrl; /* shadow the gpio output enable, etc... */ 5862306a36Sopenharmony_ci u32 ncntrs; 5962306a36Sopenharmony_ci u32 nportcntrs; 6062306a36Sopenharmony_ci u32 cntrnamelen; 6162306a36Sopenharmony_ci u32 portcntrnamelen; 6262306a36Sopenharmony_ci u32 numctxts; 6362306a36Sopenharmony_ci u32 rcvegrcnt; 6462306a36Sopenharmony_ci u32 autoneg_tries; 6562306a36Sopenharmony_ci u32 serdes_first_init_done; 6662306a36Sopenharmony_ci u32 sdmabufcnt; 6762306a36Sopenharmony_ci u32 lastbuf_for_pio; 6862306a36Sopenharmony_ci u32 updthresh; /* current AvailUpdThld */ 6962306a36Sopenharmony_ci u32 updthresh_dflt; /* default AvailUpdThld */ 7062306a36Sopenharmony_ci u8 presets_needed; 7162306a36Sopenharmony_ci u8 relock_timer_active; 7262306a36Sopenharmony_ci char emsgbuf[128]; 7362306a36Sopenharmony_ci char sdmamsgbuf[192]; 7462306a36Sopenharmony_ci char bitsmsgbuf[64]; 7562306a36Sopenharmony_ci struct timer_list relock_timer; 7662306a36Sopenharmony_ci unsigned int relock_interval; /* in jiffies */ 7762306a36Sopenharmony_ci struct qib_devdata *dd; 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistruct qib_chippport_specific { 8162306a36Sopenharmony_ci struct qib_pportdata pportdata; 8262306a36Sopenharmony_ci wait_queue_head_t autoneg_wait; 8362306a36Sopenharmony_ci struct delayed_work autoneg_work; 8462306a36Sopenharmony_ci struct timer_list chase_timer; 8562306a36Sopenharmony_ci /* 8662306a36Sopenharmony_ci * these 5 fields are used to establish deltas for IB symbol 8762306a36Sopenharmony_ci * errors and linkrecovery errors. They can be reported on 8862306a36Sopenharmony_ci * some chips during link negotiation prior to INIT, and with 8962306a36Sopenharmony_ci * DDR when faking DDR negotiations with non-IBTA switches. 9062306a36Sopenharmony_ci * The chip counters are adjusted at driver unload if there is 9162306a36Sopenharmony_ci * a non-zero delta. 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_ci u64 ibdeltainprog; 9462306a36Sopenharmony_ci u64 ibsymdelta; 9562306a36Sopenharmony_ci u64 ibsymsnap; 9662306a36Sopenharmony_ci u64 iblnkerrdelta; 9762306a36Sopenharmony_ci u64 iblnkerrsnap; 9862306a36Sopenharmony_ci u64 ibcctrl; /* kr_ibcctrl shadow */ 9962306a36Sopenharmony_ci u64 ibcddrctrl; /* kr_ibcddrctrl shadow */ 10062306a36Sopenharmony_ci unsigned long chase_end; 10162306a36Sopenharmony_ci u32 last_delay_mult; 10262306a36Sopenharmony_ci}; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* 10562306a36Sopenharmony_ci * This header file provides the declarations and common definitions 10662306a36Sopenharmony_ci * for (mostly) manipulation of the SerDes blocks within the IBA7220. 10762306a36Sopenharmony_ci * the functions declared should only be called from within other 10862306a36Sopenharmony_ci * 7220-related files such as qib_iba7220.c or qib_sd7220.c. 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_ciint qib_sd7220_presets(struct qib_devdata *dd); 11162306a36Sopenharmony_ciint qib_sd7220_init(struct qib_devdata *dd); 11262306a36Sopenharmony_civoid qib_sd7220_clr_ibpar(struct qib_devdata *); 11362306a36Sopenharmony_ci/* 11462306a36Sopenharmony_ci * Below used for sdnum parameter, selecting one of the two sections 11562306a36Sopenharmony_ci * used for PCIe, or the single SerDes used for IB, which is the 11662306a36Sopenharmony_ci * only one currently used 11762306a36Sopenharmony_ci */ 11862306a36Sopenharmony_ci#define IB_7220_SERDES 2 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_cistatic inline u32 qib_read_kreg32(const struct qib_devdata *dd, 12162306a36Sopenharmony_ci const u16 regno) 12262306a36Sopenharmony_ci{ 12362306a36Sopenharmony_ci if (!dd->kregbase || !(dd->flags & QIB_PRESENT)) 12462306a36Sopenharmony_ci return -1; 12562306a36Sopenharmony_ci return readl((u32 __iomem *)&dd->kregbase[regno]); 12662306a36Sopenharmony_ci} 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_cistatic inline u64 qib_read_kreg64(const struct qib_devdata *dd, 12962306a36Sopenharmony_ci const u16 regno) 13062306a36Sopenharmony_ci{ 13162306a36Sopenharmony_ci if (!dd->kregbase || !(dd->flags & QIB_PRESENT)) 13262306a36Sopenharmony_ci return -1; 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci return readq(&dd->kregbase[regno]); 13562306a36Sopenharmony_ci} 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_cistatic inline void qib_write_kreg(const struct qib_devdata *dd, 13862306a36Sopenharmony_ci const u16 regno, u64 value) 13962306a36Sopenharmony_ci{ 14062306a36Sopenharmony_ci if (dd->kregbase) 14162306a36Sopenharmony_ci writeq(value, &dd->kregbase[regno]); 14262306a36Sopenharmony_ci} 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_civoid set_7220_relock_poll(struct qib_devdata *, int); 14562306a36Sopenharmony_civoid shutdown_7220_relock_poll(struct qib_devdata *); 14662306a36Sopenharmony_civoid toggle_7220_rclkrls(struct qib_devdata *); 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci#endif /* _QIB_7220_H */ 150