1*90313c06Smsaitoh /* $NetBSD: imx_snvs.c,v 1.3 2024/02/07 04:20:27 msaitoh Exp $ */
28644267aSskrll
38644267aSskrll /*
4*90313c06Smsaitoh * Copyright (c) 2014 Ryo Shimizu
58644267aSskrll * All rights reserved.
68644267aSskrll *
78644267aSskrll * Redistribution and use in source and binary forms, with or without
88644267aSskrll * modification, are permitted provided that the following conditions
98644267aSskrll * are met:
108644267aSskrll * 1. Redistributions of source code must retain the above copyright
118644267aSskrll * notice, this list of conditions and the following disclaimer.
128644267aSskrll * 2. Redistributions in binary form must reproduce the above copyright
138644267aSskrll * notice, this list of conditions and the following disclaimer in the
148644267aSskrll * documentation and/or other materials provided with the distribution.
158644267aSskrll *
168644267aSskrll * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
178644267aSskrll * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
188644267aSskrll * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
198644267aSskrll * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
208644267aSskrll * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
218644267aSskrll * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
228644267aSskrll * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238644267aSskrll * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
248644267aSskrll * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
258644267aSskrll * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
268644267aSskrll * POSSIBILITY OF SUCH DAMAGE.
278644267aSskrll */
288644267aSskrll
298644267aSskrll /*
308644267aSskrll * i.MX6 Secure Non-Volatile Storage
318644267aSskrll */
328644267aSskrll
338644267aSskrll #include <sys/cdefs.h>
34*90313c06Smsaitoh __KERNEL_RCSID(0, "$NetBSD: imx_snvs.c,v 1.3 2024/02/07 04:20:27 msaitoh Exp $");
358644267aSskrll
368644267aSskrll #include <sys/bus.h>
378644267aSskrll #include <sys/device.h>
388644267aSskrll #include <sys/param.h>
398644267aSskrll
408644267aSskrll #include <dev/fdt/fdtvar.h>
418644267aSskrll
428644267aSskrll #include <arm/imx/imxsnvsvar.h>
438644267aSskrll
446e54367aSthorpej static const struct device_compatible_entry compat_data[] = {
456e54367aSthorpej { .compat = "fsl,sec-v4.0-mon" },
466e54367aSthorpej DEVICE_COMPAT_EOL
476e54367aSthorpej };
486e54367aSthorpej
498644267aSskrll int
imxsnvs_match(device_t parent,struct cfdata * match,void * aux)508644267aSskrll imxsnvs_match(device_t parent, struct cfdata *match, void *aux)
518644267aSskrll {
528644267aSskrll struct fdt_attach_args * const faa = aux;
538644267aSskrll
546e54367aSthorpej return of_compatible_match(faa->faa_phandle, compat_data);
558644267aSskrll }
568644267aSskrll
578644267aSskrll void
imxsnvs_attach(device_t parent,device_t self,void * aux)588644267aSskrll imxsnvs_attach(device_t parent, device_t self, void *aux)
598644267aSskrll {
608644267aSskrll struct fdt_attach_args * const faa = aux;
618644267aSskrll const int phandle = faa->faa_phandle;
628644267aSskrll bus_addr_t addr;
638644267aSskrll bus_size_t size;
648644267aSskrll
658644267aSskrll if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
668644267aSskrll aprint_error(": couldn't get registers\n");
678644267aSskrll return;
688644267aSskrll }
698644267aSskrll
708644267aSskrll imxsnvs_attach_common(parent, self,
718644267aSskrll faa->faa_bst, addr, size, 0, 0);
728644267aSskrll }
738644267aSskrll
74