/* * ST M48T59 RTC driver * * Copyright (c) 2007 Wind River Systems, Inc. * * Author: Mark Zhan * * 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 #include #include #include #include #include #include #include #include #include #ifndef NO_IRQ #define NO_IRQ (-1) #endif #define M48T59_READ(reg) (pdata->read_byte(dev, pdata->offset + reg)) #define M48T59_WRITE(val, reg) \ (pdata->write_byte(dev, pdata->offset + reg, val)) #define M48T59_SET_BITS(mask, reg) \ M48T59_WRITE((M48T59_READ(reg) | (mask)), (reg)) #define M48T59_CLEAR_BITS(mask, reg) \ M48T59_WRITE((M48T59_READ(reg) & ~(mask)), (reg)) struct m48t59_private { void __iomem *ioaddr; int irq; struct rtc_device *rtc; spinlock_t lock; /* serialize the NVRAM and RTC access */ }; /* * This is the generic access method when the chip is memory-mapped */ static void m48t59_mem_writeb(struct device *dev, u32 ofs, u8 val) { struct platform_device *pdev = to_platform_device(dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); writeb(val, m48t59->ioaddr+ofs); } static u8 m48t59_mem_readb(struct device *dev, u32 ofs) { struct platform_device *pdev = to_platform_device(dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); return readb(m48t59->ioaddr+ofs); } /* * NOTE: M48T59 only uses BCD mode */ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct platform_device *pdev = to_platform_device(dev); struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); unsigned long flags; u8 val; spin_lock_irqsave(&m48t59->lock, flags); /* Issue the READ command */ M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); /* tm_mon is 0-11 */ tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; tm->tm_mday = bcd2bin(M48T59_READ(M48T59_MDAY)); val = M48T59_READ(M48T59_WDAY); if ((pdata->type == M48T59RTC_TYPE_M48T59) && (val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) { dev_dbg(dev, "Century bit is enabled\n"); tm->tm_year += 100; /* one century */ } #ifdef CONFIG_SPARC /* Sun SPARC machines count years since 1968 */ tm->tm_year += 68; #endif tm->tm_wday = bcd2bin(val & 0x07); tm->tm_hour = bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F); tm->tm_min = bcd2bin(M48T59_READ(M48T59_MIN) & 0x7F); tm->tm_sec = bcd2bin(M48T59_READ(M48T59_SEC) & 0x7F); /* Clear the READ bit */ M48T59_CLEAR_BITS(M48T59_CNTL_READ, M48T59_CNTL); spin_unlock_irqrestore(&m48t59->lock, flags); dev_dbg(dev, "RTC read time %04d-%02d-%02d %02d/%02d/%02d\n", tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); return rtc_valid_tm(tm); } static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct platform_device *pdev = to_platform_device(dev); struct m48t59_plat_data *pdata = dev_get_platdata(&pdev->dev); struct m48t59_private *m48t59 = platform_get_drvdata(pdev); unsigned long flags; u8 val = 0; int year = tm->tm_year; #ifdef CONFIG_SPARC /* Sun SPARC machines count years since 1968 */ year -= 68; #endif dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n", year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); if (year < 0) return -EINVAL; spin_lock_irqsave(&m48t59->lock, flags); /* Issue the WRITE command */ M48T59_SET_BITS(M48T59_CNTL_WRITE, M48T59_CNTL); M48T59_WRITE((bin2bcd(tm->tm_sec) & 0x7F), M48T59_SEC); M48T59_WRITE((bin2bcd(tm->tm_min) & 0x7F), M48T59_MIN); M48T59_WRITE((bin2bcd(tm->tm_hour) & 0x3F), M48T59_HOUR); M48T59_WRITE((bin2bcd(tm->tm_mday) & 0x3F), M48T59_MDAY); /* tm_mon is 0-11 */ M48T59_WRITE((bin2bcd(tm->tm_mon + 1) & 0x1F), M48T59_MONTH); M48T59_WRITE(bin2bcd(year % 100), M48T59_YEAR); if (pdata->type == M48T59RTC_TYPE_M48T59 && (year / 100)) val = (M48T59_WDAY_CEB | M48T59_WDAY_CB); val |= (bin2bcd(tm->tm_wday) & 0x07); M48T59_WRITE(val, M48T59_WDAY); /* Clear the WRITE bit */ M48T59_CLEAR_BITS(M48T59_CNTL_WRITE, M48T59_CNTL); spin_unlock_irqrestore(&m48t59->lock, flags); return 0; } /* * Read alarm time and date in RTC */ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct platform_device *pdev = to_platform_device(dev); stru
---

schema: "yardstick:task:0.1"

description: >
    Sample benchmark task config file;
    Monitor network metrics provided by the kernel in a host and calculate
    IP datagram error rate, ICMP message error rate, TCP segment error rate and
    UDP datagram error rate.

scenarios:
-
  <