iPXE
atl2_hw.c File Reference

Marvell AQtion family network card driver, hardware-specific functions. More...

#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <byteswap.h>
#include <ipxe/pci.h>
#include "aqc1xx.h"
#include "atl2_hw.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (BSD2)
static int atl2_hw_boot_completed_ (struct atl_nic *nic)
void atl2_hw_read_shared_in_ (struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
void atl2_hw_write_shared_in_ (struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
int atl2_hw_finish_ack_ (struct atl_nic *nic, uint32_t ms)
int atl2_hw_fw_init_ (struct atl_nic *nic)
int atl2_hw_reset (struct atl_nic *nic)
int atl2_hw_start (struct atl_nic *nic)
int atl2_hw_stop (struct atl_nic *nic)
int atl2_hw_get_link (struct atl_nic *nic)
int atl2_hw_get_mac (struct atl_nic *nic, uint8_t *mac)

Variables

struct atl_hw_ops atl2_hw

Detailed Description

Marvell AQtion family network card driver, hardware-specific functions.

Copyright(C) 2017-2024 Marvell

SPDX-License-Identifier: BSD-2-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file atl2_hw.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( BSD2 )

◆ atl2_hw_boot_completed_()

int atl2_hw_boot_completed_ ( struct atl_nic * nic)
static

Definition at line 43 of file atl2_hw.c.

43 {
44 uint32_t reset_status = ATL_READ_REG ( ATL2_GLB_RST_CTRL2 );
45
46 return ( reset_status & ATL2_RESET_STATUS_BOOT_COMPLETED_MASK ) ||
49}
#define ATL_READ_REG(REG)
Definition aqc1xx.h:181
unsigned int uint32_t
Definition stdint.h:12
#define ATL2_GLB_RST_CTRL2
Definition atl2_hw.h:34
#define ATL2_RESET_STATUS_BOOT_COMPLETED_MASK
Definition atl2_hw.h:54
#define ATL2_HOST_ITR_REQ
Definition atl2_hw.h:37
#define ATL2_FW_HOST_INTERRUPT_REQUEST_READY
Definition atl2_hw.h:56

References ATL2_FW_HOST_INTERRUPT_REQUEST_READY, ATL2_GLB_RST_CTRL2, ATL2_HOST_ITR_REQ, ATL2_RESET_STATUS_BOOT_COMPLETED_MASK, and ATL_READ_REG.

Referenced by atl2_hw_reset().

◆ atl2_hw_read_shared_in_()

void atl2_hw_read_shared_in_ ( struct atl_nic * nic,
uint32_t offset,
uint32_t * data,
uint32_t len )

Definition at line 51 of file atl2_hw.c.

52 {
53 uint32_t i;
54
55 for (i = 0; i < len; ++i )
56 {
58 }
59}
#define ATL2_MIF_SHARED_BUF_IN
Definition atl2_hw.h:80
uint16_t offset
Offset to command line.
Definition bzimage.h:3
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11

References ATL2_MIF_SHARED_BUF_IN, ATL_READ_REG, data, len, and offset.

Referenced by atl2_hw_fw_init_(), atl2_hw_get_mac(), atl2_hw_start(), and atl2_hw_stop().

◆ atl2_hw_write_shared_in_()

void atl2_hw_write_shared_in_ ( struct atl_nic * nic,
uint32_t offset,
uint32_t * data,
uint32_t len )

Definition at line 61 of file atl2_hw.c.

62 {
63 uint32_t i;
64
65 for ( i = 0; i < len; ++i )
66 {
68 }
69}
#define ATL_WRITE_REG(VAL, REG)
Definition aqc1xx.h:180

References ATL2_MIF_SHARED_BUF_IN, ATL_WRITE_REG, data, len, and offset.

Referenced by atl2_hw_fw_init_(), atl2_hw_start(), and atl2_hw_stop().

◆ atl2_hw_finish_ack_()

int atl2_hw_finish_ack_ ( struct atl_nic * nic,
uint32_t ms )

Definition at line 71 of file atl2_hw.c.

71 {
72 uint32_t i;
73 int err = 0;
74
77
78 for ( i = 0; i < ( ms / 100 ); ++i )
79 {
80 if ( ( ATL_READ_REG ( ATL2_MCP_BUSY_WRITE ) & 1 ) == 0 )
81 {
82 break;
83 }
85 }
86 if (i == ( ms / 100 ) )
87 err = -ETIME;
88
89 return err;
90}
#define ATL2_HOST_FINISHED_WRITE
Definition atl2_hw.h:35
#define ATL2_MCP_BUSY_WRITE
Definition atl2_hw.h:36
#define ATL2_DELAY_100
Definition atl2_hw.h:92
#define ETIME
Timer expired.
Definition errno.h:665
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61

References ATL2_DELAY_100, ATL2_HOST_FINISHED_WRITE, ATL2_MCP_BUSY_WRITE, ATL_READ_REG, ATL_WRITE_REG, ETIME, and udelay().

Referenced by atl2_hw_fw_init_(), atl2_hw_start(), and atl2_hw_stop().

◆ atl2_hw_fw_init_()

int atl2_hw_fw_init_ ( struct atl_nic * nic)

Definition at line 92 of file atl2_hw.c.

92 {
94 int err = 0;
95
97 val |= ( ATL2_HOST_MODE_ACTIVE | ( 1U << 13 ) );
99
101 val = 16352;
103
105 val = 0;
107 err = atl2_hw_finish_ack_ ( nic, 50000000 );
108
109 return err;
110}
void atl2_hw_write_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition atl2_hw.c:61
int atl2_hw_finish_ack_(struct atl_nic *nic, uint32_t ms)
Definition atl2_hw.c:71
void atl2_hw_read_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition atl2_hw.c:51
#define ATL2_LINK_CTRL_IN_OFF
Definition atl2_hw.h:85
#define ATL2_MTU_IN_OFF
Definition atl2_hw.h:83
#define ATL2_LINK_OPTS_IN_OFF
Definition atl2_hw.h:86
#define ATL2_HOST_MODE_ACTIVE
Definition atl2_hw.h:75
void __asmcall int val
Definition setjmp.h:12
Definition nic.h:49

References ATL2_HOST_MODE_ACTIVE, atl2_hw_finish_ack_(), atl2_hw_read_shared_in_(), atl2_hw_write_shared_in_(), ATL2_LINK_CTRL_IN_OFF, ATL2_LINK_OPTS_IN_OFF, ATL2_MTU_IN_OFF, and val.

Referenced by atl2_hw_reset().

◆ atl2_hw_reset()

int atl2_hw_reset ( struct atl_nic * nic)

Definition at line 112 of file atl2_hw.c.

112 {
113 int completed = 0;
114 uint32_t status = 0;
116 int err = 0;
117 int i;
118
120
122
123 /* Wait for boot code started every 10us, 200 ms */
124 for ( i = 0; i < 20000; ++i )
125 {
127
129 ( status != 0xFFFFFFFFu ) ) )
130 break;
131
133 }
134 if ( i == 20000 )
135 {
136 DBGC ( nic, "Boot code hanged" );
137 err = -EIO;
138 goto err_exit;
139 }
140
141 /* Wait for boot succeed, failed or host request every 10us, 480ms */
142 for ( i = 0; i < 48000; ++i )
143 {
144 completed = atl2_hw_boot_completed_ ( nic );
145 if ( completed )
146 break;
147
149 }
150
151 if ( !completed )
152 {
153 DBGC ( nic, "FW Restart timed out" );
154 err = -ETIME;
155 goto err_exit;
156 }
157
159
161 {
162 err = -EIO;
163 DBGC ( nic, "FW Restart failed" );
164 DBGC ( nic, "status = 0x%x", status );
165 goto err_exit;
166 }
167
170 {
171 err = -ENOTSUP;
172 DBGC ( nic, "Dynamic FW load not implemented" );
173 goto err_exit;
174 }
175
176 err = atl2_hw_fw_init_ ( nic );
177
178err_exit:
179 return err;
180}
static int atl2_hw_boot_completed_(struct atl_nic *nic)
Definition atl2_hw.c:43
int atl2_hw_fw_init_(struct atl_nic *nic)
Definition atl2_hw.c:92
#define ATL2_RESET_STATUS_BC_STARTED
Definition atl2_hw.h:47
#define ATL2_RESET_STATUS_BOOT_FAILED_MASK
Definition atl2_hw.h:53
#define ATL2_DELAY_10
Definition atl2_hw.h:91
#define ATL2_RESET_STATUS_REQ_GSR
Definition atl2_hw.h:40
uint8_t status
Status.
Definition ena.h:5
#define DBGC(...)
Definition compiler.h:505
#define EIO
Input/output error.
Definition errno.h:434
#define ENOTSUP
Operation not supported.
Definition errno.h:590
u8 request[0]
List of IEs requested.
Definition ieee80211.h:2

