sni_emmc.c revision 1.1
1/* $NetBSD: sni_emmc.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $ */ 2 3/*- 4 * Copyright (c) 2020 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Tohru Nishimura. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32/* 33 * Socionext SC2A11 SynQuacer eMMC driver 34 */ 35 36#include <sys/cdefs.h> 37__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $"); 38 39#include <sys/param.h> 40#include <sys/bus.h> 41#include <sys/intr.h> 42#include <sys/device.h> 43#include <sys/errno.h> 44#include <sys/kernel.h> 45#include <sys/systm.h> 46 47#include <machine/endian.h> 48 49#include <dev/fdt/fdtvar.h> 50#include <dev/acpi/acpireg.h> 51#include <dev/acpi/acpivar.h> 52 53static int sniemmc_fdt_match(device_t, struct cfdata *, void *); 54static void sniemmc_fdt_attach(device_t, device_t, void *); 55static int sniemmc_acpi_match(device_t, struct cfdata *, void *); 56static void sniemmc_acpi_attach(device_t, device_t, void *); 57 58struct sniemmc_softc { 59 device_t sc_dev; 60}; 61 62CFATTACH_DECL_NEW(sniemmc_fdt, sizeof(struct sniemmc_softc), 63 sniemmc_fdt_match, sniemmc_fdt_attach, NULL, NULL); 64 65CFATTACH_DECL_NEW(sniemmc_acpi, sizeof(struct sniemmc_softc), 66 sniemmc_acpi_match, sniemmc_acpi_attach, NULL, NULL); 67 68static int sniemmc_attach_i(struct sniemmc_softc *); 69 70static int 71sniemmc_fdt_match(device_t parent, struct cfdata *match, void *aux) 72{ 73 static const char * compatible[] = { 74 "socionext,synquacer-sdhci", 75 "fujitsu,mb86s70-sdhci-3.0", 76 NULL 77 }; 78 struct fdt_attach_args * const faa = aux; 79 80 return of_match_compatible(faa->faa_phandle, compatible); 81} 82 83static void 84sniemmc_fdt_attach(device_t parent, device_t self, void *aux) 85{ 86 struct sniemmc_softc * const sc = device_private(self); 87 int error; 88 89 error = sniemmc_attach_i(sc); 90 (void)error; 91} 92 93static int 94sniemmc_acpi_match(device_t parent, struct cfdata *match, void *aux) 95{ 96 static const char * compatible[] = { 97 "SCX0002", 98 NULL 99 }; 100 struct acpi_attach_args *aa = aux; 101 102 if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) 103 return 0; 104 return acpi_match_hid(aa->aa_node->ad_devinfo, compatible); 105} 106 107static void 108sniemmc_acpi_attach(device_t parent, device_t self, void *aux) 109{ 110 struct sniemmc_softc * const sc = device_private(self); 111 int error; 112 113 error = sniemmc_attach_i(sc); 114 (void)error; 115} 116 117static int 118sniemmc_attach_i(struct sniemmc_softc *sc) 119{ 120 return 0; 121} 122