mmc: set correct block size value in bfin sdh driver

Wait data transfer till the data end bit other than the data block end
bit is set.

Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
mmc: fix ERASE_GRP_DEF handling

if we set manually this bit on the eMMC card using mmc_switch(...),
we also have to set it within our (before read) internal structure
'ext_csd'.

Otherwise following checks on this will fail.

Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>
mmc: restore capacity when switching to partition 0

The capacity and lba for an MMC device with part_num 0 reflects the
whole device.  When mmc_switch_part() successfully switches to a
partition, the capacity is changed to that partition.  As partition 0
does not physically exist, attempts to switch back to the whole device
will indicate an error, but the capacity setting for the whole device
must still be restored to match the partition.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Tested-by: Tom Rini <trini@ti.com>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
env_mmc: correct fini partition to match init partition

The code to set the MMC partition uses an weak function to obtain the
correct partition number.  Use that instead of the compile-time default
when deciding whether it needs to switch back.

Fixes: 6e7b7df4df43574 ("env_mmc: support env partition setup in runtime")
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Acked-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
mvebu_mmc: Driver addition

In function mvebu_mmc_write notice command timeout. It is possible that a
command is done, but a timeout occurred.

Enable timeout in set bus function.

Set window registers. Without that I could not use the driver on a Kirkwood
88F6282 SoC.

Set high capacity and 52MHz driver feature.

Signed-off-by: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>
Reviewed-by: Stefan Roese <sr@denx.de>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
mmc: Fix mmc bus width

After setting the bus width, the extended CSD register is read. Some selected
fields are compared with previously read extended CSD register fields. In this
comparison the EXT_CSD_ERASE_GROUP_DEF field is compared. But this field is
previously written under certain circumstances. And then the comparison fails.

Only compare read-only fields. Therefore compare field EXT_CSD_HC_WP_GRP_SIZE
instead of field EXT_CSD_ERASE_GROUP_DEF.

Signed-off-by: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
cmd_mmc: fix bootpart-resize maxarg to 4

sub-command 'bootpart-resize' check for argc == 4,
it will retrun CMD_RET_FAILURE when argc value not matched.

but bootpart-resize's maxarg is 3, which means you never execute
this sub-command successfully.

fix it by change bootpart-resize maxarg to 4.

Signed-off-by: wally.yeh <wally.yeh@atrustcorp.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Pierre Aubert <p.aubert@staubli.com>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
dw_mmc: cleanups

dw_mmc driver was responding to errors with debug(). Change that to
prinf so that any errors are immediately obvious. Also adjust english
in comments.

Signed-off-by: Pavel Machek <pavel@denx.de>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
cfi_flash: don't hide write/erase errors

Partially revert commit 0d01f66d235118 (CFI: cfi_flash write fix for AMD
legacy).

flash_full_status_check() used to skip status register parsing when
flash_status_check() returns OK. This is wrong since flash_status_check()
must return OK for other status bits to be valid.

Cc: Ed Swarthout <Ed.Swarthout@freescale.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Stefan Roese <sr@denx.de>
usb: ehci: Properly set hub devnum and portnr with usb-1 hubs in the chain

For full / low speed devices we need to get the devnum and portnr of the tt,
so of the first upstream usb-2 hub, not of the parent device (which may be a
usb-1 hub).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Add missing cache flush to destroy_int_queue

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: poll_int_queue check real qtd, not the overlay

When we first start an int queue, the qh's overlay area is all zeros. This
gets filled by the hc with the actual qtd values as soon as it advances
the queue, but we may call poll_int_queue before then, in which case we
would think the transfer has completed as the hc has not yet copied the
qt_token to the overlay, so the active flag is not set.

This fixes this by checking the actual qtd token, rather then the overlay.
This also fixes a (theoretical) race where we see the completion in the
overlay and free and re-use the qtd before the hc has completed writing back
the overlay to the actual qtd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Make periodic_schedules a per controller variable

Periodic schedules tracks how many int_queue-s are active, and decides whether
or not to en/disable the periodic schedule based on this. This is clearly
a per controller thing.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Fix unaligned buffer usage in usb_kbd_setled()

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Do not treat -ENODEV as an error for usb_kbd_deregister

ENODEV menas no usb keyboard was registered, threat this as a successful
usb_kbd_deregister.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: On a "usb reset" call usb_kbd_deregister() before calling usb_stop()

We need to call usb_kbd_deregister() before calling usb_stop().

usbkbd's stdio_dev->priv points to the usb_device, and usb_kbd_testc
dereferences usb_device->privptr.

usb_stop zeros usb_device, leaving usb_device->privptr NULL, causing
bad things (tm) to happen once control returns to the main loop and
usb_kbd_testc gets called.

Calling usb_kbd_deregister() avoids this. Note that we do not allow
the "usb reset" to continue when the deregister fails. This will be fixed
in a later patch.

For the same reasons always fail "usb stop" if the usb_kbd_deregister() fails,
even in the force path. This can happen when CONFIG_SYS_STDIO_DEREGISTER is
not set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Remove check for already being registered

We now always properly deregister the keyboard before calling
drv_usb_kbd_init(), so we can drop the check for already being registered.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
stdio: Add force parameter to stdio_deregister

In some cases we really want to move forward with a deregister, add a force
parameter to allow this, and replace the dev with a nulldev in this case.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Allow "usb reset" to continue when an usb kbd is used

Use the new force parameter to make the stdio_deregister succeed, replacing
stdin with a nulldev, and assume that the usb keyboard will come back after
the reset.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: dfu: thor: gadget: Remove dead code

This code is not used anymore in the current DFU implementation and
can be safely removed.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>