References ATL2_DELAY_10, ATL2_FW_HOST_INTERRUPT_REQUEST_READY, ATL2_GLB_RST_CTRL2, ATL2_HOST_ITR_REQ, atl2_hw_boot_completed_(), atl2_hw_fw_init_(), ATL2_RESET_STATUS_BC_STARTED, ATL2_RESET_STATUS_BOOT_FAILED_MASK, ATL2_RESET_STATUS_REQ_GSR, ATL_READ_REG, ATL_WRITE_REG, DBGC, EIO, ENOTSUP, ETIME, request, status, and udelay().

◆ atl2_hw_start()

int atl2_hw_start ( struct atl_nic * nic)

Definition at line 182 of file atl2_hw.c.

182 {
184
186 val = 0x4B00FFE1;
188
189 return atl2_hw_finish_ack_ ( nic, 100000 );
190}

References atl2_hw_finish_ack_(), atl2_hw_read_shared_in_(), atl2_hw_write_shared_in_(), ATL2_LINK_OPTS_IN_OFF, and val.

◆ atl2_hw_stop()

int atl2_hw_stop ( struct atl_nic * nic)

◆ atl2_hw_get_link()

int atl2_hw_get_link ( struct atl_nic * nic)

Definition at line 202 of file atl2_hw.c.

