1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Add SDIO support.

Add a CAM-Newbus SDIO support module.  This works provides a newbus
infrastructure for device drivers wanting to use SDIO.  On the lower end
while it is connected by newbus to SDHCI, it talks CAM using the MMCCAM
framework to get to it.

This also duplicates the usbdevs framework to equally create sdiodev
header files with #defines for "vendors" and "products".

Submitted by:	kibab (initial work, see https://reviews.freebsd.org/D12467)
Reviewed by:	kibab, imp (comments on earlier version)
MFC after:	6 weeks
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19749
This commit is contained in:
Bjoern A. Zeeb 2019-06-08 16:26:56 +00:00
parent 9c907eb913
commit 67ca7330cf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348805
11 changed files with 2068 additions and 0 deletions

View File

@ -68,6 +68,16 @@ usbdevs_data.h optional usb \
compile-with "${AWK} -f $S/tools/usbdevs2h.awk $S/dev/usb/usbdevs -d" \
no-obj no-implicit-rule before-depend \
clean "usbdevs_data.h"
sdiodevs.h optional mmccam \
dependency "$S/tools/sdiodevs2h.awk $S/dev/sdio/sdiodevs" \
compile-with "${AWK} -f $S/tools/sdiodevs2h.awk $S/dev/sdio/sdiodevs -h" \
no-obj no-implicit-rule before-depend \
clean "sdiodevs.h"
sdiodevs_data.h optional mmccam \
dependency "$S/tools/sdiodevs2h.awk $S/dev/sdio/sdiodevs" \
compile-with "${AWK} -f $S/tools/sdiodevs2h.awk $S/dev/sdio/sdiodevs -d" \
no-obj no-implicit-rule before-depend \
clean "sdiodevs_data.h"
cam/cam.c optional scbus
cam/cam_compat.c optional scbus
cam/cam_iosched.c optional scbus
@ -3009,6 +3019,9 @@ dev/sdhci/sdhci_fdt_gpio.c optional sdhci fdt gpio
dev/sdhci/sdhci_if.m optional sdhci
dev/sdhci/sdhci_acpi.c optional sdhci acpi
dev/sdhci/sdhci_pci.c optional sdhci pci
+dev/sdio/sdio_if.m optional mmccam
+dev/sdio/sdio_subr.c optional mmccam
+dev/sdio/sdiob.c optional mmccam
dev/sge/if_sge.c optional sge pci
dev/siis/siis.c optional siis pci
dev/sis/if_sis.c optional sis pci

View File

@ -475,6 +475,18 @@ usbdevs_data.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs
${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -d
.endif
.if !empty(SRCS:Msdiodevs.h)
CLEANFILES+= sdiodevs.h
sdiodevs.h: ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs
${AWK} -f ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs -h
.endif
.if !empty(SRCS:Msdiodevs_data.h)
CLEANFILES+= sdiodevs_data.h
sdiodevs_data.h: ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs
${AWK} -f ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs -d
.endif
.if !empty(SRCS:Macpi_quirks.h)
CLEANFILES+= acpi_quirks.h
acpi_quirks.h: ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks

79
sys/dev/sdio/sdio_if.m Normal file
View File

@ -0,0 +1,79 @@
#-
# Copyright (c) 2019 The FreeBSD Foundation
#
# Portions of this software were developed by Björn Zeeb
# under sponsorship from the FreeBSD Foundation.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# $FreeBSD$
#
#include <sys/bus.h>
#include <machine/bus.h>
INTERFACE sdio;
#
# READ DIRECT (1byte)
#
METHOD int read_direct {
device_t dev;
uint8_t fn;
uint32_t addr;
uint8_t *val;
};
#
# WRITE DIRECT (1byte)
#
METHOD int write_direct {
device_t dev;
uint8_t fn;
uint32_t addr;
uint8_t val;
};
#
# READ EXTENDED
#
METHOD int read_extended {
device_t dev;
uint8_t fn;
uint32_t addr;
uint32_t size;
uint8_t *buffer;
bool incaddr;
};
#
# WRITE EXTENDED
#
METHOD int write_extended {
device_t dev;
uint8_t fn;
uint32_t addr;
uint32_t size;
uint8_t *buffer;
bool incaddr;
};
# end

227
sys/dev/sdio/sdio_subr.c Normal file
View File

@ -0,0 +1,227 @@
/*-
* Copyright (c) 2017 Ilya Bakulin. All rights reserved.
* Copyright (c) 2018-2019 The FreeBSD Foundation
*
* Portions of this software were developed by Björn Zeeb
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Portions of this software may have been developed with reference to
* the SD Simplified Specification. The following disclaimer may apply:
*
* The following conditions apply to the release of the simplified
* specification ("Simplified Specification") by the SD Card Association and
* the SD Group. The Simplified Specification is a subset of the complete SD
* Specification which is owned by the SD Card Association and the SD
* Group. This Simplified Specification is provided on a non-confidential
* basis subject to the disclaimers below. Any implementation of the
* Simplified Specification may require a license from the SD Card
* Association, SD Group, SD-3C LLC or other third parties.
*
* Disclaimers:
*
* The information contained in the Simplified Specification is presented only
* as a standard specification for SD Cards and SD Host/Ancillary products and
* is provided "AS-IS" without any representations or warranties of any
* kind. No responsibility is assumed by the SD Group, SD-3C LLC or the SD
* Card Association for any damages, any infringements of patents or other
* right of the SD Group, SD-3C LLC, the SD Card Association or any third
* parties, which may result from its use. No license is granted by
* implication, estoppel or otherwise under any patent or other rights of the
* SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
* herein shall be construed as an obligation by the SD Group, the SD-3C LLC
* or the SD Card Association to disclose or distribute any technical
* information, know-how or other confidential information to any third party.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/endian.h>
#include <dev/mmc/mmcreg.h>
#include <dev/sdio/sdiob.h>
#include <dev/sdio/sdio_subr.h>
#include "sdio_if.h"
/* Works on F0. */
static int
sdio_set_bool_for_func(device_t dev, uint32_t addr, uint8_t fn, bool enable)
{
device_t pdev;
int error;
uint8_t val;
bool enabled;
pdev = device_get_parent(dev);
error = SDIO_READ_DIRECT(pdev, 0, addr, &val);
if (error != 0)
return (error);
enabled = (val & (1 << fn)) ? true : false;
if (enabled == enable)
return (0);
if (enable)
val |= (1 << fn);
else
val &= ~(1 << fn);
error = SDIO_WRITE_DIRECT(pdev, 0, addr, val);
return (error);
}
int
sdio_enable_func(struct sdio_func *f)
{
return (sdio_set_bool_for_func(f->dev, SD_IO_CCCR_FN_ENABLE,
f->fn, true));
}
int
sdio_disable_func(struct sdio_func *f)
{
return (sdio_set_bool_for_func(f->dev, SD_IO_CCCR_FN_ENABLE,
f->fn, false));
}
int
sdio_set_block_size(struct sdio_func *f, uint16_t bs)
{
device_t pdev;
int error;
uint32_t addr;
uint16_t v;
if (!sdio_get_support_multiblk(f->dev))
return (EOPNOTSUPP);
pdev = device_get_parent(f->dev);
addr = SD_IO_FBR_START * f->fn + SD_IO_FBR_IOBLKSZ;
v = htole16(bs);
/* Always write through F0. */
error = SDIO_WRITE_DIRECT(pdev, 0, addr, v & 0xff);
if (error == 0)
error = SDIO_WRITE_DIRECT(pdev, 0, addr + 1,
(v >> 8) & 0xff);
if (error == 0)
f->cur_blksize = bs;
return (error);
}
uint8_t
sdio_readb(struct sdio_func *f, uint32_t addr, int *err)
{
int error;
uint8_t v;
error = SDIO_READ_DIRECT(device_get_parent(f->dev), f->fn, addr, &v);
if (error) {
if (err != NULL)
*err = error;
return (0xff);
} else {
if (err != NULL)
*err = 0;
return (v);
}
}
void
sdio_writeb(struct sdio_func *f, uint8_t val, uint32_t addr, int *err)
{
int error;
error = SDIO_WRITE_DIRECT(device_get_parent(f->dev), f->fn, addr, val);
if (err != NULL)
*err = error;
}
uint32_t
sdio_readl(struct sdio_func *f, uint32_t addr, int *err)
{
int error;
uint32_t v;
error = SDIO_READ_EXTENDED(device_get_parent(f->dev), f->fn, addr,
sizeof(v), (uint8_t *)&v, false);
if (error) {
if (err != NULL)
*err = error;
return (0xffffffff);
} else {
if (err != NULL)
*err = 0;
return (le32toh(v));
}
}
void
sdio_writel(struct sdio_func *f, uint32_t val, uint32_t addr, int *err)
{
int error;
error = SDIO_WRITE_EXTENDED(device_get_parent(f->dev), f->fn, addr,
sizeof(val), (uint8_t *)&val, false);
if (err != NULL)
*err = error;
}
uint8_t
sdio_f0_readb(struct sdio_func *f, uint32_t addr, int *err)
{
int error;
uint8_t v;
error = SDIO_READ_DIRECT(device_get_parent(f->dev), 0, addr, &v);
if (error) {
if (err != NULL)
*err = error;
return (0xff);
} else {
if (err != NULL)
*err = 0;
return (v);
}
}
void
sdio_f0_writeb(struct sdio_func *f, uint8_t val, uint32_t addr, int *err)
{
int error;
error = SDIO_WRITE_DIRECT(device_get_parent(f->dev), 0, addr, val);
if (err != NULL)
*err = error;
}
/* end */

107
sys/dev/sdio/sdio_subr.h Normal file
View File

@ -0,0 +1,107 @@
/*-
* Copyright (c) 2017 Ilya Bakulin. All rights reserved.
* Copyright (c) 2018-2019 The FreeBSD Foundation
*
* Portions of this software were developed by Björn Zeeb
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Portions of this software may have been developed with reference to
* the SD Simplified Specification. The following disclaimer may apply:
*
* The following conditions apply to the release of the simplified
* specification ("Simplified Specification") by the SD Card Association and
* the SD Group. The Simplified Specification is a subset of the complete SD
* Specification which is owned by the SD Card Association and the SD
* Group. This Simplified Specification is provided on a non-confidential
* basis subject to the disclaimers below. Any implementation of the
* Simplified Specification may require a license from the SD Card
* Association, SD Group, SD-3C LLC or other third parties.
*
* Disclaimers:
*
* The information contained in the Simplified Specification is presented only
* as a standard specification for SD Cards and SD Host/Ancillary products and
* is provided "AS-IS" without any representations or warranties of any
* kind. No responsibility is assumed by the SD Group, SD-3C LLC or the SD
* Card Association for any damages, any infringements of patents or other
* right of the SD Group, SD-3C LLC, the SD Card Association or any third
* parties, which may result from its use. No license is granted by
* implication, estoppel or otherwise under any patent or other rights of the
* SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
* herein shall be construed as an obligation by the SD Group, the SD-3C LLC
* or the SD Card Association to disclose or distribute any technical
* information, know-how or other confidential information to any third party.
*
*
* $FreeBSD$
*/
#ifndef _SDIO_SUBR_H_
#define _SDIO_SUBR_H_
/*
* This file contains structures and functions to work with SDIO cards.
*/
struct sdio_func {
device_t dev; /* The device to talk to CAM. */
uintptr_t drvdata; /* Driver specific data. */
uint8_t fn; /* Function number. */
uint8_t class; /* Class of function. */
uint16_t vendor; /* Manufacturer ID. */
uint16_t device; /* Card ID. */
uint16_t max_blksize; /* Maximum block size of function. */
uint16_t cur_blksize; /* Current block size of function. */
uint16_t retries; /* Retires for CAM operations. */
uint32_t timeout; /* Timeout. */
};
struct card_info {
struct sdio_func f[8];
/* Compared to R4 Number of I/O Functions we DO count F0 here. */
uint8_t num_funcs;
bool support_multiblk; /* Support Multiple Block Transfer */
};
#ifdef _KERNEL
int sdio_enable_func(struct sdio_func *);
int sdio_disable_func(struct sdio_func *);
int sdio_set_block_size(struct sdio_func *, uint16_t);
uint8_t sdio_readb(struct sdio_func *, uint32_t, int *);
void sdio_writeb(struct sdio_func *, uint8_t, uint32_t, int *);
uint32_t sdio_readl(struct sdio_func *, uint32_t, int *);
void sdio_writel(struct sdio_func *, uint32_t, uint32_t, int *);
uint8_t sdio_f0_readb(struct sdio_func *, uint32_t, int *);
void sdio_f0_writeb(struct sdio_func *, uint8_t, uint32_t, int *);
#endif /* _KERNEL */
#endif /* _SDIO_SUBR_H_ */

1188
sys/dev/sdio/sdiob.c Normal file

File diff suppressed because it is too large Load Diff

92
sys/dev/sdio/sdiob.h Normal file
View File

@ -0,0 +1,92 @@
/*-
* Copyright (c) 2019 The FreeBSD Foundation
*
* Portions of this software were developed by Björn Zeeb
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Portions of this software may have been developed with reference to
* the SD Simplified Specification. The following disclaimer may apply:
*
* The following conditions apply to the release of the simplified
* specification ("Simplified Specification") by the SD Card Association and
* the SD Group. The Simplified Specification is a subset of the complete SD
* Specification which is owned by the SD Card Association and the SD
* Group. This Simplified Specification is provided on a non-confidential
* basis subject to the disclaimers below. Any implementation of the
* Simplified Specification may require a license from the SD Card
* Association, SD Group, SD-3C LLC or other third parties.
*
* Disclaimers:
*
* The information contained in the Simplified Specification is presented only
* as a standard specification for SD Cards and SD Host/Ancillary products and
* is provided "AS-IS" without any representations or warranties of any
* kind. No responsibility is assumed by the SD Group, SD-3C LLC or the SD
* Card Association for any damages, any infringements of patents or other
* right of the SD Group, SD-3C LLC, the SD Card Association or any third
* parties, which may result from its use. No license is granted by
* implication, estoppel or otherwise under any patent or other rights of the
* SD Group, SD-3C LLC, the SD Card Association or any third party. Nothing
* herein shall be construed as an obligation by the SD Group, the SD-3C LLC
* or the SD Card Association to disclose or distribute any technical
* information, know-how or other confidential information to any third party.
*
*
* $FreeBSD$
*/
#ifndef _SDIOB_H
#define _SDIOB_H
#define SDIOB_NAME sdiob
#define _SDIOB_NAME_S(x) __STRING(x)
#define SDIOB_NAME_S _SDIOB_NAME_S(SDIOB_NAME)
#ifdef _SYS_BUS_H_
/* Ivars for sdiob. */
enum sdiob_dev_enum {
SDIOB_IVAR_SUPPORT_MULTIBLK,
SDIOB_IVAR_FUNCTION,
SDIOB_IVAR_FUNCNUM,
SDIOB_IVAR_CLASS,
SDIOB_IVAR_VENDOR,
SDIOB_IVAR_DEVICE,
SDIOB_IVAR_DRVDATA,
};
#define SDIOB_ACCESSOR(var, ivar, type) \
__BUS_ACCESSOR(sdio, var, SDIOB, ivar, type)
SDIOB_ACCESSOR(support_multiblk,SUPPORT_MULTIBLK, bool)
SDIOB_ACCESSOR(function, FUNCTION, struct sdio_func *)
SDIOB_ACCESSOR(funcnum, FUNCNUM, uint8_t)
SDIOB_ACCESSOR(class, CLASS, uint8_t)
SDIOB_ACCESSOR(vendor, VENDOR, uint16_t)
SDIOB_ACCESSOR(device, DEVICE, uint16_t)
SDIOB_ACCESSOR(drvdata, DRVDATA, void *)
#undef SDIOB_ACCESSOR
#endif /* _SYS_BUS_H_ */
#endif /* _SDIOB_H */

74
sys/dev/sdio/sdiodevs Normal file
View File

@ -0,0 +1,74 @@
$FreeBSD$
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 The FreeBSD Foundation
*
* Portions of this software were developed by Björn Zeeb
* under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Take SDIO CIS, CISTPL_MANFID, TPLMID_MANF and TPLMID_CARD information and
* present them as vendor and device IDs (a terminology we understand for
* other parts) and run them through the usbdevs2h.awk script to generate
* a header file with #defines for them in sdiodevs.h and sdiodevs_data.h
* which provides a structure with a description as well.
* The format of this file is modelled after sys/dev/usb/usbdevs.
* For more details see there.
*/
/*
* --------------------------------------------------------------------------
* List of TPLMID_MANF "vendor ID"s.
* Please sort by vendor ID ascending.
*/
vendor BROADCOM 0x02d0 Broadcom
vendor CYPRESS 0x02d0 Cypress/Broadcom
/*
* --------------------------------------------------------------------------
* List of TPLMID_CARD "product ID"s.
* Please group by vendor in same order as above.
*/
/* Broadcom products */
product BROADCOM 43241 0x4324 BCM43241 fullmac SDIO WiFi
product BROADCOM 4329 0x4329 BCM4329 fullmac SDIO WiFi
product BROADCOM 4330 0x4330 BCM4330 fullmac SDIO WiFi
product BROADCOM 4334 0x4334 BCM4334 fullmac SDIO WiFi
product BROADCOM 4335_4339 0x4335 BCM4335_4339 fullmac SDIO WiFi
product BROADCOM 4339 0x4339 BCM4339 fullmac SDIO WiFi
product BROADCOM 4345 0x4345 BCM4345 fullmac SDIO WiFi
product BROADCOM 4354 0x4354 BCM4354 fullmac SDIO WiFi
product BROADCOM 4356 0x4356 BCM4356 fullmac SDIO WiFi
product BROADCOM 43143 0xa887 BCM43143 fullmac SDIO WiFi
product BROADCOM 43340 0xa94c BCM43340 fullmac SDIO WiFi
product BROADCOM 43341 0xa94d BCM43341 fullmac SDIO WiFi
product BROADCOM 43362 0xa962 BCM43362 fullmac SDIO WiFi
product BROADCOM 43364 0xa9a4 BCM43364 fullmac SDIO WiFi
product BROADCOM 43430 0xa9a6 BCM43430 fullmac SDIO WiFi
product BROADCOM 43455 0xa9bf BCM43455 fullmac SDIO WiFi
product CYPRESS 4373 0x4373 CY4373 fullmac SDIO WiFi
/* end */

View File

@ -324,6 +324,7 @@ SUBDIR= \
sdhci \
${_sdhci_acpi} \
sdhci_pci \
sdio \
sem \
send \
${_sfxge} \

10
sys/modules/sdio/Makefile Normal file
View File

@ -0,0 +1,10 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/sdio
KMOD= sdio
SRCS= sdiob.c sdio_subr.c
SRCS+= sdio_if.c
SRCS+= device_if.h bus_if.h sdio_if.h
.include <bsd.kmod.mk>

265
sys/tools/sdiodevs2h.awk Normal file
View File

@ -0,0 +1,265 @@
#! /usr/bin/awk -f
#-
# $NetBSD: usb/devlist2h.awk,v 1.9 2001/01/18 20:28:22 jdolecek Exp $
# $FreeBSD$
#
# SPDX-License-Identifier: BSD-4-Clause
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Christopher G. Demetriou.
# 4. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
function usage()
{
print "usage: sdiodevs2h.awk <srcfile> [-d|-h]";
exit 1;
}
function header(file)
{
printf("/*\n") > file
printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
> file
printf(" *\n") > file
printf(" * generated from:\n") > file
printf(" *\t%s\n", VERSION) > file
printf(" */\n") > file
}
function vendor(hfile)
{
nvendors++
vendorindex[$2] = nvendors; # record index for this name, for later.
vendors[nvendors, 1] = $2; # name
vendors[nvendors, 2] = $3; # id
if (hfile)
printf("#define\tSDIO_VENDOR_%s\t%s\t", vendors[nvendors, 1],
vendors[nvendors, 2]) > hfile
i = 3; f = 4;
# comments
ocomment = oparen = 0
if (f <= NF) {
if (hfile)
printf("\t/* ") > hfile
ocomment = 1;
}
while (f <= NF) {
if ($f == "#") {
if (hfile)
printf("(") > hfile
oparen = 1
f++
continue
}
if (oparen) {
if (hfile)
printf("%s", $f) > hfile
if (f < NF && hfile)
printf(" ") > hfile
f++
continue
}
vendors[nvendors, i] = $f
if (hfile)
printf("%s", vendors[nvendors, i]) > hfile
if (f < NF && hfile)
printf(" ") > hfile
i++; f++;
}
if (oparen && hfile)
printf(")") > hfile
if (ocomment && hfile)
printf(" */") > hfile
if (hfile)
printf("\n") > hfile
}
function product(hfile)
{
nproducts++
products[nproducts, 1] = $2; # vendor name
products[nproducts, 2] = $3; # product id
products[nproducts, 3] = $4; # id
if (hfile)
printf("#define\tSDIO_PRODUCT_%s_%s\t%s\t", \
products[nproducts, 1], products[nproducts, 2], \
products[nproducts, 3]) > hfile
i=4; f = 5;
# comments
ocomment = oparen = 0
if (f <= NF) {
if (hfile)
printf("\t/* ") > hfile
ocomment = 1;
}
while (f <= NF) {
if ($f == "#") {
if (hfile)
printf("(") > hfile
oparen = 1
f++
continue
}
if (oparen) {
if (hfile)
printf("%s", $f) > hfile
if (f < NF && hfile)
printf(" ") > hfile
f++
continue
}
products[nproducts, i] = $f
if (hfile)
printf("%s", products[nproducts, i]) > hfile
if (f < NF && hfile)
printf(" ") > hfile
i++; f++;
}
if (oparen && hfile)
printf(")") > hfile
if (ocomment && hfile)
printf(" */") > hfile
if (hfile)
printf("\n") > hfile
}
function dump_dfile(dfile)
{
printf("\n") > dfile
printf("const struct sdio_knowndev sdio_knowndevs[] = {\n") > dfile
for (i = 1; i <= nproducts; i++) {
printf("\t{\n") > dfile
printf("\t SDIO_VENDOR_%s, SDIO_PRODUCT_%s_%s,\n",
products[i, 1], products[i, 1], products[i, 2]) > dfile
printf("\t ") > dfile
printf("0") > dfile
printf(",\n") > dfile
vendi = vendorindex[products[i, 1]];
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[vendi, j] != "") {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[vendi, j]) > dfile
needspace = 1
j++
}
printf("\",\n") > dfile
printf("\t \"") > dfile
j = 4;
needspace = 0;
while (products[i, j] != "") {
if (needspace)
printf(" ") > dfile
printf("%s", products[i, j]) > dfile
needspace = 1
j++
}
printf("\",\n") > dfile
printf("\t},\n") > dfile
}
for (i = 1; i <= nvendors; i++) {
printf("\t{\n") > dfile
printf("\t SDIO_VENDOR_%s, 0,\n", vendors[i, 1]) > dfile
printf("\t SDIO_KNOWNDEV_NOPROD,\n") > dfile
printf("\t \"") > dfile
j = 3;
needspace = 0;
while (vendors[i, j] != "") {
if (needspace)
printf(" ") > dfile
printf("%s", vendors[i, j]) > dfile
needspace = 1
j++
}
printf("\",\n") > dfile
printf("\t NULL,\n") > dfile
printf("\t},\n") > dfile
}
printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
printf("};\n") > dfile
}
BEGIN {
nproducts = nvendors = 0
# Process the command line
for (i = 1; i < ARGC; i++) {
arg = ARGV[i];
if (arg !~ /^-[dh]+$/ && arg !~ /devs$/)
usage();
if (arg ~ /^-.*d/)
dfile="sdiodevs_data.h"
if (arg ~ /^-.*h/)
hfile="sdiodevs.h"
if (arg ~ /devs$/)
srcfile = arg;
}
ARGC = 1;
line=0;
while ((getline < srcfile) > 0) {
line++;
if (line == 1) {
VERSION = $0
gsub("\\$", "", VERSION)
if (dfile)
header(dfile)
if (hfile)
header(hfile)
continue;
}
if ($1 == "vendor") {
vendor(hfile)
continue
}
if ($1 == "product") {
product(hfile)
continue
}
if ($0 == "")
blanklines++
if (hfile)
print $0 > hfile
if (blanklines < 2 && dfile)
print $0 > dfile
}
# print out the match tables
if (dfile)
dump_dfile(dfile)
}