fwupd/plugins/vli/fu-vli-device.h
Richard Hughes 9f13d8ed1e vli: Be more specific when matching the MSP430
Add a FuDevice->ready() vfunc that is run after ->setup()
This allows plugins to perform setup actions that require quirk matches
after the instance IDs have been converted. This allows us to also
remove FuVliDevice->setup() as the ordering chain has been broken.

There are two USB-3 hubs internally (with the same VID&PID), and the
MSP430 is only attached to the top-level one.

Fixes https://github.com/fwupd/fwupd/issues/3366
2021-06-17 17:09:48 +01:00

97 lines
2.9 KiB
C

/*
* Copyright (C) 2019 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <fwupdplugin.h>
#include "fu-vli-common.h"
#define FU_TYPE_VLI_DEVICE (fu_vli_device_get_type ())
G_DECLARE_DERIVABLE_TYPE (FuVliDevice, fu_vli_device, FU, VLI_DEVICE, FuUsbDevice)
struct _FuVliDeviceClass
{
FuUsbDeviceClass parent_class;
gboolean (*spi_chip_erase) (FuVliDevice *self,
GError **error);
gboolean (*spi_sector_erase) (FuVliDevice *self,
guint32 addr,
GError **error);
gboolean (*spi_read_data) (FuVliDevice *self,
guint32 addr,
guint8 *buf,
gsize bufsz,
GError **error);
gboolean (*spi_read_status) (FuVliDevice *self,
guint8 *status,
GError **error);
gboolean (*spi_write_enable) (FuVliDevice *self,
GError **error);
gboolean (*spi_write_data) (FuVliDevice *self,
guint32 addr,
const guint8 *buf,
gsize bufsz,
GError **error);
gboolean (*spi_write_status) (FuVliDevice *self,
guint8 status,
GError **error);
};
typedef enum {
FU_VLI_DEVICE_SPI_REQ_READ_ID,
FU_VLI_DEVICE_SPI_REQ_PAGE_PROG,
FU_VLI_DEVICE_SPI_REQ_CHIP_ERASE,
FU_VLI_DEVICE_SPI_REQ_READ_DATA,
FU_VLI_DEVICE_SPI_REQ_READ_STATUS,
FU_VLI_DEVICE_SPI_REQ_SECTOR_ERASE,
FU_VLI_DEVICE_SPI_REQ_WRITE_EN,
FU_VLI_DEVICE_SPI_REQ_WRITE_STATUS,
FU_VLI_DEVICE_SPI_REQ_LAST
} FuVliDeviceSpiReq;
#define FU_VLI_DEVICE_TIMEOUT 3000 /* ms */
#define FU_VLI_DEVICE_TXSIZE 0x20 /* bytes */
void fu_vli_device_set_kind (FuVliDevice *self,
FuVliDeviceKind device_kind);
void fu_vli_device_set_spi_auto_detect (FuVliDevice *self,
gboolean spi_auto_detect);
FuVliDeviceKind fu_vli_device_get_kind (FuVliDevice *self);
guint32 fu_vli_device_get_offset (FuVliDevice *self);
gboolean fu_vli_device_get_spi_cmd (FuVliDevice *self,
FuVliDeviceSpiReq req,
guint8 *cmd,
GError **error);
gboolean fu_vli_device_spi_erase_sector (FuVliDevice *self,
guint32 addr,
GError **error);
gboolean fu_vli_device_spi_erase_all (FuVliDevice *self,
GError **error);
gboolean fu_vli_device_spi_erase (FuVliDevice *self,
guint32 addr,
gsize sz,
GError **error);
gboolean fu_vli_device_spi_read_block (FuVliDevice *self,
guint32 addr,
guint8 *buf,
gsize bufsz,
GError **error);
GBytes *fu_vli_device_spi_read (FuVliDevice *self,
guint32 address,
gsize bufsz,
GError **error);
gboolean fu_vli_device_spi_write_block (FuVliDevice *self,
guint32 address,
const guint8 *buf,
gsize bufsz,
GError **error);
gboolean fu_vli_device_spi_write (FuVliDevice *self,
guint32 address,
const guint8 *buf,
gsize bufsz,
GError **error);