Lines Matching +full:device +full:- +full:sram

1 // SPDX-License-Identifier: GPL-2.0
5 * This driver is for the MX23L4005, more specifically its real-time clock and
6 * SRAM storage. The value returned by the RTC counter must be added with the
7 * offset stored in a bias register in SRAM (on the GameCube and Wii) or in
10 * SRAM like for the other two consoles.
12 * This device sits on a bus named EXI (which is similar to SPI), channel 0,
13 * device 1. This driver assumes no other user of the EXI bus, which is
18 * - https://wiiubrew.org/wiki/Hardware/RTC
19 * - https://wiibrew.org/wiki/MX23L4005
21 * Copyright (C) 2018 rw-r-r-0644
24 * Based on rtc-gcn.c
25 * Copyright (C) 2004-2009 The GameCube Linux Team
99 void __iomem *iob = d->iob; in exi_read()
128 void __iomem *iob = d->iob; in exi_write()
161 static int gamecube_rtc_read_time(struct device *dev, struct rtc_time *t) in gamecube_rtc_read_time()
168 ret = regmap_read(d->regmap, RTC_COUNTER, &counter); in gamecube_rtc_read_time()
173 timestamp = (time64_t)d->rtc_bias + counter; in gamecube_rtc_read_time()
179 static int gamecube_rtc_set_time(struct device *dev, struct rtc_time *t) in gamecube_rtc_set_time()
186 return regmap_write(d->regmap, RTC_COUNTER, timestamp - d->rtc_bias); in gamecube_rtc_set_time()
189 static int gamecube_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) in gamecube_rtc_ioctl()
198 ret = regmap_read(d->regmap, RTC_CONTROL0, &control0); in gamecube_rtc_ioctl()
210 return -ENOIOCTLCMD; in gamecube_rtc_ioctl()
228 np = of_find_compatible_node(NULL, NULL, "nintendo,latte-srnprot"); in gamecube_rtc_read_offset_from_sram()
231 "nintendo,hollywood-srnprot"); in gamecube_rtc_read_offset_from_sram()
234 return regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias); in gamecube_rtc_read_offset_from_sram()
241 return -1; in gamecube_rtc_read_offset_from_sram()
258 /* Get the offset from RTC SRAM. in gamecube_rtc_read_offset_from_sram()
260 * Its default location on the GameCube and on the Wii is in the SRAM, in gamecube_rtc_read_offset_from_sram()
265 * SRAM address as on previous consoles. in gamecube_rtc_read_offset_from_sram()
267 ret = regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias); in gamecube_rtc_read_offset_from_sram()
269 /* Reset SRAM access to how it was before, our job here is done. */ in gamecube_rtc_read_offset_from_sram()
312 .name = "gamecube-rtc",
317 struct device *dev = &pdev->dev; in gamecube_rtc_probe()
324 return -ENOMEM; in gamecube_rtc_probe()
326 d->iob = devm_platform_ioremap_resource(pdev, 0); in gamecube_rtc_probe()
327 if (IS_ERR(d->iob)) in gamecube_rtc_probe()
328 return PTR_ERR(d->iob); in gamecube_rtc_probe()
330 d->regmap = devm_regmap_init(dev, &exi_bus, d, in gamecube_rtc_probe()
332 if (IS_ERR(d->regmap)) in gamecube_rtc_probe()
333 return PTR_ERR(d->regmap); in gamecube_rtc_probe()
338 dev_dbg(dev, "SRAM bias: 0x%x", d->rtc_bias); in gamecube_rtc_probe()
350 rtc->range_min = 0; in gamecube_rtc_probe()
351 rtc->range_max = U32_MAX; in gamecube_rtc_probe()
352 rtc->ops = &gamecube_rtc_ops; in gamecube_rtc_probe()
360 {.compatible = "nintendo,latte-exi" },
361 {.compatible = "nintendo,hollywood-exi" },
362 {.compatible = "nintendo,flipper-exi" },
370 .name = "rtc-gamecube",