qemu-riscv
[Top][All Lists]
Advanced

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

Re: [PATCH v2 01/13] hw/sd/ssi-sd: Do not create SD card within controll


From: Markus Armbruster
Subject: Re: [PATCH v2 01/13] hw/sd/ssi-sd: Do not create SD card within controller's realize
Date: Mon, 06 Dec 2021 13:34:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Hi Markus, Peter,
>
> On 11/17/21 17:33, Markus Armbruster wrote:
>> ssi_sd_realize() creates an "sd-card" device.  This is inappropriate,
>> and marked FIXME.
>> 
>> Move it to the boards that create these devices.  Prior art: commit
>> eb4f566bbb for device "generic-sdhci", and commit 26c607b86b for
>> device "pl181".
>> 
>> The device remains not user-creatable, because its users should (and
>> do) wire up its GPIO chip-select line.
>> 
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> Cc: Alistair Francis <Alistair.Francis@wdc.com>
>> Cc: Bin Meng <bin.meng@windriver.com>
>> Cc: Palmer Dabbelt <palmer@dabbelt.com>
>> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
>> Cc: qemu-arm@nongnu.org
>> Cc: qemu-riscv@nongnu.org
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
>> ---
>>  hw/arm/stellaris.c  | 15 ++++++++++++++-
>>  hw/riscv/sifive_u.c | 13 ++++++++++++-
>>  hw/sd/ssi-sd.c      | 29 +----------------------------
>>  3 files changed, 27 insertions(+), 30 deletions(-)
>> 
>> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
>> index 78827ace6b..b6c8a5d609 100644
>> --- a/hw/arm/stellaris.c
>> +++ b/hw/arm/stellaris.c
>> @@ -10,6 +10,7 @@
>>  #include "qemu/osdep.h"
>>  #include "qapi/error.h"
>>  #include "hw/sysbus.h"
>> +#include "hw/sd/sd.h"
>>  #include "hw/ssi/ssi.h"
>>  #include "hw/arm/boot.h"
>>  #include "qemu/timer.h"
>> @@ -1157,6 +1158,9 @@ static void stellaris_init(MachineState *ms, 
>> stellaris_board_info *board)
>>              void *bus;
>>              DeviceState *sddev;
>>              DeviceState *ssddev;
>> +            DriveInfo *dinfo;
>> +            DeviceState *carddev;
>> +            BlockBackend *blk;
>>  
>>              /*
>>               * Some boards have both an OLED controller and SD card 
>> connected to
>> @@ -1221,8 +1225,17 @@ static void stellaris_init(MachineState *ms, 
>> stellaris_board_info *board)
>>               *  - Make the ssd0323 OLED controller chipselect active-low
>>               */
>>              bus = qdev_get_child_bus(dev, "ssi");
>> -
>>              sddev = ssi_create_peripheral(bus, "ssi-sd");
>> +
>> +            dinfo = drive_get(IF_SD, 0, 0);
>> +            blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
>> +            carddev = qdev_new(TYPE_SD_CARD);
>> +            qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal);
>
> I guess a already asked this once but don't remember now... What is the
> point of creating a SD card without drive? Is this due to the old design
> issue we hotplug the drive to the SD card and not the SD card on the SD
> bus?

Device model "sd-card" implements BlockdevOps method change_media_cb().
This menas it models a device with a removable medium.  No drive behaves
like no medium.  I guess it's an SD card reader.

>
>> +            qdev_prop_set_bit(carddev, "spi", true);
>> +            qdev_realize_and_unref(carddev,
>> +                                   qdev_get_child_bus(sddev, "sd-bus"),
>> +                                   &error_fatal);
>> +




reply via email to

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