Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ufshci/ufshci.c
- This file was added.
| /*- | |||||
| * SPDX-License-Identifier: BSD-2-Clause | |||||
| * | |||||
| * Copyright (c) 2025, Samsung Electronics Co., Ltd. | |||||
| * 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. | |||||
| * | |||||
| * 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. | |||||
| */ | |||||
| #include <sys/param.h> | |||||
| #include <sys/bus.h> | |||||
| #include <sys/conf.h> | |||||
| #include <sys/module.h> | |||||
| #include <vm/uma.h> | |||||
| #include "ufshci_private.h" | |||||
| MALLOC_DEFINE(M_UFSHCI, "ufshci", "ufshci(4) memory allocations"); | |||||
| int | |||||
| ufshci_attach(device_t dev) | |||||
| { | |||||
| struct ufshci_controller *ctrlr = DEVICE2SOFTC(dev); | |||||
| int status; | |||||
| status = ufshci_ctrlr_construct(ctrlr, dev); | |||||
| if (status != 0) { | |||||
| ufshci_ctrlr_destruct(ctrlr, dev); | |||||
| return (status); | |||||
| } | |||||
| ctrlr->config_hook.ich_func = ufshci_ctrlr_start_config_hook; | |||||
| ctrlr->config_hook.ich_arg = ctrlr; | |||||
| if (config_intrhook_establish(&ctrlr->config_hook) != 0) | |||||
| return (ENOMEM); | |||||
| return (0); | |||||
| } | |||||
| int | |||||
| ufshci_detach(device_t dev) | |||||
| { | |||||
| struct ufshci_controller *ctrlr = DEVICE2SOFTC(dev); | |||||
| config_intrhook_drain(&ctrlr->config_hook); | |||||
| ufshci_ctrlr_destruct(ctrlr, dev); | |||||
| return (0); | |||||
| } | |||||
| void | |||||
| ufshci_completion_poll_cb(void *arg, const struct ufshci_completion *cpl, bool error) | |||||
| { | |||||
| struct ufshci_completion_poll_status *status = arg; | |||||
| /* | |||||
| * Copy status into the argument passed by the caller, so that the | |||||
| * caller can check the status to determine if the the request passed | |||||
| * or failed. | |||||
| */ | |||||
| memcpy(&status->cpl.response_upiu, &cpl->response_upiu, cpl->size); | |||||
| status->error = error; | |||||
| atomic_store_rel_int(&status->done, 1); | |||||
| } | |||||
| static int | |||||
| ufshci_modevent(module_t mod __unused, int type __unused, void *argp __unused) | |||||
| { | |||||
| return (0); | |||||
| } | |||||
| static moduledata_t ufshci_mod = { | |||||
| "ufshci", | |||||
| ufshci_modevent, | |||||
| 0 | |||||
| }; | |||||
| DECLARE_MODULE(ufshci, ufshci_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); | |||||
| MODULE_VERSION(ufshci, 1); | |||||
| MODULE_DEPEND(ufshci, cam, 1, 1, 1); | |||||