1241600Sgonzo#-
2241600Sgonzo# Copyright (c) 2006 M. Warner Losh
3241600Sgonzo# All rights reserved.
4241600Sgonzo#
5241600Sgonzo# Redistribution and use in source and binary forms, with or without
6241600Sgonzo# modification, are permitted provided that the following conditions
7241600Sgonzo# are met:
8241600Sgonzo# 1. Redistributions of source code must retain the above copyright
9241600Sgonzo#    notice, this list of conditions and the following disclaimer.
10241600Sgonzo# 2. Redistributions in binary form must reproduce the above copyright
11241600Sgonzo#    notice, this list of conditions and the following disclaimer in the
12241600Sgonzo#    documentation and/or other materials provided with the distribution.
13241600Sgonzo#
14241600Sgonzo# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15241600Sgonzo# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16241600Sgonzo# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17241600Sgonzo# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18241600Sgonzo# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19241600Sgonzo# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20241600Sgonzo# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21241600Sgonzo# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22241600Sgonzo# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23241600Sgonzo# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24241600Sgonzo# SUCH DAMAGE.
25241600Sgonzo#
26241600Sgonzo# Portions of this software may have been developed with reference to
27241600Sgonzo# the SD Simplified Specification.  The following disclaimer may apply:
28241600Sgonzo#
29241600Sgonzo# The following conditions apply to the release of the simplified
30241600Sgonzo# specification ("Simplified Specification") by the SD Card Association and
31241600Sgonzo# the SD Group. The Simplified Specification is a subset of the complete SD
32241600Sgonzo# Specification which is owned by the SD Card Association and the SD
33241600Sgonzo# Group. This Simplified Specification is provided on a non-confidential
34241600Sgonzo# basis subject to the disclaimers below. Any implementation of the
35241600Sgonzo# Simplified Specification may require a license from the SD Card
36241600Sgonzo# Association, SD Group, SD-3C LLC or other third parties.
37241600Sgonzo#
38241600Sgonzo# Disclaimers:
39241600Sgonzo#
40241600Sgonzo# The information contained in the Simplified Specification is presented only
41241600Sgonzo# as a standard specification for SD Cards and SD Host/Ancillary products and
42241600Sgonzo# is provided "AS-IS" without any representations or warranties of any
43241600Sgonzo# kind. No responsibility is assumed by the SD Group, SD-3C LLC or the SD
44241600Sgonzo# Card Association for any damages, any infringements of patents or other
45241600Sgonzo# right of the SD Group, SD-3C LLC, the SD Card Association or any third
46241600Sgonzo# parties, which may result from its use. No license is granted by
47241600Sgonzo# implication, estoppel or otherwise under any patent or other rights of the
48241600Sgonzo# SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
49241600Sgonzo# herein shall be construed as an obligation by the SD Group, the SD-3C LLC
50241600Sgonzo# or the SD Card Association to disclose or distribute any technical
51241600Sgonzo# information, know-how or other confidential information to any third party.
52241600Sgonzo#
53241600Sgonzo# $FreeBSD: releng/10.2/sys/dev/sdhci/sdhci_if.m 271051 2014-09-03 20:07:26Z marius $
54241600Sgonzo#
55241600Sgonzo
56241600Sgonzo#
57241600Sgonzo# This is the set of callbacks that mmc bridges call into the bus, or
58241600Sgonzo# that mmc/sd card drivers call to make requests.
59241600Sgonzo#
60241600Sgonzo
61246886Sgonzo#include <sys/types.h>
62246886Sgonzo#include <sys/systm.h>
63246886Sgonzo#include <sys/lock.h>
64246886Sgonzo#include <sys/mutex.h>
65271051Smarius#include <sys/sysctl.h>
66246886Sgonzo#include <sys/taskqueue.h>
67246886Sgonzo
68241600Sgonzo#include <machine/bus.h>
69246886Sgonzo
70246886Sgonzo#include <dev/mmc/bridge.h>
71246886Sgonzo#include <dev/mmc/mmcreg.h>
72246886Sgonzo#include <dev/sdhci/sdhci.h>
73246886Sgonzo
74241600SgonzoCODE {
75241600Sgonzo	struct sdhci_slot;
76241600Sgonzo}
77241600Sgonzo
78241600SgonzoINTERFACE sdhci;
79241600Sgonzo
80241600SgonzoMETHOD uint8_t read_1 {
81241600Sgonzo	device_t		brdev;
82241600Sgonzo	struct sdhci_slot	*slot;
83241600Sgonzo	bus_size_t		off;
84241600Sgonzo}
85241600Sgonzo
86241600SgonzoMETHOD uint16_t read_2 {
87241600Sgonzo	device_t		brdev;
88241600Sgonzo	struct sdhci_slot	*slot;
89241600Sgonzo	bus_size_t		off;
90241600Sgonzo}
91241600Sgonzo
92241600SgonzoMETHOD uint32_t read_4 {
93241600Sgonzo	device_t		brdev;
94241600Sgonzo	struct sdhci_slot	*slot;
95241600Sgonzo	bus_size_t		off;
96241600Sgonzo}
97241600Sgonzo
98241600SgonzoMETHOD void read_multi_4 {
99241600Sgonzo	device_t		brdev;
100241600Sgonzo	struct sdhci_slot	*slot;
101241600Sgonzo	bus_size_t		off;
102241600Sgonzo	uint32_t		*data;
103241600Sgonzo	bus_size_t		count;
104241600Sgonzo}
105241600Sgonzo
106241600SgonzoMETHOD void write_1 {
107241600Sgonzo	device_t		brdev;
108241600Sgonzo	struct sdhci_slot	*slot;
109241600Sgonzo	bus_size_t		off;
110241600Sgonzo	uint8_t			val;
111241600Sgonzo}
112241600Sgonzo
113241600SgonzoMETHOD void write_2 {
114241600Sgonzo	device_t		brdev;
115241600Sgonzo	struct sdhci_slot	*slot;
116241600Sgonzo	bus_size_t		off;
117241600Sgonzo	uint16_t		val;
118241600Sgonzo}
119241600Sgonzo
120241600SgonzoMETHOD void write_4 {
121241600Sgonzo	device_t		brdev;
122241600Sgonzo	struct sdhci_slot	*slot;
123241600Sgonzo	bus_size_t		off;
124241600Sgonzo	uint32_t		val;
125241600Sgonzo}
126241600Sgonzo
127241600SgonzoMETHOD void write_multi_4 {
128241600Sgonzo	device_t		brdev;
129241600Sgonzo	struct sdhci_slot	*slot;
130241600Sgonzo	bus_size_t		off;
131241600Sgonzo	uint32_t		*data;
132241600Sgonzo	bus_size_t		count;
133241600Sgonzo}
134246886Sgonzo
135247495SgonzoMETHOD int platform_will_handle {
136247495Sgonzo	device_t		brdev;
137247495Sgonzo	struct sdhci_slot	*slot;
138247495Sgonzo}
139247495Sgonzo
140247495SgonzoMETHOD void platform_start_transfer {
141247495Sgonzo	device_t		brdev;
142247495Sgonzo	struct sdhci_slot	*slot;
143247495Sgonzo	uint32_t		*intmask;
144247495Sgonzo}
145247495Sgonzo
146247495SgonzoMETHOD void platform_finish_transfer {
147247495Sgonzo	device_t		brdev;
148247495Sgonzo	struct sdhci_slot	*slot;
149247495Sgonzo}
150247495Sgonzo
151246886SgonzoMETHOD uint32_t min_freq {
152246886Sgonzo	device_t		brdev;
153246886Sgonzo	struct sdhci_slot	*slot;
154246886Sgonzo} DEFAULT sdhci_generic_min_freq;
155