Deleted Added
full compact
mmc.c (183446) mmc.c (183447)
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/mmc.c 183446 2008-09-28 22:27:29Z imp $");
54__FBSDID("$FreeBSD: head/sys/dev/mmc/mmc.c 183447 2008-09-28 22:40:11Z imp $");
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/kernel.h>
59#include <sys/malloc.h>
60#include <sys/lock.h>
61#include <sys/module.h>
62#include <sys/mutex.h>

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

81 */
82struct mmc_ivars {
83 uint32_t raw_cid[4]; /* Raw bits of the CID */
84 uint32_t raw_csd[4]; /* Raw bits of the CSD */
85 uint16_t rca;
86 enum mmc_card_mode mode;
87 struct mmc_cid cid; /* cid decoded */
88 struct mmc_csd csd; /* csd decoded */
55
56#include <sys/param.h>
57#include <sys/systm.h>
58#include <sys/kernel.h>
59#include <sys/malloc.h>
60#include <sys/lock.h>
61#include <sys/module.h>
62#include <sys/mutex.h>

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

81 */
82struct mmc_ivars {
83 uint32_t raw_cid[4]; /* Raw bits of the CID */
84 uint32_t raw_csd[4]; /* Raw bits of the CSD */
85 uint16_t rca;
86 enum mmc_card_mode mode;
87 struct mmc_cid cid; /* cid decoded */
88 struct mmc_csd csd; /* csd decoded */
89 u_char read_only; /* True when the device is read-only */
89};
90
91#define CMD_RETRIES 3
92
93/* bus entry points */
94static int mmc_probe(device_t dev);
95static int mmc_attach(device_t dev);
96static int mmc_detach(device_t dev);

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

608 printf("Error reading CID %d\n", err);
609 break;
610 }
611 if (mmcbr_get_mode(sc->dev) == mode_sd) {
612 ivar->mode = mode_sd;
613 mmc_decode_cid(1, ivar->raw_cid, &ivar->cid);
614 mmc_send_relative_addr(sc, &resp);
615 ivar->rca = resp >> 16;
90};
91
92#define CMD_RETRIES 3
93
94/* bus entry points */
95static int mmc_probe(device_t dev);
96static int mmc_attach(device_t dev);
97static int mmc_detach(device_t dev);

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

609 printf("Error reading CID %d\n", err);
610 break;
611 }
612 if (mmcbr_get_mode(sc->dev) == mode_sd) {
613 ivar->mode = mode_sd;
614 mmc_decode_cid(1, ivar->raw_cid, &ivar->cid);
615 mmc_send_relative_addr(sc, &resp);
616 ivar->rca = resp >> 16;
616 // RO check
617 if (mmcbr_get_ro(sc->dev))
618 ivar->read_only = 1;
617 mmc_send_csd(sc, ivar->rca, ivar->raw_csd);
618 mmc_decode_csd(1, ivar->raw_csd, &ivar->csd);
619 printf("SD CARD: %lld bytes\n", (long long)
620 ivar->csd.capacity);
621 child = device_add_child(sc->dev, NULL, -1);
622 device_set_ivars(child, ivar);
623 return;
624 }

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

733 *(int *)result = ivar->rca;
734 break;
735 case MMC_IVAR_SECTOR_SIZE:
736 *(int *)result = 512;
737 break;
738 case MMC_IVAR_TRAN_SPEED:
739 *(int *)result = ivar->csd.tran_speed;
740 break;
619 mmc_send_csd(sc, ivar->rca, ivar->raw_csd);
620 mmc_decode_csd(1, ivar->raw_csd, &ivar->csd);
621 printf("SD CARD: %lld bytes\n", (long long)
622 ivar->csd.capacity);
623 child = device_add_child(sc->dev, NULL, -1);
624 device_set_ivars(child, ivar);
625 return;
626 }

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

735 *(int *)result = ivar->rca;
736 break;
737 case MMC_IVAR_SECTOR_SIZE:
738 *(int *)result = 512;
739 break;
740 case MMC_IVAR_TRAN_SPEED:
741 *(int *)result = ivar->csd.tran_speed;
742 break;
743 case MMC_IVAR_READ_ONLY:
744 *(int *)result = ivar->read_only;
745 break;
741 }
742 return (0);
743}
744
745static int
746mmc_write_ivar(device_t bus, device_t child, int which, uintptr_t value)
747{
748 // None are writable ATM

--- 45 unchanged lines hidden ---
746 }
747 return (0);
748}
749
750static int
751mmc_write_ivar(device_t bus, device_t child, int which, uintptr_t value)
752{
753 // None are writable ATM

--- 45 unchanged lines hidden ---