Path: blob/master/drivers/mmc/host/sdhci-of-esdhc.c
15111 views
/*1* Freescale eSDHC controller driver.2*3* Copyright (c) 2007 Freescale Semiconductor, Inc.4* Copyright (c) 2009 MontaVista Software, Inc.5*6* Authors: Xiaobo Xie <[email protected]>7* Anton Vorontsov <[email protected]>8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License as published by11* the Free Software Foundation; either version 2 of the License, or (at12* your option) any later version.13*/1415#include <linux/io.h>16#include <linux/delay.h>17#include <linux/mmc/host.h>18#include "sdhci-of.h"19#include "sdhci.h"20#include "sdhci-esdhc.h"2122static u16 esdhc_readw(struct sdhci_host *host, int reg)23{24u16 ret;2526if (unlikely(reg == SDHCI_HOST_VERSION))27ret = in_be16(host->ioaddr + reg);28else29ret = sdhci_be32bs_readw(host, reg);30return ret;31}3233static void esdhc_writew(struct sdhci_host *host, u16 val, int reg)34{35if (reg == SDHCI_BLOCK_SIZE) {36/*37* Two last DMA bits are reserved, and first one is used for38* non-standard blksz of 4096 bytes that we don't support39* yet. So clear the DMA boundary bits.40*/41val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);42}43sdhci_be32bs_writew(host, val, reg);44}4546static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg)47{48/* Prevent SDHCI core from writing reserved bits (e.g. HISPD). */49if (reg == SDHCI_HOST_CONTROL)50val &= ~ESDHC_HOST_CONTROL_RES;51sdhci_be32bs_writeb(host, val, reg);52}5354static int esdhc_of_enable_dma(struct sdhci_host *host)55{56setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP);57return 0;58}5960static unsigned int esdhc_of_get_max_clock(struct sdhci_host *host)61{62struct sdhci_of_host *of_host = sdhci_priv(host);6364return of_host->clock;65}6667static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host)68{69struct sdhci_of_host *of_host = sdhci_priv(host);7071return of_host->clock / 256 / 16;72}7374struct sdhci_of_data sdhci_esdhc = {75/* card detection could be handled via GPIO */76.quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_BROKEN_CARD_DETECTION77| SDHCI_QUIRK_NO_CARD_NO_RESET,78.ops = {79.read_l = sdhci_be32bs_readl,80.read_w = esdhc_readw,81.read_b = sdhci_be32bs_readb,82.write_l = sdhci_be32bs_writel,83.write_w = esdhc_writew,84.write_b = esdhc_writeb,85.set_clock = esdhc_set_clock,86.enable_dma = esdhc_of_enable_dma,87.get_max_clock = esdhc_of_get_max_clock,88.get_min_clock = esdhc_of_get_min_clock,89},90};919293