sd.c (ebf8889bd1fe3615991ff4494635d237280652a2) sd.c (51ec92e295d563dd5712d198a7e46c2ae5ccccb2)
1/*
2 * linux/drivers/mmc/core/sd.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify

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

13#include <linux/err.h>
14
15#include <linux/mmc/host.h>
16#include <linux/mmc/card.h>
17#include <linux/mmc/mmc.h>
18#include <linux/mmc/sd.h>
19
20#include "core.h"
1/*
2 * linux/drivers/mmc/core/sd.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify

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

13#include <linux/err.h>
14
15#include <linux/mmc/host.h>
16#include <linux/mmc/card.h>
17#include <linux/mmc/mmc.h>
18#include <linux/mmc/sd.h>
19
20#include "core.h"
21#include "sysfs.h"
22#include "bus.h"
23#include "mmc_ops.h"
24#include "sd_ops.h"
25
26static const unsigned int tran_exp[] = {
27 10000, 100000, 1000000, 10000000,
28 0, 0, 0, 0
29};

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

278 }
279
280out:
281 kfree(status);
282
283 return err;
284}
285
21#include "bus.h"
22#include "mmc_ops.h"
23#include "sd_ops.h"
24
25static const unsigned int tran_exp[] = {
26 10000, 100000, 1000000, 10000000,
27 0, 0, 0, 0
28};

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

277 }
278
279out:
280 kfree(status);
281
282 return err;
283}
284
285MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
286 card->raw_cid[2], card->raw_cid[3]);
287MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
288 card->raw_csd[2], card->raw_csd[3]);
289MMC_DEV_ATTR(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
290MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
291MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev);
292MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
293MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
294MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
295MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
296MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
297
298
299static struct attribute *sd_std_attrs[] = {
300 &dev_attr_cid.attr,
301 &dev_attr_csd.attr,
302 &dev_attr_scr.attr,
303 &dev_attr_date.attr,
304 &dev_attr_fwrev.attr,
305 &dev_attr_hwrev.attr,
306 &dev_attr_manfid.attr,
307 &dev_attr_name.attr,
308 &dev_attr_oemid.attr,
309 &dev_attr_serial.attr,
310 NULL,
311};
312
313static struct attribute_group sd_std_attr_group = {
314 .attrs = sd_std_attrs,
315};
316
317static struct attribute_group *sd_attr_groups[] = {
318 &sd_std_attr_group,
319 NULL,
320};
321
322static struct device_type sd_type = {
323 .groups = sd_attr_groups,
324};
325
286/*
287 * Handle the detection and initialisation of a card.
288 *
289 * In the case of a resume, "curcard" will contain the card
290 * we're trying to reinitialise.
291 */
292static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
293 struct mmc_card *oldcard)

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

347 goto err;
348 }
349
350 card = oldcard;
351 } else {
352 /*
353 * Allocate card structure.
354 */
326/*
327 * Handle the detection and initialisation of a card.
328 *
329 * In the case of a resume, "curcard" will contain the card
330 * we're trying to reinitialise.
331 */
332static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
333 struct mmc_card *oldcard)

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

387 goto err;
388 }
389
390 card = oldcard;
391 } else {
392 /*
393 * Allocate card structure.
394 */
355 card = mmc_alloc_card(host);
395 card = mmc_alloc_card(host, &sd_type);
356 if (IS_ERR(card)) {
357 err = PTR_ERR(card);
358 goto err;
359 }
360
361 card->type = MMC_TYPE_SD;
362 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
363 }

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

513 mmc_sd_remove(host);
514
515 mmc_claim_host(host);
516 mmc_detach_bus(host);
517 mmc_release_host(host);
518 }
519}
520
396 if (IS_ERR(card)) {
397 err = PTR_ERR(card);
398 goto err;
399 }
400
401 card->type = MMC_TYPE_SD;
402 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
403 }

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

553 mmc_sd_remove(host);
554
555 mmc_claim_host(host);
556 mmc_detach_bus(host);
557 mmc_release_host(host);
558 }
559}
560
521MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
522 card->raw_cid[2], card->raw_cid[3]);
523MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
524 card->raw_csd[2], card->raw_csd[3]);
525MMC_ATTR_FN(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
526MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year);
527MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev);
528MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev);
529MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid);
530MMC_ATTR_FN(name, "%s\n", card->cid.prod_name);
531MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid);
532MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial);
533
534static struct device_attribute mmc_sd_dev_attrs[] = {
535 MMC_ATTR_RO(cid),
536 MMC_ATTR_RO(csd),
537 MMC_ATTR_RO(scr),
538 MMC_ATTR_RO(date),
539 MMC_ATTR_RO(fwrev),
540 MMC_ATTR_RO(hwrev),
541 MMC_ATTR_RO(manfid),
542 MMC_ATTR_RO(name),
543 MMC_ATTR_RO(oemid),
544 MMC_ATTR_RO(serial),
545 __ATTR_NULL,
546};
547
548/*
549 * Adds sysfs entries as relevant.
550 */
551static int mmc_sd_sysfs_add(struct mmc_host *host, struct mmc_card *card)
552{
553 int ret;
554
555 ret = mmc_add_attrs(card, mmc_sd_dev_attrs);
556 if (ret < 0)
557 return ret;
558
559 return 0;
560}
561
562/*
563 * Removes the sysfs entries added by mmc_sysfs_add().
564 */
565static void mmc_sd_sysfs_remove(struct mmc_host *host, struct mmc_card *card)
566{
567 mmc_remove_attrs(card, mmc_sd_dev_attrs);
568}
569
570#ifdef CONFIG_MMC_UNSAFE_RESUME
571
572/*
573 * Suspend callback from host.
574 */
575static void mmc_sd_suspend(struct mmc_host *host)
576{
577 BUG_ON(!host);

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

616#define mmc_sd_suspend NULL
617#define mmc_sd_resume NULL
618
619#endif
620
621static const struct mmc_bus_ops mmc_sd_ops = {
622 .remove = mmc_sd_remove,
623 .detect = mmc_sd_detect,
561#ifdef CONFIG_MMC_UNSAFE_RESUME
562
563/*
564 * Suspend callback from host.
565 */
566static void mmc_sd_suspend(struct mmc_host *host)
567{
568 BUG_ON(!host);

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

607#define mmc_sd_suspend NULL
608#define mmc_sd_resume NULL
609
610#endif
611
612static const struct mmc_bus_ops mmc_sd_ops = {
613 .remove = mmc_sd_remove,
614 .detect = mmc_sd_detect,
624 .sysfs_add = mmc_sd_sysfs_add,
625 .sysfs_remove = mmc_sd_sysfs_remove,
626 .suspend = mmc_sd_suspend,
627 .resume = mmc_sd_resume,
628};
629
630/*
631 * Starting point for SD card init.
632 */
633int mmc_attach_sd(struct mmc_host *host, u32 ocr)

--- 76 unchanged lines hidden ---
615 .suspend = mmc_sd_suspend,
616 .resume = mmc_sd_resume,
617};
618
619/*
620 * Starting point for SD card init.
621 */
622int mmc_attach_sd(struct mmc_host *host, u32 ocr)

--- 76 unchanged lines hidden ---