qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V2 6/6] hw/mdio: Use bitbang core for smc91c111


From: Paul Brook
Subject: Re: [Qemu-devel] [PATCH V2 6/6] hw/mdio: Use bitbang core for smc91c111 network device
Date: Fri, 25 Jan 2013 18:57:08 +0000
User-agent: KMail/1.13.7 (Linux/3.7-trunk-amd64; KDE/4.8.4; x86_64; ; )

> @@ -44,6 +45,10 @@ typedef struct {
>      uint8_t int_level;
>      uint8_t int_mask;
>      MemoryRegion mmio;
> +
> +    /* MDIO bus and the attached phy */
> +    struct qemu_mdio mdio_bus;
> +    struct qemu_phy phy;
>  } smc91c111_state;
> 
>  static const VMStateDescription vmstate_smc91c111 = {
> @@ -71,6 +76,8 @@ static const VMStateDescription vmstate_smc91c111 = {
>          VMSTATE_BUFFER_UNSAFE(data, smc91c111_state, 0, NUM_PACKETS *
> 2048), VMSTATE_UINT8(int_level, smc91c111_state),
>          VMSTATE_UINT8(int_mask, smc91c111_state),
> +        VMSTATE_MDIO(mdio_bus, smc91c111_state),
> +        VMSTATE_MDIO_PHY(phy, smc91c111_state),
>          VMSTATE_END_OF_LIST()
>      }
>  };

> @@ -754,6 +768,9 @@ static int smc91c111_init1(SysBusDevice *dev)
>      s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf,
>                            object_get_typename(OBJECT(dev)), dev->qdev.id,
> s); qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
> +
> +    tdk_init(&s->phy);
> +    mdio_attach(&s->mdio_bus, &s->phy, 0);
>      /* ??? Save/restore.  */
>      return 0;
>  }

There's no reason for smc91c111_state to contain the PHY state.  For devices 
with an off-chip PHY we have no way of knowing which phy is used, or what 
state is required.

The PHY should be a device in its own right, and know how to save/restore 
itself.  smc91c111_init1 should create the PHY, attach it to the MDIO bus, 
then forget about it.

Paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]