Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/rtsx/rtsx.c
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | |||||
#define RTSX_RTS5249 0x5249 | #define RTSX_RTS5249 0x5249 | ||||
#define RTSX_RTS5260 0x5260 | #define RTSX_RTS5260 0x5260 | ||||
#define RTSX_RTL8402 0x5286 | #define RTSX_RTL8402 0x5286 | ||||
#define RTSX_RTL8411 0x5289 | #define RTSX_RTL8411 0x5289 | ||||
#define RTSX_RTL8411B 0x5287 | #define RTSX_RTL8411B 0x5287 | ||||
#define RTSX_VERSION "2.1g" | #define RTSX_VERSION "2.1g" | ||||
static const struct rtsx_device { | static const struct rtsx_pciids { | ||||
uint16_t vendor_id; | |||||
uint16_t device_id; | uint16_t device_id; | ||||
const char *desc; | const char *desc; | ||||
} rtsx_devices[] = { | } rtsx_ids[] = { | ||||
{ RTSX_REALTEK, RTSX_RTS5209, RTSX_VERSION " Realtek RTS5209 PCIe SD Card Reader"}, | { RTSX_RTS5209, RTSX_VERSION " Realtek RTS5209 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTS5227, RTSX_VERSION " Realtek RTS5227 PCIe SD Card Reader"}, | { RTSX_RTS5227, RTSX_VERSION " Realtek RTS5227 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTS5229, RTSX_VERSION " Realtek RTS5229 PCIe SD Card Reader"}, | { RTSX_RTS5229, RTSX_VERSION " Realtek RTS5229 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTS522A, RTSX_VERSION " Realtek RTS522A PCIe SD Card Reader"}, | { RTSX_RTS522A, RTSX_VERSION " Realtek RTS522A PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTS525A, RTSX_VERSION " Realtek RTS525A PCIe SD Card Reader"}, | { RTSX_RTS525A, RTSX_VERSION " Realtek RTS525A PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTS5249, RTSX_VERSION " Realtek RTS5249 PCIe SD Card Reader"}, | { RTSX_RTS5249, RTSX_VERSION " Realtek RTS5249 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTS5260, RTSX_VERSION " Realtek RTS5260 PCIe SD Card Reader"}, | { RTSX_RTS5260, RTSX_VERSION " Realtek RTS5260 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTL8402, RTSX_VERSION " Realtek RTL8402 PCIe SD Card Reader"}, | { RTSX_RTL8402, RTSX_VERSION " Realtek RTL8402 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTL8411, RTSX_VERSION " Realtek RTL8411 PCIe SD Card Reader"}, | { RTSX_RTL8411, RTSX_VERSION " Realtek RTL8411 PCIe SD Card Reader" }, | ||||
{ RTSX_REALTEK, RTSX_RTL8411B, RTSX_VERSION " Realtek RTL8411B PCIe SD Card Reader"}, | { RTSX_RTL8411B, RTSX_VERSION " Realtek RTL8411B PCIe SD Card Reader" }, | ||||
{ 0, 0, NULL} | |||||
}; | }; | ||||
/* See `kenv | grep smbios.system` */ | /* See `kenv | grep smbios.system` */ | ||||
static const struct rtsx_inversion_model { | static const struct rtsx_inversion_model { | ||||
char *maker; | char *maker; | ||||
char *family; | char *family; | ||||
char *product; | char *product; | ||||
} rtsx_inversion_models[] = { | } rtsx_inversion_models[] = { | ||||
{ "LENOVO", "ThinkPad T470p", "20J7S0PM00"}, | { "LENOVO", "ThinkPad T470p", "20J7S0PM00"}, | ||||
{ "LENOVO", "ThinkPad X13 Gen 1", "20UF000QRT"}, | |||||
{ NULL, NULL, NULL} | { NULL, NULL, NULL} | ||||
}; | }; | ||||
static int rtsx_dma_alloc(struct rtsx_softc *sc); | static int rtsx_dma_alloc(struct rtsx_softc *sc); | ||||
static void rtsx_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error); | static void rtsx_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error); | ||||
static void rtsx_dma_free(struct rtsx_softc *sc); | static void rtsx_dma_free(struct rtsx_softc *sc); | ||||
static void rtsx_intr(void *arg); | static void rtsx_intr(void *arg); | ||||
static void rtsx_handle_card_present(struct rtsx_softc *sc); | static void rtsx_handle_card_present(struct rtsx_softc *sc); | ||||
▲ Show 20 Lines • Show All 3,356 Lines • ▼ Show 20 Lines | |||||
* supports. If there is a match, set the description and return success. | * supports. If there is a match, set the description and return success. | ||||
*/ | */ | ||||
static int | static int | ||||
rtsx_probe(device_t dev) | rtsx_probe(device_t dev) | ||||
{ | { | ||||
uint16_t vendor_id; | uint16_t vendor_id; | ||||
uint16_t device_id; | uint16_t device_id; | ||||
int i; | int i; | ||||
int result; | |||||
vendor_id = pci_get_vendor(dev); | vendor_id = pci_get_vendor(dev); | ||||
device_id = pci_get_device(dev); | device_id = pci_get_device(dev); | ||||
result = ENXIO; | if (vendor_id != RTSX_REALTEK) | ||||
for (i = 0; rtsx_devices[i].vendor_id != 0; i++) { | return (ENXIO); | ||||
if (rtsx_devices[i].vendor_id == vendor_id && | for (i = 0; i < nitems(rtsx_ids); i++) { | ||||
rtsx_devices[i].device_id == device_id) { | if (rtsx_ids[i].device_id == device_id) { | ||||
device_set_desc(dev, rtsx_devices[i].desc); | device_set_desc(dev, rtsx_ids[i].desc); | ||||
result = BUS_PROBE_DEFAULT; | return (BUS_PROBE_DEFAULT); | ||||
break; | |||||
} | } | ||||
} | } | ||||
return (ENXIO); | |||||
return (result); | |||||
} | } | ||||
/* | /* | ||||
* Attach function is only called if the probe is successful. | * Attach function is only called if the probe is successful. | ||||
*/ | */ | ||||
static int | static int | ||||
rtsx_attach(device_t dev) | rtsx_attach(device_t dev) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | #ifdef MMCCAM | ||||
DEVMETHOD(mmc_sim_get_tran_settings, rtsx_get_tran_settings), | DEVMETHOD(mmc_sim_get_tran_settings, rtsx_get_tran_settings), | ||||
DEVMETHOD(mmc_sim_set_tran_settings, rtsx_set_tran_settings), | DEVMETHOD(mmc_sim_set_tran_settings, rtsx_set_tran_settings), | ||||
DEVMETHOD(mmc_sim_cam_request, rtsx_cam_request), | DEVMETHOD(mmc_sim_cam_request, rtsx_cam_request), | ||||
#endif /* MMCCAM */ | #endif /* MMCCAM */ | ||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
static devclass_t rtsx_devclass; | |||||
DEFINE_CLASS_0(rtsx, rtsx_driver, rtsx_methods, sizeof(struct rtsx_softc)); | DEFINE_CLASS_0(rtsx, rtsx_driver, rtsx_methods, sizeof(struct rtsx_softc)); | ||||
DRIVER_MODULE(rtsx, pci, rtsx_driver, rtsx_devclass, NULL, NULL); | DRIVER_MODULE(rtsx, pci, rtsx_driver, NULL, NULL); | ||||
/* For Plug and Play */ | |||||
MODULE_PNP_INFO("U16:device;D:#;T:vendor=0x10ec", pci, rtsx, | |||||
imp: Does this work? I didn't think that you could specify vendor= like this. I can't seem to find… | |||||
Done Inline ActionsI test it at every boot on my laptop. I follow hlh_restart.be: I test it at every boot on my laptop.
I follow
Example 2: Using T for common vendor value
in… | |||||
Not Done Inline ActionsAh, indeed. I'd forgotten about T. imp: Ah, indeed. I'd forgotten about T.
Then this looks good to me. | |||||
rtsx_ids, nitems(rtsx_ids)); | |||||
#ifndef MMCCAM | #ifndef MMCCAM | ||||
MMC_DECLARE_BRIDGE(rtsx); | MMC_DECLARE_BRIDGE(rtsx); | ||||
#endif /* !MMCCAM */ | #endif /* !MMCCAM */ | ||||
Done Inline ActionsIt would be better to reuse the list from main probe function above without duplication. I haven't looked closer into the format string of the macro, but I think it should be possible. mav: It would be better to reuse the list from main probe function above without duplication. I… |
Does this work? I didn't think that you could specify vendor= like this. I can't seem to find the code that parses it like that, can you help me find what I'm overlooking?