Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
fw.c File Reference
#include <linux/firmware.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/export.h>
#include "i2400m.h"
#include "debug-levels.h"

Go to the source code of this file.

Data Structures

struct  i2400m_barker_db
 
struct  i2400m_fw
 

Macros

#define D_SUBMODULE   fw
 

Functions

void i2400m_bm_cmd_prepare (struct i2400m_bootrom_header *cmd)
 
 EXPORT_SYMBOL_GPL (i2400m_bm_cmd_prepare)
 
void i2400m_barker_db_exit (void)
 
int i2400m_barker_db_init (const char *_options)
 
int i2400m_is_boot_barker (struct i2400m *i2400m, const void *buf, size_t buf_size)
 
 EXPORT_SYMBOL_GPL (i2400m_is_boot_barker)
 
int i2400m_bootrom_init (struct i2400m *i2400m, enum i2400m_bri flags)
 
int i2400m_read_mac_addr (struct i2400m *i2400m)
 
int i2400m_dev_bootstrap (struct i2400m *i2400m, enum i2400m_bri flags)
 
 EXPORT_SYMBOL_GPL (i2400m_dev_bootstrap)
 
void i2400m_fw_cache (struct i2400m *i2400m)
 
void i2400m_fw_uncache (struct i2400m *i2400m)
 

Macro Definition Documentation

#define D_SUBMODULE   fw

Definition at line 164 of file fw.c.

Function Documentation

EXPORT_SYMBOL_GPL ( i2400m_bm_cmd_prepare  )
EXPORT_SYMBOL_GPL ( i2400m_is_boot_barker  )
EXPORT_SYMBOL_GPL ( i2400m_dev_bootstrap  )
void i2400m_barker_db_exit ( void  )

Definition at line 269 of file fw.c.

int i2400m_barker_db_init ( const char _options)

Definition at line 312 of file fw.c.

void i2400m_bm_cmd_prepare ( struct i2400m_bootrom_header cmd)

Prepare a boot-mode command for delivery

: pointer to bootrom header to prepare

Computes checksum if so needed. After calling this function, DO NOT modify the command or header as the checksum won't work anymore.

We do it from here because some times we cannot do it in the original context the command was sent (it is a const), so when we copy it to our staging buffer, we add the checksum there.

Definition at line 188 of file fw.c.

int i2400m_bootrom_init ( struct i2400m i2400m,
enum i2400m_bri  flags 
)

i2400m_bootrom_init - Reboots a powered device into boot mode

: device descriptor : I2400M_BRI_SOFT: a reboot barker has been seen already, so don't wait for it.

I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait for a reboot barker notification. This is a one shot; if the state machine needs to send a reboot command it will.

Returns:

< 0 errno code on error, 0 if ok.

Description:

Tries hard enough to put the device in boot-mode. There are two main phases to this:

a. (1) send a reboot command and (2) get a reboot barker

b. (1) echo/ack the reboot sending the reboot barker back and (2) getting an ack barker in return

We want to skip (a) in some cases [soft]. The state machine is horrible, but it is basically: on each phase, send what has to be sent (if any), wait for the answer and act on the answer. We might have to backtrack and retry, so we keep a max tries counter for that.

It sucks because we don't know ahead of time which is going to be the reboot barker (the device might send different ones depending on its EEPROM config) and once the device reboots and waits for the echo/ack reboot barker being sent back, it doesn't understand anything else. So we can be left at the point where we don't know what to send to it – cold reset and bus reset seem to have little effect. So the function iterates (in this case) through all the known barkers and tries them all until an ACK is received. Otherwise, it gives up.

If we get a timeout after sending a warm reset, we do it again.

Definition at line 883 of file fw.c.

int i2400m_dev_bootstrap ( struct i2400m i2400m,
enum i2400m_bri  flags 
)

i2400m_dev_bootstrap - Bring the device to a known state and upload firmware

: device descriptor

Returns: >= 0 if ok, < 0 errno code on error.

This sets up the firmware upload environment, loads the firmware file from disk, verifies and then calls the firmware upload process per se.

Can be called either from probe, or after a warm reset. Can not be called from within an interrupt. All the flow in this code is single-threade; all I/Os are synchronous.

Definition at line 1551 of file fw.c.

void i2400m_fw_cache ( struct i2400m i2400m)

Definition at line 1605 of file fw.c.

void i2400m_fw_uncache ( struct i2400m i2400m)

Definition at line 1646 of file fw.c.

int i2400m_is_boot_barker ( struct i2400m i2400m,
const void buf,
size_t  buf_size 
)

Definition at line 384 of file fw.c.

int i2400m_read_mac_addr ( struct i2400m i2400m)

Definition at line 1025 of file fw.c.