mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-18 22:54:00 +00:00
core/linux-raspberrypi add hardware rng and nxp-pcf8523 changes
This commit is contained in:
parent
3cb6844d12
commit
797ad8a01a
3 changed files with 51 additions and 326 deletions
|
@ -9,7 +9,7 @@ pkgname=('linux-raspberrypi' 'linux-headers-raspberrypi')
|
||||||
_kernelname=${pkgname#linux}
|
_kernelname=${pkgname#linux}
|
||||||
_basekernel=3.6
|
_basekernel=3.6
|
||||||
pkgver=${_basekernel}.11
|
pkgver=${_basekernel}.11
|
||||||
pkgrel=4
|
pkgrel=5
|
||||||
arch=('arm armv6h')
|
arch=('arm armv6h')
|
||||||
url="http://www.kernel.org/"
|
url="http://www.kernel.org/"
|
||||||
license=('GPL2')
|
license=('GPL2')
|
||||||
|
@ -21,7 +21,8 @@ source=('config'
|
||||||
'args-uncompressed.txt'
|
'args-uncompressed.txt'
|
||||||
'boot-uncompressed.txt'
|
'boot-uncompressed.txt'
|
||||||
'imagetool-uncompressed.py'
|
'imagetool-uncompressed.py'
|
||||||
'nxp-pcf8523.patch')
|
'https://raspy-juice.googlecode.com/svn/trunk/linux-rtc/0001-rtc-pcf8523.patch'
|
||||||
|
'https://raspy-juice.googlecode.com/svn/trunk/linux-rtc/0002-pcf8523-i2c-register-dt.patch')
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
git clone --depth 1 https://github.com/raspberrypi/linux.git
|
git clone --depth 1 https://github.com/raspberrypi/linux.git
|
||||||
|
@ -33,7 +34,8 @@ build() {
|
||||||
|
|
||||||
# Add the USB_QUIRK_RESET_RESUME for several webcams
|
# Add the USB_QUIRK_RESET_RESUME for several webcams
|
||||||
# FS#26528
|
# FS#26528
|
||||||
patch -Np1 -i "${srcdir}/nxp-pcf8523.patch"
|
patch -Np1 -i "${srcdir}/0001-rtc-pcf8523.patch"
|
||||||
|
patch -Np1 -i "${srcdir}/0002-pcf8523-i2c-register-dt.patch"
|
||||||
|
|
||||||
#nxp-pcf8523 RTC patch
|
#nxp-pcf8523 RTC patch
|
||||||
patch -Np1 -i "${srcdir}/usb-add-reset-resume-quirk-for-several-webcams.patch"
|
patch -Np1 -i "${srcdir}/usb-add-reset-resume-quirk-for-several-webcams.patch"
|
||||||
|
@ -262,11 +264,12 @@ package_linux-headers-raspberrypi() {
|
||||||
rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/arch/{alpha,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,x86,xtensa}
|
rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/arch/{alpha,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,x86,xtensa}
|
||||||
}
|
}
|
||||||
|
|
||||||
md5sums=('a36790d26055ecd0478c991a15676ae7'
|
md5sums=('5e0da33033bcf5903c81a7a9a0c79550'
|
||||||
'9d3c56a4b999c8bfbd4018089a62f662'
|
'9d3c56a4b999c8bfbd4018089a62f662'
|
||||||
'd00814b57448895e65fbbc800e8a58ba'
|
'd00814b57448895e65fbbc800e8a58ba'
|
||||||
'9335d1263fd426215db69841a380ea26'
|
'9335d1263fd426215db69841a380ea26'
|
||||||
'a00e424e2fbb8c5a5f77ba2c4871bed4'
|
'a00e424e2fbb8c5a5f77ba2c4871bed4'
|
||||||
'2f82dbe5752af65ff409d737caf11954'
|
'2f82dbe5752af65ff409d737caf11954'
|
||||||
'644b8a8e2729658212d76061dc2062b9')
|
'ca74031c9e9bfc9f4a668924dcb37f4c'
|
||||||
|
'1e46f207dcf2dd9392a099a437bb9b3e')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# Automatically generated file; DO NOT EDIT.
|
# Automatically generated file; DO NOT EDIT.
|
||||||
# Linux/arm 3.6.11-4 Kernel Configuration
|
# Linux/arm 3.6.11-5 Kernel Configuration
|
||||||
#
|
#
|
||||||
CONFIG_ARM=y
|
CONFIG_ARM=y
|
||||||
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
|
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
|
||||||
|
@ -540,7 +540,9 @@ CONFIG_IP_PNP_DHCP=y
|
||||||
CONFIG_IP_PNP_BOOTP=y
|
CONFIG_IP_PNP_BOOTP=y
|
||||||
CONFIG_IP_PNP_RARP=y
|
CONFIG_IP_PNP_RARP=y
|
||||||
CONFIG_NET_IPIP=m
|
CONFIG_NET_IPIP=m
|
||||||
# CONFIG_NET_IPGRE_DEMUX is not set
|
CONFIG_NET_IPGRE_DEMUX=m
|
||||||
|
CONFIG_NET_IPGRE=m
|
||||||
|
CONFIG_NET_IPGRE_BROADCAST=y
|
||||||
CONFIG_IP_MROUTE=y
|
CONFIG_IP_MROUTE=y
|
||||||
# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set
|
# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set
|
||||||
# CONFIG_IP_PIMSM_V1 is not set
|
# CONFIG_IP_PIMSM_V1 is not set
|
||||||
|
@ -1223,26 +1225,27 @@ CONFIG_ISCSI_TCP=m
|
||||||
# CONFIG_SCSI_OSD_INITIATOR is not set
|
# CONFIG_SCSI_OSD_INITIATOR is not set
|
||||||
# CONFIG_ATA is not set
|
# CONFIG_ATA is not set
|
||||||
CONFIG_MD=y
|
CONFIG_MD=y
|
||||||
CONFIG_BLK_DEV_MD=m
|
CONFIG_BLK_DEV_MD=y
|
||||||
CONFIG_MD_LINEAR=m
|
CONFIG_MD_AUTODETECT=y
|
||||||
CONFIG_MD_RAID0=m
|
CONFIG_MD_LINEAR=y
|
||||||
CONFIG_MD_RAID1=m
|
CONFIG_MD_RAID0=y
|
||||||
CONFIG_MD_RAID10=m
|
CONFIG_MD_RAID1=y
|
||||||
CONFIG_MD_RAID456=m
|
CONFIG_MD_RAID10=y
|
||||||
CONFIG_MD_MULTIPATH=m
|
CONFIG_MD_RAID456=y
|
||||||
CONFIG_MD_FAULTY=m
|
CONFIG_MD_MULTIPATH=y
|
||||||
CONFIG_BLK_DEV_DM=m
|
CONFIG_MD_FAULTY=y
|
||||||
|
CONFIG_BLK_DEV_DM=y
|
||||||
# CONFIG_DM_DEBUG is not set
|
# CONFIG_DM_DEBUG is not set
|
||||||
CONFIG_DM_CRYPT=m
|
CONFIG_DM_CRYPT=y
|
||||||
CONFIG_DM_SNAPSHOT=m
|
CONFIG_DM_SNAPSHOT=m
|
||||||
# CONFIG_DM_THIN_PROVISIONING is not set
|
# CONFIG_DM_THIN_PROVISIONING is not set
|
||||||
CONFIG_DM_MIRROR=m
|
CONFIG_DM_MIRROR=y
|
||||||
CONFIG_DM_RAID=m
|
CONFIG_DM_RAID=y
|
||||||
CONFIG_DM_LOG_USERSPACE=m
|
CONFIG_DM_LOG_USERSPACE=m
|
||||||
CONFIG_DM_ZERO=m
|
CONFIG_DM_ZERO=m
|
||||||
CONFIG_DM_MULTIPATH=m
|
CONFIG_DM_MULTIPATH=y
|
||||||
CONFIG_DM_MULTIPATH_QL=m
|
CONFIG_DM_MULTIPATH_QL=y
|
||||||
CONFIG_DM_MULTIPATH_ST=m
|
CONFIG_DM_MULTIPATH_ST=y
|
||||||
CONFIG_DM_DELAY=m
|
CONFIG_DM_DELAY=m
|
||||||
CONFIG_DM_UEVENT=y
|
CONFIG_DM_UEVENT=y
|
||||||
# CONFIG_DM_FLAKEY is not set
|
# CONFIG_DM_FLAKEY is not set
|
||||||
|
@ -1344,6 +1347,7 @@ CONFIG_PPP_FILTER=y
|
||||||
CONFIG_PPP_MPPE=m
|
CONFIG_PPP_MPPE=m
|
||||||
CONFIG_PPP_MULTILINK=y
|
CONFIG_PPP_MULTILINK=y
|
||||||
CONFIG_PPPOE=m
|
CONFIG_PPPOE=m
|
||||||
|
# CONFIG_PPTP is not set
|
||||||
# CONFIG_PPPOL2TP is not set
|
# CONFIG_PPPOL2TP is not set
|
||||||
CONFIG_PPP_ASYNC=m
|
CONFIG_PPP_ASYNC=m
|
||||||
CONFIG_PPP_SYNC_TTY=m
|
CONFIG_PPP_SYNC_TTY=m
|
||||||
|
@ -1414,6 +1418,7 @@ CONFIG_ATH9K_HTC=m
|
||||||
CONFIG_CARL9170=m
|
CONFIG_CARL9170=m
|
||||||
CONFIG_CARL9170_LEDS=y
|
CONFIG_CARL9170_LEDS=y
|
||||||
CONFIG_CARL9170_WPC=y
|
CONFIG_CARL9170_WPC=y
|
||||||
|
# CONFIG_CARL9170_HWRNG is not set
|
||||||
# CONFIG_ATH6KL is not set
|
# CONFIG_ATH6KL is not set
|
||||||
CONFIG_B43=m
|
CONFIG_B43=m
|
||||||
CONFIG_B43_SSB=y
|
CONFIG_B43_SSB=y
|
||||||
|
@ -1423,9 +1428,11 @@ CONFIG_B43_PHY_N=y
|
||||||
CONFIG_B43_PHY_LP=y
|
CONFIG_B43_PHY_LP=y
|
||||||
# CONFIG_B43_PHY_HT is not set
|
# CONFIG_B43_PHY_HT is not set
|
||||||
CONFIG_B43_LEDS=y
|
CONFIG_B43_LEDS=y
|
||||||
|
CONFIG_B43_HWRNG=y
|
||||||
# CONFIG_B43_DEBUG is not set
|
# CONFIG_B43_DEBUG is not set
|
||||||
CONFIG_B43LEGACY=m
|
CONFIG_B43LEGACY=m
|
||||||
CONFIG_B43LEGACY_LEDS=y
|
CONFIG_B43LEGACY_LEDS=y
|
||||||
|
CONFIG_B43LEGACY_HWRNG=y
|
||||||
CONFIG_B43LEGACY_DEBUG=y
|
CONFIG_B43LEGACY_DEBUG=y
|
||||||
CONFIG_B43LEGACY_DMA=y
|
CONFIG_B43LEGACY_DMA=y
|
||||||
CONFIG_B43LEGACY_PIO=y
|
CONFIG_B43LEGACY_PIO=y
|
||||||
|
@ -1618,7 +1625,11 @@ CONFIG_CONSOLE_POLL=y
|
||||||
CONFIG_TTY_PRINTK=y
|
CONFIG_TTY_PRINTK=y
|
||||||
# CONFIG_HVC_DCC is not set
|
# CONFIG_HVC_DCC is not set
|
||||||
# CONFIG_IPMI_HANDLER is not set
|
# CONFIG_IPMI_HANDLER is not set
|
||||||
# CONFIG_HW_RANDOM is not set
|
CONFIG_HW_RANDOM=m
|
||||||
|
# CONFIG_HW_RANDOM_TIMERIOMEM is not set
|
||||||
|
# CONFIG_HW_RANDOM_ATMEL is not set
|
||||||
|
# CONFIG_HW_RANDOM_EXYNOS is not set
|
||||||
|
CONFIG_HW_RANDOM_BCM2708=m
|
||||||
# CONFIG_R3964 is not set
|
# CONFIG_R3964 is not set
|
||||||
CONFIG_RAW_DRIVER=y
|
CONFIG_RAW_DRIVER=y
|
||||||
CONFIG_MAX_RAW_DEVS=256
|
CONFIG_MAX_RAW_DEVS=256
|
||||||
|
@ -1638,7 +1649,7 @@ CONFIG_I2C_MUX_GPIO=m
|
||||||
CONFIG_I2C_MUX_PCA9541=m
|
CONFIG_I2C_MUX_PCA9541=m
|
||||||
CONFIG_I2C_MUX_PCA954x=m
|
CONFIG_I2C_MUX_PCA954x=m
|
||||||
CONFIG_I2C_HELPER_AUTO=y
|
CONFIG_I2C_HELPER_AUTO=y
|
||||||
CONFIG_I2C_ALGOBIT=m
|
CONFIG_I2C_ALGOBIT=y
|
||||||
|
|
||||||
#
|
#
|
||||||
# I2C Hardware Bus support
|
# I2C Hardware Bus support
|
||||||
|
@ -1650,8 +1661,8 @@ CONFIG_I2C_ALGOBIT=m
|
||||||
CONFIG_I2C_BCM2708=m
|
CONFIG_I2C_BCM2708=m
|
||||||
CONFIG_I2C_BCM2708_BAUDRATE=100000
|
CONFIG_I2C_BCM2708_BAUDRATE=100000
|
||||||
# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
|
# CONFIG_I2C_DESIGNWARE_PLATFORM is not set
|
||||||
CONFIG_I2C_GPIO=m
|
CONFIG_I2C_GPIO=y
|
||||||
CONFIG_I2C_NOMADIK=m
|
CONFIG_I2C_NOMADIK=y
|
||||||
# CONFIG_I2C_OCORES is not set
|
# CONFIG_I2C_OCORES is not set
|
||||||
# CONFIG_I2C_PCA_PLATFORM is not set
|
# CONFIG_I2C_PCA_PLATFORM is not set
|
||||||
# CONFIG_I2C_PXA_PCI is not set
|
# CONFIG_I2C_PXA_PCI is not set
|
||||||
|
@ -2932,7 +2943,7 @@ CONFIG_RTC_DRV_RS5C372=m
|
||||||
CONFIG_RTC_DRV_ISL1208=m
|
CONFIG_RTC_DRV_ISL1208=m
|
||||||
CONFIG_RTC_DRV_ISL12022=m
|
CONFIG_RTC_DRV_ISL12022=m
|
||||||
CONFIG_RTC_DRV_X1205=m
|
CONFIG_RTC_DRV_X1205=m
|
||||||
CONFIG_RTC_DRV_PCF8523=y
|
CONFIG_RTC_DRV_PCF8523=m
|
||||||
CONFIG_RTC_DRV_PCF8563=m
|
CONFIG_RTC_DRV_PCF8563=m
|
||||||
CONFIG_RTC_DRV_PCF8583=m
|
CONFIG_RTC_DRV_PCF8583=m
|
||||||
CONFIG_RTC_DRV_M41T80=m
|
CONFIG_RTC_DRV_M41T80=m
|
||||||
|
@ -3085,18 +3096,18 @@ CONFIG_EXT4_FS_SECURITY=y
|
||||||
CONFIG_JBD2=y
|
CONFIG_JBD2=y
|
||||||
# CONFIG_JBD2_DEBUG is not set
|
# CONFIG_JBD2_DEBUG is not set
|
||||||
CONFIG_FS_MBCACHE=y
|
CONFIG_FS_MBCACHE=y
|
||||||
CONFIG_REISERFS_FS=m
|
CONFIG_REISERFS_FS=y
|
||||||
# CONFIG_REISERFS_CHECK is not set
|
# CONFIG_REISERFS_CHECK is not set
|
||||||
# CONFIG_REISERFS_PROC_INFO is not set
|
# CONFIG_REISERFS_PROC_INFO is not set
|
||||||
CONFIG_REISERFS_FS_XATTR=y
|
CONFIG_REISERFS_FS_XATTR=y
|
||||||
CONFIG_REISERFS_FS_POSIX_ACL=y
|
CONFIG_REISERFS_FS_POSIX_ACL=y
|
||||||
CONFIG_REISERFS_FS_SECURITY=y
|
CONFIG_REISERFS_FS_SECURITY=y
|
||||||
CONFIG_JFS_FS=m
|
CONFIG_JFS_FS=y
|
||||||
CONFIG_JFS_POSIX_ACL=y
|
CONFIG_JFS_POSIX_ACL=y
|
||||||
CONFIG_JFS_SECURITY=y
|
CONFIG_JFS_SECURITY=y
|
||||||
# CONFIG_JFS_DEBUG is not set
|
# CONFIG_JFS_DEBUG is not set
|
||||||
CONFIG_JFS_STATISTICS=y
|
CONFIG_JFS_STATISTICS=y
|
||||||
CONFIG_XFS_FS=m
|
CONFIG_XFS_FS=y
|
||||||
CONFIG_XFS_QUOTA=y
|
CONFIG_XFS_QUOTA=y
|
||||||
CONFIG_XFS_POSIX_ACL=y
|
CONFIG_XFS_POSIX_ACL=y
|
||||||
CONFIG_XFS_RT=y
|
CONFIG_XFS_RT=y
|
||||||
|
@ -3441,12 +3452,12 @@ CONFIG_SECURITY_NETWORK_XFRM=y
|
||||||
# CONFIG_EVM is not set
|
# CONFIG_EVM is not set
|
||||||
CONFIG_DEFAULT_SECURITY_DAC=y
|
CONFIG_DEFAULT_SECURITY_DAC=y
|
||||||
CONFIG_DEFAULT_SECURITY=""
|
CONFIG_DEFAULT_SECURITY=""
|
||||||
CONFIG_XOR_BLOCKS=m
|
CONFIG_XOR_BLOCKS=y
|
||||||
CONFIG_ASYNC_CORE=m
|
CONFIG_ASYNC_CORE=y
|
||||||
CONFIG_ASYNC_MEMCPY=m
|
CONFIG_ASYNC_MEMCPY=y
|
||||||
CONFIG_ASYNC_XOR=m
|
CONFIG_ASYNC_XOR=y
|
||||||
CONFIG_ASYNC_PQ=m
|
CONFIG_ASYNC_PQ=y
|
||||||
CONFIG_ASYNC_RAID6_RECOV=m
|
CONFIG_ASYNC_RAID6_RECOV=y
|
||||||
CONFIG_CRYPTO=y
|
CONFIG_CRYPTO=y
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -3557,7 +3568,7 @@ CONFIG_BINARY_PRINTF=y
|
||||||
#
|
#
|
||||||
# Library routines
|
# Library routines
|
||||||
#
|
#
|
||||||
CONFIG_RAID6_PQ=m
|
CONFIG_RAID6_PQ=y
|
||||||
CONFIG_BITREVERSE=y
|
CONFIG_BITREVERSE=y
|
||||||
CONFIG_GENERIC_STRNCPY_FROM_USER=y
|
CONFIG_GENERIC_STRNCPY_FROM_USER=y
|
||||||
CONFIG_GENERIC_STRNLEN_USER=y
|
CONFIG_GENERIC_STRNLEN_USER=y
|
||||||
|
|
|
@ -1,289 +0,0 @@
|
||||||
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
|
|
||||||
index 53eb4e5..0a22dbd 100644
|
|
||||||
--- a/drivers/rtc/Kconfig
|
|
||||||
+++ b/drivers/rtc/Kconfig
|
|
||||||
@@ -249,6 +249,15 @@ config RTC_DRV_X1205
|
|
||||||
This driver can also be built as a module. If so, the module
|
|
||||||
will be called rtc-x1205.
|
|
||||||
|
|
||||||
+config RTC_DRV_PCF8523
|
|
||||||
+ tristate "NXP PCF8523"
|
|
||||||
+ help
|
|
||||||
+ If you say yes here you get support for the
|
|
||||||
+ NXP PCF8523 RTC chip.
|
|
||||||
+
|
|
||||||
+ This driver can also be built as a module. If so, the module
|
|
||||||
+ will be called rtc-pcf8523.
|
|
||||||
+
|
|
||||||
config RTC_DRV_PCF8563
|
|
||||||
tristate "Philips PCF8563/Epson RTC8564"
|
|
||||||
help
|
|
||||||
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
|
|
||||||
index 6e69823..7812730 100644
|
|
||||||
--- a/drivers/rtc/Makefile
|
|
||||||
+++ b/drivers/rtc/Makefile
|
|
||||||
@@ -71,6 +71,7 @@ obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o
|
|
||||||
obj-$(CONFIG_RTC_DRV_NUC900) += rtc-nuc900.o
|
|
||||||
obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
|
|
||||||
obj-$(CONFIG_RTC_DRV_PCAP) += rtc-pcap.o
|
|
||||||
+obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o
|
|
||||||
obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
|
|
||||||
obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
|
|
||||||
obj-$(CONFIG_RTC_DRV_PCF2123) += rtc-pcf2123.o
|
|
||||||
diff --git a/drivers/rtc/rtc-pcf8523.c b/drivers/rtc/rtc-pcf8523.c
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..9880c42
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/drivers/rtc/rtc-pcf8523.c
|
|
||||||
@@ -0,0 +1,251 @@
|
|
||||||
+/*
|
|
||||||
+ * An I2C driver for the NXP PCF8523 RTC
|
|
||||||
+ * Copyright 2011 Promwad Innovation Company
|
|
||||||
+ *
|
|
||||||
+ * Author: Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>
|
|
||||||
+ * Promwad Innovation Company, http://promwad.com/
|
|
||||||
+ *
|
|
||||||
+ * based on the pcf8563 driver
|
|
||||||
+ *
|
|
||||||
+ * 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/i2c.h>
|
|
||||||
+#include <linux/bcd.h>
|
|
||||||
+#include <linux/rtc.h>
|
|
||||||
+#include <linux/slab.h>
|
|
||||||
+#include <linux/module.h>
|
|
||||||
+
|
|
||||||
+#define DRV_VERSION "1.0"
|
|
||||||
+
|
|
||||||
+#define PCF8523_REG_CTL1 0x00 /* control and status registers */
|
|
||||||
+#define PCF8523_REG_CTL2 0x01
|
|
||||||
+#define PCF8523_REG_CTL3 0x02
|
|
||||||
+
|
|
||||||
+#define PCF8523_REG_SC 0x03 /* datetime */
|
|
||||||
+#define PCF8523_REG_MN 0x04
|
|
||||||
+#define PCF8523_REG_HR 0x05
|
|
||||||
+#define PCF8523_REG_DM 0x06
|
|
||||||
+#define PCF8523_REG_DW 0x07
|
|
||||||
+#define PCF8523_REG_MO 0x08
|
|
||||||
+#define PCF8523_REG_YR 0x09
|
|
||||||
+
|
|
||||||
+#define PCF8523_REG_AMN 0x0A /* alarm */
|
|
||||||
+#define PCF8523_REG_AHR 0x0B
|
|
||||||
+#define PCF8523_REG_ADM 0x0C
|
|
||||||
+#define PCF8523_REG_ADW 0x0D
|
|
||||||
+
|
|
||||||
+#define PCF8523_REG_CLKO 0x0F /* clock out */
|
|
||||||
+#define PCF8523_REG_TMRAC 0x10 /* timer control */
|
|
||||||
+#define PCF8523_REG_TMRA 0x11 /* timer */
|
|
||||||
+#define PCF8523_REG_TMRBC 0x12 /* timer control */
|
|
||||||
+#define PCF8523_REG_TMRB 0x13 /* timer */
|
|
||||||
+
|
|
||||||
+#define PCF8523_CTL3_BLF (1 << 2)
|
|
||||||
+
|
|
||||||
+static struct i2c_driver pcf8523_driver;
|
|
||||||
+
|
|
||||||
+struct pcf8523 {
|
|
||||||
+ struct rtc_device *rtc;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * In the routines that deal directly with the pcf8523 hardware, we use
|
|
||||||
+ * rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
|
|
||||||
+ */
|
|
||||||
+static int pcf8523_get_datetime(struct i2c_client *client, struct rtc_time *tm)
|
|
||||||
+{
|
|
||||||
+ /* struct pcf8523 *pcf8523 = i2c_get_clientdata(client); */
|
|
||||||
+ unsigned char buf[14] = { PCF8523_REG_CTL1 };
|
|
||||||
+
|
|
||||||
+ struct i2c_msg msgs[] = {
|
|
||||||
+ { client->addr, 0, 1, buf }, /* setup read ptr */
|
|
||||||
+ { client->addr, I2C_M_RD, 14, buf }, /* read status + date */
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ /* read registers */
|
|
||||||
+ if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
|
|
||||||
+ dev_err(&client->dev, "%s: read error\n", __func__);
|
|
||||||
+ return -EIO;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (buf[PCF8523_REG_CTL3] & PCF8523_CTL3_BLF)
|
|
||||||
+ dev_info(&client->dev,
|
|
||||||
+ "low voltage detected, date/time is not reliable.\n");
|
|
||||||
+
|
|
||||||
+ dev_dbg(&client->dev,
|
|
||||||
+ "%s: raw data is ctl1=%02x, ctl2=%02x, ctl3=%02x, "
|
|
||||||
+ "sec=%02x, min=%02x, hr=%02x, "
|
|
||||||
+ "mday=%02x, wday=%02x, mon=%02x, year=%02x\n",
|
|
||||||
+ __func__,
|
|
||||||
+ buf[0], buf[1], buf[2], buf[3],
|
|
||||||
+ buf[4], buf[5], buf[6], buf[7],
|
|
||||||
+ buf[8], buf[9]);
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ tm->tm_sec = bcd2bin(buf[PCF8523_REG_SC] & 0x7F);
|
|
||||||
+ tm->tm_min = bcd2bin(buf[PCF8523_REG_MN] & 0x7F);
|
|
||||||
+ tm->tm_hour = bcd2bin(buf[PCF8523_REG_HR] & 0x3F); /* rtc hr 0-23 */
|
|
||||||
+ tm->tm_mday = bcd2bin(buf[PCF8523_REG_DM] & 0x3F);
|
|
||||||
+ tm->tm_wday = buf[PCF8523_REG_DW] & 0x07;
|
|
||||||
+ tm->tm_mon = bcd2bin(buf[PCF8523_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */
|
|
||||||
+ tm->tm_year = bcd2bin(buf[PCF8523_REG_YR]);
|
|
||||||
+ if (tm->tm_year < 70)
|
|
||||||
+ tm->tm_year += 100; /* assume we are in 1970...2069 */
|
|
||||||
+
|
|
||||||
+ dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
|
|
||||||
+ "mday=%d, mon=%d, year=%d, wday=%d\n",
|
|
||||||
+ __func__,
|
|
||||||
+ tm->tm_sec, tm->tm_min, tm->tm_hour,
|
|
||||||
+ tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
|
|
||||||
+
|
|
||||||
+ /* the clock can give out invalid datetime, but we cannot return
|
|
||||||
+ * -EINVAL otherwise hwclock will refuse to set the time on bootup.
|
|
||||||
+ */
|
|
||||||
+ if (rtc_valid_tm(tm) < 0)
|
|
||||||
+ dev_err(&client->dev, "retrieved date/time is not valid.\n");
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int pcf8523_set_datetime(struct i2c_client *client, struct rtc_time *tm)
|
|
||||||
+{
|
|
||||||
+ /* struct pcf8523 *pcf8523 = i2c_get_clientdata(client); */
|
|
||||||
+ int i, err;
|
|
||||||
+ unsigned char buf[10];
|
|
||||||
+
|
|
||||||
+ dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "
|
|
||||||
+ "mday=%d, mon=%d, year=%d, wday=%d\n",
|
|
||||||
+ __func__,
|
|
||||||
+ tm->tm_sec, tm->tm_min, tm->tm_hour,
|
|
||||||
+ tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
|
|
||||||
+
|
|
||||||
+ /* hours, minutes and seconds */
|
|
||||||
+ buf[PCF8523_REG_SC] = bin2bcd(tm->tm_sec);
|
|
||||||
+ buf[PCF8523_REG_MN] = bin2bcd(tm->tm_min);
|
|
||||||
+ buf[PCF8523_REG_HR] = bin2bcd(tm->tm_hour);
|
|
||||||
+
|
|
||||||
+ buf[PCF8523_REG_DM] = bin2bcd(tm->tm_mday);
|
|
||||||
+
|
|
||||||
+ /* month, 1 - 12 */
|
|
||||||
+ buf[PCF8523_REG_MO] = bin2bcd(tm->tm_mon + 1);
|
|
||||||
+
|
|
||||||
+ /* year and century */
|
|
||||||
+ buf[PCF8523_REG_YR] = bin2bcd(tm->tm_year % 100);
|
|
||||||
+
|
|
||||||
+ buf[PCF8523_REG_DW] = tm->tm_wday & 0x07;
|
|
||||||
+
|
|
||||||
+ /* write register's data */
|
|
||||||
+ for (i = 0; i < 7; i++) {
|
|
||||||
+ unsigned char data[2] = { PCF8523_REG_SC + i,
|
|
||||||
+ buf[PCF8523_REG_SC + i] };
|
|
||||||
+
|
|
||||||
+ err = i2c_master_send(client, data, sizeof(data));
|
|
||||||
+ if (err != sizeof(data)) {
|
|
||||||
+ dev_err(&client->dev,
|
|
||||||
+ "%s: err=%d addr=%02x, data=%02x\n",
|
|
||||||
+ __func__, err, data[0], data[1]);
|
|
||||||
+ return -EIO;
|
|
||||||
+ }
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int pcf8523_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
|
||||||
+{
|
|
||||||
+ return pcf8523_get_datetime(to_i2c_client(dev), tm);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int pcf8523_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
|
||||||
+{
|
|
||||||
+ return pcf8523_set_datetime(to_i2c_client(dev), tm);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const struct rtc_class_ops pcf8523_rtc_ops = {
|
|
||||||
+ .read_time = pcf8523_rtc_read_time,
|
|
||||||
+ .set_time = pcf8523_rtc_set_time,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static int pcf8523_probe(struct i2c_client *client,
|
|
||||||
+ const struct i2c_device_id *id)
|
|
||||||
+{
|
|
||||||
+ struct pcf8523 *pcf8523;
|
|
||||||
+
|
|
||||||
+ int err = 0;
|
|
||||||
+
|
|
||||||
+ dev_dbg(&client->dev, "%s\n", __func__);
|
|
||||||
+
|
|
||||||
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
|
||||||
+ return -ENODEV;
|
|
||||||
+
|
|
||||||
+ pcf8523 = kzalloc(sizeof(struct pcf8523), GFP_KERNEL);
|
|
||||||
+ if (!pcf8523)
|
|
||||||
+ return -ENOMEM;
|
|
||||||
+
|
|
||||||
+ dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
|
|
||||||
+
|
|
||||||
+ i2c_set_clientdata(client, pcf8523);
|
|
||||||
+
|
|
||||||
+ pcf8523->rtc = rtc_device_register(pcf8523_driver.driver.name,
|
|
||||||
+ &client->dev, &pcf8523_rtc_ops, THIS_MODULE);
|
|
||||||
+
|
|
||||||
+ if (IS_ERR(pcf8523->rtc)) {
|
|
||||||
+ err = PTR_ERR(pcf8523->rtc);
|
|
||||||
+ goto exit_kfree;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+
|
|
||||||
+exit_kfree:
|
|
||||||
+ kfree(pcf8523);
|
|
||||||
+
|
|
||||||
+ return err;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int pcf8523_remove(struct i2c_client *client)
|
|
||||||
+{
|
|
||||||
+ struct pcf8523 *pcf8523 = i2c_get_clientdata(client);
|
|
||||||
+
|
|
||||||
+ if (pcf8523->rtc)
|
|
||||||
+ rtc_device_unregister(pcf8523->rtc);
|
|
||||||
+
|
|
||||||
+ kfree(pcf8523);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static const struct i2c_device_id pcf8523_id[] = {
|
|
||||||
+ { "pcf8523", 0 },
|
|
||||||
+ { }
|
|
||||||
+};
|
|
||||||
+MODULE_DEVICE_TABLE(i2c, pcf8523_id);
|
|
||||||
+
|
|
||||||
+static struct i2c_driver pcf8523_driver = {
|
|
||||||
+ .driver = {
|
|
||||||
+ .name = "rtc-pcf8523",
|
|
||||||
+ },
|
|
||||||
+ .probe = pcf8523_probe,
|
|
||||||
+ .remove = pcf8523_remove,
|
|
||||||
+ .id_table = pcf8523_id,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static int __init pcf8523_init(void)
|
|
||||||
+{
|
|
||||||
+ return i2c_add_driver(&pcf8523_driver);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void __exit pcf8523_exit(void)
|
|
||||||
+{
|
|
||||||
+ i2c_del_driver(&pcf8523_driver);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+MODULE_AUTHOR("Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>");
|
|
||||||
+MODULE_DESCRIPTION("NXP PCF8523");
|
|
||||||
+MODULE_LICENSE("GPL");
|
|
||||||
+MODULE_VERSION(DRV_VERSION);
|
|
||||||
+
|
|
||||||
+module_init(pcf8523_init);
|
|
||||||
+module_exit(pcf8523_exit);
|
|
Loading…
Reference in a new issue