summaryrefslogtreecommitdiffstats
path: root/drivers/rtc
Commit message (Collapse)AuthorAgeFilesLines
* regmap: align regmap_bulk_read/write API with LinuxAhmad Fatoum2023-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since its inception in 2016, barebox regmap_bulk_read and regmap_bulk_write expected the last argument to be the total length of data to access in bytes. Its namesake Linux version has the same prototype, but interprets the last argument as number of elements to write, i.e. bytes / regmap_get_val_bytes(map). This went unnoticed so far, because barebox users are either using 1-byte regmaps, the code was written specifically for barebox or the code is yet unused such as the KSZ switch 64-bit accessors. Avoid nasty future surprises by switching implementation and users to the Linux interpretation of the last argument. As courtesy for out-of-tree board code, we poison the symbol when regmap.h is included, so out of tree code doesn't silently run into the inverse issue. Files with regmap.h replaced by linux/regmap.h added and no other changes are already compatible with the new definitions. All other files are adapted to the new definition through division by the value size in bytes. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2023-06-221-6/+2
|\
| * nvmem: retire struct nvmem_bus for better Linux compatibilityAhmad Fatoum2023-06-131-6/+2
| | | | | | | | | | | | | | | | | | | | nvmem_bus is arguably a confusing name and serves no real purpose over just embedding its two members directly. That's what Linux currently does, so follow suit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125711.1086786-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-132-0/+2
|/ | | | | | | | | | | | | | | | Syncing device trees with Linux upstream can lead to breakage, when the device trees are switched to newer bindings, which are not yet supported in barebox. To make it easier to spot such issues, we want to start applying some heuristics to flag possibly problematic DT changes. One step towards being able to do that is to know what nodes barebox actually consumes. Most of the nodes have a compatible entry, which is matched by an array of of_device_id, so let's have MODULE_DEVICE_TABLE point at it for future extraction. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125908.1087340-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: base: regmap: introduce REGMAP_I2CAhmad Fatoum2023-01-121-0/+1
| | | | | | | | | | | | | | | | | regmap_init_i2c is quite limited right now and only supports 8-bit registers and values. In future, we may want to expand this further, but that would require us to format the regmap_config appropriately, pulling in more code that's not required in the general case, where reg_read and reg_write can be used directly. Add a new Kconfig symbol and select it where appropriate to allow us to split formatted regmap handling from the more basic handling we currently have. We intentionally don't provide a stub function, so out-of-tree users without the select fail to link and can be fixed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111132956.1153359-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct driver_d to driverSascha Hauer2023-01-105-5/+5
| | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-106-10/+10
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: rtc: abracon: Remove redundant variableAlexander Shiyan2022-06-301-4/+1
| | | | | | Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220629063024.3945-2-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: rtc: pcf8536: Remove redundant variableAlexander Shiyan2022-06-301-4/+1
| | | | | | Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220629063024.3945-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: import pcf85363 support from linux-5.12Antony Pavlov2022-01-033-0/+176
| | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Link: https://lore.barebox.org/20211226163755.204465-1-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-225-5/+5
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-018-45/+9
| | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nvmem: provider: align read/write callback prototype with upstreamAhmad Fatoum2021-06-021-8/+5
| | | | | | | | | | | | | | barebox allocates a NVMEM device as part of nvmem_register, which it passes along to the callbacks. Callbacks then use dev->parent->priv to retrieve the driver private data. This indirection makes definition of nvmem helpers inconvenient, because they would need to hijack the ->priv member of the hardware device. Avoid this by passing along some private data pointer defined at registration time, just like Linux does. This will be used in a follow up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210531072406.5630-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add i.MX25 rtc driverSascha Hauer2019-04-123-0/+630
| | | | | | | | This adds a RTC driver for the Freescale i.MX25. This is done more to get access to the nonvolatile general purpose register than it is done to read the clock. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: ds1307: Set DS1341_BIT_DOSF in the right registerAndrey Smirnov2018-11-191-2/+2
| | | | | | | | | | DS1341_BIT_DOSF is located in DS1337_REG_STATUS, not DS1337_REG_CONTROL. Fix the code to reflect that. Also fix "additionale" -> "additional" typo while at it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-1/+1
|\
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-1/+1
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | rtc: ds1307: Add ds3231 to driver's ID listMarco Felsch2018-10-191-0/+1
| | | | | | | | | | | | | | | | | | In contrast to the ds1337 the ds3231 has a built-in temperature compensated crystal oscillator. The register map seems the same as the one from the ds1337, so using it's driver_data is okay. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: introduce device_i2c_driver() macroMarco Felsch2018-10-192-14/+2
|/ | | | | | | | | Add macro and dependency to avoid boilerplate code. Since now simple i2c drivers only have to include the i2c.h header and call the device_i2c_driver() macro to register a i2c device driver. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc-lib: drop unused rtc_ydaysAntony Pavlov2017-05-111-7/+0
| | | | | | | | | | | The patch fixes this compiler's warning: drivers/rtc/rtc-lib.c:23:29: warning: ‘rtc_ydays’ defined but not used [-Wunused-const-variable=] static const unsigned short rtc_ydays[2][13] = { ^~~~~~~~~ Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: ds1307: Add support for configuring external clock pinTrent Piepho2016-05-301-1/+44
| | | | | | | | | | | | | | | | | | | | The DS1307 has a square wave output pin, which can be used to output a clock signal from the DS1307. Additionally, the DS1308 supports configuring this pin as an input from an external clock source to which it should sync itself. Add support with OF device tree properties to configure these settings. Supported features are using the clock pin as an output, an input, the rate of the pin, and if it should be enabled on battery backup power. The driver does not check that the selected features are supported by the clock chip being used. It is the designer's responsibility to create a valid device tree node; the bootloader does not attempt to be a device tree validator. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: ds1307: Add ds1308 to driver's ID listTrent Piepho2016-05-231-0/+1
| | | | | | | | | As far as the driver is concerned, it's the same as a 1338. It's too bad the i2c drivers can't make use of OF compatible properties with a list of compatible devices. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ds1307: Configure ds1341 for lowest power modeAndrey Smirnov2016-04-051-4/+16
| | | | | | | | | | | | Empirical observations show that configuring INTCN=1, ECLK=0, EGFIL=0, DOSF=1 on DS1341 put the chip in the mode where it draws the least amount fo current. Add code to configure DS1341 in such a way in case Barebox is the last code that runs on the processor before being shut down. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ds1307: Fix a bug in probe()Andrey Smirnov2016-04-051-1/+1
| | | | | | | Add missing "~" to bit clearing operation. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: abracon: Check obtained time for validityAndrey Smirnov2016-04-051-2/+2
| | | | | | | | Check obtianed time for validity before returning it to the caller the same way other RTC drivers do. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-071-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Fix return check of dev_request_mem_regionSascha Hauer2016-02-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region returns an ERR_PTR, fix places which check for a NULL pointer instead. This patch has been generated with this semantic patch, written by me and improved by Andrey Smirnov: // <smpl> @@ expression e; expression e1; @@ e = dev_request_mem_region(...); ... -if (!e) - return e1; +if (IS_ERR(e)) + return PTR_ERR(e); @ rule1 @ expression e; @@ e = dev_request_mem_region(...); @@ expression rule1.e; identifier ret, label; constant errno; @@ if (!e) { ... ( - ret = -errno; + ret = PTR_ERR(e); ... goto label; | - return -errno; + return PTR_ERR(e); ) } @depends on rule1@ expression rule1.e; @@ - if (e == NULL) + if (IS_ERR(e)) { ... } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
* rtc-lib: Check tm_wday for validity in rtc_valid_tm()Andrey Smirnov2016-01-071-0/+2
| | | | | | | | | | | | | | RTC drivers rely on rtc_valid_tm() in order to make sure that no bogus values from uninitialized HW registers get passed to the uppper layers. A somewhat contrived way to reproduce this problem with DS1307 RTC would be to do the following: > i2c_write -b <bus> -a <addr> -r 3 0x00 > hwclock Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: ds1307: Fix a memory leakAndrey Smirnov2016-01-071-0/+3
| | | | | | | | | Several failure paths would result in control being transfered to 'exit' label, so instead of just returning error codes in those cases we also need to free the memory allocated for 'ds1307' Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: ds1307: Add code to support ds1337/1341Andrey Smirnov2016-01-071-0/+91
| | | | | | | | Port DS1337 specific bits from corresponding Linux driver and add small changes needed for DS1341. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: Add Abracon driverSascha Hauer2016-01-073-0/+130
| | | | | | | | This patch adds support for the Abracon ab-rtcmc-32.768khz-eoz9-s3 RTC. The driver can probably support other Abracon RTCs aswell, but this hasn't been verified. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: Fill in weekdays before setting timeSascha Hauer2016-01-071-1/+7
| | | | | | | | Some rtcs store the weekday. Make sure it's filled in correctly before passinf the time to the driver. This is easily done by converting it to seconds-since-epoch and back to struct rtc_time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: Check time for validity before passing it to the rtc driverSascha Hauer2016-01-071-0/+3
| | | | | | So that rtc drivers do not get invalid times. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: select GREGORIAN_CALENDERLucas Stach2014-11-271-0/+1
| | | | | | | | Fixes: drivers/rtc/rtc-lib.c:109: undefined reference to `mktime' Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: add jz4740 driverAntony Pavlov2014-08-023-0/+173
| | | | | | | Add support for the RTC unit on Ingenic JZ4740, JZ475x and JZ477x SoCs. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc-lib: import rtc_time_to_tm() from linux-3.15Antony Pavlov2014-08-021-0/+45
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rtc: import ds1307 driver from linux-3.15Antony Pavlov2014-08-023-0/+373
| | | | | | | | Current ds1307 rtc driver supports only ds1307 and ds1338 chips; it has no nvram support at the moment. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add a simple rtc frameworkAntony Pavlov2014-07-314-0/+159
| | | | | | | | This patch adds a simple rtc framework for reading and setting board's RTC time. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove unused driversSascha Hauer2007-09-2121-4210/+0
|
* svn_rev_505Sascha Hauer2007-07-0521-0/+4210