# FPGA Bridge

_Peios Kernel / Hardware and drivers / Driver development / FPGAs_

> struct fpga_bridge - The FPGA Bridge structure

<a id="rst-fpga-bridge"></a>

<a id="rst-api-to-implement-a-new-fpga-bridge"></a>

## API to implement a new FPGA bridge

- struct fpga_bridge - The FPGA Bridge structure

- struct fpga_bridge_ops - Low level Bridge driver ops

- \__fpga_bridge_register() - Create and register a bridge

- fpga_bridge_unregister() - Unregister a bridge

The helper macro `fpga_bridge_register()` automatically sets the module that registers the FPGA bridge as the owner.


#### <a id="c-struct-fpga_bridge"></a>`struct fpga_bridge`

FPGA bridge structure

**Definition**

```c
struct fpga_bridge {
    const char *name;
    struct device dev;
    struct mutex mutex;
    const struct fpga_bridge_ops *br_ops;
    struct module *br_ops_owner;
    struct fpga_image_info *info;
    struct list_head node;
    void *priv;
};
```

**Members**

- `name`: name of low level FPGA bridge
- `dev`: FPGA bridge device
- `mutex`: enforces exclusive reference to bridge
- `br_ops`: pointer to struct of FPGA bridge ops
- `br_ops_owner`: module containing the br_ops
- `info`: fpga image specific information
- `node`: FPGA bridge list node
- `priv`: low level driver private date



#### <a id="c-struct-fpga_bridge_ops"></a>`struct fpga_bridge_ops`

ops for low level FPGA bridge drivers

**Definition**

```c
struct fpga_bridge_ops {
    int (*enable_show)(struct fpga_bridge *bridge);
    int (*enable_set)(struct fpga_bridge *bridge, bool enable);
    void (*fpga_bridge_remove)(struct fpga_bridge *bridge);
    const struct attribute_group **groups;
};
```

**Members**

- `enable_show`: returns the FPGA bridge's status
- `enable_set`: set an FPGA bridge as enabled or disabled
- `fpga_bridge_remove`: set FPGA into a specific state during driver remove
- `groups`: optional attribute groups.



#### <a id="c-__fpga_bridge_register"></a>`__fpga_bridge_register()`

```c
struct fpga_bridge * __fpga_bridge_register(struct device *parent, const char *name, const struct fpga_bridge_ops *br_ops, void *priv, struct module *owner)
```

create and register an FPGA Bridge device

**Parameters**

- `struct device *parent`: FPGA bridge device from pdev
- `const char *name`: FPGA bridge name
- `const struct fpga_bridge_ops *br_ops`: pointer to structure of fpga bridge ops
- `void *priv`: FPGA bridge private data
- `struct module *owner`: owner module containing the br_ops

**Return**

struct fpga_bridge pointer or [`ERR_PTR()`](/kernel/internals/core-api/kernel-api.md#c-ERR_PTR)



#### <a id="c-fpga_bridge_unregister"></a>`fpga_bridge_unregister()`

```c
void fpga_bridge_unregister(struct fpga_bridge *bridge)
```

unregister an FPGA bridge

**Parameters**

- `struct fpga_bridge *bridge`: FPGA bridge struct

**Description**

This function is intended for use in an FPGA bridge driver's remove function.
