1*d39a76e7Sxw161283 /* 2*d39a76e7Sxw161283 * CDDL HEADER START 3*d39a76e7Sxw161283 * 4*d39a76e7Sxw161283 * The contents of this file are subject to the terms of the 5*d39a76e7Sxw161283 * Common Development and Distribution License (the "License"). 6*d39a76e7Sxw161283 * You may not use this file except in compliance with the License. 7*d39a76e7Sxw161283 * 8*d39a76e7Sxw161283 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*d39a76e7Sxw161283 * or http://www.opensolaris.org/os/licensing. 10*d39a76e7Sxw161283 * See the License for the specific language governing permissions 11*d39a76e7Sxw161283 * and limitations under the License. 12*d39a76e7Sxw161283 * 13*d39a76e7Sxw161283 * When distributing Covered Code, include this CDDL HEADER in each 14*d39a76e7Sxw161283 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*d39a76e7Sxw161283 * If applicable, add the following below this CDDL HEADER, with the 16*d39a76e7Sxw161283 * fields enclosed by brackets "[]" replaced with your own identifying 17*d39a76e7Sxw161283 * information: Portions Copyright [yyyy] [name of copyright owner] 18*d39a76e7Sxw161283 * 19*d39a76e7Sxw161283 * CDDL HEADER END 20*d39a76e7Sxw161283 */ 21*d39a76e7Sxw161283 22*d39a76e7Sxw161283 /* 23*d39a76e7Sxw161283 * Copyright (C) 2003-2005 Chelsio Communications. All rights reserved. 24*d39a76e7Sxw161283 */ 25*d39a76e7Sxw161283 26*d39a76e7Sxw161283 #pragma ident "%Z%%M% %I% %E% SMI" /* cspi.c */ 27*d39a76e7Sxw161283 28*d39a76e7Sxw161283 #include "common.h" 29*d39a76e7Sxw161283 #include "regs.h" 30*d39a76e7Sxw161283 #include "cspi.h" 31*d39a76e7Sxw161283 32*d39a76e7Sxw161283 struct pecspi { 33*d39a76e7Sxw161283 adapter_t *adapter; 34*d39a76e7Sxw161283 }; 35*d39a76e7Sxw161283 36*d39a76e7Sxw161283 int t1_cspi_intr_enable(struct pecspi *cspi) 37*d39a76e7Sxw161283 { 38*d39a76e7Sxw161283 t1_write_reg_4(cspi->adapter, A_CSPI_INTR_ENABLE, 0xffffffff); 39*d39a76e7Sxw161283 return 0; 40*d39a76e7Sxw161283 } 41*d39a76e7Sxw161283 42*d39a76e7Sxw161283 int t1_cspi_intr_disable(struct pecspi *cspi) 43*d39a76e7Sxw161283 { 44*d39a76e7Sxw161283 t1_write_reg_4(cspi->adapter, A_CSPI_INTR_ENABLE, 0); 45*d39a76e7Sxw161283 return 0; 46*d39a76e7Sxw161283 } 47*d39a76e7Sxw161283 48*d39a76e7Sxw161283 int t1_cspi_intr_status_read(struct pecspi *cspi, u32 *status) 49*d39a76e7Sxw161283 { 50*d39a76e7Sxw161283 *status = t1_read_reg_4(cspi->adapter, A_CSPI_INTR_STATUS); 51*d39a76e7Sxw161283 52*d39a76e7Sxw161283 /* TBD XXX Need to poll in case of parity/overflow */ 53*d39a76e7Sxw161283 /* t1_write_reg_4( adapter, CSPI_REG_RAMSTATUS, ); */ 54*d39a76e7Sxw161283 55*d39a76e7Sxw161283 return 0; 56*d39a76e7Sxw161283 } 57*d39a76e7Sxw161283 58*d39a76e7Sxw161283 int t1_cspi_init(struct pecspi *cspi) 59*d39a76e7Sxw161283 { 60*d39a76e7Sxw161283 adapter_t *adapter = cspi->adapter; 61*d39a76e7Sxw161283 62*d39a76e7Sxw161283 t1_write_reg_4(adapter, A_CSPI_CALENDAR_LEN, 15); 63*d39a76e7Sxw161283 t1_write_reg_4(adapter, A_CSPI_FIFO_STATUS_ENABLE, 1); 64*d39a76e7Sxw161283 return 0; 65*d39a76e7Sxw161283 } 66*d39a76e7Sxw161283 67*d39a76e7Sxw161283 struct pecspi *t1_cspi_create(adapter_t *adapter) 68*d39a76e7Sxw161283 { 69*d39a76e7Sxw161283 struct pecspi *cspi = t1_os_malloc_wait_zero(sizeof(*cspi)); 70*d39a76e7Sxw161283 71*d39a76e7Sxw161283 if (cspi) 72*d39a76e7Sxw161283 cspi->adapter = adapter; 73*d39a76e7Sxw161283 return cspi; 74*d39a76e7Sxw161283 } 75*d39a76e7Sxw161283 76*d39a76e7Sxw161283 void t1_cspi_destroy(struct pecspi *cspi) 77*d39a76e7Sxw161283 { 78*d39a76e7Sxw161283 t1_os_free((void *)cspi, sizeof(*cspi)); 79*d39a76e7Sxw161283 } 80