iPXE
Functions | Variables
atl2_hw.c File Reference

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

#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_()

static int atl2_hw_boot_completed_ ( struct atl_nic nic)
static

Definition at line 42 of file atl2_hw.c.

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

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 50 of file atl2_hw.c.

51  {
52  uint32_t i;
53 
54  for (i = 0; i < len; ++i )
55  {
57  }
58 }
#define ATL2_MIF_SHARED_BUF_IN
Definition: atl2_hw.h:80
#define ATL_READ_REG(REG)
Definition: aqc1xx.h:181
unsigned int uint32_t
Definition: stdint.h:12
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
uint32_t len
Length.
Definition: ena.h:14

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 60 of file atl2_hw.c.

61  {
62  uint32_t i;
63 
64  for ( i = 0; i < len; ++i )
65  {
67  }
68 }
#define ATL2_MIF_SHARED_BUF_IN
Definition: atl2_hw.h:80
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
unsigned int uint32_t
Definition: stdint.h:12
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
uint32_t len
Length.
Definition: ena.h:14

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 70 of file atl2_hw.c.

70  {
71  uint32_t i;
72  int err = 0;
73 
76 
77  for ( i = 0; i < ( ms / 100 ); ++i )
78  {
79  if ( ( ATL_READ_REG ( ATL2_MCP_BUSY_WRITE ) & 1 ) == 0 )
80  {
81  break;
82  }
84  }
85  if (i == ( ms / 100 ) )
86  err = -ETIME;
87 
88  return err;
89 }
#define ATL2_DELAY_100
Definition: atl2_hw.h:92
#define ATL2_HOST_FINISHED_WRITE
Definition: atl2_hw.h:35
#define ATL2_MCP_BUSY_WRITE
Definition: atl2_hw.h:36
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
#define ATL_READ_REG(REG)
Definition: aqc1xx.h:181
#define ETIME
Timer expired.
Definition: errno.h:664
unsigned int uint32_t
Definition: stdint.h:12

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 91 of file atl2_hw.c.

91  {
92  uint32_t val;
93  int err = 0;
94 
96  val |= ( ATL2_HOST_MODE_ACTIVE | ( 1U << 13 ) );
98 
100  val = 16352;
102 
104  val = 0;
106  err = atl2_hw_finish_ack_ ( nic, 50000000 );
107 
108  return err;
109 }
void __asmcall int val
Definition: setjmp.h:12
void atl2_hw_write_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:60
int atl2_hw_finish_ack_(struct atl_nic *nic, uint32_t ms)
Definition: atl2_hw.c:70
#define ATL2_HOST_MODE_ACTIVE
Definition: atl2_hw.h:75
#define ATL2_LINK_OPTS_IN_OFF
Definition: atl2_hw.h:86
void atl2_hw_read_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:50
#define ATL2_MTU_IN_OFF
Definition: atl2_hw.h:83
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
#define ATL2_LINK_CTRL_IN_OFF
Definition: atl2_hw.h:85

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 111 of file atl2_hw.c.

