2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2006-06-25 20:48:24 +08:00
|
|
|
/* drivers/rtc/rtc-v3020.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 8D Technologies inc.
|
|
|
|
* Copyright (C) 2004 Compulab Ltd.
|
|
|
|
*
|
|
|
|
* Driver for the V3020 RTC
|
|
|
|
*
|
|
|
|
* Changelog:
|
|
|
|
*
|
|
|
|
* 10-May-2006: Raphael Assenat <raph@8d.com>
|
|
|
|
* - Converted to platform driver
|
|
|
|
* - Use the generic rtc class
|
|
|
|
*
|
|
|
|
* ??-???-2004: Someone at Compulab
|
2013-07-04 06:06:05 +08:00
|
|
|
* - Initial driver creation.
|
2006-06-25 20:48:24 +08:00
|
|
|
*/
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/rtc.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/bcd.h>
|
2016-06-27 06:03:03 +08:00
|
|
|
#include <linux/platform_data/rtc-v3020.h>
|
2007-09-12 06:23:45 +08:00
|
|
|
#include <linux/delay.h>
|
2009-04-03 07:57:01 +08:00
|
|
|
#include <linux/gpio.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2006-06-25 20:48:24 +08:00
|
|
|
|
2009-04-01 06:24:59 +08:00
|
|
|
#include <linux/io.h>
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
2009-04-03 07:57:01 +08:00
|
|
|
struct v3020;
|
|
|
|
|
|
|
|
struct v3020_chip_ops {
|
|
|
|
int (*map_io)(struct v3020 *chip, struct platform_device *pdev,
|
|
|
|
struct v3020_platform_data *pdata);
|
|
|
|
void (*unmap_io)(struct v3020 *chip);
|
|
|
|
unsigned char (*read_bit)(struct v3020 *chip);
|
|
|
|
void (*write_bit)(struct v3020 *chip, unsigned char bit);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define V3020_CS 0
|
|
|
|
#define V3020_WR 1
|
|
|
|
#define V3020_RD 2
|
|
|
|
#define V3020_IO 3
|
|
|
|
|
2006-06-25 20:48:24 +08:00
|
|
|
struct v3020 {
|
2009-04-03 07:57:01 +08:00
|
|
|
/* MMIO access */
|
2006-06-25 20:48:24 +08:00
|
|
|
void __iomem *ioaddress;
|
|
|
|
int leftshift;
|
2009-04-03 07:57:01 +08:00
|
|
|
|
|
|
|
/* GPIO access */
|
2013-02-22 10:19:15 +08:00
|
|
|
struct gpio *gpio;
|
2009-04-03 07:57:01 +08:00
|
|
|
|
2015-12-12 01:50:50 +08:00
|
|
|
const struct v3020_chip_ops *ops;
|
2009-04-03 07:57:01 +08:00
|
|
|
|
2006-06-25 20:48:24 +08:00
|
|
|
struct rtc_device *rtc;
|
|
|
|
};
|
|
|
|
|
2009-04-03 07:57:01 +08:00
|
|
|
|
|
|
|
static int v3020_mmio_map(struct v3020 *chip, struct platform_device *pdev,
|
|
|
|
struct v3020_platform_data *pdata)
|
|
|
|
{
|
|
|
|
if (pdev->num_resources != 1)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
if (pdev->resource[0].flags != IORESOURCE_MEM)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
chip->leftshift = pdata->leftshift;
|
|
|
|
chip->ioaddress = ioremap(pdev->resource[0].start, 1);
|
|
|
|
if (chip->ioaddress == NULL)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void v3020_mmio_unmap(struct v3020 *chip)
|
|
|
|
{
|
|
|
|
iounmap(chip->ioaddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void v3020_mmio_write_bit(struct v3020 *chip, unsigned char bit)
|
|
|
|
{
|
|
|
|
writel(bit << chip->leftshift, chip->ioaddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char v3020_mmio_read_bit(struct v3020 *chip)
|
|
|
|
{
|
2009-11-12 06:26:49 +08:00
|
|
|
return !!(readl(chip->ioaddress) & (1 << chip->leftshift));
|
2009-04-03 07:57:01 +08:00
|
|
|
}
|
|
|
|
|
2015-12-12 01:50:50 +08:00
|
|
|
static const struct v3020_chip_ops v3020_mmio_ops = {
|
2009-04-03 07:57:01 +08:00
|
|
|
.map_io = v3020_mmio_map,
|
|
|
|
.unmap_io = v3020_mmio_unmap,
|
|
|
|
.read_bit = v3020_mmio_read_bit,
|
|
|
|
.write_bit = v3020_mmio_write_bit,
|
|
|
|
};
|
|
|
|
|
2013-02-22 10:19:15 +08:00
|
|
|
static struct gpio v3020_gpio[] = {
|
|
|
|
{ 0, GPIOF_OUT_INIT_HIGH, "RTC CS"},
|
|
|
|
{ 0, GPIOF_OUT_INIT_HIGH, "RTC WR"},
|
|
|
|
{ 0, GPIOF_OUT_INIT_HIGH, "RTC RD"},
|
|
|
|
{ 0, GPIOF_OUT_INIT_HIGH, "RTC IO"},
|
2009-04-03 07:57:01 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int v3020_gpio_map(struct v3020 *chip, struct platform_device *pdev,
|
|
|
|
struct v3020_platform_data *pdata)
|
|
|
|
{
|
2013-02-22 10:19:15 +08:00
|
|
|
int err;
|
2009-04-03 07:57:01 +08:00
|
|
|
|
|
|
|
v3020_gpio[V3020_CS].gpio = pdata->gpio_cs;
|
|
|
|
v3020_gpio[V3020_WR].gpio = pdata->gpio_wr;
|
|
|
|
v3020_gpio[V3020_RD].gpio = pdata->gpio_rd;
|
|
|
|
v3020_gpio[V3020_IO].gpio = pdata->gpio_io;
|
|
|
|
|
2013-02-22 10:19:15 +08:00
|
|
|
err = gpio_request_array(v3020_gpio, ARRAY_SIZE(v3020_gpio));
|
2009-04-03 07:57:01 +08:00
|
|
|
|
2013-02-22 10:19:15 +08:00
|
|
|
if (!err)
|
|
|
|
chip->gpio = v3020_gpio;
|
2009-04-03 07:57:01 +08:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void v3020_gpio_unmap(struct v3020 *chip)
|
|
|
|
{
|
2013-02-22 10:19:15 +08:00
|
|
|
gpio_free_array(v3020_gpio, ARRAY_SIZE(v3020_gpio));
|
2009-04-03 07:57:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void v3020_gpio_write_bit(struct v3020 *chip, unsigned char bit)
|
|
|
|
{
|
|
|
|
gpio_direction_output(chip->gpio[V3020_IO].gpio, bit);
|
|
|
|
gpio_set_value(chip->gpio[V3020_CS].gpio, 0);
|
|
|
|
gpio_set_value(chip->gpio[V3020_WR].gpio, 0);
|
|
|
|
udelay(1);
|
|
|
|
gpio_set_value(chip->gpio[V3020_WR].gpio, 1);
|
|
|
|
gpio_set_value(chip->gpio[V3020_CS].gpio, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char v3020_gpio_read_bit(struct v3020 *chip)
|
|
|
|
{
|
|
|
|
int bit;
|
|
|
|
|
|
|
|
gpio_direction_input(chip->gpio[V3020_IO].gpio);
|
|
|
|
gpio_set_value(chip->gpio[V3020_CS].gpio, 0);
|
|
|
|
gpio_set_value(chip->gpio[V3020_RD].gpio, 0);
|
|
|
|
udelay(1);
|
|
|
|
bit = !!gpio_get_value(chip->gpio[V3020_IO].gpio);
|
|
|
|
udelay(1);
|
|
|
|
gpio_set_value(chip->gpio[V3020_RD].gpio, 1);
|
|
|
|
gpio_set_value(chip->gpio[V3020_CS].gpio, 1);
|
|
|
|
|
|
|
|
return bit;
|
|
|
|
}
|
|
|
|
|
2015-12-12 01:50:50 +08:00
|
|
|
static const struct v3020_chip_ops v3020_gpio_ops = {
|
2009-04-03 07:57:01 +08:00
|
|
|
.map_io = v3020_gpio_map,
|
|
|
|
.unmap_io = v3020_gpio_unmap,
|
|
|
|
.read_bit = v3020_gpio_read_bit,
|
|
|
|
.write_bit = v3020_gpio_write_bit,
|
|
|
|
};
|
|
|
|
|
2006-06-25 20:48:24 +08:00
|
|
|
static void v3020_set_reg(struct v3020 *chip, unsigned char address,
|
|
|
|
unsigned char data)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned char tmp;
|
|
|
|
|
|
|
|
tmp = address;
|
|
|
|
for (i = 0; i < 4; i++) {
|
2009-04-03 07:57:01 +08:00
|
|
|
chip->ops->write_bit(chip, (tmp & 1));
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp >>= 1;
|
2007-09-12 06:23:45 +08:00
|
|
|
udelay(1);
|
2006-06-25 20:48:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Commands dont have data */
|
|
|
|
if (!V3020_IS_COMMAND(address)) {
|
|
|
|
for (i = 0; i < 8; i++) {
|
2009-04-03 07:57:01 +08:00
|
|
|
chip->ops->write_bit(chip, (data & 1));
|
2006-06-25 20:48:24 +08:00
|
|
|
data >>= 1;
|
2007-09-12 06:23:45 +08:00
|
|
|
udelay(1);
|
2006-06-25 20:48:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char v3020_get_reg(struct v3020 *chip, unsigned char address)
|
|
|
|
{
|
2009-04-01 06:24:59 +08:00
|
|
|
unsigned int data = 0;
|
2006-06-25 20:48:24 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
2009-04-03 07:57:01 +08:00
|
|
|
chip->ops->write_bit(chip, (address & 1));
|
2006-06-25 20:48:24 +08:00
|
|
|
address >>= 1;
|
2007-09-12 06:23:45 +08:00
|
|
|
udelay(1);
|
2006-06-25 20:48:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
data >>= 1;
|
2009-04-03 07:57:01 +08:00
|
|
|
if (chip->ops->read_bit(chip))
|
2006-06-25 20:48:24 +08:00
|
|
|
data |= 0x80;
|
2007-09-12 06:23:45 +08:00
|
|
|
udelay(1);
|
2006-06-25 20:48:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int v3020_read_time(struct device *dev, struct rtc_time *dt)
|
|
|
|
{
|
|
|
|
struct v3020 *chip = dev_get_drvdata(dev);
|
|
|
|
int tmp;
|
|
|
|
|
|
|
|
/* Copy the current time to ram... */
|
|
|
|
v3020_set_reg(chip, V3020_CMD_CLOCK2RAM, 0);
|
|
|
|
|
|
|
|
/* ...and then read constant values. */
|
|
|
|
tmp = v3020_get_reg(chip, V3020_SECONDS);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_sec = bcd2bin(tmp);
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp = v3020_get_reg(chip, V3020_MINUTES);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_min = bcd2bin(tmp);
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp = v3020_get_reg(chip, V3020_HOURS);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_hour = bcd2bin(tmp);
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp = v3020_get_reg(chip, V3020_MONTH_DAY);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_mday = bcd2bin(tmp);
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp = v3020_get_reg(chip, V3020_MONTH);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_mon = bcd2bin(tmp) - 1;
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp = v3020_get_reg(chip, V3020_WEEK_DAY);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_wday = bcd2bin(tmp);
|
2006-06-25 20:48:24 +08:00
|
|
|
tmp = v3020_get_reg(chip, V3020_YEAR);
|
2008-10-19 11:28:41 +08:00
|
|
|
dt->tm_year = bcd2bin(tmp)+100;
|
2006-06-25 20:48:24 +08:00
|
|
|
|
2009-04-01 06:24:59 +08:00
|
|
|
dev_dbg(dev, "\n%s : Read RTC values\n", __func__);
|
|
|
|
dev_dbg(dev, "tm_hour: %i\n", dt->tm_hour);
|
|
|
|
dev_dbg(dev, "tm_min : %i\n", dt->tm_min);
|
|
|
|
dev_dbg(dev, "tm_sec : %i\n", dt->tm_sec);
|
|
|
|
dev_dbg(dev, "tm_year: %i\n", dt->tm_year);
|
|
|
|
dev_dbg(dev, "tm_mon : %i\n", dt->tm_mon);
|
|
|
|
dev_dbg(dev, "tm_mday: %i\n", dt->tm_mday);
|
|
|
|
dev_dbg(dev, "tm_wday: %i\n", dt->tm_wday);
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int v3020_set_time(struct device *dev, struct rtc_time *dt)
|
|
|
|
{
|
|
|
|
struct v3020 *chip = dev_get_drvdata(dev);
|
|
|
|
|
2009-04-01 06:24:59 +08:00
|
|
|
dev_dbg(dev, "\n%s : Setting RTC values\n", __func__);
|
|
|
|
dev_dbg(dev, "tm_sec : %i\n", dt->tm_sec);
|
|
|
|
dev_dbg(dev, "tm_min : %i\n", dt->tm_min);
|
|
|
|
dev_dbg(dev, "tm_hour: %i\n", dt->tm_hour);
|
|
|
|
dev_dbg(dev, "tm_mday: %i\n", dt->tm_mday);
|
|
|
|
dev_dbg(dev, "tm_wday: %i\n", dt->tm_wday);
|
|
|
|
dev_dbg(dev, "tm_year: %i\n", dt->tm_year);
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
/* Write all the values to ram... */
|
2013-07-04 06:06:05 +08:00
|
|
|
v3020_set_reg(chip, V3020_SECONDS, bin2bcd(dt->tm_sec));
|
|
|
|
v3020_set_reg(chip, V3020_MINUTES, bin2bcd(dt->tm_min));
|
|
|
|
v3020_set_reg(chip, V3020_HOURS, bin2bcd(dt->tm_hour));
|
2008-10-19 11:28:41 +08:00
|
|
|
v3020_set_reg(chip, V3020_MONTH_DAY, bin2bcd(dt->tm_mday));
|
2013-07-04 06:06:05 +08:00
|
|
|
v3020_set_reg(chip, V3020_MONTH, bin2bcd(dt->tm_mon + 1));
|
|
|
|
v3020_set_reg(chip, V3020_WEEK_DAY, bin2bcd(dt->tm_wday));
|
|
|
|
v3020_set_reg(chip, V3020_YEAR, bin2bcd(dt->tm_year % 100));
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
/* ...and set the clock. */
|
|
|
|
v3020_set_reg(chip, V3020_CMD_RAM2CLOCK, 0);
|
|
|
|
|
|
|
|
/* Compulab used this delay here. I dont know why,
|
|
|
|
* the datasheet does not specify a delay. */
|
|
|
|
/*mdelay(5);*/
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-01 14:28:17 +08:00
|
|
|
static const struct rtc_class_ops v3020_rtc_ops = {
|
2006-06-25 20:48:24 +08:00
|
|
|
.read_time = v3020_read_time,
|
|
|
|
.set_time = v3020_set_time,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int rtc_probe(struct platform_device *pdev)
|
|
|
|
{
|
2013-11-13 07:10:53 +08:00
|
|
|
struct v3020_platform_data *pdata = dev_get_platdata(&pdev->dev);
|
2006-06-25 20:48:24 +08:00
|
|
|
struct v3020 *chip;
|
2021-06-09 20:00:50 +08:00
|
|
|
int retval;
|
2006-06-25 20:48:24 +08:00
|
|
|
int i;
|
|
|
|
|
2013-04-30 07:20:56 +08:00
|
|
|
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
2006-06-25 20:48:24 +08:00
|
|
|
if (!chip)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2009-04-03 07:57:01 +08:00
|
|
|
if (pdata->use_gpio)
|
|
|
|
chip->ops = &v3020_gpio_ops;
|
|
|
|
else
|
|
|
|
chip->ops = &v3020_mmio_ops;
|
|
|
|
|
|
|
|
retval = chip->ops->map_io(chip, pdev, pdata);
|
|
|
|
if (retval)
|
2013-07-04 06:05:41 +08:00
|
|
|
return retval;
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
/* Make sure the v3020 expects a communication cycle
|
|
|
|
* by reading 8 times */
|
|
|
|
for (i = 0; i < 8; i++)
|
2019-11-22 18:22:12 +08:00
|
|
|
chip->ops->read_bit(chip);
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
/* Test chip by doing a write/read sequence
|
|
|
|
* to the chip ram */
|
|
|
|
v3020_set_reg(chip, V3020_SECONDS, 0x33);
|
2009-04-01 06:24:59 +08:00
|
|
|
if (v3020_get_reg(chip, V3020_SECONDS) != 0x33) {
|
2006-06-25 20:48:24 +08:00
|
|
|
retval = -ENODEV;
|
|
|
|
goto err_io;
|
|
|
|
}
|
|
|
|
|
tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-11-14 23:09:05 +08:00
|
|
|
/* Make sure frequency measurement mode, test modes, and lock
|
2006-06-25 20:48:24 +08:00
|
|
|
* are all disabled */
|
|
|
|
v3020_set_reg(chip, V3020_STATUS_0, 0x0);
|
|
|
|
|
2009-04-03 07:57:01 +08:00
|
|
|
if (pdata->use_gpio)
|
|
|
|
dev_info(&pdev->dev, "Chip available at GPIOs "
|
|
|
|
"%d, %d, %d, %d\n",
|
|
|
|
chip->gpio[V3020_CS].gpio, chip->gpio[V3020_WR].gpio,
|
|
|
|
chip->gpio[V3020_RD].gpio, chip->gpio[V3020_IO].gpio);
|
|
|
|
else
|
|
|
|
dev_info(&pdev->dev, "Chip available at "
|
|
|
|
"physical address 0x%llx,"
|
|
|
|
"data connected to D%d\n",
|
|
|
|
(unsigned long long)pdev->resource[0].start,
|
|
|
|
chip->leftshift);
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
platform_set_drvdata(pdev, chip);
|
|
|
|
|
2013-04-30 07:20:56 +08:00
|
|
|
chip->rtc = devm_rtc_device_register(&pdev->dev, "v3020",
|
|
|
|
&v3020_rtc_ops, THIS_MODULE);
|
2009-12-16 08:45:53 +08:00
|
|
|
if (IS_ERR(chip->rtc)) {
|
|
|
|
retval = PTR_ERR(chip->rtc);
|
2006-06-25 20:48:24 +08:00
|
|
|
goto err_io;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_io:
|
2009-04-03 07:57:01 +08:00
|
|
|
chip->ops->unmap_io(chip);
|
2013-07-04 06:05:41 +08:00
|
|
|
|
2006-06-25 20:48:24 +08:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtc_remove(struct platform_device *dev)
|
|
|
|
{
|
|
|
|
struct v3020 *chip = platform_get_drvdata(dev);
|
|
|
|
|
2009-04-03 07:57:01 +08:00
|
|
|
chip->ops->unmap_io(chip);
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver rtc_device_driver = {
|
|
|
|
.probe = rtc_probe,
|
|
|
|
.remove = rtc_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "v3020",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-11 07:10:48 +08:00
|
|
|
module_platform_driver(rtc_device_driver);
|
2006-06-25 20:48:24 +08:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("V3020 RTC");
|
|
|
|
MODULE_AUTHOR("Raphael Assenat");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-11 12:29:25 +08:00
|
|
|
MODULE_ALIAS("platform:v3020");
|