cregit-Linux how code gets into the kernel

Release 4.7 drivers/rtc/rtc-ep93xx.c

Directory: drivers/rtc
/*
 * A driver for the RTC embedded in the Cirrus Logic EP93XX processors
 * Copyright (c) 2006 Tower Technologies
 *
 * Author: Alessandro Zummo <a.zummo@towertech.it>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/module.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/gfp.h>


#define EP93XX_RTC_DATA			0x000

#define EP93XX_RTC_MATCH		0x004

#define EP93XX_RTC_STATUS		0x008

#define  EP93XX_RTC_STATUS_INTR		 (1<<0)

#define EP93XX_RTC_LOAD			0x00C

#define EP93XX_RTC_CONTROL		0x010

#define  EP93XX_RTC_CONTROL_MIE		 (1<<0)

#define EP93XX_RTC_SWCOMP		0x108

#define  EP93XX_RTC_SWCOMP_DEL_MASK	 0x001f0000

#define  EP93XX_RTC_SWCOMP_DEL_SHIFT	 16

#define  EP93XX_RTC_SWCOMP_INT_MASK	 0x0000ffff

#define  EP93XX_RTC_SWCOMP_INT_SHIFT	 0

/*
 * struct device dev.platform_data is used to store our private data
 * because struct rtc_device does not have a variable to hold it.
 */

struct ep93xx_rtc {
	
void __iomem	*mmio_base;
	
struct rtc_device *rtc;
};


static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, unsigned short *delete) { struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); unsigned long comp; comp = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_SWCOMP); if (preload) *preload = (comp & EP93XX_RTC_SWCOMP_INT_MASK) >> EP93XX_RTC_SWCOMP_INT_SHIFT; if (delete) *delete = (comp & EP93XX_RTC_SWCOMP_DEL_MASK) >> EP93XX_RTC_SWCOMP_DEL_SHIFT; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo4962.03%125.00%
h hartley sweetenh hartley sweeten2734.18%250.00%
jingoo hanjingoo han33.80%125.00%
Total79100.00%4100.00%


static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); unsigned long time; time = readl(ep93xx_rtc->mmio_base + EP93XX_RTC_DATA); rtc_time_to_tm(time, tm); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo3262.75%125.00%
h hartley sweetenh hartley sweeten1631.37%250.00%
jingoo hanjingoo han35.88%125.00%
Total51100.00%4100.00%


static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs) { struct ep93xx_rtc *ep93xx_rtc = dev_get_platdata(dev); writel(secs + 1, ep93xx_rtc->mmio_base + EP93XX_RTC_LOAD); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo2663.41%125.00%
h hartley sweetenh hartley sweeten1229.27%250.00%
jingoo hanjingoo han37.32%125.00%
Total41100.00%4100.00%


static int ep93xx_rtc_proc(struct device *dev, struct seq_file *seq) { unsigned short preload, delete; ep93xx_rtc_get_swcomp(dev, &preload, &delete); seq_printf(seq, "preload\t\t: %d\n", preload); seq_printf(seq, "delete\t\t: %d\n", delete); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo5398.15%150.00%
h hartley sweetenh hartley sweeten11.85%150.00%
Total54100.00%2100.00%

static const struct rtc_class_ops ep93xx_rtc_ops = { .read_time = ep93xx_rtc_read_time, .set_mmss = ep93xx_rtc_set_mmss, .proc = ep93xx_rtc_proc, };
static ssize_t ep93xx_rtc_show_comp_preload(struct device *dev, struct device_attribute *attr, char *buf) { unsigned short preload; ep93xx_rtc_get_swcomp(dev, &preload, NULL); return sprintf(buf, "%d\n", preload); }

Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo4295.45%150.00%
h hartley sweetenh hartley sweeten24.55%150.00%
Total44100.00%2100.00%

static DEVICE_ATTR(comp_preload, S_IRUGO, ep93xx_rtc_show_comp_preload, NULL);
static ssize_t ep93xx_rtc_show_comp_delete(struct device *dev, struct device_attribute *attr, char *buf) { unsigned short delete; ep93xx_rtc_get_swcomp(dev, NULL, &delete); return sprintf(buf, "%d\n", delete); }

Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo4295.45%150.00%
h hartley sweetenh hartley sweeten24.55%150.00%
Total44100.00%2100.00%

static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_rtc_show_comp_delete, NULL); static struct attribute *ep93xx_rtc_attrs[] = { &dev_attr_comp_preload.attr, &dev_attr_comp_delete.attr, NULL }; static const struct attribute_group ep93xx_rtc_sysfs_files = { .attrs = ep93xx_rtc_attrs, };
static int ep93xx_rtc_probe(struct platform_device *pdev) { struct ep93xx_rtc *ep93xx_rtc; struct resource *res; int err; ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); if (!ep93xx_rtc) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ep93xx_rtc->mmio_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(ep93xx_rtc->mmio_base)) return PTR_ERR(ep93xx_rtc->mmio_base); pdev->dev.platform_data = ep93xx_rtc; platform_set_drvdata(pdev, ep93xx_rtc); ep93xx_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &ep93xx_rtc_ops, THIS_MODULE); if (IS_ERR(ep93xx_rtc->rtc)) { err = PTR_ERR(ep93xx_rtc->rtc); goto exit; } err = sysfs_create_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); if (err) goto exit; return 0; exit: pdev->dev.platform_data = NULL; return err; }

Contributors

PersonTokensPropCommitsCommitProp
h hartley sweetenh hartley sweeten12163.68%228.57%
alessandro zummoalessandro zummo4121.58%114.29%
julia lawalljulia lawall105.26%114.29%
axel linaxel lin73.68%114.29%
wolfram sangwolfram sang63.16%114.29%
jingoo hanjingoo han52.63%114.29%
Total190100.00%7100.00%


static int ep93xx_rtc_remove(struct platform_device *pdev) { sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); pdev->dev.platform_data = NULL; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
h hartley sweetenh hartley sweeten2160.00%266.67%
alessandro zummoalessandro zummo1440.00%133.33%
Total35100.00%3100.00%

static struct platform_driver ep93xx_rtc_driver = { .driver = { .name = "ep93xx-rtc", }, .probe = ep93xx_rtc_probe, .remove = ep93xx_rtc_remove, }; module_platform_driver(ep93xx_rtc_driver); MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); MODULE_DESCRIPTION("EP93XX RTC driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:ep93xx-rtc");

Overall Contributors

PersonTokensPropCommitsCommitProp
alessandro zummoalessandro zummo40754.19%18.33%
h hartley sweetenh hartley sweeten29839.68%433.33%
jingoo hanjingoo han141.86%216.67%
axel linaxel lin121.60%18.33%
julia lawalljulia lawall101.33%18.33%
wolfram sangwolfram sang60.80%18.33%
tejun heotejun heo30.40%18.33%
david brownelldavid brownell10.13%18.33%
Total751100.00%12100.00%
Directory: drivers/rtc
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}