mvsdio.c (6d91439ae2d31c45706802e0a0716e25f9f97563) mvsdio.c (17da678368fac22375f0854c811034e311be23b5)
1/*
2 * Marvell MMC/SD/SDIO driver
3 *
4 * Authors: Maen Suleiman, Nicolas Pitre
5 * Copyright (C) 2008-2009 Marvell Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

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

15#include <linux/platform_device.h>
16#include <linux/mbus.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/dma-mapping.h>
20#include <linux/scatterlist.h>
21#include <linux/irq.h>
22#include <linux/clk.h>
1/*
2 * Marvell MMC/SD/SDIO driver
3 *
4 * Authors: Maen Suleiman, Nicolas Pitre
5 * Copyright (C) 2008-2009 Marvell Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

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

15#include <linux/platform_device.h>
16#include <linux/mbus.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/dma-mapping.h>
20#include <linux/scatterlist.h>
21#include <linux/irq.h>
22#include <linux/clk.h>
23#include <linux/gpio.h>
24#include <linux/of_gpio.h>
25#include <linux/of_irq.h>
26#include <linux/mmc/host.h>
27#include <linux/mmc/slot-gpio.h>
28
29#include <asm/sizes.h>
30#include <asm/unaligned.h>
31
32#include "mvsdio.h"
33
34#define DRIVER_NAME "mvsdio"
35
36static int maxfreq;
37static int nodma;
38
23#include <linux/of_irq.h>
24#include <linux/mmc/host.h>
25#include <linux/mmc/slot-gpio.h>
26
27#include <asm/sizes.h>
28#include <asm/unaligned.h>
29
30#include "mvsdio.h"
31
32#define DRIVER_NAME "mvsdio"
33
34static int maxfreq;
35static int nodma;
36
39struct mvsdio_platform_data {
40 unsigned int clock;
41 int gpio_card_detect;
42 int gpio_write_protect;
43};
44
45struct mvsd_host {
46 void __iomem *base;
47 struct mmc_request *mrq;
48 spinlock_t lock;
49 unsigned int xfer_mode;
50 unsigned int intr_en;
51 unsigned int ctrl;
52 unsigned int pio_size;

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

704{
705 struct device_node *np = pdev->dev.of_node;
706 struct mmc_host *mmc = NULL;
707 struct mvsd_host *host = NULL;
708 const struct mbus_dram_target_info *dram;
709 struct resource *r;
710 int ret, irq;
711
37struct mvsd_host {
38 void __iomem *base;
39 struct mmc_request *mrq;
40 spinlock_t lock;
41 unsigned int xfer_mode;
42 unsigned int intr_en;
43 unsigned int ctrl;
44 unsigned int pio_size;

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

696{
697 struct device_node *np = pdev->dev.of_node;
698 struct mmc_host *mmc = NULL;
699 struct mvsd_host *host = NULL;
700 const struct mbus_dram_target_info *dram;
701 struct resource *r;
702 int ret, irq;
703
704 if (!np) {
705 dev_err(&pdev->dev, "no DT node\n");
706 return -ENODEV;
707 }
712 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
713 irq = platform_get_irq(pdev, 0);
714 if (!r || irq < 0)
715 return -ENXIO;
716
717 mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev);
718 if (!mmc) {
719 ret = -ENOMEM;

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

727 /*
728 * Some non-DT platforms do not pass a clock, and the clock
729 * frequency is passed through platform_data. On DT platforms,
730 * a clock must always be passed, even if there is no gatable
731 * clock associated to the SDIO interface (it can simply be a
732 * fixed rate clock).
733 */
734 host->clk = devm_clk_get(&pdev->dev, NULL);
708 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
709 irq = platform_get_irq(pdev, 0);
710 if (!r || irq < 0)
711 return -ENXIO;
712
713 mmc = mmc_alloc_host(sizeof(struct mvsd_host), &pdev->dev);
714 if (!mmc) {
715 ret = -ENOMEM;

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

723 /*
724 * Some non-DT platforms do not pass a clock, and the clock
725 * frequency is passed through platform_data. On DT platforms,
726 * a clock must always be passed, even if there is no gatable
727 * clock associated to the SDIO interface (it can simply be a
728 * fixed rate clock).
729 */
730 host->clk = devm_clk_get(&pdev->dev, NULL);
735 if (!IS_ERR(host->clk))
736 clk_prepare_enable(host->clk);
731 if (IS_ERR(host->clk)) {
732 dev_err(&pdev->dev, "no clock associated\n");
733 ret = -EINVAL;
734 goto out;
735 }
736 clk_prepare_enable(host->clk);
737
738 mmc->ops = &mvsd_ops;
739
740 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
741
742 mmc->f_min = DIV_ROUND_UP(host->base_clock, MVSD_BASE_DIV_MAX);
743 mmc->f_max = MVSD_CLOCKRATE_MAX;
744
745 mmc->max_blk_size = 2048;
746 mmc->max_blk_count = 65535;
747
748 mmc->max_segs = 1;
749 mmc->max_seg_size = mmc->max_blk_size * mmc->max_blk_count;
750 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
751
737
738 mmc->ops = &mvsd_ops;
739
740 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
741
742 mmc->f_min = DIV_ROUND_UP(host->base_clock, MVSD_BASE_DIV_MAX);
743 mmc->f_max = MVSD_CLOCKRATE_MAX;
744
745 mmc->max_blk_size = 2048;
746 mmc->max_blk_count = 65535;
747
748 mmc->max_segs = 1;
749 mmc->max_seg_size = mmc->max_blk_size * mmc->max_blk_count;
750 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
751
752 if (np) {
753 if (IS_ERR(host->clk)) {
754 dev_err(&pdev->dev, "DT platforms must have a clock associated\n");
755 ret = -EINVAL;
756 goto out;
757 }
758
759 host->base_clock = clk_get_rate(host->clk) / 2;
760 ret = mmc_of_parse(mmc);
761 if (ret < 0)
762 goto out;
763 } else {
764 const struct mvsdio_platform_data *mvsd_data;
765
766 mvsd_data = pdev->dev.platform_data;
767 if (!mvsd_data) {
768 ret = -ENXIO;
769 goto out;
770 }
771 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |
772 MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
773 host->base_clock = mvsd_data->clock / 2;
774 /* GPIO 0 regarded as invalid for backward compatibility */
775 if (mvsd_data->gpio_card_detect &&
776 gpio_is_valid(mvsd_data->gpio_card_detect)) {
777 ret = mmc_gpio_request_cd(mmc,
778 mvsd_data->gpio_card_detect,
779 0);
780 if (ret)
781 goto out;
782 } else {
783 mmc->caps |= MMC_CAP_NEEDS_POLL;
784 }
785
786 if (mvsd_data->gpio_write_protect &&
787 gpio_is_valid(mvsd_data->gpio_write_protect))
788 mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect);
789 }
790
752 host->base_clock = clk_get_rate(host->clk) / 2;
753 ret = mmc_of_parse(mmc);
754 if (ret < 0)
755 goto out;
791 if (maxfreq)
792 mmc->f_max = maxfreq;
793
794 spin_lock_init(&host->lock);
795
796 host->base = devm_ioremap_resource(&pdev->dev, r);
797 if (IS_ERR(host->base)) {
798 ret = PTR_ERR(host->base);

--- 83 unchanged lines hidden ---
756 if (maxfreq)
757 mmc->f_max = maxfreq;
758
759 spin_lock_init(&host->lock);
760
761 host->base = devm_ioremap_resource(&pdev->dev, r);
762 if (IS_ERR(host->base)) {
763 ret = PTR_ERR(host->base);

--- 83 unchanged lines hidden ---