202 {
204
206
207 return ( ( val & 0xf ) != 0 ) && ( ( val & 0xF0 ) != 0 );
208}
#define ATL2_MIF_SHARED_BUF_OUT
Definition atl2_hw.h:81
#define ATL2_LINK_STS_OUT_OFF
Definition atl2_hw.h:89

References ATL2_LINK_STS_OUT_OFF, ATL2_MIF_SHARED_BUF_OUT, ATL_READ_REG, and val.

◆ atl2_hw_get_mac()

int atl2_hw_get_mac ( struct atl_nic * nic,
uint8_t * mac )

Definition at line 210 of file atl2_hw.c.

210 {
211 uint32_t mac_addr[2] = {0};
212
214
215 memcpy ( mac, ( uint8_t * )mac_addr, 6 );
216
217 return 0;
218}
unsigned char uint8_t
Definition stdint.h:10
#define ATL2_MAC_ADDR_IN_OFF
Definition atl2_hw.h:84
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
void * memcpy(void *dest, const void *src, size_t len) __nonnull

References atl2_hw_read_shared_in_(), ATL2_MAC_ADDR_IN_OFF, mac, and memcpy().

Variable Documentation

◆ atl2_hw

struct atl_hw_ops atl2_hw
Initial value:
= {
.reset = atl2_hw_reset,
.start = atl2_hw_start,
.stop = atl2_hw_stop,
.get_link = atl2_hw_get_link,
.get_mac = atl2_hw_get_mac,
}
int atl2_hw_reset(struct atl_nic *nic)
Definition atl2_hw.c:112
int atl2_hw_start(struct atl_nic *nic)
Definition atl2_hw.c:182
int atl2_hw_get_mac(struct atl_nic *nic, uint8_t *mac)
Definition atl2_hw.c:210
int atl2_hw_stop(struct atl_nic *nic)
Definition atl2_hw.c:192
int atl2_hw_get_link(struct atl_nic *nic)
Definition atl2_hw.c:202

Definition at line 220 of file atl2_hw.c.

220 {
221 .reset = atl2_hw_reset,
222 .start = atl2_hw_start,
223 .stop = atl2_hw_stop,
224 .get_link = atl2_hw_get_link,
225 .get_mac = atl2_hw_get_mac,
226};

Referenced by atl_probe(), and FILE_LICENCE().