Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: omap: Support scratch registers

Register an nvmem device to expose the 3 scratch registers (total of 12
bytes) to both userspace and kernel space.

Reviewed-by: Sekhar Nori <nsekhar@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

+45
+45
drivers/rtc/rtc-omap.c
··· 70 70 #define OMAP_RTC_COMP_MSB_REG 0x50 71 71 #define OMAP_RTC_OSC_REG 0x54 72 72 73 + #define OMAP_RTC_SCRATCH0_REG 0x60 74 + #define OMAP_RTC_SCRATCH1_REG 0x64 75 + #define OMAP_RTC_SCRATCH2_REG 0x68 76 + 73 77 #define OMAP_RTC_KICK0_REG 0x6c 74 78 #define OMAP_RTC_KICK1_REG 0x70 75 79 ··· 671 667 .owner = THIS_MODULE, 672 668 }; 673 669 670 + static int omap_rtc_scratch_read(void *priv, unsigned int offset, void *_val, 671 + size_t bytes) 672 + { 673 + struct omap_rtc *rtc = priv; 674 + u32 *val = _val; 675 + int i; 676 + 677 + for (i = 0; i < bytes / 4; i++) 678 + val[i] = rtc_readl(rtc, 679 + OMAP_RTC_SCRATCH0_REG + offset + (i * 4)); 680 + 681 + return 0; 682 + } 683 + 684 + static int omap_rtc_scratch_write(void *priv, unsigned int offset, void *_val, 685 + size_t bytes) 686 + { 687 + struct omap_rtc *rtc = priv; 688 + u32 *val = _val; 689 + int i; 690 + 691 + rtc->type->unlock(rtc); 692 + for (i = 0; i < bytes / 4; i++) 693 + rtc_writel(rtc, 694 + OMAP_RTC_SCRATCH0_REG + offset + (i * 4), val[i]); 695 + rtc->type->lock(rtc); 696 + 697 + return 0; 698 + } 699 + 700 + static struct nvmem_config omap_rtc_nvmem_config = { 701 + .name = "omap_rtc_scratch", 702 + .word_size = 4, 703 + .stride = 4, 704 + .size = OMAP_RTC_KICK0_REG - OMAP_RTC_SCRATCH0_REG, 705 + .reg_read = omap_rtc_scratch_read, 706 + .reg_write = omap_rtc_scratch_write, 707 + }; 708 + 674 709 static int omap_rtc_probe(struct platform_device *pdev) 675 710 { 676 711 struct omap_rtc *rtc; ··· 847 804 } 848 805 849 806 rtc->rtc->ops = &omap_rtc_ops; 807 + omap_rtc_nvmem_config.priv = rtc; 808 + rtc->rtc->nvmem_config = &omap_rtc_nvmem_config; 850 809 851 810 /* handle periodic and alarm irqs */ 852 811 ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,