ssi-sd.c (0c0e618d233e3249f6b60678a1b013a2c8d83339) ssi-sd.c (de1b3800b7ec929f95371e6ab0345bf8b583043d)
1/*
2 * SSI to SD card adapter.
3 *
4 * Copyright (c) 2007-2009 CodeSourcery.
5 * Written by Paul Brook
6 *
7 * This code is licensed under the GNU GPL v2.
8 *

--- 227 unchanged lines hidden (view full) ---

236 VMSTATE_INT32(stopping, ssi_sd_state),
237 VMSTATE_SSI_SLAVE(ssidev, ssi_sd_state),
238 VMSTATE_END_OF_LIST()
239 }
240};
241
242static void ssi_sd_realize(SSISlave *d, Error **errp)
243{
1/*
2 * SSI to SD card adapter.
3 *
4 * Copyright (c) 2007-2009 CodeSourcery.
5 * Written by Paul Brook
6 *
7 * This code is licensed under the GNU GPL v2.
8 *

--- 227 unchanged lines hidden (view full) ---

236 VMSTATE_INT32(stopping, ssi_sd_state),
237 VMSTATE_SSI_SLAVE(ssidev, ssi_sd_state),
238 VMSTATE_END_OF_LIST()
239 }
240};
241
242static void ssi_sd_realize(SSISlave *d, Error **errp)
243{
244 ERRP_GUARD();
244 ssi_sd_state *s = SSI_SD(d);
245 DeviceState *carddev;
246 DriveInfo *dinfo;
245 ssi_sd_state *s = SSI_SD(d);
246 DeviceState *carddev;
247 DriveInfo *dinfo;
247 Error *err = NULL;
248
249 qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
250 DEVICE(d), "sd-bus");
251
252 /* Create and plug in the sd card */
253 /* FIXME use a qdev drive property instead of drive_get_next() */
254 dinfo = drive_get_next(IF_SD);
255 carddev = qdev_new(TYPE_SD_CARD);
256 if (dinfo) {
257 if (!qdev_prop_set_drive_err(carddev, "drive",
248
249 qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), TYPE_SD_BUS,
250 DEVICE(d), "sd-bus");
251
252 /* Create and plug in the sd card */
253 /* FIXME use a qdev drive property instead of drive_get_next() */
254 dinfo = drive_get_next(IF_SD);
255 carddev = qdev_new(TYPE_SD_CARD);
256 if (dinfo) {
257 if (!qdev_prop_set_drive_err(carddev, "drive",
258 blk_by_legacy_dinfo(dinfo), &err)) {
258 blk_by_legacy_dinfo(dinfo), errp)) {
259 goto fail;
260 }
261 }
262
259 goto fail;
260 }
261 }
262
263 if (!object_property_set_bool(OBJECT(carddev), "spi", true, &err)) {
263 if (!object_property_set_bool(OBJECT(carddev), "spi", true, errp)) {
264 goto fail;
265 }
266
264 goto fail;
265 }
266
267 if (!qdev_realize_and_unref(carddev, BUS(&s->sdbus), &err)) {
267 if (!qdev_realize_and_unref(carddev, BUS(&s->sdbus), errp)) {
268 goto fail;
269 }
270
271 return;
272
273fail:
268 goto fail;
269 }
270
271 return;
272
273fail:
274 error_propagate_prepend(errp, err, "failed to init SD card: ");
274 error_prepend(errp, "failed to init SD card: ");
275}
276
277static void ssi_sd_reset(DeviceState *dev)
278{
279 ssi_sd_state *s = SSI_SD(dev);
280
281 s->mode = SSI_SD_CMD;
282 s->cmd = 0;

--- 34 unchanged lines hidden ---
275}
276
277static void ssi_sd_reset(DeviceState *dev)
278{
279 ssi_sd_state *s = SSI_SD(dev);
280
281 s->mode = SSI_SD_CMD;
282 s->cmd = 0;

--- 34 unchanged lines hidden ---