cregit-Linux how code gets into the kernel

Release 4.11 arch/arm/mach-prima2/rtciobrg.c

/*
 * RTC I/O Bridge interfaces for CSR SiRFprimaII/atlas7
 * ARM access the registers of SYSRTC, GPSRTC and PWRC through this module
 *
 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
 *
 * Licensed under GPLv2 or later.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/regmap.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>


#define SIRFSOC_CPUIOBRG_CTRL           0x00

#define SIRFSOC_CPUIOBRG_WRBE           0x04

#define SIRFSOC_CPUIOBRG_ADDR           0x08

#define SIRFSOC_CPUIOBRG_DATA           0x0c

/*
 * suspend asm codes will access this address to make system deepsleep
 * after DRAM becomes self-refresh
 */

void __iomem *sirfsoc_rtciobrg_base;
static DEFINE_SPINLOCK(rtciobrg_lock);

/*
 * symbols without lock are only used by suspend asm codes
 * and these symbols are not exported too
 */

void sirfsoc_rtc_iobrg_wait_sync(void) { while (readl_relaxed(sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL)) cpu_relax(); }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song19100.00%1100.00%
Total19100.00%1100.00%


void sirfsoc_rtc_iobrg_besyncing(void) { unsigned long flags; spin_lock_irqsave(&rtciobrg_lock, flags); sirfsoc_rtc_iobrg_wait_sync(); spin_unlock_irqrestore(&rtciobrg_lock, flags); }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song30100.00%1100.00%
Total30100.00%1100.00%

EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_besyncing);
u32 __sirfsoc_rtc_iobrg_readl(u32 addr) { sirfsoc_rtc_iobrg_wait_sync(); writel_relaxed(0x00, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_WRBE); writel_relaxed(addr, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_ADDR); writel_relaxed(0x01, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL); sirfsoc_rtc_iobrg_wait_sync(); return readl_relaxed(sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_DATA); }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song49100.00%1100.00%
Total49100.00%1100.00%


u32 sirfsoc_rtc_iobrg_readl(u32 addr) { unsigned long flags, val; /* TODO: add hwspinlock to sync with M3 */ spin_lock_irqsave(&rtciobrg_lock, flags); val = __sirfsoc_rtc_iobrg_readl(addr); spin_unlock_irqrestore(&rtciobrg_lock, flags); return val; }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song4097.56%150.00%
Guo Zeng12.44%150.00%
Total41100.00%2100.00%

EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_readl);
void sirfsoc_rtc_iobrg_pre_writel(u32 val, u32 addr) { sirfsoc_rtc_iobrg_wait_sync(); writel_relaxed(0xf1, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_WRBE); writel_relaxed(addr, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_ADDR); writel_relaxed(val, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_DATA); }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song41100.00%1100.00%
Total41100.00%1100.00%


void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr) { unsigned long flags; /* TODO: add hwspinlock to sync with M3 */ spin_lock_irqsave(&rtciobrg_lock, flags); sirfsoc_rtc_iobrg_pre_writel(val, addr); writel_relaxed(0x01, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL); sirfsoc_rtc_iobrg_wait_sync(); spin_unlock_irqrestore(&rtciobrg_lock, flags); }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song5098.04%150.00%
Guo Zeng11.96%150.00%
Total51100.00%2100.00%

EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel);
static int regmap_iobg_regwrite(void *context, unsigned int reg, unsigned int val) { sirfsoc_rtc_iobrg_writel(val, reg); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Guo Zeng28100.00%1100.00%
Total28100.00%1100.00%


static int regmap_iobg_regread(void *context, unsigned int reg, unsigned int *val) { *val = (u32)sirfsoc_rtc_iobrg_readl(reg); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Guo Zeng33100.00%1100.00%
Total33100.00%1100.00%

static struct regmap_bus regmap_iobg = { .reg_write = regmap_iobg_regwrite, .reg_read = regmap_iobg_regread, }; /** * devm_regmap_init_iobg(): Initialise managed register map * * @iobg: Device that will be interacted with * @config: Configuration for register map * * The return value will be an ERR_PTR() on error or a valid pointer * to a struct regmap. The regmap will be automatically freed by the * device management code. */
struct regmap *devm_regmap_init_iobg(struct device *dev, const struct regmap_config *config) { const struct regmap_bus *bus = &regmap_iobg; return devm_regmap_init(dev, bus, dev, config); }

Contributors

PersonTokensPropCommitsCommitProp
Guo Zeng39100.00%1100.00%
Total39100.00%1100.00%

EXPORT_SYMBOL_GPL(devm_regmap_init_iobg); static const struct of_device_id rtciobrg_ids[] = { { .compatible = "sirf,prima2-rtciobg" }, {} };
static int sirfsoc_rtciobrg_probe(struct platform_device *op) { struct device_node *np = op->dev.of_node; sirfsoc_rtciobrg_base = of_iomap(np, 0); if (!sirfsoc_rtciobrg_base) panic("unable to map rtc iobrg registers\n"); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song44100.00%1100.00%
Total44100.00%1100.00%

static struct platform_driver sirfsoc_rtciobrg_driver = { .probe = sirfsoc_rtciobrg_probe, .driver = { .name = "sirfsoc-rtciobrg", .of_match_table = rtciobrg_ids, }, };
static int __init sirfsoc_rtciobrg_init(void) { return platform_driver_register(&sirfsoc_rtciobrg_driver); }

Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song16100.00%1100.00%
Total16100.00%1100.00%

postcore_initcall(sirfsoc_rtciobrg_init); MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>"); MODULE_AUTHOR("Barry Song <baohua.song@csr.com>"); MODULE_DESCRIPTION("CSR SiRFprimaII rtc io bridge"); MODULE_LICENSE("GPL v2");

Overall Contributors

PersonTokensPropCommitsCommitProp
Zhiwu Song41875.59%133.33%
Guo Zeng13424.23%133.33%
Barry Song10.18%133.33%
Total553100.00%3100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.