Linux Kernel
3.7.1
|
#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 |
EXPORT_SYMBOL_GPL | ( | i2400m_bm_cmd_prepare | ) |
EXPORT_SYMBOL_GPL | ( | i2400m_is_boot_barker | ) |
EXPORT_SYMBOL_GPL | ( | i2400m_dev_bootstrap | ) |
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.
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.
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.