desperately trying to sync up sdhc.c

This commit is contained in:
bushing 2009-05-05 21:32:37 -07:00
parent 81cef8b120
commit a137980ac1
2 changed files with 0 additions and 152 deletions

54
sdhc.c
View File

@ -1,5 +1,3 @@
/* $OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $ */
/*
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
* Copyright (c) 2009 Sven Peter <svenpeter@gmail.com>
@ -22,16 +20,6 @@
* Simplified Specification Version 1.00 (www.sdcard.com).
*/
#if 0
#include <sys/param.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#endif
#include "bsdtypes.h"
#include "sdhcreg.h"
#include "sdhcvar.h"
@ -107,18 +95,6 @@ static inline void bus_space_write_1(bus_space_handle_t ioh, u32 r, u8 v)
mask32(addr & ~3, mask, v << shift);
}
u32 splbio(void)
{
// irq_disable(IRQ_SDHC);
return 0;
}
void splx(u32 dummy)
{
(void)dummy;
// irq_enable(IRQ_SDHC);
}
/* flag values */
#define SHF_USE_DMA 0x0001
@ -186,12 +162,6 @@ struct sdmmc_chip_functions sdhc_functions = {
sdhc_card_intr_ack
};
#if 0
struct cfdriver sdhc_cd = {
NULL, "sdhc", DV_DULL
};
#endif
/*
* Called by attachment driver. For each SD card slot there is one SD
* host controller standard register set. (1.3)
@ -388,9 +358,6 @@ sdhc_host_reset(sdmmc_chipset_handle_t sch)
struct sdhc_host *hp = sch;
u_int16_t imask;
int error;
int s;
s = splsdmmc();
/* Disable all interrupts. */
HWRITE2(hp, SDHC_NINTR_SIGNAL_EN, 0);
@ -400,7 +367,6 @@ sdhc_host_reset(sdmmc_chipset_handle_t sch)
* the controller to clear the reset bit.
*/
if ((error = sdhc_soft_reset(hp, SDHC_RESET_ALL)) != 0) {
splx(s);
return (error);
}
@ -418,7 +384,6 @@ sdhc_host_reset(sdmmc_chipset_handle_t sch)
HWRITE2(hp, SDHC_NINTR_SIGNAL_EN, imask);
HWRITE2(hp, SDHC_EINTR_SIGNAL_EN, SDHC_EINTR_SIGNAL_MASK);
splx(s);
return 0;
}
@ -456,9 +421,6 @@ sdhc_bus_power(sdmmc_chipset_handle_t sch, u_int32_t ocr)
{
struct sdhc_host *hp = sch;
u_int8_t vdd;
int s;
s = splsdmmc();
/*
* Disable bus power before voltage change.
@ -468,7 +430,6 @@ sdhc_bus_power(sdmmc_chipset_handle_t sch, u_int32_t ocr)
/* If power is disabled, reset the host and return now. */
if (ocr == 0) {
splx(s);
(void)sdhc_host_reset(hp);
return 0;
}
@ -485,7 +446,6 @@ sdhc_bus_power(sdmmc_chipset_handle_t sch, u_int32_t ocr)
vdd = SDHC_VOLTAGE_1_8V;
else {
/* Unsupported voltage level requested. */
splx(s);
return EINVAL;
}
@ -503,11 +463,9 @@ sdhc_bus_power(sdmmc_chipset_handle_t sch, u_int32_t ocr)
* bus power bit.
*/
if (!ISSET(HREAD1(hp, SDHC_POWER_CTL), SDHC_BUS_POWER)) {
splx(s);
return ENXIO;
}
splx(s);
return 0;
}
@ -535,13 +493,10 @@ int
sdhc_bus_clock(sdmmc_chipset_handle_t sch, int freq)
{
struct sdhc_host *hp = sch;
int s;
int div;
int timo;
int error = 0;
s = splsdmmc();
#ifdef DIAGNOSTIC
/* Must not stop the clock if commands are in progress. */
if (ISSET(HREAD4(hp, SDHC_PRESENT_STATE), SDHC_CMD_INHIBIT_MASK) &&
@ -586,7 +541,6 @@ sdhc_bus_clock(sdmmc_chipset_handle_t sch, int freq)
HSET2(hp, SDHC_CLOCK_CTL, SDHC_SDCLK_ENABLE);
ret:
splx(s);
return error;
}
@ -695,7 +649,6 @@ sdhc_start_command(struct sdhc_host *hp, struct sdmmc_command *cmd)
u_int16_t mode;
u_int16_t command;
int error;
int s;
DPRINTF(1,("%s: start cmd %u arg=%#x data=%p dlen=%d flags=%#x "
"proc=\"%s\"\n", HDEVNAME(hp), cmd->c_opcode, cmd->c_arg,
@ -765,8 +718,6 @@ sdhc_start_command(struct sdhc_host *hp, struct sdmmc_command *cmd)
if ((error = sdhc_wait_state(hp, SDHC_CMD_INHIBIT_MASK, 0)) != 0)
return error;
s = splsdmmc();
/* Alert the user not to remove the card. */
HSET1(hp, SDHC_HOST_CTL, SDHC_LED_ON);
@ -798,7 +749,6 @@ sdhc_start_command(struct sdhc_host *hp, struct sdmmc_command *cmd)
// HWRITE2(hp, SDHC_COMMAND, command);
// HWRITE2(hp, SDHC_TRANSFER_MODE, mode);
splx(s);
return 0;
}
@ -967,14 +917,11 @@ int
sdhc_wait_intr(struct sdhc_host *hp, int mask, int timo)
{
int status;
int s;
mask |= SDHC_ERROR_INTERRUPT;
s = splsdmmc();
status = hp->intr_status & mask;
for (timo = 500; timo > 0; timo--) {
if (hp->intr_status != 0) {
status = hp->intr_status & mask;
@ -997,7 +944,6 @@ sdhc_wait_intr(struct sdhc_host *hp, int mask, int timo)
status = 0;
}
splx(s);
return status;
}

View File

@ -20,17 +20,6 @@
#ifndef _SDMMCVAR_H_
#define _SDMMCVAR_H_
#if 0
#include <sys/queue.h>
#include <sys/lock.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <dev/sdmmc/sdmmcchip.h>
#include <dev/sdmmc/sdmmcreg.h>
#endif
struct sdmmc_csd {
int csdver; /* CSD structure format */
int mmcver; /* MMC version (for CID format) */
@ -58,9 +47,6 @@ struct sdmmc_task {
void *arg;
int onqueue;
struct sdmmc_softc *sc;
#if 0
TAILQ_ENTRY(sdmmc_task) next;
#endif
};
#define sdmmc_init_task(xtask, xfunc, xarg) do { \
@ -142,9 +128,6 @@ struct sdmmc_function {
int flags;
#define SFF_ERROR 0x0001 /* function is poo; ignore it */
#define SFF_SDHC 0x0002 /* SD High Capacity card */
#if 0
SIMPLEQ_ENTRY(sdmmc_function) sf_list;
#endif
/* SD card I/O function members */
int number; /* I/O function number or -1 */
struct device *child; /* function driver */
@ -173,23 +156,11 @@ struct sdmmc_softc {
int sc_function_count; /* number of I/O functions (SDIO) */
struct sdmmc_function *sc_card; /* selected card */
struct sdmmc_function *sc_fn0; /* function 0, the card itself */
#if 0
SIMPLEQ_HEAD(, sdmmc_function) sf_head; /* list of card functions */
#endif
int sc_dying; /* bus driver is shutting down */
struct proc *sc_task_thread; /* asynchronous tasks */
#if 0
TAILQ_HEAD(, sdmmc_task) sc_tskq; /* task thread work queue */
#endif
struct sdmmc_task sc_discover_task; /* card attach/detach task */
struct sdmmc_task sc_intr_task; /* card interrupt task */
#if 0
struct lock sc_lock; /* lock around host controller */
#endif
void *sc_scsibus; /* SCSI bus emulation softc */
#if 0
TAILQ_HEAD(, sdmmc_intr_handler) sc_intrq; /* interrupt handlers */
#endif
long sc_max_xfer; /* maximum transfer size */
};
@ -202,79 +173,10 @@ struct sdmmc_attach_args {
};
#define IPL_SDMMC IPL_BIO
#define splsdmmc() splbio()
#define SDMMC_LOCK(sc) lockmgr(&(sc)->sc_lock, LK_EXCLUSIVE, NULL)
#define SDMMC_UNLOCK(sc) lockmgr(&(sc)->sc_lock, LK_RELEASE, NULL)
#define SDMMC_ASSERT_LOCKED(sc) \
KASSERT(lockstatus(&((sc))->sc_lock) == LK_EXCLUSIVE)
#if 0
void sdmmc_add_task(struct sdmmc_softc *, struct sdmmc_task *);
void sdmmc_del_task(struct sdmmc_task *);
struct sdmmc_function *sdmmc_function_alloc(struct sdmmc_softc *);
void sdmmc_function_free(struct sdmmc_function *);
int sdmmc_set_bus_power(struct sdmmc_softc *, u_int32_t, u_int32_t);
int sdmmc_mmc_command(struct sdmmc_softc *, struct sdmmc_command *);
int sdmmc_app_command(struct sdmmc_softc *, struct sdmmc_command *);
void sdmmc_go_idle_state(struct sdmmc_softc *);
int sdmmc_select_card(struct sdmmc_softc *, struct sdmmc_function *);
int sdmmc_set_relative_addr(struct sdmmc_softc *,
struct sdmmc_function *);
int sdmmc_send_if_cond(struct sdmmc_softc *, uint32_t);
void sdmmc_intr_enable(struct sdmmc_function *);
void sdmmc_intr_disable(struct sdmmc_function *);
void *sdmmc_intr_establish(struct device *, int (*)(void *),
void *, const char *);
void sdmmc_intr_disestablish(void *);
void sdmmc_intr_task(void *);
int sdmmc_io_enable(struct sdmmc_softc *);
void sdmmc_io_scan(struct sdmmc_softc *);
int sdmmc_io_init(struct sdmmc_softc *, struct sdmmc_function *);
void sdmmc_io_attach(struct sdmmc_softc *);
void sdmmc_io_detach(struct sdmmc_softc *);
u_int8_t sdmmc_io_read_1(struct sdmmc_function *, int);
u_int16_t sdmmc_io_read_2(struct sdmmc_function *, int);
u_int32_t sdmmc_io_read_4(struct sdmmc_function *, int);
int sdmmc_io_read_multi_1(struct sdmmc_function *, int, u_char *, int);
void sdmmc_io_write_1(struct sdmmc_function *, int, u_int8_t);
void sdmmc_io_write_2(struct sdmmc_function *, int, u_int16_t);
void sdmmc_io_write_4(struct sdmmc_function *, int, u_int32_t);
int sdmmc_io_write_multi_1(struct sdmmc_function *, int, u_char *, int);
int sdmmc_io_function_ready(struct sdmmc_function *);
int sdmmc_io_function_enable(struct sdmmc_function *);
void sdmmc_io_function_disable(struct sdmmc_function *);
int sdmmc_read_cis(struct sdmmc_function *, struct sdmmc_cis *);
void sdmmc_print_cis(struct sdmmc_function *);
void sdmmc_check_cis_quirks(struct sdmmc_function *);
int sdmmc_mem_enable(struct sdmmc_softc *);
void sdmmc_mem_scan(struct sdmmc_softc *);
int sdmmc_mem_init(struct sdmmc_softc *, struct sdmmc_function *);
int sdmmc_mem_read_block(struct sdmmc_function *, int, u_char *, size_t);
int sdmmc_mem_write_block(struct sdmmc_function *, int, u_char *, size_t);
/* ioctls */
#include <sys/ioccom.h>
struct bio_sdmmc_command {
void *cookie;
struct sdmmc_command cmd;
};
struct bio_sdmmc_debug {
void *cookie;
int debug;
};
#define SDIOCEXECMMC _IOWR('S',0, struct bio_sdmmc_command)
#define SDIOCEXECAPP _IOWR('S',1, struct bio_sdmmc_command)
#define SDIOCSETDEBUG _IOWR('S',2, struct bio_sdmmc_debug)
#endif
#endif