111  {
112  int completed = 0;
113  uint32_t status = 0;
115  int err = 0;
116  int i;
117 
119 
121 
122  /* Wait for boot code started every 10us, 200 ms */
123  for ( i = 0; i < 20000; ++i )
124  {
126 
127  if ( ( ( status & ATL2_RESET_STATUS_BC_STARTED ) &&
128  ( status != 0xFFFFFFFFu ) ) )
129  break;
130 
131  udelay ( ATL2_DELAY_10 );
132  }
133  if ( i == 20000 )
134  {
135  DBGC ( nic, "Boot code hanged" );
136  err = -EIO;
137  goto err_exit;
138  }
139 
140  /* Wait for boot succeed, failed or host request every 10us, 480ms */
141  for ( i = 0; i < 48000; ++i )
142  {
143  completed = atl2_hw_boot_completed_ ( nic );
144  if ( completed )
145  break;
146 
147  udelay ( ATL2_DELAY_10 );
148  }
149 
150  if ( !completed )
151  {
152  DBGC ( nic, "FW Restart timed out" );
153  err = -ETIME;
154  goto err_exit;
155  }
156 
158 
160  {
161  err = -EIO;
162  DBGC ( nic, "FW Restart failed" );
163  DBGC ( nic, "status = 0x%x", status );
164  goto err_exit;
165  }
166 
169  {
170  err = -ENOTSUP;
171  DBGC ( nic, "Dynamic FW load not implemented" );
172  goto err_exit;
173  }
174 
175  err = atl2_hw_fw_init_ ( nic );
176 
177 err_exit:
178  return err;
179 }
#define ATL2_RESET_STATUS_BOOT_FAILED_MASK
Definition: atl2_hw.h:53
int atl2_hw_fw_init_(struct atl_nic *nic)
Definition: atl2_hw.c:91
#define ATL2_RESET_STATUS_REQ_GSR
Definition: atl2_hw.h:40
#define DBGC(...)
Definition: compiler.h:505
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
#define ATL2_GLB_RST_CTRL2
Definition: atl2_hw.h:34
#define ATL2_HOST_ITR_REQ
Definition: atl2_hw.h:37
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define ATL_WRITE_REG(VAL, REG)
Definition: aqc1xx.h:180
static int atl2_hw_boot_completed_(struct atl_nic *nic)
Definition: atl2_hw.c:42
#define ATL_READ_REG(REG)
Definition: aqc1xx.h:181
#define ETIME
Timer expired.
Definition: errno.h:664
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12
uint8_t status
Status.
Definition: ena.h:16
#define ATL2_RESET_STATUS_BC_STARTED
Definition: atl2_hw.h:47
#define EIO
Input/output error.
Definition: errno.h:433
#define ATL2_FW_HOST_INTERRUPT_REQUEST_READY
Definition: atl2_hw.h:56
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
#define ATL2_DELAY_10
Definition: atl2_hw.h:91

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 181 of file atl2_hw.c.

181  {
182  uint32_t val;
183 
185  val = 0x4B00FFE1;
187 
188  return atl2_hw_finish_ack_ ( nic, 100000 );
189 }
void __asmcall int val
Definition: setjmp.h:12
void atl2_hw_write_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:60
int atl2_hw_finish_ack_(struct atl_nic *nic, uint32_t ms)
Definition: atl2_hw.c:70
#define ATL2_LINK_OPTS_IN_OFF
Definition: atl2_hw.h:86
void atl2_hw_read_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:50
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12

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)

Definition at line 191 of file atl2_hw.c.

191  {
192  uint32_t val;
193 
195  val = 0;
197 
198  return atl2_hw_finish_ack_ ( nic, 100000 );
199 }
void __asmcall int val
Definition: setjmp.h:12
void atl2_hw_write_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:60
int atl2_hw_finish_ack_(struct atl_nic *nic, uint32_t ms)
Definition: atl2_hw.c:70
#define ATL2_LINK_OPTS_IN_OFF
Definition: atl2_hw.h:86
void atl2_hw_read_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:50
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12

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

◆ atl2_hw_get_link()

int atl2_hw_get_link ( struct atl_nic nic)

Definition at line 201 of file atl2_hw.c.

201  {
202  uint32_t val;
203 
205 
206  return ( ( val & 0xf ) != 0 ) && ( ( val & 0xF0 ) != 0 );
207 }
void __asmcall int val
Definition: setjmp.h:12
#define ATL2_LINK_STS_OUT_OFF
Definition: atl2_hw.h:89
#define ATL2_MIF_SHARED_BUF_OUT
Definition: atl2_hw.h:81
#define ATL_READ_REG(REG)
Definition: aqc1xx.h:181
unsigned int uint32_t
Definition: stdint.h:12

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 209 of file atl2_hw.c.

209  {
210  uint32_t mac_addr[2] = {0};
211 
213 
214  memcpy ( mac, ( uint8_t * )mac_addr, 6 );
215 
216  return 0;
217 }
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void atl2_hw_read_shared_in_(struct atl_nic *nic, uint32_t offset, uint32_t *data, uint32_t len)
Definition: atl2_hw.c:50
#define ATL2_MAC_ADDR_IN_OFF
Definition: atl2_hw.h:84
unsigned char uint8_t
Definition: stdint.h:10
Definition: nic.h:49
unsigned int uint32_t
Definition: stdint.h:12

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:111
int atl2_hw_get_mac(struct atl_nic *nic, uint8_t *mac)
Definition: atl2_hw.c:209
int atl2_hw_stop(struct atl_nic *nic)
Definition: atl2_hw.c:191
int atl2_hw_get_link(struct atl_nic *nic)
Definition: atl2_hw.c:201
int atl2_hw_start(struct atl_nic *nic)
Definition: atl2_hw.c:181

Definition at line 219 of file atl2_hw.c.

Referenced by atl_probe().