Deleted Added
full compact
mmcsd.c (239607) mmcsd.c (248689)
1/*-
2 * Copyright (c) 2006 Bernd Walter. All rights reserved.
3 * Copyright (c) 2006 M. Warner Losh. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

46 * implication, estoppel or otherwise under any patent or other rights of the
47 * SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
48 * herein shall be construed as an obligation by the SD Group, the SD-3C LLC
49 * or the SD Card Association to disclose or distribute any technical
50 * information, know-how or other confidential information to any third party.
51 */
52
53#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 Bernd Walter. All rights reserved.
3 * Copyright (c) 2006 M. Warner Losh. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

46 * implication, estoppel or otherwise under any patent or other rights of the
47 * SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
48 * herein shall be construed as an obligation by the SD Group, the SD-3C LLC
49 * or the SD Card Association to disclose or distribute any technical
50 * information, know-how or other confidential information to any third party.
51 */
52
53#include <sys/cdefs.h>
54__FBSDID("$FreeBSD: head/sys/dev/mmc/mmcsd.c 239607 2012-08-23 04:35:55Z imp $");
54__FBSDID("$FreeBSD: head/sys/dev/mmc/mmcsd.c 248689 2013-03-24 17:23:10Z ian $");
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/bio.h>
59#include <sys/bus.h>
60#include <sys/conf.h>
61#include <sys/kernel.h>
62#include <sys/kthread.h>

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

317 end = bp->bio_pblkno + (bp->bio_bcount / sz);
318 while (block < end) {
319 char *vaddr = bp->bio_data +
320 (block - bp->bio_pblkno) * sz;
321 int numblocks = min(end - block, mmc_get_max_data(dev));
322 memset(&req, 0, sizeof(req));
323 memset(&cmd, 0, sizeof(cmd));
324 memset(&stop, 0, sizeof(stop));
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/bio.h>
59#include <sys/bus.h>
60#include <sys/conf.h>
61#include <sys/kernel.h>
62#include <sys/kthread.h>

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

317 end = bp->bio_pblkno + (bp->bio_bcount / sz);
318 while (block < end) {
319 char *vaddr = bp->bio_data +
320 (block - bp->bio_pblkno) * sz;
321 int numblocks = min(end - block, mmc_get_max_data(dev));
322 memset(&req, 0, sizeof(req));
323 memset(&cmd, 0, sizeof(cmd));
324 memset(&stop, 0, sizeof(stop));
325 cmd.mrq = &req;
325 req.cmd = &cmd;
326 cmd.data = &data;
327 if (bp->bio_cmd == BIO_READ) {
328 if (numblocks > 1)
329 cmd.opcode = MMC_READ_MULTIPLE_BLOCK;
330 else
331 cmd.opcode = MMC_READ_SINGLE_BLOCK;
332 } else {

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

346 else
347 data.flags = MMC_DATA_WRITE;
348 data.len = numblocks * sz;
349 if (numblocks > 1) {
350 data.flags |= MMC_DATA_MULTI;
351 stop.opcode = MMC_STOP_TRANSMISSION;
352 stop.arg = 0;
353 stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
326 req.cmd = &cmd;
327 cmd.data = &data;
328 if (bp->bio_cmd == BIO_READ) {
329 if (numblocks > 1)
330 cmd.opcode = MMC_READ_MULTIPLE_BLOCK;
331 else
332 cmd.opcode = MMC_READ_SINGLE_BLOCK;
333 } else {

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

347 else
348 data.flags = MMC_DATA_WRITE;
349 data.len = numblocks * sz;
350 if (numblocks > 1) {
351 data.flags |= MMC_DATA_MULTI;
352 stop.opcode = MMC_STOP_TRANSMISSION;
353 stop.arg = 0;
354 stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
355 stop.mrq = &req;
354 req.stop = &stop;
355 }
356 MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
357 &req);
358 if (req.cmd->error != MMC_ERR_NONE) {
359 device_printf(dev, "Error indicated: %d %s\n",
360 req.cmd->error, mmcsd_errmsg(req.cmd->error));
361 break;

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

393 sc->eblock = block;
394 sc->eend = end;
395 return (end);
396 }
397
398 /* Set erase start position. */
399 memset(&req, 0, sizeof(req));
400 memset(&cmd, 0, sizeof(cmd));
356 req.stop = &stop;
357 }
358 MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
359 &req);
360 if (req.cmd->error != MMC_ERR_NONE) {
361 device_printf(dev, "Error indicated: %d %s\n",
362 req.cmd->error, mmcsd_errmsg(req.cmd->error));
363 break;

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

395 sc->eblock = block;
396 sc->eend = end;
397 return (end);
398 }
399
400 /* Set erase start position. */
401 memset(&req, 0, sizeof(req));
402 memset(&cmd, 0, sizeof(cmd));
403 cmd.mrq = &req;
401 req.cmd = &cmd;
402 if (mmc_get_card_type(dev) == mode_sd)
403 cmd.opcode = SD_ERASE_WR_BLK_START;
404 else
405 cmd.opcode = MMC_ERASE_GROUP_START;
406 cmd.arg = start;
407 if (!mmc_get_high_cap(dev))
408 cmd.arg <<= 9;

--- 161 unchanged lines hidden ---
404 req.cmd = &cmd;
405 if (mmc_get_card_type(dev) == mode_sd)
406 cmd.opcode = SD_ERASE_WR_BLK_START;
407 else
408 cmd.opcode = MMC_ERASE_GROUP_START;
409 cmd.arg = start;
410 if (!mmc_get_high_cap(dev))
411 cmd.arg <<= 9;

--- 161 unchanged lines hidden ---