qemu/include/hw/mdio/mdio_slave.h
<<
>>
Prefs
   1#ifndef MDIO_SLAVE_H
   2#define MDIO_SLAVE_H
   3
   4#include "hw/qdev.h"
   5
   6#define TYPE_MDIO_SLAVE "mdio-slave"
   7#define MDIO_SLAVE(obj) \
   8    OBJECT_CHECK(MDIOSlave, (obj), TYPE_MDIO_SLAVE)
   9#define MDIO_SLAVE_CLASS(klass) \
  10    OBJECT_CLASS_CHECK(MDIOSlaveClass, (klass), TYPE_MDIO_SLAVE)
  11#define MDIO_SLAVE_GET_CLASS(obj) \
  12    OBJECT_GET_CLASS(MDIOSlaveClass, (obj), TYPE_MDIO_SLAVE)
  13
  14typedef struct MDIOSlave {
  15    DeviceState qdev;
  16
  17    uint8_t addr;
  18} MDIOSlave;
  19
  20typedef struct MDIOSlaveClass {
  21    DeviceClass parent_class;
  22
  23    /* Master to Slave */
  24    int (*send)(MDIOSlave *s, uint8_t reg, uint8_t data);
  25    /*slave to master */
  26    int (*recv)(MDIOSlave *s, uint8_t reg);
  27} MDIOSlaveClass;
  28
  29#define TYPE_MDIO_BUS "mdio-bus"
  30#define MDIO_BUS(obj) OBJECT_CHECK(struct MDIOBus, (obj), TYPE_MDIO_BUS)
  31
  32struct MDIOBus {
  33    BusState qbus;
  34
  35    uint8_t cur_addr;
  36    MDIOSlave *cur_slave;
  37};
  38
  39struct MDIOBus *mdio_init_bus(DeviceState *parent, const char *name);
  40void mdio_set_slave_addr(MDIOSlave *s, uint8_t addr);
  41int mdio_send(struct MDIOBus *s, uint8_t addr, uint8_t reg, uint8_t data);
  42int mdio_recv(struct MDIOBus *s, uint8_t addr, uint8_t reg);
  43
  44#endif
  45